@d3plus/core 4.10.0 → 4.11.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 (548) hide show
  1. package/es/index.js +1 -1
  2. package/es/internal.js +167 -8
  3. package/es/src/charts/Alluvial/aggregate.js +145 -0
  4. package/es/src/charts/Alluvial/applyLayout.js +125 -0
  5. package/es/src/charts/Alluvial/dimensions.js +56 -0
  6. package/es/src/charts/Alluvial/emit.js +73 -0
  7. package/es/src/charts/Alluvial/hover.js +101 -0
  8. package/es/src/charts/Alluvial/index.js +170 -0
  9. package/es/src/charts/Alluvial/layout.js +137 -0
  10. package/es/src/charts/Alluvial/meta.js +57 -0
  11. package/es/src/charts/Alluvial/titles.js +81 -0
  12. package/es/src/charts/ArcDiagram/applyLayout.js +386 -0
  13. package/es/src/charts/ArcDiagram/arcGeometry.js +275 -0
  14. package/es/src/charts/ArcDiagram/arcLabels.js +171 -0
  15. package/es/src/charts/ArcDiagram/arcLoops.js +78 -0
  16. package/es/src/charts/ArcDiagram/emit.js +178 -0
  17. package/es/src/charts/ArcDiagram/events.js +144 -0
  18. package/es/src/charts/ArcDiagram/index.js +215 -0
  19. package/es/src/charts/BarChart/index.js +14 -2
  20. package/es/src/charts/BoxWhisker/index.js +22 -0
  21. package/es/src/charts/BubbleChart/emit.js +31 -0
  22. package/es/src/charts/BubbleChart/index.js +54 -0
  23. package/es/src/charts/Calendar/emit.js +1 -1
  24. package/es/src/charts/Calendar/index.js +3 -2
  25. package/es/src/charts/Candlestick/buffer.js +6 -4
  26. package/es/src/charts/Candlestick/index.js +2 -1
  27. package/es/src/charts/Chord/applyLayout.js +56 -69
  28. package/es/src/charts/Chord/emit.js +55 -24
  29. package/es/src/charts/Chord/index.js +14 -10
  30. package/es/src/charts/Chord/labels.js +105 -0
  31. package/es/src/charts/Donut/index.js +5 -11
  32. package/es/src/charts/Dumbbell/index.js +2 -4
  33. package/es/src/charts/Gantt/applyLayout.js +162 -0
  34. package/es/src/charts/Gantt/emit.js +142 -0
  35. package/es/src/charts/Gantt/ganttDecor.js +207 -0
  36. package/es/src/charts/Gantt/ganttGeometry.js +107 -0
  37. package/es/src/charts/Gantt/ganttLabels.js +85 -0
  38. package/es/src/charts/Gantt/ganttRows.js +111 -0
  39. package/es/src/charts/Gantt/ganttTooltip.js +136 -0
  40. package/es/src/charts/Gantt/index.js +219 -0
  41. package/es/src/charts/Geomap/applyLayout.js +90 -49
  42. package/es/src/charts/Geomap/basemapTheme.js +3 -48
  43. package/es/src/charts/Geomap/emit.js +19 -2
  44. package/es/src/charts/Geomap/flowEmit.js +132 -0
  45. package/es/src/charts/Geomap/flowEvents.js +86 -0
  46. package/es/src/charts/Geomap/flowFields.js +91 -0
  47. package/es/src/charts/Geomap/flowGeometry.js +225 -0
  48. package/es/src/charts/Geomap/flowLinks.js +239 -0
  49. package/es/src/charts/Geomap/geoCache.js +180 -0
  50. package/es/src/charts/Geomap/globeKeys.js +131 -0
  51. package/es/src/charts/Geomap/globeRotate.js +208 -0
  52. package/es/src/charts/Geomap/index.js +51 -16
  53. package/es/src/charts/Geomap/pointLabels.js +107 -0
  54. package/es/src/charts/Hexbin/binning.js +103 -0
  55. package/es/src/charts/Hexbin/buffer.js +33 -0
  56. package/es/src/charts/Hexbin/contourLabels.js +234 -0
  57. package/es/src/charts/Hexbin/contours.js +48 -0
  58. package/es/src/charts/Hexbin/emit.js +142 -0
  59. package/es/src/charts/Hexbin/index.js +204 -0
  60. package/es/src/charts/Hexbin/layers.js +212 -0
  61. package/es/src/charts/Hexbin/settings.js +86 -0
  62. package/es/src/charts/Hexbin/tooltip.js +77 -0
  63. package/es/src/charts/Histogram/binData.js +31 -4
  64. package/es/src/charts/Histogram/index.js +32 -15
  65. package/es/src/charts/Histogram/labels.js +18 -0
  66. package/es/src/charts/Icicle/index.js +3 -3
  67. package/es/src/charts/LinePlot/index.js +7 -0
  68. package/es/src/charts/Marimekko/index.js +7 -4
  69. package/es/src/charts/Network/applyLayout.js +138 -94
  70. package/es/src/charts/Network/bundle.js +81 -0
  71. package/es/src/charts/Network/clusterLabels.js +423 -0
  72. package/es/src/charts/Network/clusters.js +290 -0
  73. package/es/src/charts/Network/emit.js +253 -70
  74. package/es/src/charts/Network/graph.js +117 -0
  75. package/es/src/charts/Network/graphFluent.js +79 -0
  76. package/es/src/charts/Network/index.js +86 -106
  77. package/es/src/charts/Network/minNodeDistance.js +64 -0
  78. package/es/src/charts/Network/polygonRows.js +44 -0
  79. package/es/src/charts/Pack/index.js +5 -1
  80. package/es/src/charts/Pie/applyLayout.js +86 -27
  81. package/es/src/charts/Pie/arcFit.js +152 -0
  82. package/es/src/charts/Pie/curvedLabels.js +134 -0
  83. package/es/src/charts/Pie/emit.js +43 -96
  84. package/es/src/charts/Pie/index.js +64 -31
  85. package/es/src/charts/Pie/labelRoom.js +154 -0
  86. package/es/src/charts/Pie/outsideLabels.js +224 -0
  87. package/es/src/charts/Pie/outsideNodes.js +267 -0
  88. package/es/src/charts/Pie/pieLabels.js +137 -0
  89. package/es/src/charts/Pie/sectorBox.js +223 -0
  90. package/es/src/charts/Pie/straightLabels.js +96 -0
  91. package/es/src/charts/Pie/straightLayout.js +215 -0
  92. package/es/src/charts/Plot/alongLegend.js +76 -0
  93. package/es/src/charts/Plot/areaLabelsAlong.js +333 -0
  94. package/es/src/charts/Plot/axisHoverScene.js +2 -1
  95. package/es/src/charts/Plot/axisValues.js +43 -0
  96. package/es/src/charts/Plot/barWidth.js +59 -11
  97. package/es/src/charts/Plot/circleLabels.js +98 -0
  98. package/es/src/charts/Plot/connectGaps.js +237 -0
  99. package/es/src/charts/Plot/connectGapsScene.js +188 -0
  100. package/es/src/charts/Plot/draw.js +8 -2
  101. package/es/src/charts/Plot/fillBetween.js +2 -1
  102. package/es/src/charts/Plot/forecastScene.js +3 -4
  103. package/es/src/charts/Plot/index.js +18 -10
  104. package/es/src/charts/Plot/labelPlacement.js +1 -1
  105. package/es/src/charts/Plot/lineLabelEmit.js +82 -0
  106. package/es/src/charts/Plot/lineLabelSides.js +51 -0
  107. package/es/src/charts/Plot/lineLabelSpread.js +65 -0
  108. package/es/src/charts/Plot/lineLabelsAlong.js +282 -0
  109. package/es/src/charts/Plot/pipeline.js +66 -19
  110. package/es/src/charts/Plot/pipelineAxisLayout.js +5 -1
  111. package/es/src/charts/Plot/pipelineDomains.js +16 -3
  112. package/es/src/charts/Plot/pipelineLineLabels.js +144 -52
  113. package/es/src/charts/Plot/pipelineScales.js +40 -8
  114. package/es/src/charts/Plot/plotFacet.js +12 -1
  115. package/es/src/charts/Plot/plotInit.js +34 -5
  116. package/es/src/charts/Plot/plotRangeBreaks.js +85 -0
  117. package/es/src/charts/Plot/referenceDomains.js +133 -0
  118. package/es/src/charts/Plot/shapeDefaults.js +10 -5
  119. package/es/src/charts/Plot/stackLegendOrder.js +176 -0
  120. package/es/src/charts/Plot/trendLabels.js +183 -0
  121. package/es/src/charts/Plot/trendLines.js +1 -0
  122. package/es/src/charts/Plot/trendScene.js +6 -3
  123. package/es/src/charts/Plot/trendTooltip.js +5 -1
  124. package/es/src/charts/PolarArea/index.js +2 -2
  125. package/es/src/charts/Priestley/applyLayout.js +14 -20
  126. package/es/src/charts/Priestley/index.js +4 -35
  127. package/es/src/charts/Priestley/timeAxis.js +100 -0
  128. package/es/src/charts/Radar/axisDecorations.js +49 -12
  129. package/es/src/charts/Radar/curvedLabels.js +187 -0
  130. package/es/src/charts/Radar/index.js +2 -3
  131. package/es/src/charts/RadialBar/curvedLabels.js +111 -0
  132. package/es/src/charts/RadialBar/emit.js +4 -1
  133. package/es/src/charts/RadialBar/index.js +16 -9
  134. package/es/src/charts/RadialBar/trackLayout.js +43 -13
  135. package/es/src/charts/RadialMatrix/index.js +3 -7
  136. package/es/src/charts/Rings/applyLayout.js +41 -24
  137. package/es/src/charts/Rings/emit.js +174 -58
  138. package/es/src/charts/Rings/index.js +61 -28
  139. package/es/src/charts/Rings/ringsGraph.js +28 -9
  140. package/es/src/charts/Rings/ringsLoops.js +73 -0
  141. package/es/src/charts/Rings/ringsParallel.js +166 -0
  142. package/es/src/charts/Sankey/applyLayout.js +116 -39
  143. package/es/src/charts/Sankey/circularLayout.js +208 -0
  144. package/es/src/charts/Sankey/circularLinks.js +301 -0
  145. package/es/src/charts/Sankey/emit.js +164 -94
  146. package/es/src/charts/Sankey/index.js +72 -75
  147. package/es/src/charts/Sankey/labels.js +80 -0
  148. package/es/src/charts/Sankey/ribbons.js +88 -0
  149. package/es/src/charts/Sankey/sankeyCycles.js +117 -0
  150. package/es/src/charts/Sankey/sankeyLayout.js +8 -3
  151. package/es/src/charts/Sankey/sankeyLinks.js +47 -0
  152. package/es/src/charts/Scatter/index.js +25 -0
  153. package/es/src/charts/SlopeChart/index.js +116 -0
  154. package/es/src/charts/SlopeChart/slope.js +95 -0
  155. package/es/src/charts/Streamgraph/index.js +51 -0
  156. package/es/src/charts/Sunburst/curvedLabels.js +74 -0
  157. package/es/src/charts/Sunburst/emit.js +74 -63
  158. package/es/src/charts/Sunburst/index.js +3 -3
  159. package/es/src/charts/Tree/index.js +2 -6
  160. package/es/src/charts/Treemap/index.js +2 -5
  161. package/es/src/charts/Violin/inner.js +3 -5
  162. package/es/src/charts/definition/makeChart.js +10 -2
  163. package/es/src/charts/drawSteps/backControl.js +17 -5
  164. package/es/src/charts/drawSteps/gestureHover.js +79 -0
  165. package/es/src/charts/drawSteps/minimap.js +6 -5
  166. package/es/src/charts/drawSteps/minimapMarkup.js +25 -9
  167. package/es/src/charts/drawSteps/searchControls.js +2 -1
  168. package/es/src/charts/drawSteps/searchControlsMarkup.js +11 -2
  169. package/es/src/charts/drawSteps/tableViewMarkup.js +17 -10
  170. package/es/src/charts/drawSteps/zoomControls.js +21 -5
  171. package/es/src/charts/events/click.legend.js +7 -2
  172. package/es/src/charts/events/click.shape.js +8 -1
  173. package/es/src/charts/events/mousemove.shape.js +5 -2
  174. package/es/src/charts/facet/drawFacets.js +14 -5
  175. package/es/src/charts/features/annotationFrame.js +179 -0
  176. package/es/src/charts/features/annotationText.js +83 -0
  177. package/es/src/charts/features/annotationTypes.js +10 -0
  178. package/es/src/charts/features/attributionFeature.js +6 -11
  179. package/es/src/charts/features/axes.js +2 -1
  180. package/es/src/charts/features/axesFinal.js +3 -1
  181. package/es/src/charts/features/axesMeasure.js +7 -4
  182. package/es/src/charts/features/calloutLayout.js +121 -0
  183. package/es/src/charts/features/calloutScene.js +155 -0
  184. package/es/src/charts/features/chartGeometry.js +1 -1
  185. package/es/src/charts/features/circleLabelPlacement.js +297 -0
  186. package/es/src/charts/features/circleLabels.js +207 -0
  187. package/es/src/charts/features/colorScaleBucket.js +2 -1
  188. package/es/src/charts/features/colorScaleHover.js +3 -2
  189. package/es/src/charts/features/colorScaleValue.js +97 -0
  190. package/es/src/charts/features/curvedArrows.js +158 -0
  191. package/es/src/charts/features/edgeArrows.js +160 -4
  192. package/es/src/charts/features/edgeBundling.js +442 -0
  193. package/es/src/charts/features/edgeBundlingSmooth.js +117 -0
  194. package/es/src/charts/features/ensureZoomDom.js +32 -8
  195. package/es/src/charts/features/features.js +32 -14
  196. package/es/src/charts/features/featuresColorScale.js +20 -6
  197. package/es/src/charts/features/featuresLegend.js +15 -24
  198. package/es/src/charts/features/legendKeys.js +64 -0
  199. package/es/src/charts/features/lineLabels.js +55 -46
  200. package/es/src/charts/features/linkBundle.js +19 -0
  201. package/es/src/charts/features/linkColor.js +72 -0
  202. package/es/src/charts/features/linkFields.js +86 -0
  203. package/es/src/charts/features/linkFocus.js +118 -0
  204. package/es/src/charts/features/linkInteraction.js +312 -0
  205. package/es/src/charts/features/linkKeys.js +20 -0
  206. package/es/src/charts/features/linkLabelGeometry.js +209 -0
  207. package/es/src/charts/features/linkLabelPath.js +162 -0
  208. package/es/src/charts/features/linkLabels.js +340 -0
  209. package/es/src/charts/features/linkWidths.js +32 -0
  210. package/es/src/charts/features/pathLabelGeometry.js +232 -0
  211. package/es/src/charts/features/pathLabels.js +50 -0
  212. package/es/src/charts/features/plotAnnotations.js +68 -17
  213. package/es/src/charts/features/plotPaint.js +38 -11
  214. package/es/src/charts/features/polyline.js +129 -0
  215. package/es/src/charts/features/referenceAnnotations.js +403 -0
  216. package/es/src/charts/features/referenceLabelPlacement.js +106 -0
  217. package/es/src/charts/features/ringLabelNodes.js +93 -0
  218. package/es/src/charts/features/ringLabels.js +222 -0
  219. package/es/src/charts/features/sceneBounds.js +26 -6
  220. package/es/src/charts/features/selfLoops.js +306 -0
  221. package/es/src/charts/features/shapeEmit.js +47 -31
  222. package/es/src/charts/features/sharedFields.js +15 -2
  223. package/es/src/charts/features/textHalo.js +29 -0
  224. package/es/src/charts/index.js +8 -0
  225. package/es/src/charts/partition/chartFields.js +2 -2
  226. package/es/src/charts/partition/interaction.js +9 -5
  227. package/es/src/charts/partition/zoom.js +7 -6
  228. package/es/src/charts/pipeline/insetPlacement.js +14 -6
  229. package/es/src/charts/pipeline/preDrawData.js +46 -3
  230. package/es/src/charts/pipeline/runVizPipeline.js +5 -0
  231. package/es/src/charts/pipeline/vizPreDraw.js +5 -3
  232. package/es/src/charts/plotBuffers/discreteBuffer.js +7 -4
  233. package/es/src/charts/polar/config.js +2 -3
  234. package/es/src/charts/viz/Viz.js +39 -36
  235. package/es/src/charts/viz/VizBase.js +18 -10
  236. package/es/src/charts/viz/backgroundInk.js +13 -7
  237. package/es/src/charts/viz/focusRing.js +104 -0
  238. package/es/src/charts/viz/focusTargets.js +208 -0
  239. package/es/src/charts/viz/history.js +74 -0
  240. package/es/src/charts/viz/keyboardNav.js +297 -0
  241. package/es/src/charts/viz/keyboardNavHost.js +95 -0
  242. package/es/src/charts/viz/loaderFormat.js +114 -0
  243. package/es/src/charts/viz/missingFields.js +2 -1
  244. package/es/src/charts/viz/mountTarget.js +9 -0
  245. package/es/src/charts/viz/nearestHover.js +183 -0
  246. package/es/src/charts/viz/nearestHoverSurface.js +92 -0
  247. package/es/src/charts/viz/ordinalColor.js +14 -12
  248. package/es/src/charts/viz/pageTheme.js +83 -0
  249. package/es/src/charts/viz/pointTooltipAnchor.js +59 -0
  250. package/es/src/charts/viz/pointVoronoi.js +124 -0
  251. package/es/src/charts/viz/reducedMotion.js +27 -0
  252. package/es/src/charts/viz/vizDataPolling.js +8 -3
  253. package/es/src/charts/viz/vizDefaults.js +15 -23
  254. package/es/src/charts/viz/vizFields.js +35 -0
  255. package/es/src/charts/viz/vizRender.js +43 -28
  256. package/es/src/charts/viz/vizTheme.js +96 -0
  257. package/es/src/charts/viz/vizVisibility.js +14 -0
  258. package/es/src/components/Axis/Axis.js +6 -0
  259. package/es/src/components/Axis/AxisBottom.js +1 -0
  260. package/es/src/components/Axis/AxisLeft.js +1 -0
  261. package/es/src/components/Axis/AxisRight.js +1 -0
  262. package/es/src/components/Axis/AxisTop.js +1 -0
  263. package/es/src/components/Axis/axisBreak.js +4 -1
  264. package/es/src/components/Axis/axisDefaults.js +5 -9
  265. package/es/src/components/Axis/axisLayoutScale.js +7 -1
  266. package/es/src/components/Axis/axisRangeBreaks.js +77 -0
  267. package/es/src/components/Axis/brokenTimeScale.js +196 -0
  268. package/es/src/components/Axis/rangeBreaks.js +201 -0
  269. package/es/src/components/Axis/timeValues.js +19 -4
  270. package/es/src/components/ColorScale/ColorScale.js +15 -9
  271. package/es/src/components/ColorScale/bucketBounds.js +32 -3
  272. package/es/src/components/ColorScale/colorScaleHoverMark.js +3 -3
  273. package/es/src/components/ColorScale/colorScaleScale.js +28 -15
  274. package/es/src/components/Legend/Legend.js +3 -0
  275. package/es/src/components/Legend/legendConfig.js +2 -6
  276. package/es/src/components/SizeLegend/SizeLegend.js +1 -0
  277. package/es/src/components/TextBox.js +29 -65
  278. package/es/src/components/Timeline/Timeline.js +12 -3
  279. package/es/src/components/Timeline/timelineConfig.js +20 -10
  280. package/es/src/components/Timeline/timelineMode.js +26 -0
  281. package/es/src/components/Timeline/timelineRender.js +7 -3
  282. package/es/src/components/Tooltip.js +15 -5
  283. package/es/src/components/fontStack.js +20 -0
  284. package/es/src/components/textBoxLayout.js +58 -21
  285. package/es/src/components/textBoxPath.js +73 -0
  286. package/es/src/components/textBoxScene.js +223 -0
  287. package/es/src/components/textBoxWords.js +70 -0
  288. package/es/src/shapes/Area.js +1 -0
  289. package/es/src/shapes/Bar.js +1 -0
  290. package/es/src/shapes/Box.js +1 -0
  291. package/es/src/shapes/Circle.js +1 -0
  292. package/es/src/shapes/Line.js +1 -0
  293. package/es/src/shapes/Path.js +1 -0
  294. package/es/src/shapes/Rect.js +1 -0
  295. package/es/src/shapes/Shape.js +1 -0
  296. package/es/src/shapes/Whisker.js +1 -0
  297. package/es/src/utils/BaseClass.js +25 -12
  298. package/es/src/utils/configPrep.js +2 -1
  299. package/es/src/utils/constant.js +13 -1
  300. package/es/src/utils/displayName.js +12 -0
  301. package/es/src/utils/theme.js +190 -0
  302. package/es/src/utils/themeInk.js +68 -0
  303. package/package.json +14 -11
  304. package/types/index.d.ts +6 -2
  305. package/types/internal.d.ts +250 -8
  306. package/types/src/charts/Alluvial/aggregate.d.ts +98 -0
  307. package/types/src/charts/Alluvial/applyLayout.d.ts +67 -0
  308. package/types/src/charts/Alluvial/dimensions.d.ts +40 -0
  309. package/types/src/charts/Alluvial/emit.d.ts +9 -0
  310. package/types/src/charts/Alluvial/hover.d.ts +31 -0
  311. package/types/src/charts/Alluvial/index.d.ts +27 -0
  312. package/types/src/charts/Alluvial/layout.d.ts +70 -0
  313. package/types/src/charts/Alluvial/meta.d.ts +54 -0
  314. package/types/src/charts/Alluvial/titles.d.ts +33 -0
  315. package/types/src/charts/ArcDiagram/applyLayout.d.ts +70 -0
  316. package/types/src/charts/ArcDiagram/arcGeometry.d.ts +150 -0
  317. package/types/src/charts/ArcDiagram/arcLabels.d.ts +89 -0
  318. package/types/src/charts/ArcDiagram/arcLoops.d.ts +48 -0
  319. package/types/src/charts/ArcDiagram/emit.d.ts +23 -0
  320. package/types/src/charts/ArcDiagram/events.d.ts +28 -0
  321. package/types/src/charts/ArcDiagram/index.d.ts +28 -0
  322. package/types/src/charts/BubbleChart/emit.d.ts +20 -0
  323. package/types/src/charts/BubbleChart/index.d.ts +16 -0
  324. package/types/src/charts/Chord/applyLayout.d.ts +3 -0
  325. package/types/src/charts/Chord/labels.d.ts +66 -0
  326. package/types/src/charts/Donut/index.d.ts +2 -1
  327. package/types/src/charts/Gantt/applyLayout.d.ts +64 -0
  328. package/types/src/charts/Gantt/emit.d.ts +17 -0
  329. package/types/src/charts/Gantt/ganttDecor.d.ts +41 -0
  330. package/types/src/charts/Gantt/ganttGeometry.d.ts +57 -0
  331. package/types/src/charts/Gantt/ganttLabels.d.ts +41 -0
  332. package/types/src/charts/Gantt/ganttRows.d.ts +84 -0
  333. package/types/src/charts/Gantt/ganttTooltip.d.ts +57 -0
  334. package/types/src/charts/Gantt/index.d.ts +36 -0
  335. package/types/src/charts/Geomap/applyLayout.d.ts +8 -0
  336. package/types/src/charts/Geomap/basemapTheme.d.ts +2 -19
  337. package/types/src/charts/Geomap/emit.d.ts +2 -2
  338. package/types/src/charts/Geomap/flowEmit.d.ts +35 -0
  339. package/types/src/charts/Geomap/flowEvents.d.ts +20 -0
  340. package/types/src/charts/Geomap/flowFields.d.ts +7 -0
  341. package/types/src/charts/Geomap/flowGeometry.d.ts +91 -0
  342. package/types/src/charts/Geomap/flowLinks.d.ts +97 -0
  343. package/types/src/charts/Geomap/geoCache.d.ts +47 -0
  344. package/types/src/charts/Geomap/globeKeys.d.ts +41 -0
  345. package/types/src/charts/Geomap/globeRotate.d.ts +70 -0
  346. package/types/src/charts/Geomap/index.d.ts +3 -0
  347. package/types/src/charts/Geomap/pointLabels.d.ts +24 -0
  348. package/types/src/charts/Hexbin/binning.d.ts +64 -0
  349. package/types/src/charts/Hexbin/buffer.d.ts +18 -0
  350. package/types/src/charts/Hexbin/contourLabels.d.ts +95 -0
  351. package/types/src/charts/Hexbin/contours.d.ts +48 -0
  352. package/types/src/charts/Hexbin/emit.d.ts +23 -0
  353. package/types/src/charts/Hexbin/index.d.ts +25 -0
  354. package/types/src/charts/Hexbin/layers.d.ts +94 -0
  355. package/types/src/charts/Hexbin/settings.d.ts +122 -0
  356. package/types/src/charts/Hexbin/tooltip.d.ts +26 -0
  357. package/types/src/charts/Histogram/binData.d.ts +20 -1
  358. package/types/src/charts/Histogram/index.d.ts +3 -2
  359. package/types/src/charts/Histogram/labels.d.ts +7 -0
  360. package/types/src/charts/Marimekko/index.d.ts +2 -1
  361. package/types/src/charts/Network/bundle.d.ts +67 -0
  362. package/types/src/charts/Network/clusterLabels.d.ts +112 -0
  363. package/types/src/charts/Network/clusters.d.ts +115 -0
  364. package/types/src/charts/Network/graph.d.ts +65 -0
  365. package/types/src/charts/Network/graphFluent.d.ts +20 -0
  366. package/types/src/charts/Network/minNodeDistance.d.ts +18 -0
  367. package/types/src/charts/Network/polygonRows.d.ts +29 -0
  368. package/types/src/charts/Pie/applyLayout.d.ts +31 -3
  369. package/types/src/charts/Pie/arcFit.d.ts +63 -0
  370. package/types/src/charts/Pie/curvedLabels.d.ts +57 -0
  371. package/types/src/charts/Pie/labelRoom.d.ts +83 -0
  372. package/types/src/charts/Pie/outsideLabels.d.ts +119 -0
  373. package/types/src/charts/Pie/outsideNodes.d.ts +93 -0
  374. package/types/src/charts/Pie/pieLabels.d.ts +85 -0
  375. package/types/src/charts/Pie/sectorBox.d.ts +95 -0
  376. package/types/src/charts/Pie/straightLabels.d.ts +24 -0
  377. package/types/src/charts/Pie/straightLayout.d.ts +88 -0
  378. package/types/src/charts/Plot/alongLegend.d.ts +42 -0
  379. package/types/src/charts/Plot/areaLabelsAlong.d.ts +119 -0
  380. package/types/src/charts/Plot/axisValues.d.ts +24 -0
  381. package/types/src/charts/Plot/barWidth.d.ts +38 -4
  382. package/types/src/charts/Plot/circleLabels.d.ts +29 -0
  383. package/types/src/charts/Plot/connectGaps.d.ts +99 -0
  384. package/types/src/charts/Plot/connectGapsScene.d.ts +55 -0
  385. package/types/src/charts/Plot/forecastScene.d.ts +5 -0
  386. package/types/src/charts/Plot/index.d.ts +15 -8
  387. package/types/src/charts/Plot/lineLabelEmit.d.ts +48 -0
  388. package/types/src/charts/Plot/lineLabelSides.d.ts +50 -0
  389. package/types/src/charts/Plot/lineLabelSpread.d.ts +15 -0
  390. package/types/src/charts/Plot/lineLabelsAlong.d.ts +116 -0
  391. package/types/src/charts/Plot/pipeline.d.ts +15 -1
  392. package/types/src/charts/Plot/pipelineLineLabels.d.ts +68 -0
  393. package/types/src/charts/Plot/plotFacet.d.ts +5 -0
  394. package/types/src/charts/Plot/plotInit.d.ts +14 -0
  395. package/types/src/charts/Plot/plotRangeBreaks.d.ts +35 -0
  396. package/types/src/charts/Plot/referenceDomains.d.ts +49 -0
  397. package/types/src/charts/Plot/stackLegendOrder.d.ts +83 -0
  398. package/types/src/charts/Plot/trendLabels.d.ts +73 -0
  399. package/types/src/charts/Plot/trendTooltip.d.ts +6 -0
  400. package/types/src/charts/Priestley/timeAxis.d.ts +76 -0
  401. package/types/src/charts/Radar/axisDecorations.d.ts +7 -2
  402. package/types/src/charts/Radar/curvedLabels.d.ts +94 -0
  403. package/types/src/charts/RadialBar/curvedLabels.d.ts +31 -0
  404. package/types/src/charts/RadialBar/trackLayout.d.ts +34 -3
  405. package/types/src/charts/Rings/emit.d.ts +50 -0
  406. package/types/src/charts/Rings/ringsGraph.d.ts +10 -2
  407. package/types/src/charts/Rings/ringsLoops.d.ts +13 -0
  408. package/types/src/charts/Rings/ringsParallel.d.ts +43 -0
  409. package/types/src/charts/Sankey/circularLayout.d.ts +103 -0
  410. package/types/src/charts/Sankey/circularLinks.d.ts +178 -0
  411. package/types/src/charts/Sankey/emit.d.ts +58 -0
  412. package/types/src/charts/Sankey/labels.d.ts +19 -0
  413. package/types/src/charts/Sankey/ribbons.d.ts +36 -0
  414. package/types/src/charts/Sankey/sankeyCycles.d.ts +24 -0
  415. package/types/src/charts/Sankey/sankeyLayout.d.ts +6 -0
  416. package/types/src/charts/Sankey/sankeyLinks.d.ts +36 -0
  417. package/types/src/charts/Scatter/index.d.ts +15 -0
  418. package/types/src/charts/SlopeChart/index.d.ts +43 -0
  419. package/types/src/charts/SlopeChart/slope.d.ts +43 -0
  420. package/types/src/charts/Streamgraph/index.d.ts +28 -0
  421. package/types/src/charts/Sunburst/curvedLabels.d.ts +56 -0
  422. package/types/src/charts/definition/ChartDefinition.d.ts +13 -0
  423. package/types/src/charts/definition/makeChart.d.ts +3 -2
  424. package/types/src/charts/drawSteps/backControl.d.ts +7 -22
  425. package/types/src/charts/drawSteps/gestureHover.d.ts +33 -0
  426. package/types/src/charts/drawSteps/minimapMarkup.d.ts +5 -4
  427. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +3 -1
  428. package/types/src/charts/drawSteps/zoomGesture.d.ts +32 -0
  429. package/types/src/charts/events/click.legend.d.ts +2 -1
  430. package/types/src/charts/facet/facetConfig.d.ts +4 -2
  431. package/types/src/charts/features/annotationFrame.d.ts +108 -0
  432. package/types/src/charts/features/annotationText.d.ts +57 -0
  433. package/types/src/charts/features/annotationTypes.d.ts +161 -0
  434. package/types/src/charts/features/axesMeasure.d.ts +4 -0
  435. package/types/src/charts/features/calloutLayout.d.ts +78 -0
  436. package/types/src/charts/features/calloutScene.d.ts +40 -0
  437. package/types/src/charts/features/chartGeometry.d.ts +1 -1
  438. package/types/src/charts/features/circleLabelPlacement.d.ts +97 -0
  439. package/types/src/charts/features/circleLabels.d.ts +130 -0
  440. package/types/src/charts/features/colorScaleValue.d.ts +35 -0
  441. package/types/src/charts/features/curvedArrows.d.ts +105 -0
  442. package/types/src/charts/features/edgeArrows.d.ts +74 -2
  443. package/types/src/charts/features/edgeBundling.d.ts +86 -0
  444. package/types/src/charts/features/edgeBundlingSmooth.d.ts +29 -0
  445. package/types/src/charts/features/ensureZoomDom.d.ts +19 -1
  446. package/types/src/charts/features/featuresLegend.d.ts +4 -3
  447. package/types/src/charts/features/legendKeys.d.ts +34 -0
  448. package/types/src/charts/features/lineLabels.d.ts +15 -12
  449. package/types/src/charts/features/linkBundle.d.ts +16 -0
  450. package/types/src/charts/features/linkColor.d.ts +48 -0
  451. package/types/src/charts/features/linkFields.d.ts +16 -0
  452. package/types/src/charts/features/linkFocus.d.ts +51 -0
  453. package/types/src/charts/features/linkInteraction.d.ts +183 -0
  454. package/types/src/charts/features/linkKeys.d.ts +11 -0
  455. package/types/src/charts/features/linkLabelGeometry.d.ts +67 -0
  456. package/types/src/charts/features/linkLabelPath.d.ts +85 -0
  457. package/types/src/charts/features/linkLabels.d.ts +77 -0
  458. package/types/src/charts/features/linkWidths.d.ts +19 -0
  459. package/types/src/charts/features/pathLabelGeometry.d.ts +99 -0
  460. package/types/src/charts/features/pathLabels.d.ts +41 -0
  461. package/types/src/charts/features/plotAnnotations.d.ts +23 -8
  462. package/types/src/charts/features/plotPaint.d.ts +17 -0
  463. package/types/src/charts/features/polyline.d.ts +32 -0
  464. package/types/src/charts/features/referenceAnnotations.d.ts +130 -0
  465. package/types/src/charts/features/referenceLabelPlacement.d.ts +58 -0
  466. package/types/src/charts/features/ringLabelNodes.d.ts +63 -0
  467. package/types/src/charts/features/ringLabels.d.ts +164 -0
  468. package/types/src/charts/features/sceneBounds.d.ts +6 -0
  469. package/types/src/charts/features/selfLoops.d.ts +165 -0
  470. package/types/src/charts/features/shapeEmit.d.ts +3 -1
  471. package/types/src/charts/features/sharedFields.d.ts +11 -2
  472. package/types/src/charts/features/textHalo.d.ts +14 -0
  473. package/types/src/charts/index.d.ts +8 -0
  474. package/types/src/charts/partition/interaction.d.ts +6 -3
  475. package/types/src/charts/partition/zoom.d.ts +4 -4
  476. package/types/src/charts/pipeline/preDrawData.d.ts +14 -1
  477. package/types/src/charts/pipeline/stages.d.ts +7 -0
  478. package/types/src/charts/plotBuffers/discreteBuffer.d.ts +0 -5
  479. package/types/src/charts/viz/Viz.d.ts +16 -2
  480. package/types/src/charts/viz/VizBase.d.ts +6 -6
  481. package/types/src/charts/viz/backgroundInk.d.ts +11 -4
  482. package/types/src/charts/viz/focusRing.d.ts +25 -0
  483. package/types/src/charts/viz/focusTargets.d.ts +56 -0
  484. package/types/src/charts/viz/history.d.ts +35 -0
  485. package/types/src/charts/viz/keyboardNav.d.ts +55 -0
  486. package/types/src/charts/viz/keyboardNavHost.d.ts +53 -0
  487. package/types/src/charts/viz/loaderFormat.d.ts +78 -0
  488. package/types/src/charts/viz/mountTarget.d.ts +7 -0
  489. package/types/src/charts/viz/nearestHover.d.ts +75 -0
  490. package/types/src/charts/viz/nearestHoverSurface.d.ts +21 -0
  491. package/types/src/charts/viz/ordinalColor.d.ts +10 -8
  492. package/types/src/charts/viz/pageTheme.d.ts +34 -0
  493. package/types/src/charts/viz/pointTooltipAnchor.d.ts +36 -0
  494. package/types/src/charts/viz/pointVoronoi.d.ts +65 -0
  495. package/types/src/charts/viz/reducedMotion.d.ts +25 -0
  496. package/types/src/charts/viz/vizDefaults.d.ts +0 -9
  497. package/types/src/charts/viz/vizFields.d.ts +32 -0
  498. package/types/src/charts/viz/vizRender.d.ts +2 -1
  499. package/types/src/charts/viz/vizTheme.d.ts +40 -0
  500. package/types/src/charts/viz/vizTypes.d.ts +84 -7
  501. package/types/src/charts/viz/vizVisibility.d.ts +6 -0
  502. package/types/src/components/Axis/Axis.d.ts +1 -0
  503. package/types/src/components/Axis/AxisBottom.d.ts +1 -0
  504. package/types/src/components/Axis/AxisLeft.d.ts +1 -0
  505. package/types/src/components/Axis/AxisRight.d.ts +1 -0
  506. package/types/src/components/Axis/AxisTop.d.ts +1 -0
  507. package/types/src/components/Axis/axisBreak.d.ts +2 -0
  508. package/types/src/components/Axis/axisRangeBreaks.d.ts +25 -0
  509. package/types/src/components/Axis/brokenTimeScale.d.ts +51 -0
  510. package/types/src/components/Axis/rangeBreaks.d.ts +82 -0
  511. package/types/src/components/Axis/timeValues.d.ts +1 -1
  512. package/types/src/components/ColorScale/ColorScale.d.ts +1 -0
  513. package/types/src/components/ColorScale/bucketBounds.d.ts +15 -1
  514. package/types/src/components/Legend/Legend.d.ts +1 -0
  515. package/types/src/components/SizeLegend/SizeLegend.d.ts +1 -0
  516. package/types/src/components/TextBox.d.ts +1 -0
  517. package/types/src/components/Timeline/Timeline.d.ts +1 -0
  518. package/types/src/components/Timeline/timelineConfig.d.ts +5 -0
  519. package/types/src/components/Timeline/timelineMode.d.ts +17 -0
  520. package/types/src/components/Tooltip.d.ts +4 -3
  521. package/types/src/components/fontStack.d.ts +10 -0
  522. package/types/src/components/textBoxLayout.d.ts +18 -9
  523. package/types/src/components/textBoxPath.d.ts +59 -0
  524. package/types/src/components/textBoxScene.d.ts +51 -0
  525. package/types/src/components/textBoxWords.d.ts +33 -0
  526. package/types/src/shapes/Area.d.ts +1 -0
  527. package/types/src/shapes/Bar.d.ts +1 -0
  528. package/types/src/shapes/Box.d.ts +1 -0
  529. package/types/src/shapes/Circle.d.ts +1 -0
  530. package/types/src/shapes/Line.d.ts +1 -0
  531. package/types/src/shapes/Path.d.ts +1 -0
  532. package/types/src/shapes/Rect.d.ts +1 -0
  533. package/types/src/shapes/Shape.d.ts +1 -0
  534. package/types/src/shapes/Whisker.d.ts +1 -0
  535. package/types/src/utils/BaseClass.d.ts +9 -0
  536. package/types/src/utils/D3plusConfig.d.ts +981 -30
  537. package/types/src/utils/configPrep.d.ts +2 -0
  538. package/types/src/utils/constant.d.ts +8 -0
  539. package/types/src/utils/displayName.d.ts +10 -0
  540. package/types/src/utils/index.d.ts +1 -1
  541. package/types/src/utils/theme.d.ts +170 -0
  542. package/types/src/utils/themeInk.d.ts +56 -0
  543. package/umd/d3plus-core.full.js +86811 -61031
  544. package/umd/d3plus-core.full.min.js +2 -2
  545. package/umd/d3plus-core.js +28392 -6498
  546. package/umd/d3plus-core.min.js +2 -2
  547. package/es/src/components/Axis/gridStroke.js +0 -10
  548. package/types/src/components/Axis/gridStroke.d.ts +0 -8
@@ -1,7 +1,7 @@
1
1
  /*
2
- @d3plus/core v4.10.0
2
+ @d3plus/core v4.11.0
3
3
  Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-selection"),require("@d3plus/dom"),require("@d3plus/render"),require("@d3plus/data"),require("@d3plus/text"),require("@d3plus/color"),require("d3-scale"),require("@d3plus/locales"),require("d3-color"),require("d3-array"),require("d3-transition"),require("@d3plus/format"),require("@d3plus/math"),require("@floating-ui/dom"),require("d3-brush"),require("d3-time-format"),require("d3-shape"),require("d3-interpolate"),require("d3-zoom"),require("@d3plus/export"),require("d3-time"),require("d3-chord"),require("d3-tile"),require("d3-geo"),require("topojson-client"),require("d3-geo-projection"),require("d3-composite-projections"),require("d3-hierarchy"),require("d3-force"),require("d3-polygon")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","d3-selection","@d3plus/dom","@d3plus/render","@d3plus/data","@d3plus/text","@d3plus/color","d3-scale","@d3plus/locales","d3-color","d3-array","d3-transition","@d3plus/format","@d3plus/math","@floating-ui/dom","d3-brush","d3-time-format","d3-shape","d3-interpolate","d3-zoom","@d3plus/export","d3-time","d3-chord","d3-tile","d3-geo","topojson-client","d3-geo-projection","d3-composite-projections","d3-hierarchy","d3-force","d3-polygon"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3plus=e.d3plus||{},e.d3,e.d3plus,e.d3plus,e.d3plus,e.d3plus,e.d3plus,e.d3,e.d3plus,e.d3,e.d3,e.d3,e.d3plus,e.d3plus,e.FloatingUIDOM,e.d3,e.d3,e.d3,e.d3,e.d3,e.d3plus,e.d3,e.d3,e.d3,e.d3,e.topojson,e.d3,e.d3,e.d3,e.d3,e.d3)}(this,function(e,t,n,i,o,a,r,s,c,l,h,u,d,f,m,p,g,y,x,b,_,k,v,w,S,C,M,$,A,z,D){"use strict";function F(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var B=F(s),L=F(y),P=F(S),R=F($),E=Object.freeze({__proto__:null,get Area(){return Io},get Bar(){return Vo},get Box(){return Sa},get Circle(){return Uo},get Image(){return Ma},get Line(){return ya},get Path(){return Aa},get Rect(){return Yo},get Shape(){return jo},get Whisker(){return _a}});function N(e){return function(){return e}}function T(e,t){return void 0===t?t=>t[e]:n=>void 0===n[e]?t:n[e]}const O="D3PLUS-COMMON-RESET";function W(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}const j=Symbol("d3plus.resolvesReset");function H(e){return W(e)?I({},e):Array.isArray(e)?e.slice():e}function I(e,t,n){for(const i of Object.keys(t)){const o=t[i],a=W(n)?n[i]:void 0;if(o===O)void 0===a?delete e[i]:e[i]=H(a);else if(W(o)){const t=e[i];e[i]=I(W(t)?t:{},o,a)}else e[i]=H(o)}return e}function G(e,t,n){return I(H(e),t,n)}function V(e){return e===O||W(e)&&Object.values(e).some(V)}function q(e,t){if("function"==typeof e.coerce)return e.coerce(t);switch(e.coerce){case"accessor":return"function"==typeof t?t:"string"==typeof t?T(t):N(t);case"const":return"function"==typeof t?t:N(t);default:return t}}function Y(e,t,n,i){const o=V(n)?e._defaultConfig?.()[t]:void 0;if(n===O)return W(o)?G({},o):{};const a=arguments.length>3?i:e.schema[t];return G(W(a)?a:{},W(n)?n:{},o)}function K(e,...t){for(const n of t){const t=e[n];if("function"!=typeof t)throw new Error(`resolvesReset: "${n}" is not a method`);t[j]=!0}}function U(e,t,n){return n===O?H(e._defaultConfig?.()[t]):Y(e,t,n)}const X=Symbol("d3plus.fluentAccessor"),Q=new WeakMap;function Z(e){return"function"==typeof e&&X in e}function J(e,t){for(let n=e;n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return!Z(e.value)}return!1}function ee(e,t,n={}){e.schema||(e.schema={});for(const i of t){const t=i.key,o=t in n;if("default"in i||void 0!==i.factory){const n="default"in i?i.default:i.factory(e);let o=q(i,n);i.decorate&&(o=i.decorate(e,o));const a=e.schema[t],r=i.merge&&W(o)?G(W(a)?a:{},o):o;e.schema[t]=r,i.onSet?.(e,r)}else if(o&&void 0===e.schema[t]){const o=q(i,n[t]);e.schema[t]=o,i.onSet?.(e,o)}}const i=Object.getPrototypeOf(e);if(!i)return;let o=Q.get(i);if(o||Q.set(i,o=new WeakSet),!o.has(t)){o.add(t);for(const e of t){if(J(i,e.key))continue;const t=e.key;i[t]=function(...n){if(!n.length)return this.schema[t];const i=q(e,n[0]),o=e.merge?U(this,t,i):i;return this.schema[t]=o,e.onSet?.(this,o),this},e.merge&&(i[t][j]=!0),Object.defineProperty(i[t],X,{value:!0})}}}const te={drawDepth:"_drawDepth",id:"_id",ids:"_ids",drawLabel:"_drawLabel",timeFilter:"_timeFilter",filteredData:"_filteredData",legendData:"_legendData"};function ne(e,t){let n=e;const i=e.viz;for(const e of t){const t=e(n);n=Object.assign({},n,t);for(const e of Object.keys(t)){const n=te[e],o=t[e];n&&void 0!==o&&(i[n]=o)}}return n}function ie(e){return{width:e.schema.width-e._margin.left-e._margin.right,height:e.schema.height-e._margin.top-e._margin.bottom}}function oe(e,t,n){return{x:e._margin.left+t/2,y:e._margin.top+n/2}}function ae(e){const{width:t,height:n}=ie(e);return{type:"rect",x:e._margin.left,y:e._margin.top,width:t,height:n}}const re=e=>Number(n.date(Number(e)));function se(e,t,i,o){const a=e._xFunc,r=e._yFunc,s=e._x,c=e._y,l=e._id,h=e.schema.time;if(!(a&&r&&s&&c&&e._data&&h))return[];const u=function(e){const t=new Set,n=e=>!0===e||"number"==typeof e&&e>0,i=e=>{for(const o of e)!n(o.trailPersist)||"circle"!==o.type&&"rect"!==o.type||t.add(o.key),"group"===o.type&&i(o.children)};return i(e.root.children),t}(t);if(!u.size)return[];const d=new Set;e._data.forEach((e,t)=>d.add(re(h(e,t))));const f=[...d].filter(e=>e>i&&e<o).sort((e,t)=>e-t);if(!f.length)return[];const m=new Map;e._data.forEach((e,t)=>{const n=l(e,t);if(!u.has(n))return;let i=m.get(n);i||m.set(n,i=new Map),i.set(re(h(e,t)),{d:e,i:t})});const p=t=>e._yTime?n.date(t):t;return f.map(t=>({sequence:t,positions:[...u].flatMap(i=>{const o=m.get(i)?.get(t);return o?[{key:i,x:a((l=s(o.d,o.i),e._xTime?n.date(l):l)),y:r(p(c(o.d,o.i)))}]:[];var l})})).filter(e=>e.positions.length>0)}const ce=new WeakSet,le=new Set,he=new WeakMap;let ue=!0;function de(e){return ce.add(e),e}function fe(e){return"object"==typeof e&&null!==e&&ce.has(e)}function me(e,t){pe(`${e} received unknown property "${t}".`)}function pe(e){ue&&!le.has(e)&&(le.add(e),console.warn(e))}function ge(e,t,n){if(!ue)return;let i=he.get(e);i||he.set(e,i=new Set),i.has(t)||(i.add(t),console.warn(n))}const ye=["d3plus-render-svg","d3plus-render-canvas"];function xe(e){return(e?.elements?.()??[]).filter(e=>"svg"===e.localName||"canvas"===e.localName)}const be=new WeakMap;function _e(e){const t=(Array.isArray(e)?e:[e]).flatMap(e=>"string"==typeof e?e.split(/\s+/).filter(Boolean):[]);return Array.from(new Set(t))}function ke(e,t,n=[]){const i=_e(t);for(const t of be.get(e)??[])i.includes(t)||n.includes(t)||e.classList.remove(t);for(const t of i)e.classList.add(t);be.set(e,i)}function ve(e){for(const{el:t,keep:n}of e._classNameTargets())ke(t,e.schema.className,n)}const we=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");function Se(e,t){if(!W(e)||!V(e))return e;const i={...e},o=n.isObject(t)?t:{};for(const e of Object.keys(i))e.startsWith("_")||(i[e]===O?void 0===o[e]?delete i[e]:i[e]=o[e]:i[e]=Se(i[e],o[e]));return i}function Ce(e){let t=[];do{t=t.concat(Object.getOwnPropertyNames(e)),e=Object.getPrototypeOf(e)}while(e&&e!==Object.prototype);return t.filter(e=>0!==e.indexOf("_")&&!["config","constructor","destroy","measure","parent","render","renderMode","toScene"].includes(e))}function Me(e,t,n){if(!n.has(e)){n.add(e),e.schema.colorDefaults={...e.schema.colorDefaults,...t};for(const i of[...Object.values(e),...Object.values(e.ctx)])i instanceof $e&&Me(i,t,n)}}class $e{config(e){const t=this._defaultConfig();if(arguments.length){for(const n in e)if({}.hasOwnProperty.call(e,n))if(n in this){const i=e[n],o=this[n];i===O&&"on"===n?this.schema.on=t[n]:o[j]?o.call(this,i):i===O?o.call(this,t[n]):o.call(this,Se(i,t[n]))}else fe(e)||me(`${this.constructor.name}.config()`,n);return this}{const e={};return Ce(Object.getPrototypeOf(this)).forEach(t=>{e[t]=this[t]()}),e}}_defaultConfig(){if(!this._configDefault){const e={};Ce(Object.getPrototypeOf(this)).forEach(t=>{const i=this[t]();i!==this&&(e[t]=n.isObject(i)?n.assign({},i):i)}),this._configDefault=e}return this._configDefault}locale(e){return arguments.length?(this.schema.locale=c.findLocale(e),this):this.schema.locale}className(e){return arguments.length?(this.schema.className=e,ve(this),this):this.schema.className}_classNameTargets(){return xe(this._sceneRenderer).map(e=>({el:e,keep:ye}))}colorDefaults(e){if(!arguments.length)return this.schema.colorDefaults;const{scale:t,...n}=e??{},i={...n};return Array.isArray(t)?i.scale=s.scaleOrdinal().range(t):t&&(i.scale=t),Me(this,i,new WeakSet),this}on(e,t){return 2===arguments.length?(this.schema.on[e]=t,this):arguments.length?"string"==typeof e?this.schema.on[e]:(this.schema.on=Object.assign({},this.schema.on,e),this):this.schema.on}parent(e){return arguments.length?(this.schema.parent=e,this):this.schema.parent}translate(e){return arguments.length?(this.schema.translate=e,this):this.schema.translate}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}constructor(){this.schema={},this.ctx={},this.schema.colorDefaults={...r.colorDefaults},this.schema.locale="en-US",this.schema.on={},this.schema.parent={},this.schema.translate=(e,t=this.schema.locale)=>{const n=c.translateLocale[t],i=e;return n&&n[i]?n[i]:e},this._uuid=crypto.randomUUID()}}function Ae(e=this.schema.shapeConfig,t="shape",n=!1){const i={duration:this.schema.duration,on:{}},o=e=>(t,n,i,o)=>{if(!e)return e;let a;for(;t.__d3plus__;)a&&(t.__d3plusParent__=a),a=t,n=t.i,t=t.data||t.feature;return e.bind(this)(t,n,i||a,o)},a=(e,n)=>{for(const i in n)({}.hasOwnProperty.call(n,i)&&!i.includes(".")||i.includes(`.${t}`))&&(e.on[i]=o(n[i]))},r=e=>e.map(e=>e instanceof Array?r(e):"object"==typeof e?s({},e):"function"==typeof e?o(e):e),s=(e,t)=>{for(const n in t)({}).hasOwnProperty.call(t,n)&&("on"===n?a(e,t[n]):"sort"===n?e[n]=t[n]:"function"==typeof t[n]?e[n]=o(t[n]):t[n]instanceof Array?e[n]=r(t[n]):"object"==typeof t[n]?(e[n]||(e[n]={}),e[n].on={},s(e[n],t[n])):e[n]=t[n]);return e};return s(i,e),this.schema.on&&a(i,this.schema.on),n&&e[n]&&(s(i,e[n]),e[n].on&&a(i,e[n].on)),de(i)}function ze(e,t,n){return t[e]||this.schema[e](t,n)}function De(e){const t=e._select,n=t&&"function"==typeof t.node?t.node():null;if(!(n instanceof Element))return;const o=n,a=e.schema.width??400,r=e.schema.height??200;e._sceneRenderer?e._sceneRenderer.resize(a,r):(e._sceneRenderer=new i.SvgRenderer,e._sceneRenderer.mount({container:o,width:a,height:r}));const s={root:{type:"group",key:"root",children:[e.toScene()]},width:a,height:r};e._sceneRenderer.drawScene(s,{duration:0}),ve(e)}K($e.prototype,"shapeConfig");const Fe=new WeakMap;function Be(e){const t=T(e);return"string"==typeof e&&Fe.set(t,e),t}function Le(e){return"function"==typeof e?Fe.get(e):void 0}const Pe={fontSize:12,fontWeight:600,padding:4,textAnchor:"middle"},Re=4/3;function Ee(e){return"function"==typeof e?e:"string"==typeof e&&e?Be(e):void 0}function Ne(e){const t=e??{},n=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0;return{columns:n(t.columns),rows:n(t.rows),padding:"number"==typeof t.padding&&t.padding>=0?t.padding:20,sort:t.sort??"ascending",scales:"shared"===t.scales||"independent"===t.scales?t.scales:void 0,axes:Oe(t.axes),title:!1===t.title||"function"==typeof t.title?t.title:void 0,titleConfig:{...Pe,...t.titleConfig??{}}}}const Te=e=>"outer"===e||"all"===e;function Oe(e){if(Te(e))return e;if(!e||"object"!=typeof e)return;const{x:t,y:n}=e,i={};return Te(t)&&(i.x=t),Te(n)&&(i.y=n),i.x||i.y?i:void 0}function We(e,t){return"object"==typeof e?e[t]:e}function je(e,t,n,i){const o="function"==typeof n.axes?n.axes(e):n.axes,a=n.fixedAxes?n.fixedAxes(e):{},r=e=>"outer"===(We(t.axes,e)??We(o,e)??"outer")&&(i||!!a[e]);return{x:r("x"),y:r("y")}}function He(e,t){return"shared"===(e.scales??t.scales??"shared")}function Ie(e){return"function"==typeof e.schema.facet}const Ge="__d3plusGroupDepth",Ve="__d3plusGroupLabel";function qe(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function Ye(e){const t=qe(e),n=t?t[Ge]:void 0;return"number"==typeof n?n:void 0}function Ke(e,t,n){const i=qe(t);return e.slice(0,n+1).map(e=>e(i,0))}function Ue(e,t,n,i){const o=qe(n);return!!o&&t.every((t,n)=>{const a=e[n](o,i);return a===t||Array.isArray(a)&&a.includes(t)})}function Xe(e,t,n){return n.some((n,i)=>!Ue(e,t,n,i))}const Qe=new Set(["rect","circle","line","area","path"]);function Ze(e,t){const n=new Set,i=e=>{if(Qe.has(e.type)&&void 0!==e.datum){const i=e.datum,o=i&&i.data?i.data:i;if(void 0!==o&&!n.has(o)){n.add(o);const i="number"==typeof e.index?e.index:"number"==typeof o.i?o.i:0;t(o,i,e)}}const o=e.children;o&&o.forEach(i)};e.forEach(i)}const Je=new Map,et=new Map,tt=new Set,nt=new WeakMap;function it(e){const t=e.schema.link;if(!t)return null;const n="string"==typeof t?{group:t}:t;if(!n.group)return null;const i="function"==typeof n.by?n.by:"string"==typeof n.by?T(n.by):(t,n)=>e._id?.(t,n);return{group:n.group,by:i,hover:!1!==n.hover,active:!1!==n.active,highlight:!1!==n.highlight,legend:!1!==n.legend,color:!1!==n.color}}function ot(e){at(e);const t=it(e);if(!t)return;let n=Je.get(t.group);n||Je.set(t.group,n=new Set),n.add(e),e._linkGroup=t.group}function at(e){const t=e._linkGroup;if(void 0===t)return;const n=Je.get(t);n&&(n.delete(e),n.size||(Je.delete(t),et.delete(t))),e._linkGroup=void 0}function rt(e){const t=e.schema.colorDefaults,n=e._linkGroup;if(void 0===n||t.scale!==e._autoColorScale)return t;if(!it(e)?.color)return t;let i=et.get(n);return i||(i=s.scaleOrdinal().range(t.scale.range()),et.set(n,i)),{...t,scale:i}}function st(e){const t=Array.isArray(e)?e:[e],n=[];for(const e of t)null!=e&&n.push(e instanceof Date?""+ +e:`${e}`);return n}function ct(e,t,n){const i=new Set,o=(e,o)=>{if(n(e,o))for(const n of st(t(e,o)))i.add(n)},a=e._chartScene;return a&&a.length?Ze(a,o):(e._filteredData??[]).forEach(o),i}function lt(e,t){return(n,i)=>st(e.by(n,i)).some(e=>t.has(e))}function ht(e,t){nt.set(e,t)}function ut(e,t,n){if(tt.has(t.group))return;const i=Je.get(t.group);if(i&&!(i.size<2)){tt.add(t.group);try{for(const t of i){if(t===e)continue;const i=it(t);i&&n(t,i)}}finally{tt.delete(t.group)}}}function dt(e,t,n){const i=nt.get(e);if(nt.delete(e),void 0===n)return;const o=it(e);if(!o||!o[t])return;const a="function"==typeof n?i??n:null;let r=null;ut(e,o,(n,i)=>{if(!i[t])return;const s=n[t];s&&(a&&!r&&(r=ct(e,o.by,a)),s.call(n,!!r&&lt(i,r)))})}function ft(e,t,n){const i=e._id(t,n);return Array.isArray(i)?i:[i]}function mt(e,t,n){const i=new Set;return n.length?((e._legendData??[]).forEach((o,a)=>{if(ft(e,o,a).some(e=>n.includes(e)))for(const e of st(t.by(o,a)))i.add(e)}),i):i}function pt(e){const t=it(e);if(!t||!t.legend)return;const n=mt(e,t,e._hidden),i=mt(e,t,e._solo);ut(e,t,(e,t)=>{if(!t.legend||!e._legendData?.length)return;const o=[],a=[];e._legendData.forEach((r,s)=>{const c=st(t.by(r,s)),l=ft(e,r,s),h=e=>{for(const t of l)e.includes(t)||e.push(t)};i.size&&c.some(e=>i.has(e))?h(a):n.size&&c.length&&c.every(e=>n.has(e))&&h(o)});const r=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e));r(o,e._hidden)&&r(a,e._solo)||(e._hidden=a.length?[]:o,e._solo=a,e.render?.())})}function gt(e){const t=e.schema.shapeConfig;return Boolean(e._hoverOutline)||1!==t?.hoverOpacity}const yt={},xt=new WeakMap;function bt(){return"undefined"!=typeof IntersectionObserver}function _t(e,n,i,o=0,a){const r=function(e){return!e||"undefined"!=typeof window&&e===window?null:"string"==typeof e?t.select(e).node():"undefined"!=typeof Element&&e instanceof Element?e:null}(n),s=r||yt;let c=xt.get(s);if(!c){const e=new Map,t=new IntersectionObserver(t=>{t.forEach(t=>{e.get(t.target)?.forEach(e=>{clearTimeout(e.timer),e.timer=void 0,t.isIntersecting?e.delay>0?e.timer=setTimeout(e.onVisible,e.delay):e.onVisible():e.onHidden?.()})})},{root:r,rootMargin:"25% 0px"});c={targets:e,io:t},xt.set(s,c)}const{targets:l,io:h}=c,u={delay:o,onHidden:a,onVisible:i};let d=l.get(e);return d||l.set(e,d=new Set),d.add(u),h.unobserve(e),h.observe(e),()=>{clearTimeout(u.timer),d.delete(u),d.size||(l.delete(e),h.unobserve(e))}}function kt(e){if(!(e.schema.detectVisible&&e.schema.detectVisibleUnload&&bt()))return e._unloadUnobserve?.(),void(e._unloadUnobserve=void 0);e._unloadUnobserve||(e._unloadUnobserve=_t(e._select.node(),e.schema.scrollContainer,()=>function(e){e._unloaded&&(e._unloaded=!1,e._instantNextDraw=!0,e._forceVisible=!0,e.render())}(e),0,()=>function(e){if(e._unloaded)return;e._unloaded=!0,e._resizePoll=clearTimeout(e._resizePoll);const t=e._select.node()?.parentNode;t&&e._resizeObserver?.unobserve(t),e._tooltipClass.data([]).render(),null!=e._sceneRepaintRAF&&(cancelAnimationFrame(e._sceneRepaintRAF),e._sceneRepaintRAF=void 0),e._sceneRenderer&&"function"==typeof e._sceneRenderer.destroy&&(e._sceneRenderer.destroy(),e._sceneRenderer=void 0),e._select.selectAll("g.data-table").remove()}(e)))}function vt(e){return e instanceof Array?e.some(o.isData):o.isData(e)}function wt(e){const t=JSON.stringify(e)??"";let n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`${t.length}:${(n>>>0).toString(36)}`}function St(e,t,n){return new Promise((i,a)=>{let r;const s={_cache:!1,_lrucache:e._lrucache,_data:[],config:e=>{r=e}},c=function(e){return(e instanceof Array?e:[e]).map(e=>{if(!o.isData(e))return e;if("string"==typeof e)return{url:e,cache:"no-cache"};const t=e;return"cache"in t?t:{...t,cache:"no-cache"}})}(t);o.load.call(s,c,n,"data",(e,t)=>{e?a(e):i({data:t??[],config:r})})})}function Ct(e){e._dataPollStop?.(),e._dataPollStop=void 0,e._dataPollFor=void 0}function Mt(e){return[e.schema.dataPollingInterval,e._userData,e._userDataFormat,e.schema.detectVisible,e.schema.scrollContainer]}function $t(e,t){const n=e._userData,i=e._userDataFormat,o=e._select?.node()?.ownerDocument;let a=!1;const r=function(e){let t,n=!1,i=!1,o=!1,a=!1;const r=()=>{t=setTimeout(c,e.interval)},s=()=>{o=!1,i=!0,Promise.resolve().then(e.fetch).then(t=>{n||(a=!1,e.onData(t))},t=>{n||(a||e.onError(t),a=!0)}).catch(t=>{n||e.onError(t)}).finally(()=>{i=!1,n||r()})};function c(){t=void 0,n||(e.paused()?o=!0:s())}return r(),{stop(){n=!0,clearTimeout(t),t=void 0},resume(){n||!o||i||e.paused()||s()}}}({interval:t,fetch:()=>St(e,n,i),onData:t=>function(e,{data:t,config:n}){const i=wt(t);i!==e._dataSignature&&(e._dataSignature=i,n&&e.config(n),e._data=t,e.schema.timeFilter||(e._timelineSelection=!1),e.render())}(e,t),onError:e=>{console.warn("d3plus: dataPollingInterval could not refresh the data; keeping the last data and retrying.",e)},paused:()=>a||"hidden"===o?.visibilityState}),s=()=>{"hidden"!==o?.visibilityState&&r.resume()};o?.addEventListener("visibilitychange",s);const c=e.schema.detectVisible&&bt()?_t(e._select.node(),e.schema.scrollContainer,()=>{a=!1,r.resume()},0,()=>{a=!0}):void 0;e._dataPollFor=Mt(e),e._dataPollStop=()=>{r.stop(),o?.removeEventListener("visibilitychange",s),c?.()}}function At(e){const t=e.schema.dataPollingInterval,n="number"==typeof t&&t>0&&isFinite(t);if(n&&!vt(e._userData)&&pe(`${e.constructor.name}: dataPollingInterval only polls data loaded from a URL.`),!n||e._ssr||!vt(e._userData))return void Ct(e);const i=Mt(e),o=e._dataPollFor;o&&o.every((e,t)=>e===i[t])||(Ct(e),$t(e,t))}function zt(e=a.textSplit){return(t,n)=>e(t,n).reduce((e,t)=>{const n=e.length-1;return n>=0&&e[n].endsWith(a.softHyphen)?e[n]=e[n].slice(0,-1)+t:e.push(t),e},[])}const Dt=zt();function Ft(e,t){if(e.truncated)return{fits:!1,result:e};if(!e.lines.slice(0,-1).some(e=>e.endsWith("-")))return{fits:!0,result:e};const n=t();return n.truncated?{fits:!1,result:e}:{fits:!0,result:n}}function Bt(e){let t=(e%360+360)%360;return t>180&&(t-=360),t>90?t-=180:t<-90&&(t+=180),0===t?0:t}function Lt(e){return"number"==typeof e&&Number.isFinite(e)?Bt(e):-90}const Pt={rotate:!1,angle:0,slant:!1};const Rt=e=>"top"===e?30:-30;function Et(e){return"number"==typeof e?Number.isFinite(e)&&0!==Bt(e):!0===e}function Nt(e,t){return!(!Et(e)||"number"!=typeof e)&&(!t||90!==Math.abs(Bt(e)))}function Tt(e,t){const n=Math.abs(e)*Math.PI/180;return t?n:Math.PI/2-n}function Ot(e){return"bottom"===e?{x:0,y:1}:"top"===e?{x:0,y:-1}:"left"===e?{x:-1,y:0}:{x:1,y:0}}function Wt(e,t){const n=t*Math.PI/180,i=Ot(e),o=Math.cos(n)*i.x+Math.sin(n)*i.y;return Math.abs(o)<1e-9?"middle":o<0?"end":"start"}function jt(e,t,n,i,o,a){const r=t*Math.PI/180,s=Math.cos(r),c=Math.sin(r),l=-Math.sin(r),h=Math.cos(r),u=Ot(e),d=Wt(e,t),f=Math.abs(l*u.x+h*u.y),m=u.x*(a+i/2*f),p=u.y*(a+i/2*f),g="end"===d?n:"start"===d?0:n/2,y=i/2,x=(e,t)=>({x:m+(e-g)*s+(t-y)*l,y:p+(e-g)*c+(t-y)*h}),b=x(n/2,o/2);return{x:b.x-n/2,y:b.y-o/2,width:n,height:o,corners:[x(0,0),x(n,0),x(n,i),x(0,i)]}}function Ht(e,t,n,i){const o="top"===e||"bottom"===e,a=jt(e,t,n,i,i,0).corners.map(e=>o?e.x:e.y);return[Math.max(0,-Math.min(...a)),Math.max(0,Math.max(...a))]}function It(e,t,n,i,o){const a=Tt(e,t),r=Math.sin(a);return r<1e-9?{width:i,height:n}:{width:Math.max(0,(n-o*Math.cos(a))/r),height:Math.max(o,i*r)}}function Gt(e,t,i){if(t<2)return i;const o=e.map(({text:e,fontFamily:o,fontSize:r,lineHeight:s})=>{const c={"font-family":o,"font-size":r},l=n.textWidth(`${e}`,c),h=`${e}`.split(/\s+/).filter(Boolean),u=Math.max(0,...h.map(e=>n.textWidth(e,c))),d=a.textWrap().fontFamily(o).fontSize(r).lineHeight(s).split(Dt).height(s*(t+1));return function(e,t,n,i,o=1.08){for(let a=Math.max(1,n);a<i;a*=o)if(e(a)<=t)return Math.ceil(a);return i}(t=>d.width(t)(`${e}`).lines.filter(e=>""!==e).length,t,Math.max(u+1,l/t),i)});return Math.min(i,Math.max(0,...o))}function Vt(e,t){const n=e.lines.length,i=n?(n-1)*e.lineHeight+e.fS:0;if(e.slant){const n=Math.sin(Tt(e.angle,t));return n<1e-9?e.width:i/n}return Boolean(e.rotate)!==t?e.width:i}function qt(e,t,n,i){const o=e=>t[e.i]-2*e.fP,a=new Set(e.filter(e=>!e.fits)),r=(t,n,i)=>{for(let o=t+n;o>=0&&o<e.length;o+=n)if(!(e[o].truncated||i&&a.has(e[o])))return e[o]},s=(e,t)=>{const s=[r(e.i,-1,t),r(e.i,1,t)].filter(e=>void 0!==e).map(t=>2*(Math.abs(t.position-e.position)-(e=>a.has(e)?Math.min(e.width,o(e)):e.width)(t)/2-e.fP)),c=Math.floor(s.length?Math.min(...s):Math.max(...n)-Math.min(...n));return c>o(e)&&i(e,c),e.fits};let c=Math.min(...n);const l=e.map(e=>{const t=Math.max(0,2*(e.position-c));return c+=t,t});[...a].sort((e,t)=>l[t.i]-l[e.i]).forEach(e=>{a.delete(e),s(e,!1)||s(e,!0),e.truncated=!e.fits})}function Yt(e,t,n){let i=1;const o=n=>e.some((i,o)=>o>=n&&o%n===0&&function(e,t,n){return Math.abs(t.position-e.position)-(Vt(e,n)+Vt(t,n))/2<t.fP}(e[o-n],i,t));for(;i<e.length&&o(i);)i++,n?.(i,!1);i>1&&n?.(i,!0),e.forEach((e,t)=>e.truncated=t%i!==0)}function Kt(e,t){const n=e.slice().reverse();e.forEach(i=>{const{fP:o,i:a,position:r}=i,s=e=>Vt(e,t);let c=a?n.find(e=>e.i<a&&!e.truncated):void 0;if(a===e.length-1)for(;c&&r-s(i)/2-o<c.position+s(c)/2;)c.truncated=!0,c=n.find(e=>e.i<a&&!e.truncated);i.truncated=!!c&&r-s(i)/2-o<c.position+s(c)/2})}function Ut(e,t,n,i){const o=h.min([e.schema.maxSize,e.schema.width]),a=h.min([e.schema.maxSize,e.schema.height]);return t?a-n-i-e._margin.top-e._margin.bottom:o-n-i-e._margin.left-e._margin.right}function Xt(e,t){const{labels:n,rangeOuter:i,horizontal:o,hBuff:r,p:s,tickFormat:c,offset:l=1,ownSpace:u}=t,d=o&&!e._labelRotation&&Qt(e,n);e._shownLabels=n;const f={horizontal:o,hBuff:r,p:s,tickFormat:c,wholeLine:d};let m=function(e,t){const{fontSize:n}=e.schema.shapeConfig.labelConfig,i=e.schema.shapeConfig.labelConfig.fontFamily||a.fontFamily,o=e.schema.shapeConfig.labelConfig.padding,r=e._labelRotation?e._labelAngle:0,s=!!e._labelRotation&&e._labelSlant;return t.map((t,a)=>{const c="function"==typeof i?i(t,a):i,l="function"==typeof o?o(t,a):o,h="function"==typeof n?n(t,a):n,u=e._getPosition(t);return{d:t,i:a,fF:c,fP:l,fS:h,lineHeight:e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(t,a):1.4*h,position:u,rotate:e._labelRotation,angle:r,slant:s}})}(e,n);const p=function(e,t,n){return"band"===e.schema.scale?e._d3Scale.bandwidth():t.reduce((i,o,a)=>{const{position:r}=o,s=a?r-(r-t[a-1].position):1===t.length?n[0]:r-(t[a+1].position-r),c=Math.abs(r-s),l=a==t.length-1?1===t.length?n[1]:r+(r-t[a-1].position):r-(r-t[a+1].position),u=Math.abs(r-l),d="point"===e.schema.scale?1:2;return h.max([h.max([c,u])*d,i])},0)}(e,m,i);f.slantWidth=function(e,t,n){const i=t[0];if(!i?.slant)return;const{horizontal:o,hBuff:a,p:r,tickFormat:s,space:c}=n,l=t=>e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(t.d,t.i):Math.ceil(1.4*t.fS),h=It(i.angle,o,Ut(e,o,a,r),c-2*i.fP,l(i));return Gt(t.map(e=>({text:s(e.d),fontFamily:e.fF,fontSize:e.fS,lineHeight:l(e)})),((e,t)=>Math.max(1,Math.min(3,Math.floor(e/t+1e-9))))(h.height,l(i)),h.width)}(e,m,{...f,space:p});const g=u?function(e,t){return e.length<2?e.map(()=>Math.abs(t[t.length-1]-t[0])):e.map((t,n)=>{const i=[e[n-1],e[n+1]].filter(e=>void 0!==e).map(e=>Math.abs(t-e));return Math.min(...i)})}(m.map(e=>e.position),i):void 0,y=new Map,x=(t,n=(g?g[t.i]:p)-2*t.fP)=>{t.space=n;const{lines:i,widths:r,width:s,height:c,fits:l}=function(e,t,n,i){const{horizontal:o,hBuff:r,p:s,tickFormat:c}=n,{d:l,i:u,fF:d,fP:f,fS:m,rotate:p,space:g,angle:y,slant:x}=t,b=p?"width":"height",_=p?"height":"width",k=e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(l,u):void 0,v=c(l),w=h.min([e.schema.maxSize,e.schema.width]),S=Ut(e,o,r,s),C=x?It(y,o,S,g,k??Math.ceil(1.4*m)):void 0,M=i&&JSON.stringify([v,d,f,m,k,p,x&&y,x&&n.slantWidth,g]),$=M?i.get(M):void 0;if($)return{...$,lines:$.lines.slice(),widths:$.widths.slice()};const A=a.textWrap().fontFamily(d).fontSize(m).lineHeight(k);let z,D;return C?A.split(Dt).width(Math.min(C.width,n.slantWidth??1/0)).height(C.height):(A[_](o?g:S),A[b](o?S:g)),n.wholeLine?(A.width(e.schema.width-2*s),z=A(v),D=!z.truncated&&z.lines.filter(e=>""!==e).length<=1):(z=A(v),D=Ft(z,()=>A.split(Dt)(v)).fits,o&&!p&&`${v}`.trim()&&!z.lines.some(e=>""!==e)&&(A.width(w-2*s),z=A(v))),z.fits=D,z.lines=z.lines.filter(e=>""!==e),z.width=z.lines.length?Math.ceil(h.max(z.widths)):0,z.height=z.lines.length?Math.ceil(z.lines.length*A.lineHeight())+f:0,M&&i.set(M,{lines:z.lines.slice(),widths:z.widths.slice(),width:z.width,height:z.height,fits:D}),z}(e,t,f,y);return o&&!t.rotate?t.space=Math.max(t.space,Math.ceil(s)):!o&&!t.rotate&&c-t.fP>t.space&&(t.space=Math.ceil(c)),Object.assign(t,{lines:i,widths:r,width:s,height:c,fits:l})};m=m.map(e=>x(e));const b=(t,n=t)=>{e._shownLabels=t.map(e=>e.d),n.forEach(e=>x(e))};return Zt(e.schema.scale)?Yt(m,o,d?(e,t)=>{const n=m.filter((t,n)=>n%e===0);b(n,t?m:n)}:void 0):g&&o&&!e._labelRotation?qt(m,g,e._d3Scale.range(),x):d?function(e,t,n){let i=e;for(let o=0;o<4;o++){Kt(e,t);const o=e.filter(e=>!e.truncated);if(o.length===i.length&&o.every((e,t)=>e===i[t]))return;i=o,n(i,e)}}(m,o,b):Kt(m,o),l>1&&function(e=[],t){let n=0;e.forEach(i=>{const o=e[i.i-1],a=i.rotate&&t||!i.rotate&&!t?"width":"height",r=i.rotate&&t||!i.rotate&&!t?"height":"width";o?o.position+o[r]/2>i.position-i[r]/2&&(n?(i.offset=o[a],n=0):n=1):n=1})}(m,o),m}function Qt(e,t){const{scale:n}=e.schema;return"time"===n||Zt(n)&&t.length>0&&t.every(e=>e instanceof Date||!isNaN(e))}function Zt(e){return["band","ordinal","point"].includes(e)}function Jt(e,t){return e.slant?function(e,t,n,i){const o=Tt(e,t);return n*Math.sin(o)+i*Math.cos(o)}(e.angle,t,e.width,e.height-e.fP)+(t?e.fP:0):e[e.rotate||!t?"width":"height"]}const en=e=>"function"==typeof e&&"brokenSpec"in e;function tn(e,t,n){if(!Array.isArray(e)||!e.length)return[];const i=(Array.isArray(e[0])?e:[e]).filter(e=>Array.isArray(e)&&2===e.length).map(e=>e.map(Number)).filter(e=>e.every(Number.isFinite)&&e[0]!==e[1]).map(e=>e[0]<e[1]?[e[0],e[1]]:[e[1],e[0]]).sort((e,t)=>e[0]-t[0]),o=[];for(const e of i){const t=o[o.length-1];t&&e[0]<=t[1]?t[1]=Math.max(t[1],e[1]):o.push([e[0],e[1]])}return o.filter(([e,i])=>e>t&&i<n)}function nn(e){const[t,n]=e.domain,i=Math.min(t,n),o=Math.max(t,n),a=t<=n?e.range[0]:e.range[1],r=t<=n?e.range[1]:e.range[0],s=Math.sign(r-a)||1,c=e.breaks.reduce((e,[t,n])=>e+n-t,0),l=(Math.abs(r-a)-e.breaks.length*e.space)/(o-i-c),h=[i],u=[a];let d=i;for(const[t,n]of e.breaks){const i=u[u.length-1]+s*l*(t-d);h.push(t,n),u.push(i,i+s*e.space),d=n}return h.push(o),u.push(r),{values:h,pixels:u}}function on(e){let{values:t,pixels:n}=nn(e),i=s.scaleLinear().domain(t).range(n);const o=t=>{const n=+t,o=(t=>{const n=e.edge;if(!n)return;const i=(t-n.value)/(n.edge-n.value);return i<1?i<=0?n.position:n.position+i*(n.edgePosition-n.position):void 0})(n);return void 0!==o?o:i(n)},a=()=>{({values:t,pixels:n}=nn(e)),i=s.scaleLinear().domain(t).range(n)};return o.brokenSpec=e,o.domain=t=>void 0===t?e.domain.slice():(e.domain=Array.from(t,Number),a(),o),o.range=t=>void 0===t?e.range.slice():(e.range=Array.from(t,Number),a(),o),o.copy=()=>on({...e,breaks:e.breaks.map(e=>[e[0],e[1]])}),o.invert=t=>{const n=e.edge;if(n){const e=(t-n.position)/(n.edgePosition-n.position);if(e<=0)return n.value;if(e<1)return n.value+e*(n.edge-n.value)}return i.invert(t)},o.segments=()=>{const i=[];for(let e=0;e<t.length;e+=2)i.push({domain:[t[e],t[e+1]],range:[n[e],n[e+1]]});return e.domain[0]>e.domain[1]?i.reverse().map(e=>({domain:[e.domain[1],e.domain[0]],range:[e.range[1],e.range[0]]})):i},o.ticks=n=>s.scaleLinear().domain([t[0],t[t.length-1]]).ticks(n).filter(t=>!e.breaks.some(([e,n])=>t>e&&t<n)),o}function an(e,t,n){const i=new Set,o=[],a=e=>{const t=Number(e);i.has(t)||(i.add(t),o.push(e))},r=new Set(e.brokenSpec.breaks.flat());for(const i of e.segments()){const e=s.scaleLinear().domain(i.domain).range(i.range),o=t(e);o.forEach(a);const c=o.map(Number);i.domain.filter(e=>r.has(e)&&!c.includes(e)).forEach(t=>{n&&!n(t,c,e)||a(t)})}return o}const rn=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t;function sn(e,t="breakConfig"){const n=e.schema[t]||{};return{angle:rn(n.angle,30),gap:Math.max(0,rn(n.gap,5)),size:Math.max(0,rn(n.size,10)),space:Math.max(0,rn(n.space,36)),mask:!1!==n.mask,lines:!1!==n.lines}}const cn=e=>sn(e,"baselineBreakConfig");function ln(e,t){const{baseline:n,baselineBreak:i,scale:o}=e.schema;if(!i||"linear"!==o||!e._d3Scale)return null;if("number"!=typeof n||!Number.isFinite(n))return null;const a=e._d3Scale.domain().map(Number);if(2!==a.length||a.some(e=>!Number.isFinite(e)))return null;const r=Math.min(a[0],a[1]),s=Math.max(a[0],a[1]);if(r===s||n>=r&&n<=s)return null;const c=n<r?r:s,l=a[0]===c?0:1,h=t[l],u=t[1-l],{space:d}=cn(e);if(!d||Math.abs(u-h)<=2*d)return null;return{value:n,position:h,edge:c,edgePosition:h+Math.sign(u-h)*d}}function hn(e,t){if(e._baselineBreak=ln(e,t),e._breaks=[],"linear"!==e.schema.scale||!e._d3Scale)return;const n=e._baselineBreak,i=e._d3Scale.domain().map(Number),o=t.slice(0,2).map(e=>n&&e===n.position?n.edgePosition:e),{space:a,mask:r}=sn(e);let s=tn(e.schema.break,Math.min(...i),Math.max(...i));if(Math.abs(o[1]-o[0])-s.length*a<2*a&&(s=[]),!n&&!s.length)return;const c=on({domain:i,range:o,breaks:s,space:a,edge:n});e._d3Scale=c;const l="number"==typeof e.schema.baseline?e.schema.baseline:0;n&&e._breaks.push({start:n.value,end:n.edge,startPosition:n.position,endPosition:n.edgePosition,baseline:!0,mask:cn(e).mask}),s.forEach(([t,n])=>{const[i,o]=Math.abs(n-l)<Math.abs(t-l)?[n,t]:[t,n];e._breaks.push({start:i,end:o,startPosition:c(i),endPosition:c(o),baseline:!1,mask:r})})}function un(e,t,n=!0){const i=t.filter(t=>{const n=Number(t);return!e.some(e=>n>Math.min(e.start,e.end)&&n<Math.max(e.start,e.end))});return n&&e.forEach(e=>{e.baseline&&!i.some(t=>Number(t)===e.start)&&i.push(e.start)}),i}function dn(e,t){const{gap:n}=sn(e,t.baseline?"baselineBreakConfig":"breakConfig"),i=(t.startPosition+t.endPosition)/2;return[i-n/2,i+n/2]}function fn(e,t,n){const i=n(e.schema.barConfig),o=e._breaks||[];return o.length?mn(e,o,t,i,n):[{type:"line",key:"bar",points:t,paint:i}]}function mn(e,t,n,i,o){const a=e._position.horizontal,r=a?0:1,s=n[0][1-r],c=(e,t)=>a?[e,t]:[t,e],l=n.map(e=>e[r]),h=t.find(e=>e.baseline);h&&l.push(h.startPosition);const u=Math.min(...l),d=Math.max(...l),f=["top","left"].includes(e.schema.orient)?-1:1,m=t.map(t=>dn(e,t)).sort((e,t)=>e[0]-t[0]),p=[];let g=u;m.forEach(([e,t])=>{p.push([g,e]),g=t}),p.push([g,d]);const y=h?h.startPosition<=u?0:p.length-1:-1,x=y>0;let b=0;const _=p.map(([e,t],n)=>{const o=n===y?"bar-baseline":b++?"bar-"+(b-1):"bar",a=[c(e,s),c(t,s)];return{type:"line",key:o,points:x?a.reverse():a,paint:i}});y>0&&_.unshift(..._.splice(y,1));let k=0;return t.forEach(t=>{const n=t.baseline?"baselineBreakConfig":"breakConfig",{angle:i,size:a}=sn(e,n),r=o(e.schema[n]),l=Math.sign(t.endPosition-t.startPosition),h=i*Math.PI/180,u=Math.sin(h)*a,d=Math.cos(h)*a,m=e=>[c(e,s),c(e-l*u,s+f*d)],p=t.baseline?"baseline-break":"break-"+k++,[g,y]=dn(e,t),[x,b]=l<0?[y,g]:[g,y];_.push({type:"line",key:`${p}-0`,points:m(x),paint:r},{type:"line",key:`${p}-1`,points:m(b),paint:r})}),_}function pn(e){if(null==e)return;const t=n.date(e);return t instanceof Date&&!isNaN(+t)?t:void 0}function gn(e){return e.map(pn).filter(e=>void 0!==e)}function yn(e,t){const[n,i]=h.extent(t.domain()).map(Number);return e.filter(e=>+e>=n&&+e<=i)}function xn(e){return e.schema.timeLocale||c.locale[e.schema.locale]||c.locale["en-US"]}function bn(e){const{_scaleData:t,schema:{domain:n}}=e;return $n(e,"timeReference",[t,n],()=>gn(t.length?t:n).sort((e,t)=>+e-+t))}function _n(e,t){const n=xn(e),i=function(e){return"time"===e.schema.scale?bn(e):Sn(e)}(e);return(i.length?$n(e,"dateLabel",[i,n],()=>d.dateFullFormatter(i,kn(n)))(t):d.formatDateFull(t,[t],kn(n))).replace(/^Q/,n.quarter)}function kn(e){let t=vn.get(e);return t||vn.set(e,t=g.timeFormatLocale(e).format),t}const vn=new WeakMap,wn=e=>e instanceof Date&&!isNaN(+e);function Sn(e){const{_scaleData:t,schema:{domain:n}}=e;return $n(e,"dateCategories",[n,t],()=>{const e=e=>Array.isArray(e)?e.filter(wn):[],i=e(n),o=i.length?i:e(t),a=new Set;return o.filter(e=>!a.has(+e)&&!!a.add(+e)).sort((e,t)=>+e-+t)})}function Cn(e){const t=e._shownLabels;if(!t)return;const n=Mn.get(e);if(n&&n[0]===t)return n[1];const i=gn(t).sort((e,t)=>+e-+t);return Mn.set(e,[t,i]),i}const Mn=new WeakMap;function $n(e,t,n,i){const o=n.flatMap(e=>Array.isArray(e)?[e,e.length]:[e]);let a=An.get(e);a||An.set(e,a=new Map);const r=a.get(t);if(r&&r.fingerprint.length===o.length&&r.fingerprint.every((e,t)=>e===o[t]))return r.value;const s=i();return a.set(t,{fingerprint:o,value:s}),s}const An=new WeakMap,zn=e=>"number"==typeof e&&e>=1e3&&e<=2999;function Dn(e){return e.length>0&&e.every(e=>zn(e)&&Number.isInteger(e))}function Fn(e){const t=e.schema.domain??[];return!(!t.length||!t.every(zn))&&Dn(e._scaleData.length?e._scaleData:t)}function Bn(e,t="en-US"){return d.formatAbbreviate(e,t,"~f")}const Ln=e=>e<0||Object.is(e,-0),Pn=e=>Math.pow(10,Math.floor(Math.log10(Math.abs(e))))*Math.pow(-1,Ln(e)?1:0),Rn=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,Ln(e)?1:0),En=e=>{const t=`${e}`;if(t.includes("e-")||"0"===t)return 0;const n=t.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(n)return+`${n[1]}${+n[2]+1}`;const i=t.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return i?+`${i[1]}${+i[2]}`:e};function Nn(e,t,n){const i=e=>{if(o){if(!e)return 0;const t=`${e}`.match(/0\.(0*)/);if(t)return+`0.${Array(t[1].length+1).fill(0).join("")}1`}return`${Math.round(Math.abs(e))}`.length},o=e.every(e=>Math.abs(e)<1),a=[i(e[0]),i(e[1])].filter(Boolean).sort();if(!a.length)return;const r=e.some(e=>Ln(e))&&e.some(e=>e>0),s=1===a.length?a[0]:a[0]>1&&a[0]===a[1]?a[0]-1:"outside"!==t&&r?h.max(a):a[0]+(a[1]-a[0])/2;let c=s<1?En(s):+`1${Array(Math.floor(En(s))-1).fill(0).join("")}`;c>=Math.abs(e[1]-e[0])&&(c/=2);const l=e[1]<e[0],u=[Math["outside"===t?l?"ceil":"floor":l?"floor":"ceil"](e[0]/c)*c,Math["outside"===t?l?"floor":"ceil":l?"ceil":"floor"](e[1]/c)*c];return"log"===n&&(0===u[0]&&(u[0]=e[0]),0===u[1]&&(u[1]=e[1])),u.map(En)}const Tn=["linear","log","pow","sqrt"];function On(e,t,n){if(["linear","pow","sqrt"].includes(n))return Nn(e,t,n);if("log"===n){const i=[],o=e[1]<e[0];i[0]=("outside"===t?Ln(e[0])?o?Pn:Rn:o?Rn:Pn:Ln(e[0])?o?Rn:Pn:o?Pn:Rn)(e[0]),i[1]=("inside"===t?Ln(e[1])?o?Pn:Rn:o?Rn:Pn:(Ln(e[1]),o?Pn:Rn))(e[1]);const a=i[1]<i[0];return i[0]!==i[1]&&i.some(e=>Math.abs(e)>10)&&a===o?i:Nn(e,t,n)}}const Wn=(e,t)=>e<0?-Math.pow(-e,t):Math.pow(e,t);function jn(e,t){return e.map(e=>{const n=Math.min(...t.map(t=>Math.abs(t-e)).filter(e=>e>0));return function(e,t){if(!(t>0&&Number.isFinite(t)))return e;let n=Math.floor(Math.log10(Math.max(Math.abs(e),t)))+1;for(;n>-30;n--)for(const i of[5,2,1]){const o=i*Math.pow(10,n),a=Math.round(e/o)*o;if(Math.abs(a-e)<=t)return+a.toPrecision(12)}return e}(e,n/3)})}function Hn(e,t,n){let i,o,a;const r=(n,i)=>(a&&a.dates===n&&a.format===g.timeFormat||(a={dates:n,format:g.timeFormat,label:d.dateFormatter(n,g.timeFormat)}),a.label(i,Cn(e)).replace(/^Q/g,t.quarter)),s=e.schema.tickFormat;return s?t=>s.call(e,t):t=>{if(wn(t)&&(e=>["band","ordinal","point"].includes(e.schema.scale))(e))return r(o??(o=Sn(e)),t);if(isNaN(t)||["band","ordinal","point"].includes(e.schema.scale))return t;if("time"===e.schema.scale)return r(bn(e),t);if("linear"===e.schema.scale&&"smallest"===e.schema.tickSuffix){const n="object"==typeof e.schema.locale?e.schema.locale:c.formatLocale[e.schema.locale],{separator:i,suffixes:o}=n,a=t>=1e3?o[e._tickUnit+8]:"",r=t/Math.pow(10,3*e._tickUnit);return`${d.formatAbbreviate(r,n,`,.${r.toString().length}r`)}${i}${a}`}{const o=n(),a=o[1]<o[0],r=a?o.length-1:0,s=a?0:o.length-1,c="inside"===e.schema.rounding?o.indexOf(t)===r?e.schema.roundingInsideMinPrefix:o.indexOf(t)===s?e.schema.roundingInsideMaxPrefix:"":"",l="inside"===e.schema.rounding?o.indexOf(t)===r?e.schema.roundingInsideMinSuffix:o.indexOf(t)===s?e.schema.roundingInsideMaxSuffix:"":"";i??(i=Fn(e));return`${c}${i?Bn(t,e.schema.locale):d.formatAbbreviate(t,e.schema.locale)}${l}`}}}function In(e){const{labels:t}=e.schema;return Array.isArray(t)&&t.length&&t.every(Array.isArray)?t:void 0}function Gn(e,t,n,i){const o=function(e,t,n){let i=n?n.slice():[],[o,a]=t;e.schema.range&&(void 0!==e.schema.range[0]&&(o=e.schema.range[0]),void 0!==e.schema.range[e.schema.range.length-1]&&(a=e.schema.range[e.schema.range.length-1])),(void 0===i[0]||i[0]<o)&&(i[0]=o),(void 0===i[1]||i[1]>a)&&(i[1]=a);const r=a-o;if("ordinal"===e.schema.scale&&e.schema.domain.length>i.length)if(n===e.schema.range){const t=e.schema.domain.length+1;i=h.range(t).map(e=>i[0]+r*(e/(t-1))).slice(1,t),i=i.map(e=>e-i[0]/2)}else{const t=e.schema.domain.length,n=i[1]-i[0];i=h.range(t).map(e=>i[0]+n*(e/(t-1)))}return i}(e,t,void 0!==i?i:e.schema.range),a=`scale${e.schema.scale.charAt(0).toUpperCase()}${e.schema.scale.slice(1)}`,r=e.schema.domain.slice();var s;if(e._d3Scale=B[a]().domain("time"===e.schema.scale?function(e){const t=e.schema.domain.map(pn),n=e._scaleData;return t.some(e=>void 0===e)&&n.length?h.extent(n):t}(e):r).range(o),"pow"===e.schema.scale&&e._d3Scale.exponent&&e._d3Scale.exponent("number"==typeof(s=e.schema.exponent)&&Number.isFinite(s)&&s>0?s:1),"none"!==e.schema.rounding){const t=On(r,e.schema.rounding,e.schema.scale);t&&e._d3Scale.domain(t)}e.schema.reverse&&e._d3Scale.domain(e._d3Scale.domain().slice().reverse()),e._d3Scale.padding&&e._d3Scale.padding(e.schema.scalePadding),e._d3Scale.align&&e._d3Scale.align(e.schema.scaleAlign),e._d3Scale.paddingInner&&e._d3Scale.paddingInner(e.schema.paddingInner),e._d3Scale.paddingOuter&&e._d3Scale.paddingOuter(e.schema.paddingOuter),e._d3ScaleNegative=null,"log"===e.schema.scale&&function(e){const t=e._d3Scale.domain(),n=e._scaleData;if(0===t[0]){const e=h.min([h.min(n),Math.abs(t[1])]);t[0]=0===e||1===e?1e-6:e<=1?Pn(e):1,Ln(t[1])&&(t[0]*=-1)}else if(0===t[t.length-1]){const e=h.min([h.min(n),Math.abs(t[0])]);t[t.length-1]=0===e||1===e?1e-6:e<=1?Pn(e):1,Ln(t[0])&&(t[t.length-1]*=-1)}const i=e._d3Scale.range();if(Ln(t[0])&&Ln(t[t.length-1]))e._d3ScaleNegative=e._d3Scale.copy().domain(t).range(i),e._d3Scale=null;else if(t[0]>0&&t[t.length-1]>0)e._d3Scale.domain(t).range(i);else{const o=t.map(e=>Math.log10(Math.abs(e))).map(e=>e||-1e-6),a=o[0]/h.sum(o)*(i[1]-i[0]);let r=h.min([h.min(n.filter(e=>e>=0)),Math.abs(t[1])]);1===r&&(r=1e-6);let s=h.min([h.min(n.filter(Ln)),Math.abs(t[0])]);1===s&&(s=1e-6);const c=0===r?1e-6:r<=1?Pn(r):1,l=0===s?-1e-6:s<=1?Pn(s):1,u=h.min([Math.abs(c),Math.abs(l)]);e._d3ScaleNegative=e._d3Scale.copy(),(Ln(t[0])?e._d3Scale:e._d3ScaleNegative).domain([Ln(t[0])?u:-u,t[1]]).range([i[0]+a,i[1]]),(Ln(t[0])?e._d3ScaleNegative:e._d3Scale).domain([t[0],Ln(t[0])?-u:u]).range([i[0],i[0]+a])}}(e),hn(e,o);const{ticks:c,labels:l}=function(e){const t=In(e),n=t?t[Math.min(e._labelSet??0,t.length-1)]:e.schema.labels,i=e.schema.ticks||(t?n:void 0);let o=(i?"time"===e.schema.scale?gn(i):i:(e._d3Scale?e._d3Scale.ticks:e._d3ScaleNegative?.ticks)?e._getTicks():e.schema.domain).slice(),a=(n?"time"===e.schema.scale?gn(n):n:(e._d3Scale?e._d3Scale.ticks:e._d3ScaleNegative?.ticks)?e._getLabels():o).slice();return"time"===e.schema.scale&&(o=o.map(Number),a=a.map(Number)),e._breaks.length&&(o=un(e._breaks,o),a=un(e._breaks,a,!n)),o=o.sort((t,n)=>e._getPosition(t)-e._getPosition(n)),a=a.sort((t,n)=>e._getPosition(t)-e._getPosition(n)),{ticks:o,labels:a}}(e);!function(e,t){if("linear"===e.schema.scale&&"smallest"===e.schema.tickSuffix){const n=t.filter(e=>e>=1e3);if(n.length>0){const t=Math.min(...n);let i=1;for(;i&&i<7&&t/Math.pow(10,3*i)>=1;)e._tickUnit=i,i+=1}}}(e,l);const u=function(e,t,n){const i=[];return e._availableTicks=t,t.forEach((t,o)=>{let a=n({id:t,tick:!0},o);"Circle"===e.schema.shape&&(a*=2);const r=e._getPosition(t);!i.length||Math.abs(f.closest(r,i.filter(e=>!1!==e))-r)>2*a?i.push(r):i.push(!1)}),t=t.filter((e,t)=>!1!==i[t]),e._visibleTicks=t,t}(e,c,n);return{range:o,ticks:u,labels:l}}function Vn(e){const t=xn(e);g.timeFormatDefaultLocale(t);const{width:n,height:i,x:o,y:r,horizontal:s,opposite:c}=e._position,l=e.schema.padding,u=[l,e.schema[n]-l],d="Circle"===e.schema.shape?e.schema.shapeConfig.r:"Rect"===e.schema.shape?e.schema.shapeConfig[n]:e.schema.shapeConfig.strokeWidth,f="function"!=typeof d?()=>d:d,m=e._margin={top:0,right:0,bottom:0,left:0};!function(e){An.delete(e)}(e),e._scaleData=function(e){if("time"!==e.schema.scale)return e._data??[];const t=gn(e._data??[]),n=(e.schema.domain??[]).map(pn);if(n.length<2||n.some(e=>void 0===e))return t;const[i,o]=h.extent(n);return t.filter(e=>e>=i&&e<=o)}(e);let p=[],y=[],x=[];const b=function(e,t,n){const i=Hn(e,t,n),o=e.schema.rotatedTickFormat;return o?t=>(e._labelRotation?o:i)(t):i}(e,t,()=>x);e._labelFormat=b;const _=t=>({range:y,ticks:x,labels:p}=Gn(e,u,f,t));e._labelSet=0,_(),function(e,t){if(!e.schema.title)return;const{range:n,p:i,height:o,margin:r}=t,{fontFamily:s,fontSize:c,lineHeight:l}=e.schema.titleConfig,h=a.textWrap().fontFamily("function"==typeof s?s():s).fontSize("function"==typeof c?c():c).lineHeight("function"==typeof l?l():l).width(n[n.length-1]-n[0]-2*i).height(e.schema[o]-e.schema.tickSize-2*i),u=h(e.schema.title).lines.length;r[e.schema.orient]=u*h.lineHeight()+i}(e,{range:y,p:l,height:i,margin:m});const{hBuff:k,wBuff:v}=function(e,t,n,i){let o="Circle"===e.schema.shape?"function"==typeof e.schema.shapeConfig.r?e.schema.shapeConfig.r({tick:!0}):e.schema.shapeConfig.r:"Rect"===e.schema.shape?"function"==typeof e.schema.shapeConfig[i]?e.schema.shapeConfig[i]({tick:!0}):e.schema.shapeConfig[i]:e.schema.tickSize,a=n({tick:!0});return"Rect"===e.schema.shape&&(o/=2),"Circle"!==e.schema.shape&&(a/=2),{hBuff:o,wBuff:a}}(e,0,f,i),w=s&&!Zt(e.schema.scale)&&Xn(e,p,b),S={rangeOuter:u,horizontal:s,hBuff:k,p:l,tickFormat:b,rescale:_,ownSpace:w},C=e._labelRotationSetting;Yn(e,function(e,t){return Et(e)?{rotate:!0,angle:Lt(e),slant:Nt(e,t)}:Pt}(C,s));let M=Kn(e,{range:y,labels:p},S);const $=In(e)?.length??0;for(let t=1;t<$&&Qn(M);t++)e._labelSet=t,M=Kn(e,_(),S);void 0===C&&s&&(M=function(e,t,n){const{labels:i,tickFormat:o,ownSpace:a,rangeOuter:r,relayout:s}=n,c=Qt(e,i),l=Xn(e,i,o)?e=>Qn(e):c?e=>e.length&&!e[0].fits?1:0:void 0,h=l?l(t):0;if(!l||!h||a&&2*h<t.length)return t;let u={turn:Pt,misses:h,data:t},d=Pt;for(const t of[{rotate:!0,angle:Rt(e.schema.orient),slant:!0},{rotate:!0,angle:-90,slant:!1}]){Yn(e,d=t);const n=s(),i=l(n)+(c&&n[0]?.truncated?1:0)+(t.slant&&qn(e,n,r).some(e=>e>1)?1:0);if(i<u.misses&&(u={turn:t,misses:i,data:n}),!i)break}return u.turn===d?u.data:(Yn(e,u.turn),s())}(e,M,{labels:p,tickFormat:b,ownSpace:w,rangeOuter:u,relayout:()=>Kn(e,_(),S)})),function(e,t,n){const i=new Set(t.filter(e=>e.truncated).map(e=>e.d));i.size&&(e._visibleTicks=n.filter(e=>!i.has(e)))}(e,M,x),e._labelOverflow=qn(e,M,y);const A=h.max(M,e=>e.height)||0;!function(e,t){const n=e.schema.labelOffset?h.max(t,e=>e.offset||0):0;t.forEach(e=>e.offset=e.offset?n:0)}(e,M);const z=function(e,t){const{textData:n,rangeOuter:i,hBuff:o,horizontal:a,p:r,width:s,height:c,x:l,y:u,opposite:d,margin:f}=t,m="Line"===e.schema.shape?0:o,p=e._outerBounds={[c]:(h.max(n,e=>Math.ceil(Jt(e,a)+(e.offset??0)))||0)+(n.length?r:0),[s]:i[i.length-1]-i[0],[l]:i[0]};return p[c]="number"==typeof e.schema.fixedSize?e.schema.fixedSize:h.max([e.schema.minSize,p[c]]),e._labelSpace=p[c],f[e.schema.orient]+=o,f[d]=void 0!==e.schema.gridSize?h.max([e.schema.gridSize,m]):e.schema[c]-f[e.schema.orient]-p[c]-r,p[c]+=f[d]+f[e.schema.orient],p[u]="start"===e.schema.align?e.schema.padding:"end"===e.schema.align?e.schema[c]-p[c]-e.schema.padding:e.schema[c]/2-p[c]/2,p}(e,{textData:M,rangeOuter:u,hBuff:k,horizontal:s,p:l,width:n,height:i,x:o,y:r,opposite:c,margin:m});return{ticks:x,labels:p,range:y,textData:M,tickFormat:b,hBuff:k,wBuff:v,tickGet:f,labelHeight:A,bounds:z}}function qn(e,t,n){const i=t.filter(e=>!e.truncated&&e.slant);if(!i.length)return[0,0];const o=Math.min(n[0],n[n.length-1]),a=Math.max(n[0],n[n.length-1]),r=t=>Ht(e.schema.orient,t.angle,t.width,t.height-t.fP),s=i[0],c=i[i.length-1];return[Math.max(0,r(s)[0]-(s.position-o)),Math.max(0,r(c)[1]-(a-c.position))]}function Yn(e,t){e._labelRotation=t.rotate,e._labelAngle=t.angle,e._labelSlant=t.slant}function Kn(e,t,n){const{rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,rescale:c,ownSpace:l}=n;let{labels:h}=t,u=Xt(e,{labels:h,rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,ownSpace:l});const d=e.schema.labelOffset&&u.some(e=>e.truncated);d&&(u=Xt(e,{labels:h,rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,ownSpace:l,offset:2}));let[f,m]=t.range;for(let t=0;t<3;t++){const t=u.filter(e=>!e.truncated),n=[0,1].map(n=>{const a=t[n?t.length-1:0];if(!a)return 0;const{height:r,position:s,rotate:c,width:l}=a,h=n?i[1]:i[0],u=a.slant?Ht(e.schema.orient,a.angle,l,r-a.fP)[n]:(c||!o?r:l)/2,d=n?h-s:s-h;return d>=u?0:u-d}),p=m-f-(i[1]-i[0])/2,g=n[0]+n[1],y=g>p&&t.some(e=>e.slant)?Math.max(0,p)/g:1,x=[f+n[0]*y,m-n[1]*y];if(e.schema.range&&(void 0!==e.schema.range[0]&&(x[0]=e.schema.range[0]),void 0!==e.schema.range[e.schema.range.length-1]&&(x[1]=e.schema.range[e.schema.range.length-1])),x[0]===f&&x[1]===m)break;const b=Un(u);if([f,m]=x,({labels:h}=c(x)),u=Xt(e,{labels:h,rangeOuter:i,horizontal:o,hBuff:a,p:r,tickFormat:s,ownSpace:l,offset:d?2:1}),Un(u)===b&&!u.some(e=>e.slant))break}return u}function Un(e){const t=e.filter(e=>!e.truncated);return[t[0],t[t.length-1]].map(e=>e?`${e.d instanceof Date?+e.d:e.d}`:"").join(",")}function Xn(e,t,n){const i=e=>!(e instanceof Date)&&isNaN(e);return Zt(e.schema.scale)?t.some(i):Array.isArray(e.schema.labels)&&!!n&&t.some(e=>i(n(e)))}function Qn(e){return e.filter(e=>!e.fits||e.truncated).length}function Zn(e,t){const i=e?n.backgroundColor(e):"rgb(255, 255, 255)";return r.colorContrast(i,t)===t.dark?r.colorGray[200]:r.colorGray[800]}function Jn(e){return()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)}}function ei(e){return{angle:30,gap:5,lineConfig:{},lines:!0,mask:!0,size:10,space:36,stroke:Jn(e),"stroke-width":1}}function ti(e,t,n,i=0){const o=t=>{if("function"==typeof t)try{return t.call(e,n,i)}catch{return}return t},a={},r=o(t.stroke);null!=r&&(a.stroke=String(r));const s=o(t["stroke-width"]);null!=s&&(a.strokeWidth=Number(s));const c=o(t["stroke-opacity"]);null!=c&&(a.strokeOpacity=Number(c));const l=o(t["stroke-linecap"]);null!=l&&(a.strokeLinecap=l);const h=o(t["stroke-dasharray"]);if(null!=h){const e=String(h).split(/[\s,]+/).map(Number).filter(e=>Number.isFinite(e));e.length&&(a.strokeDasharray=e)}const u=o(t.opacity);null!=u&&(a.opacity=Number(u));const d=o(t.fill);return null!=d&&(a.fill=String(d)),a}function ni(e){if(!e._d3Scale&&!e._d3ScaleNegative)return null;const{height:t,x:n,y:i,opposite:o}=e._position,a=e._margin[o],r=["top","left"].includes(e.schema.orient)?e._outerBounds[i]+e._outerBounds[t]-a:e._outerBounds[i]+a,s="point"===e.schema.scale&&e._d3Scale.align?e._d3Scale.align():.5,c="band"===e.schema.scale?e._d3Scale.step()-e._d3Scale.bandwidth():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding()*2*s:0,l="band"===e.schema.scale?e._d3Scale.step():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding()*2*(1-s):0,h=(e._d3ScaleNegative?e._d3ScaleNegative.domain():[]).concat(e._d3Scale?e._d3Scale.domain():[]).sort((e,t)=>e-t);if(!h.length)return null;const u=e._getPosition(h[0])-c,d=e._getPosition(h[h.length-1])+l;return{points:"x"===n?[[u,r],[d,r]]:[[r,u],[r,d]]}}function ii(e,t,n,i=.5){if(t.length<3)return!1;const o=t.map(n).sort((e,t)=>e-t),a=n(e);if(![a,...o].every(Number.isFinite))return!1;const r=o.length-1,s=Math.abs(a-o[0])<=Math.abs(a-o[r]),c=s?o[0]:o[r],l=s?o[1]:o[r-1],h=Math.abs(c-l);return!!h&&Math.abs(a-c)-h*i<=1e-9*h}const oi=936e5;function ai(e,t,n){const i=B.scaleLinear().domain([200,1200]).range([8,28]),o=e.range(),a=Math.abs(o[1]-o[0]);let r=Math.floor(i(a));if("time"===this.schema.scale)if(n.length){const e=h.extent(n),i=n.reduce((e,t,n,i)=>{if(n){const o=Math.abs(t-i[n-1]);o<e&&(e=o)}return e},1/0),o=Math.round((e[1]-e[0])/i);r=h.min([r*(t?2:.5),o])}else r=t?2*r:r/2;return Math.floor(r)}function ri(e,t=!1){if(en(e))return an(e,e=>ri.call(this,e,t),t?void 0:(e,t,n)=>!ii(e,t,e=>n(e)));let i;const o=e.copy(),a="time"===this.schema.scale?yn(this._scaleData,e):[];if(a.length){const t=h.extent(a),n=t.map(t=>e(t));o.domain(t).range(n)}const r=o.domain(),s=r[1]<r[0],c=ai.call(this,o,t,a);if(t||"log"!==this.schema.scale){if(o.exponent&&1!==o.exponent())i=function(e,t,n,i=!1){const[o,a]=e.map(Number),r=Math.min(o,a),s=Math.max(o,a);if(!Number.isFinite(r)||!Number.isFinite(s)||r===s||!t)return r===s&&Number.isFinite(r)?[r]:[];const c=Math.max(1,Math.round(n)),l=Wn(r,t),h=Wn(s,t),u=e=>Array.from({length:e+1},(n,i)=>Wn(l+(h-l)*i/e,1/t)),d=u(c),f=jn(d,d);let m=f;if(i){const e=u(2*c),t=e.filter((e,t)=>t%2);m=f.concat(jn(t,e))}const p=Array.from(new Set(m)).filter(e=>e>=r&&e<=s).sort((e,t)=>e-t);return a<o?p.reverse():p}(r,o.exponent(),Math.max(1,c/2),t);else if(i=o.ticks(c),!t&&!["log","time"].includes(this.schema.scale)&&i.length>1){const e=Math.abs(2*En(i[1]-i[0]));i=i.filter(t=>{const n=Math.abs(t)%e,i=En(n);return i!==n?!i||i===e:0===n})}}else{const e=r.map(e=>Math.log10(e)%1==0?e:(s?Rn:Pn)(e)),t=e[1]<e[0],n=e.map(e=>(Ln(e)?-1:1)*([-1,1].includes(e)||Math.abs(e)<1?1:Math.log10(Math.abs(e)))),a=Math.ceil((Math.abs(n[1]-n[0])+1)/(.65*c));i=a<=1&&n[0]===n[1]||t!==s?o.ticks(c).filter(e=>+`${e}`.replace("0.","")%2==0):h.range(n[0],n[1],n[1]<n[0]?-1:1).concat([n[1]]).filter(e=>Math.abs(e)%a===0).map(e=>+(""+(Ln(e)?-1:1)*(e?Math.pow(10,Math.abs(e)):Math.sign(1/e)>0?1:-1)).replace(/9+/g,"1"))}if("time"===this.schema.scale&&this._scaleData.length){const e=this._scaleData.map(Number);i=i.filter(t=>{const n=+t;return e.find(e=>e>=n-oi&&e<=n+oi)})}return function(e,t,i,o,a){if(!1===e.schema.domainTicks)return t;const r=i[1]<i[0],s=t.map(Number),c=(e.schema.ticks??[]).map(t=>Number("time"===e.schema.scale?n.date(t):t)),l=e=>!t.map(Number).includes(Number(e))&&(!a||c.includes(Number(e))||!ii(Number(e),s,e=>o(e))),h=n=>!e._d3ScaleNegative||Ln(n)===t.some(e=>Ln(e));return h(i[r?1:0])&&l(i[0])&&t.unshift(i[0]),h(i[r?0:1])&&l(i[1])&&t.push(i[1]),t}(this,i,r,o,!t)}function si(e,t,n){const{x:i,y:o,width:a,height:r}=jt(e.schema.orient,t.angle,t.width,t.height-t.fP,t.height,n);return{x:i,y:o,width:a,height:r}}function ci(e,t,n){const{fP:i,fS:o,lineHeight:a,lines:r,width:s}=t,c=a*r.length;return{x:-s/2+((t.angle??-90)>0?-1:1)*(o/4),y:"bottom"===e.schema.orient?n+(s-c)/2+i:n-(s+c)/2-2*i,width:s,height:t.height}}const li=[{key:"align",coerce:"identity",default:"middle"},{key:"baseline",coerce:"identity",default:0},{key:"baselineBreak",coerce:"identity",default:!1},{key:"break",coerce:"identity",default:!1},{key:"domain",coerce:"identity",default:[0,10]},{key:"domainTicks",coerce:"identity",default:!0},{key:"duration",coerce:"identity",default:600},{key:"exponent",coerce:"identity",default:1},{key:"grid",coerce:"identity"},{key:"gridLog",coerce:"identity",default:!1},{key:"gridSize",coerce:"identity"},{key:"height",coerce:"identity",default:400},{key:"labels",coerce:"identity"},{key:"labelOffset",coerce:"identity",default:!1},{key:"fixedSize",coerce:"identity"},{key:"maxSize",coerce:"identity"},{key:"minSize",coerce:"identity"},{key:"padding",coerce:"identity",default:5},{key:"paddingInner",coerce:"identity",default:.1},{key:"paddingOuter",coerce:"identity",default:.1},{key:"range",coerce:"identity"},{key:"renderMode",coerce:"identity",default:"full"},{key:"reverse",coerce:"identity",default:!1},{key:"rotatedTickFormat",coerce:"identity"},{key:"rounding",coerce:"identity",default:"none"},{key:"roundingInsideMinPrefix",coerce:"identity",default:"< "},{key:"roundingInsideMinSuffix",coerce:"identity",default:""},{key:"roundingInsideMaxPrefix",coerce:"identity",default:""},{key:"roundingInsideMaxSuffix",coerce:"identity",default:"+"},{key:"scale",coerce:"identity",default:"linear"},{key:"scaleAlign",coerce:"identity",default:.5},{key:"scalePadding",coerce:"identity",default:.5},{key:"shape",coerce:"identity",default:"Line"},{key:"tickFormat",coerce:"identity"},{key:"ticks",coerce:"identity"},{key:"tickSize",coerce:"identity",default:8},{key:"tickSuffix",coerce:"identity",default:"normal"},{key:"timeLocale",coerce:"identity",default:void 0},{key:"title",coerce:"identity"},{key:"width",coerce:"identity",default:400}];class hi extends $e{_getDomain(){let e=[];this._d3ScaleNegative&&(e=this._d3ScaleNegative.domain()),this._d3Scale&&(e=e.concat(this._d3Scale.domain())),this._baselineBreak&&(e=e.concat([this._baselineBreak.value]));const t=["band","ordinal","point"].includes(this.schema.scale)?e:h.extent(e);return e[0]>e[1]?t.reverse():t}_givenDomain(e=!1){const t=(e?this._d3ScaleNegative:this._d3Scale).domain();return this.schema.reverse?t.slice().reverse():t}_getPosition(e){if("log"===this.schema.scale){if(0===e)return(this._d3Scale||this._d3ScaleNegative).range()[this._d3Scale?0:1];const t=Ln(e)?this._d3ScaleNegative:this._d3Scale;return t?t(e):0}return this._d3Scale?this._d3Scale(e):0}_getRange(){let e=[];return this._d3ScaleNegative&&(e=this._d3ScaleNegative.range()),this._d3Scale&&(e=e.concat(this._d3Scale.range())),this._baselineBreak&&e.push(this._baselineBreak.position),e[0]>e[1]?h.extent(e).reverse():h.extent(e)}_getLabels(){let e=[];if(this._d3ScaleNegative&&(e=e.concat(ri.bind(this)(this._d3ScaleNegative,!1))),this._d3Scale&&(e=e.concat(ri.bind(this)(this._d3Scale,!1))),"log"===this.schema.scale){if(e.some(e=>Ln(e))&&e.some(e=>e>0)){const t=h.min([...this._d3ScaleNegative.domain().map(Math.abs),...this._d3Scale.domain()]);e.includes(t)||e.splice(e.findIndex(e=>e>t),0,t),e.includes(-t)&&e.includes(t)&&e.splice(e.indexOf(-t),1)}}return e}_getTicks(){const e="time"===this.schema.scale&&this._d3Scale?yn(this._scaleData,this._d3Scale):this._scaleData;if(["band","ordinal","point","time"].includes(this.schema.scale)&&e.length&&e.length<this.schema.width/4)return e;let t=[];return this._d3ScaleNegative&&(t=t.concat(ri.bind(this)(this._d3ScaleNegative,!0))),this._d3Scale&&(t=t.concat(ri.bind(this)(this._d3Scale,!0))),"log"===this.schema.scale&&t.includes(-1)&&t.includes(1)&&t.splice(t.indexOf(-1),1),t}toScene(){return function(e){const t=[],n=e._gridLineData??[];(function(e){if(!e._gridLineData||!e._gridLineData.length)return[];const{height:t,x:n,y:i,opposite:o}=e._position,a=e._margin[o],r=["top","left"].includes(e.schema.orient)?e._outerBounds[i]+e._outerBounds[t]-a:e._outerBounds[i]+a,s=["top","left"].includes(e.schema.orient)?a:-a,c="band"===e.schema.scale?e._d3Scale.bandwidth()/2:0,l="x"===n;return(e._gridLineData??[]).map(t=>{const n=e._getPosition(t.id)+c;return{points:[l?[n,r]:[r,n],l?[n,r+s]:[r+s,n]]}})})(e).forEach((i,o)=>{const a=ti(e,e.schema.gridConfig,n[o],o);t.push({type:"line",key:`grid-${o}`,points:i.points,paint:a})});const i=e._tickShape&&"function"==typeof e._tickShape.toScene?e._tickShape.toScene():null;if(i&&t.push(i),e._tickShape){const n=e._tickShape._labelClass;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){const e=n.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}const o=ni(e);let a;o&&t.push(...fn(e,o.points,t=>ti(e,t))),e._titleClass&&"function"==typeof e._titleClass.toScene&&e._titleClass._data&&e._titleClass._data.length&&t.push(e._titleClass.toScene());const r=e._select&&"function"==typeof e._select.node?e._select.node():null;if(r&&"function"==typeof r.getAttribute){const e=r.getAttribute("transform");if(e){const t=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);t&&(a={x:Number(t[1]),y:Number(t[2])})}}return{type:"group",key:`Axis-${e._uuid.slice(0,8)}`,...a?{transform:a}:{},children:t}}(this)}render(e){if(void 0===this._select&&"compute"!==this.schema.renderMode)if(this._managesOwnScenePaint){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width",`${this.schema.width}px`),e.setAttribute("height",`${this.schema.height}px`),document.body.appendChild(e),this.select(e)}else{const e=document.createElement("div");document.body.appendChild(e),this.select(e)}const t=Vn(this),{ticks:i,labels:o}=t,a=this._select,r="compute"===this.schema.renderMode&&(void 0===this._select||null===this._select||"function"==typeof this._select.node&&null===this._select.node())?null:n.elem(`g#d3plus-Axis-${this._uuid}`,{parent:a});this._group=r;const s=(0!==this.schema.gridSize?this.schema.grid||"log"===this.schema.scale&&!this.schema.gridLog?o:i:[]).map(e=>({id:e}));this._gridLineData=s;const c=function(e,t){const{ticks:n,labels:i,textData:o,tickFormat:a,hBuff:r,labelHeight:s}=t,{height:c,x:l,y:h,horizontal:u,opposite:d}=e._position,f=["top","left"].includes(e.schema.orient),m=e.schema.padding,p=e._margin,g=e._outerBounds,y=i.filter((e,t)=>o[t].lines.length&&!n.includes(e)),x=o.some(e=>e.rotate);let b=n.concat(y).map(t=>{const y=o.find(e=>e.d===t),b=e._getPosition(t),_=y?y.space:0,k=y?y.fP:0,v=y&&e.schema.labelOffset?y.offset??0:0,w=u?_:g.width-p[e._position.opposite]-r-p[e.schema.orient]+m,S=!u&&y&&"number"==typeof e.schema.fixedSize?Math.max(w,Math.ceil(y.width)+m):w,C=p[d],M=(r+v)*(f?-1:1),$=f?g[h]+g[c]-C:g[h]+C;return{id:t,labelBounds:y?.slant?si(e,y,Math.abs(M)+(u?k:m)):x&&y?ci(e,y,M):{x:u?-_/2:"left"===e.schema.orient?-S-m+M:M+m,y:u?"bottom"===e.schema.orient?M+k:M-s-k:-_/2,width:u?_:S,height:u?s:_},rotate:!!y&&y.rotate,angle:y?y.angle:0,size:i.includes(t)||"log"===e.schema.scale&&Math.log10(Math.abs(t))%1==0?M:n.includes(t)?Math.ceil(M/2):e._scaleData.find(e=>+e===t)?Math.ceil(M/4):0,text:!(y?.truncated||!i.includes(t))&&a(t),tick:n.includes(t),[l]:b+("band"===e.schema.scale?e._d3Scale.bandwidth()/2:0),[h]:$}});return"Line"===e.schema.shape&&(b=b.concat(b.map(e=>{const t=Object.assign({},e);return t[h]=t[h]+e.size,t}))),b}(this,t);return function(e,t){e._tickShape=(new E[e.schema.shape]).renderMode("compute").select(null).data(t).duration(e.schema.duration).labelConfig({ellipsis:e=>e&&e.length?`${e}...`:"",...e._labelRotation&&e._labelSlant?{split:Dt}:{},rotate:e=>{const t=void 0!==e.rotate?e:e.data;return t?.rotate?Number(t.angle??-90):0}}),e._tickShape.config(Ae.bind(e)(e.schema.shapeConfig)).labelConfig({padding:0}).render()}(this,c),function(e,t,i){const{range:o}=t,{horizontal:a}=e._position,r=e._margin,s=e._outerBounds;e._titleClass.renderMode("compute").data(e.schema.title?[{text:e.schema.title}]:[]).duration(e.schema.duration).height(r[e.schema.orient]).rotate("left"===e.schema.orient?-90:"right"===e.schema.orient?90:0).select(i?n.elem("g.d3plus-Axis-title",{parent:i}).node():null).text(e=>e.text).verticalAlign("middle").width(o[o.length-1]-o[0]).x(a?o[0]:"left"===e.schema.orient?s.x+r.left/2-(o[o.length-1]-o[0])/2:s.x+s.width-r.right/2-(o[o.length-1]-o[0])/2).y(a?"bottom"===e.schema.orient?s.y+s.height-r.bottom:s.y:o[0]+(o[o.length-1]-o[0])/2-r[e.schema.orient]/2).config(Ae.bind(e)(e.schema.titleConfig)).render()}(this,t,r),this._lastScale=this._getPosition.bind(this),"compute"===this.schema.renderMode||this._managesOwnScenePaint||De(this),e&&setTimeout(e,this.schema.duration+100),this}barConfig(e){return arguments.length?(this.schema.barConfig=Y(this,"barConfig",e),this):this.schema.barConfig}breakConfig(e){return arguments.length?(this.schema.breakConfig=Y(this,"breakConfig",e),this):this.schema.breakConfig}baselineBreakConfig(e){return arguments.length?(this.schema.baselineBreakConfig=Y(this,"baselineBreakConfig",e),this):this.schema.baselineBreakConfig}data(e){return arguments.length?(this._data=e,this):this._data}gridConfig(e){return arguments.length?(this.schema.gridConfig=Y(this,"gridConfig",e),this):this.schema.gridConfig}labelRotation(e){return arguments.length?(this._labelRotationSetting=e,this):this._labelRotationSetting}orient(e){if(arguments.length){const t=["top","bottom"].includes(e),n={top:"bottom",right:"left",bottom:"top",left:"right"};return this._position={horizontal:t,width:t?"width":"height",height:t?"height":"width",x:t?"x":"y",y:t?"y":"x",opposite:n[e]},this.schema.orient=e,this}return this.schema.orient}outerBounds(){return this._outerBounds}measure(){return Vn(this),this}select(e){return arguments.length?(this._select=null==e?void 0:t.select(e),this):this._select}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}titleConfig(e){return arguments.length?(this.schema.titleConfig=Y(this,"titleConfig",e),this):this.schema.titleConfig}constructor(){super(),this._scaleData=[],this._labelAngle=0,this._labelSlant=!1,this._labelOverflow=[0,0],this._d3Scale=null,this._d3ScaleNegative=null,this._baselineBreak=null,this._breaks=[],ee(this,li),this._data=[],this._labelRotation=!1,this._labelRotationSetting=void 0,this.schema.barConfig={stroke:Jn(this),"stroke-width":1},this.schema.baselineBreakConfig=ei(this),this.schema.breakConfig=ei(this),this.schema.gridConfig=function(e){return{stroke:()=>Zn(e._select?.node(),e.schema.colorDefaults),"stroke-width":1}}(this),this.orient("bottom"),this._outerBounds={width:0,height:0,x:0,y:0},this.schema.shapeConfig=function(e){return{fill:Jn(e),height:e=>e.tick?8:0,label:e=>e.text,labelBounds:e=>e.labelBounds,labelConfig:{fontColor:Jn(e),fontResize:!1,fontSize:N(12),padding:5,textAnchor:()=>{if(e._labelRotation&&e._labelSlant)return Wt(e.schema.orient,e._labelAngle);const t=n.rtl();return"left"===e.schema.orient?t?"start":"end":"right"===e.schema.orient?t?"end":"start":e._labelRotation?Wt(e.schema.orient,e._labelAngle):"middle"},verticalAlign:()=>"bottom"===e.schema.orient?"top":"top"===e.schema.orient?e._labelRotation?"top":"bottom":"middle"},r:e=>e.tick?4:0,stroke:Jn(e),strokeWidth:1,width:e=>e.tick?8:0}}(this),this._tickUnit=0,this._titleClass=new ro,this.schema.titleConfig=function(e){return{fontColor:Jn(e),fontSize:12,textAnchor:"middle"}}(this),this._margin={top:0,right:0,bottom:0,left:0},this._availableTicks=[],this._visibleTicks=[]}}K(hi.prototype,"barConfig","breakConfig","baselineBreakConfig","gridConfig","shapeConfig","titleConfig");class ui extends hi{constructor(){super(),this.orient("bottom")}}class di extends hi{constructor(){super(),this.orient("left")}}class fi extends hi{constructor(){super(),this.orient("right")}}class mi extends hi{constructor(){super(),this.orient("top")}}const pi=new WeakMap;function gi(e){const t=e._lineData,{align:n,direction:i,padding:o}=e.schema,a=e._outerBounds,r=[t,e._data,a.x,a.y,a.width,e._titleHeight,e._rtl,n,i,o],s=pi.get(e);if(s&&s.deps.every((e,t)=>e===r[t]))return s;const c=new Map;t.forEach(e=>{const t=c.get(e.y);t?t.push(e):c.set(e.y,[e])});const l=new Map,u=new Map;c.forEach((t,n)=>{l.set(n,e._rowWidth(t)),u.set(n,h.max(t.map(e=>e.height)))});const d=h.max(e._data.map((t,n)=>e._fetchConfig("height",t,n))),f=new Map,m=[],p=[];t.forEach(t=>{const r=t.y,s=l.get(r),c="left"===n||"right"===n&&"column"===i?0:"center"===n?(a.width-s)/2:a.width-s,g=f.get(r)||{widths:0,pads:0,last:0,count:0},y=g.count?g.widths+o*(g.pads-g.last):0,x=e._rtl?t.width+o:0;m.push(y+o*(g.count?t.sentence?2:1:0)+a.x+t.shapeWidth/2+c+x),p.push(r+e._titleHeight+a.y+h.max([u.get(r),d])/2);const b=t.width?2:1;f.set(r,{widths:g.widths+t.shapeWidth+t.width,pads:g.pads+b,last:b,count:g.count+1})});const g={deps:r,x:m,y:p};return pi.set(e,g),g}function yi(e,t,i){const o={lines:1,newRows:[],maxLines:h.max(e._lineData.map(e=>e.words.length))};if(e._wrapLines=()=>function(e,t,i,o){if(t.lines++,t.lines>t.maxLines)return;const r=1===t.lines?e._lineData.slice():e._lineData.filter(n=>n.width+n.shapeWidth+e.schema.padding*(n.width?2:1)>i&&n.words.length>=t.lines).sort((e,t)=>t.sentence.length-e.sentence.length);if(r.length&&o>r[0].height*t.lines){let i=!1;for(let e=0;e<r.length;e++){const o=r[e],s=o.og,c=s.height*t.lines,l=s.width*(1/t.lines*1.5),u=a.textWrap().fontFamily(o.f).fontSize(o.s).lineHeight(o.lh).width(l).height(c)(o.sentence);if(u.truncated){i=!0;break}o.width=Math.ceil(h.max(u.lines.map(e=>n.textWidth(e,{"font-family":o.f,"font-size":o.s}))))+o.s,o.height=u.lines.length*(o.lh+1)}i||e._wrapRows()}else t.newRows=[]}(e,o,t,i),e._wrapRows=()=>function(e,t,n,i){t.newRows=[];let o=1,a=0;for(let r=0;r<e._lineData.length;r++){const s=e._lineData[r],c=s.width+e.schema.padding*(s.width?2:1)+s.shapeWidth;if(h.sum(t.newRows.map(e=>h.max(e,e=>h.max([e.height,e.shapeHeight]))))>i){t.newRows=[];break}if(c>n){t.newRows=[],e._wrapLines();break}a+c<n?a+=c:"column"!==e.schema.direction&&(a=c,o++),t.newRows[o-1]||(t.newRows[o-1]=[]),t.newRows[o-1].push(s),"column"===e.schema.direction&&(a=0,o++)}}(e,o,t,i),e._wrapRows(),!o.newRows.length||h.sum(o.newRows,e._rowHeight.bind(e))+e.schema.padding>i){for(let t=0;t<e._lineData.length;t++)e._lineData[t].width=0,e._lineData[t].height=0;e._wrapRows()}return!(!o.newRows.length||h.sum(o.newRows,e._rowHeight.bind(e))+e.schema.padding>i)&&(o.newRows.forEach((t,n)=>{t.forEach(t=>{n&&(t.y=h.sum(o.newRows.slice(0,n),e._rowHeight.bind(e)))})}),h.max(o.newRows,e._rowWidth.bind(e)))}const xi=[{key:"align",coerce:"identity",default:"center"},{key:"direction",coerce:"identity",default:"row"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"id",coerce:"identity",default:T("id")},{key:"label",coerce:"const",default:T("id")},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"shape",coerce:"const",default:N("Rect")},{key:"title",coerce:"identity"},{key:"verticalAlign",coerce:"identity",default:"middle"},{key:"width",coerce:"identity",default:400}];class bi extends $e{_fetchConfig(e,t,n){const i=this.schema.shapeConfig.labelConfig,o=void 0!==this.schema.shapeConfig[e]?this.schema.shapeConfig[e]:i?.[e];return o||"lineHeight"!==e?"function"==typeof o?o(t,n):o:1.4*this._fetchConfig("fontSize",t,n)}_rowHeight(e){return h.max(e.map(e=>e.height).concat(e.map(e=>e.shapeHeight)))+this.schema.padding}_rowWidth(e){return h.sum(e.map((t,n)=>{const i=this.schema.padding*(n===e.length-1?0:t.width?2:1);return t.shapeWidth+t.width+i}))}toScene(){const e=[];let t;this._titleClass&&"function"==typeof this._titleClass.toScene&&this._titleClass._data&&this._titleClass._data.length&&e.push(this._titleClass.toScene()),(this._shapes||[]).forEach(t=>{const n=t;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){e.push(n.toScene());const t=n._labelClass;if(t&&"function"==typeof t.toScene&&t._data&&t._data.length){const n=t.toScene();n&&Array.isArray(n.children)&&e.push(...n.children)}}});const n=this._select&&"function"==typeof this._select.node?this._select.node():null;if(n&&"function"==typeof n.getAttribute){const e=n.getAttribute("transform");if(e){const n=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);n&&(t={x:Number(n[1]),y:Number(n[2])})}}return{type:"group",key:`Legend-${this._uuid.slice(0,8)}`,...t?{transform:t}:{},children:e}}render(e){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(t.select("body").append("div").node()),this._group=n.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=n.elem("g.d3plus-Legend-title",{parent:this._group}),this._shapeGroup=n.elem("g.d3plus-Legend-shape",{parent:this._group}),function(e){if(e._titleHeight=0,e._titleWidth=0,e.schema.title){const t=e.schema.titleConfig.fontFamily||e._titleClass.fontFamily()(),n=e.schema.titleConfig.fontSize||e._titleClass.fontSize()();let i=e.schema.titleConfig.lineHeight||e._titleClass.lineHeight();i="function"==typeof i?i():i??1.4*n;const o=a.textWrap().fontFamily(t).fontSize(n).lineHeight(i).width(e.schema.width).height(e.schema.height)(e.schema.title);e._titleHeight=i+o.lines.length+e.schema.padding,e._titleWidth=h.max(o.widths)}}(this);const i=this.schema.height-this._titleHeight;this._lineData=function(e,t){return e._data.map((i,o)=>{const r=e.schema.label(i,o),s=e.schema.shape(i,o),c=e._fetchConfig("r",i,o),l=e._fetchConfig("height",i,o);let u={data:i,i:o,id:e.schema.id(i,o),shape:s,shapeR:c,shapeWidth:"Circle"===s?2*c:"Line"===s?l:e._fetchConfig("width",i,o),shapeHeight:"Circle"===s?2*c:l,y:0};if(!r)return u.sentence=!1,u.words=[],u.height=0,u.width=0,u;const d=e._fetchConfig("fontFamily",i,o),f=e._fetchConfig("lineHeight",i,o),m=e._fetchConfig("fontSize",i,o),p=t-(e._data.length+1)*e.schema.padding,g=e.schema.width,y=a.textWrap().fontFamily(d).fontSize(m).lineHeight(f).width(g).height(p)(r);return u=Object.assign(u,y),u.width=u.lines.length?Math.ceil(h.max(u.lines.map(e=>n.textWidth(e,{"font-family":d,"font-size":m}))))+10:0,u.height=Math.ceil(u.lines.length*(f+1)),u.og={height:u.height,width:u.width},u.f=d,u.s=m,u.lh=f,u})}(this,i);let o=this._rowWidth(this._lineData);const r=this.schema.width-2*this.schema.padding;var s;return("column"===this.schema.direction||o>r)&&(o=yi(this,r,i)),!1===o?((s=this)._titleClass.data([]),s._shapes=[],Object.assign(s._outerBounds,{width:0,height:0,x:0,y:0})):(function(e,t){const n=h.max(e._lineData,(t,n)=>h.max([t.height,e._fetchConfig("height",t.data,n)])+t.y)+e._titleHeight,i=h.max([t,e._titleWidth]);e._outerBounds.width=i,e._outerBounds.height=n;let o=e.schema.padding,a=e.schema.padding;"center"===e.schema.align?o=(e.schema.width-i)/2:"right"===e.schema.align&&(o=e.schema.width-e.schema.padding-i),"middle"===e.schema.verticalAlign?a=(e.schema.height-n)/2:"bottom"===e.schema.verticalAlign&&(a=e.schema.height-e.schema.padding-n),e._outerBounds.x=o,e._outerBounds.y=a}(this,o),function(e){e._titleClass.renderMode("compute").data(e.schema.title?[{text:e.schema.title}]:[]).duration(e.schema.duration).select(e._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[e.schema.align]).width(e.schema.width-2*e.schema.padding).x(e.schema.padding).y(e._outerBounds.y).config(e.schema.titleConfig).render()}(this),function(e){e._shapes=[];const t=Ae.bind(e)(e.schema.shapeConfig,"legend"),n={id:e=>e.id,label:e=>e.label},i=e._data.map((t,n)=>({__d3plus__:!0,data:t,i:n,id:e.schema.id(t,n),label:!!e._lineData[n].width&&e.schema.label(t,n),shape:e.schema.shape(t,n)}));e._shapes=[],["Circle","Rect"].forEach(o=>{e._shapes.push((new E[o]).renderMode("compute").parent(e).data(i.filter(e=>e.shape===o||"Line"===e.shape)).duration(e.schema.duration).labelConfig({padding:0}).select(e._shapeGroup.node()).verticalAlign("top").config(t).config(n).config(function(e,t){const n=e=>"Line"===e.shape,i=(t,n)=>e._fetchConfig(t,n.data,n.i),o=t=>e._lineData[t.i];return"Rect"===t?{width:e=>n(e)?o(e).shapeWidth:i("width",e),height:e=>n(e)?2:i("height",e)}:{r:e=>n(e)?.3*o(e).shapeHeight:i("r",e),label:e=>!n(e)&&e.label,hitArea:e=>n(e)?null:i("hitArea",e)}}(e,o)).render())})}(this)),"compute"!==this.schema.renderMode&&De(this),e&&setTimeout(e,this.schema.duration+100),this}active(e){return this._shapes.forEach(t=>t.active(e)),this}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){return this._shapes.forEach(t=>t.hover(e)),this}outerBounds(){return this._outerBounds}select(e){return arguments.length?(this._select=t.select(e),this._rtl=n.rtl(),this):this._select}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}titleConfig(e){return arguments.length?(this.schema.titleConfig=Y(this,"titleConfig",e),this):this.schema.titleConfig}constructor(){var e;super(),ee(this,xi),this._titleClass=new ro,this._data=[],this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._shapes=[],this.schema.shapeConfig=(e=this,{fill:T("color"),height:N(12),hitArea:(t,n)=>{const i=e._lineData[n],o=h.max([i.height,i.shapeHeight]);return{width:i.width+i.shapeWidth,height:o,x:-i.shapeWidth/2,y:-o/2}},labelBounds:(t,n)=>{const i=e._lineData[n],o=i.shapeWidth/2,a=h.max([i.shapeHeight,i.height]),r=e._rtl?i.shapeWidth+i.width+2*e.schema.padding:0;return{width:i.width,height:a,x:o+5-r,y:-a/2}},labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)},fontFamily:e._titleClass.fontFamily(),fontResize:!1,fontSize:N(10),pointerEvents:N("none"),textAnchor:"start",verticalAlign:"middle"},opacity:1,r:N(6),width:N(12),x:(t,n)=>gi(e).x[n],y:(t,n)=>gi(e).y[n]}),this.schema.titleConfig={fontSize:12},this._rtl=!1,this._titleHeight=0,this._titleWidth=0}}function _i(e){const[t,n]=e.toExponential(14).split("e"),i=t.split(".")[1].replace(/0+$/,"");return Math.max(0,i.length-Number(n))}K(bi.prototype,"shapeConfig","titleConfig");const ki=(e,t)=>+(e*10**t).toPrecision(15),vi=(e,t)=>+(e/10**t).toPrecision(15);const wi=["buckets","jenks","linear","log","quantile"],Si=e=>"buckets"===e||"jenks"===e||"quantile"===e;const Ci=e=>e.schema.colorMin??e.schema.colorDefaults.off,Mi=e=>e.schema.colorMid??e.schema.colorDefaults.light,$i=e=>e.schema.colorMax??e.schema.colorDefaults.sequential;function Ai(e,t){const{scale:n}=t;let i=e.schema.buckets instanceof Array?e.schema.buckets:void 0;const o=t.diverging&&!t.colors?function(e,t,n){const{domain:i,numBuckets:o}=t,a=Math.floor(o/2),r=x.interpolateRgb.gamma(2.2)(Ci(e),Mi(e)),s=h.range(0,a,1).map(e=>r(e/a)),c=(o%2?[0]:[]).map(()=>Mi(e)),l=x.interpolateRgb.gamma(2.2)($i(e),Mi(e)),u=h.range(0,a,1).map(e=>l(e/a)).reverse(),d=s.concat(c).concat(u);if(!n){const t=(d.length-1)/2;n=h.range(i[0],e.schema.midpoint,-(i[0]-e.schema.midpoint)/t).concat(h.range(e.schema.midpoint,i[1],(i[1]-e.schema.midpoint)/t)).concat([i[1]])}return{colors:d,buckets:n}}(e,t,i):function(e,t,n){const{allValues:i,domain:o,negative:a,positive:s,diverging:c,numBuckets:l,scale:u}=t;let{colors:d}=t;if(!d){const t=a?Ci(e):$i(e);if("buckets"===u||"quantile"===u){const e=r.colorRamp(t,l);d=s?e:e.slice().reverse()}else{const e=r.colorRamp(t,2);d=a?e.slice().reverse():e}}if(!n)if("quantile"===u){const e=1/(d.length-1);n=h.range(0,1+e/2,e).map(e=>h.quantile(i,e))}else if(c&&e.schema.color&&e.schema.centered){const t=d.indexOf(Mi(e)),i=(e.schema.midpoint-o[0])/t,a=(o[1]-e.schema.midpoint)/(d.length-t),r=h.range(o[0],e.schema.midpoint,i),s=h.range(e.schema.midpoint,o[1]+a/2,a);n=r.concat(s)}else{const e=(o[1]-o[0])/(d.length-1);n=h.range(o[0],o[1]+e/2,e)}return{colors:d,buckets:n}}(e,t,i);let a,{colors:c}=o;if(i=o.buckets,"buckets"===n||"quantile"===n)a=i,c=[c[0]].concat(c);else if("log"===n){const e=i.filter(e=>e<0);if(e.length){const t=e[0],n=e.map(e=>-Math.pow(Math.abs(t),e/t));e.forEach((e,t)=>{i[i.indexOf(e)]=n[t]})}const t=i.filter(e=>e>0);if(t.length){const e=t[t.length-1],n=t.map(t=>Math.pow(e,t/e));t.forEach((e,t)=>{i[i.indexOf(e)]=n[t]})}i.includes(0)&&(i[i.indexOf(0)]=1)}const l="buckets"===n||"quantile"===n?s.scaleThreshold:s.scaleLinear;return e._colorScale=l().domain(i).range(c),{colors:c,ticks:a,labels:void 0}}function zi(e){const t=["bottom","top"].includes(e.schema.orient),n=t?"height":"width",i=t?"width":"height",a=t?"x":"y",c=t?"y":"x",l=e._data.map(e.schema.value).filter(e=>"number"==typeof e&&!Number.isNaN(e)).sort((e,t)=>e-t),u=function(e,t,n){const i=t.length?[t[0],t[t.length-1]]:[void 0,void 0],o="function"==typeof e?e.call(n,t.slice(),i):e;return wi.includes(o)?o:(pe(`ColorScale received unknown scale ${JSON.stringify(o)??String(o)}; using "linear". Use one of ${wi.map(e=>`"${e}"`).join(", ")}, or a function returning one.`),"linear")}(e.schema.scale,l,e);e._scaleType=u;const d=e.schema.domain||h.extent(l),m=d[0]<e.schema.midpoint,p=d[1]>e.schema.midpoint,g=m&&p,y=h.min([e.schema.buckets instanceof Array?e.schema.buckets.length:e.schema.buckets,g&&"jenks"!==u?2*Math.floor(o.unique(l).length/2)-1:o.unique(l).length]);let x=g&&(!e.schema.color||e.schema.color instanceof Array&&!e.schema.color.includes(Mi(e)))?void 0:e.schema.color;!x||x instanceof Array||(x=r.colorRamp(x,y));const b={scale:u,allValues:l,domain:d,negative:m,positive:p,diverging:g,numBuckets:y,colors:x},_="jenks"===u?function(e,t){const{allValues:n,diverging:i,numBuckets:o}=t;let a,c,{colors:l}=t;const u=h.min([l?l.length:o,o,n.length]);let d;if(e.schema.buckets instanceof Array)a=e.schema.buckets;else{if(i&&e.schema.centered){const t=Math.floor(u/2),i=u%2,o=n.filter(t=>t<e.schema.midpoint),a=h.deviation(o),r=n.concat(e.schema.midpoint).filter(t=>t>=e.schema.midpoint),s=h.deviation(r),c=a>s?1:0,l=s>a?1:0,m=f.ckmeans(o,h.min([t+i*c,o.length])),p=f.ckmeans(r,h.min([t+i*l,r.length]));d=m.concat(p)}else d=f.ckmeans(n,u);a=d.map(e=>e[0])}const m=new Set(a);if(a.length!==m.size&&(c=Array.from(m)),!l)if(i){const t=[Ci(e),Mi(e),$i(e)],n=a.slice(0,u).filter((t,n)=>t<e.schema.midpoint&&a[n+1]<=e.schema.midpoint),i=a.slice(0,u).filter((t,n)=>t<=e.schema.midpoint&&a[n+1]>e.schema.midpoint),o=a.slice(0,u).filter(t=>t>e.schema.midpoint),s=n.map((e,i)=>i?r.colorLighter(t[0],i/n.length):t[0]),c=i.map(()=>t[1]),h=o.map((e,n)=>n===o.length-1?t[2]:r.colorLighter(t[2],1-(n+1)/o.length));l=s.concat(c).concat(h)}else l=r.colorRamp($i(e),o);return a.length<=u&&(l=l.slice(-a.length)),l=[l[0]].concat(l),e._colorScale=s.scaleThreshold().domain(a).range(l),{colors:l,ticks:a,labels:c}}(e,b):Ai(e,b);return e._colorScale.clamp&&e._colorScale.clamp(!0),{scale:u,allValues:l,domain:d,ticks:_.ticks,labels:_.labels,colors:_.colors,horizontal:t,height:n,width:i,x:a,y:c}}function Di(e,t,o){const a={x:0,y:0},{axisConfig:r,labelConfig:c,axisDomain:l,labelData:h}=function(e,t,i){const{horizontal:o,height:a,width:r,domain:s,labels:c,ticks:l}=t,h=s.slice();if(e.schema.bucketAxis){const e=h[h.length-1],t=h[h.length-2],n=e?e/10:t/10,i=n>=1||n<=-1?Math.round(n).toString().length-1:-1*n.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,o=Math.pow(10,i);h[h.length-1]=e+o}const u=n.assign({domain:o?h:h.slice().reverse(),duration:e.schema.duration,height:e.schema.height,labels:c||l,orient:e.schema.orient,padding:e.schema.padding,scale:"log"===t.scale?"log":"linear",ticks:l,width:e.schema.width},e.schema.axisConfig),d=n.assign({height:e.schema[a]/2,width:e.schema[r]/2},e.schema.labelConfig);e._labelClass.config(d);const f=[];if(o&&e._labelMin){const t={"font-family":e._labelClass.fontFamily()(e._labelMin),"font-size":e._labelClass.fontSize()(e._labelMin),"font-weight":e._labelClass.fontWeight()(e._labelMin)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMin,t);a&&a<e.schema[r]/2&&(f.push(e._labelMin),a+=e.schema.padding,o&&(i.x+=a),u[r]=u[r]-a)}if(o&&e._labelMax){const t={"font-family":e._labelClass.fontFamily()(e._labelMax),"font-size":e._labelClass.fontSize()(e._labelMax),"font-weight":e._labelClass.fontWeight()(e._labelMax)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMax,t);a&&a<e.schema[r]/2&&(f.push(e._labelMax),a+=e.schema.padding,o||(i.y+=a),u[r]=u[r]-a)}return{axisConfig:u,labelConfig:d,axisDomain:h,labelData:f}}(e,t,a),{axisBounds:u,axisScale:d,scaleRange:f}=function(e,t,i,o,a){const{horizontal:r,height:s,width:c,x:l,y:h}=t;e._axisTest.renderMode("compute").select(n.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:e._group}).node()).config(o).duration(0).render();const u=e._axisTest.outerBounds();e._outerBounds[c]=e.schema[c]-2*e.schema.padding,e._outerBounds[s]=u[s]+e.schema.size,e._outerBounds[l]=e.schema.padding,e._outerBounds[h]=e.schema.padding,"middle"===e.schema.align?e._outerBounds[h]=(e.schema[s]-e._outerBounds[s])/2:"end"===e.schema.align&&(e._outerBounds[h]=e.schema[s]-e.schema.padding-e._outerBounds[s]);const d=e._outerBounds[h]+(["bottom","right"].includes(e.schema.orient)?e.schema.size:0)-(o.padding||e._axisClass.padding()),f=`translate(${a.x+(r?0:d)}, ${a.y+(r?d:0)})`;return e._axisClass.renderMode("compute").select(n.elem("g.d3plus-ColorScale-axis",n.assign(i.groupParams,{condition:!0,enter:{transform:f},update:{transform:f}})).node()).config(o).align("start").render(),{axisBounds:u,axisScale:e._axisTest._getPosition.bind(e._axisTest),scaleRange:e._axisTest._getRange()}}(e,t,o,r,a);!function(e,t,n,o){const{horizontal:a,colors:r}=t,c=e._colorScale.domain(),l=s.scaleLinear().domain(o).range(a?[0,100]:[100,0]),h=r.map((e,t)=>({offset:(t<=c.length-1?l(n(c[t])):100)/100,color:String(e)})).sort((e,t)=>e.offset-t.offset),u={type:"linear",from:a?[0,0]:[0,1],to:a?[1,0]:[0,0],stops:h};e._gradientFill=i.gradientToken(u)}(e,t,d,f);const m=function(e,t,i,o){const{height:a,width:r,x:s,y:c,ticks:l}=t,{axisScale:h,scaleRange:u,axisDomain:d,axisBounds:f,offsets:m}=o,p=(e,t)=>{const n=l[t+1]||d[d.length-1];return Math.abs(h(n)-h(e))},g=n.assign({duration:e.schema.duration,fill:l?t=>e._colorScale(t):e._gradientFill,[s]:l?(t,n)=>h(t)+p(t,n)/2-(["left","right"].includes(e.schema.orient)?p(t,n):0):u[0]+(u[1]-u[0])/2+m[s],[c]:e._outerBounds[c]+(["top","left"].includes(e.schema.orient)?f[a]:0)+e.schema.size/2+m[c],[r]:l?p:u[1]-u[0],[a]:e.schema.size},e.schema.rectConfig),y=e._outerBounds[c]+(["top","left"].includes(e.schema.orient)?f[a]:0)+m[c];return e._barGeometry={orient:e.schema.orient,position:e=>h(e)+m[s],range:[u[0]+m[s],u[1]+m[s]],cross:[y,y+e.schema.size],domain:[d[0],d[d.length-1]],...l?{ticks:l}:{}},e._rectClass.renderMode("compute").data(l||[0]).id((e,t)=>t).select(i.rectGroup.node()).config(g).render(),g}(e,t,o,{axisScale:d,scaleRange:f,axisDomain:l,axisBounds:u,offsets:a});!function(e,t,n,i,o,a){const{horizontal:r,height:s,width:c}=t;i.height=e._outerBounds[s],i.width=e._outerBounds[c],e._labelClass.renderMode("compute"),e._labelClass.config(i).data(a).select(n.labelGroup.node()).x(t=>t===e._labelMax?o.x+o.width/2+e.schema.padding:e._outerBounds.x).y(t=>o.y-e._labelClass.fontSize()(t)/2).text(e=>e).rotate(r?0:"right"===e.schema.orient?90:-90).render()}(e,t,o,c,m,h)}const Fi=e=>"bottom"===e||"top"===e;function Bi(e,[t,n]){const i=Math.min(t,n),o=Math.max(t,n);return Math.min(o,Math.max(i,e))}function Li(e,t){if("number"!=typeof t||!Number.isFinite(t))return null;const n=e.position(Bi(t,e.domain));return Number.isFinite(n)?Bi(n,e.range):null}function Pi(e,t,n,i){return"bottom"===e?[[t,n[1]],[t,n[1]+i]]:"top"===e?[[t,n[0]],[t,n[0]-i]]:"right"===e?[[n[1],t],[n[1]+i,t]]:[[n[0],t],[n[0]-i,t]]}function Ri(e,t){return"function"==typeof e?e(t):e}function Ei(e){const t=e;return t.interactive=!1,t.interactionGroup="axis",e}function Ni(e){const t=Ri(e.config.tickConfig?.length,e.value),n=e.cs._axisClass.schema.tickSize;return"number"==typeof t?t:"number"==typeof n?n:8}function Ti(e,t,n,i){const o=e.config.tickConfig||{};return Ei({type:"line",key:`${e.key}-tick`,points:Pi(t,n,i,Ni(e)),paint:{fill:"none",stroke:Ri(o.stroke,e.value)??e.tickPaint.stroke??e.ink,strokeWidth:Ri(o.strokeWidth,e.value)??e.tickPaint.strokeWidth??1}})}function Oi(e,t,i,o){const{cs:a,value:s}=e,c=e.config.badgeConfig||{},l=Ri(c.fontSize,s)??11,h=Ri(c.fontFamily,s)||`${a._labelClass.fontFamily()(o)}`,u=Ri(c.fontWeight,s)??400,d=Ri(c.padding,s)??3,f=Ri(c.fill,s)??e.color,m=Ri(c.fontColor,s)??r.colorContrast(f,a.schema.colorDefaults),p=n.textWidth(o,{"font-family":h,"font-size":l,"font-weight":u}),g=Fi(t.orient)?a.schema.width:a.schema.height,y=Ni(e),x=a._axisClass.schema,b=("number"==typeof x.tickSize?x.tickSize:8)+("number"==typeof x.padding?x.padding:0),_=Math.max(d,b-y),k=function(e,t,n,i,o,a){const{width:r,height:s}=i;if(Fi(e))return{x:Bi(t-r/2,[0,Math.max(0,o-r)]),y:"bottom"===e?n[1]+a:n[0]-a-s,width:r,height:s};const c=Bi(t-s/2,[0,Math.max(0,o-s)]);return{x:"right"===e?n[1]+a:n[0]-a-r,y:c,width:r,height:s}}(t.orient,i,t.cross,Fi(t.orient)?{width:p+2*d,height:l+2*_}:{width:p+2*_,height:l+2*d},g,y),v=`${e.key}-badge`;return Ei({type:"group",key:v,children:[Ei({type:"rect",key:`${v}-box`,...k,rx:Ri(c.rx,s)??0,paint:{fill:f,stroke:Ri(c.stroke,s)??e.ink,strokeWidth:Ri(c.strokeWidth,s)??1}}),Ei({type:"text",key:`${v}-text`,x:0,y:0,transform:{x:k.x+k.width/2,y:k.y+k.height/2},lines:[{text:o,x:0,y:0,width:p}],font:{family:h,size:l,weight:u,anchor:"middle",baseline:"middle"},paint:{fill:m}})]})}function Wi(e,t){if(!t.ticks)return[];const n=function(e,t,n){let i=-1;return e.forEach((e,n)=>{t>=e&&(i=n)}),i<0?e.length?[e[0],e[1]??n]:null:[e[i],e[i+1]??n]}(t.ticks,e.value,t.domain[1]);if(!n)return[];const[i,o]=n.map(e=>Li(t,e));if(null===i||null===o)return[];const a=e.config.outlineConfig||{},r=Math.min(i,o),s=Math.abs(o-i),[c,l]=t.cross,h=Fi(t.orient)?{x:r,y:c,width:s,height:l-c}:{x:c,y:r,width:l-c,height:s};return[Ei({type:"rect",key:`${e.key}-outline`,...h,paint:{fill:"none",stroke:Ri(a.stroke,e.value)??e.ink,strokeWidth:Ri(a.strokeWidth,e.value)??2}})]}function ji(e){let t;const n=(e,i)=>{if(t)return;const o=i||String(e.key).startsWith("Axis-");"group"===e.type?e.children.forEach(e=>n(e,o)):o&&"path"===e.type&&!String(e.key).endsWith("::hit")&&(t={stroke:e.paint?.stroke,strokeWidth:e.paint?.strokeWidth})};return e.children.forEach(e=>n(e,!1)),t??{}}function Hi(e,t){const i=e._hoverValue,o=e._barGeometry;if(!1===e.schema.hoverMark||"number"!=typeof i||!Number.isFinite(i)||!e._colorScale||!o)return;const a=e._select&&"function"==typeof e._select.node?e._select.node():null,s=r.colorContrast(a?n.backgroundColor(a):"rgb(255, 255, 255)",e.schema.colorDefaults),c={cs:e,key:`${t.key}-hover`,value:i,color:String(e._colorScale(i)),ink:s,config:e.schema.hoverMarkConfig||{},tickPaint:ji(t)};t.children.push(...function(e,t){const n=Li(t,e.value);if(null===n)return[];const i=function(e,t){const n=e._axisClass._labelFormat??e.schema.axisConfig.tickFormat;return`${(n?n(t):`${t}`)??""}`.replace(/<[^>]*>/g,"").trim()}(e.cs,e.value);return[...Wi(e,t),Ti(e,t.orient,n,t.cross),...i?[Oi(e,t,n,i)]:[]]}(c,o))}const Ii=[{key:"align",coerce:"identity",default:"middle"},{key:"buckets",coerce:"identity",default:5},{key:"bucketAxis",coerce:"identity",default:!1},{key:"bucketFormat",coerce:"identity"},{key:"bucketJoiner",coerce:"identity",default:(e,t)=>e!==t?`${e} - ${t}`:`${e}`},{key:"centered",coerce:"identity",default:!0},{key:"color",coerce:"identity"},{key:"colorMax",coerce:"identity"},{key:"colorMid",coerce:"identity"},{key:"colorMin",coerce:"identity"},{key:"domain",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"hoverMark",coerce:"identity",default:!0},{key:"hoverMarkConfig",merge:!0,factory:function(){return{tickConfig:{},badgeConfig:{fontSize:11,fontWeight:400,padding:3,rx:2},outlineConfig:{strokeWidth:2}}}},{key:"midpoint",coerce:"identity",default:0},{key:"orient",coerce:"identity",default:"bottom"},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity",default:"linear"},{key:"size",coerce:"identity",default:10},{key:"value",coerce:"const",default:T("value")},{key:"width",coerce:"identity",default:400}];class Gi extends $e{render(e){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(t.select("body").append("div").node()),this._group=n.elem("g.d3plus-ColorScale",{parent:this._select});const i=zi(this),o=this.schema.bucketAxis||!Si(i.scale),a=u.transition().duration(this.schema.duration),r={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:a,update:{opacity:1}},s={labelGroup:n.elem("g.d3plus-ColorScale-labels",Object.assign({condition:o},r)),rectGroup:n.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:o},r)),legendGroup:n.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!o},r)),groupParams:r,gradient:o};return o?Di(this,i,s):function(e,t,i){const{horizontal:o,allValues:a,ticks:r,colors:s}=t;e._barGeometry=void 0,n.elem("g.d3plus-ColorScale-axis",Object.assign({condition:i.gradient},i.groupParams));let c=r.reduce((t,n,i)=>{const o=e.schema.bucketFormat.bind(e)(n,i,r,a);return t.push({color:s[i+1],id:o,_isColorScaleBucket:!0}),t},[]);o||(c=c.reverse());const l=n.assign({align:o?"center":{start:"left",middle:"center",end:"right"}[e.schema.align],direction:o?"row":"column",duration:e.schema.duration,height:e.schema.height,padding:e.schema.padding,shapeConfig:n.assign({duration:e.schema.duration},e.schema.axisConfig.shapeConfig||{}),title:e.schema.axisConfig.title,titleConfig:e.schema.axisConfig.titleConfig||{},width:e.schema.width,verticalAlign:o?{start:"top",middle:"middle",end:"bottom"}[e.schema.align]:"middle"},e.schema.legendConfig);e._legendClass.renderMode("compute").data(c).select(i.legendGroup.node()).config(l).render(),e._outerBounds=e._legendClass.outerBounds()}(this,i,s),"compute"!==this.schema.renderMode&&De(this),e&&setTimeout(e,this.schema.duration+100),this}toScene(){const e=[],t=t=>{if(t&&"function"==typeof t.toScene){const n=t.toScene();n&&e.push(n)}};let n;this.schema.bucketAxis||!Si(this._scaleType)?(t(this._rectClass),t(this._axisClass),t(this._labelClass)):t(this._legendClass);const i=this._select&&"function"==typeof this._select.node?this._select.node():null;if(i&&"function"==typeof i.getAttribute){const e=i.getAttribute("transform");if(e){const t=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);t&&(n={x:Number(t[1]),y:Number(t[2])})}}const o={type:"group",key:`ColorScale-${this._uuid.slice(0,8)}`,...n?{transform:n}:{},children:e};return Hi(this,o),o}axisConfig(e){return arguments.length?(this.schema.axisConfig=Y(this,"axisConfig",e),this):this.schema.axisConfig}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){return arguments.length?(this._hoverValue=e,this):this._hoverValue}labelConfig(e){return arguments.length?(this.schema.labelConfig=Y(this,"labelConfig",e),this):this.schema.labelConfig}labelMin(e){return arguments.length?(this._labelMin=e,this):this._labelMin}labelMax(e){return arguments.length?(this._labelMax=e,this):this._labelMax}legendConfig(e){return arguments.length?(this.schema.legendConfig=Y(this,"legendConfig",e),this):this.schema.legendConfig}outerBounds(){return this._outerBounds}rectConfig(e){return arguments.length?(this.schema.rectConfig=Y(this,"rectConfig",e),this):this.schema.rectConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}constructor(){super(),this._scaleType="linear",ee(this,Ii),this._axisClass=new hi,this.schema.axisConfig={gridSize:0},this._axisTest=new hi,this.schema.bucketFormat=(e,t,n,i)=>{const o=this.schema.axisConfig.tickFormat?this.schema.axisConfig.tickFormat:Dn(i)?e=>Bn(e,this.schema.locale):d.formatAbbreviate,a=t===n.length-1;if(e===n[t+1]||a){const t=a&&e<h.max(i)?"+":"";return`${o(e)}${t}`}const[r,s]=function(e,t,n,i,o){const a=n[t+1],r=h.max(i.filter(Number.isFinite).map(_i))??0,s=ki(e,r),c=vi(1===t&&n[0]===e?Math.floor(s)+1:Math.ceil(s),r),l=e=>vi(Math.ceil(ki(a,e))-1,e),u=o(vi(Math.ceil(ki(a,r)),r));let d=r,f=l(d);for(;o(f)===u&&l(d-1)>=c;)f=l(--d);return[c,f]}(e,t,n,i,o);return this.schema.bucketJoiner(o(r),o(s))},this._data=[],this._labelClass=new ro,this.schema.labelConfig={fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return r.colorContrast(e,this.schema.colorDefaults)},fontSize:12},this._legendClass=new bi,this.schema.legendConfig={shapeConfig:{stroke:()=>this.schema.colorDefaults.dark,strokeWidth:1}},this._outerBounds={width:0,height:0,x:0,y:0},this._rectClass=(new Yo).parent(this),this.schema.rectConfig={stroke:"#999",strokeWidth:1}}}function Vi(e,t,n){return n.width<=n.availableWidth/3&&n.height<=n.availableHeight/3}K(Gi.prototype,"axisConfig","labelConfig","legendConfig","rectConfig");function qi(e){for(let t=1;t<15;t++)if(Number(e.toPrecision(t))===e)return t;return 15}function Yi(e,t=3){const[n,i]=e;if(t<=1)return[i];if(2===t)return[n,i];const o=h.ticks(n,i,4*t).filter(e=>e>n&&e<i),a=.15*(i-n),r=[];for(let e=1;e<t-1;e++){const s=n+(i-n)*e/(t-1),c=o.filter(e=>!r.includes(e)&&Math.abs(e-s)<=a);c.sort((e,t)=>qi(e)-qi(t)||Math.abs(e-s)-Math.abs(t-s)),c.length&&r.push(c[0])}return[n,...r.sort((e,t)=>e-t),i]}function Ki(e){const t=e.scale.domain();if(t.length<2||!Number.isFinite(t[0])||!Number.isFinite(t[1])||t[0]===t[1])return{circles:[],lines:[],labels:[],width:0,height:0};const i=e.maxRadius??1/0,o=function(e,t){const n="function"==typeof e?e(t):Array.isArray(e)?e:Yi(t,e??3);return Array.from(new Set(n.filter(e=>Number.isFinite(e)))).sort((e,t)=>t-e)}(e.values,t).filter(t=>e.scale(t)<=i+.5),a=o.map(t=>Math.max(0,e.scale(t)||0)),r=Math.max(0,...a);if(!o.length||!r)return{circles:[],lines:[],labels:[],width:0,height:0};const{padding:s,fontSize:c}=e,l=1.2*c,h=o.map(t=>e.tickFormat(t)),u=h.map(t=>n.textWidth(t,{"font-family":e.fontFamily,"font-size":c})),d=e.title?String(e.title):"",f=d?n.textWidth(d,{"font-family":e.titleFontFamily,"font-size":e.titleFontSize,"font-weight":e.titleFontWeight}):0,m=d?1.2*e.titleFontSize+2:0,p=2*r+e.lineLength+e.labelPadding+Math.max(...u),g=Math.max(p,f),y=Math.min(s+g/2,s+g-p+r),x=s+m+l/2+2*r,b=o.map((e,t)=>({value:e,cx:y,cy:x-a[t],r:a[t]})),_=y+r+e.lineLength+e.labelPadding,k=[],v=[];let w,S=-1/0;if(b.forEach((t,n)=>{const i=t.cy-t.r,o=Math.max(i,S+l);S=o,k.push({value:t.value,text:h[n],x:_,y:o,width:u[n]});const a=[[t.cx,i],[t.cx+r,i]];o!==i&&a.push([t.cx+r+e.lineLength/2,o]),a.push([_-e.labelPadding,o]),v.push({value:t.value,points:a})}),d){w={text:d,x:Math.min(Math.max(y,s+f/2),s+g-f/2),y:s+e.titleFontSize,width:f}}const C=Math.max(x,S+l/2)+s;return{circles:b,lines:v,labels:k,title:w,width:Math.ceil(g+2*s),height:Math.ceil(C)}}function Ui(e,t){if(1===t||!Number.isFinite(t)||t<=0)return e;const[n,i]=e.domain(),o=e.invert?Math.max(n,Math.min(i,e.invert(e(i)/t))):i,a=(o<i?h.ticks(n,o,4).filter(e=>e>n&&e<=o).pop():void 0)??o,r=n=>e(n)*t;return r.domain=()=>[n,a],r}const Xi=[{key:"labelPadding",coerce:"identity",default:4},{key:"lineLength",coerce:"identity",default:6},{key:"padding",coerce:"identity",default:4},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity"},{key:"tickFormat",coerce:"identity"},{key:"title",coerce:"identity"},{key:"values",coerce:"identity"}],Qi=e=>a.fontFamilyStringify(void 0===e?a.fontFamily:Array.isArray(e)?e:[e]);class Zi extends $e{labelConfig(e){return arguments.length?(this.schema.labelConfig=Y(this,"labelConfig",e),this):this.schema.labelConfig}lineConfig(e){return arguments.length?(this.schema.lineConfig=Y(this,"lineConfig",e),this):this.schema.lineConfig}shapeConfig(e){return arguments.length?(this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}titleConfig(e){return arguments.length?(this.schema.titleConfig=Y(this,"titleConfig",e),this):this.schema.titleConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}layout(){const e=this.schema.scale;if(!e||"function"!=typeof e.domain)return this._layout={circles:[],lines:[],labels:[],width:0,height:0};const t=this.schema.labelConfig,n=this.schema.titleConfig,i=this.schema.locale;return this._layout=Ki({scale:e,values:this.schema.values,tickFormat:this.schema.tickFormat??(e=>d.formatAbbreviate(e,i)),fontFamily:Qi(t.fontFamily),fontSize:t.fontSize??10,title:this.schema.title,titleFontFamily:Qi(n.fontFamily),titleFontSize:n.fontSize??11,titleFontWeight:n.fontWeight??600,lineLength:this.schema.lineLength,labelPadding:this.schema.labelPadding,padding:this.schema.padding,maxRadius:this._maxRadius}),this._layout}outerBounds(){return{width:this._layout.width,height:this._layout.height}}toScene(e=0,t=0){const n=this._layout,i=this.schema.shapeConfig,o=this.schema.lineConfig,a=this.schema.labelConfig,r=this.schema.titleConfig,s=Qi(a.fontFamily),c=[];return n.circles.forEach(e=>c.push({type:"circle",key:`circle-${e.value}`,interactive:!1,cx:e.cx,cy:e.cy,r:e.r,paint:{...i}})),n.lines.forEach(e=>c.push({type:"line",key:`line-${e.value}`,interactive:!1,points:e.points,paint:{fill:"none",...o}})),n.labels.forEach(e=>c.push({type:"text",key:`label-${e.value}`,interactive:!1,x:0,y:0,transform:{x:e.x,y:e.y},lines:[{text:e.text,x:0,y:0,width:e.width}],font:{family:s,size:a.fontSize??10,anchor:"start",baseline:"middle"},paint:{fill:a.fontColor}})),n.title&&c.push({type:"text",key:"title",interactive:!1,x:0,y:0,transform:{x:n.title.x,y:n.title.y},lines:[{text:n.title.text,x:0,y:0,width:n.title.width}],font:{family:Qi(r.fontFamily),size:r.fontSize??11,weight:r.fontWeight??600,anchor:"middle",baseline:"alphabetic"},paint:{fill:r.fontColor}}),{type:"group",key:`SizeLegend-${this._uuid.slice(0,8)}`,transform:{x:e,y:t},children:c}}render(e){return this.layout(),"compute"!==this.schema.renderMode&&(void 0===this._select&&this.select(t.select("body").append("div").node()),this.schema.width=this._layout.width,this.schema.height=this._layout.height,De(this)),e&&setTimeout(e,0),this}constructor(){super(),ee(this,Xi),this._layout={circles:[],lines:[],labels:[],width:0,height:0},this.schema.labelConfig={fontColor:r.colorDefaults.dark,fontSize:10},this.schema.lineConfig={stroke:r.colorDefaults.dark,strokeOpacity:.5,strokeWidth:1},this.schema.shapeConfig={fill:r.colorDefaults.dark,fillOpacity:.05,stroke:r.colorDefaults.dark,strokeOpacity:.6,strokeWidth:1},this.schema.titleConfig={fontColor:r.colorDefaults.dark,fontSize:11,fontWeight:600}}}K(Zi.prototype,"labelConfig","lineConfig","shapeConfig","titleConfig");class Ji{exit(e,t){e.transition().duration(t).style("opacity",0).transition().remove(),this._isVisible=!1}hide({duration:e=600,callback:t}={}){return this.mask.call(this.exit.bind(this),e),this.elem.call(this.exit.bind(this),e),t&&setTimeout(t,e+100),this._isVisible=!1,this}render({callback:e,container:i="body",duration:o=600,html:a="Please Wait",mask:r="rgba(0, 0, 0, 0.05)",style:s={}}={}){const c=t.select(i);return this.mask=c.selectAll("div.d3plus-Mask").data(r?[r]:[]),this.mask=this.mask.enter().append("div").attr("class","d3plus-Mask").style("opacity",1).merge(this.mask),this.mask.exit().call(this.exit.bind(this),o),n.stylize(this.mask,{"background-color":"transparent",bottom:"0px",left:"0px",position:"absolute",right:"0px",top:"0px"}),this.elem=c.selectAll("div.d3plus-Message").data([a]),this.elem=this.elem.enter().append("div").attr("class","d3plus-Message").style("opacity",1).merge(this.elem).html(String),n.stylize(this.elem,s),e&&setTimeout(e,100),this._isVisible=!0,this}constructor(){this._isVisible=!1}}function eo(e){const t={};for(const n of e.split(";")){const[e,i]=n.split(":").map(e=>e.trim());e&&i&&("font-weight"===e?t.weight=/^\d+$/.test(i)?Number(i):i:"font-style"===e&&(t.style="italic"===i?"italic":"normal"))}return void 0===t.weight&&void 0===t.style?void 0:t}function to(e,t,n){let i=e.trimEnd().replace(/&([^;&]*)/g,(e,t)=>"amp"===t?e:`&amp;${t}`).replace(/<([^A-z^/]+)/g,(e,t)=>`&lt;${t}`).replace(/<$/g,"&lt;").replace(/(<[^>^/]+>)([^<^>]+)$/g,(e,t,n)=>`${t}${n}${t.replace("<","</")}`).replace(/^([^<^>]+)(<\/[^>]+>)/g,(e,t,n)=>`${n.replace("</","<")}${t}${n}`),o=n;o&&!i.startsWith("<")&&(i=`<${o}>${i}`,i.includes(`</${o}>`)||(i+=`</${o}>`));const a=/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g,r=[];let s,c=0;for(;null!==(s=a.exec(i));){s.index>c&&r.push({text:i.slice(c,s.index)});const n=s[1],a=s[2],l=t[n];l?(o=!e.includes(`</${n}>`)&&n,r.push({text:a,style:eo(l)})):r.push({text:a}),c=s.index+s[0].length}return c<i.length&&r.push({text:i.slice(c)}),!r.length&&i&&r.push({text:i}),{runs:r,openTag:o}}function no(e,t,n,i){const{lineData:o,line:a,fS:r,lH:s,w:c,h:l,vA:h,style:u,widths:d,truncated:f,padding:m}=i,p=a*s,g=e.schema.rotate(t,n);let y=0===g?"top"===h?0:"middle"===h?l/2-p/2:l-p:0;y-=.1*s;const x=function(e,t){let n=null;if(e.schema.html){const i=e.schema.html;let o=!1;const a=[];let r=!1;for(const e of t){const{runs:t,openTag:n}=to(e,i,o);a.push(t),o=n,t.some(e=>e.style)&&(r=!0)}r&&(n=a)}return n}(e,o);return{aH:e.schema.ariaHidden(t,n),data:t,i:n,lines:o,lineRuns:x,fC:e.schema.fontColor(t,n),fStroke:e.schema.fontStroke(t,n),fSW:e.schema.fontStrokeWidth(t,n),fF:u["font-family"],fO:e.schema.fontOpacity(t,n),fW:u["font-weight"],id:e.schema.id(t,n),pE:e.schema.pointerEvents(t,n),tA:e.schema.textAnchor(t,n),vA:e.schema.verticalAlign(t,n),widths:d,truncated:f,fS:r,lH:s,w:c,h:l,r:g,x:e.schema.x(t,n)+m.left,y:e.schema.y(t,n)+y+m.top}}function io(e,t,i){const o=e;let r=e.schema.text(t,i);if(void 0===r)return null;r=`${r}`.trim();const s=e.schema.fontResize(t,i),c=e.schema.lineHeight(t,i)/e.schema.fontSize(t,i);let l=s?e.schema.fontMax(t,i):e.schema.fontSize(t,i),u=s?l*c:e.schema.lineHeight(t,i),d=1,f=[],m={lines:[],truncated:!1,widths:[]};const p={"font-family":n.fontExists(e.schema.fontFamily(t,i)),"font-size":l,"font-weight":e.schema.fontWeight(t,i),"line-height":u},g=n.parseSides(e.schema.padding(t,i)),y=e.schema.height(t,i)-(g.top+g.bottom),x=e.schema.width(t,i)-(g.left+g.right),b=e.schema.shape(t,i),_=a.textWrap().fontFamily(p["font-family"]).fontSize(l).fontWeight(p["font-weight"]).lineHeight(u).maxLines(e.schema.maxLines(t,i)).height(y).overflow(e.schema.overflow(t,i)).shape(b).width(x).split(e.schema.split),k=e.schema.fontMax(t,i),v=e.schema.fontMin(t,i),w=e.schema.verticalAlign(t,i),S=e.schema.split(r,i);return x>(s?v:0)&&(y>u||s&&y>v*c)&&(s&&(l=function(e,t,i,o,a,r,s){const c=n.textWidth(a,r),l=1.165+t/i*.1,u=t*i*("circle"===s?Math.PI/4:1),d=h.max(c),f=h.sum(c,e=>e*o)*l;if(d>t||f>u){const n=Math.sqrt(u/f),i=t/d,o=h.min([n,i]);e=Math.floor(e*o)}const m=Math.floor(.8*i);return e>m&&(e=m),e}(l,x,y,u,S,p,b)),function e(){const t=()=>{d<1?f=[o.schema.ellipsis("",d)]:f[d-1]=o.schema.ellipsis(f[d-1],d)};if(s&&(l=h.max([l,v]),l=h.min([l,k]),u=l*c,_.fontSize(l).lineHeight(u),p["font-size"]=l,p["line-height"]=u),m=_(r),f=m.lines.filter(e=>""!==e),d=f.length,m.truncated)if(s){if(l--,l<v)return l=v,void t();e()}else t()}()),f.length?no(e,t,i,{lineData:f,line:d,fS:l,lH:u,w:x,h:y,vA:w,style:p,widths:m.widths,truncated:m.truncated,padding:g}):null}const oo={i:"font-style: italic;",em:"font-style: italic;",b:"font-weight: bold;",strong:"font-weight: bold;"},ao=[{key:"ariaHidden",coerce:"const",default:N("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(e,t)=>t?`${e.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:N("black")},{key:"fontFamily",coerce:"const",default:N(a.fontFamily)},{key:"fontMax",coerce:"const",default:N(50)},{key:"fontMin",coerce:"const",default:N(8)},{key:"fontOpacity",coerce:"const",default:N(1)},{key:"fontResize",coerce:"const",default:N(!1)},{key:"fontSize",coerce:"const",default:N(10)},{key:"fontStroke",coerce:"const",default:N("transparent")},{key:"fontStrokeWidth",coerce:"const",default:N(0)},{key:"fontWeight",coerce:"const",default:N(400)},{key:"height",coerce:"const",default:T("height",200)},{key:"id",coerce:"const",default:(e,t)=>e.id||`${t}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:N(null)},{key:"overflow",coerce:"const",default:N(!1)},{key:"padding",coerce:"const",default:N(0)},{key:"pointerEvents",coerce:"const",default:N("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:N(0)},{key:"rotateAnchor",coerce:"const",default:e=>[e.w/2,e.h/2]},{key:"shape",coerce:"const",default:e=>e.__d3plusWrapShape__??"square"},{key:"split",coerce:"identity",default:a.textSplit},{key:"text",coerce:"const",default:T("text")},{key:"textAnchor",coerce:"const",default:N("start")},{key:"verticalAlign",coerce:"const",default:N("top")},{key:"width",coerce:"const",default:T("width",200)},{key:"x",coerce:"const",default:T("x",0)},{key:"y",coerce:"const",default:T("y",0)}];class ro extends $e{_textData(){return this._data.reduce((e,t,n)=>{const i=io(this,t,n);return i&&e.push(i),e},[])}toScene(){const e=n.rtl();return{type:"group",key:"textBox-group",children:this._textData().map(t=>{const n="middle"===t.tA?"middle":"end"===t.tA?"end":"start",i="middle"===t.tA?t.w/2:e?"start"===t.tA?t.w:0:"end"===t.tA?t.w:2*Math.sin(Math.PI*t.r/180),o=t.lines.map((e,n)=>{const o=0===t.r||"top"===t.vA?(n+1)*t.lH-(t.lH-t.fS):"middle"===t.vA?(t.h+t.fS)/2-(t.lH-t.fS)+(n-t.lines.length/2+.5)*t.lH:t.h-2*(t.lH-t.fS)-(t.lines.length-(n+1))*t.lH+2*Math.cos(Math.PI*t.r/180),a=t.widths?t.widths[n]??0:0,r=t.lineRuns?t.lineRuns[n]:void 0;return r?{text:e,x:i,y:o,width:a,runs:r}:{text:e,x:i,y:o,width:a}}),r=this.schema.rotateAnchor(t,t.i),s="true"===t.aH||!0===t.aH,c="none"!==t.pE;return{type:"text",key:t.id,id:`d3plus-textBox-${a.strip(t.id)}`,datum:t.data,index:t.i,x:0,y:0,width:t.w,height:t.h,lines:o,font:{family:t.fF,size:t.fS,weight:t.fW,anchor:n,baseline:"alphabetic",dir:e?"rtl":"ltr"},paint:{fill:t.fC,opacity:t.fO,...t.fStroke&&"transparent"!==t.fStroke?{stroke:t.fStroke}:{},...t.fSW?{strokeWidth:t.fSW}:{}},transform:{x:t.x,y:t.y,rotate:t.r,rotateAnchor:r},aria:s?{hidden:!0}:void 0,interactive:c}})}}render(e){if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;if(void 0===this._select&&"undefined"!=typeof document){const e=t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).node();this.select(e)}if(this._select){const e=this._select,t=e&&"function"==typeof e.node?e.node():e;if(t){const e=this.toScene(),n=e.children.reduce((e,t)=>Math.max(e,(t.transform?.x??0)+(t.width??0)),0),o=e.children.reduce((e,t)=>Math.max(e,(t.transform?.y??0)+(t.height??0)),0),a="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null,r=a&&a.width||Number(t.getAttribute("width"))||t.clientWidth||0,s=a&&a.height||Number(t.getAttribute("height"))||t.clientHeight||0,c=Math.max(r,n)||400,l=Math.max(s,o)||300;for(;t.firstChild;)t.removeChild(t.firstChild);const h={root:e,width:c,height:l},u=new i.SvgRenderer;u.mount({container:t,width:c,height:l}),u.drawScene(h),this._sceneRenderer=u,ve(this)}}return e&&setTimeout(e,0),this}data(e){return arguments.length?(this._data=e,this):this._data}html(e){return arguments.length?(this.schema.html="boolean"==typeof e?!!e&&oo:e,this):this.schema.html}select(e){return arguments.length?(this._select=t.select(e),this):this._select}constructor(){super(),ee(this,ao),this.schema.lineHeight=(e,t)=>1.2*this.schema.fontSize(e,t),this.schema.html=oo}}const so=e=>"function"==typeof e?e():e;function co(e,t){const n=so(e),i="number"==typeof n&&Number.isFinite(n)?n:1,o=so(t);return{min:i,max:"number"==typeof o&&Number.isFinite(o)?Math.max(Math.floor(o),Math.ceil(i),1):1/0}}function lo(e,t,n,i,o="hi",a="lo"){const r=i.min-1;Math.abs(t-e)<r&&("lo"===a?(t=Math.min(n-1,e+r),e=Math.max(0,t-r)):(e=Math.max(0,t-r),t=Math.min(n-1,e+r)));const s=i.max-1;return t-e>s&&("lo"===o?t=e+s:e=t-s),[e,t]}function ho(e){const t=co(e.brushMin,e.brushMax);return!1===e.brushing?{...t,min:1}:t}const uo="#bbb";function fo(e){return e.slice().sort((e,t)=>Number(e)-Number(t))}function mo(e){e.schema.brushFilter=e=>{const t=e;return!t.button&&t.detail<2},e.schema.domain=[2001,2010],e.schema.gridSize=0,e.schema.handleConfig={fill:()=>e.schema.colorDefaults.light,stroke:"#228be6","stroke-width":2,rx:2,ry:2},e.schema.height=100,e.schema.labelOffset=!1,e._labelRotationSetting=!1,e.schema.on={},e.orient("bottom"),e._playButtonClass=new ro,e.schema.playButtonConfig={fontColor:()=>e.schema.colorDefaults.dark,fontSize:15,text:()=>e._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},e.schema.selectionConfig={fill:"#228be6","fill-opacity":()=>"buttons"===e._buttonBehaviorCurrent?.3:1,"stroke-width":0},e.schema.shape="Rect",e.schema.barConfig=n.assign({},e.schema.barConfig,{stroke:()=>"buttons"===e._buttonBehaviorCurrent?"transparent":uo,"stroke-width":()=>"buttons"===e._buttonBehaviorCurrent?0:1}),e.schema.shapeConfig=n.assign({},e.schema.shapeConfig,function(e){return{labelBounds:t=>"buttons"===e._buttonBehaviorCurrent?{x:t.labelBounds.x,y:-e.schema.buttonHeight/2+1,width:t.labelBounds.width,height:e.schema.buttonHeight}:t.labelBounds,labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)},fontSize:()=>12,verticalAlign:()=>"buttons"===e._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===e._buttonBehaviorCurrent?"#fff":uo,stroke:()=>"buttons"===e._buttonBehaviorCurrent?uo:"transparent",height:t=>"buttons"===e._buttonBehaviorCurrent?e.schema.buttonHeight:t.tick?e.schema.handleSize:0,width:t=>"buttons"===e._buttonBehaviorCurrent?e._ticksWidth/e._availableTicks.length:t.tick?e.schema.domain.map(Number).includes(t.id)?2:1:0,y:t=>"buttons"===e._buttonBehaviorCurrent?"middle"===e.schema.align?e.schema.height/2:"start"===e.schema.align?e._margin.top+e.schema.buttonHeight/2:e.schema.height-e.schema.buttonHeight/2-e._margin.bottom:t.y,rx:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0,ry:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0}}(e)),e._buttonBehaviorCurrent="auto",e._hiddenHandles=!1,e._paddingLeft=0,e._ticksWidth=0}function po(e,t,i,o=i){const a=ho(e.schema);if(a.min<=1&&a.max===1/0||!i.length)return;const r=i.map(Number),s=[t[0],t[t.length-1]].map(e=>function(e,t){let n=-1;return e.forEach((i,o)=>{(n<0||Math.abs(i-t)<Math.abs(e[n]-t))&&(n=o)}),n}(r,Number(e))),c=Math.min(...s),l=Math.max(...s),[h,u]=lo(c,l,r.length,a,"hi","hi");h===c&&u===l||([t[0],t[t.length-1]]=fo([i[h],i[u]]),e.schema.selection=[o[h],o[u]].map(e=>n.date(e)))}const go=[{key:"buttonPadding",coerce:"identity",default:10},{key:"brushing",coerce:"identity",default:!0},{key:"brushFilter",coerce:"identity"},{key:"brushMax",coerce:"const"},{key:"brushMin",coerce:"const",default:N(1)},{key:"buttonAlign",coerce:"identity",default:"middle"},{key:"buttonBehavior",coerce:"identity",default:"auto"},{key:"buttonHeight",coerce:"identity",default:24},{key:"handleSize",coerce:"identity",default:6},{key:"playButton",coerce:"identity",default:!0},{key:"playButtonInterval",coerce:"identity",default:1e3},{key:"selection",coerce:"identity"},{key:"snapping",coerce:"identity",default:!0}];class yo extends hi{_brushBrush(e){if(!e.sourceEvent||null===e.selection||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render()),this._updateDomain(e)),this._brushStyle(),e.sourceEvent&&!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const n=t.pointers(e,this._select.node());n.length&&this._brushGroup.selectAll(".handle").filter(e=>"e"===e.type).attr("x",n[0][0]-this.schema.handleSize/2)}this.schema.on.brush&&this.schema.on.brush(this.schema.selection)}_snapBrushVisual(e){const t=this._hiddenHandles?0:this.schema.handleSize;this._brushGroup.selectAll(".selection").attr("x",e[0]).attr("width",e[1]-e[0]),this._brushGroup.selectAll(".handle").attr("x",n=>("e"===n.type[n.type.length-1]?e[1]:e[0])-t/2)}_brushEnd(e){if(!e.sourceEvent)return;const t=this._updateDomain(e);this._brushStyle();const n=this._brushGroup.transition(this._transition);this.schema.brushing||n.duration(0),n.call(this._brush.move,this._updateBrushLimit(t)),this.schema.on.end&&this.schema.on.end(this.schema.selection)}_brushStart(e){null===e.sourceEvent||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),null!==e.selection&&this._snapBrushVisual(this._updateBrushLimit(this._updateDomain(e)))),this._brushStyle(),this.schema.on.start&&this.schema.on.start(e)}_brushStyle(){const{height:e}=this._position,t="Circle"===this.schema.shape?"function"==typeof this.schema.shapeConfig.r?2*this.schema.shapeConfig.r({tick:!0}):this.schema.shapeConfig.r:"Rect"===this.schema.shape?"function"==typeof this.schema.shapeConfig[e]?this.schema.shapeConfig[e]({tick:!0}):this.schema.shapeConfig[e]:this.schema.tickSize,i=this._brushGroup.selectAll(".selection").call(n.attrize,this.schema.selectionConfig).attr("transform","translate(0,-1)").attr("height",t+2).style("display",()=>this.schema.brushing||this._hiddenHandles?null:"none"),o=this._brushGroup.selectAll(".handle").call(n.attrize,this.schema.handleConfig).style("display",e=>this._hiddenHandles||!this.schema.brushing&&"w"===e.type?"none":null).attr("transform",e=>"buttons"===this._buttonBehaviorCurrent?`translate(${"w"===e.type?-this.schema.handleSize/2:0},-1)`:"").attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight+2:t+this.schema.handleSize);if(!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const e=+i.attr("x")||0,t=+i.attr("width")||0;o.filter(e=>"e"===e.type).attr("x",e+t/2-this.schema.handleSize/2)}if(this._brushGroup.selectAll(".overlay").attr("x",this._paddingLeft).attr("cursor","pointer").attr("transform",`translate(0,${"buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight/2:-this.schema.handleSize})`).attr("width","buttons"===this._buttonBehaviorCurrent?this._ticksWidth:this.schema.width).attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight:2*this.schema.handleSize),"buttons"===this._buttonBehaviorCurrent){const e="middle"===this.schema.align?this.schema.height/2-this.schema.buttonHeight/2:"start"===this.schema.align?this._margin.top:this.schema.height-this.schema.buttonHeight-this._margin.bottom;o.attr("y",e),i.attr("y",e)}}_updateDomain(e){const i=t.pointers(e,this._select.node()),o=(e.selection&&this.schema.brushing||!i.length?e.selection:[i[0][0],i[0][0]]).map(Number),a="ticks"===this._buttonBehaviorCurrent,r=fo(this._availableTicks).map(Number),s=this._d3Scale.range(),c=this._availableTicks.map(Number),l=e=>r.indexOf(a?f.closest(+this._d3Scale.invert(e),r):c[s.indexOf(f.closest(e,s))]),h=a?r:s,u=e.selection,d=i.length?i[0][0]:NaN,m=u&&Math.abs(d-u[0])<Math.abs(d-u[1])?"lo":"hi",[p,g]=function(e,t,n,i,o=!1){const a=Math.min(...e),r=Math.max(...e),s=e["lo"===i?0:1]===a?"lo":"hi",c=o?((e,t,n)=>e===t?"lo":n)(a,r,s):"lo";return lo(a,r,t,n,s,c)}([l(o[0]),l(o[1])],r.length,ho(this.schema),m,!a),y=e=>s[c.indexOf(r[e])],x=a?[n.date(r[p]),n.date(r[g])]:fo([y(p),y(g)]),b=+x[0]===+x[1];return"brush"!==e.type&&"end"!==e.type||(this.schema.selection="ticks"===this._buttonBehaviorCurrent?b?x[0]:x:b?n.date(this._availableTicks[h.indexOf(x[0])]):fo([n.date(this._availableTicks[h.indexOf(x[0])]),n.date(this._availableTicks[h.indexOf(x[1])])])),x}_updateBrushLimit(e){const t="ticks"===this._buttonBehaviorCurrent?fo(e.map(n.date).map(e=>this._d3Scale(e))):e;if(t[0]===t[1]&&(t[0]-=.1,t[1]+=.1),"buttons"===this._buttonBehaviorCurrent){const e=this._hiddenHandles?0:this.schema.handleSize,n=.5*(this._ticksWidth/this._availableTicks.length-e);t[0]-=n,t[1]+=n}return t}_togglePlay(){if(this._playTimer)return clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),void this._onPlayToggle?.();const e=e=>{this.selection(e).render(),this.schema.on.end&&this.schema.on.end(this.schema.selection)};let t=!0;const i=()=>{const i=fo(("ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks)||[]);if(!i.length)return;let o=this.schema.selection||[this.schema.domain[this.schema.domain.length-1]];o instanceof Array||(o=[o]),o=o.map(n.date).map(Number),1===o.length&&o.push(o[0]);const a=i.map(Number),r=a.indexOf(o[0]),s=a.indexOf(o[o.length-1]);s===a.length-1?t?e([i[0],i[s-r]]):(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),this._onPlayToggle?.()):(s+1===a.length-1&&(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1),e([i[r+1],i[s+1]])),t=!1},o=Number(this.schema.duration)||0,a=o>0?o:this.schema.playButtonInterval;this._playTimer=setInterval(i,a),i(),this._onPlayToggle?.()}_isFullRangeSelected(){const e="ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks;if(!e||e.length<2)return!1;if(null==this.schema.selection)return!1;const t=(this.schema.selection instanceof Array?this.schema.selection:[this.schema.selection]).map(n.date).map(Number),i=e.map(Number);return Math.min(...t)<=Math.min(...i)&&Math.max(...t)>=Math.max(...i)}toScene(){const e=super.toScene(),t=this._playButtonClass;return this.schema.playButton&&t&&"function"==typeof t.toScene&&t._data&&t._data.length&&e.children.push(t.toScene()),e}render(e){const{height:t,y:o}=this._position,{ticks:r,tickFormat:l}=function(e){e.schema.ticks&&(e.schema.ticks=gn(e.schema.ticks)),e._data&&(e._data=gn(e._data));let t=e.schema.ticks?e.schema.ticks:e.schema.domain.map(n.date);if(!e.schema.ticks){const n=s.scaleTime().domain(t).range([0,e.schema.width]);t=n.ticks()}const i=e.schema.timeLocale||c.locale[e.schema.locale]||c.locale["en-US"];let o;void 0===e._userFormat&&(e._userFormat=e.schema.tickFormat||!1);const a=e.schema.tickFormat=e._userFormat?e._userFormat:e=>(o&&o.format===g.timeFormat||(o={format:g.timeFormat,label:d.dateFormatter(t,g.timeFormat)}),o.label(e).replace(/^Q/g,i.quarter));return{ticks:t,tickFormat:a}}(this);!function(e,t,i){if(e._ticksWidth=e.schema.width,["auto","buttons"].includes(e.schema.buttonBehavior)){let o=0;t.forEach((t,r)=>{const{fontFamily:s,fontSize:c}=e.schema.shapeConfig.labelConfig,l="function"==typeof s?s(t,r):s,u="function"==typeof c?c(t,r):c,d=a.textWrap().fontFamily(l).fontSize(u).lineHeight(e.schema.shapeConfig.lineHeight?e.schema.shapeConfig.lineHeight(t,r):void 0)(i(t));let f=d.lines.length?Math.ceil(h.max(d.lines.map(e=>n.textWidth(e,{"font-family":l,"font-size":u}))))+u/4:0;f%2&&f++,o<f&&(o=f+2*e.schema.buttonPadding)}),e._ticksWidth=o*t.length}}(this,r,l);const u=this.schema.playButton?this.schema.playButtonConfig.width||this.schema.buttonHeight:0,f=function(e,t,i){const o=e.schema.width-i;e._buttonBehaviorCurrent="auto"===e.schema.buttonBehavior?e._ticksWidth<o?"buttons":"ticks":e.schema.buttonBehavior;const a=e._hiddenHandles="buttons"===e._buttonBehaviorCurrent&&!e.schema.brushing;if("buttons"===e._buttonBehaviorCurrent){e.schema.scale="ordinal";const t=s.scaleTime().domain(e.schema.domain.map(n.date)).ticks().map(Number);e.schema.domain=e.schema.ticks?e.schema.ticks:Array.from(Array(t[t.length-1]-t[0]+1),(e,n)=>t[0]+n).map(n.date),e.schema.ticks=e.schema.domain;const o=.5*e._ticksWidth/e.schema.ticks.length,a=e.schema.width-e._ticksWidth-i;e._paddingLeft="middle"===e.schema.buttonAlign?a/2+i:"end"===e.schema.buttonAlign?a+i:i,e.schema.range=[e._paddingLeft+o,e._paddingLeft+e._ticksWidth-o]}else e.schema.scale="time",e.schema.domain=h.extent(t),e.schema.range=[i?1.5*i:void 0,void 0],e._paddingLeft=i;return a}(this,r,u);if(super.render(e),function(e,t,i,o){const a=e._outerBounds[o],r=e._d3Scale.range(),[s,c]="buttons"===e._buttonBehaviorCurrent?[e._paddingLeft,e._paddingLeft+e._ticksWidth]:[r[0],r[r.length-1]],l=e._brush=p.brushX().extent([[s,a],[c,a+e._outerBounds[i]]]).filter(e.schema.brushFilter).handleSize(t?0:e.schema.handleSize).on("start",e._brushStart.bind(e)).on("brush",e._brushBrush.bind(e)).on("end",e._brushEnd.bind(e)),h=fo(("ticks"===e._buttonBehaviorCurrent?e._availableTicks:e.schema.ticks)||[]),u=t=>{const n=h[h.map(Number).indexOf(+t)];return void 0===n?void 0:e._d3Scale(n)},d="ticks"===e._buttonBehaviorCurrent?h:h.map(u),f=fo([e.schema.brushMin()>d.length?d[0]:d[d.length-e.schema.brushMin()],d[d.length-1]]),m=void 0===e.schema.selection?f:e.schema.selection instanceof Array?"buttons"===e._buttonBehaviorCurrent?fo(e.schema.selection.map(n.date).map(u)):e.schema.selection.map(n.date):"buttons"===e._buttonBehaviorCurrent?[u(n.date(e.schema.selection))]:[e.schema.selection];1===m.length&&m.push(m[0]),po(e,m,d,h),e._updateBrushLimit(m),e._brushGroup=n.elem("g.brushGroup",{parent:e._group}),e._brushGroup.call(l).transition(e._transition).call(l.move,"ticks"===e._buttonBehaviorCurrent?e._updateBrushLimit(m):m),e._outerBounds.y-=e.schema.handleSize/2,e._outerBounds.height+=e.schema.handleSize/2}(this,f,t,o),function(e,t){const i=n.elem("g.d3plus-Timeline-play",{parent:e._group}),o=e.schema.playButton?[{x:e._paddingLeft-t,y:"buttons"===e._buttonBehaviorCurrent?"middle"===e.schema.align?e.schema.height/2-e.schema.buttonHeight/2:"start"===e.schema.align?e._margin.top:e.schema.height-e.schema.buttonHeight-e._margin.bottom:e._outerBounds.y,width:t,height:e.schema.buttonHeight}]:[],a=e._isFullRangeSelected();e._playButtonClass.renderMode("compute").data(o).select(i.node()).config(Ae.bind(e)(e.schema.playButtonConfig)),a&&e._playButtonClass.config({fontColor:e.schema.colorDefaults.missing}),e._playButtonClass.render();const r=n.elem("rect.d3plus-Timeline-play-hit",{parent:i,condition:o.length>0});if(o.length){const t=o[0];r.attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height).attr("fill","transparent").attr("cursor",a?"default":"pointer").style("pointer-events",a?"none":"all").on("click",()=>{e._isFullRangeSelected()||e._togglePlay()})}}(this,u),"compute"!==this.schema.renderMode&&this._select&&(function(e,t){const n=e._select,o=n&&"function"==typeof n.node?n.node():null;if(!(o instanceof Element))return;const a=o,r=e.schema.width??400,s=e.schema.height??100,c=e;c._sceneRenderer?c._sceneRenderer.resize(r,s):(c._sceneRenderer=new i.SvgRenderer,c._sceneRenderer.mount({container:a,width:r,height:s})),c._sceneRenderer.drawScene({root:{type:"group",key:"root",children:[t]},width:r,height:s},{duration:0}),ve(e)}(this,this.toScene()),this._group)){const e=this._select.node(),t=this._group.node();e instanceof Element&&t instanceof Element&&t.parentNode===e&&e.appendChild(t)}return this}handleConfig(e){return arguments.length?(this.schema.handleConfig=Y(this,"handleConfig",e),this):this.schema.handleConfig}on(e,t){return 2===arguments.length?(this.schema.on[e]=t,this):arguments.length?"string"==typeof e?this.schema.on[e]:(this.schema.on=n.assign({},this.schema.on,e),this):this.schema.on}playButtonConfig(e){return arguments.length?(this.schema.playButtonConfig=Y(this,"playButtonConfig",e),this):this.schema.playButtonConfig}selectionConfig(e){return arguments.length?(this.schema.selectionConfig=Y(this,"selectionConfig",e),this):this.schema.selectionConfig}constructor(){super(),ee(this,go),mo(this),this._managesOwnScenePaint=!0}}function xo(e=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:e[0],y:e[1],top:e[1],right:e[0],bottom:e[1],left:e[0]})}}async function bo(e,t,n,i,o,a){const{x:r,y:s,placement:c,middlewareData:l}=await m.computePosition(e,t,{strategy:"fixed",placement:"top",middleware:[m.offset(i+o),m.flip({fallbackPlacements:["bottom"],padding:5}),m.shift({padding:5}),m.arrow({element:n})]});Object.assign(t.style,{position:"fixed",left:`${r}px`,top:`${s}px`,visibility:"visible"});const h="bottom"===c,u=parseFloat(n.style.borderRightWidth)||0;h?(n.style.transform="rotate(225deg)",n.style.top=`-${a/2+u}px`,n.style.bottom=""):(n.style.transform="rotate(45deg)",n.style.bottom=`-${a/2+u}px`,n.style.top=""),n.style.left=null!=l.arrow?.x?`${l.arrow.x}px`:""}K(yo.prototype,"handleConfig","playButtonConfig","selectionConfig");const _o=['[id="d3plus-portal"]',".d3plus-tooltip-portal",".d3plus-tooltip",".d3plus-tooltip-title",".d3plus-tooltip-body",".d3plus-tooltip-footer",".d3plus-tooltip-arrow",".d3plus-tooltip-table",".d3plus-tooltip-thead",".d3plus-tooltip-tbody"];function ko(e,t,n,i){return`${i?`d3plus-tooltip-${i}`:"d3plus-tooltip"}-${e._uuid}-${t?e.schema.id(t,n):""}`}function vo(e,t,i,o){t.append("div").attr("class",`d3plus-tooltip-${o}`).attr("id",(t,n)=>ko(e,t,n,o));const a=i.select(`.d3plus-tooltip-${o}`).html((t,n)=>e.schema[o](t,n)).style("display",(t,n)=>{const i=e.schema[o](t,n);return!1!==i&&null!=i?"block":"none"});n.stylize(a,e.schema[`${o}Style`])}function wo(e,t){t.style("background",e.schema.background).style("border-radius",e.schema.borderRadius).style("pointer-events",e.schema.pointerEvents).style("padding",e.schema.padding).style("max-width",e.schema.maxWidth).style("min-width",e.schema.minWidth).style("width",e.schema.width).style("height",e.schema.height).style("border",e.schema.border)}const So="d3plus-tooltip",Co=[{key:"arrow",coerce:"const",default:T("arrow","")},{key:"background",coerce:"const",factory:e=>()=>e.schema.colorDefaults.light},{key:"body",coerce:"const",default:T("body","")},{key:"border",coerce:"const",default:N("1px solid rgba(0, 0, 0, 0.25)")},{key:"borderRadius",coerce:"const",default:N("4px")},{key:"footer",coerce:"const",default:T("footer","")},{key:"height",coerce:"const",default:N("auto")},{key:"id",coerce:"const",default:(e,t)=>`${t}`},{key:"offset",coerce:"const",default:N(5)},{key:"padding",coerce:"const",default:N("10px")},{key:"pointerEvents",coerce:"const",default:N("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:T("title","")},{key:"titleSwatch",coerce:"identity",default:!0},{key:"maxWidth",coerce:"const",default:N("300px")},{key:"minWidth",coerce:"const",default:N("200px")},{key:"width",coerce:"const",default:N("auto")}];class Mo extends $e{render(e){const o=this,a=`d3plus-tooltip-${this._uuid}-`,r=function(e){if(!e._parentEl)return n.elem("div#d3plus-portal");let i=e._portalEl??null;return i&&i.isConnected||(i=document.createElement("div"),i.setAttribute("class","d3plus-tooltip-portal"),i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.width="0",i.style.height="0",i.style.pointerEvents="none",document.body.appendChild(i),e._portalEl=i),t.select(i)}(this);i.resetInjectedBoxes(r.node(),_o);const s=r.selectAll(`.${So}`).filter(function(){return this.id.startsWith(a)}).data(this._data,this.schema.id),c=s.enter().append("div").attr("class",So),l=s.merge(c);return l.each(function(){this instanceof Element&&ke(this,o.schema.className,[So])}),n.stylize(l,this.schema.tooltipStyle),vo(this,c,l,"title"),vo(this,c,l,"body"),function(e,t,i,o){const a=t.append("table").attr("class","d3plus-tooltip-table"),r=i.select(".d3plus-tooltip-table");n.stylize(r,e.schema.tableStyle),a.append("thead").attr("class","d3plus-tooltip-thead");const s=i.select(".d3plus-tooltip-thead");n.stylize(s,e.schema.theadStyle);const c=s.selectAll("tr").data([0]),l=c.enter().append("tr");c.exit().remove();const h=c.merge(l);n.stylize(h,e.schema.trStyle);const u=h.selectAll("th").data(e.schema.thead),d=u.enter().append("th").merge(u).html(o);n.stylize(d,e.schema.thStyle),u.exit().remove(),a.append("tbody").attr("class","d3plus-tooltip-tbody");const f=i.select(".d3plus-tooltip-tbody");n.stylize(f,e.schema.tbodyStyle);const m=f.selectAll("tr").data(e.schema.tbody),p=m.enter().append("tr");m.exit().remove();const g=m.merge(p);n.stylize(g,e.schema.trStyle);const y=g.selectAll("td").data(e=>e),x=y.enter().append("td").merge(y).html(o);n.stylize(x,e.schema.tdStyle)}(this,c,l,function(e){if("function"==typeof e){const n=t.select(this.parentNode.parentNode).datum();return e(n,o._data.indexOf(n),n)}return e}),vo(this,c,l,"footer"),vo(this,c,l,"arrow"),function(e,t,n,i){t.attr("id",(t,n)=>ko(e,t,n)).style("visibility","hidden").call(t=>wo(e,t)).each(function(t,n){const i=e.schema.id(t,n),o=this,a=o.querySelector(".d3plus-tooltip-arrow"),r=a.offsetHeight,s=a.getBoundingClientRect().height/2;a.style.bottom=`-${r/2}px`;const c=e.schema.position(t,n),l=Array.isArray(c)?xo(c):c;e._tooltipRefs[i]={reference:l,arrowEl:a,tooltip:o,arrowHeight:r,arrowDistance:s},bo(l,o,a,e.schema.offset(t,n),s,r)}),n.each(function(t,n){const i=e.schema.id(t,n),o=e.schema.position(t,n),a=e._tooltipRefs[i];a&&(a.reference=Array.isArray(o)?xo(o):o,bo(a.reference,a.tooltip,a.arrowEl,e.schema.offset(t,n),a.arrowDistance,a.arrowHeight))}).call(t=>wo(e,t)),i.exit().each(function(t,n){const i=e.schema.id(t,n);delete e._tooltipRefs[i]}).remove()}(this,c,l,s),e&&setTimeout(e,100),this}className(e){return arguments.length?super.className(e):super.className()}arrowStyle(e){return arguments.length?(this.schema.arrowStyle=Y(this,"arrowStyle",e),this):this.schema.arrowStyle}bodyStyle(e){return arguments.length?(this.schema.bodyStyle=Y(this,"bodyStyle",e),this):this.schema.bodyStyle}parent(e){if(!arguments.length)return this._parentEl;const t=this._parentEl,n=e||void 0;return t&&t!==n&&this._portalEl&&(this._portalEl.remove(),this._portalEl=void 0),this._parentEl=n,this}data(e){return arguments.length?(this._data=e,this):this._data}footerStyle(e){return arguments.length?(this.schema.footerStyle=Y(this,"footerStyle",e),this):this.schema.footerStyle}position(e){return arguments.length?(this.schema.position="string"==typeof e?N(t.select(e).node()||[0,0]):"function"==typeof e?e:N(e),this):this.schema.position}tableStyle(e){return arguments.length?(this.schema.tableStyle=Y(this,"tableStyle",e),this):this.schema.tableStyle}tbodyStyle(e){return arguments.length?(this.schema.tbodyStyle=Y(this,"tbodyStyle",e),this):this.schema.tbodyStyle}theadStyle(e){return arguments.length?(this.schema.theadStyle=Y(this,"theadStyle",e),this):this.schema.theadStyle}titleStyle(e){return arguments.length?(this.schema.titleStyle=Y(this,"titleStyle",e),this):this.schema.titleStyle}tooltipStyle(e){return arguments.length?(this.schema.tooltipStyle=Y(this,"tooltipStyle",e),this):this.schema.tooltipStyle}trStyle(e){return arguments.length?(this.schema.trStyle=Y(this,"trStyle",e),this):this.schema.trStyle}tdStyle(e){return arguments.length?(this.schema.tdStyle=Y(this,"tdStyle",e),this):this.schema.tdStyle}thStyle(e){return arguments.length?(this.schema.thStyle=Y(this,"thStyle",e),this):this.schema.thStyle}constructor(){super(),ee(this,Co),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=e=>[e.x,e.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":"0 1px 5px rgba(0, 0, 0, 0.25)",color:(e,t)=>r.colorContrast(this.schema.background(e,t),this.schema.colorDefaults),"font-family":a.fontFamilyStringify(a.fontFamily)},this.schema.trStyle={"border-top":(e,t)=>t?"1px solid rgba(0, 0, 0, 0.1)":"none"};const e=(e,t)=>t?"right":"left";this.schema.tdStyle={"text-align":e},this.schema.thStyle={"text-align":e}}}function $o(e){const{data:t,dataFilter:n,label:i,labelBounds:o,x:a,y:r,aes:s,rotate:c,id:l,datum:h}=e,u=[];return(n?n(t):t).forEach((e,n)=>{let d=e;e.nested&&void 0!==e.key&&e.values&&(d=e.values[0],n=t.indexOf(d));let f=i(d,n);if(o&&!1!==f&&null!=f){const t=o(d,n,s(e,n));if(!t)return;f.constructor!==Array&&(f=[f]);const i=d.__d3plusShape__?d.translate?d.translate[0]:a(d.data,d.i):a(d,n),m=d.__d3plusShape__?d.translate?d.translate[1]:r(d.data,d.i):r(d,n);d.__d3plusShape__&&(d=d.data,n=d.i);for(let e=0;e<f.length;e++){const o=t.constructor===Array?t[e]:Object.assign({},t),a=c(d,n),r=d.labelConfig;let s=r&&r.rotate?r.rotate:void 0!==t.angle?t.angle:0;s+=a;const p=0!==a?[-1*o.x||0,-1*o.y||0]:[o.width/2,o.height/2];u.push({__d3plus__:!0,data:h?h(d,n):d,height:o.height,l:e,id:`${l(d,n)}_${e}`,r:s,rotateAnchor:p,...o.shape?{__d3plusWrapShape__:o.shape}:{},text:f[e],width:o.width,x:i+o.x,y:m+o.y})}}}),u}K(Mo.prototype,"arrowStyle","bodyStyle","footerStyle","tableStyle","tbodyStyle","theadStyle","titleStyle","tooltipStyle","trStyle","tdStyle","thStyle");const Ao=["squares","nylon","waves","woven","crosses","caps","hexagons"],zo=["background","fill","stroke"];function Do(e,t,i,o={}){if(!e)return!1;const a=t();if("none"===a)return!1;const r=n.isObject(e)?{...e}:{texture:e};r.background||(r.background=a),r.stroke||o.stroke||(r.stroke=i()),Ao.includes(r.texture)||"function"==typeof r.texture?(r.d=r.texture,r.texture="paths"):"grid"===r.texture&&(r.orientation||o.orientation||(r.orientation=["vertical","horizontal"]),r.texture="lines"),r.fill||"paths"===r.texture||(r.fill=r.stroke);for(const e of zo){const t=r[e];t&&"object"==typeof t&&(r[e]=String(t))}const s=n.assign({},o,r);return"function"==typeof s.d&&(s.d=s.d(s.size||20)),JSON.stringify(s)}function Fo(e){let t=e;for(;t.__d3plus__&&t.data;)t=t.data;return t.__d3plusShape__?t.data:t}function Bo(e,t){if("number"==typeof e.width&&"number"==typeof e.height){return{x:"number"==typeof e.x?e.x:-e.width/2,y:"number"==typeof e.y?e.y:-e.height/2,width:e.width,height:e.height}}if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,n="number"==typeof e.cy?e.cy:0;return{x:t-e.r,y:n-e.r,width:2*e.r,height:2*e.r}}if("string"==typeof e.d){const t=f.pathBounds(e.d);return t.width>0&&t.height>0?t:null}return function(e){if(!e.length)return null;let t=1/0,n=1/0,i=-1/0,o=-1/0;for(const[a,r]of e)a<t&&(t=a),r<n&&(n=r),a>i&&(i=a),r>o&&(o=r);return!Number.isFinite(t)||i<=t||o<=n?null:{x:t,y:n,width:i-t,height:o-n}}(t)}function Lo(e,t,n,i,o,a){return`M${e+(o=Math.min(o,n/2))},${t}h${n-2*o}a${o},${a=Math.min(a,i/2)} 0 0 1 ${o},${a}v${i-2*a}a${o},${a} 0 0 1 ${-o},${a}h${-(n-2*o)}a${o},${a} 0 0 1 ${-o},${-a}v${-(i-2*a)}a${o},${a} 0 0 1 ${o},${-a}Z`}function Po(e,t){if("string"==typeof e.d)return{type:"path",d:e.d};if("number"==typeof e.width&&"number"==typeof e.height){const t="number"==typeof e.x?e.x:-e.width/2,n="number"==typeof e.y?e.y:-e.height/2,i="number"==typeof e.rx?e.rx:0,o="number"==typeof e.ry?e.ry:0;return i>0||o>0?{type:"path",d:Lo(t,n,e.width,e.height,i||o,o||i)}:{type:"rect",x:t,y:n,width:e.width,height:e.height}}if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,n="number"==typeof e.cy?e.cy:0,i=e.r;return{type:"path",d:`M${t-i},${n}a${i},${i} 0 1,0 ${2*i},0a${i},${i} 0 1,0 ${-2*i},0Z`}}if(t.length>2){return{type:"path",d:`M${t.map(([e,t])=>`${e},${t}`).join("L")}Z`}}}function Ro(e,t,n){if("contain"!==n){const n=Bo(e,t);return n?{box:n,clip:Po(e,t),preserveAspectRatio:"xMidYMid slice"}:null}let i;if("number"==typeof e.width&&"number"==typeof e.height)i=Bo(e,t);else if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,n="number"==typeof e.cy?e.cy:0,o=e.r/Math.SQRT2;i={x:t-o,y:n-o,width:2*o,height:2*o}}else{const n=function(e,t){return"string"==typeof e.d?f.path2polygon(e.d):t}(e,t),o=n.length>2?f.largestRect(n,{angle:0}):null;i=o?{x:o.cx-o.width/2,y:o.cy-o.height/2,width:o.width,height:o.height}:Bo(e,t)}return i?{box:i,preserveAspectRatio:"xMidYMid meet"}:null}function Eo(e,t,n){return e.map((e,i)=>{const o={type:"image",key:`${e.key}-bgimage-img`,x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,href:e.url,preserveAspectRatio:e.preserveAspectRatio,interactive:!1};return{type:"group",key:`${e.key}-bgimage`,children:[o],datum:e.datum,index:e.index,interactive:!1,paint:{opacity:e.opacity??1},...e.transform?{transform:e.transform}:{},...e.clip?{clip:e.clip}:{},...t?{z:n+i}:{}}})}function No(e){const t=Number(e);return Number.isFinite(t)?t:void 0}function To(e){return null==e||""===e?void 0:String(e)}function Oo(e){if(null==e||"none"===e||""===e)return;if("number"==typeof e)return[e];const t=String(e).split(/[\s,]+/).map(Number).filter(e=>Number.isFinite(e));return t.length?t:void 0}const Wo=[{key:"activeOpacity",coerce:"identity",default:.25},{key:"ariaLabel",coerce:"const",default:N("")},{key:"backgroundImage",coerce:"const",default:N(!1)},{key:"backgroundImageFit",coerce:"const",default:N("cover")},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"fill",coerce:"const",default:N("black")},{key:"fillOpacity",coerce:"const",default:N(1)},{key:"hitArea",coerce:"const"},{key:"hoverOpacity",coerce:"identity",default:.5},{key:"id",coerce:"accessor",default:(e,t)=>void 0!==e.id?e.id:t},{key:"label",coerce:"const",default:N(!1)},{key:"labelBounds",coerce:"const"},{key:"opacity",coerce:"const",default:N(1)},{key:"pointerEvents",coerce:"const",default:N("visiblePainted")},{key:"renderMode",coerce:"identity",default:"full"},{key:"role",coerce:"const",default:N("presentation")},{key:"rotate",coerce:"const",default:N(0)},{key:"rx",coerce:"const",default:N(0)},{key:"ry",coerce:"const",default:N(0)},{key:"scale",coerce:"const",default:N(1)},{key:"shapeRendering",coerce:"const",default:N("geometricPrecision")},{key:"stroke",coerce:"const"},{key:"strokeDasharray",coerce:"const",default:N("0")},{key:"strokeLinecap",coerce:"const",default:N("butt")},{key:"strokeOpacity",coerce:"const",default:N(1)},{key:"strokeWidth",coerce:"const",default:N(0)},{key:"textAnchor",coerce:"const",default:N("start")},{key:"texture",coerce:"const",default:N(!1)},{key:"vectorEffect",coerce:"const",default:N("non-scaling-stroke")},{key:"verticalAlign",coerce:"const",default:N("top")},{key:"x",coerce:"accessor",default:T("x",0)},{key:"y",coerce:"accessor",default:T("y",0)}];class jo extends $e{_aes(e,t){return{}}_getTextureKey(e,t){const n=this._styleVal(this.schema.texture,e,t);return!!n&&Do(n,()=>this._styleVal(this.schema.fill,e,t),()=>this._styleVal(this.schema.stroke,e,t),this.schema.textureDefault)}_nestWrapper(e){return(t,n)=>e(t.__d3plusShape__?t.data:t,t.__d3plusShape__?t.i:n)}_buildLabelData(){return $o({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(this):void 0,label:this.schema.label,labelBounds:this.schema.labelBounds?this.schema.labelBounds.bind(this):void 0,x:this.schema.x,y:this.schema.y,aes:this._aes.bind(this),rotate:this.schema.rotate,id:this.schema.id})}_styleVal(e,t,n){return"function"!=typeof e?e:t.nested&&void 0!==t.key&&t.values?e(t.data,t.i):e(t,n)}_sceneTransform(e,t){const n=Boolean(e.__d3plusShape__),i=n?e.data:e,o=n?e.i:t;let a,r;if(n&&e.translate){const[t,n]=String(e.translate).split(",").map(Number);a=t,r=n}else a=Number(this.schema.x(i,o)),r=Number(this.schema.y(i,o));return{x:a,y:r,scale:n&&void 0!==e.scale?Number(e.scale):Number(this.schema.scale(i,o)),rotate:n&&void 0!==e.rotate?Number(e.rotate):Number(this.schema.rotate(e.data||e,o))}}_scenePaint(e,t){const n=this._getTextureKey(e,t);return{fill:n?`pattern:${n}`:To(this._styleVal(this.schema.fill,e,t)),fillOpacity:No(this._styleVal(this.schema.fillOpacity,e,t)),stroke:To(this._styleVal(this.schema.stroke,e,t)),strokeWidth:No(this._styleVal(this.schema.strokeWidth,e,t)),strokeOpacity:No(this._styleVal(this.schema.strokeOpacity,e,t)),strokeDasharray:Oo(this._styleVal(this.schema.strokeDasharray,e,t)),strokeLinecap:To(this._styleVal(this.schema.strokeLinecap,e,t)),vectorEffect:To(this._styleVal(this.schema.vectorEffect,e,t)),shapeRendering:To(this._nestWrapper(this.schema.shapeRendering)(e,t)),opacity:No(this._nestWrapper(this.schema.opacity)(e,t))}}_sceneGeometry(e,t){return null}toScene(){let e=this._data;this._dataFilter&&(e=this._dataFilter(e));const t=[],n=[],i=function(e,t){if(!t||e.length<2)return null;const n=e.map((e,t)=>t);n.sort((n,i)=>t(Fo(e[n]),Fo(e[i])));const i=new Array(e.length);return n.forEach((e,t)=>i[e]=t),i}(e,this.schema.sort);return e.forEach((e,o)=>{const a=this._sceneGeometry(e,o);if(!a)return;const r=this._nestWrapper(this.schema.id)(e,o),s=e.__d3plusShape__?e.data:e,c=this._sceneTransform(e,o),l=this._scenePaint(e,o),h=function(e,t,n,i){if(!e.__d3plusShape__||!Array.isArray(e.values))return{};const o=e.values,a=[];return o.forEach((e,o)=>{if("function"==typeof i&&!1===i(e,o))return;const r=Number(t(e,o)),s=Number(n(e,o));Number.isFinite(r)&&Number.isFinite(s)&&a.push({x:r,y:s,datum:e,index:"number"==typeof e.i?e.i:o})}),a.length?{interactionPoints:a}:{}}(e,this.schema.x,this.schema.y,this.schema.defined);if(this.schema.hitArea){const n=function(e,t,n,i,o,a,r,s,c){const l="function"==typeof e?e(t,n,i):e;if(!l)return null;if("number"!=typeof l.width&&"string"==typeof c)return{type:"path",d:c,key:`${o}::hit`,datum:a,index:n,shapeType:r,paint:{fill:"none",stroke:"transparent",strokeWidth:"number"==typeof l["stroke-width"]?l["stroke-width"]:10,vectorEffect:"non-scaling-stroke"},transform:s,aria:{hidden:!0}};return"number"!=typeof l.width||"number"!=typeof l.height?null:{type:"rect",x:"number"==typeof l.x?l.x:-l.width/2,y:"number"==typeof l.y?l.y:-l.height/2,width:l.width,height:l.height,key:`${o}::hit`,datum:a,index:n,shapeType:r,paint:{fill:"transparent"},transform:s,aria:{hidden:!0}}}(this.schema.hitArea,e,o,this._aes(e,o),r,s,this._name,c,a.d);n&&t.push(i?{...n,...h,z:i[o]}:{...n,...h})}t.push({...a,key:r,datum:s,index:o,shapeType:this._name,paint:l,transform:c,aria:{role:To(this._nestWrapper(this.schema.role)(e,o)),label:To(this._nestWrapper(this.schema.ariaLabel)(e,o))},...h,...i?{z:i[o]}:{}});const u="none"!==l.fill&&this._nestWrapper(this.schema.backgroundImage)(e,o);if(u){const t=a,i=Ro(t,"string"!=typeof t.d&&"number"!=typeof t.width&&"number"!=typeof t.r?this._aes(e,o).points??[]:[],"contain"===this._nestWrapper(this.schema.backgroundImageFit)(e,o)?"contain":"cover");i&&n.push({key:r,index:o,datum:s,url:u,box:i.box,clip:i.clip,preserveAspectRatio:i.preserveAspectRatio,opacity:No(this._nestWrapper(this.schema.opacity)(e,o)),transform:c})}}),n.length&&t.push(...Eo(n,i,e.length)),{type:"group",key:`${this._name}-group`,children:t}}render(e){const t=this._labelClass;if(t&&"function"==typeof t.renderMode&&t.renderMode("compute"),this._labelClass.config(this.schema.labelConfig),this._labelClass.data(this._buildLabelData()),"compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;if(void 0===this._select&&"undefined"!=typeof document){const e=document.createElement("div");e.style.cssText="display:block;",document.body.appendChild(e),this.select(e)}if(this._select){const e=this._select,t=e&&"function"==typeof e.node?e.node():e;t&&function(e,t){const o="svg"===(t.tagName||"").toLowerCase(),a=o?Number(t.getAttribute("width")):t.clientWidth,r=o?Number(t.getAttribute("height")):t.clientHeight,[s,c]=a&&r?[a,r]:n.getSize(t),l=a||s||400,h=r||c||300,u=e.toScene(),d=[];e._labelClass&&"function"==typeof e._labelClass.toScene&&e._labelClass._data&&e._labelClass._data.length&&d.push(...e._labelClass.toScene().children);const f={root:{...u,children:[...u.children,...d]},width:l,height:h},m=e._sceneRenderer;if(m&&"function"==typeof m.destroy&&m.destroy(),!m)for(;t.firstChild;)t.removeChild(t.firstChild);const p=new i.SvgRenderer;p.mount({container:t,width:l,height:h}),p.drawScene(f),e._sceneRenderer=p,ve(e)}(this,t)}return e&&setTimeout(e,0),this}active(e){return arguments.length&&void 0!==e?(this.schema.active=e,this):this.schema.active}activeStyle(e){return arguments.length?(this.schema.activeStyle=Y(this,"activeStyle",e),this):this.schema.activeStyle}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){return arguments.length&&void 0!==e?(this.schema.hover=e,this):this.schema.hover}hoverStyle(e){return arguments.length?(this.schema.hoverStyle=Y(this,"hoverStyle",e),this):this.schema.hoverStyle}labelConfig(e){return arguments.length?(this.schema.labelConfig=Y(this,"labelConfig",e),this):this.schema.labelConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}sort(e){return arguments.length?(this.schema.sort=e??null,this):this.schema.sort}textureDefault(e){return arguments.length?(this.schema.textureDefault=Y(this,"textureDefault",e),this):this.schema.textureDefault}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(e="g"){super(),ee(this,Wo),this._data=[],this._labelClass=new ro,this._name="Shape",this._tagName=e,this._textureDefs={},this.schema.stroke=(e,t)=>{const n=l.color(this.schema.fill(e,t));return n?n.darker(1).formatHex():this.schema.fill(e,t)},this.schema.activeStyle={stroke:(e,t)=>{let n=this.schema.fill(e,t);["transparent","none"].includes(n)&&(n=this.schema.stroke(e,t));const i=l.color(n);return i?i.darker(1).toString():n},"stroke-width":(e,t)=>3*(this.schema.strokeWidth(e,t)||1)},this.schema.hoverStyle={stroke:(e,t)=>{let n=this.schema.fill(e,t);["transparent","none"].includes(n)&&(n=this.schema.stroke(e,t));const i=l.color(n);return i?i.darker(.5).toString():n},"stroke-width":(e,t)=>2*(this.schema.strokeWidth(e,t)||1)},this.schema.labelConfig={fontColor:(e,t)=>r.colorContrast(this.schema.fill(e,t),this.schema.colorDefaults),fontOpacity:(e,t)=>this.schema.opacity(e,t),fontResize:!0,fontMax:50,fontMin:8,fontSize:12,padding:5,textAnchor:"start",verticalAlign:"top"},this.schema.textureDefault={}}}K(jo.prototype,"activeStyle","hoverStyle","labelConfig","textureDefault");const Ho=[{key:"curve",coerce:"const",default:N("linear")},{key:"defined",coerce:"identity",default:()=>!0}];class Io extends jo{_sceneGeometry(e){const t=Number(e.x),n=Number(e.y),i=String(this.schema.curve.bind(this)(this.config())),o=L[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`],a=e=>(n,i)=>e(n,i)-t,r=e=>(t,i)=>e(t,i)-n,s=L.area().defined(this.schema.defined).curve(o).x(a(this.schema.x)).x0(a(this.schema.x0)).y(r(this.schema.y)).y0(r(this.schema.y0));return this.schema.x1?s.x1(a(this.schema.x1)):s.x1(null),this.schema.y1?s.y1(r(this.schema.y1)):s.y1(null),{type:"path",d:s(e.values)||""}}_aes(e){const t=e.values.slice().sort((e,t)=>this.schema.y1?this.schema.x(e)-this.schema.x(t):this.schema.y(e)-this.schema.y(t)),n=t.map((e,t)=>[this.schema.x0(e,t),this.schema.y0(e,t)]),i=t.reverse().map((e,t)=>this.schema.y1?[this.schema.x(e,t),this.schema.y1(e,t)]:[this.schema.x1(e,t),this.schema.y(e,t)]);let o=n.concat(i);return n[0][1]>i[0][1]&&(o=o.reverse()),o.push(o[0]),{points:o}}_dataFilter(e){const t=h.groups(e,this.schema.id).map(([t,n])=>{const i={key:t,values:n};i.data=o.merge(i.values),i.i=e.indexOf(i.values[0]);const a=h.extent(i.values.map(this.schema.x).concat(i.values.map(this.schema.x0)).concat(this.schema.x1?i.values.map(this.schema.x1):[]));i.xR=a,i.width=a[1]-a[0],i.x=a[0]+i.width/2;const r=h.extent(i.values.map(this.schema.y).concat(i.values.map(this.schema.y0)).concat(this.schema.y1?i.values.map(this.schema.y1):[]));return i.yR=r,i.height=r[1]-r[0],i.y=r[0]+i.height/2,i.nested=!0,i.translate=[i.x,i.y],i.__d3plusShape__=!0,i});return t.key=e=>e.key,t}x(e){return arguments.length?(this.schema.x="function"==typeof e?e:N(e),this.schema.x0=this.schema.x,this):this.schema.x}x0(e){return arguments.length?(this.schema.x0="function"==typeof e?e:N(e),this.schema.x=this.schema.x0,this):this.schema.x0}x1(e){return arguments.length?(this.schema.x1="function"==typeof e?e:null===e?null:N(e),this):this.schema.x1}y(e){return arguments.length?(this.schema.y="function"==typeof e?e:N(e),this.schema.y0=this.schema.y,this):this.schema.y}y0(e){return arguments.length?(this.schema.y0="function"==typeof e?e:N(e),this.schema.y=this.schema.y0,this):this.schema.y0}y1(e){return arguments.length?(this.schema.y1="function"==typeof e?e:null===e?null:N(e),this):this.schema.y1}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,Ho),this._name="Area",this.schema.labelBounds=(e,t,n)=>{const i=f.largestRect(n.points);return i?{angle:i.angle,width:i.width,height:i.height,x:i.cx-i.width/2-this.schema.x(e,t),y:i.cy-i.height/2-this.schema.y(e,t)}:null},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this.schema.x=T("x"),this.schema.x0=T("x"),this.schema.x1=null,this.schema.y=N(0),this.schema.y0=N(0),this.schema.y1=T("y")}}const Go=[{key:"height",coerce:"accessor",default:N(10)},{key:"width",coerce:"accessor",default:N(10)}];class Vo extends jo{_sceneGeometry(e,t){const n=this._getWidth(e,t),i=this._getHeight(e,t);return{type:"rect",x:null!==this.schema.x1?this._getX(e,t):-n/2,y:null===this.schema.x1?this._getY(e,t):-i/2,width:n,height:i}}_aes(e,t){return{height:this._getHeight(e,t),width:this._getWidth(e,t)}}_applyPosition(e){e.attr("width",(e,t)=>this._getWidth(e,t)).attr("height",(e,t)=>this._getHeight(e,t)).attr("x",(e,t)=>null!==this.schema.x1?this._getX(e,t):-this._getWidth(e,t)/2).attr("y",(e,t)=>null===this.schema.x1?this._getY(e,t):-this._getHeight(e,t)/2)}_getHeight(e,t){return null!==this.schema.x1?this.schema.height(e,t):Math.abs(this.schema.y1(e,t)-this.schema.y(e,t))}_getWidth(e,t){return null===this.schema.x1?this.schema.width(e,t):Math.abs(this.schema.x1(e,t)-this.schema.x(e,t))}_getX(e,t){const n=null===this.schema.x1?this.schema.x(e,t):this.schema.x1(e,t)-this.schema.x(e,t);return n<0?n:0}_getY(e,t){const n=null!==this.schema.x1?this.schema.y(e,t):this.schema.y1(e,t)-this.schema.y(e,t);return n<0?n:0}x0(e){return arguments.length?(this.schema.x0="function"==typeof e?e:N(e),this.schema.x=this.schema.x0,this):this.schema.x0}x1(e){return arguments.length?(this.schema.x1="function"==typeof e?e:null===e?null:N(e),this):this.schema.x1}y0(e){return arguments.length?(this.schema.y0="function"==typeof e?e:N(e),this.schema.y=this.schema.y0,this):this.schema.y0}y1(e){return arguments.length?(this.schema.y1="function"==typeof e?e:null===e?null:N(e),this):this.schema.y1}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("rect"),ee(this,Go),this._name="Bar",this.schema.labelBounds=(e,t,n)=>({width:n.width,height:n.height,x:null!==this.schema.x1?this._getX(e,t):-n.width/2,y:null===this.schema.x1?this._getY(e,t):-n.height/2}),Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=T("x"),this.schema.x0=T("x"),this.schema.x1=null,this.schema.y=N(0),this.schema.y0=N(0),this.schema.y1=T("y")}}const qo=[{key:"height",coerce:"accessor",default:T("height")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0},{key:"width",coerce:"accessor",default:T("width")}];class Yo extends jo{_sceneGeometry(e,t){const n=Number(this.schema.width(e,t)),i=Number(this.schema.height(e,t)),o=this._styleVal(this.schema.rx,e,t),a=this._styleVal(this.schema.ry,e,t);return{type:"rect",x:-n/2,y:-i/2,width:n,height:i,...null==o?{}:{rx:Number(o)},...null==a?{}:{ry:Number(a)},...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(e,t){return{width:this.schema.width(e,t),height:this.schema.height(e,t)}}_applyPosition(e){e.attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>-this.schema.width(e,t)/2).attr("y",(e,t)=>-this.schema.height(e,t)/2)}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("rect"),ee(this,qo),this._name="Rect",this.schema.labelBounds=(e,t,n)=>({width:n.width,height:n.height,x:-n.width/2,y:-n.height/2})}}const Ko=[{key:"r",coerce:"accessor",default:T("r")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0}];class Uo extends jo{_applyPosition(e){e.attr("r",(e,t)=>this.schema.r(e,t)).attr("x",(e,t)=>-this.schema.r(e,t)/2).attr("y",(e,t)=>-this.schema.r(e,t)/2)}_sceneGeometry(e,t){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(e,t)),...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(e,t){return{r:this.schema.r(e,t)}}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("circle"),ee(this,Ko),this._name="Circle",this.schema.labelBounds=(e,t,n)=>({width:2*n.r,height:2*n.r,x:-n.r,y:-n.r,shape:"circle"}),this.schema.labelConfig=n.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}const Xo=new Map([["Circle",Uo],["Rect",Yo]]);const Qo=e=>Xo.has(e);function Zo(e){return Array.isArray(e)?e:[e,e]}function Jo(e,t){const n=h.quantile(e,.25),i=h.quantile(e,.5),o=h.quantile(e,.75),a=i=>function(e,t,n,i,o){const a=h.min(e),r=h.max(e);if("tukey"===t){const e=n?o+1.5*(o-i):i-1.5*(o-i);return n?e>r?r:e:e<a?a:e}return"extent"===t?n?r:a:"number"==typeof t?h.quantile(e,t):void 0}(e,t[i],i,n,o);return{first:n,median:i,third:o,lowerLimit:a(0),upperLimit:a(1)}}const ea=["fill","stroke","backgroundImage","backgroundImageFit","texture","textureDefault"],ta={fill:"white",stroke:"black"};function na(e,t){return fe(e)?de(t):t}function ia(e){return"function"==typeof e?t=>e(t.data,t.i):e}function oa(e){const t="string"==typeof e?l.color(e):null;return t&&t.opacity?r.colorContrast(t.formatRgb(),{dark:"black",light:"white"}):"black"}function aa(e){const t=new Set(e),n=new Set;return e.map(e=>{if(!n.has(e))return n.add(e),e;let i=1;for(;t.has(`${e}~${i}`);)i++;const o=`${e}~${i}`;return t.add(o),o})}const ra=["boxMin","boxQ1","boxMedian","boxQ3","boxMax"];function sa(e){if(null!=e&&!1!==e)return"function"==typeof e?e:"string"==typeof e?Be(e):N(e)}function ca(e){return ra.some(t=>"function"==typeof e[t])}function la(e,t){const n=function(e){return ca(e)?ra.filter(t=>"function"!=typeof e[t]):[]}(t);n.length&&pe(`${e} draws precomputed boxes only when ${ra.join(", ")} are all set; missing ${n.join(", ")}.`)}const ha=e=>"number"==typeof e&&Number.isFinite(e),ua=e=>"number"==typeof e||e instanceof Date?+e:NaN;function da(e,t,n){const i="function"==typeof e.boxOutliers?e.boxOutliers(t,n):void 0;return(Array.isArray(i)?i:[i]).map(ua).filter(ha)}function fa(e,t,n){const i=[];for(const o of ra){const a=e[o];if("function"!=typeof a)return null;const r=ua(a(t,n));if(!ha(r))return null;i.push(r)}i.sort((e,t)=>e-t);const o=da(e,t,n),[a,r,s,c,l]=i;return{min:a,q1:r,median:s,q3:c,max:l,outliers:o}}function ma(e,t,n){const i=e,o=e.first,a=e.third-o;"vertical"===e.orient?(i.height=a,i.width=n,i.x=t,i.y=o+a/2):"horizontal"===e.orient&&(i.height=n,i.width=a,i.x=o+a/2,i.y=t)}function pa(e,t,n){const i=e=>{const o={...e},a=function(e,t){const n=new Set;for(let i=e;i&&"object"==typeof i&&!n.has(i);i=i.data){const e=t.get(i);if(e)return e;n.add(i)}}(e.datum,n);return a&&(o.owners=[...e.owners??[],{shapeType:t,...a}]),"group"===e.type&&(o.children=e.children.map(i)),o};return e.map(i)}const ga=[{key:"curve",coerce:"const",default:N("linear")},{key:"defined",coerce:"identity",default:e=>e}];class ya extends jo{_dataFilter(e){const t=h.groups(e,this.schema.id).map(([t,n])=>{const i={key:t,values:n};i.data=o.merge(i.values),i.i=e.indexOf(i.values[0]);const a=h.extent(i.values,this.schema.x);i.xR=a,i.width=a[1]-a[0],i.x=a[0]+i.width/2;const r=h.extent(i.values,this.schema.y);return i.yR=r,i.height=r[1]-r[0],i.y=r[0]+i.height/2,i.nested=!0,i.translate=[i.x,i.y],i.__d3plusShape__=!0,i});return t.key=e=>e.key,t}_sceneGeometry(e){const t=Number(e.x),n=Number(e.y),i=String(this.schema.curve.bind(this)(this.config())),o=L[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`];return{type:"path",d:L.line().curve(o).defined(this.schema.defined).x((e,n)=>this.schema.x(e,n)-t).y((e,t)=>this.schema.y(e,t)-n)(e.values)||""}}_aes(e,t){return{points:e.values.map(e=>[this.schema.x(e,t),this.schema.y(e,t)])}}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,ga),this._name="Line",this._path=L.line(),this.schema.fill=N("none"),this.schema.stroke=N("black"),this.schema.strokeWidth=N(1),this.schema.hitArea=N({d:e=>this._path(e.values),fill:"none","stroke-width":10,transform:null})}}const xa={Circle:Uo,Rect:Yo},ba=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:T("endpoint","Rect")},{key:"length",coerce:"const",default:T("length",25)},{key:"orient",coerce:"const",default:T("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:T("x",0)},{key:"y",coerce:"const",default:T("y",0)}];class _a extends $e{render(e){const i="compute"===this.schema.renderMode;void 0!==this._select||i||this.select(t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const o=e=>i?null:n.elem(e,{parent:this._select}).node();this._owned=new Map(this._data.map((e,t)=>[e,{datum:e,index:t}]));const a=aa(this._data.map((e,t)=>`${e.id??t}`)),r=function(e,t){const n=[];return e._data.forEach((i,o)=>{const a=e.schema.orient(i,o),r=e.schema.x(i,o),s=e.schema.y(i,o);let c=r;"left"===a?c-=e.schema.length(i,o):"right"===a&&(c+=e.schema.length(i,o));let l=s;"top"===a?l-=e.schema.length(i,o):"bottom"===a&&(l+=e.schema.length(i,o)),n.push({__d3plus__:!0,data:i,i:o,id:t[o],x:r,y:s}),n.push({__d3plus__:!0,data:i,i:o,id:t[o],x:c,y:l})}),n}(this,a);this._line=(new ya).data(r).renderMode(i?"compute":"full").select(o("g.d3plus-Whisker")).config(Ae.bind(this)(this.schema.lineConfig,"shape")).render();const s=function(e,t){return e._data.map((n,i)=>{const o={__d3plus__:!0};o.data=n,o.i=i,o.id=`${t[i]}-end`,o.endpoint=e.schema.endpoint(n,i),o.length=e.schema.length(n,i),o.orient=e.schema.orient(n,i);let a=e.schema.x(n,i);"left"===o.orient?a-=o.length:"right"===o.orient&&(a+=o.length);let r=e.schema.y(n,i);return"top"===o.orient?r-=o.length:"bottom"===o.orient&&(r+=o.length),o.x=a,o.y=r,o})}(this,a);return this._whiskerEndpoint=[],h.groups(s,e=>e.endpoint).forEach(([e,t])=>{this._whiskerEndpoint.push((new xa[e]).data(t).renderMode(i?"compute":"full").select(o(`g.d3plus-Whisker-Endpoint-${e}`)).config(de({height:e=>"top"===e.orient||"bottom"===e.orient?5:20,width:e=>"top"===e.orient||"bottom"===e.orient?20:5})).config(Ae.bind(this)(this.schema.endpointConfig,"shape",e)).render())}),e&&setTimeout(e,this.schema.duration+100),this}toScene(){const e=[],t=t=>{const n=t&&"function"==typeof t.toScene?t.toScene():null;n&&Array.isArray(n.children)&&e.push(...n.children)};if(t(this._line),Array.isArray(this._whiskerEndpoint))for(const e of this._whiskerEndpoint)t(e);return{type:"group",key:"d3plus-Whisker-scene",children:pa(e,"Whisker",this._owned)}}active(e){this._line&&this._line.active(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.active(e))}data(e){return arguments.length?(this._data=e,this):this._data}endpointConfig(e){return arguments.length?(this.schema.endpointConfig=Y(this,"endpointConfig",e),this):this.schema.endpointConfig}hover(e){this._line&&this._line.hover(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.hover(e))}lineConfig(e){return arguments.length?(this.schema.lineConfig=Y(this,"lineConfig",e),this):this.schema.lineConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,ba),this.schema.endpointConfig={Circle:{r:T("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[],this._owned=new Map}}K(_a.prototype,"endpointConfig","lineConfig");const ka=e=>"function"==typeof e?e:T(e),va=[{key:"backgroundImage",coerce:"const"},{key:"backgroundImageFit",coerce:"const"},{key:"boxMax",coerce:sa},{key:"boxMedian",coerce:sa},{key:"boxMin",coerce:sa},{key:"boxOutliers",coerce:sa},{key:"boxQ1",coerce:sa},{key:"boxQ3",coerce:sa},{key:"fill",coerce:"const"},{key:"id",coerce:"accessor"},{key:"orient",coerce:"const",default:T("orient","vertical")},{key:"outlier",coerce:"const",default:T("outlier","Circle")},{key:"rectWidth",coerce:"const",default:N(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"stroke",coerce:"const"},{key:"texture",coerce:"const"},{key:"textureDefault",coerce:"identity"},{key:"whiskerMode",coerce:Zo,default:["tukey","tukey"]},{key:"x",coerce:ka,default:T("x",250)},{key:"y",coerce:ka,default:T("y",250)}];function wa(e,[t,n],i,a){const r={key:t,values:n};r.data=o.merge(r.values),r.i=e._data.indexOf(r.values[0]),r.id=i,r.orient=e.schema.orient(r.data,r.i);const s=r.values.map("vertical"===r.orient?e.schema.y:e.schema.x);s.sort((e,t)=>e-t);const{first:c,median:l,third:h,lowerLimit:u,upperLimit:d}=Jo(s,e.schema.whiskerMode);return Object.assign(r,{first:c,median:l,third:h}),void 0!==u&&Object.assign(r,{lowerLimit:u}),void 0!==d&&Object.assign(r,{upperLimit:d}),ma(r,t,e.schema.rectWidth(r.data,r.i)),function(e,t,n){t.values.forEach((i,o)=>{const a="vertical"===t.orient?e.schema.y(i,o):e.schema.x(i,o);if(a<t.lowerLimit||a>t.upperLimit){const r=e.schema.outlier(i,o);if(!Qo(r))return;const s={__d3plus__:!0};s.data=i,s.i=o,s.id=`${t.id}-outlier-${o}`,s.outlier=r,"vertical"===t.orient?(s.x=t.x,s.y=a,n.push(s)):"horizontal"===t.orient&&(s.y=t.y,s.x=a,n.push(s))}})}(e,r,a),r.__d3plus__=!0,r}class Sa extends $e{render(){const e="compute"===this.schema.renderMode;void 0!==this._select||e||this.select(t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const i=t=>e?null:n.elem(t,{parent:this._select}).node(),o=[],a=ca(this.schema)?function(e,t){const{schema:n}=e;la("Box",n);const i=e._data.map((e,t)=>({row:e,i:t,stats:fa(n,e,t)})).filter(e=>e.stats),o=n.orient,a=i.map(({row:e,i:t})=>"vertical"===o(e,t)?n.x(e,t):n.y(e,t)),r=aa(i.map(({row:e,i:t},i)=>`${(n.id?n.id(e,t):void 0)??a[i]}`));return e._owned=new Map,i.map(({row:i,i:s,stats:c},l)=>{const h=c,u={__d3plus__:!0,key:a[l],values:[i],data:i,i:s,id:r[l],orient:o(i,s),first:h.q1,median:h.median,third:h.q3,lowerLimit:h.min,upperLimit:h.max};ma(u,a[l],n.rectWidth(i,s));const d=t.length,f=n.outlier(i,s);Qo(f)&&h.outliers.forEach((e,n)=>t.push(function(e,t,n,i){const o="vertical"===e.orient;return{__d3plus__:!0,data:e.data,i:e.i,id:`${e.id}-outlier-${i}`,outlier:t,x:o?e.x:n,y:o?n:e.y}}(u,f,e,n)));const m={datum:u,index:l};for(const n of[u,...t.slice(d)])e._owned.set(n,m);return u})}(this,o):function(e,t){const n=h.groups(e._data,(t,n)=>"vertical"===e.schema.orient(t,n)?e.schema.x(t,n):e.schema.y(t,n)),i=aa(n.map(([t,n])=>{const i=n[0];return`${(e.schema.id?e.schema.id(i,e._data.indexOf(i)):void 0)??t}`}));return e._owned=new Map,n.map((n,o)=>{const a=t.length,r=wa(e,n,i[o],t),s={datum:r,index:o};for(const n of[r,...t.slice(a)])e._owned.set(n,s);return r})}(this,o),r=function(e,t){const n={...ta};for(const i of ea){const o=e[i];void 0===o||i in t||(n[i]=ia(o))}return na(t,{...n,...t})}(this.schema,Ae.bind(this)(this.schema.rectConfig,"shape"));this._box=(new Yo).data(a).id(e=>`${e.id}-box`).x(e=>e.x).y(e=>e.y).renderMode(e?"compute":"full").select(i("g.d3plus-Box")).config(r).render(),this._median=(new Yo).data(a).id(e=>`${e.id}-median`).x(e=>"vertical"===e.orient?e.x:e.median).y(e=>"vertical"===e.orient?e.median:e.y).height(e=>"vertical"===e.orient?1:e.height).width(e=>"vertical"===e.orient?e.width:1).renderMode(e?"compute":"full").select(i("g.d3plus-Box-Median")).config(function(e,t){if("fill"in t)return t;const n="function"==typeof e?(t,n)=>oa(e(t,n)):()=>oa(e);return na(t,{...t,fill:n})}(r.fill,Ae.bind(this)(this.schema.medianConfig,"shape"))).render();const s=function(e){const t=[];return e.forEach((e,n)=>{const i=e.x,o=e.y,a=e.first-e.lowerLimit,r=e.upperLimit-e.third;if("vertical"===e.orient){const s=o-e.height/2,c=o+e.height/2;t.push({__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-top`,x:i,y:s,length:a,orient:"top"},{__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-bottom`,x:i,y:c,length:r,orient:"bottom"})}else if("horizontal"===e.orient){const s=i+e.width/2,c=i-e.width/2;t.push({__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-right`,x:s,y:o,length:r,orient:"right"},{__d3plus__:!0,data:e,i:n,id:`${e.id}-whisker-left`,x:c,y:o,length:a,orient:"left"})}}),t}(a);return this._whisker=(new _a).data(s).renderMode(e?"compute":"full").select(i("g.d3plus-Box-Whisker")).config(Ae.bind(this)(this.schema.whiskerConfig,"shape")).render(),this._whiskerEndpoint=[],h.groups(o,e=>e.outlier).forEach(([t,n])=>{const o=function(e){return Xo.get(e)}(t);var a,r;this._whiskerEndpoint.push((new o).data(n).renderMode(e?"compute":"full").select(i(`g.d3plus-Box-Outlier-${t}`)).config((a=this.schema,r=Ae.bind(this)(this.schema.outlierConfig,"shape",t),void 0===a.fill||"fill"in r?r:na(r,{...r,fill:ia(a.fill)}))).render())}),this}toScene(){const e=[],t=t=>{const n=t&&"function"==typeof t.toScene?t.toScene():null;n&&Array.isArray(n.children)&&e.push(...n.children)};if(t(this._box),t(this._median),t(this._whisker),Array.isArray(this._whiskerEndpoint))for(const e of this._whiskerEndpoint)t(e);return{type:"group",key:"d3plus-Box-scene",children:pa(e,"Box",this._owned)}}active(e){this._box&&this._box.active(e),this._median&&this._median.active(e),this._whisker&&this._whisker.active(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.active(e))}data(e){return arguments.length?(this._data=e,this):this._data}hover(e){this._box&&this._box.hover(e),this._median&&this._median.hover(e),this._whisker&&this._whisker.hover(e),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(t=>t.hover(e))}medianConfig(e){return arguments.length?(this.schema.medianConfig=Y(this,"medianConfig",e),this):this.schema.medianConfig}outlierConfig(e){return arguments.length?(this.schema.outlierConfig=Y(this,"outlierConfig",e),this):this.schema.outlierConfig}rectConfig(e){return arguments.length?(this.schema.rectConfig=Y(this,"rectConfig",e),this):this.schema.rectConfig}select(e){return arguments.length?(this._select=t.select(e),this):this._select}whiskerConfig(e){return arguments.length?(this.schema.whiskerConfig=Y(this,"whiskerConfig",e),this):this.schema.whiskerConfig}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super(),ee(this,va),this.schema.medianConfig={},this.schema.outlierConfig={Circle:{r:T("r",5)},Rect:{height:(e,t)=>"vertical"===this.schema.orient(e,t)?5:20,width:(e,t)=>"vertical"===this.schema.orient(e,t)?20:5}},this.schema.rectConfig={strokeWidth:N(1)},this.schema.whiskerConfig={},this._whiskerEndpoint=[],this._owned=new Map}}K(Sa.prototype,"medianConfig","outlierConfig","rectConfig","whiskerConfig");const Ca=[{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"accessor",default:T("height")},{key:"id",coerce:"identity",default:T("id")},{key:"opacity",coerce:"const",default:N(1)},{key:"pointerEvents",coerce:"const",default:N("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"url",coerce:"identity",default:T("url")},{key:"width",coerce:"accessor",default:T("width")},{key:"x",coerce:"const",default:T("x",0)},{key:"y",coerce:"const",default:T("y",0)}];class Ma{config(e){if(!arguments.length)return{...this.schema,data:this._data,select:this._select};const t=e;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("function"==typeof this[e]?this[e](t[e]):this.schema[e]=t[e]);return this}render(e){if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;void 0===this._select&&this.select(t.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const n=this._select.selectAll(".d3plus-Image").data(this._data,this.schema.id),i=n.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",(e,t)=>this.schema.x(e,t)+this.schema.width(e,t)/2).attr("y",(e,t)=>this.schema.y(e,t)+this.schema.height(e,t)/2),o=u.transition().duration(this.schema.duration),a=this;return i.merge(n).attr("xlink:href",this.schema.url).style("pointer-events",this.schema.pointerEvents).transition(o).attr("opacity",this.schema.opacity).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).each(function(e,n){const i=t.select(this),o=a.schema.url(e,n);if(!(0===o.indexOf("http://")||0===o.indexOf("https://"))||0===o.indexOf(window.location.hostname)){const e=new window.Image;e.src=o,e.crossOrigin="Anonymous",e.onload=function(){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;t.getContext("2d").drawImage(e,0,0),i.attr("xlink:href",t.toDataURL("image/png"))}}}),n.exit().transition(o).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).attr("opacity",0).remove(),e&&setTimeout(e,this.schema.duration+100),this}data(e){return arguments.length?(this._data=e,this):this._data}toScene(){return{type:"group",key:"d3plus-Image",children:(this._data||[]).map((e,t)=>({type:"image",key:`${this.schema.id(e,t)}`,x:this.schema.x(e,t),y:this.schema.y(e,t),width:this.schema.width(e,t),height:this.schema.height(e,t),href:this.schema.url(e,t),paint:{opacity:this.schema.opacity(e,t)},datum:e,index:t}))}}select(e){return arguments.length?(this._select=t.select(e),this):this._select}constructor(){ee(this,Ca)}}const $a=[{key:"d",coerce:"const",default:T("path")}];class Aa extends jo{_sceneGeometry(e,t){return{type:"path",d:String(this.schema.d(e,t))}}_aes(e,t){return{points:f.path2polygon(this.schema.d(e,t))}}config(e){return arguments.length?(super.config(e),this):super.config()}constructor(){super("path"),ee(this,$a),this._name="Path",this.schema.labelBounds=(e,t,n)=>{const i=this.schema.labelConfig.rotate,o=f.largestRect(n.points,{angle:i?i(e,t):0});return!!o&&{angle:o.angle,width:o.width,height:o.height,x:o.cx-o.width/2,y:o.cy-o.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}const za=E;let Da;function Fa(e,t,i={}){const o=`${e}.${i.method??"shapeConfig"}()`,a=function(){if(!Da){Da={};for(const[e,t]of Object.entries(za))Da[e]=new t}return Da}(),r=i.shapes??Object.fromEntries(Object.keys(a).map(e=>[e,e])),s=i.extra??{},c=Object.values(r).map(e=>a[e]);for(const e of Object.keys(t)){const i=r[e]&&a[r[e]];if(i){if(!n.isObject(t[e]))continue;for(const n of Object.keys(t[e]))n in i||s[e]?.includes(n)||me(o,`${e}.${n}`)}else s[""]?.includes(e)||c.some(t=>e in t)||me(o,e)}}class Ba extends $e{active(e){return arguments.length?(this._active=e,1!==this.schema.shapeConfig.activeOpacity&&(this.schema.legend&&this._legendClass.active(e),this._sceneRenderer&&this._scheduleSceneRepaint()),dt(this,"active",e),this):this._active}data(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"data"),this._hidden=[],this._solo=[],this._userData&&JSON.stringify(e)!==JSON.stringify(this._userData)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userData=e,this._userDataFormat=t,this._dataSignature=void 0,Ct(this),this):this._data}facet(e){return arguments.length?(this.schema.facet=Ee(e),this):this.schema.facet}facetConfig(e){return arguments.length?(this.schema.facetConfig=Y(this,"facetConfig",e),this):this.schema.facetConfig}fontFamily(e){if(arguments.length){const t={fontFamily:e},n={titleConfig:t,shapeConfig:{labelConfig:t}};return this.shapeConfig({labelConfig:t}),this.colorScaleConfig({axisConfig:n}),["axis","column","row","timeline","x","y","x2","y2"].forEach(e=>{const t=`${e}Config`;this[t]&&this[t](n)}),["back","title","total","subtitle"].forEach(e=>{const n=`${e}Config`;this[n]&&this[n](t)}),this.tooltipConfig({tooltipStyle:{"font-family":a.fontFamilyStringify(e)}}),this.schema.fontFamily=e,this}return this.schema.fontFamily}groupBy(e){if(!arguments.length)return this.schema.groupBy;this._groupByRaw=e;const t=e instanceof Array?e:[e];return this.schema.groupBy=t.map(e=>"function"==typeof e?e:(this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const n=o.unique(e.map(t));return 1===n.length?n[0]:n}),Be(e))),this}hover(e){if(!arguments.length)return this._hover;let t=this._hover=e;if(1!==this.schema.shapeConfig.hoverOpacity&&void 0!==e){if("function"==typeof e){const n=[...this._filteredData??[],...this._legendClass.data()??[]].filter(e),i=new Set;n.map(this._ids).forEach(e=>{for(let t=1;t<=e.length;t++)i.add(JSON.stringify(e.slice(0,t)))}),i.size&&(t=(e,t)=>{const n=this._ids(e,t),o=Ye(e);return i.has(JSON.stringify(void 0===o?n:n.slice(0,o+1)))})}this.schema.legend&&this._legendClass.hover(t)}return this._sceneRenderer&&void 0!==e&&(gt(this)||this._hoverBucket)&&this._scheduleSceneRepaint(),dt(this,"hover",e),this}highlight(e){return arguments.length?(this._highlight=e,this._sceneRenderer&&this._scheduleSceneRepaint(),dt(this,"highlight",e),this):this._highlight}select(e){return arguments.length?(this._select=t.select(e),this):this._select}shapeConfig(e){return arguments.length?(W(e)&&Fa(this.constructor.name,e),this.schema.shapeConfig=Y(this,"shapeConfig",e),this):this.schema.shapeConfig}threshold(e){return arguments.length?("function"==typeof e?this.schema.threshold=e:isFinite(e)&&!isNaN(e)&&(this.schema.threshold=N(1*e)),this):this.schema.threshold}thresholdKey(e){return arguments.length?(this.schema.thresholdKey="function"==typeof e?e:Be(e),this):this.schema.thresholdKey}time(e){return arguments.length?("function"==typeof e?this.schema.time=e:e?(this.schema.time=Be(e),this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const n=o.unique(e.map(t));return 1===n.length?n[0]:n}),this._userTime&&JSON.stringify(e)!==JSON.stringify(this._userTime)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userTime=e):(this.schema.time=void 0,this._userTime=void 0,this.schema.timeFilter=!1,this._timelineSelection=!1),this):this.schema.time}timelineDefault(e){return arguments.length?(e instanceof Array||(e=[e,e]),this.schema.timelineDefault=e.map(e=>n.date(e)).filter(e=>!1!==e),this):this.schema.timelineDefault}total(e){return arguments.length?(this.schema.total="function"==typeof e?e:!!e&&Be(e),this):this.schema.total}}function La(e){const t=e._colorScaleClass,n=e.schema.colorScale;if(!t||"function"!=typeof t._colorScale||!n)return null;const i=t._colorScale;return{rows:Array.isArray(t._data)?t._data:[],colorOf:(e,t)=>{let o=e;for(;o&&o.__d3plus__&&o.data;)o=o.data;return o&&o._isColorScaleBucket?o.color:i(n(o,t))}}}function Pa(e,t,n){const i=La(e);if(!i)return null;let o=0,a=0;return i.rows.forEach((e,r)=>{const s=n(e,r);Number.isFinite(s)&&(o+=s,i.colorOf(e,r)===t&&(a+=s))}),o?a/o:null}function Ra(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t&&t._isColorScaleBucket?t:null}function Ea(e,t){const n=e._colorScaleClass;if(!n||!e.schema.colorScale)return;let i=!1;if("mousemove"===t.type||"mouseenter"===t.type){if(e._transitionEndsAt&&Date.now()<e._transitionEndsAt)return;if(!1===n.hoverMark())return;i=function(e,t){const n=e.schema.colorScale;if(!t||"function"!=typeof n)return null;if(t.interactionGroup)return null;if(Ra(t.datum))return null;let i=t.datum,o="number"==typeof t.index?t.index:0;for(;i&&i.__d3plus__&&i.data;)i=i.data,"number"==typeof i.i&&(o=i.i);if(!i||"object"!=typeof i)return null;const a=n(i,o);if(null==a||""===a)return null;if("number"!=typeof a&&"string"!=typeof a)return null;const r=+a;return Number.isFinite(r)?r:null}(e,t.pick?.node)??!1}else if("mouseleave"!==t.type)return;(n.hover()??!1)!==i&&(n.hover(i),e._scheduleSceneRepaint())}K(Ba.prototype,"facetConfig","shapeConfig");function Na(e,t,n){const i={...e.paint??{}};let o="string"==typeof i.fill?i.fill:void 0;if(o&&"transparent"!==o&&"none"!==o||(o="string"==typeof i.stroke?i.stroke:void 0),!o||"transparent"===o||"none"===o)return e;const a=l.color(o);a&&(i.stroke=a.darker(t).formatHex());const r="number"==typeof i.strokeWidth&&i.strokeWidth?i.strokeWidth:1;return i.strokeWidth=r*n,{...e,paint:i}}function Ta(e){const t="function"==typeof e._hover?e._hover:null,n="function"==typeof e._active?e._active:null,i="function"==typeof e._highlight?e._highlight:null;if(!t&&!n&&!i)return null;const o=e.schema.shapeConfig??{};let a="number"==typeof o.hoverOpacity?o.hoverOpacity:.5;const r="number"==typeof o.activeOpacity?o.activeOpacity:.25,s=!t&&!n;return t&&e._hoverBucket&&a>=1&&(a=.5),{predicate:t??n??i,dimOpacity:t?a:n?r:1,isHover:!!t,gray:s,kind:t?"hover":n?"active":"highlight",activePredicate:n}}function Oa(e,t){const n=function(e){const t=e._colorScaleClass;if(!t||"function"==typeof e._hover)return null;const n=t.hover();if("number"!=typeof n||!Number.isFinite(n)||!1===t.hoverMark()||t._barGeometry||"function"!=typeof t._colorScale)return null;const i=e.schema.shapeConfig,o=i?.hoverOpacity;return{color:t._colorScale(n),dimOpacity:"number"==typeof o&&o<1?o:.5}}(t);let i,o;if(n)i=new Set([n.color]),o=n.dimOpacity;else{const n=Ta(t);if(!n)return e;i=function(e,t){const n=La(e);if(!n)return null;const i=new Set;return n.rows.forEach((e,o)=>{t(e,o)&&i.add(n.colorOf(e,o))}),i}(t,n.predicate),o=n.dimOpacity}if(!i)return e;const a=e=>{let t=e,n=e.datum;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(n&&n._isColorScaleBucket&&!i.has(n.color)){const n=e.paint&&"number"==typeof e.paint.opacity?e.paint.opacity:1;t={...e,paint:{...e.paint??{},opacity:n*o}}}const r=t.children;return r&&r.length&&(t={...t,children:r.map(a)}),t};return e.map(a)}function Wa(e,t,n){let i=t;if(e(i,n))return!0;for(;i&&i.__d3plus__&&i.data;)if(i=i.data,e(i,n))return!0;return!1}function ja(e,t){const n=e.datum;if(n){const i=n.data??n,o="number"==typeof e.index?e.index:"number"==typeof i.i?i.i:0;return Wa(t,i,o)}const i=e.interactionPoints;return i&&i.length?i.some((e,n)=>{const i=e.datum;return Wa(t,i,"number"==typeof i.i?i.i:n)}):null}function Ha(e,t){const n=Ta(t);if(!n)return e;const{predicate:i,dimOpacity:o,isHover:a,gray:s,kind:c,activePredicate:l}=n,h=e=>{const t=e.interactionGroup;if("axis"===t||"timeline"===t)return e;let n=e;const u=ja(e,i);if(null!==u)if(u){if("highlight"!==c&&Qe.has(e.type)){n="active"===c||!!l&&!0===ja(e,l)?Na(e,1,3):Na(e,.5,2)}a&&(n={...n,z:1e6})}else{const t=e.paint??{};if(s){const i={...t};"string"==typeof t.fill&&(i.fill=r.colorGrayscale(t.fill)),"string"==typeof t.stroke&&(i.stroke=r.colorGrayscale(t.stroke)),n={...e,paint:i}}else{const i="number"==typeof t.opacity?t.opacity:1;n={...e,paint:{...t,opacity:i*o}}}}const d=n.children;return d&&d.length&&(n={...n,children:d.map(h)}),n};return e.map(h)}function Ia(e){const t=e._select&&"function"==typeof e._select.node?e._select.node():null;return t?n.backgroundColor(t):"rgb(255, 255, 255)"}function Ga(e){return r.colorContrast(Ia(e),e.schema.colorDefaults)}const Va=["sizeLegend","legend","colorScale"];function qa(e){return{padding:10,margin:6,fillOpacity:.85,strokeWidth:1,rx:4,...e.schema.legendInsetConfig||{}}}function Ya(e,t){return Boolean(e._insetPending&&e._insetPending.has(t))}function Ka(e,t){const n=e._insetPlacement;return n&&n.key===t?n:null}function Ua(e,t){return Ka(e,t)?.orient??"column"}function Xa(e,t){return"column"===e?{width:.4*t.width,height:.6*t.height}:{width:.6*t.width,height:.4*t.height}}function Qa(e,t){const n=qa(e),i=n.fill??Ia(e);return{type:"rect",key:"viz-inset-background",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.rx,ry:n.rx,paint:{fill:i,fillOpacity:n.fillOpacity,stroke:n.stroke??r.colorContrast(i,e.schema.colorDefaults),strokeOpacity:n.stroke?1:.15,strokeWidth:n.strokeWidth}}}function Za(e,t,n,i){const o=Ja(e,t,i);return o?[Qa(e,Ka(e,t)),{...n,transform:o}]:[n]}function Ja(e,t,n){const i=Ka(e,t);if(!i)return null;const{margin:o}=qa(e);return{x:i.x+o-(n.x??0),y:i.y+o-(n.y??0)}}function er(e){let t=e._select?.node()?.parentNode??null;for(;t&&!(t instanceof HTMLElement);)t=t.parentNode;return t instanceof HTMLElement?t:null}function tr(e,n){const{kind:i,width:o,height:a,duration:r,ocean:s}=n,c=`d3plus-${"generic"===i?"zoom":i}`,l="geomap"===i&&s||"transparent",h=function(e,n){const i="geomap"!==n||"canvas"!==e._renderer||e._ssr?null:er(e);if(!i)return e._select;i.style.isolation="isolate";const o=t.select(i).selectAll(":scope > svg.d3plus-geomap-underlay").data([0]);return o.enter().insert("svg",":first-child").attr("class","d3plus-geomap-underlay").style("position","absolute").style("top","0").style("left","0").style("z-index","-1").style("overflow","hidden").style("pointer-events","none").merge(o).attr("width",e.schema.width).attr("height",e.schema.height)}(e,i),u=e._container&&e._container.classed(c)?e._container.node():null;u&&u.parentNode!==h.node()&&h.node().insertBefore(u,h.node().firstChild),h!==e._select?e._select.selectAll(":scope > svg.d3plus-geomap").remove():function(e){const t=er(e);t&&t.querySelector(":scope > svg.d3plus-geomap-underlay")?.remove()}(e);let d=h.selectAll(`:scope > svg.${c}`).data([0]);if(d=d.enter().insert("svg",":first-child").attr("class",c).attr("opacity",0).attr("width",o).attr("height",a).attr("x",e._margin.left).attr("y",e._margin.top).style("background-color",l).merge(d),e._container=d,d.transition().duration(r).attr("opacity",1).attr("width",o).attr("height",a).attr("x",e._margin.left).attr("y",e._margin.top),"generic"===i){let t=d.selectAll(`g.${c}-zoomGroup`).data([0]);t=t.enter().append("g").attr("class",`${c}-zoomGroup`).merge(t),e._zoomGroup=t}else if("network"===i){const t=d.selectAll(`rect.${c}-hitArea`).data([0]);t.enter().append("rect").attr("class",`${c}-hitArea`).merge(t).attr("width",o).attr("height",a).attr("fill","transparent").on("click",()=>{e._focus&&(e.active(!1),e._focus=void 0,e._zoomToBounds(null))});let n=d.selectAll(`g.${c}-zoomGroup`).data([0]);n=n.enter().append("g").attr("class",`${c}-zoomGroup`).merge(n),e._zoomGroup=n}else{const t=d.selectAll(`rect.${c}-ocean`).data([0]);t.enter().append("rect").attr("class",`${c}-ocean`).merge(t).attr("width",o).attr("height",a).attr("fill",s||"transparent");let n=d.selectAll(`g.${c}-tileGroup`).data([0]);n=n.enter().append("g").attr("class",`${c}-tileGroup`).merge(n),e._tileGroup=n;let i=d.selectAll(`g.${c}-zoomGroup`).data([0]);i=i.enter().append("g").attr("class",`${c}-zoomGroup`).merge(i),e._zoomGroup=i}}function nr(e){const t=e.interactionPoints;if(t&&t.length>1){const e=[];for(let n=1;n<t.length;n++)e.push([Math.abs(t[n].x-t[n-1].x),Math.abs(t[n].y-t[n-1].y)]);return e}const n=function(e){switch(e.type){case"rect":case"image":return[e.width,e.height];case"circle":return[2*e.r,2*e.r];case"path":{const t=f.pathBounds(e.d);return[t.width,t.height]}case"line":{const t=f.pathBounds(i.linePath(e));return[t.width,t.height]}case"area":{const t=f.pathBounds(i.areaPath(e));return[t.width,t.height]}default:return null}}(e);return n?[n]:[]}const ir=new WeakSet;function or(e){return ir.add(e),e}function ar(e){return"function"==typeof e&&ir.has(e)}const rr=e=>e&&"function"!=typeof e?Be(e):e,sr={aggs:{merge:!0},ariaHidden:{},attribution:{},attributionIcon:{},attributionStyle:{merge:!0},backControlClassName:{},backControlStyle:{},cache:{},color:{coerce:rr},colorOrdinal:{default:!1},colorScale:{coerce:rr},colorScaleConfig:{merge:!0},colorScaleMaxSize:{},colorScalePadding:{coerce:"const"},colorScalePosition:{coerce:"const"},dataCutoff:{},dataPollingInterval:{onSet:e=>function(e){(e._dataPollStop||e._sceneRenderer)&&(e._queue?.some(e=>"data"===e[3])||At(e))}(e)},depth:{},detectResize:{},detectResizeDelay:{},detectVisible:{},detectVisibleInterval:{},detectVisibleUnload:{},discrete:{},duration:{},filter:{},height:{},hiddenColor:{coerce:"const"},hiddenOpacity:{coerce:"const"},label:{coerce:"const"},legend:{coerce:"const"},legendConfig:{merge:!0},legendFilterInvert:{coerce:"const"},legendInset:{},legendInsetConfig:{merge:!0},legendPadding:{coerce:"const"},legendPosition:{coerce:"const"},legendSort:{},legendTooltip:{merge:!0},link:{onSet:e=>ot(e)},loadingHTML:{coerce:"const"},loadingMessage:{},messageMask:{},messageStyle:{merge:!0},minimap:{},minimapClassName:{},minimapLabelStyle:{},minimapStyle:{},minimapViewportStyle:{},minimapViewportStyleActive:{},noDataHTML:{coerce:"const"},noDataMessage:{},saveControl:{},saveControlClassName:{},saveControlConfig:{merge:!0},saveControlMenuClassName:{},saveControlMenuItemStyle:{},saveControlMenuItemStyleHover:{},saveControlMenuStyle:{},saveControlStyle:{},saveControlStyleActive:{},saveControlStyleHover:{},scrollContainer:{},search:{},searchAccessor:{},searchControlClassName:{},searchControlStyle:{},searchControlStyleActive:{},searchControlStyleHover:{},shape:{coerce:"const"},sizeLegend:{coerce:"const"},sizeLegendConfig:{merge:!0},sizeLegendPosition:{},subtitle:{coerce:"const"},subtitleConfig:{merge:!0},subtitlePadding:{coerce:"const"},svgDesc:{},svgTitle:{},tableView:{},tableViewClassName:{},tableViewControlClassName:{},tableViewControlStyle:{},tableViewControlStyleActive:{},tableViewControlStyleHover:{},tableViewDownload:{},tableViewPageSize:{},tableViewSort:{},thresholdName:{coerce:"const"},timeFilter:{},timeline:{},timelineConfig:{merge:!0},timelinePadding:{coerce:"const"},title:{coerce:"const"},titleConfig:{merge:!0},titlePadding:{coerce:"const"},tooltip:{coerce:"const"},tooltipConfig:{merge:!0},totalConfig:{merge:!0},totalFormat:{},totalPadding:{coerce:"const"},width:{},zoom:{},zoomBrushHandleSize:{},zoomBrushHandleStyle:{},zoomBrushSelectionStyle:{},zoomControlClassName:{},zoomControlIcons:{},zoomControlStyle:{},zoomControlStyleActive:{},zoomControlStyleHover:{},zoomFactor:{},zoomMax:{},zoomPadding:{},zoomPan:{},zoomScroll:{}},cr=Object.entries(sr).map(([e,t])=>({key:e,...t}));function lr(e){if(!["string","number","boolean"].includes(typeof e))return;const t=`${e}`;return""===t||l.color(t)?void 0:t}function hr(e,t){if(e._legendCategories&&t){for(;t.__d3plus__&&t.data;)t=t.data;return e._legendCategories.get(t)}}function ur(e,t){return hr(this,e)??this._drawLabel(e,t,this._legendDepth)}function dr(e){return i.isFlipEligible(e)?"rect"===e.type?{x:e.x,y:e.y,width:e.width,height:e.height}:"circle"===e.type?{x:e.cx-e.r,y:e.cy-e.r,width:2*e.r,height:2*e.r}:"area"===e.type?f.pathBounds(i.areaPath(e)):"path"===e.type?f.pathBounds(e.d):null:null}function fr(e,t){for(const n of e){if(i.isFlipEligible(n)&&t(n))return n;if("group"===n.type&&n.children.length){const e=fr(n.children,t);if(e)return e}}}function mr(e){const t=e._pendingEnterOrigin;if(e._pendingEnterOrigin=void 0,t&&e._bodyRect){const n=e._bodyRect;e._resolvedEnterFrom={x:n.x+t.fx*n.width,y:n.y+t.fy*n.height,width:t.fw*n.width,height:t.fh*n.height},e._resolvedEnterFromBody=n,e._resolvedInstantExitKey=t.key}else e._resolvedEnterFrom=void 0,e._resolvedEnterFromBody=void 0,e._resolvedInstantExitKey=void 0;const n=e._pendingExitReunion;if(e._pendingExitReunion=void 0,n&&e._chartScene){const t=e.schema.groupBy?.[n.groupDepth],i=t?fr(e._chartScene,e=>{const i=function(e){const t=e;return t&&t.data?t.data:t}(e.datum);return void 0!==i&&t(i,function(e,t){const n=e;return n&&"number"==typeof n.i?n.i:t??0}(e.datum,e.index))===n.groupId}):void 0;e._resolvedExitTo=i?dr(i)??void 0:void 0,e._resolvedExitToBody=n.body,e._resolvedReunionEnterKey=i?.key,e._resolvedReunionEnterFrom=i?n.body:void 0,e._resolvedInstantExitAll=Boolean(i)}else e._resolvedExitTo=void 0,e._resolvedExitToBody=void 0,e._resolvedReunionEnterKey=void 0,e._resolvedReunionEnterFrom=void 0,e._resolvedInstantExitAll=void 0}function pr(e,t,n,i){i.stopPropagation();const o=Ye(e);if(void 0===o){if(this._drawDepth<this.schema.groupBy.length-1){this._select.style("cursor","auto");const n=this.schema.groupBy[this._drawDepth],i=n(e,t);this.hover(!1),this.schema.tooltip(e,t)&&this._tooltipClass.data([]).render();const o=this.schema.filter,a=this._lastScenePick?.node,r=a&&dr(a);if(r&&this._bodyRect&&this._bodyRect.width&&this._bodyRect.height){const e=this._bodyRect;this._pendingEnterOrigin={fx:(r.x-e.x)/e.width,fy:(r.y-e.y)/e.height,fw:r.width/e.width,fh:r.height/e.height,key:a.key,parentStartAngle:a.startAngle,parentEndAngle:a.endAngle}}this._history.push({depth:this.schema.depth,filter:o,groupId:i,groupDepth:this._drawDepth});const s=Array.isArray(i)?e=>i.includes(e):e=>e===i;this.config({depth:this._drawDepth+1,filter:(e,t)=>(!o||o(e,t))&&s(n(e,t))}).render()}}else!function(e,t,n){const i=e.schema.groupBy,o=Ke(i,t,n);if(!Xe(i,o,e._filteredData??[]))return;e._select.style("cursor","auto"),e.hover(!1),e._tooltipClass.data([]).render();const a=e.schema.filter;e._history.push({depth:e.schema.depth,filter:a}),e.config({filter:(e,t)=>(!a||a(e,t))&&Ue(i,o,e,t)}).render()}(this,e,o)}function gr(e,t,n,i){this._select.style("cursor","auto"),this.schema.tooltip(e,t)&&this._tooltipClass.data([]).render();let o=this._id(e,t);o instanceof Array||(o=[o]);const a=this._hidden.indexOf(o[0]),r=this._solo.indexOf(o[0]),s=h.merge(this._legendClass.data().map((e,t)=>{let n=this._id(e,t);return n instanceof Array||(n=[n]),n})).length,c=()=>{pt(this),this.render()};this.schema.legendFilterInvert.bind(this)(this)?i.shiftKey?a<0&&!this._solo.length?(this._hidden=this._hidden.concat(o),r>=0&&(this._solo=[]),this._hidden.length===s&&(this._hidden=[]),c()):r>=0&&(this._solo=[],this._hidden=[],c()):(r<0&&this._hidden.length<s-1?(this._solo=o,this._hidden=[]):(this._solo=[],this._hidden=[]),c()):i.shiftKey&&r<0?(this._solo=o,this._hidden=[],c()):i.shiftKey||(a>=0?this._hidden=this._hidden.filter(e=>!o.includes(e)):r>=0?(this._solo=[],this._hidden=[]):this._solo.length&&r<0?(this._solo=this._solo.concat(o),this._solo.length===s&&(this._solo=[])):(this._hidden=this._hidden.concat(o),this._hidden.length===s&&(this._hidden=[])),c())}function yr(e,t){if(this._sharedHoverActive&&"shared"===this._sharedHoverState?.mode)return;const n=Ra(e);if(n){const e=function(e,t){const n=La(e);return n?(e,i)=>n.colorOf(e,i)===t:null}(this,n.color);return void(e&&(this._hoverBucket=!0,this.hover(e)))}if(this._hoverBucket=!1,(!this._sharedHoverActive||!this._plotColumnHighlight)&&gt(this)){const n=Ye(e);if(void 0!==n){const t=this.schema.groupBy,i=Ke(t,e,n);return void this.hover((e,n)=>Ue(t,i,e,n))}let i=this._id(e,t);i instanceof Array||(i=[i]),this.hover((e,t)=>{let n=this._id(e,t);return n instanceof Array||(n=[n]),i.some(e=>n.includes(e))})}}function xr(e,t){if(!Array.isArray(e)&&!Array.isArray(t))return e===t;const n=new Set([].concat(e)),i=new Set([].concat(t));return n.size===i.size&&[...n].every(e=>i.has(e))}function br(e,t){setTimeout(()=>{let n=e;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(!n)return;let i=this._hoverDatum;for(;i&&i.__d3plus__&&i.data;)i=i.data;if(i&&xr(this._id(i),this._id(n)))return;if(this._sharedHoverActive)return;gt(this)&&this._hover&&!this._hover(e,t)||this.hover(!1);const o=this._tooltipClass.data();if(o.length&&this.schema.tooltip(e,t)){let e=o[0];for(;e.__d3plus__&&e.data;)e=e.data;xr(this._id(e),this._id(n))&&this._tooltipClass.data([]).render()}},0),this._select.style("cursor","auto")}const _r="__d3plusShare",kr="__d3plus",vr=new WeakSet;function wr(e,t){e[_r]=t,(void 0===e.share||vr.has(e))&&(e.share=t,vr.add(e))}function Sr(e){return e?e[_r]:void 0}function Cr(e){const t=Sr(e);return Array.isArray(t)?t.reduce((e,t)=>e+t,0):"number"==typeof t?t:NaN}function Mr(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function $r(e,t,n){let i=0;for(const e of t)i+=Math.abs(+n(e))||0;return i>0?Math.abs(+n(e))/i:NaN}function Ar(e){return e.startsWith(kr)}const zr=`${kr}Members`;function Dr(e,t,n,i){const o=new Map;return e.forEach((e,a)=>{const r=`${t(e,a)}`,s=+i(e,a)||0,c=o.get(r);c?c.value+=s:o.set(r,{label:`${n(e,a)}`,value:s})}),Array.from(o.values()).sort((e,t)=>t.value-e.value)}const Fr=e=>`<span class="d3plus-tooltip-member" style="padding-left: 12px">${e}</span>`;function Br(e,t,n=10){const i=function(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;const n=t?t[zr]:void 0;return n?Array.isArray(n)?n:[n]:[]}(t);if(!i.length)return[];const o=e._thresholdMemberFormat??(t=>d.formatAbbreviate(t,e.schema.locale)),a=i.slice(0,n).map(e=>[Fr(e.label),o(e.value)]),r=i.slice(n);return r.length&&a.push([Fr(`+${d.formatAbbreviate(r.length,e.schema.locale)} ${e.schema.translate("more")}`),o(r.reduce((e,t)=>e+t.value,0))]),a}function Lr(e,t,n){const i=Br(t,n);if(!i.length)return e;const o=e.tbody();return e.tbody((e,t)=>{const n="function"==typeof o?o(e,t):o;return[...Array.isArray(n)?n:[],...i]}),e}const Pr=10,Rr="display: inline-block; flex: none; margin-right: 6px; width: 10px; height: 10px;";function Er(e,t){if(!e)return"";if("Line"===t){const t=6;return`<span class="d3plus-tooltip-swatch d3plus-tooltip-swatch-line" style="${Rr} position: relative"><span style="position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: ${e}"></span><span style="position: absolute; left: ${(Pr-t)/2}px; top: ${(Pr-t)/2}px; width: ${t}px; height: ${t}px; border-radius: 50%; background: ${e}"></span></span>`}return`<span class="d3plus-tooltip-swatch" style="${Rr} border-radius: ${"Circle"===t?"50%":"1px"}; background: ${e}"></span>`}function Nr(e,t){return e?null==t||!1===t||""===t?"":`<span style="display: inline-flex; align-items: center">${e}<span>${t}</span></span>`:`${t}`}const Tr=e=>"string"==typeof e&&"none"!==e&&"transparent"!==e?e:void 0;function Or(e,t){for(const n of e){if(n.key===t)return n;const e=n.children&&Or(n.children,t);if(e)return e}}const Wr=["::hit","::confidence","::stem"];function jr(e,t){const n=t&&t.key;if("string"!=typeof n)return t;let i=n;for(const e of Wr)for(;i.endsWith(e);)i=i.slice(0,-e.length);return i===n?t:Or(e._chartScene||[],i)||t}function Hr(e,t){const n=jr(e,t);return n&&Ir(n)}function Ir(e){const t=e.paint;if(t)return"Line"===e.shapeType?Tr(t.stroke)??Tr(t.fill):Tr(t.fill)??Tr(t.stroke)}const Gr=e=>!!e.paint&&"Label"!==e.shapeType&&"text"!==e.type,Vr=e=>e.shapeType??("circle"===e.type?"Circle":void 0);function qr(e){let t=e;for(;t&&"object"==typeof t&&t.data&&"object"==typeof t.data&&!Array.isArray(t.data);)t=t.data;return t}function Yr(e,t,n){for(const i of e){if(Gr(i)&&!`${i.key}`.endsWith("::hit")&&"legend"===i.interactionGroup===n&&qr(i.datum)===t&&Ir(i))return i;const e=i.children&&Yr(i.children,t,n);if(e)return e}}function Kr(e,t){if(!t||!t.node)return"";const n=t.node,i=Gr(n)?Hr(e,n):void 0;if(i&&!t.isLegend)return Er(i,Vr(n));const o=e._paintedScene?.root,a=i?n:o&&Yr([o],qr(t.d),!!t.isLegend);if(!a)return"";const r=a.datum?.shape;return Er(Hr(e,a),t.isLegend&&"string"==typeof r?r:Vr(a))}function Ur(e,t){if(!t||!1===e.schema.titleSwatch)return e;const n=e.schema.title;return e.title((e,i)=>Nr(t,n(e,i)))}function Xr(e,t,n,i){const o=i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY],a=h.merge(this._legendClass.data().map((e,t)=>{let n=this._id(e,t);return n instanceof Array||(n=[n]),n})).length;if(e&&this.schema.tooltip(e,t)){let i=this._id(e,t);i instanceof Array&&(i=i[0]);const r=this.schema.translate,s=gr.bind(this).toString(),c=Object.keys(this.schema.on).some(e=>["click","click.legend"].includes(e)&&this.schema.on[e]&&this.schema.on[e].toString()!==s),l=this.schema.on["click.legend"]&&this.schema.on["click.legend"].toString()===s,h=this._drawDepth<this.schema.groupBy.length-1;this._select.style("cursor",c||l&&h?"pointer":"auto");const u=this.schema.legendFilterInvert.bind(this)(this),d=this._solo.includes(i),f=this._hidden.includes(i);this._tooltipClass.data([n||e]).footer(!!l&&(u?this._solo.length&&!d||f?r("Click to Highlight"):1===this._solo.length&&d||this._hidden.length===a-1?r("Click to Show All"):`${r("Click to Highlight")}<br />${r("Shift+Click to Hide")}`:this._solo.length&&!d||f?`${r("Click to Show")}<br />${r("Shift+Click to Highlight")}`:1===this._solo.length&&d||this._hidden.length===a-1?r("Click to Show All"):`${r("Click to Hide")}<br />${r("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():ur.bind(this)).titleSwatch(!0).position(o).config(Ae.bind(this)(this.schema.tooltipConfig)).config(Ae.bind(this)(this.schema.legendTooltip)),Lr(this._tooltipClass,this,e),Ur(this._tooltipClass,Kr(this,this._lastScenePick)).render()}}function Qr(e,t,n,i){if(e&&this.schema.tooltip(e,t)){const t=pr.bind(this).toString(),o=Object.keys(this.schema.on).some(e=>["click","click.shape"].includes(e)&&this.schema.on[e]&&this.schema.on[e].toString()!==t),a=this.schema.on["click.shape"]&&this.schema.on["click.shape"].toString()===t,r=Ye(e),s=void 0===r?this._drawDepth<this.schema.groupBy.length-1:Xe(this.schema.groupBy,Ke(this.schema.groupBy,e,r),this._filteredData??[]);if(this._select.style("cursor",o||a&&s?"pointer":"auto"),this._sharedHoverActive)return;const c=i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY];let l=n||e;for(;l&&l.__d3plus__&&l.data;)l=l.data;this._tooltipClass.data([l]).footer(!(!a||!s)&&this.schema.translate("Click to Expand")).title((e,t)=>this._drawLabel(e,t)).titleSwatch(!0).position(c).config(Ae.bind(this)(this.schema.tooltipConfig)),Lr(this._tooltipClass,this,l),Ur(this._tooltipClass,Kr(this,this._lastScenePick)).render()}}function Zr(){return"undefined"==typeof window||window.innerWidth>600}class Jr{get(e){if(!this._map.has(e))return;const t=this._map.get(e);return this._map.delete(e),this._map.set(e,t),t}set(e,t){this._map.delete(e),this._map.size>=this._cap&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}constructor(e){this._cap=e,this._map=new Map}}const es={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`400 12px/1 ${a.fontFamilyStringify(a.fontFamily)}`,gap:"4px",height:"20px","justify-content":"center",margin:0,padding:"0 6px",width:"auto"};function ts(e){e.schema.on={"click.shape":pr.bind(e),"click.legend":gr.bind(e),mouseenter:yr.bind(e),mouseleave:br.bind(e),"mousemove.shape":Qr.bind(e),"mousemove.legend":Xr.bind(e)},e._queue=[];const t=t=>{const{width:n,height:i}=t[0].contentRect;(n!==e.schema.width&&e._autoWidth||i!==e.schema.height&&e._autoHeight)&&n&&i&&(e._setSVGSize(n,i),e._callback||e.render())},n=function(e,t){let n;return function(...i){const o=this;clearTimeout(n),n=setTimeout(()=>e.apply(o,i),t)}}(t,e.schema.detectResizeDelay);e._resizeObserver="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(i=>{const{width:o,height:a}=i[0].contentRect;if(e._resizeSettled)n(i);else{if(!o||!a)return;e._resizeSettled=!0,t(i)}}),e.schema.scrollContainer="undefined"==typeof window?"":window}const ns="rgba(255, 255, 255, 0.7)",is="rgba(24, 25, 28, 0.7)",os={"border-radius":"3px 0 0 0",display:"flex","align-items":"center",gap:"4px",font:`400 10px/1.4 ${a.fontFamilyStringify(a.fontFamily)}`},as={...os,background:ns,color:r.colorContrast(ns)},rs={...os,background:is,color:r.colorContrast(is)},ss={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},cs={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},ls=!1,hs={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},us={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},ds=!1;const fs={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)","border-radius":"2px","box-sizing":"border-box"},ms={background:"rgba(0, 0, 0, 0.15)",border:"1px solid rgba(0, 0, 0, 0.5)","border-radius":"2px",cursor:"grab"},ps={background:"rgba(0, 0, 0, 0.25)",cursor:"grabbing"},gs={bottom:"2px",right:"3px",color:"rgba(0, 0, 0, 0.75)",font:`400 9px/1 ${a.fontFamilyStringify(a.fontFamily)}`,"pointer-events":"none"};const ys={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},xs={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},bs=!1;const _s={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${a.fontFamilyStringify(a.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},ks={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},vs=!1,ws={background:"Canvas",border:"1px solid rgba(128, 128, 128, 0.5)","border-radius":"3px","box-shadow":"0 2px 6px rgba(0, 0, 0, 0.2)",color:"CanvasText","margin-top":"4px",padding:"2px 0"},Ss={background:"none",border:"none",color:"inherit",font:`12px/1.2 ${a.fontFamilyStringify(a.fontFamily)}`,margin:0,padding:"4px 10px"},Cs={background:"rgba(128, 128, 128, 0.2)"};function Ms(e){e.schema.aggs={},ee(e,cr),function(e){e._renderer="svg",e.schema.ariaHidden=!0,e.schema.attribution=!1,e.schema.attributionIcon=void 0,e.schema.attributionStyle=as,e.schema.cache=!0}(e),function(e){e.schema.color=(t,n)=>e.schema.groupBy[0](t,n);const t=s.scaleOrdinal().range(r.colorDefaults.scale.range());e.schema.colorDefaults={...r.colorDefaults,scale:t},e._autoColorScale=t,e._colorScaleClass=new Gi,e.schema.colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},e.schema.colorScalePadding=Zr,e.schema.colorScalePosition=N("auto"),e.schema.colorScaleMaxSize=600}(e),function(e){e._data=[],e.schema.dataCutoff=100,e.schema.dataPollingInterval=!1,e.schema.detectResize=!0,e.schema.detectResizeDelay=400,e.schema.detectVisible=!0,e.schema.detectVisibleInterval=1e3,e.schema.detectVisibleUnload=!0,e.schema.duration=600,e.schema.fontFamily=a.fontFamily,e._hidden=[],e.schema.hiddenColor=N("#aaa"),e.schema.hiddenOpacity=N(.5),e._history=[],e.schema.groupBy=[T("id")],e.schema.facetConfig={}}(e),function(e){e.schema.legend=(t,n)=>{if(e._legendCategories)return n.length>1;const i=h.max(n,(t,n)=>{if(t._isAggregation)return 1;const i=e.schema.groupBy[e._legendDepth].bind(e)(t,n);return i instanceof Array?i.length:1});return n.length>1&&(i??0)<=2},e._legendClass=new bi,e.schema.legendConfig={label:ur.bind(e),shapeConfig:{ariaLabel:ur.bind(e),labelConfig:{fontColor:()=>Ga(e),fontResize:!1,padding:0}}},e.schema.legendFilterInvert=N(!1),e.schema.legendPadding=Zr,e.schema.legendPosition=N("auto");const t=t=>hr(e,t)??e._drawLabel(t);e.schema.legendSort=(e,n)=>t(e).localeCompare(t(n)),e.schema.legendTooltip={},e._sizeLegendClass=new Zi,Object.assign(e.schema,{sizeLegend:Vi,sizeLegendConfig:{},sizeLegendPosition:"right"})}(e),function(e){e.schema.loadingHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("Loading Visualization")}</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${e.schema.translate("Powered by D3plus")}</a></sub>\n </div>`,e.schema.loadingMessage=!0,e._lrucache=new Jr(10),e._messageClass=new Ji,e.schema.messageMask="rgba(0, 0, 0, 0.05)",e.schema.messageStyle={bottom:"0",left:"0",position:"absolute",right:"0","text-align":"center",top:"0"},e.schema.noDataHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("No Data Available")}</strong>\n </div>`,e.schema.noDataMessage=!0}(e),ts(e),function(e){e.schema.shape=N("Rect"),e.schema.shapeConfig={ariaLabel:(t,n)=>e._drawLabel(t,n),fill:(t,n)=>{for(;t.__d3plus__&&t.data;)n=(t=t.data).i;if(e.schema.colorScale){const i=e.schema.colorScale(t,n);if(null!=i){const t=e._colorScaleClass._colorScale,n=e._colorScaleClass.color();return t?t.domain().length?t(i):t.range()[t.range().length-1]:n instanceof Array?n[n.length-1]:n}}const i=e.schema.color(t,n);if(l.color(i))return i;const o="string"==typeof i?i:JSON.stringify(i);return e.schema.colorOrdinal&&e._ordinalColorScale?e._ordinalColorScale(o):r.colorAssign(o,rt(e))},labelConfig:{fontColor:or((t,n)=>{const i="function"==typeof e.schema.shapeConfig.fill?e.schema.shapeConfig.fill(t,n):e.schema.shapeConfig.fill;return r.colorContrast(i,e.schema.colorDefaults)})},opacity:N(1),stroke:(t,n)=>{const i="function"==typeof e.schema.shapeConfig.fill?e.schema.shapeConfig.fill(t,n):e.schema.shapeConfig.fill,o=l.color(i);return o?o.darker(.25).toString():i},role:"presentation",strokeWidth:N(0)},e._solo=[]}(e),function(e){e._subtitleClass=new ro,e.schema.subtitleConfig={ariaHidden:!0,fontColor:()=>Ga(e),fontSize:12,padding:5,textAnchor:"middle"},e.schema.subtitlePadding=Zr,e.schema.svgDesc="",e.schema.svgTitle="",e.schema.timeline=!0,e._timelineClass=(new yo).align("end"),e.schema.timelineConfig={padding:5},e.schema.timelinePadding=Zr,e.schema.threshold=N(1e-4),e.schema.thresholdKey=void 0,e.schema.thresholdName=()=>e.schema.translate("Values"),e._titleClass=new ro,e.schema.titleConfig={ariaHidden:!0,fontColor:()=>Ga(e),fontSize:16,padding:5,textAnchor:"middle"},e.schema.titlePadding=Zr,e.schema.tooltip=N(!0),e._tooltipClass=new Mo,e.schema.tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},e._totalClass=new ro,e.schema.totalConfig={fontColor:()=>Ga(e),fontSize:10,padding:5,textAnchor:"middle"},e.schema.totalFormat=t=>`${e.schema.translate("Total")}: ${d.formatAbbreviate(t,e.schema.locale)}`,e.schema.totalPadding=Zr}(e),function(e){e.schema.zoom=!0,e._zoomBehavior=b.zoom(),e._zoomBrush=p.brush(),e.schema.zoomBrushHandleSize=1,e.schema.zoomBrushHandleStyle={fill:"#444"},e.schema.zoomBrushSelectionStyle={fill:"#777","stroke-width":0},e.schema.zoomControlClassName=void 0,e.schema.zoomControlIcons=void 0,e.schema.zoomControlStyle=ss,e.schema.zoomControlStyleActive=cs,e.schema.zoomControlStyleHover=ls,e.schema.zoomFactor=2,e.schema.zoomMax=void 0,e.schema.zoomPadding=20,e.schema.zoomPan=!0,e.schema.zoomScroll="modifier"}(e),function(e){e.schema.tableView=!0,e.schema.tableViewClassName=void 0,e.schema.tableViewControlClassName=void 0,e.schema.tableViewControlStyle=hs,e.schema.tableViewControlStyleActive=us,e.schema.tableViewControlStyleHover=ds,e.schema.tableViewDownload=!0,e.schema.tableViewPageSize=50,e.schema.tableViewSort=!0}(e),function(e){e.schema.minimap=!0,e.schema.minimapClassName=void 0,e.schema.minimapStyle=fs,e.schema.minimapViewportStyle=ms,e.schema.minimapViewportStyleActive=ps,e.schema.minimapLabelStyle=gs}(e),function(e){e.schema.backControlClassName=void 0,e.schema.backControlStyle=es}(e),function(e){e.schema.search=!0,e.schema.searchAccessor=(t,n)=>e._drawLabel(t,n),e.schema.searchControlClassName=void 0,e.schema.searchControlStyle=ys,e.schema.searchControlStyleActive=xs,e.schema.searchControlStyleHover=bs}(e),function(e){e.schema.saveControl=!0,e.schema.saveControlClassName=void 0,e.schema.saveControlConfig={},e.schema.saveControlMenuClassName=void 0,e.schema.saveControlMenuItemStyle=Ss,e.schema.saveControlMenuItemStyleHover=Cs,e.schema.saveControlMenuStyle=ws,e.schema.saveControlStyle=_s,e.schema.saveControlStyleActive=ks,e.schema.saveControlStyleHover=vs}(e)}const $s=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),As={AccentColor:"Highlight",AccentColorText:"HighlightText"};function zs(e,t,n){const i=$s(t);e.style.setProperty(i,n);const o=As[n];o&&!e.style.getPropertyValue(i)&&e.style.setProperty(i,o)}function Ds(e,t,n){return n&&e===t?{}:e||{}}function Fs(e,t,n,i){const{base:o,active:a={},hover:r={}}=t;for(const t of new Set([...Object.keys(o),...Object.keys(a),...Object.keys(r)]))e.style.removeProperty($s(t));for(const t of[o,n?r:{},i?a:{}])for(const n in t){const i=t[n];null!=i&&!1!==i&&zs(e,n,String(i))}}function Bs(e,t,n){const i=Boolean(e[`${t}ClassName`]),o=(n,o)=>Ds(e[`${t}Style${n}`],o,i);return{base:o("",n.base),active:o("Active",n.active),hover:o("Hover",n.hover)}}function Ls(e){return String(e??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e]))}function Ps(e){return Boolean(e._brushing)}function Rs(e){return Bs(e.schema,"zoomControl",{base:ss,active:cs,hover:ls})}function Es(e,t,n=!1){Fs(t,Rs(e),n,t.classList.contains("active"))}const Ns='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',Ts=`<svg ${Ns}><line x1="12" y1="4" x2="12" y2="20"/><line x1="4" y1="12" x2="20" y2="12"/></svg>`,Os=`<svg ${Ns}><line x1="4" y1="12" x2="20" y2="12"/></svg>`,Ws=`<svg ${Ns}><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>`,js=`<svg ${Ns} stroke-dasharray="4 3"><rect x="4" y="4" width="16" height="16" rx="1"/></svg>`;function Hs(e,t,n){const i=e.schema.zoomControlIcons?.[t];return"string"==typeof i?i:"function"==typeof i?(e=>`<span class="zoom-control-icon" data-icon="${e}" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>`)(t):n}const Is={zoomIn:"zoom-in",zoomOut:"zoom-out",zoomReset:"zoom-reset",zoomBrush:"zoom-brush"},Gs={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"4px",boxSizing:"border-box",paddingTop:"4px",paddingRight:"4px"};function Vs(e){const t=e.schema.zoomControlClassName?` ${e.schema.zoomControlClassName}`:"",n=(n,i,o,a)=>`<button type="button" class="zoom-control ${n}${a?" active":""}${t}" aria-label="${e.schema.translate(i)}"${void 0===a?"":` aria-pressed="${a}"`}>${o}</button>`;return n("zoom-in","Zoom In",Hs(e,"zoomIn",Ts))+n("zoom-out","Zoom Out",Hs(e,"zoomOut",Os))+n("zoom-reset","Reset Zoom",Hs(e,"zoomReset",Ws))+n("zoom-brush","Brush Zoom",Hs(e,"zoomBrush",js),Ps(e))}function qs(e){let t=e._select&&e._select.node()?e._select.node().parentNode:null;for(;t&&!(t instanceof HTMLElement);)t=t.parentNode;return t instanceof HTMLElement?t:null}function Ys(e){return Boolean(e.schema.zoom)&&!e._ssr}const Ks={width:96,height:24};function Us(e){if(!Ys(e))return null;const t=Vs(e),{base:n}=Rs(e),i=`${t}|${JSON.stringify(n)}`,o=e._zoomControlsBox;if(o&&o.signature===i)return o;let a=Ks;const r=qs(e);if(r){const n=document.createElement("div");n.className="d3plus-zoom-control";for(const e in Gs)n.style.setProperty($s(e),Gs[e]);n.style.setProperty("display","inline-flex"),n.style.setProperty("position","absolute"),n.style.setProperty("visibility","hidden"),n.style.setProperty("pointer-events","none"),n.innerHTML=t,n.querySelectorAll(".zoom-control").forEach(t=>Es(e,t)),r.appendChild(n);const i=n.getBoundingClientRect();r.removeChild(n),i.width&&i.height&&(a={width:Math.ceil(i.width),height:Math.ceil(i.height)})}return e._zoomControlsBox={...a,signature:i},e._zoomControlsBox}function Xs(e){const t=Us(e);return t&&t.height?t.height+4:0}function Qs(e){return{width:e.reduce((e,t,n)=>e+t.width+(n?6:0),0),height:Math.max(0,...e.map(e=>e.height))}}function Zs(e){const t=e._bottomRightBox;return t&&t.width&&t.height?t:null}function Js(e){const t=Zs(e);return t&&!t.inset?t:null}function ec(e,t,n){const i=Js(e);if(!i||"right"===i.side||t>=i.bottom+i.height)return 0;const o=i.width-n;return o>0?o+6:0}function tc(e,t){const n=Js(e);return n?Math.max(0,n.bottom+n.height-t):0}function nc(e,t,n,i){return{inset:"bottom"===t?ec(e,n,i):0,drop:"left"===t||"right"===t?tc(e,n):0}}function ic(e,t){const n=Js(e);return n&&"bottom"===n.side?Math.max(0,n.bottom+n.height-t):0}function oc(e,t){const n=Js(e);return n&&"right"===n.side?Math.max(0,n.width+6-t):0}function ac(e,t){const n=e._zoomTransform?.scale??1;if(t.inset)return function(e,t,n){const i=Ka(e,"sizeLegend");if(!i)return null;const{margin:o}=qa(e),a=t.items.map(e=>({item:e,paint:e.paint(n)})).filter(e=>Boolean(e.paint));if(!a.length)return null;const r=a.reduce((e,t,n)=>e+t.paint.width+(n?6:0),0)+2*o,s=Math.max(...a.map(e=>e.paint.height))+2*o,c="left"===i.alignX?i.x:"center"===i.alignX?i.x+(i.width-r)/2:i.x+i.width-r,l="top"===i.alignY?i.y:"middle"===i.alignY?i.y+(i.height-s)/2:i.y+i.height-s,h=[Qa(e,{...i,x:c,y:l,width:r,height:s})];let u=c+r-o;const d=l+s-o;for(const{item:e,paint:t}of a)h.push({type:"group",key:e.key,transform:{x:u-t.width,y:d-t.height},children:[t.node]}),u-=t.width+6;return{type:"group",key:"viz-bottomRight",children:h}}(e,t,n);const i=[];let o=e.schema.width;const a=e.schema.height-t.bottom;return t.items.forEach(e=>{const t=e.paint(n);t&&i.push({type:"group",key:e.key,transform:{x:o-t.width,y:a-t.height},children:[t.node]}),o-=e.width+6}),i.length?{type:"group",key:"viz-bottomRight",children:i}:null}const rc=new WeakMap;function sc(e){rc.delete(e)}function cc(e){return{type:"htmlOverlay",key:"viz-zoom-controls",x:0,y:0,width:e.schema.width,style:Gs,className:"d3plus-zoom-control",html:Vs(e),events:{".zoom-in":{click:()=>bc.bind(e)(e.schema.zoomFactor)},".zoom-out":{click:()=>bc.bind(e)(1/e.schema.zoomFactor)},".zoom-reset":{click:()=>bc.bind(e)(0)},".zoom-brush":{click:t=>{const n=t.target.closest(".zoom-brush");if(!n)return;const i=!Ps(e);n.classList.toggle("active",i),n.setAttribute("aria-pressed",String(i)),Es(e,n,n.matches(":hover")),mc.bind(e)(i)}}},onUpdate:t=>{t.querySelectorAll(".zoom-control").forEach(t=>{t.dataset.zoomBound||(t.dataset.zoomBound="1",Es(e,t),t.addEventListener("mouseenter",()=>Es(e,t,!0)),t.addEventListener("mouseleave",()=>Es(e,t)),function(e,t){var n;const i=e.schema.zoomControlIcons;if(!i)return;const o=Object.keys(Is).find(e=>t.classList.contains(Is[e])),a=o&&i[o];if(!o||"function"!=typeof a)return;const r=t.querySelector(".zoom-control-icon");if(!r)return;const s=(n=e)._zoomIconCleanup||(n._zoomIconCleanup={});s[o]?.(),s[o]=a(r)||void 0}(e,t))})}}}const lc={name:"zoom",layout:({viz:e})=>{if(e.schema.zoom?function(e){if(!e._select)return;if(!e._ssr&&(!e._container||e._container.classed("d3plus-zoom"))){const{width:t,height:n}=ie(e);tr(e,{kind:"generic",width:t,height:n,duration:e.schema.duration})}"canvas"!==e._renderer&&uc(e,e._select)}(e):function(e){e._zoomTransform=void 0,sc(e);const t=e._zoomEventTarget||e._container;t&&t.node()&&t.property("__zoom",b.zoomIdentity)}(e),!e._container||!e._zoomGroup)return{panel:null,margin:{}};const t=ie(e),n=e._zoomHeight||t.height,i=e._zoomWidth||t.width,{left:o,top:a}=e._margin,r=[[o,a],[o+i,a+n]];e._zoomBehavior.filter(t=>function(e,t){const n="modifier"===e.schema.zoomScroll;return"wheel"===t.type?!n||t.ctrlKey||t.metaKey:!function(e){const t=e.target;return Boolean(t&&"function"==typeof t.closest&&t.closest("g.d3plus-viz-timeline, g.d3plus-zoom-brush"))}(t)&&("touchstart"===t.type&&n?(t.touches?.length??0)>1||pc(e):!t.ctrlKey&&!t.button)}(e,t)).wheelDelta(gc).extent(r).scaleExtent([1,hc(e,i,n)]).translateExtent(r).on("zoom",t=>{(function(e,t){const n=t;if(!n||"object"!=typeof n||"number"!=typeof n.k)return!1;const i=rc.get(e)??{k:1,x:0,y:0};return n.k===i.k&&(n.x??0)===i.x&&(n.y??0)===i.y})(e,t.transform)||xc.bind(e)(t.transform)}),e._zoomToBounds=kc.bind(e);const s=Ys(e)?cc(e):null;e._zoomBrush.extent([[0,0],[i,n]]).filter(e=>!e.button&&e.detail<2).handleSize(e.schema.zoomBrushHandleSize).on("start",Sc.bind(e)).on("brush",vc.bind(e)).on("end",wc.bind(e));const c=e._select.selectAll(":scope > g.d3plus-zoom-brush").data([0]);return e._brushGroup=c.enter().append("g").attr("class","d3plus-zoom-brush").merge(c).attr("transform",`translate(${o}, ${a})`).call(e._zoomBrush),mc.bind(e)(Ps(e)),e._renderTiles&&e._renderTiles(fc(e),0),{panel:s,margin:{}}}};function hc(e,t,n){return"number"==typeof e.schema.zoomMax?e.schema.zoomMax:function(e,t,n,i,o=1){const a=Math.max(1,t-2*i),r=Math.max(1,n-2*i);let s=1;for(const t of e){if(void 0===t.datum||"group"===t.type||"text"===t.type)continue;if(String(t.key).endsWith("::hit"))continue;const e=o*(t.transform?.scale??1);for(const[n,i]of nr(t)){const t=Math.min(n>0?a/(n*e):1/0,i>0?r/(i*e):1/0);Number.isFinite(t)&&t>s&&(s=t)}}return s}(e._zoomShapes||e._chartScene||[],t,n,e.schema.zoomPadding,e._chartTransform?.scale??1)}function uc(e,t){const n=e._zoomEventTarget;n&&n.node()===t.node()||(n&&n.on(".zoom",null),e._container&&e._container.on(".zoom",null),e._zoomEventTarget=t)}function dc(e){const t="canvas"===e._renderer,n=Ps(e);e._select&&e._select.style("pointer-events",t||n?"none":null),e._container&&e._container.style("pointer-events",t?"none":null),e._brushGroup&&e._brushGroup.style("pointer-events",n?"all":null)}function fc(e){const t=b.zoomTransform((e._zoomEventTarget||e._container).node()),{left:n,top:i}=e._margin;return b.zoomIdentity.translate(t.x+(t.k-1)*n,t.y+(t.k-1)*i).scale(t.k)}function mc(e=!1){!function(e,t){e._brushing=t}(this,e),e?this._brushGroup.style("display","inline"):this._brushGroup.style("display","none"),dc(this);const t=this._zoomEventTarget||this._container;!e&&this.schema.zoom?(t.call(this._zoomBehavior),this.schema.zoomScroll||t.on("wheel.zoom",null),yc(this),this.schema.zoomPan||t.on("mousedown.zoom mousemove.zoom",null).on("touchstart.zoom touchmove.zoom touchend.zoom touchcancel.zoom",null)):t.on(".zoom",null)}function pc(e){const t=e._zoomEventTarget||e._container;return Boolean(t&&t.node()&&b.zoomTransform(t.node()).k>1)}function gc(e){const t=e.ctrlKey&&0===e.deltaMode&&Math.abs(e.deltaY)<50;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(t?10:1)}function yc(e){const t=e._zoomEventTarget||e._container;if(!t)return;const n="modifier"===e.schema.zoomScroll&&e.schema.zoomPan;t.style("touch-action",n?pc(e)?"none":"pan-x pan-y":null)}function xc(e=!1,t=0){this._zoomGroup&&(t?this._zoomGroup.transition().duration(t).attr("transform",e):this._zoomGroup.attr("transform",e));const n=e;if(n&&"object"==typeof n&&"k"in n){const e={k:n.k??1,x:n.x??0,y:n.y??0};!function(e,t){rc.set(e,{k:t.k,x:t.x,y:t.y})}(this,e),this._zoomRescale&&this._zoomRescale(e,t)?this._zoomTransform=void 0:this._zoomTransform={x:e.x,y:e.y,scale:e.k}}else!1===n&&(this._zoomTransform=void 0,sc(this));!function(e){const t=Zs(e);if(!t||!e._featurePanels)return;const n=e._featurePanels.filter(e=>"viz-bottomRight"!==e.key),i=ac(e,t);e._featurePanels=i?[...n,i]:n}(this),this._drawSceneToTarget&&this._sceneRenderer&&this._drawSceneToTarget(t),yc(this),this._renderTiles&&this._renderTiles(fc(this),t)}function bc(e=0){if(!this._container)return;const[[t,n],[i,o]]=this._zoomBehavior.extent().bind(document)(),a=(t+i)/2,r=(n+o)/2,s=b.zoomTransform((this._zoomEventTarget||this._container).node());if(!e)return _c(this,1,0,0);const c=s.k*e;_c(this,c,a-(a-s.x)/s.k*c,r-(r-s.y)/s.k*c)}function _c(e,t,n,i,o=e.schema.duration){const[a,r]=e._zoomBehavior.scaleExtent(),[[s,c],[l,h]]=e._zoomBehavior.translateExtent(),u=Math.max(a,Math.min(r,t)),d=Math.max(l*(1-u),Math.min(s*(1-u),n)),f=Math.max(h*(1-u),Math.min(c*(1-u),i)),m=b.zoomIdentity.translate(d,f).scale(u);(e._zoomEventTarget||e._container).property("__zoom",m),xc.bind(e)(m,o)}function kc(e,t=this.schema.duration){if(!e)return _c(this,1,0,0,t);const[[n,i],[o,a]]=this._zoomBehavior.translateExtent(),r=this.schema.zoomPadding,s=b.zoomTransform((this._zoomEventTarget||this._container).node()),c=(e[0][0]-s.x)/s.k,l=(e[0][1]-s.y)/s.k,h=(e[1][0]-s.x)/s.k,u=(e[1][1]-s.y)/s.k,d=Math.min((o-n-2*r)/(h-c),(a-i-2*r)/(u-l));_c(this,d,(n+o)/2-d*(c+h)/2,(i+a)/2-d*(l+u)/2,t)}function vc(){Cc.bind(this)()}function wc(e){if(!e.selection)return;this._brushGroup.call(this._zoomBrush.move,null),mc.bind(this)(!1),function(e){const t=qs(e)?.querySelector(".d3plus-zoom-control .zoom-brush");if(!t)return;const n=Ps(e);t.classList.toggle("active",n),t.setAttribute("aria-pressed",String(n)),Es(e,t,t.matches(":hover"))}(this);const{left:t,top:n}=this._margin;kc.bind(this)(e.selection.map(([e,i])=>[e+t,i+n]))}function Sc(){Cc.bind(this)()}function Cc(){this._brushGroup.selectAll(".selection").call(n.attrize,this.schema.zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(n.attrize,this.schema.zoomBrushHandleStyle||{})}function Mc(e,t){const n=e._facetPanels;if(!n||!n.length||!t)return;const i=e._zoomTransform,o=i&&i.scale?i.scale:1,a=(t[0]-(i?.x??0))/o,r=(t[1]-(i?.y??0))/o;return n.find(e=>{const t=e.cell;return a>=t.x&&a<=t.x+t.width&&r>=t.y&&r<=t.y+t.height})}function $c(e,t,n){if(!t)return n();const i=e,o=function(e){return{_chartScene:e.scene,_chartTransform:e.chartTransform,...e.state}}(t),a={};for(const e of Object.keys(o))a[e]=i[e],i[e]=o[e];try{return n()}finally{for(const e of Object.keys(o))i[e]===o[e]&&(i[e]=a[e])}}function Ac(e,t){const n=e;for(const e of t)for(const t of Object.keys(e.state))n[t]=void 0}function zc(e){const t=Boolean(e.schema.backControlClassName);return Ds(e.schema.backControlStyle,es,t)}const Dc=`<svg ${Ns}><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>`;function Fc(e){const t=e.schema.backControlClassName?` ${e.schema.backControlClassName}`:"",n=e.schema.translate("Back");return`<button type="button" class="back-control${t}">${Dc}${n}</button>`}function Bc(e){return function(e){return Boolean(e._history&&e._history.length)&&!e._ssr}(e)?{key:"back",html:Fc(e),styleSignature:JSON.stringify(zc(e)),events:{".back-control":{click:()=>function(e){const t=e._history.pop();t?(void 0!==t.groupId&&void 0!==t.groupDepth&&(e._pendingExitReunion={groupId:t.groupId,groupDepth:t.groupDepth,body:e._bodyRect}),e.config({depth:t.depth,filter:t.filter}).render()):e.depth(e._drawDepth-1).filter(!1).render()}(e)}},onUpdate:t=>{const n=t.querySelector(".back-control");n&&!n.dataset.backBound&&(n.dataset.backBound="1",function(e,t){Fs(t,{base:zc(e)},!1,!1)}(e,n))}}:null}function Lc(e){return Boolean(e._tableView)}function Pc(e){return e._tableViewPage||0}function Rc(e,t){e._tableViewPage=t}function Ec(e){return e._tableViewSort}function Nc(e){return"raw"===e._tableViewDataSource?"raw":"aggregate"}function Tc(e){const t=e._data,n=e._filteredData||t;return!(!t||!n||t===n)&&t.length!==n.length}function Oc(e){return Bs(e.schema,"tableViewControl",{base:hs,active:us,hover:ds})}function Wc(e,t,n=!1){Fs(t,Oc(e),n,t.classList.contains("active"))}function jc(e){return JSON.stringify(Oc(e))}const Hc='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',Ic=`<svg ${Hc}><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="12" y1="3" x2="12" y2="21"/></svg>`,Gc=`<svg ${Hc}><path d="M12 3v12"/><polyline points="7 11 12 16 17 11"/><path d="M4 18v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"/></svg>`,Vc=`<svg ${Hc}><polyline points="14 4 19 9 14 14"/><line x1="4" y1="9" x2="19" y2="9"/><polyline points="10 20 5 15 10 10"/><line x1="20" y1="15" x2="5" y2="15"/></svg>`,qc='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:11px;height:11px;vertical-align:middle;margin-left:4px;flex-shrink:0"',Yc=`<svg ${qc}><polyline points="6 15 12 9 18 15"/></svg>`,Kc=`<svg ${qc}><polyline points="6 9 12 15 18 9"/></svg>`;function Uc(e){const t=Lc(e);return`<button type="button" class="table-view-control table-view-toggle${t?" active":""}${e.schema.tableViewControlClassName?` ${e.schema.tableViewControlClassName}`:""}" aria-label="${e.schema.translate(t?"Show Chart":"Show Data Table")}" aria-pressed="${t}">${Ic}</button>`}function Xc(e){const t=function(e){return null==e?"":e instanceof Date?e.toISOString():String(e)}(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Qc(e,t,n){const i=e.schema.groupBy;return i&&i.length?i.map(e=>String(e(t,n))).join("\0"):""}function Zc(e,t){const n=e._data;if(!n||!n.length)return t;const{exact:i,group:o}=function(e){const t=e._data||[],n=e._tableViewGroupOrder;if(n&&n.data===t)return n;const i=new Map,o=new Map;t.forEach((t,n)=>{const a=JSON.stringify(t);i.has(a)||i.set(a,n);const r=Qc(e,t,n);o.has(r)||o.set(r,n)});const a={data:t,exact:i,group:o};return e._tableViewGroupOrder=a,a}(e);return t.map((t,n)=>({row:t,order:i.get(JSON.stringify(t))??o.get(Qc(e,t,n))??Number.MAX_SAFE_INTEGER})).sort((e,t)=>e.order-t.order).map(e=>e.row)}function Jc(e){const t="raw"===Nc(e)&&Tc(e);let n=((t?e._data:e._filteredData||e._data)||[]).slice();const i=function(e){const t=[],n=new Set;for(const i of e)for(const e of Object.keys(i))n.has(e)||Ar(e)||(n.add(e),t.push(e));return t}(n),o=Ec(e);if(o&&i.includes(o.column)){const t="desc"===o.direction?-1:1,{column:i}=o;n.sort((n,o)=>t*function(e,t,n){const i=null==e,o=null==t;return i||o?i&&o?0:i?1:-1:"number"==typeof e&&"number"==typeof t?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t),n,{numeric:!0})}(n[i],o[i],e.schema.locale))}else t||(n=Zc(e,n));return{rows:n,columns:i}}function el(e,t){const n=t.length,i=e.schema.tableViewPageSize,o="number"==typeof i&&i>0?i:n||1,a=Math.max(1,Math.ceil(n/o)),r=Math.min(Math.max(0,Pc(e)),a-1);Rc(e,r);const s=r*o,c=Math.min(s+o,n);return{slice:t.slice(s,c),page:r,totalPages:a,start:s,end:c,total:n}}function tl(e,t,n){return t.map(t=>`<td style="padding:6px 10px;border-bottom:1px solid #e0e0e0;"><div class="d3plus-table-view-cell" style="max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${Ls(function(e,t){return null==e?"":e instanceof Date?e.toLocaleDateString(t):"number"==typeof e?e.toLocaleString(t):String(e)}(n[t],e.schema.locale))}</div></td>`).join("")}function nl(e,t){return e?`<tr aria-hidden="true" style="height:${e}px;padding:0;border:0;"><td style="padding:0;border:0;" colspan="${t}"></td></tr>`:""}function il(e,t,n,i,o,a){const r=Math.max(t.length,1);return nl(30*i,r)+n.slice(i,o).map(n=>function(e,t,n){return`<tr style="height:30px;">${tl(e,t,n)}</tr>`}(e,t,n)).join("")+nl(30*(a-o),r)}function ol(e){const t=Ec(e),{rows:n,columns:i}=Jc(e),{slice:o,page:r,totalPages:s,start:c,end:l,total:h}=el(e,n),u=o.length,d=u>300,f=h?il(e,i,o,0,d?Math.min(u,60):u,u):`<tr><td style="padding:12px;color:#767676;" colspan="${Math.max(i.length,1)}">${e.schema.translate("No Data Available")}</td></tr>`,m=i.map(n=>function(e,t,n){const i=Ls(t);if(!function(e){return!1!==e.schema.tableViewSort}(e))return`<th style="position:sticky;top:0;background:#fff;text-align:left;padding:6px 10px;border-bottom:2px solid #ccc;white-space:nowrap;">${i}</th>`;const o=n?.column===t,a=o?"desc"===n.direction?"descending":"ascending":"none",r=o?"desc"===n.direction?Kc:Yc:"";return`<th class="tableview-sort-header" data-column="${Ls(t)}" role="button" tabindex="0" aria-sort="${a}" style="position:sticky;top:0;background:#fff;text-align:left;padding:6px 10px;border-bottom:2px solid #ccc;white-space:nowrap;cursor:pointer;user-select:none;">${i}${r}</th>`}(e,n,t)).join(""),p=s>1?`<div class="d3plus-table-view-pagination" style="display:flex;align-items:center;gap:8px;padding:6px 10px;border-top:1px solid #e0e0e0;font-size:12px;flex:0 0 auto;">\n <button type="button" class="tableview-page-prev"${r<=0?" disabled":""}>‹ ${e.schema.translate("Previous")}</button>\n <span>${h?c+1:0}–${l} / ${h}</span>\n <button type="button" class="tableview-page-next"${r>=s-1?" disabled":""}>${e.schema.translate("Next")} ›</button>\n </div>`:"",g=e.schema.tableViewClassName?` ${e.schema.tableViewClassName}`:"",y=Uc(e)+(function(e){return!1!==e.schema.tableViewDownload}(e)?function(e){const t=e.schema.translate("Download");return`<button type="button" class="table-view-control tableview-download-csv" aria-label="${t}" title="${t} CSV">${Gc}</button>`}(e):"")+(Tc(e)?function(e){const t="raw"===Nc(e),n=e.schema.tableViewControlClassName?` ${e.schema.tableViewControlClassName}`:"",i=e.schema.translate(t?"Show Aggregate Data":"Show Raw Data");return`<button type="button" class="table-view-control tableview-source-toggle${t?" active":""}${n}" aria-label="${i}" title="${i}" aria-pressed="${t}">${Vc}</button>`}(e):""),x=d?"table-layout:fixed;":"";return`\n <div class="d3plus-table-view-frame" style="display:flex;flex-direction:column;width:100%;height:100%;box-sizing:border-box;background:#fff;font:12px/1.4 ${a.fontFamilyStringify(e.schema.fontFamily||"sans-serif")};">\n <div class="d3plus-table-view-toolbar" style="flex:0 0 auto;display:flex;gap:4px;padding:4px;">${y}</div>\n <div class="d3plus-table-view-scroll"${d?' data-tableview-virtual="1"':""} style="flex:1 1 auto;min-height:0;overflow:auto;">\n <table class="d3plus-table-view-table${g}" style="border-collapse:collapse;width:100%;${x}">\n <thead><tr>${m}</tr></thead>\n <tbody>${f}</tbody>\n </table>\n </div>\n ${p}\n </div>`}function al(e){const{rows:t,columns:n}=Jc(e),i=function(e,t){const n=[e.map(Xc).join(",")];for(const i of t)n.push(e.map(e=>Xc(i[e])).join(","));return n.join("\r\n")}(n,t),o=new Blob([i],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(o),r=document.createElement("a");r.href=a,r.download="table-view.csv",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)}function rl(e,t){e.querySelectorAll(".table-view-control").forEach(e=>{e.dataset.tableViewBound||(e.dataset.tableViewBound="1",Wc(t,e),e.addEventListener("mouseenter",()=>Wc(t,e,!0)),e.addEventListener("mouseleave",()=>Wc(t,e)))})}function sl(e,t){const n=e.querySelector(".d3plus-table-view-scroll[data-tableview-virtual]");if(!n||n.dataset.tableviewVirtualBound)return;const i=n.querySelector("tbody");if(!i)return;n.dataset.tableviewVirtualBound="1";const{rows:o,columns:a}=Jc(t),{slice:r}=el(t,o);let s=0;const c=()=>{s=0,function(e,t,n,i,o){const a=i.length,r=Math.max(1,Math.ceil(t.clientHeight/30)),s=Math.max(0,Math.floor(t.scrollTop/30)-10),c=Math.min(a,s+r+20);n.innerHTML=il(e,o,i,s,c,a)}(t,n,i,r,a)};n.addEventListener("scroll",()=>{s||(s=requestAnimationFrame(c))},{passive:!0}),c()}const cl="viz-table-view-overlay";function ll(e){const t=e.target.closest(".tableview-sort-header");return t?.dataset.column}function hl(e){return{type:"htmlOverlay",key:cl,x:0,y:0,width:e.schema.width,height:e.schema.height,className:"d3plus-table-view",html:ol(e),events:{".table-view-toggle":{click:()=>dl(e)},".tableview-page-prev":{click:()=>fl(e,-1)},".tableview-page-next":{click:()=>fl(e,1)},".tableview-download-csv":{click:()=>al(e)},".tableview-source-toggle":{click:()=>function(e){(function(e,t){e._tableViewDataSource=t})(e,"raw"===Nc(e)?"aggregate":"raw"),Rc(e,0),ul(e)}(e)},".tableview-sort-header":{click:t=>{const n=ll(t);n&&ml(e,n)},keydown:t=>{const n=t.key;if("Enter"!==n&&" "!==n)return;const i=ll(t);i&&(t.preventDefault(),ml(e,i))}}},onUpdate:t=>function(e,t){rl(e,t),sl(e,t)}(t,e)}}function ul(e){const t=(e._featurePanels||[]).slice(),n=t.findIndex(e=>e.key===cl);if(Lc(e)){const i=hl(e);n>=0?t[n]=i:t.push(i)}else n>=0&&t.splice(n,1);e._featurePanels=t,function(e){const t=qs(e)?.querySelector(".d3plus-top-left-controls-item .table-view-toggle");if(!t)return;const n=Lc(e);t.classList.toggle("active",n),t.setAttribute("aria-pressed",String(n)),Wc(e,t,t.matches(":hover"))}(e),e._drawSceneToTarget&&e._sceneRenderer&&e._drawSceneToTarget(0)}function dl(e){!function(e,t){e._tableView=t}(e,!Lc(e)),Rc(e,0),ul(e)}function fl(e,t){Rc(e,Math.max(0,Pc(e)+t)),ul(e)}function ml(e,t){const n=Ec(e);!function(e,t){e._tableViewSort=t}(e,{column:t,direction:n?.column===t&&"asc"===n.direction?"desc":"asc"}),Rc(e,0),ul(e)}const pl={name:"tableView",layout:({viz:e})=>Lc(e)?{panel:hl(e),margin:{}}:{panel:null,margin:{}}};function gl(e){return function(e){return Boolean(e.schema.tableView)&&!e._ssr}(e)?{key:"table-view",html:Uc(e),styleSignature:jc(e),events:{".table-view-toggle":{click:()=>dl(e)}},onUpdate:t=>rl(t,e)}:null}const yl=["png","svg","jpg"];function xl(e){if(!Array.isArray(e))return yl.slice();const t=[];for(const n of e){const e=String(n).toLowerCase().replace("jpeg","jpg");yl.includes(e)&&!t.includes(e)&&t.push(e)}return t}function bl(e){return("string"==typeof e||"number"==typeof e?String(e).replace(/<[^>]*>/g,"").replace(/[\\/:*?"<>|\p{Cc}]/gu,"").replace(/\s+/g," ").trim().slice(0,100).trim():"")||"download"}function _l(e){return Ia({_select:e._select})}function kl(e){const t=e.schema.title;return"function"==typeof t?t(e._filteredData||[]):void 0}function vl(e){const{filename:t,formats:n,background:i,callback:o,...a}=e.schema.saveControlConfig||{};return{filename:"string"==typeof t&&t.trim()?bl(t):bl(kl(e)),formats:xl(n),background:!1!==i&&("string"==typeof i&&i?i:_l(e)),callback:"function"==typeof o?o:void 0,renderOptions:a}}function wl(e){const t="canvas"===e._renderer?e.toCanvas():e._select?.node?.(),n="canvas"===e._renderer?"canvas":"svg";return t?.localName===n?t:null}const Sl=["position","top","left","content-visibility","touch-action"];function Cl(e,t){let n=null;if("canvas"===e._renderer){const t=e.toSVGString();if(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml");n=e.querySelector("parsererror")?null:e.documentElement}}else{const t=wl(e);n=t?t.cloneNode(!0):null,n&&function(e){e.removeAttribute("aria-hidden");for(const t of Sl)e.style?.removeProperty(t)}(n)}if(!n||"svg"!==n.localName)return null;if(t){const e=n.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("class","d3plus-save-background"),e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("fill",t),n.insertBefore(e,n.firstChild)}return n}function Ml(e){const t=e.pixelRatio;return"number"==typeof t&&t>0?t:"number"==typeof devicePixelRatio&&devicePixelRatio>0?devicePixelRatio:1}function $l(e,t){const n=e.getBoundingClientRect().width;return n>0&&e.width/n<t-.01}function Al(e,t){const{filename:n,background:i,callback:o,renderOptions:a}=vl(e),r=e=>{o?o(e):e&&console.error(e)},s=()=>r(new Error("The chart has not been rendered, so it cannot be saved."));if("svg"===t){const t=Cl(e,i);return t?void _.saveElement(t,{filename:n,type:"svg",callback:r}):s()}const c=wl(e);if(!c)return s();const l={...a,backgroundColor:i||("jpg"===t?_l(e):void 0)},h={filename:n,type:t};"canvas"===e._renderer&&$l(c,Ml(l))&&function(e,t,n,i,o){const a=i.backgroundColor,r=Cl(e,"string"==typeof a&&a),s=t.ownerDocument;if(!r||!s.body)return!1;const c=s.createElement("div");c.setAttribute("aria-hidden","true"),c.style.cssText="position:fixed;left:-100000px;top:0;";const l=s.importNode(r,!0);return c.appendChild(l),s.body.appendChild(c),_.saveElement(l,{...n,callback:e=>{c.remove(),o(e)}},i),!0}(e,c,h,l,r)||_.saveElement(c,{...h,callback:r},l)}const zl={png:"PNG image",svg:"SVG vector",jpg:"JPG image"};function Dl(e){return xl(e.schema.saveControlConfig?.formats)}function Fl(e){return Bs(e.schema,"saveControl",{base:_s,active:ks,hover:vs})}function Bl(e,t,n=!1){Fs(t,Fl(e),n,t.classList.contains("active"))}const Ll={position:"relative",display:"inline-flex","align-items":"center"},Pl={position:"absolute",top:"100%",left:"0","z-index":"1",display:"none","flex-direction":"column","min-width":"max-content"},Rl={display:"flex"},El={display:"block",width:"100%","text-align":"start","white-space":"nowrap",cursor:"pointer"};function Nl(e){const t=Boolean(e.schema.saveControlMenuClassName),n=(n,i)=>Ds(e.schema[n],i,t);return{menu:n("saveControlMenuStyle",ws),item:n("saveControlMenuItemStyle",Ss),itemHover:n("saveControlMenuItemStyleHover",Cs)}}function Tl(...e){return e.flatMap(e=>Object.entries(e)).filter(([,e])=>null!=e&&!1!==e).map(([e,t])=>`${$s(e)}:${Ls(t)}`).join(";")}function Ol(e){const t=Dl(e),n=t=>e.schema.translate(t),i=n("Download"),o=e.schema.saveControlClassName?` ${Ls(e.schema.saveControlClassName)}`:"",a=(e,t)=>`<button type="button" class="save-control save-toggle${o}" aria-label="${Ls(e)}" title="${Ls(e)}"${t}>${Gc}</button>`;if(1===t.length){const e=`${i} (${n(zl[t[0]])})`;return`<span class="save-root" style="${Tl(Ll)}">${a(e,` data-format="${t[0]}"`)}</span>`}const r=Nl(e),s=Tl(r.item,El),c=e.schema.saveControlMenuClassName?` ${Ls(e.schema.saveControlMenuClassName)}`:"",l=t.map(e=>`<button type="button" role="menuitem" tabindex="-1" class="save-menu-item" data-format="${e}" style="${s}">${Ls(n(zl[e]))}</button>`).join("");return`<span class="save-root" style="${Tl(Ll)}">`+a(i,' aria-haspopup="menu" aria-expanded="false"')+`<span class="d3plus-save-menu${c}" role="menu" aria-label="${Ls(i)}" style="${Tl(r.menu,Pl)}">${l}</span></span>`}const Wl=new WeakMap;function jl(e){return e instanceof Element?e.closest(".save-root"):null}function Hl(e){return e.querySelector(".save-toggle")}function Il(e){return Array.from(e.querySelectorAll(".save-menu-item"))}function Gl(e){return"true"===Hl(e)?.getAttribute("aria-expanded")}function Vl(e,t,n){const i=Hl(t),o=t.querySelector(".d3plus-save-menu");if(!i||!o)return;i.setAttribute("aria-expanded",String(n)),i.classList.toggle("active",n),Bl(e,i,i.matches(":hover"));const a=n?Rl:Pl;o.style.setProperty("display",String(a.display))}function ql(e,t,n=!1){Wl.get(t)?.(),Wl.delete(t),Vl(e,t,!1),n&&Hl(t)?.focus()}function Yl(e,t,n="first"){Vl(e,t,!0);const i=t.ownerDocument,o=n=>{t.isConnected&&t.contains(n.target)||ql(e,t)};Wl.get(t)?.(),i.addEventListener("pointerdown",o,!0),Wl.set(t,()=>i.removeEventListener("pointerdown",o,!0));const a=Il(t);a["last"===n?a.length-1:0]?.focus()}function Kl(e,t,n){const i=t.target.closest(".save-menu-item");i&&function(e,t,n){const{item:i,itemHover:o}=Nl(e);Fs(t,{base:{...i,...El},hover:o},n,!1)}(e,i,n)}function Ul(e){return function(e){return Boolean(e.schema.saveControl)&&!e._ssr&&Dl(e).length>0}(e)?{key:"save",html:Ol(e),styleSignature:JSON.stringify(Fl(e)),events:{".save-toggle":{click:t=>function(e,t){const n=jl(t.target),i=n&&Hl(n);if(!n||!i)return;const o=i.dataset.format;o?Al(e,o):Gl(n)?ql(e,n,!0):Yl(e,n)}(e,t),keydown:t=>function(e,t){const n=t.key,i=jl(t.target);i&&i.querySelector(".d3plus-save-menu")&&("ArrowDown"===n||"ArrowUp"===n?(t.preventDefault(),Yl(e,i,"ArrowUp"===n?"last":"first")):"Escape"===n&&Gl(i)&&(t.stopPropagation(),ql(e,i,!0)))}(e,t)},".d3plus-save-menu":{keydown:t=>function(e,t){const n=t.key,i=jl(t.target);if(!i)return;const o=Il(i),a=o.indexOf(t.target),r=e=>{t.preventDefault(),o[(e+o.length)%o.length]?.focus()};"ArrowDown"===n?r(a+1):"ArrowUp"===n?r(a-1):"Home"===n?r(0):"End"===n?r(o.length-1):"Escape"===n?(t.preventDefault(),t.stopPropagation(),ql(e,i,!0)):"Tab"===n&&ql(e,i)}(e,t)},".save-menu-item":{click:t=>function(e,t){const n=jl(t.target),i=t.target.closest(".save-menu-item");n&&i&&(ql(e,n,!0),Al(e,i.dataset.format))}(e,t),mouseover:e=>function(e){e.target.closest(".save-menu-item")?.focus()}(e),focusin:t=>Kl(e,t,!0),focusout:t=>Kl(e,t,!1)},".save-root":{focusout:t=>function(e,t){const n=jl(t.target),i=t.relatedTarget;n&&i&&!n.contains(i)&&Gl(n)&&ql(e,n)}(e,t)}},onUpdate:t=>{const n=t.querySelector(".save-toggle");n&&!n.dataset.saveBound&&(n.dataset.saveBound="1",Bl(e,n),n.addEventListener("mouseenter",()=>Bl(e,n,!0)),n.addEventListener("mouseleave",()=>Bl(e,n)))}}:null}function Xl(e){return Boolean(e._searchOpen)}function Ql(e){return Bs(e.schema,"searchControl",{base:ys,active:xs,hover:bs})}function Zl(e,t,n=!1){Fs(t,Ql(e),n,t.classList.contains("active"))}const Jl=`<svg ${Ns}><circle cx="10" cy="9" r="7"/><line x1="21" y1="20" x2="15" y2="14"/></svg>`,eh=`<svg ${Ns}><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg>`,th={width:"0",padding:"0",border:"none",opacity:"0","pointer-events":"none"},nh={width:"120px",padding:"0 22px 0 6px",border:"1px solid #ccc","border-radius":"3px",opacity:"1","pointer-events":"auto"},ih={height:"20px","box-sizing":"border-box",margin:"0",font:`12px/1 ${a.fontFamilyStringify(a.fontFamily)}`,transition:"width 0.15s ease, opacity 0.15s ease"},oh={position:"relative",display:"inline-block"},ah={display:"inline-flex","align-items":"center"},rh={position:"absolute",top:"50%",right:"2px",transform:"translateY(-50%)",display:"inline-flex","align-items":"center","justify-content":"center",visibility:"visible",width:"16px",height:"16px",margin:"0",padding:"0",border:"none",background:"none",cursor:"pointer"},sh={...rh,visibility:"hidden",cursor:"default"},ch={position:"absolute",top:"100%",left:"0","margin-top":"4px",width:"100%","box-sizing":"border-box",display:"block",visibility:"visible",background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)",color:"rgba(0, 0, 0, 0.75)","font-size":"11px","text-align":"center",padding:"2px 4px","white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis","pointer-events":"none"},lh={...ch,visibility:"hidden"};function hh(e){return Object.entries(e).map(([e,t])=>`${$s(e)}:${t}`).join(";")}function uh(e,t){const n=t?nh:th;for(const t in n)e.style.setProperty($s(t),n[t])}function dh(e){const t=e.schema.searchControlClassName?` ${e.schema.searchControlClassName}`:"",n=e.schema.translate("Search"),i=Xl(e),o=e._searchTerm||"",a=o.trim().length>0,r=hh({...ih,...i?nh:th}),s=hh(a?rh:sh),c=hh(oh);return`<span class="search-root" style="${hh(ah)}"><button type="button" class="search-control search-toggle${i?" active":""}${t}" aria-label="${n}" aria-pressed="${i}">${Jl}</button><span class="search-input-wrap" style="${c}"><input type="text" class="search-control search-input" placeholder="${n}" aria-label="${n}" value="${Ls(o)}" style="${r}"${i?"":' tabindex="-1"'}/><button type="button" class="search-control search-clear" aria-label="${e.schema.translate("Clear")}" style="${s}"${a?"":' tabindex="-1"'}>${eh}</button><span class="search-count" aria-live="polite"></span></span></span>`}function fh(e,t,n,i){const o=e.schema.searchAccessor(t,n);if("string"==typeof o&&o.toLowerCase().includes(i))return!0;return e._ids(t,n).some(e=>"string"==typeof e&&e.toLowerCase().includes(i))}function mh(e,t){const n=t.trim().toLowerCase();if(!n)return[];const i=[];return Ze(e._chartScene||[],(t,o,a)=>{fh(e,t,o,n)&&i.push({node:a,row:t,index:o})}),i}function ph(e,t){const n=dh(e),o=function(e){const t=e._featurePanels??[];for(const e of t){if("viz-top-left-controls"!==e?.key||!e.children)continue;const t=e.children.find(e=>"viz-top-left-controls-search"===e.key);if(t)return t}return null}(e);o&&(o.html=n),i.markOverlayHtmlSynced(t,n)}function gh(e,t){const n=t.querySelector(".search-count");if(!n)return;const i=e._searchTerm||"",o=i.trim().length>0,a=o?mh(e,i).length:0;"number"==typeof e._searchMatchIndex&&e._searchMatchIndex>=a&&(e._searchMatchIndex=void 0),function(e,t,n,i,o){const a=n?ch:lh;for(const e in a)t.style.setProperty($s(e),a[e]);const{text:r,label:s}=function(e,t,n){let i;return i=0===n?e.schema.translate("No Matches"):"number"!=typeof t?`${n} ${e.schema.translate(1===n?"Match":"Matches")}`:`${e.schema.translate("Match")} ${t+1}/${n}`,{text:i,label:i}}(e,i,o);t.textContent=n?r:"",t.setAttribute("aria-label",s)}(e,n,o,e._searchMatchIndex,a)}function yh(e,t,n){const i=n.trim().length>0;e._searchMatchIndex=void 0;const o=t.querySelector(".search-clear");o&&function(e,t){const n=t?rh:sh;for(const t in n)e.style.setProperty($s(t),n[t]);e.tabIndex=t?0:-1}(o,i),gh(e,t)}function xh(e,t){e._searchOpen=!1,e._searchTerm="",e.highlight(e._searchPrevHighlight??!1),e._searchPrevHighlight=void 0,ph(e,t),yh(e,t,"");const n=t.querySelector(".search-toggle");n&&(n.classList.remove("active"),n.setAttribute("aria-pressed","false"),Zl(e,n,n.matches(":hover")));const i=t.querySelector(".search-input");i&&(i.value="",i.setAttribute("tabindex","-1"),uh(i,!1))}function bh(e,t){const n=t.currentTarget;Xl(e)?xh(e,n):function(e,t){e._searchOpen=!0,e._searchPrevHighlight=e._highlight,ph(e,t);const n=t.querySelector(".search-toggle");n&&(n.classList.add("active"),n.setAttribute("aria-pressed","true"),Zl(e,n,n.matches(":hover")));const i=t.querySelector(".search-input");i&&(i.removeAttribute("tabindex"),uh(i,!0),i.focus())}(e,n)}function _h(e,t,n){e._searchTerm=n,e.highlight(function(e,t){const n=t.trim().toLowerCase();return n?(t,i)=>fh(e,t,i,n):e._searchPrevHighlight??!1}(e,n)),ph(e,t),yh(e,t,n)}function kh(e,t,n){if("canvas"===e._renderer||"function"!=typeof e._zoomToBounds)return;const i=t.parentElement?.parentElement,o=i?.querySelector("svg");if(!i||!o)return;const a=function(e,t){const n=e.querySelectorAll("[data-key]");for(const e of n)if(e.getAttribute("data-key")===String(t))return e;return null}(i,n);if(!a)return;const r=a.getBoundingClientRect(),s=o.getBoundingClientRect();(r.width||r.height)&&e._zoomToBounds([[r.left-s.left,r.top-s.top],[r.right-s.left,r.bottom-s.top]],e.schema.duration)}function vh(e,t){const n=t,i=t.currentTarget;"Escape"===n.key?xh(e,i):"Enter"===n.key&&(n.preventDefault(),function(e,t,n){const i=e._searchTerm||"";if(!i.trim())return;const o=mh(e,i);if(!o.length)return;const a=o.length,r=e._searchMatchIndex,s=(("number"==typeof r?r:1===n?-1:0)+n+a)%a;e._searchMatchIndex=s,gh(e,t),kh(e,t,o[s].node.key)}(e,i,n.shiftKey?-1:1))}function wh(e){return function(e){return Boolean(e.schema.search)&&!e._ssr}(e)?{key:"search",html:dh(e),styleSignature:JSON.stringify(Ql(e)),events:{".search-toggle":{click:t=>bh(e,t)},".search-clear":{click:t=>function(e,t){const n=t.currentTarget,i=n.querySelector(".search-input");i&&(i.value=""),_h(e,n,""),i?.focus()}(e,t)},".search-input":{input:t=>function(e,t){const n=t.target;_h(e,t.currentTarget,n.value)}(e,t),keydown:t=>vh(e,t)}},onUpdate:t=>{gh(e,t);const n=t.querySelector(".search-toggle");n&&!n.dataset.searchBound&&(n.dataset.searchBound="1",Zl(e,n),n.addEventListener("mouseenter",()=>Zl(e,n,!0)),n.addEventListener("mouseleave",()=>Zl(e,n)));const i=t.querySelector(".search-input");i&&!i.dataset.searchBlurBound&&(i.dataset.searchBlurBound="1",i.addEventListener("blur",n=>function(e,t,n){if((e._searchTerm||"").trim().length>0)return;const i=n.relatedTarget;i&&t.contains(i)||xh(e,t)}(e,t,n)))}}:null}function Sh(e,t){if(!t.length)return null;const n=t.map(e=>`${e.key}:${e.html}|${e.styleSignature??""}`).join("||"),i=e._topLeftControlsBox;if(i&&i.signature===n)return i.measurement;const o=function(e,t){const n=qs(e);if(!n){let e=0;return{items:t.map(t=>{const n={...t,x:e};return e+=32,n}),width:Math.max(0,e-4),height:20}}const i=document.createElement("div");i.className="d3plus-top-left-controls",i.style.setProperty("display","inline-flex"),i.style.setProperty("align-items","center"),i.style.setProperty("gap","4px"),i.style.setProperty("position","absolute"),i.style.setProperty("visibility","hidden"),i.style.setProperty("pointer-events","none"),i.innerHTML=t.map(e=>`<span class="tlc-item" data-tlc-key="${e.key}" style="display:inline-flex;align-items:center;">${e.html}</span>`).join("");for(const e of t)e.onUpdate?.(i);n.appendChild(i);const o=i.getBoundingClientRect(),a=Array.from(i.querySelectorAll(":scope > .tlc-item")),r=t.map((e,t)=>{const n=a[t]?.getBoundingClientRect();return{...e,x:n?Math.round(n.left-o.left):0}});return n.removeChild(i),{items:r,width:o.width?Math.ceil(o.width):0,height:o.height?Math.ceil(o.height):0}}(e,t);return e._topLeftControlsBox={width:o.width,height:o.height,signature:n,measurement:o},o}function Ch(e,t){const n=Sh(e,t);return n?{type:"group",key:"viz-top-left-controls",children:n.items.map(e=>({type:"htmlOverlay",key:`viz-top-left-controls-${e.key}`,x:4+e.x,y:4,className:"d3plus-top-left-controls-item",html:e.html,events:e.events,onUpdate:e.onUpdate}))}:null}function Mh(e,t){const n=Sh(e,t);return n?{width:n.width?n.width+4:0,height:n.height?n.height+4:0}:null}function $h(e,t){const n=Mh(e,t);return n&&n.height?n.height+4:0}const Ah=[Bc,gl,Ul,wh];function zh(e){const t=[];for(const n of Ah){const i=n(e);i&&t.push(i)}return t}const Dh={name:"topLeftControls",layout:({viz:e})=>{const t=zh(e);return t.length?{panel:Ch(e,t),margin:{}}:{panel:null,margin:{}}}};function Fh(e){const t="function"==typeof e.config?e.config():{};return Object.freeze(t)}function Bh(e){const t=e._legendData||[],n=(t,n,i)=>{const o=e.schema.shape(t,n);"fill"===i&&"Line"===o&&(i="stroke");const a=e.schema.shapeConfig[o]&&e.schema.shapeConfig[o][i]?e.schema.shapeConfig[o][i]:e.schema.shapeConfig[i];return"function"==typeof a?a.bind(e)(t,n):a},i=(t,n)=>"function"==typeof e.schema.color?e.schema.color(t,n):void 0,a=(e,t,i)=>[null==i?n(e,t,"fill"):"string"==typeof i?i:JSON.stringify(i),n(e,t,"opacity"),n(e,t,"texture")].join("_"),r=e.schema.colorScale?t.filter((t,n)=>void 0===e.schema.colorScale(t,n)):t,s=new Map;r.forEach((e,t)=>{const n=i(e,t),o=a(e,t,n),r=s.get(o);r?r.leaves.push(e):s.set(o,{leaves:[e],color:n})});const c=Array.from(s.values(),({leaves:t,color:n})=>({datum:o.merge(t,e.schema.aggs),color:n})),l=c.map(e=>e.datum),h=l.map((t,n)=>e._ids(t,n).slice(0,e._drawDepth+1));e._legendDepth=0;for(let t=0;t<=e._drawDepth;t++){const n=h.map(e=>e[t]);if(!n.some(e=>Array.isArray(e))&&Array.from(new Set(n)).length===l.length){e._legendDepth=t;break}}e._legendCategories=function(e,t){const n=e.schema.groupBy?.[e._legendDepth??0];return"function"==typeof n&&t.some((t,i)=>{const o=n.bind(e)(t,i);return Array.isArray(o)&&o.length>1})}(e,l)?function(e){const t=new WeakMap,n=new Set;for(const{datum:i,color:o}of e){const e=lr(o);if(void 0===e||n.has(e))return;n.add(e),t.set(i,e)}return t}(c):void 0;const u=e=>e._isAggregation?1:0;return l.sort((t,n)=>u(t)-u(n)||e.schema.legendSort(t,n)),{legendData:l,legendKey:(e,t)=>a(e,t,i(e,t)),getAttr:n}}function Lh(e,t,i){const{legendData:o,legendKey:a,getAttr:r}=t,s=(t,n)=>{let i=e._id(t,n);return Array.isArray(i)&&(i=i[0]),e._hidden.includes(i)||e._solo.length>0&&!e._solo.includes(i)},c={transform:`translate(${i.x}, ${i.y})`},l=n.elem("g.d3plus-viz-legend",{condition:i.visible&&!e.schema.legendConfig.select,enter:c,parent:e._select,duration:0,update:c}).node();e._legendClass.renderMode("compute").id(a).align(i.align).direction(i.direction).duration(e.schema.duration).data(i.visible?o:[]).height(i.height).locale(e.schema.locale).parent(e).select(l).shape((t,n)=>{const i=e.schema.shape(t,n);return"Circle"===i||"Line"===i?i:"Rect"}).verticalAlign(i.verticalAlign).width(i.width).shapeConfig(Ae.bind(e)(e.schema.shapeConfig,"legend")).shapeConfig({fill:(t,n)=>s(t,n)?e.schema.hiddenColor(t,n):r(t,n,"fill"),labelConfig:{fontOpacity:(t,n)=>s(t,n)?e.schema.hiddenOpacity(t,n):1}}).config(e.schema.legendConfig).render()}function Ph(e){const{width:t,height:n}=e.outerBounds();return!(!t||!n)&&(e._lineData||[]).every(e=>{if(!e.sentence)return!0;const t=e.lines.length;return e.width>0&&!e.truncated&&t<=`${e.sentence}`.split("\n").length&&e.height<=e.og.height})}function Rh(e,t){const n=Fh(e);return!1!==yu(e.schema.legendPosition.bind(e)(n),e)&&Boolean(e.schema.legend.bind(e)(n,t.legendData))}function Eh(e,t,n,i=Bh(e)){const o=Rh(e,i)&&!e.schema.legendConfig.select;if(Lh(e,i,{x:0,y:0,...Xa(t,n),align:"left",direction:t,verticalAlign:"top",visible:o}),!o)return null;const a=e._legendClass,r=(a._lineData||[]).every(e=>e.width>0),{width:s,height:c}=a.outerBounds();return r&&s&&c?{width:s,height:c}:null}function Nh(e,t,n){if(Ya(e,"legend"))return Eh(e,Ua(e,"legend"),{width:e.schema.width-n.left-n.right,height:e.schema.height-n.top-n.bottom},t),{panel:null,margin:{}};const i=Fh(e),o=yu(e.schema.legendPosition.bind(e)(i),e),a=["top","bottom"].includes(o),r=e.schema.legendPadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},{drop:s,insetRight:c,shorten:l}=function(e,t,n,i){const o=vu(e,t,n.top,"left"===t?n.left:n.right),a=nc(e,t,n.bottom+i.bottom,n.right+i.right);return{drop:o,insetRight:a.inset,shorten:a.drop}}(e,o,n,r),h={x:a?n.left+r.left:n.left,y:(a?n.top:n.top+r.top)+s,width:(a?e.schema.width-(n.left+n.right+r.left+r.right):e.schema.width-(n.left+n.right))-c,height:(a?e.schema.height-(n.bottom+n.top):e.schema.height-(n.bottom+n.top+r.bottom+r.top))-s-l,align:a?"center":o,direction:a?"row":"column",verticalAlign:a?o:"middle",visible:Rh(e,t)};let u=0;"top"===o?u=function(e,t,n,i,o){const a=n.visible&&!e.schema.legendConfig.select?Su(e,i,n.x,o,!0):[{left:0,right:0,drop:0}];for(const[i,{left:o,right:r,drop:s}]of a.entries())if(Lh(e,t,{...n,x:n.x+o,y:n.y+s,width:n.width-o-r,height:n.height-s}),i===a.length-1||Ph(e._legendClass))return s;return 0}(e,t,h,n.top,n.right+r.right):Lh(e,t,h);const d=e._legendClass.outerBounds(),f={};return!e.schema.legendConfig.select&&d.height&&(f[o]=a?u+d.height+2*e._legendClass.padding():d.width+2*e._legendClass.padding()),{panel:null,margin:f}}const Th={name:"legend",configFields:["legend","legendConfig","legendPadding","legendPosition","legendSort"],layout:({viz:e,layoutMargin:t})=>Nh(e,Bh(e),t)};function Oh(e){const t=e.schema.filter,n=e._filterApplied;return t&&n?(e,i)=>n(e)||t(e,i):t}function Wh(e){if(!e.schema.timeline)return{min:1,max:1/0};const t=e.schema.timelineConfig||{},n=co(t.brushMin,t.brushMax);return!1===t.brushing?{...n,min:1}:n}function jh(e,t,i){const o=[...new Set(t.map(Number))].sort((e,t)=>e-t);if(o.length<=i)return()=>!0;const a=o[o.length-i],r=e.schema.time;return(e,t)=>+n.date(r(e,t))>=a}function Hh(e){let t;if(e.schema.time&&!e.schema.timeFilter&&e._data.length){const i=e._data.map(e.schema.time).map(e=>n.date(e)),o=e._data[0],a=0;t=e.schema.discrete&&`_${e.schema.discrete}`in e&&e[`_${e.schema.discrete}`](o,a)===e.schema.time(o,a)?jh(e,i,Wh(e).max):jh(e,i,Math.max(1,Math.ceil(Wh(e).min)))}return t}function Ih(e,t,n,i,a,r=e._data){const s=[],c=[];if(r.length){const l=e.schema.timeFilter||a;let u=l?r.filter(l):r;const d=Oh(e);d&&(u=u.filter(d));const f=[];for(let t=0;t<=n;t++)f.push(e.schema.groupBy[t]);f.push(...function(e){const t=e.schema.discrete;if(!t)return[];const n=[],i=e;for(const o of[t,`${t}2`])`_${o}`in e?n.push(i[`_${o}`]):"function"==typeof e.schema[o]&&n.push(e.schema[o]);return n}(e));const m=h.rollup(u,t=>{const n=e._data.indexOf(t[0]),a=e.schema.shape(t[0],n),r=i(t[0],n),l=e._mergeRows?e._mergeRows(t):o.merge(t,e.schema.aggs);e._hidden.includes(r)||e._solo.length&&!e._solo.includes(r)||(e.schema.discrete||"Line"!==a?s.push(l):s.push(...t)),c.push(l)},...f);t.filteredData=s,t._thresholdTree=m}else t.filteredData=s;t.legendData=c}function Gh(e){return e instanceof Date?""+ +e:`${e}`}function Vh(e){if(null!=e&&""!==e)return e instanceof Date||"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e:`${e}`}function qh(e,t){const n=e instanceof Date?+e:e,i=t instanceof Date?+t:t;return"number"==typeof n&&"number"==typeof i?n-i:`${e}`.localeCompare(`${t}`,void 0,{numeric:!0})}function Yh(e,t){const n=e.slice();if(Array.isArray(t)){const e=new Map(t.map((e,t)=>[Gh(e),t])),i=t=>e.get(Gh(t))??1/0;return n.sort((e,t)=>i(e)-i(t))}return"function"==typeof t?n.sort(t):"data"===t?n:(n.sort(qh),"descending"===t?n.reverse():n)}function Kh(e,t,n){const i=new Map;e.forEach((e,n)=>{const o=Vh(t(e,n));if(void 0===o)return;const a=Gh(o);let r=i.get(a);r||i.set(a,r={key:a,value:o,rows:[]}),r.rows.push(e)});const o=new Map(Array.from(i.values()).map(e=>[e.key,e]));return Yh(Array.from(i.values()).map(e=>e.value),n).map(e=>o.get(Gh(e)))}function Uh(e,t){const n=e.schema.facet;if(!n)return[];const i=e._data||[],o=Oh(e);return Kh(o?i.filter(o):i,n,t)}function Xh(e,t,n){const i={};Ih(e,i,e._drawDepth,e._id,n,t);let o=i.filteredData??[];return t.length&&i._thresholdTree&&e._thresholdFunction&&(o=e._thresholdFunction(o,i._thresholdTree,e._thresholdRows??i.legendData)),o}function Qh(e){return Hh(e)}function Zh(e,t){if(e instanceof Date){const n=t.filter(e=>e instanceof Date).sort((e,t)=>+e-+t);return d.formatDate(e,n)}return`${e}`}const Jh=E,eu=e=>new Jh[e];function tu(e,t,n){return"function"==typeof e?e(t,n):e}function nu(e,t,n,i){const o=Do(tu(e.texture,t,n),()=>i,()=>tu(e.stroke,t,n),e.textureDefault);return o?`pattern:${o}`:"string"==typeof i?i:void 0}function iu(e,t,n){const i=tu(e.fill,t,n),o=tu(e.stroke,t,n),a=tu(e.strokeWidth,t,n),r=tu(e.opacity,t,n),s=tu(e.vectorEffect,t,n);return{fill:nu(e,t,n,i),stroke:o,strokeWidth:a,opacity:r,vectorEffect:"none"===s||"non-scaling-stroke"===s?s:void 0}}function ou(e,t,n){return e._drawLabel(t.data??t,t.i??n)}function au(e,t,n,i="shape"){return Ae.bind(e)(n??e.schema.shapeConfig,i,t)}function ru(e,t){const n=e.schema.shapeConfig??{},i=e=>e&&"object"==typeof e?e.labelConfig:void 0,o={...i(n),...i(n[t])};for(const e in o)ar(o[e])&&delete o[e];const{labelConfig:a}=au(e,t,{labelConfig:o});return a??{}}function su(e,t={}){if(!e)return[];const n=!1!==t.shape,i=!1!==t.labels;try{e.render();const t=[];if(n&&"function"==typeof e.toScene){const n=e.toScene();n&&Array.isArray(n.children)&&t.push(...n.children)}if(i){const n=e._labelClass;if(n&&"function"==typeof n.toScene){const e=n.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}return t}catch{return[]}}const cu=["fillOpacity","opacity","stroke","strokeDasharray","strokeLinecap","strokeOpacity","strokeWidth"];function lu(e){let t;const n=new Map,i=(i,o)=>{void 0===t&&(t=function(e){const t=La(e);if(!t)return null;const n=new Map;return t.rows.forEach((e,i)=>{const o=t.colorOf(e,i);n.has(o)||n.set(o,{row:e,i:i})}),n}(e));const a=t?.get(i.color)??t?.values().next().value;if(!a)return;const{row:r,i:s}=a,c=e._colorScaleShape(r,s),l="Line"===c?"":c;return n.has(l)||n.set(l,au(e,l)),tu(n.get(l)[o],r,s)};return Object.fromEntries(cu.map(e=>[e,t=>i(t,e)]))}function hu(e,t,i){const a={opacity:t.orient?1:0,transform:`translate(${t.x}, ${t.y})`},r=n.elem("g.d3plus-viz-colorScale",{condition:i&&!e.schema.colorScaleConfig.select,enter:a,parent:e._select,duration:0,update:a}).node();e.schema.colorScale&&e._colorScaleClass.renderMode("compute").align(t.align).duration(e.schema.duration).data(function(e){const t=e.schema.facet;return Array.from(h.rollup(e._data,t=>o.merge(t,e.schema.aggs),(n,i)=>`${e.schema.time?e.schema.time(n,i):"all"}-${t?Gh(t(n,i)):"all"}-${e._ids(n,i).join("_")}`).values()).filter((t,n)=>null!=e.schema.colorScale(t,n))}(e)).height(t.height).locale(e.schema.locale).orient(t.orient).select(r).value(e.schema.colorScale).width(t.width).legendConfig({shapeConfig:lu(e)}).config(e.schema.colorScaleConfig).hover(!1).render()}function uu(e){return yu(e.schema.colorScalePosition.bind(e)(Fh(e)),e)}function du(e,t,n){const i=Boolean(e.schema.colorScale)&&!1!==uu(e)&&!e.schema.colorScaleConfig.select,o=Xa(t,n),a=e.schema.colorScaleMaxSize;if(hu(e,{x:0,y:0,width:"row"===t?h.min([a,o.width]):o.width,height:"column"===t?h.min([a,o.height]):o.height,orient:"column"===t?"right":"bottom",align:"start"},i),!i)return null;const{width:r,height:s}=e._colorScaleClass.outerBounds();return r&&s?{width:r,height:s}:null}const fu={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:e,layoutMargin:t})=>{if(Ya(e,"colorScale"))return du(e,Ua(e,"colorScale"),{width:e.schema.width-t.left-t.right,height:e.schema.height-t.top-t.bottom}),{panel:null,margin:{}};const n=uu(e),i=["top","bottom"].includes(n),o=e.schema.colorScale&&n,a=e.schema.colorScalePadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},r=vu(e,n,t.top,"left"===n?t.left:t.right),s=nc(e,n,t.bottom+a.bottom,t.right+a.right),c=e.schema.width-(t.left+t.right+a.left+a.right)-s.inset,l=i?h.min([e.schema.colorScaleMaxSize,c]):e.schema.width-(t.left+t.right),u=e.schema.height-(t.bottom+t.top+a.bottom+a.top)-r-s.drop,d=i?e.schema.height-(t.bottom+t.top):h.min([e.schema.colorScaleMaxSize,u]);hu(e,{x:i?t.left+a.left+(c-l)/2:t.left,y:i?t.top:t.top+a.top+r+(u-d)/2,width:l,height:d,orient:n,align:{bottom:"end",left:"start",right:"end",top:"start"}[n]||"bottom"},Boolean(o));const f={};if(o){const t=e._colorScaleClass.outerBounds();if(!e.schema.colorScaleConfig.select&&t.height){const o="function"==typeof e._colorScaleClass.padding?e._colorScaleClass.padding():e._legendClass.padding();f[n]=i?t.height+2*o:t.width+2*o}}return{panel:null,margin:f}}};function mu(e,t){const n=e.querySelector(".d3plus-attribution-text"),i=e.querySelector(".d3plus-attribution-toggle");n&&(n.style.display=t?"":"none"),i&&i.setAttribute("aria-expanded",String(t)),e.style.borderRadius="3px 0 0 0",e.style.padding=t?"4px 6px":"2px"}const pu={name:"attribution",configFields:["attribution","attributionIcon","attributionStyle"],layout:({viz:e})=>{let i=t.select(e._select.node().parentNode).selectAll("div.d3plus-attribution").data(e.schema.attribution?[0]:[]);const o=i.enter().append("div").attr("class","d3plus-attribution");i.exit().remove();const a=e._basemapDark?function(e){const t=as,n=rs,i={...e};for(const e of Object.keys(n))i[e]===t[e]&&(i[e]=n[e]);return i}(e.schema.attributionStyle):e.schema.attributionStyle;i=i.merge(o).style("position","absolute").style("right",`${e._margin.right}px`).style("bottom",`${e._margin.bottom}px`).call(n.stylize,a);const r=`<span class="d3plus-attribution-text">${e.schema.attribution}</span><button type="button" class="d3plus-attribution-toggle" aria-label="${e.schema.translate("Attribution")}" aria-expanded="true">${function(e){const t=e.schema.attributionIcon;return"string"==typeof t?t:"function"==typeof t?'<span class="d3plus-attribution-icon" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" style="width:12px;height:12px;display:block"><circle cx="12" cy="12" r="10"/><line x1="12" y1="11" x2="12" y2="17"/><line x1="12" y1="7" x2="12" y2="7.01"/></svg>'}(e)}</button>`,s=i.node();if(s&&s.__d3plusHTML!==r){s.innerHTML=r,s.__d3plusHTML=r,s.querySelectorAll("a").forEach(e=>{e.style.color="inherit",e.style.textDecoration="none"});const t=s.querySelector(".d3plus-attribution-toggle");t&&(t.style.border="0",t.style.background="transparent",t.style.color="inherit",t.style.margin="0",t.style.padding="0",t.style.flexShrink="0"),function(e,t){const n=e.schema.attributionIcon;if("function"!=typeof n)return;const i=t.querySelector(".d3plus-attribution-icon");i&&(e._attributionIconCleanup?.(),e._attributionIconCleanup=n(i)||void 0)}(e,s)}const c=i.node();if(!c)return{panel:null,margin:{}};const{width:l}=ie(e);c.style.maxWidth=`${Math.min(280,l)}px`;const h=c.querySelector(".d3plus-attribution-text");h.style.whiteSpace="nowrap";const u=h.getBoundingClientRect().width>.5*l;h.style.whiteSpace="";const d=t.select(c).select(".d3plus-attribution-toggle").style("display",u?"":"none");if(!u)return t.select(c).on(".compact",null),mu(c,!0),{panel:null,margin:{}};const f=()=>mu(c,Boolean(e._attributionPinned||c.matches(":hover, :focus-within")));return t.select(c).on("mouseenter.compact focusin.compact",()=>mu(c,!0)).on("mouseleave.compact focusout.compact",()=>window.setTimeout(f,0)),d.on("click.compact",()=>{e._attributionPinned=!e._attributionPinned,mu(c,e._attributionPinned)}),mu(c,Boolean(e._attributionPinned)),{panel:null,margin:{}}}},gu=new Set([!1,"top","right","bottom","left"]);function yu(e,t){return"auto"===e?function(e){return e.schema.width>1.5*e.schema.height?"right":"bottom"}(t):gu.has(e)?e:"bottom"}function xu(e,t,n={top:0,right:0,bottom:0,left:0}){const i={top:0,right:0,bottom:0,left:0},o=[];for(const a of t){if(!a.layout)continue;const t={top:n.top+i.top,right:n.right+i.right,bottom:n.bottom+i.bottom,left:n.left+i.left},r=a.layout({...e,layoutMargin:t}),{panel:s,margin:c,vizUpdate:l}=r;if(s&&o.push(s),i.top+=c.top??0,i.right+=c.right??0,i.bottom+=c.bottom??0,i.left+=c.left??0,l&&e.viz){const t=e.viz;for(const e of Object.keys(l)){t[e.startsWith("_")?e:`_${e}`]=l[e]}}}return{panels:o,margin:i}}const bu=6;function _u(e,t,n){const i=Us(e);if(!i||t>=Xs(e))return 0;const o=i.width-n;return o>0?o+bu:0}function ku(e,t,n){const i=function(e,t,n,i){const o=Mh(e,i);return!o||t>=$h(e,i)?0:Math.max(0,o.width-n)}(e,t,n,zh(e));return i>0?i+bu:0}function vu(e,t,n,i){return"right"===t&&_u(e,n,i)?Xs(e)-n:"left"===t&&ku(e,n,i)?$h(e,zh(e))-n:0}function wu(e){return Math.max(Xs(e),$h(e,zh(e)))}function Su(e,t,n,i,o){const a=function(e,t,n,i){const o=ku(e,t,n),a=_u(e,t,i);return{left:o,right:a,symmetric:Math.max(o,a)}}(e,t,n,i);if(!a.left&&!a.right)return[{left:0,right:0,drop:0}];const r=[];return o&&a.left!==a.right&&r.push({left:a.symmetric,right:a.symmetric,drop:0}),r.push({left:a.left,right:a.right,drop:0}),r.push({left:0,right:0,drop:Math.max(0,wu(e)-t)}),r}function Cu(e,t){const{viz:n,layoutMargin:i}=e,o=t.getText(n);if(!o)return{panel:null,margin:{}};const a=n.schema[t.paddingMethod](n)?n._padding:{right:0,left:0},r=n[t.textClassKey];r.data([{text:o}]).locale(n.schema.locale).config(n.schema[t.configKey]);const{x:s,width:c,drop:l,boxes:h}=function(e,t,n,i,o,a){const r=t.split(),s=(e,n,i)=>{t.width(n);const o=()=>{const o=t._textData();return{x:e,width:n,drop:i,boxes:o,lines:o[0]?.lines??[],truncated:!o.length||o[0].truncated}};return Ft(o(),()=>{t.split(zt(r));const e=o();return t.split(r),e})},c=s(i,a,0).result;if(!c.boxes.length)return c;const l=Su(e,n,i,o,"middle"===c.boxes[0].tA);if(1===l.length)return c;for(const[e,{left:t,right:n,drop:o}]of l.entries()){const{fits:r,result:c}=s(i+t,a-t-n,o);if(r||e===l.length-1)return c}return c}(n,r,i.top,i.left+a.left,i.right+a.right,n.schema.width-(i.left+i.right+a.left+a.right));if(!h.length)return{panel:null,margin:{}};const u=h[0],d=u.lH,f=n.schema[t.configKey]?.padding??0,m=u.lines.length*d+2*f,p=i.top+l+f,g=u.lines.map((e,t)=>({text:e,x:"middle"===u.tA?c/2:"end"===u.tA?c:0,y:(t+1)*d-(d-u.fS),width:u.widths?.[t]??0}));return{panel:{type:"text",key:t.panelKey,x:0,y:0,lines:g,font:{family:u.fF,size:u.fS,anchor:"middle"===u.tA||"end"===u.tA||"start"===u.tA?u.tA:"start",baseline:"alphabetic"},paint:{fill:u.fC,opacity:u.fO},transform:{x:s,y:p}},margin:{top:l+m}}}const Mu={name:"title",configFields:["title","titleConfig","titlePadding"],layout:e=>Cu(e,{panelKey:"viz-title",getText:e=>!!e.schema.title&&e.schema.title(e._filteredData||[]),textClassKey:"_titleClass",configKey:"titleConfig",paddingMethod:"titlePadding"})},$u={name:"subtitle",configFields:["subtitle","subtitleConfig","subtitlePadding"],layout:e=>Cu(e,{panelKey:"viz-subtitle",getText:e=>!!e.schema.subtitle&&e.schema.subtitle(e._filteredData||[]),textClassKey:"_subtitleClass",configKey:"subtitleConfig",paddingMethod:"subtitlePadding"})};const Au={name:"timeline",configFields:["timeline","timelineConfig","timelinePadding"],layout:({viz:e,layoutMargin:t})=>{let i=e.schema.time&&e.schema.timeline;const a=i?o.unique(e._data.map(e.schema.time)).map(e=>n.date(e)):[];i=i&&a.length>1;const r=e.schema.timelinePadding(e)?e._padding:{right:0,left:0},s={transform:`translate(${t.left+r.left}, 0)`},c=n.elem("g.d3plus-viz-timeline",{condition:i,enter:s,parent:e._select,duration:e.schema.duration,update:s}).node();if(!i)return{panel:null,margin:{}};const l=e._timelineClass.renderMode("compute").domain(h.extent(a)).duration(e.schema.duration).height(e.schema.height-t.bottom).locale(e.schema.locale).select(c).ticks(a.sort((e,t)=>+e-+t)).width(e.schema.width-(t.left+t.right+r.left+r.right)),u=h.extent(a);if(e._timelineSelection)e._timelineSelection[0]<u[0]&&(e._timelineSelection[0]=u[0]),e._timelineSelection[1]>u[1]&&(e._timelineSelection[1]=u[1]);else{const t=h.extent((e._filteredData||[]).flatMap((t,n)=>e.schema.time(t,n)).map(e=>n.date(e)));e._timelineSelection=e.schema.timelineDefault||(t[0]?t:u)}l.selection(e._timelineSelection),l._onPlayToggle=()=>e._scheduleSceneRepaint();const d=e.schema.timelineConfig;return l.config(d).on("brush",e=>{d.on&&d.on.brush&&d.on.brush(e)}).on("end",t=>{!function(e,t){if(Array.isArray(t)||(t=[t,t]),JSON.stringify(t)!==JSON.stringify(e._timelineSelection)){e._timelineSelection=t;const i=t.map(Number);e.timeFilter(t=>{const o=n.date(e.schema.time(t)).getTime();return o>=i[0]&&o<=i[1]}).render()}}(e,t),d.on&&d.on.end&&d.on.end(t)}).render(),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},zu={name:"total",configFields:["total","totalConfig","totalFormat","totalPadding"],layout:e=>Cu(e,{panelKey:"viz-total",getText:e=>{const t=e._filteredData||[],n="function"==typeof e.schema.total?h.sum(t.map(e.schema.total)):!(!0!==e.schema.total||!e._size)&&h.sum(t.map(e._size));return!!n&&e.schema.totalFormat(n)},textClassKey:"_totalClass",configKey:"totalConfig",paddingMethod:"totalPadding"})};function Du(e,t,n){return e.schema.minimapClassName&&t===n?{}:t||{}}function Fu(e,...t){const n=new Set;for(const e of t)for(const t of Object.keys(e))n.add(t);for(const t of n)e.style.removeProperty($s(t));for(const n of t)for(const t in n){const i=n[t];null!=i&&!1!==i&&e.style.setProperty($s(t),String(i))}}function Bu(e){const t=e.schema.minimapClassName?` ${e.schema.minimapClassName}`:"";return`<div class="d3plus-minimap-viewport${t}" tabindex="0" aria-label="${e.schema.translate("Pan viewport — drag or use arrow keys")}"></div><div class="d3plus-minimap-label${t}"></div>`}function Lu(e){const t=function(e){return e._zoomEventTarget||e._container}(e)?.node();return t?b.zoomTransform(t):b.zoomIdentity}function Pu(e){const t=e._plotZoomBase?.scales;return t?{x:Boolean(t.x||t.x2),y:Boolean(t.y||t.y2)}:{x:!0,y:!0}}const Ru={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function Eu(e,t,n,i,o){const[[a,r],[s,c]]=e._zoomBehavior.translateExtent(),l=Pu(e),h=Lu(e);_c(e,i,l.x?(a+s)/2-t*i:h.x,l.y?(r+c)/2-n*i:h.y,o)}function Nu(e,t,n,i,o){const[[a,r],[s,c]]=e._zoomBehavior.translateExtent();return[a+i/t*(s-a),r+o/n*(c-r)]}function Tu(e,t,n,i,o,a){const r=a.parentElement,s=r?.querySelector(".d3plus-minimap-label");if(!r||!s)return;const c=Lu(e),l=c.k>1;if(Fu(r,i.outer),Fu(r,{position:"absolute","box-sizing":"border-box",overflow:"hidden",opacity:l?"1":"0","pointer-events":l?"auto":"none",transition:`opacity ${e.schema.duration}ms`}),!l)return;const[[h,u],[d,f]]=e._zoomBehavior.translateExtent(),m=d-h,p=f-u,g=Math.min(1,1/c.k),y=Pu(e),x=y.x?g:1,b=y.y?g:1,_=(h-c.x)/c.k,k=(u-c.y)/c.k,v=Math.max(0,Math.min(1-x,m?(_-h)/m:0)),w=Math.max(0,Math.min(1-b,p?(k-u)/p:0));Fu(a,i.viewport,o.dragging?i.viewportActive:{}),Fu(a,{position:"absolute","box-sizing":"border-box","touch-action":"none",left:v*t+"px",top:w*n+"px",width:`${Math.max(1,x*t)}px`,height:`${Math.max(1,b*n)}px`}),Fu(s,i.label),Fu(s,{position:"absolute"}),s.textContent=function(e){const t=Math.round(10*e)/10;return`${t%1==0?t.toFixed(0):t.toFixed(1)}x`}(c.k)}function Ou(e,t,n,i,o){const a=e=>e.target?.closest(".d3plus-minimap-viewport"),r=e=>{if(e.pointerId!==i.dragPointerId)return;i.dragging=!1;const t=a(e);t&&o(t)};return{pointerdown:t=>{const n=t,r=a(t);if(!r)return;try{r.setPointerCapture(n.pointerId)}catch{}i.dragging=!0,i.dragPointerId=n.pointerId;const s=Lu(e);i.dragStart={x:n.clientX,y:n.clientY,tx:s.x,ty:s.y,k:s.k},o(r),t.preventDefault()},pointermove:n=>{const o=n;if(!i.dragging||o.pointerId!==i.dragPointerId)return;const[[a],[r]]=e._zoomBehavior.translateExtent(),s=(r-a)/t,c=Pu(e),l=c.x?(o.clientX-i.dragStart.x)*s*i.dragStart.k:0,h=c.y?(o.clientY-i.dragStart.y)*s*i.dragStart.k:0;_c(e,i.dragStart.k,i.dragStart.tx-l,i.dragStart.ty-h,0)},pointerup:r,pointercancel:r,keydown:n=>{const i=n,o=Ru[i.key];if(!o)return;i.preventDefault();const[[a],[r]]=e._zoomBehavior.translateExtent(),s=(r-a)/t,c=i.shiftKey?40:10,l=Lu(e),h=Pu(e),u=h.x?o[0]*c*s*l.k:0,d=h.y?o[1]*c*s*l.k:0;_c(e,l.k,l.x-u,l.y-d,e.schema.duration)}}}function Wu(e,t,n){return{click:i=>{const o=i.target;if(o?.closest(".d3plus-minimap-viewport"))return;const a=o?.closest(".d3plus-minimap");if(!a)return;const r=i,s=a.getBoundingClientRect(),[c,l]=Nu(e,t,n,r.clientX-s.left,r.clientY-s.top);Eu(e,c,l,Lu(e).k,e.schema.duration)},dblclick:t=>{t.preventDefault(),_c(e,1,0,0)},wheel:i=>{const o=i;if(!o.ctrlKey&&!o.metaKey)return;o.preventDefault();const a=i.target?.closest(".d3plus-minimap");if(!a)return;const r=a.getBoundingClientRect(),[s,c]=Nu(e,t,n,o.clientX-r.left,o.clientY-r.top),l=o.deltaY<0?e.schema.zoomFactor:1/e.schema.zoomFactor;Eu(e,s,c,Lu(e).k*l,0)}}}function ju(e,t,n,i){const o=function(e){return{outer:Du(e,e.schema.minimapStyle,fs),viewport:Du(e,e.schema.minimapViewportStyle,ms),viewportActive:Du(e,e.schema.minimapViewportStyleActive,ps),label:Du(e,e.schema.minimapLabelStyle,gs)}}(e),a={dragging:!1,dragPointerId:null,dragStart:{x:0,y:0,tx:0,ty:0,k:1}},r=i=>Tu(e,t,n,o,a,i),s=e.schema.minimapClassName?` ${e.schema.minimapClassName}`:"";return{type:"htmlOverlay",key:"viz-minimap",x:e.schema.width-4-t,y:i+4,width:t,height:n,className:`d3plus-minimap${s}`,html:Bu(e),events:{".d3plus-minimap-viewport":Ou(e,t,0,a,r),".d3plus-minimap":Wu(e,t,n)},onUpdate:e=>{const t=e.querySelector(".d3plus-minimap-viewport");t&&r(t)}}}const Hu={name:"minimap",layout:({viz:e})=>{if(!(e.schema.zoom&&e.schema.minimap&&e._container&&e._zoomBehavior&&Ys(e)))return{panel:null,margin:{}};const t=Us(e);if(!t)return{panel:null,margin:{}};const n=ie(e),i=e._zoomHeight||n.height,o=e._zoomWidth||n.width;if(!o||!i)return{panel:null,margin:{}};const a=t.width-4;return{panel:ju(e,a,a*(i/o),t.height),margin:{}}}};function Iu([e,t],n){if(!n)return[e,t];let i=e,o=t;if(n.rotate){const[e,t]=n.rotateAnchor??[0,0],a=n.rotate*Math.PI/180,r=Math.cos(a),s=Math.sin(a),c=i-e,l=o-t;i=e+c*r-l*s,o=t+c*s+l*r}const a=n.scale??1;return[i*a+(n.x??0),o*a+(n.y??0)]}const Gu=([e,t])=>({x:e,y:t,width:0,height:0});function Vu(e){switch(e.type){case"rect":case"image":return[{x:e.x,y:e.y,width:e.width,height:e.height}];case"circle":return[{x:e.cx-e.r,y:e.cy-e.r,width:2*e.r,height:2*e.r}];case"path":{const t=f.path2polygon(e.d,10);return t.length?t.map(Gu):[f.pathBounds(e.d)]}case"line":return e.points.map(Gu);case"area":return[...e.topline,...e.baseline].map(Gu);case"text":return function(e){const t=e.font?.size??0,n=e.font?.anchor??"start",i=e.font?.baseline??"alphabetic",o="hanging"===i?0:"middle"===i?t/2:.8*t;return(e.lines||[]).filter(e=>e.text&&e.width).map(i=>{const a="middle"===n?i.width/2:"end"===n?i.width:0;return{x:e.x+i.x-a,y:e.y+i.y-o,width:i.width,height:t}})}(e);default:return[]}}function qu(e){return t=>e.reduceRight((e,t)=>Iu(e,t),t)}function Yu(e,t){const n=[t([e.x,e.y]),t([e.x+e.width,e.y]),t([e.x,e.y+e.height]),t([e.x+e.width,e.y+e.height])],i=n.map(e=>e[0]),o=n.map(e=>e[1]),a=Math.min(...i),r=Math.min(...o);return{x:a,y:r,width:Math.max(...i)-a,height:Math.max(...o)-r}}function Ku(e,t,n,i=!1){const o=[],a=(e,t)=>{for(const r of e){if(String(r.key).endsWith("::hit")||n&&n(r))continue;const e=r.transform?[...t,r.transform]:t;if("group"===r.type){a(r.children,e);continue}if(!i&&void 0===r.datum)continue;const s=qu(e);for(const e of Vu(r))[e.x,e.y,e.width,e.height].every(Number.isFinite)&&o.push(Yu(e,s))}};return a(e,t?[t]:[]),o}function Uu(e,t,n){const{width:i,height:o}=ie(e);return{bounds:t??{x:e._margin.left,y:e._margin.top,width:i,height:o},obstacles:Ku(e._chartScene||[],e._chartTransform,n)}}const Xu=12*1.4+5;function Qu(e,t){return"auto"===t.bind(e)(Fh(e))}function Zu(e){return Va.filter(t=>"legend"===t?Qu(e,e.schema.legendPosition)&&function(e){const t=Xa("column",{width:e.schema.width||0,height:e.schema.height||0});return Bh(e).legendData.length*Xu*Xu<=t.width*t.height}(e):"colorScale"!==t||Qu(e,e.schema.colorScalePosition))}const Ju={sizeLegend:["column"],legend:["column","row"],colorScale:["column","row"]};function ed(e,t,n,i){if("sizeLegend"===t){const t=Zs(e);return t?{width:t.width,height:t.height}:null}return"legend"===t?Eh(e,n,i):du(e,n,i)}const td=[{alignX:"right",alignY:"bottom"},{alignX:"right",alignY:"top"},{alignX:"left",alignY:"bottom"},{alignX:"left",alignY:"top"}];function nd(e,t,n,i){const o=.5,a=e.filter(e=>e.width>=n&&e.height>=i);if(!a.length)return null;const r=e=>({right:Math.abs(e.x+e.width-(t.x+t.width))<o,left:Math.abs(e.x-t.x)<o,bottom:Math.abs(e.y+e.height-(t.y+t.height))<o,top:Math.abs(e.y-t.y)<o}),s=(e,t,o)=>({x:"right"===t?e.x+e.width-n:"left"===t?e.x:e.x+(e.width-n)/2,y:"bottom"===o?e.y+e.height-i:"top"===o?e.y:e.y+(e.height-i)/2,width:n,height:i,alignX:t,alignY:o});for(const{alignX:e,alignY:t}of td){const n=a.find(n=>{const i=r(n);return i[e]&&i[t]});if(n)return s(n,e,t)}const c=a[0],l=r(c);return s(c,l.right?"right":l.left?"left":"center",l.bottom?"bottom":l.top?"top":"middle")}function id(e){const t=e._insetRegion?.();if(!t)return null;const{padding:n}=qa(e),i=t.bounds,o={x:i.x+n,y:i.y+n,width:i.width-2*n,height:i.height-2*n};if(o.width<=0||o.height<=0)return null;const a=function(e){const t=[],{width:n,height:i}=ie(e),o=Us(e);if(o){const a=e.schema.minimap?(o.width-4)*(i/Math.max(1,n)):0;t.push({x:e.schema.width-o.width,y:0,width:o.width,height:o.height+a})}const a=Mh(e,zh(e));if(a&&t.push({x:0,y:0,width:a.width,height:a.height}),e.schema.attribution){const i=e._select?.node?.()?.parentNode,o=i?.querySelector?.("div.d3plus-attribution"),a=String(e.schema.attribution).replace(/<[^>]*>/g,""),r=Math.min(o?.offsetWidth||6*a.length+30,n/2),s=o?.offsetHeight||22,c=e.schema.width-e._margin.right,l=e.schema.height-e._margin.bottom;t.push({x:c-r,y:l-s,width:r,height:s})}return t}(e);return{rects:f.negativeSpace(o,t.obstacles,{padding:n,exclude:a}),bounds:o,area:i}}function od(e,t){const n=t.filter(t=>function(e,t){return"sizeLegend"===t?Boolean(Zs(e)?.inset):"legend"===t?Boolean(e._legendClass?._data?.length):Boolean(e.schema.colorScale)&&!1!==yu(e.schema.colorScalePosition.bind(e)(Fh(e)),e)&&!e.schema.colorScaleConfig.select}(e,t)),i=n.length?id(e):null;if(!i||!i.rects.length)return{placement:null,showing:n};const{margin:o}=qa(e);for(const t of n)for(const a of Ju[t]){const r=ed(e,t,a,i.area),s=r&&nd(i.rects,i.bounds,r.width+2*o,r.height+2*o);if(s)return{placement:{key:t,orient:a,...s},showing:n}}return{placement:null,showing:n}}function ad(e,t){e._margin={...t.margin},e._padding={...t.padding},e._draw()}function rd(e){e._insetPlacement=null;const t="function"==typeof e._insetRegion&&function(e){const t=e.schema.legendInset;return"function"==typeof t?Boolean(t.bind(e)(Fh(e))):Boolean(t)}(e)?Zu(e):[];if(!t.length)return e._insetPending=null,void e._draw();const n={margin:{...e._margin},padding:{...e._padding}};e._insetPending=new Set(t),e._draw();const i=od(e,t),{showing:o}=i;let{placement:a}=i;if(o.length){if(a&&o.some(e=>e!==a.key)&&(e._insetPending=new Set([a.key]),ad(e,n),a=od(e,[a.key]).placement),!a)return e._insetPending=new Set,void ad(e,n);e._insetPlacement=a}}function sd(e,t,n){if(e<=0||t<=0)return 0;const i=Math.min(e,t*n);return i*(i/n)}function cd(e,t,n){if(e<=0)return{columns:0,rows:0};const{columns:i,rows:o}=n;if(i)return{columns:Math.min(i,e),rows:Math.max(o??0,Math.ceil(e/i))};if(o){const t=Math.ceil(e/o);return{columns:t,rows:Math.ceil(e/t)}}const a=n.gutter??{left:0,right:0,bottom:0};let r={columns:1,rows:e},s=-1,c=1/0,l=1/0;for(let i=1;i<=e;i++){const o=Math.ceil(e/i),h=(t.width-a.left-a.right-(i-1)*(n.columnPadding??n.padding))/i,u=(t.height-a.bottom-(o-1)*n.padding)/o-n.titleHeight,d=sd(h,u,n.aspect),f=i*o-e,m=u>0?Math.abs(Math.log(h/u/n.aspect)):1/0;(d>1.01*s||d>=.99*s&&(f<c||f===c&&m<l))&&(r={columns:i,rows:o},s=Math.max(d,s),c=f,l=m)}return r}function ld(e,t,n){const{columns:i,rows:o}=cd(e,t,n);if(!i)return[];const a=n.gutter??{left:0,right:0,bottom:0},r=n.padding,s=n.columnPadding??r,c=Math.max(0,(t.width-a.left-a.right-(i-1)*s)/i),l=Math.max(0,(t.height-a.bottom-(o-1)*r)/o),h=[];for(let n=0;n<e;n++){const o=Math.floor(n/i),u=n%i,d=n+i<e,f=t.x+u*(c+s)+(u?a.left:0),m=t.y+o*(l+r);h.push({index:n,row:o,column:u,x:f,y:m,width:c+(u?0:a.left)+(u===i-1?a.right:0),height:l+(d?0:a.bottom),edges:{top:0===o,right:u===i-1||n===e-1,bottom:!d,left:0===u}})}return h}const hd={top:0,right:0,bottom:0,left:0},ud=[{x:!0,y:!0},{x:!0,y:!1},{x:!1,y:!0},{x:!1,y:!1}];function dd(e){return`${e.x?"x":""}${e.y?"y":""}`}function fd(e,t={x:!1,y:!1}){const n=e[dd(t)]??hd,i={};for(const[t,o]of Object.entries(e))i[t]={top:Math.max(0,o.top-n.top),right:Math.max(0,o.right-n.right),bottom:Math.max(0,o.bottom-n.bottom),left:Math.max(0,o.left-n.left)};return i}function md(e){const t=Object.values(e),n=(t,n)=>Math.max(0,...ud.filter(n).map(n=>e[dd(n)]?.[t]??0));return{top:Math.max(0,...t.map(e=>e.top)),right:Math.max(0,...t.map(e=>e.right)),bottom:n("bottom",e=>e.x),left:n("left",e=>e.y)}}function pd(e,t,n,i){const o=0===e.column?n.left:0,a=e.column===i-1?n.right:0,r=t+n.top,s=e.edges.bottom?n.bottom:0;return{x:e.x+o,y:e.y+r,width:Math.max(0,e.width-o-a),height:Math.max(0,e.height-r-s)}}function gd(e){const t=Object.fromEntries(["top","right","bottom","left"].map(t=>[t,Math.max(...e.map(e=>e[t]))]));return e.map(e=>({top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}))}function yd(e,t){return{x:e.x-t.left,y:e.y-t.top,width:e.width+t.left+t.right,height:e.height+t.top+t.bottom}}function xd(e){const t=(t,n)=>Math.max(0,...ud.filter(n).map(n=>e[dd(n)]?.[t]??0));return t("left",e=>e.x&&!e.y)+t("right",e=>e.x)}function bd(e,t){const n="function"==typeof t?t:e=>`${t}/${e}`;return e.map(e=>{const t=e.children,i={...e,key:n(`${e.key}`)};return t&&(i.children=bd(t,n)),i})}function _d(e,t,n){const i=(new ro).data(e.map((e,t)=>({id:`facet-title-${t}`,text:e.text}))).x((t,n)=>e[n].x).y((t,n)=>e[n].y).width((t,n)=>e[n].width).height(()=>1e4).verticalAlign("top").config(t);return n&&i.locale(n),i}function kd(e,t,n){if(!e.length)return 0;const i="number"==typeof t.padding?t.padding:0,o=_d(e,{...t,padding:0},n)._textData(),a=Math.max(0,...o.map(e=>e.lines.length*e.lH));return a?a+2*i:0}function vd(e,t,n){if(!e.length)return[];const i="number"==typeof t.padding?t.padding:0;return _d(e.map(e=>({...e,x:e.x+i,y:e.y+i,width:e.width-2*i})),{...t,padding:0},n).toScene().children.map(e=>{const t={...e,interactive:!1,interactionGroup:"facet"};return delete t.datum,delete t.index,t})}function wd(e,t,n,i){return{type:"group",key:`${e}/cells`,...i?{clip:i}:{},children:[{type:"group",key:`${e}/body`,...n?{transform:n}:{},children:t}]}}function Sd(e,t,n,i){const o=[];return n&&o.push(n),t&&o.push(t),{type:"group",key:e,children:o,...i?{aria:{role:"group",label:i}}:{}}}function Cd(e,t){return{top:t.y,left:t.x,right:e.schema.width-t.x-t.width,bottom:e.schema.height-t.y-t.height}}function Md(e,t){const{x:n,y:i}="boolean"==typeof t?{x:t,y:t}:t;return{x:!n||e.edges.bottom,y:!i||e.edges.left}}function $d(e,t,n,i,o){if(e._filteredData=n,e._margin=Cd(e,i),e._padding={...t.padding},e._chartScene=[],e._chartTransform=void 0,e._chartClip=void 0,e._zoomShapes=void 0,!n.length||i.width<=0||i.height<=0)return{scene:[],zoomShapes:[],state:{}};const a=t.hooks.panel?t.hooks.panel(e,o):void 0;let r,s;e._facetStep="panel";try{e._draw(),r=e._chartScene||[],s=t.hooks.scene?t.hooks.scene(e,r):r}finally{e._facetStep=void 0,a&&a()}return{scene:s,zoomShapes:e._zoomShapes||r,chartTransform:e._chartTransform,chartClip:e._chartClip,state:t.hooks.capture?t.hooks.capture(e):{}}}function Ad(e,t){return void 0!==t.titleConfig.fontColor?t.titleConfig:{...t.titleConfig,fontColor:Ga(e)}}function zd(e,t){const{title:n}=e,i=t.map(e=>e.value);return t.map(e=>!1===n?"":n?`${n(e.value,e.data)}`:Zh(e.value,i))}function Dd(e,t,n,i){const o=t.map((e,t)=>({text:e,x:0,y:0,width:n[t]?n[t].width:0})).filter(e=>e.text&&e.width>0);return kd(o,i,e.schema.locale)}function Fd(e,t,n,i){const{config:o,hooks:a,panels:r,area:s}=t,c={columns:o.columns,rows:o.rows,padding:o.padding,titleHeight:0,aspect:a.aspect??Re},l=Dd(e,n,ld(r.length,s,c),i);c.titleHeight=l;const h=ld(r.length,s,c)[0],u=pd(h,l,hd,1);t.shared&&a.share&&(e._margin=Cd(e,u),t.scales=a.share(e,r.map(e=>e.data)));const d=je(e,o,a,t.shared),f=d.x||d.y?function(e,t,n,i,o){const a=t.panels.find(e=>e.data.length)?.data,r=t.hooks.insets;if(!a||!r)return{};const s={};for(const c of ud.filter(e=>(o.x||e.x)&&(o.y||e.y)))$d(e,t,a,i,{cell:n,shared:t.shared,labels:c,scales:t.scales}),s[dd(c)]=r(e);return fd(s,function(e){return{x:!e.x,y:!e.y}}(o))}(e,t,h,u,d):{},m=md(f);c.gutter=m,c.columnPadding=o.padding+xd(f),c.titleHeight=l+m.top;const p=ld(r.length,s,c),g=Math.max(1,...p.map(e=>e.column+1));return{cells:p,columns:g,titleHeight:l,outer:d,gutter:m,expansions:f}}function Bd(e,t,n){return{text:e,x:n.x,y:t.y,width:n.width}}function Ld(e,t){const n=Ad(e,t.config),i=zd(t.config,t.panels),o=Fd(e,t,i,n),{cells:a,expansions:r}=o,s=a.map(e=>pd(e,o.titleHeight,o.gutter,o.columns)),c=vd(a.map((e,t)=>Bd(i[t],e,s[t])).filter(e=>e.text),n,e.schema.locale),l=a.map(e=>Md(e,o.outer)),h=a.map((e,t)=>yd(s[t],r[dd(l[t])]??hd)),u=function(e,t,n,i,o,a){const r=t.hooks.insets,{outer:s,expansions:c}=a;if(!r||s.x===s.y)return[];const l=t.panels.map((a,s)=>{if(!a.data.length)return;$d(e,t,a.data,i[s],{cell:n[s],shared:t.shared,labels:o[s],scales:t.scales});const l=c[dd(o[s])]??hd,h=r(e);return{top:h.top-l.top,right:h.right-l.right,bottom:h.bottom-l.bottom,left:h.left-l.left}}),h=gd(l.filter(e=>!!e));let u=0;return l.map(e=>e?h[u++]:hd)}(e,t,a,h,l,o);let d=0;const f=[],m=[],p=[];return t.panels.forEach((n,o)=>{const r=a[o],s=u[o]?yd(h[o],u[o]):h[o],g=$d(e,t,n.data,s,{cell:r,shared:t.shared,labels:l[o],scales:t.scales}),y=`facet-${n.key}`,x=i[o]?c[d++]:void 0,b=g.scene.length?wd(y,bd(g.scene,y),g.chartTransform,g.chartClip):void 0;m.push(Sd(y,x?{...x,key:`${y}/title`}:void 0,b,i[o])),p.push(...g.zoomShapes),f.push({key:y,value:n.value,cell:r,area:s,chartTransform:g.chartTransform,scene:g.scene,state:g.state})}),e._chartScene=m,{states:f,zoomShapes:p}}function Pd(e){const t=Ne(e.schema.facetConfig),n=Uh(e,t.sort);if(!n.length||!(e._filteredData||[]).length)return!1;const i=Qh(e),o=n.map(t=>({...t,data:Xh(e,t.rows,i)})),a=o.flatMap(e=>e.data);if(!a.length)return!1;e._filteredData=a,e._insetPending=null,e._insetPlacement=null,e._facetStep="chrome";try{e._draw()}finally{e._facetStep=void 0}const r={...e._margin},s={...e._padding},c={x:r.left,y:r.top,width:e.schema.width-r.left-r.right,height:e.schema.height-r.top-r.bottom},l=e._facetHooks?e._facetHooks():{},h=He(t,l),{states:u,zoomShapes:d}=Ld(e,{config:t,hooks:l,panels:o,area:c,shared:h,scales:void 0,padding:s});return e._filteredData=a,e._margin=r,e._padding=s,e._chartTransform=void 0,e._chartClip=void 0,e._bodyRect={...c},e._zoomShapes=d,e._facetPanels=u,e._pendingEnterOrigin=void 0,e._pendingExitReunion=void 0,Ac(e,u),!0}function Rd(e){e._facetPanels=void 0,Ie(e)&&Pd(e)||rd(e)}function Ed(e,t){const n=Ga(e),i=e._sizeLegendClass;i.renderMode("compute").locale(e.schema.locale).title(e._sizeKey).labelConfig({fontColor:n,fontFamily:e.schema.fontFamily}).titleConfig({fontColor:n,fontFamily:e.schema.fontFamily}).lineConfig({stroke:n}).shapeConfig({fill:n,stroke:n}).config(e.schema.sizeLegendConfig).scale(t);const{width:o,height:a}=i.layout();return{width:o,height:a}}function Nd(e,t){if(!e._sizeLegendClass||"function"!=typeof e._sizeLegendScale)return null;const n=e._sizeLegendScale(t);if(!n)return null;e._sizeLegendClass._maxRadius=void 0;const{width:i,height:o}=Ed(e,n);if(!i||!o)return null;const a={width:i,height:o,availableWidth:t.width,availableHeight:t.height};return e.schema.sizeLegend.bind(e)(Fh(e),n,a)?{key:"sizeLegend",width:i,height:o,paint:t=>{const n=e._sizeLegendFinal;if(!n)return null;e._sizeLegendClass._maxRadius=1===t?void 0:n(n.domain()[1]);const i=Ed(e,Ui(n,t));return i.width&&i.height?{node:e._sizeLegendClass.toScene(),...i}:null}}:null}const Td=[Nd];function Od(e,t,n){const i=[];for(const t of Td){const o=t(e,n);o&&i.push(o)}const o="bottom"===e.schema.sizeLegendPosition?"bottom":"right",a=Ya(e,"sizeLegend");e._bottomRightBox=i.length?{...Qs(i),bottom:t,side:o,inset:a,items:i}:null}const Wd={name:"bottomRightControls",configFields:["sizeLegend","sizeLegendConfig","sizeLegendPosition"],layout:({viz:e})=>{const t=Zs(e);return{panel:t?ac(e,t):null,margin:{}}}};function jd(e){e._preDraw(),Rd(e),Hd(e),mr(e),e._drawSceneToTarget()}function Hd(e){const t=xu({viz:e},[lc,Hu,Dh,Wd,pu,pl]);t.panels.length&&(e._featurePanels=[...e._featurePanels||[],...t.panels])}function Id(){this._tooltipClass.data([]).render()}const Gd="d3plus-viz-spacer";function Vd(e,t){return void 0===e||t?void 0:e}function qd(e){const t=e._select?.node(),n=t?.parentNode;if(!t||!n||"http://www.w3.org/1999/xhtml"!==n.namespaceURI)return;let i=Array.from(n.children).find(e=>e.classList.contains(Gd));const o=Vd(e.schema.width,e._autoWidth),a=Vd(e.schema.height,e._autoHeight);if("canvas"===e._renderer||void 0===o&&void 0===a)i?.remove();else{if(!i){i=n.ownerDocument.createElement("div"),i.className=Gd,i.setAttribute("aria-hidden","true");const e=i.style;e.display="block",e.flex="none",e.boxSizing="content-box",e.margin="0",e.padding="0",e.border="0",e.visibility="hidden",e.pointerEvents="none",n.insertBefore(i,t.nextSibling)}i.style.width=`${o??0}px`,i.style.height=`${a??0}px`}}const Yd="d3plus-viz";const Kd=":where(.d3plus-render-overlays, .d3plus-zoom-control, .d3plus-top-left-controls)",Ud=[".d3plus-zoom-control",".d3plus-top-left-controls",".d3plus-top-left-controls-item",`${Kd} .tlc-item`,`${Kd} .zoom-control-icon`,`${Kd} .search-root`,`${Kd} .search-input-wrap`,`${Kd} .search-count`,".d3plus-minimap",".d3plus-minimap-viewport",".d3plus-minimap-label",".d3plus-table-view",".d3plus-table-view-frame",".d3plus-table-view-toolbar",".d3plus-table-view-scroll",".d3plus-table-view-table",".d3plus-table-view-cell",".d3plus-table-view-pagination",".d3plus-attribution",".d3plus-attribution-text",".d3plus-attribution-icon",".d3plus-Mask",".d3plus-Message"];function Xd(e){return!!e._forceVisible||n.inViewport(e._select.node())}function Qd(e){const t=[];return e._queue.forEach(n=>{const i=e.schema.cache?e._lrucache.get(`${n[3]}_${n[1]}`):void 0;if(i){const t=n[2]?n[2](i):i;`_${n[3]}`in e?e[`_${n[3]}`]=t:e.schema[n[3]]=t}else t.push(new Promise(t=>{n[0](n[1],n[2],n[3],(i,o)=>{i?console.error(i):"data"===n[3]&&function(e,t){e._dataSignature=e.schema.dataPollingInterval?wt(t):void 0}(e,o),t()})}))}),e._queue=[],t}function Zd(e,t){var i;if(e._unloaded)return;let o;!function(e){const t=e._data instanceof Array&&e._data.length>0?Object.keys(e._data[0]):[],n=e._select.selectAll("g.data-table").data(!e.schema.ariaHidden&&e._data instanceof Array&&e._data.length?[0]:[]),i=n.enter().append("g").attr("class","data-table").attr("role","table");n.exit().remove();const o=n.merge(i).selectAll("text").data(e._data instanceof Array?h.range(0,e._data.length+1):[]);o.exit().remove();const a=o.merge(o.enter().append("text").attr("role","row")).selectAll("tspan").data((n,i)=>t.map(t=>({role:i?"cell":"columnheader",text:i?e._data[i-1][t]:t})));a.exit().remove(),a.merge(a.enter().append("tspan")).attr("role",e=>e.role).attr("dy","-1000px").html(e=>e.text)}(e),jd(e),e._instantNextDraw=!1,kt(e),At(e),!e._messageClass._isVisible||e.schema.noDataMessage&&!e._filteredData.length||(e._messageClass.hide(),"0"===e._select.attr("opacity")&&e._select.transition().duration(e.schema.duration).attr("opacity",1));const a=()=>{if(o=void 0,!e._fontsUnsubscribe)return;const t=e._callback?e.schema.duration:(e._transitionEndsAt??0)-Date.now();t>0?o=setTimeout(a,t):e.render()};(i=e)._fontsUnsubscribe??(i._fontsUnsubscribe=n.onFontsLoaded(()=>{void 0===o&&a()})),e.schema.detectResize&&(e._autoWidth||e._autoHeight)?e._resizeObserver?.observe(e._select.node().parentNode):e._resizeObserver?.unobserve(e._select.node().parentNode),t&&setTimeout(()=>{t(),e._callback=void 0},e.schema.duration+100)}function Jd(e,o){e._callback=o,e.schema.detectVisible&&e.schema.detectVisibleUnload||(e._unloadUnobserve?.(),e._unloadUnobserve=void 0,e._unloaded=!1),e._margin={bottom:0,left:0,right:0,top:0},e._padding={bottom:0,left:0,right:0,top:0},function(e){if(void 0===e._select||"svg"!==e._select.node().tagName.toLowerCase()){const n=void 0===e._select?t.select("body").insert("div","#d3plus-portal").style("height","100dvh").style("width","100%").style("min-height","150px"):e._select,i=n.select(".d3plus-viz").size()?n.select(".d3plus-viz"):n.append("svg");e.select(i.node())}}(e),function(e){if(e._tooltipClass&&e._select?.node){const t=e._select.node()?.parentNode;t&&e._tooltipClass.parent(t)}}(e),function(e){i.resetInjectedBoxes(e._select?.node(),Ud)}(e),qd(e),function(e){e.schema.width&&e.schema.height||e.schema.detectVisible&&!Xd(e)||(e._autoWidth=void 0===e.schema.width||!!e._autoWidth&&e.schema.width===e._measuredWidth,e._autoHeight=void 0===e.schema.height||!!e._autoHeight&&e.schema.height===e._measuredHeight,e._setSVGSize())}(e),qd(e);const r=t.select(e._select.node().parentNode);return function(e,t){!function(e){const t=void 0!==e.schema.width?`${e.schema.width}px`:void 0,n=void 0!==e.schema.height?`${e.schema.height}px`:void 0;e._select.classed("d3plus-viz")||e._select.style("width",t).style("height",n).attr("width",t).attr("height",n),e._select.transition().duration(e.schema.duration).style("width",t).style("height",n).attr("width",t).attr("height",n)}(e),e._select.attr("class",Yd).attr("aria-hidden",e.schema.ariaHidden).attr("aria-labelledby",`${e._uuid}-title ${e._uuid}-desc`).attr("role","img").attr("xmlns","http://www.w3.org/2000/svg").attr("xmlns:xlink","http://www.w3.org/1999/xlink").style("position","absolute").style("top",t.style("padding-top")).style("left",t.style("padding-left")).style("content-visibility",e.schema.detectVisible?"auto":null),ve(e),"static"===t.style("position")&&t.style("position","relative"),t.style("font-family",a.fontFamilyStringify(e.schema.fontFamily)),null===e._select.attr("opacity")&&e._select.attr("opacity",1);const n=e._select.selectAll("title").data([0]),i=n.enter().append("title").attr("id",`${e._uuid}-title`);n.merge(i).text(e.schema.svgTitle);const o=e._select.selectAll("desc").data([0]),r=o.enter().append("desc").attr("id",`${e._uuid}-desc`);o.merge(r).text(e.schema.svgDesc)}(e,r),function(e){e._visiblePoll=clearInterval(e._visiblePoll),e._resizePoll=clearTimeout(e._resizePoll),e._scrollPoll=clearTimeout(e._scrollPoll),e._visibleUnobserve?.(),e._visibleUnobserve=void 0,e.schema.scrollContainer&&t.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null)}(e),function(e,i){return e.schema.detectVisible&&"hidden"===e._select.style("visibility")?(e._visiblePoll=setInterval(()=>{"hidden"!==e._select.style("visibility")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(i))},e.schema.detectVisibleInterval),!0):e.schema.detectVisible&&"none"===e._select.style("display")?(e._visiblePoll=setInterval(()=>{"none"!==e._select.style("display")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(i))},e.schema.detectVisibleInterval),!0):!(!e.schema.detectVisible||Xd(e)||(bt()?(e._visibleUnobserve=_t(e._select.node(),e.schema.scrollContainer,()=>{e._visibleUnobserve?.(),e._visibleUnobserve=void 0,e._forceVisible=!0,e.render(i)},e.schema.detectVisibleInterval),0):(t.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,()=>{e._scrollPoll||(e._scrollPoll=setTimeout(()=>{n.inViewport(e._select.node())&&(t.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null),e.render(i)),e._scrollPoll=clearTimeout(e._scrollPoll)},e.schema.detectVisibleInterval))}),0)))}(e,o)||function(e,t){const n=Qd(e);e.schema.loadingMessage&&n.length&&e._messageClass.render({container:e._select.node().parentNode,html:e.schema.loadingHTML(e),mask:!!e._filteredData&&e.schema.messageMask,style:e.schema.messageStyle}),Promise.all(n).then(()=>Zd(e,t))}(e,o),e._forceVisible=!1,t.select("body").on(`touchstart.${e._uuid}`,Id.bind(e)),e}function ef(e,t,n,i,o){const a=xu({viz:e},[t],n);for(const e of o)i[e]+=a.margin[e],n[e]+=a.margin[e]}function tf(e){if(e._chartScene=[],e._chartTransform=void 0,"panel"===e._facetStep)return{marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:(e._featurePanels??[]).slice()};e._featurePanels=[];const t={marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:[]},n=Fh(e),i=yu(e.schema.legendPosition.bind(e)(n),e),o=yu(e.schema.colorScalePosition.bind(e)(n),e);t.legendPosition=i,t.colorScalePosition=o;const a={top:e._margin.top,right:e._margin.right,bottom:e._margin.bottom,left:e._margin.left},r=xu({viz:e},[Mu,$u,zu],a);e._featurePanels.push(...r.panels),t.marginDelta.top+=r.margin.top,a.top+=r.margin.top;const s=xu({viz:e},[Au],a);t.marginDelta.bottom+=s.margin.bottom,a.bottom+=s.margin.bottom,Od(e,a.bottom,{width:e.schema.width-a.left-a.right,height:e.schema.height-a.top-a.bottom});const c=oc(e,a.right);a.right+=c,"top"!==i&&"bottom"!==i||ef(e,Th,a,t.marginDelta,["top","bottom"]),"top"!==o&&"bottom"!==o||ef(e,fu,a,t.marginDelta,["top","bottom"]),a.right-=c;const l=ic(e,a.bottom);t.marginDelta.bottom+=l,a.bottom+=l,"left"!==i&&"right"!==i&&!1!==i||ef(e,Th,a,t.marginDelta,["left","right"]),"left"!==o&&"right"!==o&&!1!==o||ef(e,fu,a,t.marginDelta,["left","right"]);const h=oc(e,a.right);t.marginDelta.right+=h,a.right+=h;const u=Math.max(0,wu(e)-t.marginDelta.top);t.marginDelta.top+=u,a.top+=u;const d=t.marginDelta;return e._margin={top:e._margin.top+d.top,right:e._margin.right+d.right,bottom:e._margin.bottom+d.bottom,left:e._margin.left+d.left},t.featurePanels=e._featurePanels.slice(),t}const nf={x:"_x",x2:"_x2",y:"_y",y2:"_y2",size:"_size",stackOrder:"_stackOrder"},of=["dimensions"];const af=e=>null!==e&&"object"==typeof e;function rf(e,t){return e.some(e=>e.some(e=>af(e)&&t in e))}function sf(e){const t=new Set;for(const n of e)for(const e of n)if(af(e))for(const n in e)t.add(n);return Array.from(t)}function cf(e,{key:t,field:n},i){const o=i.slice(0,10);return i.length>10&&o.push("…"),`${e} ${t}: no rows have '${n}'; fields are: ${o.join(", ")}`}function lf(e){const t=({key:e,field:t})=>`missing-field:${e}:${t}`,n=function(e){const t=new Map,n=(e,n)=>{const i=Le(n);void 0===i||t.has(n)||t.set(n,{key:e,field:i})};for(const[t,i]of Object.entries(nf))n(t,e[i]);for(const t of e._confidenceBands??[])n("confidence",t.lower),n("confidence",t.upper);const i=Object.keys(e.schema).filter(e=>"thresholdKey"!==e);for(const t of[...i,"thresholdKey"]){const i=e.schema[t];Array.isArray(i)&&"function"==typeof i[0]?i.forEach(e=>n(t,e)):n(t,i)}const o=Array.from(t.values());for(const t of of){const n=e.schema[t],i=Array.isArray(n)?n:[n];for(const e of i)"string"==typeof e&&o.push({key:t,field:e})}return o}(e).filter(n=>function(e,t){return ue&&!he.get(e)?.has(t)}(e,t(n)));if(!n.length)return;const i=function(e){return[e._sourceData??e._data,e.schema.nodes,e.schema.links].filter(e=>Array.isArray(e))}(e);if(!i.some(e=>e.some(af)))return;let o;for(const a of n)rf(i,a.field)||(o??(o=sf(i)),ge(e,t(a),cf(e.constructor.name,a,o)))}function hf(e,t,n){for(;t.__d3plus__&&t.data;)n=(t=t.data).i;return e(t,n)}function uf(e,t,n){const i={noDataMessage:!1};return h.group(t,n).size>e.schema.dataCutoff?i.hoverOverride={hoverOpacity:1,duration:0,stashOriginals:!0}:void 0!==e._userHover&&(i.hoverOverride={hoverOpacity:e._userHover,duration:e._userDuration,restoreOriginals:!0}),i.noDataMessage=!(!e.schema.noDataMessage||t.length),i}function df(e){lf(e);const t=void 0!==e.schema.depth?h.min([e.schema.depth>=0?e.schema.depth:0,e.schema.groupBy.length-1]):e.schema.groupBy.length-1,{id:n,ids:i,drawLabel:o}=function(e,t){const n=e.schema.groupBy,i=e.schema.label,o=e.schema.thresholdName,a=e.schema.locale,r=e=>"number"==typeof e?`${e}`:e,s=(e,t)=>n.map(n=>`${hf(n,e,t)}`).filter(Boolean);return{id:(e,i)=>{const o=hf(n[t],e,i);return Array.isArray(o)?o.map(r):r(o)},ids:s,drawLabel:(n,r,c)=>{const l=e._drawDepth??t;if(!n)return"";const h=Ye(n),u=c??h??l;for(;n.__d3plus__&&n.data;)r=(n=n.data).i;if(u===h&&"string"==typeof n[Ve])return n[Ve];if(n._isColorScaleBucket)return`${n.id}`;if(n._isAggregation)return`${o(n,r)} < ${d.formatAbbreviate(100*n._threshold,a)}%`;if(i&&u===l)return`${i(n,r)}`;const f=s(n,r).slice(0,u+1),m=f.reverse().find(e=>!(e instanceof Array))||f[f.length-1];return m instanceof Array?function(e){return e.reduce((t,n,i)=>(i?i===e.length-1&&1===i?t+=` and ${n}`:i===e.length-1?t+=`, and ${n}`:t+=`, ${n}`:t+=n,t),"")}(m):`${m}`}}}(e,t);(function(e){const t=e=>!0===e||"number"==typeof e&&e>0,n=t=>e?.[t]?.trailPersist;return!!e&&(t(e.trailPersist)||t(n("Circle"))||t(n("Rect")))})(e.schema.shapeConfig)&&(e._axisPersist=!0,e.schema.timelineConfig={...e.schema.timelineConfig||{},brushing:!1});const a={};Ih(e,a,t,n,Hh(e)),e._drawDepth=t,e._id=n,e._ids=i,e._drawLabel=o,void 0!==a.legendData&&(e._legendData=a.legendData),e._thresholdRows=a.legendData;let c=a.filteredData||[];e._data.length&&a._thresholdTree&&(c=e._thresholdFunction(c,a._thresholdTree,e._thresholdRows),e._thresholdLegend&&a.legendData&&(e._legendData=e._thresholdLegend(a.legendData))),e._filteredData=c,function(e){if(!e.schema.colorOrdinal||e.schema.colorScale)return void(e._ordinalColorScale=void 0);const t=e._filteredData??[],n=e.schema.color,i=new Set,o=[];t.forEach((e,t)=>{const a=n(e,t),r="string"==typeof a?a:JSON.stringify(a);i.has(r)||(i.add(r),o.push(a))});const a=(o.every(e=>"number"==typeof e)?[...o].sort((e,t)=>e-t):o).map(e=>"string"==typeof e?e:JSON.stringify(e)),c=r.colorRamp((e.schema.colorDefaults??r.colorDefaults).sequential,a.length||1,{ordinal:!0});e._ordinalColorScale=s.scaleOrdinal().domain(a).range(c)}(e);const l=uf(e,c,e._id);l.hoverOverride?.stashOriginals?(void 0===e._userHover&&(e._userHover=e.schema.shapeConfig.hoverOpacity||.5),void 0===e._userDuration&&(e._userDuration=e.schema.shapeConfig.duration||600),e.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=l.hoverOverride.duration):l.hoverOverride?.restoreOriginals&&(e.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=l.hoverOverride.duration),l.noDataMessage&&(e._messageClass.render({container:e._select.node().parentNode,html:e.schema.noDataHTML(e),mask:!1,style:e.schema.messageStyle}),e._select.transition().duration(e.schema.duration).attr("opacity",0))}function ff(e,t){const n=e;return{d:n&&n.data?n.data:n,i:n&&"number"==typeof n.i?n.i:t,x:e}}const mf={area:"Area",circle:"Circle",line:"Line",path:"Path",rect:"Rect"};function pf(e,t){const n=[],i=function(e){return"string"==typeof e.shapeType?e.shapeType:mf[e.type]}(e);i&&n.push({shapeType:i,...t});for(const t of e.owners??[])n.some(e=>e.shapeType===t.shapeType)||n.push({shapeType:t.shapeType,...ff(t.datum,t.index)});return n}function gf(e,t){e.interactionGroup=t;const n=e.children;if(n)for(const e of n)gf(e,t)}class yf extends Ba{_preDraw(){df(this)}toScene(){const e=[];if(this._chartScene&&this._chartScene.length){const t=Ha(this._chartScene,this),n=[{type:"group",key:"viz-zoom",transform:this._zoomTransform??{x:0,y:0,scale:1},children:[{type:"group",key:"viz-chart-body",...this._chartTransform?{transform:this._chartTransform}:{},children:t}]}],i=this._chartClip??(this.schema.zoom&&this._margin?ae(this):void 0);e.push({type:"group",key:"viz-chart-cells",...i?{clip:i}:{},children:n})}const t=[["legend",this._legendClass],["colorScale",this._colorScaleClass],["timeline",this._timelineClass]];for(const[n,i]of t)if(i&&"function"==typeof i.toScene&&i._select&&"function"==typeof i._select.node&&i._select.node()){let t=i.toScene();"legend"===n?(gf(t,"legend"),t=Ha([t],this)[0]):"colorScale"===n?t=Oa([t],this)[0]:"timeline"===n&&gf(t,"timeline"),e.push({type:"group",key:`viz-${n}`,children:"timeline"===n?[t]:Za(this,n,t,i.outerBounds())})}return this._featurePanels&&this._featurePanels.length&&e.push({type:"group",key:"viz-features",children:this._featurePanels}),{width:this.schema.width,height:this.schema.height,root:{type:"group",key:"viz-root",children:e}}}_draw(){tf(this)}_sizeLegendScale(e){return null}_insetRegion(){return null}_colorScaleShape(e,t){return this.schema.shape(e,t)}_thresholdFunction(e,t,n){return e}_thresholdLegend(e){return e}_setSVGSize(e,t){let[i,o]=e&&t?[e,t]:n.getSize(this._select.node().parentNode);i-=parseFloat(this._select.style("border-left-width")),i-=parseFloat(this._select.style("border-right-width")),o-=parseFloat(this._select.style("border-top-width")),o-=parseFloat(this._select.style("border-bottom-width")),this._autoWidth&&(this._measuredWidth=i),this._autoHeight&&(this._measuredHeight=o),this._autoWidth&&this.schema.width!==i&&(this.width(i),this._select.style("width",`${this.schema.width}px`).attr("width",`${this.schema.width}px`)),this._autoHeight&&this.schema.height!==o&&(this.height(o),this._select.style("height",`${this.schema.height}px`).attr("height",`${this.schema.height}px`))}render(e){return Jd(this,e)}toSVGString(){return function(e,t){const n=_e(t),i=/^\s*<[a-zA-Z][^\s>/]*/.exec(e);if(!n.length||!i)return e;const o=e.indexOf(">",i[0].length),a=e.slice(0,o<0?e.length:o),r=/\sclass="([^"]*)"/.exec(a);if(!r)return`${i[0]} class="${we(n.join(" "))}"${e.slice(i[0].length)}`;const s=r[1].split(/\s+/).filter(Boolean),c=[...s,...n.filter(e=>!s.includes(e))],l=r.index;return`${e.slice(0,l)} class="${we(c.join(" "))}"${e.slice(l+r[0].length)}`}(this._sceneRenderer?.toSVGString?.()??"",this.schema.className)}toCanvas(){return"canvas"===this._renderer?this._sceneRenderer?.toCanvas?.():void 0}renderer(e){return arguments.length?(this._renderer="canvas"===e?"canvas":"svg",this):this._renderer}_drawSceneToTarget(e){const i="canvas"===this._renderer?"canvas":"svg",o=this._select&&this._select.node?this._select.node():null;if(!o)return;const a=function(e,t){return"canvas"===e&&"undefined"!=typeof Element&&t instanceof Element&&"svg"===t.tagName.toLowerCase()?t.parentNode??t:t}(i,o),r=this.toScene();this._paintedScene=r;const s=this.schema.width||400,c=this.schema.height||300;this._ensureSceneRenderer(i,a,s,c),ve(this);const l=void 0!==e?e:this._instantNextDraw?0:this.schema.duration;l>0&&null!=this._sceneRepaintRAF&&(cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),l>0&&(this._transitionEndsAt=Date.now()+l+30);const h=this._timelineSelection,u=!(!this._timelineClass||!1!==this._timelineClass.schema.brushing)&&Array.isArray(h)&&h.length?Math.max(...h.map(e=>Number(n.date(Number(e))))):void 0,d=void 0!==u&&void 0!==this._trailSeq&&u>this._trailSeq?se(this,r,this._trailSeq,u):void 0;if(void 0!==u&&(this._trailSeq=u),this._sceneRenderer.drawScene(r,{duration:l,sequence:u,trailCatchup:d,enterFrom:this._resolvedEnterFrom,enterFromBody:this._resolvedEnterFromBody,exitTo:this._resolvedExitTo,exitToBody:this._resolvedExitToBody,instantExitKey:this._resolvedInstantExitKey,reunionEnterKey:this._resolvedReunionEnterKey,reunionEnterFrom:this._resolvedReunionEnterFrom,instantExitAll:this._resolvedInstantExitAll}),this._resolvedEnterFrom=void 0,this._resolvedEnterFromBody=void 0,this._resolvedExitTo=void 0,this._resolvedExitToBody=void 0,this._resolvedInstantExitKey=void 0,this._resolvedReunionEnterKey=void 0,this._resolvedReunionEnterFrom=void 0,this._resolvedInstantExitAll=void 0,this._lastSceneRendered=r,dc(this),this._select&&"canvas"===i&&this._select.selectAll("g.d3plus-viz-timeline, g.d3plus-viz-brush").style("pointer-events","auto"),"canvas"===i&&function(e){if(!e.schema.zoom||e._ssr||!e._zoomBehavior||!e._brushGroup)return;const n=e._sceneRenderer,i=n&&"function"==typeof n.toCanvas?n.toCanvas():null;!i||e._zoomEventTarget&&e._zoomEventTarget.node()===i||(uc(e,t.select(i)),mc.bind(e)(Ps(e)))}(this),"svg"===i){const e="function"==typeof o.querySelector?o:null,t=e?e.querySelector(":scope > g.d3plus-viz-timeline"):null;t&&e.appendChild(t),e?.querySelectorAll(":scope > g.d3plus-zoom-brush, :scope > g.d3plus-viz-brush").forEach(t=>{t!==e.lastElementChild&&e.appendChild(t)})}}_interactionDatum(e,t){return ff(e.datum,e.index??0)}_sharedHover(e){}_classNameTargets(){return function(e,t,n){if("canvas"===n)return xe(t).filter(e=>"canvas"===e.localName).map(e=>({el:e,keep:ye}));const i="undefined"!=typeof Element&&e instanceof Element&&e.classList.contains(Yd)?e:void 0;return i?[{el:i,keep:[Yd]}]:[]}(this._select?.node?.(),this._sceneRenderer,"canvas"===this._renderer?"canvas":"svg")}_facetHooks(){return{}}_ensureSceneRenderer(e,t,n,o){const a=this._sceneRenderer?.target?this._sceneRenderer.target()?.container:void 0,r=!!this._sceneRenderer?.target&&a!==t;if(!this._sceneRenderer||this._sceneRenderer.kind!==e||r){this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const a="canvas"===e?i.CanvasRenderer:i.SvgRenderer;this._sceneRenderer=new a,this._sceneRenderer.mount({container:t,width:n,height:o,pixelRatio:this._scenePixelRatio}),this._lastScenePick=null,this._sceneRenderer.on(e=>this._routeSceneEvent(e))}else this._sceneRenderer.resize(n,o)}_routeSceneEvent(e){$c(this,Mc(this,e.point),()=>this._dispatchSceneEvent(e))}_dispatchSceneEvent(e){if(this._sharedHover(e),Ea(this,e),this._transitionEndsAt&&Date.now()<this._transitionEndsAt)return;const t=e.pick,n=(t,n,i,o)=>{const a=this.schema.on&&this.schema.on[t];if("function"==typeof a)try{a.call(this,n,i,o,e.nativeEvent)}catch(e){!function(e){const t=globalThis.reportError;"function"==typeof t?t(e):console.error(e)}(e)}};if("mouseleave"===e.type){const e=this._lastScenePick;if(e){n("mouseleave."+(e.isLegend?"legend":"shape"),e.d,e.i,e.x);for(const t of e.shapeTargets)n(`mouseleave.${t.shapeType}`,t.d,t.i,t.x);n("mouseleave",e.d,e.i,e.x)}return this._lastScenePick=null,void(this._hoverDatum=null)}if(!t||!t.node)return;const i=t.node;if("axis"===i.interactionGroup||"timeline"===i.interactionGroup||"trend"===i.interactionGroup)return;const o=e.nativeEvent&&e.nativeEvent.target,a="legend"===i.interactionGroup||!(!o||"function"!=typeof o.closest)&&!!o.closest('[data-key="viz-legend"]'),r=a?"legend":"shape",s=`${e.type}.${r}`,{d:c,i:l,x:h}=this._interactionDatum(t,e);if(void 0===c)return;const u=a?[]:pf(t.node,{d:c,i:l,x:h});this._lastScenePick={d:c,i:l,x:h,isLegend:a,shapeTargets:u,node:t.node},this._hoverDatum=h,n(s,c,l,h);for(const t of u)n(`${e.type}.${t.shapeType}`,t.d,t.i,t.x);n(e.type,c,l,h)}_scheduleSceneRepaint(){this._sceneRenderer&&("function"==typeof requestAnimationFrame?null==this._sceneRepaintRAF&&(this._sceneRepaintRAF=requestAnimationFrame(()=>{this._sceneRepaintRAF=void 0,this._drawSceneToTarget(0)})):this._drawSceneToTarget(0))}destroy(){return at(this),Ct(this),this._resizeObserver?.disconnect(),this._fontsUnsubscribe?.(),this._fontsUnsubscribe=void 0,this._tooltipClass.data([]).render(),t.select("body").on(`touchstart.${this._uuid}`,null),this._visiblePoll&&(this._visiblePoll=clearInterval(this._visiblePoll)),this._resizePoll&&(this._resizePoll=clearTimeout(this._resizePoll)),this._scrollPoll&&(this._scrollPoll=clearTimeout(this._scrollPoll)),this._visibleUnobserve?.(),this._visibleUnobserve=void 0,this._unloadUnobserve?.(),this._unloadUnobserve=void 0,null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),this.schema.scrollContainer&&t.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`,null),this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&(this._sceneRenderer.destroy(),this._sceneRenderer=void 0),this}constructor(){var e;super(),Ms(this),(e=this).schema.legendInset=!0,e.schema.legendInsetConfig={}}}function xf(e,t=yf){class n extends t{_draw(t){return super._draw(t),e.layoutStage&&"chrome"!==this._facetStep&&function(e,t,n,i){if(function(e){return!0===e.paintDriven}(t))throw new Error(`runChartDraw cannot drive ${t.name} — it's a paint-driven chart (ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely on Plot._paint to populate _chartScene imperatively; their _draw should NOT call runChartDraw.`);e._chartScene=[];const o=ne({viz:e},[n]);if(!Array.isArray(e._chartScene))throw new Error(`runChartDraw: stage for ${t.name} replaced viz._chartScene with a non-array value (got ${typeof e._chartScene}). Stages should use \`(v._chartScene ||= []).push(...)\` rather than reassigning.`);const a=e._chartScene.slice(),r=t.emit(o);e._chartScene=[...a,...r],e._chartTransform=i?i(e):function(e){return{x:e._margin.left,y:e._margin.top}}(e),e._chartClip=t.chartClip?t.chartClip(e):void 0,e._bodyRect=t.chartBodyRect?t.chartBodyRect(e):{x:0,y:0,...ie(e)}}(this,e,e.layoutStage,e.chartTransform),this}toScene(){const t=super.toScene();return e.decorateScene?e.decorateScene(this,t):t}_sizeLegendScale(t){return e.sizeLegendScale?e.sizeLegendScale(this,t):super._sizeLegendScale(t)}_insetRegion(){return e.insetRegion?e.insetRegion(this):super._insetRegion()}_colorScaleShape(t,n){return e.colorScaleShape?e.colorScaleShape(this,t,n):super._colorScaleShape(t,n)}_facetHooks(){return e.facet?{...super._facetHooks(),...e.facet}:super._facetHooks()}_thresholdLegend(t){return e.thresholdFunction?e.thresholdFunction(this,t,t):super._thresholdLegend(t)}_thresholdFunction(t,n,i){return e.thresholdFunction?e.thresholdFunction(this,t,i):super._thresholdFunction(t,n,i)}constructor(){super(),function(e,t){if(t.ctx)for(const[n,i]of Object.entries(t.ctx))e.ctx[n]=i;if(t.defaults){const n=e;for(const[e,i]of Object.entries(t.defaults))n[`_${e}`]=i}t.fields&&ee(e,t.fields),t.setup&&t.setup(e)}(this,e)}}return Object.defineProperty(n,"name",{value:e.name}),n}const bf=e=>e._swarm?e._swarm.axis:"y"===e.schema.discrete?"x":"y";function _f(e){return!(!Array.isArray(e)||e.length>2)&&(void 0===e[0]||null===e[0])!=(void 0===e[1]||null===e[1])}function kf(e,t){if("x"!==t&&"y"!==t)return;const n=e[`_${t}Config`]?.domain;if(!_f(n)||!((e,t)=>e.schema.discrete!==t&&!e.schema[`${t}Sort`]&&e._swarm?.cross!==t)(e,t))return;const i=n.slice();return"y"===t&&2===i.length?i.reverse():i}const vf=(e,t)=>kf(e,t)??e.schema[`${t}Domain`];function wf(e){const t=e._userBaseline;if("number"!=typeof t||!Number.isFinite(t))return;const n=bf(e);if(e[`_${n}Time`]||e.schema[`${n}Sort`])return;const i=e[`_${n}Config`];return"log"===i?.scale&&t<=0?void 0:n}function Sf(e,t){return Boolean(vf(e,t))||wf(e)===t}function Cf(e,t){const n=e[`_${t}Config`]?.domain;return Array.isArray(n)&&n.some(e=>null!=e)&&!_f(n)}function Mf(e,t,n){return Cf(e,t)?"none":n}function $f(e,t,n){const i=e[`_${t}Config`]?.rounding;return i??Mf(e,t,n)}function Af(e,t){const n=e[`_${t}Config`]?.domain;if(void 0!==n&&!kf(e,t))return!1;const i=vf(e,t);return i?_f(i):wf(e)===t}function zf(e,t){const n=e[`_${t}Config`]??{};if(!Af(e,t))return n;const i={...n};return delete i.rounding,kf(e,t)&&delete i.domain,i}function Df(e,t,n){const i=vf(e,t),o=i?i.slice():void 0;if(wf(e)!==t)return o;const a=e._userBaseline,r=n?.[1],s="number"==typeof r&&r<=a?1:0,c=o??[];return void 0===c[s]&&(c[s]=a),c}function Ff({stackKey:e,fromZero:t}){return function({data:n,x:i,y:o,x2:a,y2:r,buffer:s=10}){const c=a?"x2":"x",l=r?"y2":"y",u="x"===this.schema.discrete?o:i,d=u.domain().slice(),f="x"===this.schema.discrete;let m,p;if(f&&d.reverse(),this.schema.stacked){const t=h.groups(n,t=>e(t,this.schema.discrete)).map(([,e])=>e.map(e=>e[f?l:c]));p=t.map(e=>h.sum(e.filter(e=>e>0))),m=t.map(e=>h.sum(e.filter(e=>e<0)))}else{const e=n.map(e=>e[f?l:c]);p=t?e.filter(e=>e>0):e,m=t?e.filter(e=>e<0):e}let g=u(h.max(p));t&&!(f?g<u(0):g>u(0))||(g+=f?-s:s),g=u.invert(g);let y=u(h.min(m));return t&&!(f?y>u(0):y<u(0))||(y+=f?s:-s),y=u.invert(y),g>d[1]&&(d[1]=g),y<d[0]&&(d[0]=y),f&&d.reverse(),u.domain(d),[i,o]}}var Bf=Ff({stackKey:(e,t)=>`${e[t]}_${e.group}`,fromZero:!0}),Lf=Ff({stackKey:(e,t)=>e[t],fromZero:!1});const Pf=(e,t,n)=>{if(e.padding)e.padding(.5);else{const i=Array.from(new Set(t.map(e=>+e[n]))).reduce((e,t,n,i)=>{if(!n)return e;const o=i[n-1];return!e||t-o<e?t-o:e},0),o=e.domain().slice();"y"===n&&o.reverse(),o[0]=new Date(+o[0]-i/2),o[1]=new Date(+o[1]+i/2),"y"===n&&o.reverse(),e.domain(o)}},Rf=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,e<0?1:0);function Ef(e,t,n,i,o,a,r){if(void 0===n||isNaN(o[0])||isNaN(o[1]))return o;if(r&&(o=o.slice().reverse()),o[0]===o[1]){if(o=o.slice(),"log"===t)(o=[(c=o[0],Math.pow(10,Math.floor(Math.log10(Math.abs(c))))*Math.pow(-1,c<0?1:0)),Rf(o[0])])[1]<o[0]&&o.reverse();else{const e=Math.abs(parseFloat(o[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));o[0]-=e,o[1]+=e}return e.domain(r?o.slice().reverse():o),r?o.reverse():o}var c;const l=o[0]===o[1]?10:Math.abs(Math.log(o[1]-o[0])/100),h=()=>{let o=e.copy(),c=!1;if("log"===t){let t=e.domain().slice(),n=e.range().slice();if(r&&(t=t.reverse(),n=n.reverse()),c=t[0]*t[1]<0,c){const e=s.scaleLog().domain([1e-6,Math.abs(t[a])]).range([0,1])(Math.abs(t[a?0:1])),i=e/(e+1)*(n[1]-n[0]);t=(0===a?[t[0],1e-6]:[1e-6,t[1]]).map(Math.abs),n=0===a?[n[0],n[0]+i]:[n[0]+i,n[1]]}o=s.scaleLog().domain(t).range(n)}let l=!1;const h=o.range();let u;return u=o("log"===t&&c?Math.abs(n):n),r?0===a?l=u+i>h[a]:1===a&&(l=u-i<h[a]):0===a?l=u-i<h[a]:1===a&&(l=u+i>h[a]),l};if(e.invert&&h()){const s=10;if("log"===t){let t=0;for(;t<10&&h();){const n=(0===a?-1:1)*(o[a]<0?-1:1);o[a]+=o[a]*l*n,e.domain(r?o.slice().reverse():o),t++}}else if(0===a){const t=e.invert(e(n)+(i+s)*(r?1:-1));t<o[a]&&(o[a]=t,e.domain(r?o.slice().reverse():o))}else if(1===a){const t=e.invert(e(n)+(i+s)*(r?-1:1));t>o[a]&&(o[a]=t,e.domain(r?o.slice().reverse():o))}}return r?o.reverse():o}const Nf={Bar:Bf,Box:Lf,Circle:function({data:e,x:t,y:n,x2:i,y2:o,yScale:a,xScale:r,config:s,buffer:c}){t=t.copy(),n=n.copy();const l=i?"x2":"x",h=o?"y2":"y";let u=t.domain().slice(),d=n.domain().slice();return!t.invert&&t.padding&&Pf(t,e,this.schema.discrete),!n.invert&&n.padding&&Pf(n,e,this.schema.discrete),(t.invert||n.invert)&&e.forEach(e=>{const i=s?.r,o=c||2*("function"==typeof i?i(e.data,e.i):Number(i)||0);t.invert&&(u=Ef(t,r??"linear",e[l],o,u,0,!1),u=Ef(t,r??"linear",e[l],o,u,1,!1)),n.invert&&(d=Ef(n,a??"linear",e[h],o,d,0,!0),d=Ef(n,a??"linear",e[h],o,d,1,!0))}),[t,n]},Line:function({data:e,x:t,y:n,x2:i,y2:o}){const a=i?"x2":"x",r=o?"y2":"y",s="x"===this.schema.discrete?n:t,c=s.domain().slice();"x"===this.schema.discrete&&c.reverse();const l=e.map(e=>e["x"===this.schema.discrete?r:a]),u=s.invert(s(h.max(l))+("x"===this.schema.discrete?-10:10));return u>c[1]&&(c[1]=u),"x"===this.schema.discrete&&c.reverse(),s.domain(c),[t,n]},Rect:function({data:e,x:t,y:n,x2:i,y2:o,yScale:a,xScale:r,config:s}){t=t.copy(),n=n.copy();const c=i?"x2":"x",l=o?"y2":"y";let h=t.domain().slice(),u=n.domain().slice();return!t.invert&&t.padding&&Pf(t,e,this.schema.discrete),!n.invert&&n.padding&&Pf(n,e,this.schema.discrete),(t.invert||n.invert)&&e.forEach(e=>{if(t.invert){const n=(s?.width)(e.data,e.i);h=Ef(t,r??"linear",e[c],n,h,0,!1),h=Ef(t,r??"linear",e[c],n,h,1,!1)}if(n.invert){const t=(s?.height)(e.data,e.i);u=Ef(n,a??"linear",e[l],t,u,0,!0),u=Ef(n,a??"linear",e[l],t,u,1,!0)}}),[t,n]}};function Tf(e,t,n){const i="x"===e?[t.x,n.bottom]:"x2"===e?[t.x,n.top]:"y"===e?[n.left,t.y]:[n.right,t.y];return[[t.x,t.y],i]}function Of(e,t){return"function"==typeof e?e(t.datum,t.index):e}function Wf(e){const t=e;return t.interactive=!1,t.interactionGroup="axis",e}function jf(e,t,n,i){const o=e.schema.axisHoverConfig.guideConfig||{},a=Of(o.strokeDasharray,t);return t.badges.filter(e=>e.guide).map(e=>Wf({type:"line",key:`plot-axis-hover-guide-${e.axis}`,points:Tf(e.axis,t.point,n),paint:{fill:"none",stroke:Of(o.stroke,t)??i,strokeWidth:Of(o.strokeWidth,t)??1,strokeOpacity:Of(o.strokeOpacity,t)??1,strokeDasharray:Array.isArray(a)?a:Oo(a)}}))}function Hf(e,t){const i=e._plotArea;if(!i)return{guides:[],badges:[]};const o=function(e){return{left:e.x,right:e.x+e.width,top:e.y,bottom:e.y+e.height}}(i),a=t.color||r.colorGray[500];return{guides:jf(e,t,o,a),badges:t.badges.map(i=>function(e,t,i,o,a){const s=e.schema.axisHoverConfig.badgeConfig||{},c=Of(s.fontSize,t)??12,l=Of(s.fontFamily,t)||`${e.schema.fontFamily}`,h=Of(s.fontWeight,t)??400,u=Of(s.padding,t)??4,d=Of(s.fill,t)??a,f=Of(s.fontColor,t)??r.colorContrast(d,e.schema.colorDefaults),m=n.textWidth(i.text,{"font-family":l,"font-size":c,"font-weight":h}),p=function(e,t,n,i){const{width:o,height:a}=n;return"x"===e?{x:t-o/2,y:i.bottom,width:o,height:a}:"x2"===e?{x:t-o/2,y:i.top-a,width:o,height:a}:"y"===e?{x:i.left-o,y:t-a/2,width:o,height:a}:{x:i.right,y:t-a/2,width:o,height:a}}(i.axis,i.at,{width:m+2*u,height:c+2*u},o),g=`plot-axis-hover-badge-${i.axis}`;return Wf({type:"group",key:g,children:[Wf({type:"rect",key:`${g}-box`,...p,rx:Of(s.rx,t)??0,paint:{fill:d}}),Wf({type:"text",key:`${g}-text`,x:0,y:0,transform:{x:p.x+p.width/2,y:p.y+p.height/2},lines:[{text:i.text,x:0,y:0,width:m}],font:{family:l,size:c,weight:h,anchor:"middle",baseline:"middle"},paint:{fill:f}})]})}(e,t,i,o,a))}}function If(e){const t=`curve${e.charAt(0).toUpperCase()}${e.slice(1)}`,n=L[t];return"function"==typeof n?n:L.curveLinear}function Gf(e,t){const n=au(e,"Line").curve,i="function"==typeof n?t?n(t,t.i):void 0:n;return"string"==typeof i&&i?i:"linear"}const Vf="fill-between",qf=1e5;function Yf(){return{fillOpacity:.25}}function Kf(e,t){let n=[];!0===e?n=t.length>=2?[[t[0],t[1]]]:[]:Array.isArray(e)&&(n=e.every(Array.isArray)?e:[e]);const i=new Set(t);return n.filter(e=>e.length>=2).map(e=>[`${e[0]}`,`${e[1]}`]).filter(([e,t])=>e!==t&&i.has(e)&&i.has(t))}function Uf(e,t,n,i){const o=new Map;t.forEach(e=>o.set(`${e.discrete}`,e));const a=[];return e.forEach(e=>{const t=o.get(`${e.discrete}`);if(!t)return;const r={pos:n(e),a:i(e),b:i(t)};[r.pos,r.a,r.b].every(Number.isFinite)&&a.push(r)}),a}function Xf(e,t,n,i){const o=y.area().curve(If(i));return n?o.x(e=>e.pos).y0(t).y1(e=>e.a):o.y(e=>e.pos).x0(t).x1(e=>e.a),o(e)||""}function Qf(e){const{viz:t}=e,n=e.values,i=Kf(t.schema.fillBetween,function(e){return Array.from(new Set(e.map(e=>`${e.id}`)))}(n));if(!i.length)return[];const o="x"===(t.schema.discrete||"x"),a=e.shapeConfig.x,r=e.shapeConfig.y,s=o?a:r,c=o?r:a,l=Gf(t,n[0]);return i.flatMap(e=>function(e,t,[n,i],o){const a=t.filter(e=>`${e.id}`===n),r=t.filter(e=>`${e.id}`===i),s=Uf(a,r,o.pos,o.val);if(s.length<2)return[];const c=Zf(t,o.val,o.horizontal?"y":"x"),l=`${Vf}-${n}-${i}`,h=[{id:`${l}-${n}`,above:n,below:i,rep:a[0],edge:-c*qf},{id:`${l}-${i}`,above:i,below:n,rep:r[0],edge:c*qf}],u=h.flatMap(e=>{const t={...e.rep.data,above:e.above,below:e.below};return s.map(n=>({__d3plus__:!0,data:t,i:e.rep.i,id:e.id,...n}))}),d=o.horizontal?{x:e=>e.pos,x0:e=>e.pos,x1:null,y:e=>e.a,y0:e=>e.b,y1:e=>e.a}:{y:e=>e.pos,y0:e=>e.pos,y1:null,x:e=>e.a,x0:e=>e.b,x1:e=>e.a},f=eu("Area").renderMode("compute").data(u).config({...d,curve:o.curve,duration:e.schema.duration,label:!1,fill:tm(e),strokeWidth:0}).config(function(e){return au(e,"Area",{...em(e),...e.schema.fillBetweenConfig})}(e));f.render();const m=su(f);return h.flatMap(e=>{const t=m.filter(t=>t.key===e.id||t.key===`${e.id}-bgimage`);if(!t.some(t=>t.key===e.id))return[];t.forEach(e=>e.interactive=!1);const n=Xf(s,e.edge,o.horizontal,o.curve);return[{type:"group",key:`${e.id}::clip`,interactive:!1,clip:{type:"path",d:n},children:t}]})}(t,n,e,{pos:s,val:c,horizontal:o,curve:l}))}function Zf(e,t,n){const i=e[0];for(const o of e){const e=Number(o[n])-Number(i[n]),a=t(o)-t(i);if(e&&a)return Math.sign(e)===Math.sign(a)?1:-1}return"y"===n?-1:1}const Jf=["texture","textureDefault","backgroundImage","backgroundImageFit"];function em(e){const t=e.schema.shapeConfig??{},n=t.Area??{},i={};for(const e of Jf){const o=void 0!==n[e]?n[e]:t[e];void 0!==o&&(i[e]=o)}return i}function tm(e){return(t,n)=>{const{Line:i,stroke:o}=e.schema.shapeConfig,a=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof a?a(t,n):a}}function nm(){return{fillOpacity:.05,fontSize:12,fontOpacity:.7,lineDasharray:"6 4",strokeDasharray:"4 4",strokeOpacity:.4,strokeWidth:1}}function im(e,t){return e instanceof Date?+e:f.finite(e)?e:t}function om(e){const t=new Map;return e.forEach((e,n)=>{t.has(`${e}`)||t.set(`${e}`,n)}),e=>im(e,t.get(`${e}`)??NaN)}function am(e){return e.reduce((e,t)=>!e||t.at<e.at?t:e,void 0)}function rm(e,t=!1){const n=om(e.map(e=>e.value)),i=new Map;e.forEach(e=>{const t=i.get(e.series)??[];t.push({value:e.value,at:n(e.value),forecast:e.forecast}),i.set(e.series,t)});const o=new Map;for(const[e,n]of i){const i=am(n.filter(e=>e.forecast&&Number.isFinite(e.at)));if(!i)continue;const a=n.filter(e=>e.at<i.at);if(a.length){const t=a.reduce((e,t)=>t.at>e.at?t:e);o.set(e,{value:t.value,next:i.value,at:t.at})}else t&&o.set(e,{value:i.value,next:i.value,at:i.at})}return o}function sm(e,t){const n=e.schema.discrete||"x",i=e.schema.forecast;let o;if("function"==typeof i)o=Boolean(i(t.data,t.i));else{const i=t["x"===n?"y":"x"];o=(e._confidence||[]).some(e=>{const n=e?e(t.data,t.i):void 0;return f.finite(n)&&n!==i})}return{series:`${t.id}`,value:t[n],forecast:o}}function cm(e){let t;const n=[];for(const i of e._trendFits||[])i.samples.forEach((e,o)=>{const a=e[i.axis],r=im(a,o);e.step?n.push({value:a,at:r}):e.projected||t&&!(r>t.at)||(t={value:a,at:r})});if(!t)return null;const i=am(n.filter(e=>e.at>t.at));return i?{value:t.value,next:i.value,series:new Map}:null}function lm(e,t){const i=e.schema.forecast;if(!1===i||null===i)return null;const o=function(e,t){const i=e.schema.forecast;if(!1===i||null==i)return null;const o=e.schema.discrete||"x";if(!0===i||"auto"===i||"function"==typeof i){const n=rm(t.map(t=>sm(e,t)),"function"==typeof i),o=am(Array.from(n.values()));if(!o)return null;const a=new Map(Array.from(n,([e,t])=>[e,t.value]));return{value:o.value,next:o.next,series:a}}const a=("x"===o?e._xTime:e._yTime)?n.date(i):i,r=t.map(e=>e[o]),s=om([...r,a]),c=s(a),l=am(r.map(e=>({value:e,at:s(e)})).filter(e=>e.at>c));return l?{value:a,next:l.value}:{value:a}}(e,t);if(void 0!==i&&!0!==i&&"auto"!==i&&"function"!=typeof i)return o;const a=cm(e);if(!o||!a)return o||a;const r=e.schema.discrete||"x",s=om(t.map(e=>e[r]));return s(a.value)<s(o.value)?{...a,series:o.series}:o}const hm=new WeakMap,um=new WeakSet,dm=e=>e instanceof Date?String(e.getTime()):String(e);function fm(e){if("function"==typeof e)return e;if("string"==typeof e&&e){const t=Be(e);return hm.set(t,{key:e}),t}}function mm(e,t){return hm.set(e,{text:t}),e}function pm(e,t,n,i={}){const a=new Map;for(const n of e){if(!n.data)continue;const e=dm(n[t]),i=a.get(e);i?i.data.push(n.data):a.set(e,{value:n[t],data:[n.data]})}return Array.from(a.values(),({value:e,data:t})=>{const a=1===t.length?t[0]:o.merge(t,i);return{value:e,size:Number(n(a,0)),data:a}})}function gm(e){let t=0;return e.filter(e=>Number.isFinite(e.size)&&e.size>0).map(({value:e,size:n})=>{const i=t+n,o={value:e,size:n,start:t,end:i,mid:(t+i)/2};return t=i,o})}function ym(e,t,n){const i=e.schema.barWidth,o=e.schema.discrete,a=e._discreteExtent&&!um.has(e._discreteExtent);if("function"!=typeof i||"x"!==o&&"y"!==o||a)return function(e){e._barSpans=void 0,e._discreteExtent&&um.has(e._discreteExtent)&&(e._discreteExtent=void 0)}(e),[t,n];const r=pm(n,o,i,e.schema.aggs),s=e.schema[`${o}Sort`];s&&r.sort((e,t)=>s(e.data,t.data));const c=gm(r),l=new Map(c.map(e=>[dm(e.value),e])),h=new WeakMap,u=e=>e.filter(e=>{const t=l.get(dm(e[o]));return!!t&&(e.data&&h.set(e.data,t),e[o]=t.mid,!0)}),d=u(t),f=n===t?d:u(n),m=c.length?c[c.length-1].end:0,p={axis:o,spans:c,total:m,byDatum:h};e._barSpans=p,"x"===o?e._xTime=!1:e._yTime=!1;const g=e=>{const t=p.byDatum.get(e);return t?[t.start,t.end]:[0,0]};return um.add(g),e._discreteExtent=g,[d,f]}function xm(e){return e instanceof Date?d.formatDate(e,[e]):String(e)}function bm(e,t,n){return e.total?`${d.formatAbbreviate(t.size/e.total*100,n)}%`:""}function _m(e,t,n){return t?"x"===n?`${e}\n${t}`:`${e} (${t})`:e}function km(e,t){const n=e._barSpans;if(!n||n.axis!==t)return{};const i=e.schema.locale,o=n.spans.map(e=>e.mid),a=new Map(n.spans.map(e=>[e.mid,xm(e.value)])),r=e=>a.get(e)??"";if(!e.schema.barWidthShare)return{labels:o,ticks:o,tickFormat:r};const s=new Map(n.spans.map(e=>[e.mid,_m(xm(e.value),bm(n,e,i),t)]));return{labels:o,ticks:o,tickFormat:e=>s.get(e)??"",rotatedTickFormat:r}}function vm(e){const t=e.schema.barWidth,n=t?hm.get(t):void 0;return n?.key?n.key:e.schema.translate(n?.text??"Width")}function wm(e,t){const n=e._barSpans,i=n&&t&&"object"==typeof t?n.byDatum.get(t):void 0;if(!n||!i)return[];const o=e.schema.locale,a=bm(n,i,o);return[[vm(e),`${d.formatAbbreviate(i.size,o)}${a?` (${a})`:""}`]]}function Sm(e,t){return Boolean(e._discreteExtent)&&e.schema.discrete===t}function Cm(e,t){return e._discreteExtent(t.data)}function Mm(e,t){const n=t.filter(e=>e.data).map(t=>Cm(e,t));return[h.min(n,e=>e[0]),h.max(n,e=>e[1])]}const $m={method:"confidenceConfig",shapes:{Area:"Area",Bar:"Path"},extra:{"":["bandOpacity","capWidth","tooltip"],Bar:["capWidth"]}};const Am=[.15,.6],zm=e=>!!e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype;function Dm(e){const[t,n,i]=Array.isArray(e)?e:zm(e)?[e.lower,e.upper,e.label]:[],o=function(e){const t=e=>"function"==typeof e?e:!("string"!=typeof e||!e)&&Be(e),n=Array.isArray(e)?[t(e[0]),t(e[1])]:[!1,!1];return!(!n[0]&&!n[1])&&n}([t,n]);if(!o)return null;const a={lower:o[0],upper:o[1]};return"string"!=typeof i&&"number"!=typeof i||(a.label=`${i}`),a}function Fm(e){const t=function(e){return Array.isArray(e)&&e.length>0&&e.every(e=>Array.isArray(e)||zm(e))}(e)?e:[e];return t.map(Dm).filter(e=>null!==e)}function Bm(e){const t=e._confidence;if(!t)return[];const n=e._confidenceBands;return n&&n.length?n:[{lower:t[0],upper:t[1]}]}function Lm(e,t,n){return t?Bm(e).map((i,o)=>{const a={label:i.label??`${e.schema.translate("Band")} ${o+1}`},r=i.lower?i.lower(t,n):void 0,s=i.upper?i.upper(t,n):void 0;return f.finite(r)&&(a.lower=r),f.finite(s)&&(a.upper=s),a}):[]}function Pm(e,t){if(t<=0)return[];if(f.finite(e))return Array.from({length:t},()=>e);const n=Array.isArray(e)&&e.length&&e.every(f.finite)?e:Am;if(1===n.length)return Array.from({length:t},()=>n[0]);const i=x.piecewise(x.interpolateNumber,n);return Array.from({length:t},(e,n)=>i(1===t?1:n/(t-1)))}function Rm(e){let t=0;return e.map(e=>{const n=Math.min(1,Math.max(0,e)),i=t>=1?0:Math.max(0,1-(1-n)/(1-t));return t=1-(1-t)*(1-i),+i.toFixed(6)})}function Em(e,t){return null==e||"number"==typeof e&&Number.isNaN(e)?t:e}function Nm(e,t){const n=Bm(e).slice(1),i=[];for(const e of n)for(const n of t){const t=n.data,o=n.i;for(const n of[e.lower,e.upper]){const e=n?n(t,o):void 0;f.finite(e)&&i.push(e)}}return i}function Tm(e){if(!e.length)return 0;const t=e.slice().sort((e,t)=>e[0]-t[0]);let[n,i]=t[0];for(let e=1;e<=t.length;e++){const o=t[e];if(o&&o[0]<i)o[1]>i&&(i=o[1]);else{if(n<0&&i>0)return-n<=i?n:i;o&&([n,i]=o)}}return 0}function Om(e,t=0){const n=e.map(()=>0);if(e.length<2)return n;const i=e.map((e,t)=>t).sort((t,n)=>e[t].value-e[n].value||t-n),o=2*Math.max(...e.map(e=>e.r))+t,a=[];let r=0;for(const s of i){const{value:i,r:c}=e[s];for(;r<a.length&&e[a[r]].value<i-o;)r++;const l=[];for(let o=r;o<a.length;o++){const r=a[o],s=i-e[r].value,h=c+e[r].r+t;if(s<h){const e=Math.sqrt(h*h-s*s);l.push([n[r]-e,n[r]+e])}}n[s]=Tm(l),a.push(s)}return n}function Wm(e,t,n=1){let i=0;return e.forEach((e,o)=>{i=Math.max(i,Math.abs(t[o])+e.r*n)}),i}const jm=(e,t)=>1===t?e:e.map(e=>({value:e.value,r:e.r*t}));function Hm(e,t,n){let i=1;for(let o=0;o<12;o++){const o=Wm(e,Om(jm(e,i),t*i),i);if(o<=n||0===o)break;i*=Math.max(.5,.98*Math.sqrt(n/o))}return i}function Im(e,t){const{padding:n,extent:i,overflow:o}=t,a="shrink"===o&&i>0?Math.min(1,...e.map(e=>Hm(e,n,i))):1;return{offsets:e.map(e=>{const t=Om(jm(e,a),n*a);return"visible"===o?t:t.map((t,n)=>{const o=Math.max(0,i-e[n].r*a);return Math.max(-o,Math.min(o,t))})}),scale:a}}const Gm=e=>null==e||""===e,Vm=e=>"number"==typeof e&&Number.isFinite(e)||e instanceof Date,qm=e=>e.some(Vm)&&e.every(e=>Gm(e)||Vm(e));function Ym(e,t){if(!e||!t.length)return null;const n=t.map(e=>e.x),i=t.map(e=>e.y);let o;if("x"===e||"y"===e)o=e;else if("auto"===e){if(!t.every(e=>"Circle"===e.shape))return null;i.every(Gm)?o="x":n.every(Gm)&&(o="y")}else o=qm(n)?"x":"y";if(!o||!qm("x"===o?n:i))return null;const a="x"===o?"y":"x",r=t.some(e=>!Gm(e[a])&&!Vm(e[a]));return{axis:o,cross:a,lanes:r}}function Km(e,t){const{cross:n,lanes:i}=t;for(const t of e)t[n]=i&&!Gm(t[n])?`${t[n]}`:""}const Um=(e,t)=>!!e._swarm&&e._swarm.cross===t&&!e._swarm.lanes;function Xm(e,t){const n=e._swarm,i=e.schema.swarmConfig||{},{axis:o,cross:a}=n,r="x"===o?t.x:t.y,s="x"===a?t.x:t.y,c="x"===a?t.xRange:t.yRange,l=Math.abs(c[c.length-1]-c[0]),h=new Map;n.lanes&&t.lanes.forEach(e=>h.set(`${e}`,s(e,a)));const u=Array.from(h.values()).sort((e,t)=>e-t);let d=u.length>1?1/0:l;for(let e=1;e<u.length;e++)d=Math.min(d,u[e]-u[e-1]);const f=(c[0]+c[c.length-1])/2,m=new Map;t.values.forEach((e,n)=>{const i=`${e[a]}`;m.has(i)||m.set(i,{rows:[],nodes:[]});const s=m.get(i);s.rows.push(e),s.nodes.push({value:r(e[o]),r:Math.max(0,Number(t.r(e,n))||0)})});const p=i.padding??1,g=Array.from(m.values()),y=Im(g.map(e=>e.nodes),{padding:p,extent:Math.max(0,d/2-p/2),overflow:i.overflow??"shrink"}),x=new Map;return g.forEach((e,t)=>{e.rows.forEach((n,i)=>{const r=h.get(`${n[a]}`)??f,s=e.nodes[i].value,c=r+y.offsets[t][i];x.set(n,{x:"x"===o?s:c,y:"x"===o?c:s,r:e.nodes[i].r*y.scale})})}),x}const Qm=["x","x2","y","y2"];function Zm(e,t){const n=e._plotFacetScales?.padded;if(!n)return t;const i={...t};for(const e of Qm){const t=i[e];t&&n[e]&&"function"==typeof t.invert&&(i[e]=t.copy().domain(n[e]))}return i}function Jm(e,t){const n=e.schema[`${t}Break`],i={break:void 0!==n&&n},o=zf(e,t),a={...km(e,t),...e._plotAxisDefaults?.[t]};if(!Object.keys(a).length)return{...i,...o};const r=Object.fromEntries(Object.entries(o).filter(([,e])=>void 0!==e));return G({...i,...a},r)}function ep(e,t){const n=Boolean(e.schema.baselineBreak)&&bf(e)===t,{baseline:i}=e.schema;return"number"==typeof i?{baseline:i,baselineBreak:n}:{baselineBreak:n}}function tp(e,t,n,i=e.schema[`${t}Domain`]){if(!e.schema.baselineBreak||t!==bf(e)||"linear"!==n)return!1;const{baseline:o}=e.schema;if("number"!=typeof o||!Array.isArray(i))return!1;const[a,r]=i;return"number"==typeof a&&a>o||"number"==typeof r&&r<o}function np(e,t){const n="y"===bf(e),i=(n?e._yAxis:e._xAxis)?._baselineBreak,o=n?e._yFunc:e._xFunc;if(!i||!o)return t;const a=o(i.edge),r=o(i.value);if(!Number.isFinite(a)||!Number.isFinite(r))return t;const s=n?1:0;return t.map(e=>(e[s]-a)*(r-a)<=0?e:n?[e[0],a]:[a,e[1]])}function ip(e,t){const n="y"===bf(e),i=n?e._yAxis:e._xAxis;if(!i||"function"!=typeof i._getRange)return;const o=i._getRange().map(Number);if(o.length<2||o.some(e=>!Number.isFinite(e)))return;const a=n?t.x2Height:0,r=n?t.yOffset:0;return[Math.min(o[0],o[o.length-1])-a-r,Math.max(o[0],o[o.length-1])-a]}function op(e,t,n){if(!n)return e;const[i,o]=n,a=e=>"number"==typeof e&&Number.isFinite(e)?Math.min(o,Math.max(i,e)):e,r=Object.assign({},e);for(const e of[t,`${t}0`,`${t}1`]){const t=r[e];if("function"==typeof t){const n=t;r[e]=function(...e){return a(n.apply(this,e))}}else"number"==typeof t&&(r[e]=a(t))}return r}function ap(e,t,n){if(!_f(e)||!t)return;const i=e=>null!=e,o=t.slice();return"number"==typeof n&&(o[0]>n?o[0]=n:o[1]<n&&(o[1]=n)),{pinned:[i(e[0]),i(e[1])],auto:o}}function rp(e,t,n,i){const o=t.pinned[0]?1:0,a=On(o?[+t.auto[0],e[1]]:[e[0],+t.auto[1]],n,i);if(!a)return;const r=a[o];if(o?r<=e[0]:r>=e[1])return;const s=e.slice();return s[o]=r,s}const sp=(e,t)=>e[`_${t}Config`]?.rounding??e._plotAxisDefaults?.[t]?.rounding??"outside",cp=({viz:e,plotScales:t,plotConfigScales:n,plotOpenEnds:i})=>{if(!t||!n||!i)return{};const o={...t};for(const t of["x","y"]){const a=i[t],r=n[`${t}ConfigScale`],s=sp(e,t);if(!a||!Tn.includes(r)||"none"===s)continue;const c=o[t],l=e=>"y"===t?e.slice().reverse():e,h=rp(l(c.domain().map(Number)),a,s,r);h&&(o[t]=c.copy().domain(l(h)))}return{plotScales:o}},lp=B;function hp(e,t){return t?e.map(e=>void 0===e?e:n.date(e)):e.slice()}function up(e,t,n,i){const o=e[`_${t}Time`]?"Time":!Sm(e,t)&&(e.schema.discrete===t||e.schema[`${t}Sort`])||e._swarm?.cross===t?"Point":"Linear",a=n[t]?hp(n[t],e[`_${t}Time`]):i[t],r=e.schema[`${t}2Domain`]?hp(e.schema[`${t}2Domain`],e[`_${t}2Time`]):i[`${t}2`];return"Point"!==o&&(a&&void 0===a[0]&&(a[0]=i[t][0]),a&&void 0===a[1]&&(a[1]=i[t][1]),r&&void 0===r[0]&&(r[0]=i[`${t}2`][0]),r&&void 0===r[1]&&(r[1]=i[`${t}2`][1])),[a,o,r,o]}function dp(e,t,n,i){const o=e[`_${n}Config`].scale;if("auto"===o){if(e.schema.discrete===n)return i;const o=t.map(e=>e[n]);return h.deviation(o)/h.mean(o)>3?"log":"linear"}return o||i}const fp=(e,t)=>e.map(e=>e[t]).filter(e=>![NaN,void 0,!1].includes(e));const mp=({viz:e,plotFormattedData:t,plotAxisData:n,plotInitialDomains:i})=>{const o=t||[],a=n||[];let r=i;const s=e.schema.width-e._margin.left-e._margin.right,c=e.schema.height-e._margin.top-e._margin.bottom,l=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,u=e.schema.discrete?"x"===e.schema.discrete?"y2":"x2":void 0,d=[l,u].filter(e=>e),f={x:Df(e,"x",r.x),y:Df(e,"y",r.y)},m={x:ap(f.x,r.x,d.includes("x")?e.schema.baseline:void 0),y:ap(f.y,r.y,d.includes("y")?e.schema.baseline:void 0)},[p,g,y,x]=up(e,"x",f,r),[b,_,k,v]=up(e,"y",f,r),w=dp(e,a,"y",_).toLowerCase(),S=dp(e,a,"y2",v).toLowerCase(),C=dp(e,a,"x",g).toLowerCase(),M=dp(e,a,"x2",x).toLowerCase();r={x:p,x2:y||p.slice(),y:b,y2:k||b.slice()},function(e,t,n,i){Object.keys(t).forEach(o=>{"log"===e[`_${o}ConfigScale`]&&t[o].includes(0)&&(h.min(t[o])<0?t[o][1]=h.max(fp(n,o)):t[o][0]=h.min(fp(i,o)))})}(e,r,o,a),function(e,t,n,i,o){n.forEach(n=>{if(e[`_${n}Config`].domain&&!kf(e,n)){const i=e[`_${n}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),t[n]=i}else if(n&&void 0!==e.schema.baseline&&!tp(e,n,n.startsWith("x")?i.x:i.y,o[n])){const i=e.schema.baseline;t[n]&&t[n][0]>i?t[n][0]=i:t[n]&&t[n][1]<i&&(t[n][1]=i)}})}(e,r,d,{x:C,y:w},f);const $=lp[`scale${g}`]().domain(r.x).range(h.range(0,s+1,s/(r.x.length-1))),A=lp[`scale${x}`]().domain(r.x2).range(h.range(0,s+1,s/(r.x2.length-1))),z=lp[`scale${_}`]().domain(r.y.slice().reverse()).range(h.range(0,c+1,c/(r.y.length-1))),D=lp[`scale${v}`]().domain(r.y2.slice().reverse()).range(h.range(0,c+1,c/(r.y2.length-1)));return{plotDomains:r,plotScales:{x:$,y:z,x2:A,y2:D,xScale:g,yScale:_,x2Scale:x,y2Scale:v},plotConfigScales:{xConfigScale:C,yConfigScale:w,x2ConfigScale:M,y2ConfigScale:S},plotOpps:{opp:l,opp2:u,opps:d},plotOpenEnds:m}},pp="::confidence";function gp(e,t,n){const i=t<0?n[0]:n[1],o=t<0?n[1]:n[0];return i+(e-t)*(t?(i-o)/t:1)}function yp(e,t,n){const i=e[t],o={};for(const[t,a]of[["lower",e.lci],["upper",e.hci]])f.finite(a)&&(n&&f.finite(i)&&f.finite(n[0])&&f.finite(n[1])?o[t]=gp(a,i,n):n||(o[t]=a));return o}function xp(e,t,n,i){const o={lower:f.finite(e),upper:f.finite(t)};if(!i)return{lower:e,upper:t,end:n,caps:o};const[a,r]=i,s=(e,t)=>{if(!f.finite(e))return e;const n=f.clamp(e,a,r);return n!==e&&(o[t]=!1),n};return{lower:s(e,"lower"),upper:s(t,"upper"),end:f.clamp(n,a,r),caps:o}}function bp(e){return{capWidth:"50%",stroke:(t,n)=>{const{Bar:i,fill:o}=e.schema.shapeConfig,a=i&&void 0!==i.fill?i.fill:o,r="function"==typeof a?a(t,n):a,s=l.color(r);return s?s.darker(1.5).formatHex():r},strokeWidth:2}}function _p(e,t){return!(!f.finite(t)||!e)&&e.some(e=>t>Math.min(e.start,e.end)&&t<Math.max(e.start,e.end))}function kp(e,t){const{viz:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:a}=e,r="y"===n.schema.discrete?"y":"x",s="x"===r?"y":"x",c="x"===r?e.y:e.x,l=function(e,t,n){const i="y"===t?e.viz._yAxis:e.viz._xAxis,o=i&&!i._d3ScaleNegative&&i._d3Scale?i._d3Scale.domain():[],a=o.length?[o[0],o[o.length-1]].map(e=>n(e)):[];if(2!==a.length||!a.every(f.finite))return e.valueExtent;const r=Math.min(a[0],a[1]),s=Math.max(a[0],a[1]);return e.valueExtent?[Math.max(r,e.valueExtent[0]),Math.min(s,e.valueExtent[1])]:[r,s]}(e,s,c),h=("y"===s?n._yAxis:n._xAxis)?._breaks,u=new Map;for(const e of t){if("rect"!==e.type||"Bar"!==e.shapeType||`${e.key}`.endsWith("::hit"))continue;const t=e.datum;if(!t||u.has(t))continue;const d=n.schema.stacked?i[o.get(t.id)??-1]?.[a.get(t.discrete)??-1]:void 0;if(n.schema.stacked&&!d)continue;const m=yp(t,s,d);if(!f.finite(m.lower)&&!f.finite(m.upper))continue;const p=void 0!==t[`${s}2`]?`${s}2`:void 0,g=e=>f.finite(e)?c(e,p):void 0,y=e.transform??{},x=t[s],b=xp(g(m.lower),g(m.upper),c(d?x<0?d[0]:d[1]:x,p),l);_p(h,m.lower)&&(b.caps.lower=!1),_p(h,m.upper)&&(b.caps.upper=!1),u.set(t,{key:e.key,center:"x"===r?(y.x??0)+e.x+e.width/2:(y.y??0)+e.y+e.height/2,thickness:"x"===r?e.width:e.height,...b})}return u}function vp(e,t){const{viz:n}=e;if(!n._confidence)return[];const i=kp(e,t);if(!i.size)return[];const o=au(n,"Bar",{...bp(n),...n._confidenceConfig??{}}),a=o.capWidth;delete o.capWidth,delete o.tooltip;const r="y"===n.schema.discrete?"y":"x",s=e=>i.get(e),c=eu("Path").renderMode("compute").config(o).config({d:(e,t)=>{const n=s(e),i="function"==typeof a?a(e,t):a;return function(e,t,n,i,o,a,r={}){const s=f.finite(o)?o:i,c=f.finite(a)?a:i,l=n/2,h=(t,n)=>"x"===e?`${n},${t}`:`${t},${n}`;let u=`M${h(s,t)}L${h(c,t)}`;for(const[e,n]of[[o,r.lower],[a,r.upper]])f.finite(e)&&!1!==n&&l>0&&(u+=`M${h(e,t-l)}L${h(e,t+l)}`);return u}(r,n.center,function(e,t){if(f.finite(e))return Math.max(0,e);if("string"==typeof e&&e.trim().endsWith("%")){const n=parseFloat(e);if(f.finite(n))return Math.max(0,t*n/100)}return t/2}(i,n.thickness),n.end,n.lower,n.upper,n.caps)},fill:"none",hitArea:{"stroke-width":10},id:e=>`${s(e).key}${pp}`,label:!1,x:0,y:0}).data(Array.from(i.keys()));return n._wirePlotShapeEvents(c,"Bar",e.events),su(c).map(e=>({...e,shapeType:"Bar"}))}function wp(e){return e.__d3plusStackOrder=!0,e}function Sp(e){let t,n=-1,i=0;const o=e.length;for(;++n<o;)(t=+e[n][1])&&(i+=t);return i}const Cp=wp(e=>L.stackOrderAscending(e)),Mp=wp(e=>L.stackOrderDescending(e)),$p=wp(e=>{const t=e.map(Sp),n=e.map(e=>e.key.split("_")[0]);return L.stackOrderNone(e).sort((e,i)=>n[e].localeCompare(n[i])||t[e]-t[i])}),Ap=wp(e=>$p(e).reverse());function zp(e,t="descending"){return wp(n=>{const i=n.map(t=>{let n=0;for(let i=0;i<t.length;i++){const o=(t[i].data||[]).find(e=>e.id===t.key);if(o&&o.data){const t=+e(o.data);isNaN(t)||(n+=t)}}return n});return L.stackOrderNone(n).sort((e,n)=>"ascending"===t?i[e]-i[n]:i[n]-i[e])})}const Dp={ascending:Cp,descending:Mp,key:$p,keyReverse:Ap,none:wp(e=>L.stackOrderNone(e)),data:wp(e=>L.stackOrderNone(e)),insideOut:wp(e=>L.stackOrderInsideOut(e)),appearance:wp(e=>L.stackOrderAppearance(e)),reverse:wp(e=>L.stackOrderReverse(e))},Fp=Object.keys(Dp);function Bp(e){if("function"==typeof e)return e.__d3plusStackOrder?e:zp(e);if(Array.isArray(e))return e;if(e&&"object"==typeof e){const{value:i,order:o}=e;return"function"==typeof i?zp(i,o):(t=zp(T(i),o),n=i,Fe.set(t,n),t)}var t,n;return"string"==typeof e?e in Dp?Dp[e]:(console.warn(`[d3plus] Unknown stackOrder "${e}". Expected one of: ${Fp.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`),Mp):Mp}function Lp(e,t){let n,i,o,a,r,s;if(!((n=e.length)>0))return;const c=e[t[0]].length;for(let l=0;l<c;++l)for(s=r=0,a=0;a<n;++a)(o=(i=e[t[a]][l])[1]-i[0])>=0?(i[0]=s,i[1]=s+=o):o<0?(i[1]=r,i[0]=r+=o):i[0]=s}const Pp={diverging:Lp,none:L.stackOffsetNone,expand:L.stackOffsetExpand,silhouette:L.stackOffsetSilhouette,wiggle:L.stackOffsetWiggle},Rp=Object.keys(Pp);function Ep(e){return"function"==typeof e?e:"string"==typeof e&&e in Pp?Pp[e]:(console.warn(`[d3plus] Unknown stackOffset "${e}". Expected one of: ${Rp.join(", ")}; or an offset function. Falling back to "diverging".`),Lp)}const Np=[k.timeYear,k.timeMonth,k.timeDay,k.timeHour,k.timeMinute,k.timeSecond];function Tp(e){const t=e.slice().sort((e,t)=>e-t),n=t.length>>1;return t.length%2?t[n]:(t[n-1]+t[n])/2}function Op(e,t){if(!t)return[];const i=function(e){const t=e.some(e=>e instanceof Date);if(e.some(e=>!(e instanceof Date)&&"number"!=typeof e))return null;const n=Array.from(new Set(e.map(Number).filter(Number.isFinite))).sort((e,t)=>e-t);if(n.length<2)return null;const i=n.slice(1).map((e,t)=>e-n[t]);if(!t){const e=Tp(i);return(t,n)=>+(t+e*n).toPrecision(12)}const o=n.map(e=>new Date(e)),a=Np.find(e=>o.every(t=>+e.floor(t)===+t));if(a){const e=Math.round(Tp(o.slice(1).map((e,t)=>a.count(o[t],e))));if(e>0)return(t,n)=>a.offset(t,e*n)}const r=Tp(i);return(e,t)=>new Date(+e+r*t)}(e);if(!i)return[];const o=e.some(e=>e instanceof Date),a=e.reduce((e,t)=>+t>+e?t:e,e[0]);if("number"==typeof t){const e=Math.min(Math.floor(t),1e3);return Array.from({length:Math.max(e,0)},(e,t)=>i(a,t+1))}const r=t.to;if(null==r)return[];const s=o?n.date(r):+r;if(!Number.isFinite(+s))return[];const c=[];for(let e=1;e<=1e3;e++){const t=i(a,e);if(+t>+s)break;c.push(t)}return c}const Wp=["linear","exponential","logarithmic","power","polynomial"];function jp(e){return!0===e?"linear":Wp.includes(e)?e:null}function Hp(e){return"y"===e?"y":"x"}function Ip(e,t,n=50){const[i,o]=e;return t?t.filter(e=>e>=i&&e<=o):i===o?[i]:Array.from({length:n},(e,t)=>i+(o-i)*t/(n-1))}function Gp(e,t,n){const[i,o]=e,a=Math.max(...t);if(!(a>o))return[];if(n)return[o,...n.filter(e=>e>o&&e<=a)];const r=o>i?Math.round(50*(a-o)/(o-i)):50,s=Ip([o,a],null,Math.min(Math.max(r,2),50)+1);return Array.from(new Set([...s,...t.filter(e=>e>o)])).sort((e,t)=>e-t)}function Vp(e,t,n,i=[]){const o=jp(e._trendLine);if(!o||!t.length)return[];const a=e._trendLineConfig||{},r=Hp(e.schema.discrete),s="x"===r?"y":"x",{toNumber:c,fromNumber:l}=function(e){const t=e.map(e=>`${e}`),n=e.some(e=>!(e instanceof Date)&&"number"!=typeof e),i=e.some(e=>e instanceof Date);return{toNumber:e=>{if(e instanceof Date)return+e;if(!n&&"number"==typeof e)return e;const i=t.indexOf(`${e}`);return i<0?NaN:i},fromNumber:t=>n?e[Math.round(t)]:i?new Date(t):t}}(n.concat(i)),u=function(e,t){return!e[`_${t}Time`]&&(e.schema.discrete===t&&!Sm(e,t)||!!e.schema[`${t}Sort`])}(e,r)?n.concat(i).map(c).filter(Number.isFinite):null,d=i.length?n.concat(i).map(c).filter(Number.isFinite):[],m="log"===`${e[`_${s}Config`]?.scale}`.toLowerCase(),p=e.schema.shapeConfig.fill,g=[];for(const[n,i,y,x]of function(e,t,n,i){const o="x"===n?"y":"x",a=e=>[i(e[n]),+e[o]];if(e.schema.stacked)return[["all",h.groups(t,e=>i(e[n])).map(([e,t])=>[e,t.reduce((e,t)=>e+(+t[o]||0),0)]),void 0,-1]];const r=[["all",t.map(a),void 0,-1]];if("all"===e._trendLineConfig?.group)return r;const s=n=>h.groups(t,t=>function(e,t,n){return e._ids(t.data,t.i).slice(0,n+1).join("_")}(e,t,n)).map(([e,t])=>[e,t.map(a),t[0],n]),c=e._drawDepth,l=s(c);return l.some(([,e])=>e.length>1)?l:c>0?s(c-1):r}(e,t,r,c)){const t=f.regression(i,o,{order:a.order});if(!t)continue;const c=a.confidence&&"linear"===o,h=a.confidenceLevel,b=c?f.linearConfidence(i,h):null,_=c?f.linearPrediction(i,h):null,k=[],v=(e,n)=>{const i=t.predict(e);if(!Number.isFinite(i)||m&&i<=0)return;const o={[r]:l(e),[s]:i},a=n?_:b;a&&([o.lci,o.hci]=a(e)),n&&(o.projected=!0),n&&e>t.extent[1]&&d.includes(e)&&(o.step=!0),k.push(o)};if(Ip(t.extent,u).forEach(e=>v(e,!1)),Gp(t.extent,d,u).forEach(e=>v(e,!0)),k.length<2)continue;const w=y?y.data:void 0,S=a.stroke?a.stroke:w?"function"==typeof p?p(w,y.i):p:"#444",C=w?e._drawLabel(w,y.i,x):e.schema.translate("Trend Line");g.push({id:n,label:C,color:S,axis:r,fit:t,samples:k,row:w})}return g}function qp(e){const t=[];for(const{axis:n,samples:i}of e){const e="x"===n?"y":"x";for(const n of i)t.push(n[e]),void 0!==n.lci&&t.push(n.lci,n.hci)}return t.filter(Number.isFinite)}const Yp=({viz:e,plotFormattedData:t,xData:n,yData:i})=>{const o=Hp(e.schema.discrete),a=("x"===o?n:i)||[],r=jp(e._trendLine)?Op(a,e._trendLineConfig?.projection):[],s=e._trendFits=e._swarm?[]:Vp(e,t||[],a,r);if(!s.length)return{};const c=qp(s),l="x"===o?{yData:(i||[]).concat(c)}:{xData:(n||[]).concat(c)};return s.some(e=>e.samples.some(e=>e.projected))?{...l,[`${o}Data`]:a.concat(r)}:l};function Kp(e,t){const{data:n,axisData:i,xData:o,yData:a,opp:r,stackGroup:s}=t;!function(e,t,n){const i=t.filter(e=>["Area","Bar"].includes(e.shape)),o=h.groups(i,e=>e.group).reduce((e,[t,i])=>(e[t]||(e[t]=0),e[t]+=h.sum(i,e=>e[n]),e),{});t.sort((t,i)=>{if(e.schema[`${e.schema.discrete}Sort`])return e.schema[`${e.schema.discrete}Sort`](t.data,i.data);const a=t[e.schema.discrete],r=i[e.schema.discrete];return a-r!==0?a-r:t.group!==i.group?o[i.group]-o[t.group]:i[n]-t[n]})}(e,i,r);const c=Array.from(new Set(i.map(e=>e.discrete))),l=Array.from(new Set(i.map(e=>e.id))),u=h.groups(i,e=>e.discrete).map(([,e])=>e);!1!==e._stackShares&&function(e,t){const n=e.filter(e=>["Area","Bar"].includes(e.shape)),i=new Map;for(const e of n)i.set(e.discrete,(i.get(e.discrete)||0)+Math.abs(+e[t]||0));for(const e of n){const n=i.get(e.discrete),o=n?Math.abs(+e[t]||0)/n:0;wr(e,o),e.data&&wr(e.data,o)}}(n,r),function(e,t){const{axisData:n,data:i,stackData:o,stackKeys:a,stackGroup:r,opp:s}=t;o.forEach(t=>{const o=Array.from(new Set(t.map(e=>e.id)));o.length<a.length&&a.forEach(a=>{if(!o.includes(a)){const o=n.filter(e=>e.id===a)[0],c=o.shape;if("Area"===c){const n=r(o.data,o.i),l={__d3plus__:!0,data:o.data,discrete:"Bar"===o.shape?`${t[0][e.schema.discrete]}_${n}`:`${t[0][e.schema.discrete]}`,group:n,id:o.id,ids:a,shape:c,[e.schema.discrete]:t[0][e.schema.discrete],[s]:0};i.push(l)}}})})}(e,{axisData:i,data:n,stackData:u,stackKeys:l,stackGroup:s,opp:r}),e.schema[`${e.schema.discrete}Sort`]?n.sort((t,n)=>e.schema[`${e.schema.discrete}Sort`](t.data,n.data)):n.sort((t,n)=>t[e.schema.discrete]-n[e.schema.discrete]);const d=new Set(i.filter(e=>e.data?._isAggregation).map(e=>e.id)),m=function(e,t,n,i,o){const a=e._stackOrder;Array.isArray(a)&&t.sort((e,t)=>a.indexOf(e)-a.indexOf(t));const r=Array.isArray(a)?L.stackOrderNone:a;return L.stack().keys(t).offset(e._stackOffset).order(o.size?function(e,t){return n=>{const i=e(n),o=e=>t.has(n[e].key);return i.filter(e=>!o(e)).concat(i.filter(o))}}(r,o):r).value((e,t)=>{const n=e.filter(e=>e.id===t);return n.length?n[0][i]:0})(n)}(e,l,u,r,d),p="x"===e.schema.discrete?o:a,g=qp(e._trendFits||[]);!e._confidence||"x"!==r&&"y"!==r||g.push(...function(e,t,n,i,o){const a=[];for(const r of e){if("Bar"!==r.shape)continue;const e=n[i.indexOf(r.id)],s=e&&e[o.indexOf(r.discrete)];if(!s)continue;const{lower:c,upper:l}=yp(r,t,s);f.finite(c)&&a.push(c),f.finite(l)&&a.push(l)}return a}(i,r,m,l,c));const y="x"===e.schema.discrete?e._xTime:e._yTime;return{plotInitialDomains:{[e.schema.discrete]:e._discreteExtent?Mm(e,i):y?h.extent(p):p,[r]:[h.min([...m.map(e=>h.min(e.map(e=>e[0]))),...g]),h.max([...m.map(e=>h.max(e.map(e=>e[1]))),...g])]},plotDiscreteKeys:c,plotStackData:m,plotStackKeys:l}}const Up=({viz:e,plotFormattedData:t,plotAxisData:n,xData:i,x2Data:o,yData:a,y2Data:r,plotStackGroup:s})=>{const c=t||[],l=n||[],u=s,d=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,f=e.schema.stacked?Kp(e,{data:c,axisData:l,xData:i||[],yData:a||[],opp:d,stackGroup:u}):function(e,t){const{axisData:n,xData:i,x2Data:o,yData:a,y2Data:r}=t,s=e._xTime,c=e._x2Time,l=e._yTime,u=e._y2Time,d=e.schema.discrete||"x";return e.schema[`${e.schema.discrete}Sort`]?n.sort((t,n)=>e.schema[`${e.schema.discrete}Sort`](t.data,n.data)):n.sort((e,t)=>e[d]-t[d]),{plotInitialDomains:{x:Sm(e,"x")?Mm(e,n):!s&&"x"===e.schema.discrete||e.schema.xSort||"x"===e._swarm?.cross?i:h.extent(i),x2:!c&&"x"===e.schema.discrete||e.schema.x2Sort?o:h.extent(o),y:Sm(e,"y")?Mm(e,n):!l&&"y"===e.schema.discrete||e.schema.ySort||"y"===e._swarm?.cross?a:h.extent(a),y2:!u&&"y"===e.schema.discrete||e.schema.y2Sort?r:h.extent(r)},plotDiscreteKeys:[],plotStackData:[],plotStackKeys:[]}}(e,{axisData:l,xData:i||[],x2Data:o||[],yData:a||[],y2Data:r||[]}),m=e._plotFacetScales?.domains;return m&&f.plotInitialDomains&&(f.plotInitialDomains={...f.plotInitialDomains,...m}),f};function Xp(e,t,n){const i=au(e,"Line");t.config(i);const o=t.labelConfig(),a=void 0!==o.fontColor?o.fontColor:n.fontColor(),r=void 0!==o.fontSize?o.fontSize:n.fontSize(),s=void 0!==o.fontWeight?o.fontWeight:n.fontWeight(),c=void 0!==o.fontFamily?o.fontFamily:n.fontFamily(),l=void 0!==o.padding?o.padding:n.padding();return{labelFunction:i.label||e._drawLabel,fontColorAccessor:a,fontSizeAccessor:r,fontWeightAccessor:s,fontFamilyAccessor:c,paddingAccessor:l}}function Qp(e,t,n){return i=>("log"===t&&0===i&&(i=e._givenDomain()[n[0]<0?1:0]),e._getPosition.bind(e)(i))}const Zp=({viz:e,plotFormattedData:t,plotScales:i,plotConfigScales:o,plotTestAxes:a,plotLineLabelTest:r,y2Exists:s})=>{const c=t||[];if(!e.schema.lineLabels||s)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const l=c.filter(t=>"Line"===t.shape&&("function"!=typeof e.schema.lineLabels||e.schema.lineLabels(t.data,t.i))),u=h.groups(l,e=>e.id);if(!u.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const{testLineShape:d,testTextBox:f}=r,{xTest:m,yTest:p}=a,g=i.x.domain(),y=i.y.domain(),x=o.xConfigScale,b=o.yConfigScale,_=e.schema.width-e._margin.left-e._margin.right,k={...Xp(e,d,f),xEstimate:Qp(m,x,g),yEstimate:Qp(p,b,y)},v=u.map(e=>function([e,t],i){const{labelFunction:o,fontColorAccessor:a,fontSizeAccessor:r,fontWeightAccessor:s,fontFamilyAccessor:c,paddingAccessor:l,xEstimate:u,yEstimate:d}=i;let f,m=t[t.length-1];for(;m.__d3plus__&&m.data;)m=m.data,f=m.i;const p="function"==typeof o?o(m,f):o,g="function"==typeof a?a(m,f):a,y="function"==typeof r?r(m,f):r,x="function"==typeof s?s(m,f):s;let b="function"==typeof c?c(m,f):c;Array.isArray(b)&&(b=b.map(e=>`'${e}'`).join(", "));const _="function"==typeof l?l(m,f):l,k=n.textWidth(p,{"font-size":y,"font-family":b,"font-weight":x}),v=t.map(e=>[u(e.x),d(e.y)]),w=h.max(t.map(e=>u(e.x))),S=t.find(e=>u(e.x)===w).y;return{id:e,labelWidth:k+2*_,spaceNeeded:k+4*_,value:S,yEstimate:d(S),padding:_,fontSize:y,fontColor:g,maxX:w,xValue:h.max(t,e=>e.x),coords:v}}(e,k)).sort((e,t)=>y[1]>y[0]?e.value-t.value:t.value-e.value).filter((e,t,n)=>!function(e,t){const{fontSize:n,id:i,labelWidth:o,maxX:a,yEstimate:r}=e;return 0!==t.filter(e=>e.id!==i&&e.coords.some(t=>(t[0]>a||t[0]===a&&e.maxX!==a)&&t[0]<=a+o&&t[1]<=r+.75*n&&t[1]>=r-.75*n)).length}(e,n)),w=h.max(v,e=>e.maxX),S=h.max(v.map(e=>e.labelWidth));let C;const M=w===m._getRange.bind(m)()[1]?h.max(v.filter(e=>e.maxX===w),e=>e.spaceNeeded):0;if(M){C=_-h.min([M,_/4])-e._margin.right}return{plotLabelWidths:v,plotLargestLabel:S,plotXRangeMax:C}};function Jp(e,t){const i=()=>Ga(e);return n.assign({barConfig:{stroke:i},baselineBreakConfig:{stroke:i},breakConfig:{stroke:i},shapeConfig:{fill:i,labelConfig:{fontColor:i},stroke:i},titleConfig:{fontColor:i}},t)}function eg(e){return Sf(e,"x")||e._discreteExtent&&"x"===e.schema.discrete?"none":"outside"}function tg(e,t){const{xData:n,xScalePadding:i}=t;return Jp(e,{data:n,locale:e.schema.locale,rounding:Mf(e,"x",eg(e)),scalePadding:i,...ep(e,"x")})}const ng=({viz:e,plotAxisData:t,plotScales:n,x2Exists:i,y2Exists:a,x2Data:r,y2Data:s,yData:c})=>{const l=t||[],{x:h,y:u,x2:d,y2:f,xScale:m,yScale:p,x2Scale:g,y2Scale:y}=n,x=h.domain(),b=d.domain(),_=u.domain(),k=f.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},w=Sf(e,"y")||Sm(e,"y")?"none":"outside",S={...i?{data:r}:v,baselineBreak:!1,rounding:$f(e,"x2",eg(e))},C={...a?{data:s}:v,baselineBreak:!1,rounding:$f(e,"y2",w)},{showX:M,showY:$}=function(e){return{showX:"x"===e.schema.discrete?e.schema.width>e._discreteCutoff&&e.schema.width>e.schema.xCutoff:e.schema.width>e.schema.xCutoff&&!Um(e,"x"),showY:"y"===e.schema.discrete?e.schema.height>e._discreteCutoff&&e.schema.height>e.schema.yCutoff:e.schema.height>e.schema.yCutoff&&!Um(e,"y")}}(e),A=function(e,t,n,i,o){const a={data:n,locale:e.schema.locale,rounding:Mf(e,"y",i),scalePadding:t.padding?t.padding():0,scaleAlign:t.align?t.align():.5,...ep(e,"y")};return o.showX||!o.showY||e._swarm||(a.barConfig={stroke:"transparent"},a.tickSize=0,a.shapeConfig={labelBounds:(t,n)=>{const{width:i,y:o}=t.labelBounds,a=e.schema.height/2;return{x:n?-a:0,y:o,width:i,height:a}},labelConfig:{padding:0,rotate:0},labelRotation:!1}),a}(e,u,c,w,{showX:M,showY:$}),z=function(e,t){const n=au(e,"Bar"),i=void 0!==n.label?"function"==typeof n.label?n.label:()=>n.label:e._drawLabel,o=[],a=[];for(const e of t){if("Box"===e.shape)continue;const t=i(e.data,e.i);("number"==typeof t||t)&&(o.push(String(t)),a.push(e))}return{labels:o,rows:a}}(e,l),D=z.labels;let F;const B=(t,n)=>{if(Sm(e,t))return function(e,t){const n=new Set;return t.filter(e=>e.data).forEach(t=>Cm(e,t).forEach(e=>n.add(e))),Array.from(n).sort((e,t)=>e-t)}(e,l);const i=o.unique(l.map(e=>e[t]));return"Point"===n&&i.every(e=>D.includes(`${e}`))?("x"!==t&&"y"!==t||t===e.schema.discrete&&("x"===t?M:$)&&(F={axis:t,...z}),[]):null},L=B("x",m),P=B("x2",g),R=B("y",p),E=B("y2",y);return{plotDefaultConfig:v,plotDefaultX2Config:Jp(e,S),plotDefaultY2Config:Jp(e,C),plotShowX:M,plotShowY:$,plotYC:Jp(e,A),plotBarLabels:D,plotBarLabelCheck:F,plotXTicks:L,plotX2Ticks:P,plotYTicks:R,plotY2Ticks:E,plotXDomain:x,plotX2Domain:b,plotYDomain:_,plotY2Domain:k}},ig=e=>null===e||"number"==typeof e&&!Number.isFinite(e)||Array.isArray(e)&&0===e.length;function og(e,t){const n=h.extent(t);return lp[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(n).range([n[0]===n[1]?e.schema.sizeMax:h.min([e.schema.sizeMax/2,e.schema.sizeMin]),e.schema.sizeMax])}const ag=(e,t)=>(e._plotCircleShapes??["Circle"]).includes(t);function rg(e,t){const{xTime:i,x2Time:o,yTime:a,y2Time:r}=t,s=i||o||a||r,c=(t,n)=>`${!s&&e.schema.time?e.schema.time(t,n):"time"}_${e.schema.stacked?((t,n)=>e._stackGroup?e._stackGroup(t,n):e.schema.groupBy.length>1?e._ids(t,n).slice(0,-1).join("_"):"group")(t,n):`${e._ids(t,n).join("_")}`}`;return{prepData:(t,s)=>{const l={__d3plus__:!0,data:t,group:c(t,s),i:s,hci:e._confidence&&e._confidence[1]&&e._confidence[1](t,s),id:e._ids(t,s).slice(0,e._drawDepth+1).join("_"),lci:e._confidence&&e._confidence[0]&&e._confidence[0](t,s),shape:e.schema.shape(t,s),x:i?n.date(e._x(t,s)):e._x(t,s),x2:o?n.date(e._x2(t,s)):e._x2(t,s),y:a?n.date(e._y(t,s)):e._y(t,s),y2:r?n.date(e._y2(t,s)):e._y2(t,s)};return l.discrete="Bar"===l.shape?`${l[e.schema.discrete]}_${l.group}`:`${l[e.schema.discrete]}`,l.id="Bar"===l.shape?`${l.id}_${l[e.schema.discrete]}`:l.id,l},stackGroup:c}}const sg=({viz:e})=>{if(!e._filteredData||!e._filteredData.length)return e._sizeLegendFinal=null,e._swarm=null,{plotFormattedData:[],plotAxisData:[],x2Exists:!1,y2Exists:!1};const{prepData:t,stackGroup:n}=rg(e,function(e){const t=!!e.schema.time&&e.schema.time(e._filteredData[0],0),n=e._x2Time=t&&e._x2(e._filteredData[0],0)===t,i=e._xTime=t&&e._x(e._filteredData[0],0)===t,o=e._y2Time=t&&e._y2(e._filteredData[0],0)===t;return{xTime:i,x2Time:n,yTime:e._yTime=t&&e._y(e._filteredData[0],0)===t,y2Time:o}}(e)),i=function(e){const t=e.schema.discrete;if(!t||Sm(e,t))return null;if("x"===t?e._xTime:e._yTime)return null;const n=("x"===t?e._xConfig:e._yConfig)?.domain,i=Array.isArray(n)?n:e.schema[`${t}Domain`];return Array.isArray(i)&&i.length?new h.InternSet(i):null}(e),o=t=>(e=>!(ig(e.x)||ig(e.y)||void 0!==e.x2&&ig(e.x2)||void 0!==e.y2&&ig(e.y2)))(t)&&(!i||i.has(t[e.schema.discrete])),a=e._filteredData.map(t).filter(o),[r,s]=ym(e,a,e._axisPersist?e._data.map(t).filter(o):a);e._formattedData=r;const c=e._swarm=Ym(e.schema.swarm,s);c&&(Km(r,c),s!==r&&Km(s,c)),function(e,t){e._sizeScaleD3=e._size?e._plotFacetScales?.size??og(e,t.map(t=>e._size(t.data))):()=>e.schema.sizeMin,e._sizeLegendFinal=e._size&&t.some(t=>ag(e,t.shape))?e._sizeScaleD3:null}(e,s);const l=s.some(e=>void 0!==e.x2),u=s.some(e=>void 0!==e.y2);return{plotFormattedData:r,plotAxisData:s,x2Exists:l,y2Exists:u,plotStackGroup:n}},cg=({viz:e,plotFormattedData:t,plotAxisData:i})=>{const a=t||[],r=i||[];function s(t){const i=e[`_${t}Time`],s=i?a:r,c=e._plotAxisRows?e._plotAxisRows(s,t):s,l=c.filter(e=>![NaN,void 0,!1].includes(e[t])),u=e._plotAxisValues?e._plotAxisValues(c,t):[];if(!l.length)return u;const d="number"==typeof l[0][t];let f=e.schema.discrete===t?h.rollups(l,t=>1===t.length?t[0].data:o.merge(t.map(e=>e.data),e.schema.aggs),e=>e[t]).sort((n,o)=>{if(e.schema[`${t}Sort`])return e.schema[`${t}Sort`](n[1],o[1]);return(i||d?parseFloat(n[0]):n[0])-(i||d?parseFloat(o[0]):o[0])}).map(([e])=>i?n.date(e):d?parseFloat(e):e):o.unique(l.sort((n,i)=>e.schema[`${t}Sort`]?e.schema[`${t}Sort`](n.data,i.data):n[t]-i[t]).map(e=>e[t]),e=>`${e}`);return e.schema.discrete!==t.charAt(0)&&e._confidence&&(e._confidence[0]&&(f=f.concat(c.map(e=>e.lci))),e._confidence[1]&&(f=f.concat(c.map(e=>e.hci))),f=f.concat(Nm(e,c))),u.length?f.concat(u):f}return{xData:s("x"),x2Data:s("x2"),yData:s("y"),y2Data:s("y2")}},lg=({viz:e,plotFormattedData:t,plotAxisData:n,plotScales:i,plotConfigScales:o})=>{const a=t||[],r=n||[];let{x:s,y:c,x2:l,y2:u}=i;const{xConfigScale:d,yConfigScale:f,x2ConfigScale:m,y2ConfigScale:p}=o,g=i.xScale,y=i.yScale;if("Point"!==("x"===e.schema.discrete||"y"===e._swarm?.axis?y:g)){h.groups(r,e=>e.shape).forEach(([t,n])=>{if(["Bar","Box"].includes(t)&&!e._discreteExtent&&Pf("x"===e.schema.discrete?s:c,a,e.schema.discrete),e._buffer[t]){const i=e._buffer[t].bind(e)({data:n,x:s,y:c,yScale:f,xScale:d,config:e.schema.shapeConfig[t]});s=i[0],c=i[1];const o=e._buffer[t].bind(e)({data:n,x:l,y:u,yScale:p,xScale:m,x2:!0,y2:!0,config:e.schema.shapeConfig[t]});l=o[0],u=o[1]}})}return{plotScales:Zm(e,{...i,x:s,y:c,x2:l,y2:u})}},hg={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:N("Circle"),tooltipShared:!0,trendLine:!1}};function ug(e){return this._sizeScaleD3(this._size?this._size(e):null)}function dg(e,t,n,i){const o=("y"===t?e._y:e._x)(n,i),a="y"===t?e._yAxis:e._xAxis;return o<0!==Boolean(a?.schema?.reverse)}function fg(e,t){if(this.schema.stacked)return!1;const n=this._labelPosition(e,t);if("outside"===n)return!0;if("inside"===n)return!1;const i="x"===this.schema.discrete.charAt(0)?"y":"x",o=this.schema.discrete.replace(this.schema.discrete.charAt(0),i),a="y"===o?this._yAxis:this._xAxis,r="y"===o?this._y:this._x,s=a._d3Scale.range(),c=r(e,t),l=dg(this,o,e,t),h=a._getPosition(0),u="y"===o?l?s[1]-h:h-s[0]:l?h-s[0]:s[1]-h,d=a._getPosition(c);return Math.abs(l?h-d:d-h)<u/2}function mg(e){return!!e._confidence&&!1!==e._confidenceConfig?.tooltip}function pg(e,t,n){const i={},o=e._confidence;if(!o||!t)return i;const[a,r]=o,s=a?a(t,n):void 0,c=r?r(t,n):void 0;return f.finite(s)&&(i.lower=s),f.finite(c)&&(i.upper=c),i}function gg(e,t,n,i){if(!mg(e))return[];if(Bm(e).length>1)return yg(e,t,n,i);const{lower:o,upper:a}=pg(e,t,n),r=[];return f.finite(o)&&r.push([e.schema.translate("Lower Bound"),i(o)]),f.finite(a)&&r.push([e.schema.translate("Upper Bound"),i(a)]),r}function yg(e,t,n,i){return Lm(e,t,n).map(({label:e,lower:t,upper:n})=>[e,bg(t,n,i)]).filter(([,e])=>e)}function xg(e,t,n){const i=bg(e,t,n);return i?` (${i})`:""}function bg(e,t,n){const i=f.finite(e),o=f.finite(t);return i&&o?`${n(e)} – ${n(t)}`:i?`≥ ${n(e)}`:o?`≤ ${n(t)}`:""}const _g=e=>"x"===e?"y":"x";function kg(e,t){const n=e[`_${t}Config`];if(n&&"string"==typeof n.title)return n.title;const i=e[`_${t}Key`];return"string"==typeof i?i:""}function vg(e,t,n){const i=e[`_${t}Config`];if(i&&"function"==typeof i.tickFormat)return i.tickFormat(n);const o=function(e,t,n){if(!e[`_${t}Time`])return;const i=pn(n);if(!i)return;const o=e[`_${t}Axis`];return o&&"time"===o.schema.scale?_n(o,i):d.formatDateFull(i,[i])}(e,t,n);if(void 0!==o)return o;if(wn(n)){const i=e[`_${t}Axis`];return i?_n(i,n):d.formatDateFull(n,[n])}if("number"==typeof n&&t!==e.schema.discrete){const i=e[`_${t}Axis`];return i&&Fn(i)?Bn(n,e.schema.locale):d.formatAbbreviate(n,e.schema.locale)}return String(n)}function wg(e,t,n){const i=n.rows[0],o=e[`_${t}`],a=o&&!i.projected?o(i.datum,i.index):n.value;return[kg(e,t),vg(e,t,a)]}function Sg(e,t,n){const i=n.nativeEvent,o=i&&i.touches&&i.touches.length?[i.touches[0].clientX,i.touches[0].clientY]:i?[i.clientX,i.clientY]:n.point,a=e._zoomTransform,r=e._chartTransform,s=t.axis,c=(t.px+(r?.[s]??0))*(a?.scale??1)+(a?.[s]??0),l="x"===s?0:1,h=[o[0],o[1]];return h[l]=o[l]-n.point[l]+c,h}function Cg(e){const t=e._tooltipClass;e._sharedTooltipSaved||(e._sharedTooltipSaved={arrow:t.arrow(),thead:t.thead(),tbody:t.tbody()});const n=e._sharedTooltipSaved;return t.thead(n.thead).tbody(n.tbody).titleSwatch(!0)}function Mg(e,t,n){const i=n=>vg(e,t,n),o=n.projected;return o?void 0===o.lci||void 0===o.hci?"":xg(o.lci,o.hci,i):function(e,t,n,i){if(!mg(e))return"";const{lower:o,upper:a}=pg(e,t,n);return xg(o,a,i)}(e,n.datum,n.index,i)}function $g(e,t,n){const i=_g(t.axis),{header:o,names:a}=function(e,t){const n=` (${e.schema.translate("Projected")})`,i=wg(e,t.axis,t),o=t.rows.every(e=>e.projected);return{header:o?[i[0],`${i[1]}${n}`]:i,names:t.rows.map(e=>e.projected&&!o?`${e.name}${n}`:e.name)}}(e,t);Cg(e).data([t.rows[0].datum]).config(Ae.bind(e)(e.schema.tooltipConfig)).title(()=>kg(e,i)).thead(o).tbody(t.rows.flatMap((t,n)=>[[Nr(Er(t.color,t.shape),a[n]),`${vg(e,i,t.value)}${Mg(e,i,t)}`],...Br(e,t.datum,5)])).footer(!1).arrow(!1).position(Sg(e,t,n)).render()}function Ag(e){return{label:(t,n)=>!!e.schema.stacked&&e._drawLabel(t,n),labelBounds:(t,n,i)=>{const o=np(e,i.points);let a=f.largestRect(o,{angle:h.range(-20,20,5)});if((!a||a.height<20||a.width<50)&&(a=f.largestRect(o,{angle:h.range(-80,80,5)})),!a)return null;const r=h.min(i.points,e=>e[0]),s=h.max(i.points.filter(e=>e[0]===r),e=>e[1]);return{angle:a.angle,width:a.width,height:a.height,x:a.cx-a.width/2-r,y:a.cy-a.height/2-s}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}function zg(e){const t=(t,n)=>wn(n)?vg(e,t,n):n;return(n,i)=>{let o;return n.nested?o=`${e._drawLabel(n.data,n.i)}`:(o=`${e._drawLabel(n,i)}`,void 0!==e._x(n,i)&&(o+=`, x: ${t("x",e._x(n,i))}`),void 0!==e._y(n,i)&&(o+=`, y: ${t("y",e._y(n,i))}`),void 0!==e._x2(n,i)&&(o+=`, x2: ${t("x",e._x2(n,i))}`),void 0!==e._y2(n,i)&&(o+=`, y2: ${t("y",e._y2(n,i))}`)),`${o}.`}}function Dg(e){return{curve:()=>e.schema.discrete?`monotone${e.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:N("none"),labelConfig:{fontColor:(t,n)=>{const i="function"==typeof e.schema.shapeConfig.Line.stroke?e.schema.shapeConfig.Line.stroke(t,n):e.schema.shapeConfig.Line.stroke;return r.colorLegible(i)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:N(2)}}function Fg(){return{Area:Ag(this),ariaLabel:zg(this),Bar:{labelBounds(e,t,n){const i="y"===this.schema.discrete?"width":"height",o="y"===this.schema.discrete?"height":"width",a="x"===this.schema.discrete.charAt(0)?"y":"x",r="y"===a,s=this.schema.discrete.replace(this.schema.discrete.charAt(0),a),c=("y"===s?this._yAxis:this._xAxis)._d3Scale.range(),l=Math.abs(c[1]-c[0]),h=dg(this,s,e,t);return fg.bind(this)(e,t)?{[i]:l-n[i],[o]:n[o],x:r?-n.width/2:h?-l:n.width+1,y:r?h?n.height+1:-l:-n.height/2+1}:{[i]:n[i],[o]:n[o],x:r?-n.width/2:h?(this.schema.stacked,1-n.width):-1,y:r?h?(this.schema.stacked,1):1-n.height:-n.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(e,t){if(fg.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return r.colorContrast(e,this.schema.colorDefaults)}return r.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(e,t):this.schema.shapeConfig.fill,this.schema.colorDefaults)},fontStroke(e,t){if(fg.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return r.colorContrast(e,this.schema.colorDefaults)}return"transparent"},fontStrokeWidth(e,t){return fg.bind(this)(e,t)?.1:0},padding:3,textAnchor(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",o="y"===i,a=dg(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),i),e,t),r=o?"middle":fg.bind(this)(e,t)?a?"end":"start":a?"start":"end";return n.rtl()?"start"===r?"end":"end"===r?"start":r:r},verticalAlign(e,t){const n="x"===this.schema.discrete.charAt(0)?"y":"x",i="y"===n,o=dg(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),n),e,t);return i?fg.bind(this)(e,t)?o?"top":"bottom":o?"bottom":"top":"middle"}}},Circle:{r:ug.bind(this),trail:!0},Line:Dg(this),Rect:{height:e=>2*ug.bind(this)(e),width:e=>2*ug.bind(this)(e),trail:!0}}}const Bg=[{key:"axisHover",coerce:"identity",default:!0},{key:"axisHoverConfig",merge:!0,factory:function(){return{guideConfig:{strokeDasharray:"4 3",strokeWidth:1},badgeConfig:{fontSize:12,fontWeight:400,padding:4,rx:2}}}},{key:"barPadding",coerce:"identity"},{key:"baselineBreak",coerce:"identity"},{key:"fillBetween",coerce:"identity",default:!1},{key:"fillBetweenConfig",merge:!0,factory:Yf},{key:"forecast",coerce:"identity"},{key:"forecastConfig",merge:!0,factory:nm},{key:"lineLabels",coerce:"identity"},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"stacked",coerce:"identity"},{key:"swarm",coerce:"identity",default:"auto"},{key:"swarmConfig",merge:!0,factory:()=>({padding:1,overflow:"shrink"})},{key:"tooltipShared",coerce:"identity"},{key:"xBreak",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yBreak",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}];function Lg(e){const t=hg.defaults;e._axisPersist=t.axisPersist,e._annotations=t.annotations,e._backgroundConfig={duration:0,fill:"transparent"},e.schema.barPadding=t.barPadding,e._buffer=n.assign({},Nf,{Bar:!1,Line:!1}),e._confidence=!1,e._confidenceConfig={fill:(t,n)=>{const{Line:i,stroke:o}=e.schema.shapeConfig,a=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof a?a(t,n):a},fillOpacity:N(.5)},e._crosshairConfig={stroke:r.colorGray[500],strokeDasharray:"4 3",strokeWidth:1},e._discreteCutoff=t.discreteCutoff,e._groupPadding=t.groupPadding,e._labelConnectorConfig={strokeDasharray:"1 1"},e._labelPosition=N("auto"),e._lineMarkerConfig={fill:(t,n)=>r.colorAssign(e._id(t,n),rt(e)),r:N(3)},e._lineMarkers=t.lineMarkers,e._previousAnnotations={back:[],front:[]},e._previousShapes=[],e.schema.shape=t.shape,e.schema.shapeConfig=n.assign(e.schema.shapeConfig,Fg.call(e)),e._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],e.schema.shapeSort=(t,n)=>e._shapeOrder.indexOf(t)-e._shapeOrder.indexOf(n),e.schema.tooltipShared=t.tooltipShared,e.schema.sizeMax=20,e.schema.sizeMin=5,e.schema.sizeScale="sqrt",e._stackOffset=Lp,e._stackOrder=Mp,e.schema.threshold=N(0),e._thresholdMemberFormat=t=>vg(e,"y"===e.schema.discrete?"x":"y",t),e.schema.timelineConfig=n.assign(e.schema.timelineConfig,{brushMin:()=>e._xTime||e._yTime||e._x2Time||e._y2Time?2:1})}const Pg=["ellipsis","fontFamily","fontMax","fontMin","fontResize","fontSize","fontWeight","lineHeight","maxLines","overflow","padding","split"];function Rg(e,t,n,i){if(!e.length)return!0;const o=function(e,t){const n=new ro;for(const i of Pg){const o=e[i];if(void 0!==o)if("split"===i||"function"!=typeof o)n[i](o);else{const e=o;n[i]((n,i)=>e(t[i].data,t[i].i))}}return n}(i,t);return e.every((e,t)=>{const i=io(o,{text:e,width:n.width,height:n.height},t);return!!i&&!i.truncated&&""!==i.lines.join("")})}function Eg(e,t,n,i,o){const a="y"===e.schema.discrete?"y":"x",r=new Map;for(const e of t){const t=String(e[a]);r.set(t,(r.get(t)??0)+1)}const s=e.schema.stacked?1:h.max(Array.from(r.values()))??1,c=function(e,t,n,i,o){const a="x"===e?t.width:t.height,r=("x"===e?t.height:t.width)/2;let s=a/Math.max(1,n);return o.group<s&&(s-=o.group),i>1&&(s=(s-o.bar*i-1)/i),s=Math.max(0,s),"x"===e?{width:s,height:r}:{width:r,height:s}}(a,i,r.size,s,{group:e._groupPadding??0,bar:e.schema.barPadding??0});return Rg(n,t,c,o)}function Ng(e,t,n){const i=au(e,"Bar").labelConfig||{};return!Eg(e,t.rows,t.labels,n,i)}function Tg(e,t,n){const{xTest:i,x2Test:o,showX:a,x2Exists:r,width:s}=e,c=e.xRangeMax||void 0;a&&i.range([t,c]).measure(),r&&o.range([t,c]).measure();const l=i._getRange()[1],u=o._getRange()[1];return h.max([0,n,s-l,s-u])}function Og(e,t,n){const{yDomain:i,y2Domain:o,yConfigScale:a,y2ConfigScale:r}=t,{defaultY2Config:s,showY:c,y2Exists:l,yC:u}=t,{yTicks:d,x2TestRange:f,xTestRange:m,height:p,width:g}=t,{yTest:y,y2Test:x}=t;let{xOffsetRight:b}=t;c&&y.domain(i).height(p).maxSize(g/2).range(n).ticks(d).width(g).config(u).config(Jm(e,"y")).scale(a).measure();const _=y.outerBounds(),k=_.width?_.width+y.padding():void 0,v=h.max([0,k,m[0],f[0],e._plotMinLeft?.()]);l&&x.config(u).domain(o).gridSize(0).height(p).range(n).width(g-h.max([0,b-t.y2Width])).title(!1).config(e._y2Config).config(s).scale(r).measure();const w=x.outerBounds(),S=w.width?w.width+x.padding():void 0;return b=Tg(t,v,S),{yBounds:_,yWidth:k,y2Bounds:w,y2Width:S,xOffsetLeft:v,xOffsetRight:b}}function Wg(e,t){const{xTest:n,showX:i,xLabelMode:o}=e;if(i&&(!o||"axis"===o))return n.range(t).measure(),n.outerBounds().height+n.padding()}function jg(e,t,n){const{x2Height:i,topOffset:o,height:a,horizontalMargin:r,verticalMargin:s}=t,c=(t,r=0)=>{const c=a-(t+o+s),l=n?.insetBottom??Math.max(0,e._plotInsetBottom?.(c-i)??0)+r;return{yBottom:c,insetBottom:l,yRange:[i,c-l]}};let l=c(t.xHeight),h=n||Og(e,t,l.yRange);for(let i=0;!n&&i<3;i++){const n=Wg(t,[h.xOffsetLeft,t.width-(h.xOffsetRight+r)]);if(void 0===n||n===t.xHeight)break;e._padding.bottom+=n-t.xHeight,t={...t,xHeight:n},l=c(n),h=Og(e,t,l.yRange)}const u=n?0:function(e,t){const n=[e.yTest,...e.y2Exists?[e.y2Test]:[]],i=Math.max(0,...n.map(e=>e._labelOverflow?.[1]??0));return Math.max(0,Math.ceil(i-(e.xHeight+t)))}(t,l.insetBottom);return u&&(l=c(t.xHeight,u),h=Og(e,t,l.yRange)),{pCtx:t,...l,solved:h}}const Hg={labels:[]},Ig=(e,t,n)=>"function"==typeof e?e(t,n):e;function Gg(e,t,n){const i=!(n||Um(e,"y")&&e.schema.height>e.schema.yCutoff);return t&&i&&void 0===e._xConfig?.labels}function Vg(e){const t=e._getDomain();if(!t.length)return[];const n="time"===e.schema.scale,[i,o]=[t[0],t[t.length-1]].map(e=>n?+e:e);return i===o||i instanceof Date&&o instanceof Date&&+i===+o?[i]:[i,o]}function qg(e){const t=e.schema.shapeConfig,i=t.labelConfig||{},o=e._labelFormat||(e=>`${e}`);let r=0,s=0;const c=Vg(e).map((e,c)=>{const l=Ig(i.fontSize??12,e,c),h=t.lineHeight?t.lineHeight(e,c):1.4*l,u=`${o(e)??""}`,d=a.textWrap().fontFamily(n.fontExists(Ig(i.fontFamily??a.fontFamily,e,c))).fontSize(l).fontWeight(Ig(i.fontWeight??400,e,c)).lineHeight(h).width(Number.MAX_SAFE_INTEGER).height(h)(u),f=d.lines.filter(e=>""!==e);return r=Math.max(r,Math.ceil(f.length*h)),s=Math.max(s,Ig(i.padding??0,e,c)),{value:e,text:u,width:f.length?Math.ceil(Math.max(...d.widths)):0}});return{labels:c,padding:s,height:r}}function Yg(e,t){const n=e.height?e.padding+e.height:0;return t-n>=n?n:0}function Kg(e,t,n,i){const o=Math.max(0,n-i);if(e+t<=o)return[o-t,o-e];const a=o/2;return e<=a?[e,o-e]:t<=a?[o-t,t]:[a,a]}function Ug(e,t,n,i=!1){const{labels:o,padding:a,height:r}=e;if(!o.length||!r)return[];const[s,c]=[t[0],t[t.length-1]],l=n+a;if(1===o.length){const[{value:e,text:t}]=o;return[{value:e,text:t,x:s,y:l,width:c-s,height:r,textAnchor:"middle"}]}const[h,u]=o,d=Kg(h.width,u.width,c-s,a);return[{value:h.value,text:h.text,x:s,y:l,width:d[0],height:r,textAnchor:i?"end":"start"},{value:u.value,text:u.text,x:c-d[1],y:l,width:d[1],height:r,textAnchor:i?"start":"end"}]}function Xg(e,t,i){return Ug(qg(e),t,i,n.rtl())}function Qg(e,t){e.measure();const n=e._outerBounds.y+e._margin.top;e.height(e.height()+t-n)}function Zg(e,t){if(!t.length)return null;const n=e.schema.shapeConfig.labelConfig||{},i=(new ro).renderMode("compute").config(n).config({fontResize:!1,padding:0,rotate:0,textAnchor:e=>e.textAnchor,verticalAlign:"top"}).data(t.map((e,n)=>({...e,id:1===t.length?"middle":n?"end":"start",i:n,data:{id:e.value,text:e.text}}))),{children:o}=i.toScene();return o.length?{type:"group",key:"plot-x-end-labels",children:o}:null}function Jg(e,t,n,i,o,a,r){const{xTest:s,x2Test:c,yTest:l,showX:u,showY:d,x2Exists:f,height:m,width:p}=t,{labelWidths:g,largestLabel:y,xRangeMax:x}=function(e,t,n,i,o){const{xTest:a,x2Test:r,xDomain:s,x2Domain:c,xTicks:l,x2Ticks:h,xConfigScale:u,x2ConfigScale:d,defaultX2Config:f,showX:m,x2Exists:p,height:g,width:y}=t;let x;const b=o?Hg:{};m&&a.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(Jm(e,"x")).config(b).scale(u).measure();const{labelWidths:_,largestLabel:k,xRangeMax:v}=i();return void 0!==v&&(x=v),m&&x&&a.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(Jm(e,"x")).config(b).scale(u).measure(),p&&r.domain(c).height(g).range([void 0,x]).ticks(h).width(y).config(n).tickSize(0).config(f).config(e._x2Config).scale(d).measure(),{labelWidths:_,largestLabel:k,xRangeMax:x}}(e,t,n,a,r),b=s._getRange(),_=c._getRange(),k=c.outerBounds(),v=f?k.height+c.padding():0,w=h.max([0,i,b[0],_[0],e._plotMinLeft?.()]),S=l.shapeConfig().labelConfig,C=(d?S.fontSize()/2:0)+(e._plotInsetTop??0),M=Tg({xTest:s,x2Test:c,showX:u,x2Exists:f,xRangeMax:x,width:p},w,o),$=s.outerBounds(),A=r?Yg(qg(s),m-v):0;return{xRangeMax:x,labelWidths:g,largestLabel:y,xTestRange:b,x2TestRange:_,x2Height:v,xOffsetLeft:w,xOffsetRight:M,topOffset:C,xHeight:r?A:$.height+(d||u?s.padding():0),xLabelMode:r?A?"ends":"none":"axis"}}function ey(e,t,n){let i=t;const o=i.barLabelCheck,a="y"===o?.axis&&Ng(e,o,ty(e,i,0,function(e,t){if(!t.showX)return 0;const n=(new ui).align("end").gridSize(0);return n.domain(t.xDomain).height(t.height).maxSize(t.height/2).range([void 0,void 0]).ticks(t.xTicks).width(t.width).config(tg(e,t)).config(Jm(e,"x")).scale(t.xConfigScale).measure(),n.outerBounds().height+n.padding()}(e,i)+function(e,t){const{yTest:n,yC:i,showY:o}=t;o&&n.config(i).config(Jm(e,"y"));const a=n.shapeConfig().labelConfig;return(o?a.fontSize()/2:0)+(e._plotInsetTop??0)}(e,i)));a&&(i={...i,yTicks:null});const{yBounds:r,yWidth:s,y2Bounds:c,y2Width:l}=function(e,t){const{yTest:n,y2Test:i,yDomain:o,y2Domain:a,yTicks:r,y2Ticks:s,yConfigScale:c,y2ConfigScale:l,defaultY2Config:h,yC:u,showY:d,y2Exists:f,height:m,width:p}=t;d&&n.domain(o).height(m).maxSize(p/2).range([void 0,void 0]).ticks(r).width(p).config(u).config(Jm(e,"y")).scale(c).measure();const g=n.outerBounds(),y=g.width?g.width+n.padding():void 0;f&&i.domain(a).height(m).range([void 0,void 0]).ticks(s).width(p).config(u).config(h).config(e._y2Config).scale(l).measure();const x=i.outerBounds();return{yBounds:g,yWidth:y,y2Bounds:x,y2Width:x.width?x.width+i.padding():void 0}}(e,i),h="x"===o?.axis&&Ng(e,o,ty(e,i,(s??0)+(l??0),0));h&&(i={...i,xTicks:null});const u=Gg(e,i.showX,i.showY),d=tg(e,i),f=Jg(e,i,d,s,l,n,u);return e._padding.left+=f.xOffsetLeft,e._padding.right+=f.xOffsetRight,e._padding.bottom+=f.xHeight,e._padding.top+=f.x2Height+f.topOffset,{yBounds:r,y2Bounds:c,yWidth:s,y2Width:l,xC:d,...f,barLabelsOnAxis:a||h,xTicks:i.xTicks,yTicks:i.yTicks}}function ty(e,t,n,i){const o="panel"===e._facetStep?0:wu(e);return{width:t.width-n,height:t.height-i-o}}const ny=new ya,iy=new ro,oy=(e,t)=>yf.prototype._draw.call(e,t);function ay(e,t){if(e._axisHoverState=null,"chrome"===e._facetStep||!e._filteredData.length&&!e._annotations?.length)return oy(e,t),e;const n={xTest:(new ui).align("end").gridSize(0),x2Test:(new mi).align("start").gridSize(0),yTest:(new di).align("start").gridSize(0),y2Test:(new di).align("end").gridSize(0)},i=function(e){const t=ne({viz:e},[sg,cg,Yp]);return{data:t.plotFormattedData,axisData:t.plotAxisData,x2Exists:t.x2Exists,y2Exists:t.y2Exists,xData:t.xData,x2Data:t.x2Data,yData:t.yData,y2Data:t.y2Data,stackGroup:t.plotStackGroup}}(e),{data:o,axisData:a,x2Exists:r,y2Exists:s,xData:c,x2Data:l,yData:u,y2Data:d}=i,f=e.schema.height-e._margin.top-e._margin.bottom,m=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,p=e.schema.width-e._margin.left-e._margin.right,g=function(e,t,n,i,o){const{xData:a,x2Data:r,yData:s,y2Data:c}=o,l=ne({viz:e,plotFormattedData:t,plotAxisData:n,xData:a,x2Data:r,yData:s,y2Data:c,plotStackGroup:i},[Up,mp]);return{plotInitialDomains:l.plotInitialDomains,plotDiscreteKeys:l.plotDiscreteKeys,plotStackData:l.plotStackData,plotStackKeys:l.plotStackKeys,plotDomains:l.plotDomains,plotScales:l.plotScales,plotConfigScales:l.plotConfigScales,plotOpps:l.plotOpps,plotOpenEnds:l.plotOpenEnds}}(e,o,a,i.stackGroup,{xData:c,x2Data:l,yData:u,y2Data:d}),{x:y,y:x,x2:b,y2:_,xScale:k,yScale:v}=g.plotScales,w=h.groups(o,e=>e.shape).sort(([t],[n])=>e.schema.shapeSort(t,n)),S=function(e,t,n,i,o){const a=ne({viz:e,plotFormattedData:t,plotAxisData:n,plotScales:{...i.plotScales,...o},plotConfigScales:i.plotConfigScales,plotOpenEnds:i.plotOpenEnds},[lg,cp]).plotScales;return{x:a.x,y:a.y,x2:a.x2,y2:a.y2}}(e,o,a,g,{x:y,y:x,x2:b,y2:_}),C=function(e,t,n,i,o,a){const{x2Exists:r,y2Exists:s}=o,{x2Data:c,y2Data:l,yData:h}=a,u=ne({viz:e,plotAxisData:t,plotScales:{...n.plotScales,...i},x2Exists:r,y2Exists:s,x2Data:c,y2Data:l,yData:h},[ng]);return{xDomain:u.plotXDomain,x2Domain:u.plotX2Domain,yDomain:u.plotYDomain,y2Domain:u.plotY2Domain,defaultConfig:u.plotDefaultConfig,defaultX2Config:u.plotDefaultX2Config,defaultY2Config:u.plotDefaultY2Config,showX:u.plotShowX,showY:u.plotShowY,yC:u.plotYC,xTicks:u.plotXTicks,x2Ticks:u.plotX2Ticks,yTicks:u.plotYTicks,y2Ticks:u.plotY2Ticks,barLabels:u.plotBarLabels,barLabelCheck:u.plotBarLabelCheck}}(e,a,g,S,{x2Exists:r,y2Exists:s},{x2Data:l,y2Data:d,yData:u}),M=e.schema.lineLabels&&!s,$=function(e,t,n,i,o){const{xTest:a,yTest:r}=o;return()=>{const o=ne({viz:e,plotFormattedData:t,plotScales:n.plotScales,plotConfigScales:n.plotConfigScales,plotTestAxes:{xTest:a,yTest:r},plotLineLabelTest:{testLineShape:ny,testTextBox:iy},y2Exists:i},[Zp]);return{labelWidths:o.plotLabelWidths,largestLabel:o.plotLargestLabel,xRangeMax:o.plotXRangeMax}}}(e,o,g,s,n),A=ey(e,function(e,t,n,i){const{x2Exists:o,y2Exists:a,height:r,width:s,xData:c,x:l}=i;return{...e,xDomain:t.xDomain,x2Domain:t.x2Domain,yDomain:t.yDomain,y2Domain:t.y2Domain,xTicks:t.xTicks,x2Ticks:t.x2Ticks,yTicks:t.yTicks,y2Ticks:t.y2Ticks,xConfigScale:n.xConfigScale,x2ConfigScale:n.x2ConfigScale,yConfigScale:n.yConfigScale,y2ConfigScale:n.y2ConfigScale,defaultX2Config:t.defaultX2Config,defaultY2Config:t.defaultY2Config,yC:t.yC,showX:t.showX,showY:t.showY,x2Exists:o,y2Exists:a,height:r,width:s,xData:c,xScalePadding:l.padding?l.padding():0,barLabelCheck:t.barLabelCheck}}(n,C,g.plotConfigScales,{x2Exists:r,y2Exists:s,height:f,width:p,xData:c,x:S.x}),$),z={...e._margin};oy(e,t);const D=e._margin.left+e._margin.right-z.left-z.right,F=e._margin.top+e._margin.bottom-z.top-z.bottom,B={...i,domains:g.plotDomains,shapeData:w,discreteKeys:g.plotDiscreteKeys,stackData:g.plotStackData,stackKeys:g.plotStackKeys,...S,xScale:k,yScale:v,...g.plotConfigScales,...C,...A,...n,height:f,width:p,opp:m,showLineLabels:M,horizontalMargin:D,verticalMargin:F};return e._paint(B)}function ry(e){const t=Object.create(e);return t._d3Scale=e._d3Scale?e._d3Scale.copy():null,t._d3ScaleNegative=e._d3ScaleNegative?e._d3ScaleNegative.copy():null,t.schema={...e.schema},t}const sy={domainTicks:!0,fixedSize:void 0};const cy=e=>!!e._labelRotation&&e._labelAngle;const ly=([e,t])=>[e,Math.max(e,t)];function hy(e,t,n){const{labelWidths:i}=t,o=jg(e,t,n);t=o.pCtx;const{x2Height:a,horizontalMargin:r}=t;let s=o.yRange;const{insetBottom:c,yBottom:l}=o,{yBounds:u,yWidth:d,y2Bounds:f,y2Width:m,xOffsetLeft:p,xOffsetRight:g}=o.solved,y=n?.xRange??ly([p,t.width-(g+r)]),x=function(e,t,n,i){const{x2Height:o,topOffset:a}=t,r={x:e._margin.left,y:e._margin.top+o+a};e._chartTransform=r;const s=n>i?n-i:0,c={x:{x:e._margin.left,y:e._margin.top+o+a},x2:{x:e._margin.left,y:e._margin.top+a},y:{x:e._margin.left+s,y:e._margin.top+a},y2:{x:e._margin.left-t.horizontalMargin,y:e._margin.top+a}};return e=>({x:c[e].x-r.x,y:c[e].y-r.y})}(e,t,p,d),b=[],_=(n?.yRange??s)[1]+c-a,k=function(e,t,n,i,o,a){const{xDomain:r,x2Domain:s,xConfigScale:c,x2ConfigScale:l}=t,{defaultX2Config:h,showX:u,x2Exists:d,xC:f}=t,{xTicks:m,x2Ticks:p,x2Height:g,topOffset:y,height:x,width:b,verticalMargin:_}=t,k=e._xAxis,v=e._x2Axis;k.renderMode("compute").select(null).domain(r).height(x-(g+y+_)).maxSize(x/2).range(n).ticks(m).width(b).labelRotation(cy(t.xTest)).config({...sy,...f}).config(Jm(e,"x")).config(t.zoomAxes?.x??{}).scale(c);const w=Boolean(t.xLabelMode&&"axis"!==t.xLabelMode);w&&Qg(k,a),k.render(),u&&o.push({key:"plot-x-axis",transform:i("x"),axis:k,gridOnly:w}),d&&(v.renderMode("compute").select(null).domain(s).height(x-(t.xHeight+y+_)).range(n).ticks(p).width(b).labelRotation(cy(t.x2Test)).config({...sy,...f}).config(h).config(e._x2Config).config(t.zoomAxes?.x2??{}).scale(l).render(),o.push({key:"plot-x2-axis",transform:i("x2"),axis:v}));const S=ry(k),C=ry(v),M=(e,t)=>"x2"===t?("log"===l&&0===e&&(e=C._givenDomain()[s[0]<0?1:0]),C._getPosition(e)):("log"===c&&0===e&&(e=S._givenDomain()[r[0]<0?1:0]),S._getPosition(e));return e._xFunc=M,M}(e,t,y,x,b,_),v="ends"===t.xLabelMode?Xg(e._xAxis,y,_):[];s=n?.yRange??ly([e._xAxis.outerBounds().y+a,l-c]);const w=function(e,t,n,i,o,a,r,s){const{yDomain:c,y2Domain:l,yConfigScale:u,y2ConfigScale:d}=t,{defaultY2Config:f,showY:m,y2Exists:p,yC:g}=t,{yTicks:y,x2Height:x,height:b,width:_}=t,k=e._yAxis,v=e._y2Axis;k.renderMode("compute").select(null).domain(c).height(b).maxSize(_/2).range(i).ticks(y).width(n[n.length-1]).config({...sy,...g}).config(Jm(e,"y")).config(t.zoomAxes?.y??{}).scale(u).render(),m&&s.push({key:"plot-y-axis",transform:r("y"),axis:k}),p&&(v.renderMode("compute").select(null).config({...sy,...g}).domain(p?l:c).gridSize(0).height(b).range(i).width(_-h.max([0,o-a])).title(!1).config(e._y2Config).config(f).config(t.zoomAxes?.y2??{}).scale(d).render(),s.push({key:"plot-y2-axis",transform:r("y2"),axis:v}));const w=ry(k),S=ry(v),C=(e,t)=>"y2"===t?("log"===d&&0===e&&(e=l[1]<0?S._givenDomain(!0)[0]:S._givenDomain()[1]),S._getPosition(e)-x):("log"===u&&0===e&&(e=c[1]<0?w._givenDomain(!0)[0]:w._givenDomain()[1]),w._getPosition(e)-x);return e._yFunc=C,C}(e,t,y,s,g,m,x,b),S=function(e,t,n){let i={};return t&&(h.groups(t,e=>e.xValue).forEach(([,t])=>{const i=h.max(t.map(e=>e.fontSize)),o=h.range(n[0],n[1],i).reverse(),a=(n[1]-n[0])/8;t.forEach(function t(n,i,r){if(n.defaultY||(n.defaultY=e._yAxis._getPosition(n.value)),i){const e=r[i-1],{fontSize:s,padding:c}=n,l=n.newY||n.defaultY,h=e.newY||e.defaultY;if(l-s/2-c<h){const s=o.find(e=>e<h);n.defaultY-s<a&&(e.newY=s,i&&t(e,i-1,r))}}})}),i=t.reduce((e,t)=>(t.newY&&(e[t.id]=t.newY),e),{})),i}(e,i,s);let C=e._xAxis.barConfig()["stroke-width"];return C&&(C/=2),{x:k,y:w,xRange:y,yRange:s,xOffsetLeft:p,xOffsetRight:g,yWidth:d,y2Width:m,yBounds:u,y2Bounds:f,axisSceneQueue:b,yOffset:C||0,labelPositions:S,xEndLabels:v,insetBottom:c}}const uy=e=>"text"===e.type||"htmlOverlay"===e.type,dy="plot-break-mask";function fy(e,t){return["y","x"].flatMap(n=>{const i=e[`_${n}Axis`];if(!i||!i._breaks||!i._breaks.length)return[];const o="y"===n,a=o?t.x2Height:0,r=(o?t.xRange:t.yRange.map(e=>e-t.x2Height)).slice(0,2).sort((e,t)=>e-t);return i._breaks.map(e=>({axis:i,brk:e,vertical:o,gap:dn(i,e).map(e=>e-a),extent:r}))})}const my=e=>e.baseline?"baselineBreakConfig":"breakConfig";function py(e,t){return{...ti(e,e.schema.barConfig),...ti(e,(e.schema[my(t)]||{}).lineConfig||{})}}function gy(e,t){return fy(e,t).flatMap(({axis:e,brk:t,vertical:n,gap:i,extent:o},a)=>{if(!sn(e,my(t)).lines)return[];const r=py(e,t),s=`break-line-${n?"y":"x"}-${a}`;return i.map((e,t)=>({type:"line",key:`${s}-${t}`,points:n?[[o[0],e],[o[1],e]]:[[e,o[0]],[e,o[1]]],paint:r,interactive:!1,interactionGroup:"axis"}))})}const yy=e=>e.reduce((t,[n,i],o)=>{const[a,r]=e[(o+1)%e.length];return t+n*r-a*i},0)/2;function xy(e,t){const n=Math.sign(yy(e));return[e,...t.map(e=>Math.sign(yy(e))===n?e.slice().reverse():e)].map(e=>`M${e.map(([e,t])=>`${e},${t}`).join("L")}Z`).join("")}function by(e,t,n,i=0){const o=e[0]+i,a=e[1]-i,[r,s]=t;return n?[[r,o],[s,o],[s,a],[r,a]]:[[o,r],[a,r],[a,s],[o,s]]}function _y(e,t,n){const i=[[-1e6,-1e6],[1e6,-1e6],[1e6,1e6],[-1e6,1e6]],o=fy(e,n),a=[!0,!1].flatMap(e=>{const t=o.filter(t=>t.vertical===e&&t.brk.mask).map(({axis:t,brk:n,gap:i,extent:o})=>{const a=sn(t,my(n)).lines?(py(t,n).strokeWidth??1)/2:0;return by(i,o,e,a)});return t.length?[{axis:e?"y":"x",d:xy(i,t)}]:[]});if(!a.length)return t;const r=[];let s=[],c=0;const l=()=>{if(!s.length)return;const e=c++?"-"+(c-1):"",t=a.reduce((t,{axis:n,d:i})=>[{type:"group",key:`${dy}-${n}${e}`,clip:{type:"path",d:i},children:t}],s);r.push(...t),s=[]};for(const e of t)uy(e)?(l(),r.push(e)):s.push(e);return l(),r}const ky=e=>"group"===e.type&&String(e.key).startsWith(dy);function vy(e){return e.some(ky)?e.flatMap(e=>ky(e)?vy(e.children):[e]):e}const wy="plot-domain-clip",Sy=e=>String(e.key).endsWith("::hit"),Cy=e=>"text"===e.type||"htmlOverlay"===e.type||"axis"===e.interactionGroup,My=e=>"circle"===e.type;function $y(e){const t=e.paint;if(!t||!t.stroke||"none"===t.stroke||"transparent"===t.stroke)return 0;const n=Number(t.strokeWidth??1);return Number.isFinite(n)&&n>0?n/2:0}function Ay(e){return e.reduce((e,t)=>Math.max(e,function(e){if(Sy(e))return 0;if("group"===e.type)return Ay(e.children);const t=Math.abs(e.transform?.scale??1);return("circle"===e.type?e.r+$y(e):$y(e))*t}(t)),0)}function zy(e,t,n=[]){if(Sy(e))return!1;const i=e.transform?[e.transform,...n]:n;return"group"===e.type?e.children.some(e=>zy(e,t,i)):function(e){switch(e.type){case"circle":return[[e.cx,e.cy]];case"rect":case"image":return[[e.x,e.y],[e.x+e.width,e.y+e.height]];case"path":{const t=f.pathBounds(e.d);return[[t.x,t.y],[t.x+t.width,t.y+t.height]]}case"line":return e.points;case"area":return[...e.topline,...e.baseline];default:return[]}}(e).some(e=>{const[n,o]=i.reduce((e,t)=>Iu(e,t),e);return Number.isFinite(n)&&Number.isFinite(o)&&(n<t.x0||n>t.x1||o<t.y0||o>t.y1)})}const Dy=(e,t,n=0)=>({x0:e.x0-t,y0:e.y0-t-n,x1:e.x1+t,y1:e.y1+t+n});function Fy(e,t){const n=function(e){const t=e.xRange.slice(0,2).map(Number),n=e.yRange.slice(0,2).map(t=>Number(t)-e.x2Height);return{x0:Math.min(...t),y0:Math.min(...n),x1:Math.max(...t),y1:Math.max(...n)}}(t);if(![n.x0,n.y0,n.x1,n.y1].every(Number.isFinite))return e;const i=Dy(n,1,t.yOffset??0),o=[];let a=[],r=0,s=!1;const c=()=>{if(!a.length)return;const e=`${wy}-${r++}`;if(a.some(e=>zy(e,i))){const t=Dy(n,Ay(a)),i=a.map(e=>e.z).filter(e=>"number"==typeof e);o.push({type:"group",key:e,clip:{type:"rect",x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0},children:a,...i.length?{z:Math.min(...i)}:{}}),s=!0}else o.push(...a);a=[]};for(const t of e)Cy(t)?(c(),o.push(t)):(a.length&&My(a[0])!==My(t)&&c(),a.push(t));return c(),s?o:e}const By=new RegExp(`(^|/)${wy}-\\d+$`),Ly=e=>"group"===e.type&&By.test(String(e.key));function Py(e){return e.some(Ly)?e.flatMap(e=>"group"===e.type&&Ly(e)?e.children:[e]):e}function Ry(e,t){const n=[];try{const t=e.toScene();t&&Array.isArray(t.children)&&t.children.length&&n.push(t);const i=e._labelClass;if(i&&"function"==typeof i.toScene){const e=i.toScene();e&&Array.isArray(e.children)&&e.children.length&&n.push(e)}}catch{return null}if(!n.length)return null;const i={type:"group",key:t,children:n};return function(e){const t=e=>{e.interactive=!1;const n=e.children;if(n)for(const e of n)t(e)};e.forEach(t)}([i]),i}function Ey(e,t,n,i,o,a){const r=Object.assign({},t);delete r.shape,delete r.layer;const s=eu(t.shape).renderMode("compute").duration(e.schema.duration).config(r).config(de({x:e=>e.x2?n(e.x2,"x2"):n(e.x),x0:"x"===e.schema.discrete?e=>e.x2?n(e.x2,"x2"):n(e.x):n(o.x[0]),x1:"x"===e.schema.discrete?null:e=>e.x2?n(e.x2,"x2"):n(e.x),y:e=>e.y2?i(e.y2,"y2"):i(e.y),y0:"y"===e.schema.discrete?e=>e.y2?i(e.y2,"y2"):i(e.y):i(o.y[1])-a,y1:"y"===e.schema.discrete?null:e=>e.y2?i(e.y2,"y2"):i(e.y)-a}));return s.render(),s}function Ny(e,t,n,i,o,a){const r=[];return Object.keys(e._previousAnnotations).forEach(s=>{const c=e._annotations.filter(e=>"back"===s&&!e.layer||e.layer===s),l=c.map(e=>e.shape);c.forEach((c,l)=>{const h=(t=>Ey(e,t,n,i,o,a))(c);if("front"===s)r.push(h);else{const e=Ry(h,`annotation-${s}-${l}`);e&&t.push(e)}});e._previousAnnotations[s].filter(e=>!l.includes(e)).forEach(e=>{eu(e).renderMode("compute").data([]).render()}),e._previousAnnotations[s]=l}),r}const Ty=["bandOpacity","capWidth","tooltip"];function Oy(e){const{viz:t,x:i,y:o,values:a}=e,r=Bm(t);if(!r.length)return[];const s=t.schema.discrete||"x",c="x"===s?"y":"x",l="x"===s?o:i,h=Object.assign({},t.schema.shapeConfig,t._confidenceConfig),u=n.assign(au(t,"Line",h),au(t,"Area",h));Ty.forEach(e=>delete u[e]);const d=r.length>1,f=d?Rm(Pm(t._confidenceConfig?.bandOpacity,r.length)):[],m=[];return r.forEach((t,n)=>{const i=(e,t,n)=>l(e?Em(e(t.data,t.i),n):n),o=de(Object.assign({},e.shapeConfig));o[`${c}0`]=e=>i(t.lower,e,e[c]),o[`${c}1`]=e=>i(t.upper,e,e[c]),n&&(o.id=e=>`${e.id}::band-${n}`);const r=eu("Area").renderMode("compute").config(o).data(a);r.config(u),d&&r.config({fillOpacity:f[n]}),r.render(),m.push(...su(r))}),m}function Wy(e,t,n,i){const o=e/2;if(t<2)return[-o,o];const a=2*i/(t-1),r=n*a-i;return[(n<=0?-o:r-a/2)-r,(n>=t-1?o:r+a/2)-r]}const jy=e=>"Bar"===e.shapeType&&String(e.key).endsWith("::hit");function Hy(e,t){const n=e=>Sr(e),i=t.label(),o=t.labelBounds(),a=t.labelConfig(),r="number"==typeof a.padding?a.padding:0,s=a.verticalAlign;if("function"!=typeof o)return;const c=new WeakSet,l=(e,t)=>{const o=i(e,t);return!(!1===o||null==o||Array.isArray(o)||!Number.isFinite(n(e)))&&o};t.label((t,o)=>{const a=l(t,o);return!1===a?i(t,o):[a,`${d.formatAbbreviate(100*n(t),e.schema.locale)}%`]}),t.labelBounds((e,t,n)=>{const i=o(e,t,n);if(!i||Array.isArray(i)||!1===l(e,t))return i;const a=function(e,t){const n=Math.min(14,.4*(e.height-2*t));if(n<8)return null;const i=e.height-t-n;return[{...e,height:i+t},{...e,height:n+2*t,y:e.y+i-t}]}(i,r);return a?(c.add((e=>e.__d3plusShape__?e.data:e)(e)),a):[i,{...i,height:0,width:0}]}),t.labelConfig({verticalAlign:(e,t)=>!!e&&c.has(e.data)?1===e.l?"top":"bottom":"function"==typeof s?s(e,t):s})}function Iy(e,t){return{start:i.cubicInOut(e/t),end:i.cubicInOut((e+1)/t)}}function Gy(e,t){const{viz:n}=e;if(!n.schema.stacked||function(e){const t=e=>"rect"===e.type&&"Bar"===e.shapeType||"group"===e.type&&e.children.some(t);return!!e&&t(e.root)}(n._paintedScene))return t;const{levels:i,depth:o}=function(e,t){const{opp:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:a}=t,r=new Map;for(const t of e){const e=Number(t[n??"y"]),s=i[o.get(t.id)??-1],c=a.get(t.discrete);if(!e||!Number.isFinite(e)||!s||void 0===c)continue;const l=s.index??o.get(t.id),h=`${c}|${t.group}|${e<0?"-":"+"}`;r.has(h)||r.set(h,[]),r.get(h).push({row:t,order:l})}const s=new Map;let c=0;for(const e of r.values())e.sort((e,t)=>e.order-t.order),e.forEach(({row:e},t)=>s.set(e,t)),c=Math.max(c,e.length);return{levels:s,depth:c}}(e.values,e);if(o<2)return t;const a=new Map;for(const e of t){const t="Bar"===e.shapeType?i.get(e.datum):void 0;void 0!==t&&a.set(e.datum,Iy(t,o))}return t.map(e=>{const t=e.datum,n=a.get(t)??a.get(t?.data);return n?{...e,enterWindow:n}:e})}function Vy(e,t,n,i){if("none"===t.paint?.fill)return null;const o=tu(e.backgroundImage,n,i);if("string"!=typeof o||!o)return null;const a=Ro(t,[],"contain"===tu(e.backgroundImageFit,n,i)?"contain":"cover");if(!(a&&a.box.width>0&&a.box.height>0))return null;const r=t.paint?.opacity,[s]=Eo([{key:t.key,index:t.index??i??0,datum:t.datum,url:o,box:a.box,clip:a.clip,preserveAspectRatio:a.preserveAspectRatio,opacity:"number"==typeof r?r:void 0,transform:t.transform}],null,0);return s}function qy(e,t,n){if(!e.backgroundImage)return[];const i=[];return t.forEach((t,o)=>{const[a,r]=n(o),s=Vy(e,t,a,r);s&&i.push(s)}),i}function Yy(e,t,n=16){const i=[];let o=0,a=0;const r=(e,t)=>{i.push([e,t]),o=e,a=t},s={moveTo:r,lineTo:r,closePath:()=>{},bezierCurveTo(e,t,r,s,c,l){const h=o,u=a;for(let o=1;o<=n;o++){const a=o/n,d=1-a,f=d*d*d,m=3*d*d*a,p=3*d*a*a,g=a*a*a;i.push([f*h+m*e+p*r+g*c,f*u+m*t+p*s+g*l])}o=c,a=l},quadraticCurveTo(e,t,r,s){const c=o,l=a;for(let o=1;o<=n;o++){const a=o/n,h=1-a;i.push([h*h*c+2*h*a*e+a*a*r,h*h*l+2*h*a*t+a*a*s])}o=r,a=s}};return y.line().curve(If(t)).context(s)(e),i}function Ky(e,t,n){let i,o=0;if(e.length){const o=Math.sign(e[e.length-1][t]-e[0][t])||1;(e[0][t]-n)*o>=0&&(i=0)}for(let a=1;a<e.length;a++){const r=e[a-1],s=e[a],c=Math.hypot(s[0]-r[0],s[1]-r[1]);void 0===i&&(r[t]-n)*(s[t]-n)<=0&&s[t]!==r[t]&&(i=o+c*((n-r[t])/(s[t]-r[t]))),o+=c}return[i??o,o]}function Uy(e,t,n){const i=n.length%2?n.concat(n):n,o=i.reduce((e,t)=>e+t,0);if(!(o>0)||e>=t)return;const a=[+e.toFixed(2),0];for(let n=0;n<t-e;n+=o)a.push(...i);return a}const Xy="plot-forecast",Qy=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t;function Zy(e,t,n){return"x"===(e.schema.discrete||"x")?t.x(n):t.y(n)}function Jy(e,t,n){const i=e.schema.discrete||"x",o=om(n.map(e=>e[i])),a=n.map(n=>({at:o(n[i]),px:Zy(e,t,n[i])})).filter(e=>Number.isFinite(e.px)).sort((e,t)=>e.at-t.at);return a.length<2?1:a[a.length-1].px<a[0].px?-1:1}function ex(e,t,n,i,o){if(void 0===i.next)return NaN;const a=Zy(e,t,i.next);if(!Number.isFinite(a))return NaN;const r=Zy(e,t,i.value);if(Number.isFinite(r)&&Math.abs(r-a)>=.5)return(r+a)/2;const s=e.schema.discrete||"x",c=n.map(n=>Zy(e,t,n[s])).filter(e=>Number.isFinite(e)),l=e=>c.filter(t=>(t-a)*o*e>.5).reduce((e,t)=>void 0===e||Math.abs(t-a)<Math.abs(e-a)?t:e,void 0),h=l(-1);if(void 0!==h)return(h+a)/2;const u=l(1);return void 0!==u?a-(u-a)/2:a}function tx(e,t,i,o=!1){const a=lm(e,t);if(!a||!t.length)return[];const s="x"===(e.schema.discrete||"x"),c=Jy(e,i,t),l=o?ex(e,i,t,a,c):Zy(e,i,a.value);if(!Number.isFinite(l))return[];const h=s?i.xRange:[0,i.yRange[1]-i.yRange[0]],u=s?[0,i.yRange[1]-i.yRange[0]]:i.xRange,d=Math.min(h[0],h[1]),f=Math.max(h[0],h[1]),m=c>0?f:d,p=Math.min(Math.max(l,d),f);if(Math.abs(m-p)<1)return[];const g=l>=d-.5&&l<=f+.5,y=e.schema.forecastConfig,x=function(e){const t=n.backgroundColor(e._select?.node());return r.colorContrast(t,e.schema.colorDefaults)}(e),b=Math.min(p,m),_=Math.abs(m-p),k={type:"rect",key:`${Xy}-region`,x:s?b:u[0],y:s?u[0]:b,width:s?_:u[1]-u[0],height:s?u[1]-u[0]:_,paint:{fill:y.fill||x,fillOpacity:Qy(y.fillOpacity,.05)},interactive:!1},v=[];if(!1!==y.fill&&"none"!==y.fill&&v.push(k),v.push(...nx(y,k,x)),g&&!1!==y.stroke&&"none"!==y.stroke){const e={fill:"none",stroke:y.stroke||x,strokeWidth:Qy(y.strokeWidth,1),strokeOpacity:Qy(y.strokeOpacity,.4)},t=Oo(y.strokeDasharray);t&&(e.strokeDasharray=t),v.push({type:"line",key:`${Xy}-rule`,points:s?[[p,u[0]],[p,u[1]]]:[[u[0],p],[u[1],p]],curve:"linear",paint:e,interactive:!1})}const w=g?function(e,t){const n=t.label;return!1===n||null===n||""===n?"":"function"==typeof n?`${n(e.schema.locale)}`:"string"==typeof n?n:e.schema.translate("Forecast")}(e,y):"";return w&&v.push(function(e,t,i,o){const a=Qy(t.fontSize,12),r=t.fontFamily||`${e.schema.fontFamily}`,s=n.textWidth(i,{"font-family":r,"font-size":a}),c=5,l=o.dir>=0,h=o.horizontal?o.from+(l?c:-c):o.cross[0]+c,u=o.horizontal?o.cross[0]+c+a/2:o.from+(l?c+a/2:-c-a/2);return{type:"text",key:`${Xy}-label`,interactive:!1,x:0,y:0,transform:{x:h,y:u},lines:[{text:i,x:0,y:0,width:s}],font:{family:r,size:a,weight:t.fontWeight??400,anchor:o.horizontal&&!l?"end":"start",baseline:"middle"},paint:{fill:t.fontColor||o.ink,opacity:Qy(t.fontOpacity,.7)}}}(e,y,w,{from:p,dir:Math.sign(m-p),horizontal:s,cross:u,ink:x})),v.length?[{type:"group",key:Xy,interactive:!1,children:v}]:[]}function nx(e,t,n){const i=[],o="string"==typeof e.fill&&"none"!==e.fill?e.fill:n,a=Do(e.texture,()=>"transparent",()=>o,e.textureDefault||void 0);a&&i.push({...t,key:`${Xy}-texture`,paint:{fill:`pattern:${a}`,opacity:Qy(e.textureOpacity,.3)}});const r=e.backgroundImage,s="string"==typeof r&&Vy({backgroundImage:r,backgroundImageFit:e.backgroundImageFit},{...t,paint:{}},void 0,0);return s&&i.push(s),i}function ix(e,t,n,i){const o=Oo(e.schema.forecastConfig.lineDasharray);if(!o||!o.some(e=>e>0))return null;const a=lm(e,t);if(!a||a.series&&!a.series.size)return null;const r="x"===(e.schema.discrete||"x")?0:1,s=n.x,c=n.y,l=Gf(e,t[0]),h=new Map;return(n,u)=>{const d=`${t[u]?.id}`;if(!h.has(d)){const n=(t=>{const n=a.series?a.series.get(t):a.value;return void 0===n?NaN:Zy(e,i,n)})(d);if(Number.isFinite(n)){const e=t.filter(e=>`${e.id}`===d).map(e=>[s(e),c(e)]),[i,a]=Ky(Yy(e,l),r,n);h.set(d,Uy(i,a,o))}else h.set(d,void 0)}return h.get(d)}}function ox(e,t){return(n,i)=>{const o=e(n,i);return o||("function"==typeof t?t(n,i):t)}}function ax(e){const t=e.map(([e])=>e),n=e.flatMap(([,e])=>e);return{rows:n,slots:t.includes("Bar")&&!t.includes("Line")&&!t.includes("Area")}}function rx(e,t){const{viz:n,opp:i,x:o,y:a,stackData:r,domains:s,stackKeyIndex:c,discreteKeyIndex:l}=e,h=de(Object.assign({},e.shapeConfig));if("Circle"===t&&n._size){const e=n._size;h.sort=(t,n)=>(Number(e(n))||0)-(Number(e(t))||0)}if("Box"===t&&(h.id=e=>e.discrete),n.schema.stacked&&["Area","Bar"].includes(t)){const e="x"===i?o:a;h[`${i}`]=h[`${i}0`]=t=>{const n=c.get(t.id)??-1,o=l.get(t.discrete)??-1,a=t[i]<0?1:0;return e(n>=0?r[n][o][a]:s[i]["x"===i?0:1])},h[`${i}1`]=t=>{const n=c.get(t.id)??-1,o=l.get(t.discrete)??-1,a=t[i]<0?0:1;return e(n>=0?r[n][o][a]:s[i]["x"===i?0:1])}}return h}function sx(e,t,n,i){const{viz:o,events:a}=e;o._wirePlotShapeEvents(n,t,a);const r=au(o,t);void 0===o.schema.shapeConfig.duration&&delete r.duration,n.config(r),i&&n.config(i(r)),"Bar"===t&&e.barLabelsOnAxis&&n.label(!1),o.schema.stacked&&"Bar"===t&&Hy(o,n),n.render();const s=su(n);if("Bar"!==t)return s;const c=vp(e,s);if(!c.length)return Gy(e,s);let l=-1;return s.forEach((e,t)=>{"Bar"===e.shapeType&&(l=t)}),Gy(e,[...s.slice(0,l+1),...c,...s.slice(l+1)])}const cx=(e,t)=>sx(e,t,eu(t).renderMode("compute").config(rx(e,t)).data(e.values));function lx(e){const{viz:t,values:n}=e,i=t.schema.discrete;if("Time"!==("x"===i?e.xScale:e.yScale))return n;const o=e.zoomRanges?.[i];if(o){const t="x"===i?e.x:e.y,[a,r]=h.extent(o);return n.filter(e=>{const n=t(e[i]);return n>=a-.5&&n<=r+.5})}const[a,r]=h.extent(("x"===i?e.xDomain:e.yDomain).map(Number));return n.filter(e=>{const t=+e[i];return t>=a&&t<=r})}function hx(e,t,n){const{viz:i}=e;i.schema.stacked||function(e,t,n,i){n&&e.config({hitArea:(o,a)=>function(e,t,n,i){const[o,a]=t,[r,s]=n;return"x"===e?{x:o,y:r-(i.y??0),width:a-o,height:s-r}:{x:r-(i.x??0),y:o,width:s-r,height:a-o}}(t,i(o,a),n,e._sceneTransform(o,a))})}(t,"y"===i.schema.discrete?"y":"x",e.valueExtent,n)}const ux={Bar:e=>{const t={...e,values:lx(e)},{viz:n,x:i,y:o,xScale:a,yScale:r,xDomain:s,yDomain:c,xRange:l,yRange:u,values:d,zoomRanges:f}=t,m=eu("Bar").renderMode("compute").config(op(rx(t,"Bar"),bf(n),t.valueExtent)).data(d),p="x"===n.schema.discrete?i:o;if(n._discreteExtent)return function(e,t,n){const{viz:i,values:o}=e,a=e=>{const[t,o]=Cm(i,e);return Math.max(1,Math.abs(n(o)-n(t))-i._groupPadding)},r=e=>{const[t,o]=Cm(i,e);return Math.abs(n(o)-n(t))},s=i.schema.discrete,c=i._barSpans?function(e,t){const n=new Map,i=new Set;let o=!1;for(const a of e){const e=dm(a[t]),r=n.get(e)??new Set;r.add(a.group),n.set(e,r),i.add(a.group),r.size>1&&(o=!0)}return o?Array.from(i):[]}(o,s):[];if(c.length<2)return t.width(a),t.height(a),hx(e,t,e=>Wy(r(e),1,0,0)),sx(e,"Bar",t);const l=e=>function(e,t,n,i){const o=Math.max(1,(e-i*t-1)/t);if(t<2)return{size:o,offset:0};const a=Math.max(0,e-o)/2;return{size:o,offset:n*a*2/(t-1)-a}}(a(e),c.length,c.indexOf(e.group),i.schema.barPadding),h=e.shapeConfig[s];return t[s]((e,t)=>h(e,t)+l(e).offset),t.width(e=>l(e).size),t.height(e=>l(e).size),hx(e,t,e=>Wy(r(e),c.length,c.indexOf(e.group),Math.max(0,a(e)-l(e).size)/2)),sx(e,"Bar",t)}(t,m,p);let g;const y="x"===n.schema.discrete?a:r,x="x"===n.schema.discrete?s:c,b="x"===n.schema.discrete?l:u,_=f?.[n.schema.discrete];if("Point"!==y&&2===x.length){const e=Array.from(new Set(d.map(e=>p(e[n.schema.discrete]))));e[0]>e[e.length-1]&&e.reverse();const t=e[0],i=e[e.length-1];e.unshift(_?2*_[0]-t:b[0]-t-b[0]),e.push(_?2*_[1]-i:b[1]+b[1]-i),g=e.reduce((e,t,n,i)=>{if(n){const o=Math.abs(t-i[n-1]);o<e&&(e=o)}return e},1/0)}else g=x.length>1?Math.abs(p(x[1])-p(x[0])):b[b.length-1]-b[0];const k=g;n._groupPadding<g&&(g-=n._groupPadding);let v=g||1;const w=h.groups(d,e=>e[n.schema.discrete],e=>e.group),S=h.merge(w.map(([,e])=>e.map(([e])=>e))),C=Array.from(new Set(S)),M=n.schema.discrete,$=t.shapeConfig[M];let A=()=>Wy(k,1,0,0);if(1===h.max(w.map(([,e])=>e.length)))m[M]((e,t)=>$(e,t));else{v=(v-n.schema.barPadding*C.length-1)/C.length;const e=g/2-v/2,t=B.scaleLinear().domain([0,C.length-1]).range([-e,e]);m[M]((e,n)=>$(e,n)+t(C.indexOf(e.group))),A=t=>Wy(k,C.length,C.indexOf(t.group),e)}return m.width(v),m.height(v),hx(t,m,A),sx(t,"Bar",m)},Circle:(e,t)=>{if(!e.viz._swarm)return cx(e,t);const{viz:n,values:i,x:o,y:a,xRange:r,yRange:s}=e,c=eu("Circle").renderMode("compute").config(rx(e,"Circle")).data(i);return sx(e,"Circle",c,t=>{const c=t.r,l=Xm(n,{values:i,x:o,y:a,xRange:r,yRange:s,lanes:"x"===n._swarm.cross?e.xDomain:e.yDomain,r:"function"==typeof c?c:()=>c}),h=e=>l.get(e);return{x:e=>h(e).x,y:e=>h(e).y,r:e=>h(e).r}})},Line:e=>{const{viz:t,values:n,width:i,showLineLabels:o,labelWidths:a,largestLabel:r,labelPositions:s}=e,c=[],l=eu("Line").renderMode("compute").config(rx(e,"Line")).data(n);t.schema.fillBetween&&c.push(...Qf(e)),l.duration(1.5*i),t._confidence&&c.push(...Oy(e)),l.config({discrete:e.shapeConfig.discrete||"x",label:!!o&&((e,n)=>{if(!("function"!=typeof t.schema.lineLabels||t.schema.lineLabels(e.data,e.i)))return!1;const i=a.find(t=>t.id===e.id);if(i){const o=i.newY||i.defaultY,r=a.filter(e=>e.newY===o);return r.length>1?r[0].id===e.id&&`+${d.formatAbbreviate(r.length,t.schema.locale)} ${t.schema.translate("more")}`:t._drawLabel(e,n)}return!1}),labelBounds:!!o&&((e,n,i)=>{const[o,a]=i.points[0],[c,l]=i.points.reduce((e,t)=>t[0]>=e[0]?t:e),h=t.schema.height/4;return{x:c-o,y:l-a-h/2-(s[e.id]?l-s[e.id]:0),width:r,height:h}})});const h=ix(t,n,e.shapeConfig,e);c.push(...sx(e,"Line",l,h?e=>({strokeDasharray:ox(h,e.strokeDasharray)}):void 0));const u=eu("Circle").renderMode("compute").data(t._lineMarkers?n:[]).config(e.shapeConfig).config(t._lineMarkerConfig).id(e=>`${e.id}_${e.discrete}`);return t._wirePlotShapeEvents(u,"Circle",e.events),u.render(),c.push(...su(u)),c}};const dx=["group","order","confidence","confidenceLevel","confidenceConfig","projection","projectionConfig","tooltip","stroke"];function fx(e,t,n){const i=e;return i.interactive=n,i.interactionGroup="trend",n&&(i.trendFit=t),i.datum=t.row,i.children&&i.children.forEach(e=>fx(e,t,n)),e}function mx(e,t,n){return(e._trendFits||[]).map(i=>function(e,t,n,i){const o=e._trendLineConfig||{},a=[],r=()=>`trend-${t.id}`;if(void 0!==t.samples[0].lci){const s=eu("Area").renderMode("compute").duration(e.schema.duration).data(t.samples).config({id:r,label:!1,fill:t.color,stroke:"none",strokeWidth:0}).config(o.confidenceConfig||{}).config(function(e,t,n){const i=i=>"x"===e.axis?t(i.x):n(i.y),o=i=>"x"===e.axis?n(i.lci):t(i.lci),a=i=>"x"===e.axis?n(i.hci):t(i.hci);return"x"===e.axis?{x:i,x0:i,x1:null,y:o,y0:o,y1:a}:{y:i,y0:i,y1:null,x:o,x0:o,x1:a}}(t,n,i));a.push(...su(s).map(e=>fx(e,t,!1)))}const s=Object.fromEntries(Object.entries(o).filter(([e])=>!dx.includes(e))),c=(r,c,l)=>{if(r.length<2)return;const h=eu("Line").renderMode("compute").duration(e.schema.duration).data(r).config({...s,id:c,label:!1,stroke:t.color}).config(l).config({x:e=>n(e.x),y:e=>i(e.y)});a.push(...su(h).map(e=>fx(e,t,!1!==o.tooltip)))};return c(t.samples.filter(e=>!e.projected),r,{}),c(t.samples.filter(e=>e.projected),()=>`trend-${t.id}-projection`,o.projectionConfig||{}),a.length?{type:"group",key:`plot-trend-${t.id}`,children:a}:null}(e,i,t,n)).filter(e=>null!==e)}function px(e,t,n,i,o){const{shapeData:a,domains:r,discreteKeys:s,stackData:c,stackKeys:l,xDomain:h,yDomain:u}=n,{xScale:d,yScale:f}=n,{labelWidths:m,largestLabel:p}=n,{width:g}=n,{opp:y,showLineLabels:x}=n,{x:b,y:_,xRange:k,yRange:v,labelPositions:w,yOffset:S}=i,C=Object.keys(e.schema.on),M=new Map;for(let e=0;e<l.length;e++)M.set(l[e],e);const $=new Map;for(let e=0;e<s.length;e++)$.set(s[e],e);const A={viz:e,shapeConfig:o,events:C,x:b,y:_,xScale:d,yScale:f,xDomain:h,yDomain:u,xRange:k,yRange:v,opp:y,domains:r,stackData:c,stackKeyIndex:M,discreteKeyIndex:$,showLineLabels:x,labelWidths:m,largestLabel:p,labelPositions:w,width:g,values:[],valueExtent:ip(e,{x2Height:n.x2Height,yOffset:S}),barLabelsOnAxis:n.barLabelsOnAxis,insetBottom:i.insetBottom??0,x2Height:n.x2Height,zoomRanges:n.zoomRanges};var z;t.push(...(z=a.flatMap(([e,t])=>function(e,t){return(e.viz._plotShapeEmitters?.[t]??ux[t]??cx)(e,t)}({...A,values:t},e)),z.some(jy)?[...z.filter(jy),...z.filter(e=>!jy(e))]:z))}const gx=e=>"string"==typeof e.key&&e.key.startsWith("grid-"),yx=e=>{e.interactionGroup="axis";const t=e.children;if(t)for(const e of t)yx(e)};function xx(e,t,i,o){const a=[],{shapeData:r,domains:s}=t,{labelWidths:c}=t,{x:l,y:h,xRange:u,yRange:d,yOffset:f,axisSceneQueue:m}=i,p=function(e){const t=[],n=[];return e.forEach(({key:e,transform:i,axis:o,gridOnly:a})=>{if(!o||"function"!=typeof o.toScene)return;const r=o.toScene();if(!r)return;const s=r.children||[],c=s.filter(gx),l=s.filter(e=>!gx(e));if(c.length){const n={type:"group",key:`${e}-grid`,transform:i,children:c};yx(n),t.push(n)}if(l.length&&!a){const t={type:"group",key:e,transform:i,children:l};yx(t),n.push(t)}}),{grid:t,rest:n}}(m);!function(e,t,n,i){const o=e._backgroundConfig;if(o&&o.fill&&"transparent"!==o.fill){const e=eu("Rect").renderMode("compute").data([{}]).x(n[0]+(n[1]-n[0])/2).width(n[1]-n[0]).y((i[1]-i[0])/2).height(i[1]-i[0]).config(o);e.render();const a=su(e);t.unshift(...a)}}(e,a,u,d),a.push(...p.grid),a.push(...gy(e,{xRange:u,yRange:d,x2Height:t.x2Height})),a.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);if(!i.length)return[];const o=i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue),y:t.defaultY},t)).concat(i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t))),a=eu("Line").config({data:o,stroke:e=>e.fontColor,x:e=>e.x,y:e=>e.y}).config(e._labelConnectorConfig).renderMode("compute");return a.render(),su(a)}(e,c));const g=Ny(e,a,l,h,s,f),y=ax(r);a.push(...tx(e,y.rows,{x:l,y:h,xRange:u,yRange:d},y.slots));const x=mx(e,l,h),b=function(e,t,n,i,o){const a=e.schema.discrete||"x";return de({discrete:e.schema.discrete,duration:e.schema.duration,label:t=>e._drawLabel(t.data,t.i),x:e=>void 0!==e.x2?t(e.x2,"x2"):t(e.x),x0:"x"===a?e=>e.x2?t(e.x2,"x2"):t(e.x):t("number"==typeof e.schema.baseline?e.schema.baseline:i.x[0]),x1:"x"===a?null:e=>e.x2?t(e.x2,"x2"):t(e.x),y:e=>void 0!==e.y2?n(e.y2,"y2"):n(e.y),y0:"y"===a?e=>e.y2?n(e.y2,"y2"):n(e.y):n("number"==typeof e.schema.baseline?e.schema.baseline:i.y[1])-o,y1:"y"===a?null:e=>e.y2?n(e.y2,"y2"):n(e.y)-o})}(e,l,h,s,f),_=x.length;px(e,x,t,i,b);const k=function(e,t){const n=[];for(let i=e.length-1;i>=t;i--)"axis"===e[i].interactionGroup&&n.unshift(...e.splice(i,1));return n}(x,_);e._plotUnderlay&&x.splice(_,0,...e._plotUnderlay(x.slice(_),l,h));const v=[d[0],d[1]+(i.insetBottom??0)];a.push(...o?x:Fy(x,{xRange:u,yRange:v,x2Height:t.x2Height,yOffset:f})),function(e,t,n){const i=t.map(([e])=>e);i.includes("Line")&&(e._confidence&&i.push("Area"),e._lineMarkers&&i.push("Circle")),e._previousShapes.filter(t=>!i.includes(t)&&!e._plotShapeEmitters?.[t]).forEach(e=>{const t=eu(e);"function"==typeof t.renderMode&&t.renderMode("compute"),"function"==typeof t.select&&t.select(null),t.config(n).data([]).render()}),e._previousShapes=i}(e,r,b),g.forEach((e,t)=>{const n=Ry(e,`annotation-front-${t}`);n&&a.push(n)});const w=_y(e,a,{xRange:u,yRange:d,x2Height:t.x2Height}),S=e.schema.zoom?[{type:"group",key:bx,...o?{clip:o}:{},children:w}]:w,C=Zg(e._xAxis,i.xEndLabels??[]);return C&&yx(C),[...S,...k,...p.rest,...C?[C]:[]]}const bx="plot-zoom-content";function _x(e,t,n,i){const o=hy(e,t,n),{xRange:a,yRange:r}=o;return e._bodyRect={x:a[0],y:r[0],width:a[1]-a[0],height:r[1]-r[0]},e._plotAxisDomains={x:e._xAxis?._d3Scale?.domain()??[],y:e._yAxis?._d3Scale?.domain()??[]},e._plotArea={x:a[0],y:0,width:a[1]-a[0],height:r[1]-r[0]+(o.insetBottom??0)},{nodes:xx(e,t,o,i),layout:o}}const kx=(e,t)=>"time"===t||"Linear"===e&&["linear","pow","sqrt"].includes(t);function vx(e,t,n){const{nodes:i,layout:o}=_x(e,t);if(clearTimeout(e._plotUnclipTimer),e._plotZoomBase=void 0,e._zoomShapes=void 0,!e.schema.zoom)return i;const a={},r={},s={},c={};for(const n of function(e){const t=[];return kx(e.xScale,e.xConfigScale)&&t.push("x"),e.x2Exists&&kx(e.xScale,e.x2ConfigScale)&&t.push("x2"),kx(e.yScale,e.yConfigScale)&&t.push("y"),e.y2Exists&&kx(e.yScale,e.y2ConfigScale)&&t.push("y2"),t}(t)){const t=e[`_${n}Axis`],i=t?._d3Scale;i&&"function"==typeof i.invert&&(a[n]=i.copy(),r[n]=t?._labelSpace,s[n]=Boolean(t?._baselineBreak),c[n]=Boolean(t?.schema.reverse))}if(e._zoomShapes=function(e){const t=e.find(e=>e.key===bx);return t&&"group"===t.type?Py(vy(t.children)):void 0}(i),!Object.keys(a).length)return i;const{x:l=0,y:h=0}=e._chartTransform||{};if(e._plotZoomBase={pCtx:t,layout:o,chartTransform:{x:l,y:h},scales:a,labelSpace:r,breaks:s,reversed:c},n&&(1!==n.k||n.x||n.y)){const t=wx(e,n);if(t)return t}return i}function wx(e,t,n=!1){const i=e._plotZoomBase;if(!i)return;const{pCtx:o,layout:a}=i,r=1===t.k&&!t.x&&!t.y,s=r?{}:function(e,t){const{pCtx:n,layout:i,chartTransform:o,scales:a}=e,r=i=>{const r=a[i],s="y"===i[0],c=s?o.y:o.x,l=s?t.y:t.x,h=s?-n.x2Height:0,u=r.range().map(e=>r.invert((e+h+c-l)/t.k-c-h)),[d,f]=r.domain();return(+f-+d)*(+u[1]-+u[0])<0!==Boolean(e.reversed[i])?u.reverse():u},s={};for(const e of Object.keys(a))s[`${e}Domain`]=r(e);s.zoomAxes={};for(const t of Object.keys(a))s.zoomAxes[t]={rounding:"none",domainTicks:!1,fixedSize:e.labelSpace[t],domain:s[`${t}Domain`],...e.breaks[t]?{}:{baselineBreak:!1}};const c=(e,i)=>{const a=i?o.y:o.x,r=i?-n.x2Height:0;return(e+r+a)*t.k+(i?t.y:t.x)-a-r};return s.zoomRanges={},a.x&&(s.zoomRanges.x=i.xRange.map(e=>c(e,!1))),a.y&&(s.zoomRanges.y=i.yRange.map(e=>c(e,!0))),s}(i,t),c=r&&!n?void 0:{type:"rect",x:a.xRange[0],y:a.yRange[0]-o.x2Height,width:a.xRange[1]-a.xRange[0],height:a.yRange[1]-a.yRange[0]+(a.insetBottom??0)};return _x(e,{...o,...s},a,c).nodes}const Sx={2:"²",3:"³"},Cx={exponential:"Exponential",linear:"Linear",logarithmic:"Logarithmic",polynomial:"Polynomial",power:"Power"};function Mx(e,t){const n=e.filter(([e])=>0!==e);return n.length?n.map(([e,n],i)=>{const o=`${t(Math.abs(e))}${n}`;return 0===i?e<0?`−${o}`:o:e<0?` − ${o}`:` + ${o}`}).join(""):t(0)}function $x(e,t=String,n="x"){const i=n,o="x"===n?"y":"x",a=e.coefficients;let r;if("exponential"===e.type)r=`${t(a[0])}e^(${t(a[1])}${i})`;else if("power"===e.type)r=`${t(a[0])}${i}^${t(a[1])}`;else if("logarithmic"===e.type)r=Mx([[a[1],`ln(${i})`],[a[0],""]],t);else{r=Mx(a.map((e,t)=>[e,0===t?"":1===t?i:`${i}${Sx[t]||`^${t}`}`]).reverse(),t)}return`${o} = ${r}`}function Ax(e,t,n,i){const o=n.nativeEvent,a=o&&o.touches&&o.touches.length?[o.touches[0].clientX,o.touches[0].clientY]:o?[o.clientX,o.clientY]:n.point;Ur(Cg(e).data([t.row||{}]).config(Ae.bind(e)(e.schema.tooltipConfig)).title(()=>t.label),Er(t.color,"Line")).thead([]).tbody(function(e,t,n){const{fit:i,axis:o}=t,a=t=>e.schema.translate(t),r=[];if(n&&n.projected){const t="x"===o?"y":"x",i=n=>vg(e,t,n),s=void 0!==n.lci?` (${i(n.lci)} – ${i(n.hci)})`:"";r.push([kg(e,o),`${vg(e,o,n[o])} (${a("Projected")})`],[kg(e,t),`${i(n[t])}${s}`])}var s;return r.push([a("Trend Line"),a(Cx[i.type])]),e[`_${o}Time`]||r.push([a("Equation"),$x(i,(s=e.schema.locale,e=>0!==e&&Math.abs(e)<.001?e.toPrecision(3):d.formatAbbreviate(e,s)),o)]),r.push(["R²",i.r2.toFixed(3)],[a("Observations"),`${i.n}`]),r}(e,t,i?function(e,t,n){const i="x"===t.axis?e._xFunc:e._yFunc;if(!i)return;const o="x"===t.axis?n[0]:n[1],a=e=>{let n,a=1/0;for(const r of e){const e=Math.abs(i(r[t.axis])-o);e<a&&([n,a]=[r,e])}return n},r=a(t.samples);return r&&r.projected?a(t.samples.filter(e=>e.step)):void 0}(e,t,i):void 0)).footer(!1).position(a).render()}function zx(e,t){const n=e._zoomTransform,i=n&&n.scale?n.scale:1,o=e._chartTransform;return[(t[0]-(n?.x??0))/i-(o?.x??0),(t[1]-(n?.y??0))/i-(o?.y??0)]}const Dx=e=>e instanceof Date?String(e.getTime()):String(e);function Fx(e,t){return!(!t.shapeType||!t.datum||"Box"===t.shapeType)&&("Bar"!==t.shapeType||!!e.schema.stacked)}function Bx(e,t,n){const i=new Map,o="x"===t?e._xFunc:e._yFunc,a=(e,o,a,r)=>{if(!e||!Number.isFinite(o))return null;const s=Dx(e[t]);let c=i.get(s);if(c||(c={px:o,value:e[t],members:new Map,bars:new Set,markers:[]},i.set(s,c)),"Bar"===r){const t=e.data||e;c.bars.add(t),n.bars.add(t)}const l=String(e.id),h=c.members.get(l);return h?h.color||(h.color=a):c.members.set(l,{wrapped:e,color:a,shape:r}),c},r=new Set,s=i=>{if(i.interactionGroup||!1===i.interactive)return;if(i.children&&i.children.forEach(e=>s(e)),"Box"===i.shapeType&&(n.box=!0),!Fx(e,i))return;const c=i.paint||{},l=Tr(c.stroke)??Tr(c.fill);if("Area"===i.shapeType&&(n.area=!0),i.interactionPoints)for(const e of i.interactionPoints){const n=a(e.datum,e[t],l,i.shapeType);n&&"Line"===i.shapeType&&!r.has(e.datum)&&(r.add(e.datum),n.markers.push({datum:e.datum,x:e.x,y:e.y}))}else if(o&&!i.datum.__d3plusShape__){const e=i.datum;a(e,o(e[t]),l,i.shapeType)}};return(e._chartScene||[]).forEach(e=>s(e)),o&&function(e,t,n,i){for(const o of e._trendFits||[])if(o.axis===t&&!1!==e._trendLineConfig?.tooltip)for(const e of o.samples){if(!e.step)continue;const a=e[t],r=i(a);if(!Number.isFinite(r))continue;const s=Dx(a);let c=n.get(s);c||(c={px:r,value:a,members:new Map,bars:new Set,markers:[]},n.set(s,c));const l=o.row||{};c.members.set(`${o.id}::projected`,{wrapped:l,color:o.color,shape:"Line",trend:{fit:o,sample:e}})}}(e,t,i,o),i}function Lx(e,t,n,i){if(i.trend){const{fit:e,sample:o}=i.trend,a=Number(o["x"===t?"y":"x"]);if(!Number.isFinite(a))return null;const r=String(e.label),s=e.row||{};return{id:n,name:r,value:a,color:i.color,shape:"Line",datum:s,index:0,projected:{lci:o.lci,hci:o.hci}}}const o="x"===t?e._y:e._x,a=i.wrapped.data||i.wrapped,r="number"==typeof i.wrapped.i?i.wrapped.i:0,s=o?Number(o(a,r)):NaN;if(!Number.isFinite(s)||!e.schema.tooltip(a,r))return null;return{id:n,name:String(e._drawLabel(a,r)),value:s,color:i.color,shape:i.shape,datum:a,index:r}}function Px(e,t,n){let i=null;for(const o of e.values())(void 0===n||o.members.has(n))&&(!i||Math.abs(o.px-t)<Math.abs(i.px-t))&&(i=o);return i}const Rx=e=>!(!e||!e.shapeType||!e.datum||e.interactionGroup||!1===e.interactive);function Ex(e,t){const n=t?.datum?.data;if(!n||Rx(t))return;let i;const o=e=>{i||(Rx(e)&&e.datum===n?i=e:e.children&&e.children.forEach(e=>o(e)))};return(e._chartScene||[]).forEach(e=>o(e)),i}function Nx(e,t,n,i){const o=e.schema.discrete;if("x"!==o&&"y"!==o)return null;const a=o,r="x"===a?n[0]:n[1],s={bars:new Set,area:!1,box:!1},c=Bx(e,a,s);if(s.box)return null;const l=s.area?"front":"back",h=t.pick?t.pick.node:void 0,u=Ex(e,h)??h,d=Rx(u)&&"Box"!==u.shapeType,f=(t,n,i,o)=>{const r=t?.members.get(n)??(o?{wrapped:o,color:Hr(e,u),shape:u?.shapeType}:void 0),s=r?Lx(e,a,n,r):null;if(!s||!Number.isFinite(i))return null;const c=t?t.markers.filter(e=>String(e.datum.id)===n):[],h=t?t.value:r.wrapped[a];return{mode:"single",axis:a,px:i,value:h,rows:[s],markers:c,layer:l}};if(i&&e.schema.tooltipShared){const t=Px(c,r);if(t){const n=[];if(t.members.forEach((t,i)=>{const o=Lx(e,a,i,t);o&&n.push(o)}),n.length>=2||n.some(e=>e.projected)){!function(e,t,n){const i="x"===t?e._yFunc:e._xFunc,o=e=>{const n=i?i(e):NaN;return Number.isFinite(n)?"x"===t?n:-n:-e};n.sort((e,t)=>o(e.value)-o(t.value))}(e,a,n);const i=t.bars.size?{rows:t.bars,bars:s.bars}:void 0;return{mode:"shared",axis:a,px:t.px,value:t.value,rows:n,markers:t.markers,layer:l,stack:i}}if(1===n.length&&!d)return f(t,n[0].id,t.px)}}if(!d)return null;const m=u.datum,p=String(m.id);if(u.interactionPoints){const e=Px(c,r,p);return e?f(e,p,e.px):null}return f(null,p,function(e,t){const n=e,i=n.transform?.[t]??0;return"rect"===n.type?i+(n[t]??0)+(("x"===t?n.width:n.height)??0)/2:"circle"===n.type?i+(("x"===t?n.cx:n.cy)??0):NaN}(jr(e,u)??u,a),m)}function Tx(e,t){let n=null;const i=e._plotArea;if("mousemove"===t.type||"mouseenter"===t.type){if(e._transitionEndsAt&&Date.now()<e._transitionEndsAt)return;const o=t.pick&&t.pick.node;if(o&&o.trendFit)return void function(e,t,n){const i=e._sharedHoverState;e._sharedHoverActive=!0,e._sharedHoverState=null;const o=Array.isArray(n.point)?zx(e,n.point):void 0;Ax(e,t,n,o),i&&("shared"===i.mode&&"function"==typeof e._hover&&e.hover(!1),e._scheduleSceneRepaint())}(e,o.trendFit,t);if(i&&Array.isArray(t.point)&&(!o||"legend"!==o.interactionGroup)){const[o,a]=zx(e,t.point);n=Nx(e,t,[o,a],o>=i.x&&o<=i.x+i.width&&a>=i.y&&a<=i.y+i.height)}}else if("mouseleave"!==t.type||t.nativeEvent&&"mouseleave"!==t.nativeEvent.type)return;const o=e._sharedHoverState;if(n){e._sharedHoverActive=!0;const{mode:i,axis:a,px:r,value:s,markers:c,layer:l}=n,h=Mc(e,t.point)?.key;e._sharedHoverState={mode:i,axis:a,px:r,value:s,markers:c,layer:l,panel:h},"shared"===i?$g(e,n,t):function(e,t,n){const i=t.rows[0],o=e._drawDepth<e.schema.groupBy.length-1,a=Cg(e).data([i.datum]).title(()=>e._drawLabel(i.datum,i.index)).footer(!(!o||!e.schema.on["click.shape"])&&e.schema.translate("Click to Expand")).config(Ae.bind(e)(e.schema.tooltipConfig)),r=a.tbody(),s="function"==typeof r?r(i.datum,i.index):r;Ur(a,Er(i.color,i.shape)).tbody([...!1===e._tooltipAxisRows?[]:[wg(e,"x",t),wg(e,"y",t)],...i.projected?[]:gg(e,i.datum,i.index,n=>vg(e,_g(t.axis),n)),...Array.isArray(s)?s:[],...Br(e,i.datum)]).arrow(!1).position(Sg(e,t,n)).render()}(e,n,t),o&&o.px===r&&o.mode===i&&o.panel===h||(!function(e,t,n){const i=t.stack,o=()=>{"function"==typeof e._hover&&e.hover(!1)},a=e._plotColumnHighlight;if(a&&1===e.schema.shapeConfig.hoverOpacity)o();else if(a){const n=new Set(t.rows.map(e=>e.datum));ht(e,e=>n.has(e)),e.hover(a(n))}else"single"===t.mode?"shared"===n&&o():i?(ht(e,e=>i.rows.has(e)),e.hover(e=>i.rows.has(e)||!i.bars.has(e))):o()}(e,n,o?.mode),e._scheduleSceneRepaint())}else e._sharedHoverActive&&(e._sharedHoverActive=!1,e._sharedHoverState=null,e._tooltipClass.data([]).render(),function(e){const t=e._sharedTooltipSaved;t&&e._tooltipClass.arrow(t.arrow).thead(t.thead).tbody(t.tbody),e._sharedTooltipSaved=void 0}(e),"function"==typeof e._hover&&e.hover(!1),e._scheduleSceneRepaint())}const Ox=/::(hit|stem|confidence)$/;function Wx(e,t){return Math.abs(e)>=Math.abs(e+t)?e:e+t}function jx(e,t,n){return Number.isFinite(t)?{...e,[n]:t,span:[e[n],t]}:e}function Hx(e,t,n){const i=e,o=i.datum;if(!o||"string"==typeof i.key&&Ox.test(i.key))return[];const a=i.shapeType;if(i.interactionPoints)return i.interactionPoints.map(e=>({x:e.x,y:e.y,datum:e.datum,color:n,shape:a}));const r=i.transform?.x??0,s=i.transform?.y??0;if("circle"===i.type)return[{x:r+(i.cx??0),y:s+(i.cy??0),datum:o,color:n,shape:a}];if("rect"!==i.type)return[];const c=i.x??0,l=i.y??0,h=i.width??0,u=i.height??0;if("Bar"!==a)return[{x:r+c+h/2,y:s+l+u/2,datum:o,color:n,shape:a}];if("x"===t){const e=r+Wx(c,h);return[{x:e,y:s+l+u/2,datum:o,color:n,shape:a,span:[r,e]}]}const d=s+Wx(l,u);return[{x:r+c+h/2,y:d,datum:o,color:n,shape:a,span:[s,d]}]}function Ix(e){return!(!e||!e.shapeType||!e.datum||"Box"===e.shapeType||e.interactionGroup||!1===e.interactive||e.datum.__d3plusShape__)}function Gx(e,t,n){let i=null,o=1/0;for(const a of e){const e=a.span,r=e&&n>=Math.min(e[0],e[1])&&n<=Math.max(e[0],e[1])?0:Math.abs(a[t]-n);r<o&&(o=r,i=a)}return i}const Vx=(e,t,n)=>e(t,n);function qx(e,t,n,i){return Number.isFinite(t)&&Math.abs(t-n)<=1?e:i?i(n):e}function Yx(e,t){if(null==t)return"";if("number"==typeof t&&!Number.isFinite(t))return"";return`${(e?e(t):`${t}`)??""}`.replace(/<[^>]*>/g,"").trim()}function Kx(e,t,n,i){const o=e[`_${t}Axis`]?._d3Scale;if(!o||"function"!=typeof o.invert)return;const a=Vx(n,i,t)-o(i);return Number.isFinite(a)?e=>o.invert(e-a):void 0}function Ux(e,t,n){if("Area"!==t.shape)return t;const i=void 0!==t.datum[`${n}2`]?`${n}2`:n,o="x"===n?e._xFunc:e._yFunc,a=Number(t.datum[i]);if(!o||!Number.isFinite(a))return t;if(!e.schema.stacked)return jx(t,Vx(o,a,i),n);const r=Kx(e,i,o,a),s=r?Number(r(t[n])):NaN;return Number.isFinite(s)?jx(t,Vx(o,s+a,i),n):t}function Xx(e){const t=e.schema.discrete;return"x"===t||"y"===t?t:void 0}function Qx(e,t,n){const i=Xx(e),o=t.pick?t.pick.node:void 0,a=jr(e,Ex(e,o)??o),r=Ix(a);if(i){const t=e._sharedHoverState;if(!t)return r?function(e,t,n,i){const o="x"===n?"y":"x",a=Hx(t,o,Hr(e,t));return a.length&&void 0!==a[0].datum[`${o}2`]?Gx(a.map(t=>Ux(e,t,o)),n,i["x"===n?0:1]):null}(e,a,i,n):null;const o="single"===t.mode&&r?String(a.datum.id):void 0,s="x"===i?"y":"x",c=function(e){const t="y"===e.schema.discrete?"x":"y",n=[],i=o=>{o.interactionGroup||!1===o.interactive||(o.children&&o.children.forEach(e=>i(e)),Ix(o)&&n.push(...Hx(o,t,Hr(e,o))))};return(e._chartScene||[]).forEach(e=>i(e)),n}(e).map(t=>Ux(e,t,s)).filter(e=>Math.abs(e[i]-t.px)<=1&&(void 0===o||String(e.datum.id)===o)),l="x"===i?"y":"x";return Gx(c,l,n["x"===l?0:1])}if(!r)return null;return function(e,t){let n=null,i=1/0;for(const o of e){const e=Math.hypot(o.x-t[0],o.y-t[1]);e<i&&(i=e,n=o)}return n}(Hx(a,"y",Hr(e,a)).map(t=>Ux(e,t,"y")),n)}const Zx=e=>e?JSON.stringify([e.point,e.color,e.panel,e.badges]):"";function Jx(e,t){let n=null;if("mousemove"===t.type||"mouseenter"===t.type){if(e._transitionEndsAt&&Date.now()<e._transitionEndsAt)return;const i=t.pick?.node;if(!1!==e.schema.axisHover&&e._plotArea&&Array.isArray(t.point)&&(!i||"legend"!==i.interactionGroup)&&(n=function(e,t,n){const i=Qx(e,t,n);if(!i||!function(e,t){const n=e._plotArea;return!!n&&t.x>=n.x-1&&t.x<=n.x+n.width+1&&t.y>=n.y-1&&t.y<=n.y+n.height+1}(e,i))return null;const o=Xx(e),a=o?e._sharedHoverState:null,r=e.schema.axisHover,s=function(e,t){const n=[];for(const i of["x","y"])t.bar&&i===(t.discrete??"x")||t.cross!==i&&(t.only&&t.only!==i||n.push(void 0!==e[`${i}2`]?`${i}2`:i));return n}(i.datum,{discrete:o,bar:"Bar"===i.shape,cross:e._swarm?.cross,only:"x"===r||"y"===r?r:void 0}),c=[];for(const t of s){const n=t.charAt(0),r=!!a&&n===o,s=r?a.px:i[n],l="x"===n?e._xFunc:e._yFunc,h=r?a.value:i.datum[t],u=Yx(n=>vg(e,t,n),r||!l?h:qx(h,Vx(l,h,t),s,Kx(e,t,l,h)));u&&c.push({axis:t,at:s,text:u,guide:!r})}if(!c.length)return null;const l=i.datum.data||i.datum;return{point:{x:i.x,y:i.y},color:i.color,datum:l,index:"number"==typeof i.datum.i?i.datum.i:0,badges:c}}(e,t,zx(e,t.point)),n)){const i=Mc(e,t.point)?.key;void 0!==i&&(n.panel=i)}}else if("mouseleave"!==t.type)return;const i=e._axisHoverState;Zx(i)!==Zx(n)&&(e._axisHoverState=n,e._scheduleSceneRepaint())}function eb(e){const t=e;return t.interactive=!1,t.interactionGroup="axis",t.children&&t.children.forEach(eb),e}const tb=e=>{const t=e,n=t.datum;return!!t.shapeType&&!t.interactionGroup&&!1!==t.interactive&&!!n&&void 0!==n.id};function nb(e,t,n,i){const o=[...e];if(t.length){const e=o.findIndex(e=>tb(e)||Ly(e)&&e.children.some(tb));"back"===i&&e>=0?o.splice(e,0,...t):o.push(...t)}return o.push(...n),o}function ib(e,t,n,i){const o=e._plotArea;if(!o)return t;const{state:a,axis:r}=n,s="x"===e.schema.discrete||"y"===e.schema.discrete,c=s&&e.schema.tooltipShared&&function(e){const t=n=>!n.interactionGroup&&!1!==n.interactive&&(!!Fx(e,n)||!!n.children&&n.children.some(e=>t(e)));return(e._chartScene||[]).some(e=>t(e))}(e)?[{type:"rect",key:i("plot-hover-surface"),...o,interactionGroup:"axis",paint:{fill:"transparent"}}]:[];let l=t;const h=a&&s?function(e,t){const n=()=>t.px,i="x"===t.axis?n:e._xFunc,o="y"===t.axis?n:e._yFunc,a=e._plotAxisDomains?.x,r=e._plotAxisDomains?.y;if(!(i&&o&&a?.length&&r?.length))return null;const s="x"===t.axis?r:a,c=Ry(Ey(e,{shape:"Line",data:[s[0],s[s.length-1]].map(e=>"x"===t.axis?{x:t.value,y:e}:{x:e,y:t.value}),id:()=>"crosshair",...e._crosshairConfig},i,o,{x:a,y:r},0),"plot-crosshair");return c?eb(c):null}(e,a):null,u=r?Hf(e,r):null,d=bd([...h?[h]:[],...u?u.guides:[]],i),f=bd(a&&s?function(e,t){if(e._lineMarkers||!t.markers.length)return[];const n=new Map(t.markers.map(e=>[e.datum,e])),i=eu("Circle").renderMode("compute").data(t.markers.map(e=>e.datum)).config(e._lineMarkerConfig).x(e=>n.get(e).x).y(e=>n.get(e).y).id(e=>`${e.id}_shared`);return i.render(),[{type:"group",key:"plot-shared-markers",children:su(i)}].map(eb)}(e,a):[],i);if(d.length||f.length){const e=a?a.layer:"back",t=l.findIndex(e=>e.key===i(bx));if(t>=0){const n=l[t];l=[...l],l[t]={...n,children:nb(n.children||[],d,f,e)}}else l=nb(l,d,f,e)}const m=u?bd(u.badges,i):[];return[...c,...l,...m]}function ob(e,t){const n=e.schema.discrete;if("x"!==n&&"y"!==n&&!e._axisHoverState)return;const i=t.root.children.find(e=>"viz-chart-cells"===e.key),o=i&&i.children&&i.children[0],a=o&&o.children&&o.children[0];if(!a||!a.children)return;const r=e._facetPanels;a.children=r?a.children.map(t=>{const n=r.find(e=>e.key===t.key);return n?function(e,t,n){const i=t.children||[],o=i.findIndex(e=>e.key===`${n.key}/cells`),a=i[o],r=a&&a.children&&a.children[0];if(!a||!r||!r.children)return t;const s=e._sharedHoverState,c=e._axisHoverState,l=$c(e,n,()=>ib(e,r.children,{state:s&&s.panel===n.key?s:null,axis:c&&c.panel===n.key?c:null},e=>`${n.key}/${e}`)),h=[...i];return h[o]={...a,children:[{...r,children:l},...a.children.slice(1)]},{...t,children:h}}(e,t,n):t}):ib(e,a.children,{state:e._sharedHoverState,axis:e._axisHoverState},e=>e)}const ab=/^plot-(x|x2|y|y2)-axis$/;function rb(e,t){if(e.schema[`${t}Sort`])return!0;if(Sm(e,t))return!1;const n=e[`_${t}Time`];return e.schema.discrete===t.charAt(0)&&!n}function sb(e){let t,n;for(const i of e)for(const e of i)null==e||Number.isNaN(+e)||((void 0===t||+e<+t)&&(t=e),(void 0===n||+e>+n)&&(n=e));return void 0===t||void 0===n?void 0:[t,n]}function cb(e,t){const n=t.filter(e=>e.length).map(t=>function(e,t){e._filteredData=t;const n=ne({viz:e},[sg,cg,Yp,Up]);return{formatted:n.plotFormattedData||[],domains:n.plotInitialDomains||{}}}(e,t)),i=n.flatMap(e=>e.formatted),o=ne({viz:e,plotFormattedData:i,plotAxisData:i},[cg]),a={};for(const t of Qm)if(n.some(e=>e.domains[t]))if(rb(e,t)){const e=o[`${t}Data`];e&&e.length&&(a[t]=e)}else{const e=sb(n.map(e=>e.domains[t]||[]));e&&(a[t]=e)}const r=e._size?i.map(t=>e._size(t.data)):[],s=r.length?og(e,r):void 0;return{domains:a,size:s,padded:lb(e,i,a,s)}}function lb(e,t,n,i){const o=e._sizeScaleD3;i&&(e._sizeScaleD3=i);const a=ne({viz:e,plotFormattedData:t,plotAxisData:t,plotInitialDomains:{...n}},[mp,lg]);e._sizeScaleD3=o;const r={},s=a.plotScales;if(!s)return r;for(const e of Qm){const t=s[e];t&&"function"==typeof t.invert&&(r[e]=t.domain())}return r}function hb(e,t){const n=e||{};return{...n,labels:t?n.labels:[],title:!!t&&n.title}}function ub(e,t){e&&e.config({labels:t?.labels,title:t?.title})}function db(e,t){const n={scales:e._plotFacetScales,x:e._xConfig,y:e._yConfig};return e._plotFacetScales=t.shared?t.scales:void 0,e._xConfig=hb(n.x,t.labels.x),e._yConfig=hb(n.y,t.labels.y),()=>{e._plotFacetScales=n.scales,e._xConfig=n.x,e._yConfig=n.y,ub(e._xAxis,n.x),ub(e._yAxis,n.y)}}function fb(e){const t=e._plotArea,n=e._chartTransform;if(!t||!n)return{top:0,right:0,bottom:0,left:0};const i=t.x+(n.x??0),o=t.y+(n.y??0);return{top:o-e._margin.top,right:e.schema.width-e._margin.right-(i+t.width),bottom:e.schema.height-e._margin.bottom-(o+t.height),left:i-e._margin.left}}const mb={aspect:4/3,share:cb,panel:db,insets:fb,capture:e=>({_plotArea:e._plotArea,_plotAxisDomains:e._plotAxisDomains,_xFunc:e._xFunc,_yFunc:e._yFunc,_trendFits:e._trendFits,_barSpans:e._barSpans})},pb=e=>Array.isArray(e)?e.map(pb).join(""):e instanceof Date?+e:e;function gb(e,t){const{aggs:n,id:i,position:a,threshold:r,value:s}=t,c=Math.min(1,Math.max(0,+r(e)));if(!(c>0))return null;const l=new Map,h=new Map;let u=0;if(e.forEach((e,t)=>{const n=`${i(e,t)}`,o=Math.abs(+s(e,t))||0;l.set(n,(l.get(n)??0)+o);const a=h.get(n);a?a.push(e):h.set(n,[e]),u+=o}),!(u>0))return null;const d=new Set;if(l.forEach((e,t)=>{e<c*u&&d.add(t)}),d.size<2)return null;const f=function(e,t,n){const i=new Set;e.forEach(e=>e.forEach(e=>Object.keys(e).forEach(e=>i.add(e))));const a=Array.from(i).filter(n=>e.every(e=>{let i;return e.every((e,o)=>{const a=e[n];if("number"==typeof a)return!1;const r=pb(a);return!t.some(t=>pb(t(e,o))===r)&&(0===o&&(i=r),r===i)})})),r=e.filter(e=>e.length).map(e=>{const t={};for(const n of a)t[n]=e[0][n];return t});return o.merge(r,n)}(Array.from(d,e=>h.get(e)),a,n);return{members:d,percent:c,identity:f}}function yb(e,t,n){const{aggs:i,id:a,position:r}=n,s=n.label??a,c=n.measure??n.value,l=[],h=new Map;if(e.forEach((e,n)=>{if(!t.members.has(`${a(e,n)}`))return void l.push(e);const i=r.map(t=>`${pb(t(e,n))}`).join(""),o=h.get(i);o?o.push(e):h.set(i,[e])}),!h.size)return e;const u=Array.from(h.values(),e=>{const n=o.merge(e,i),l=e[0],h=r.map(e=>pb(e(l,0)));for(const t of Object.keys(l))h.some(n=>e.every(e=>pb(e[t])===n))&&(n[t]=l[t]);return{...n,...t.identity,_isAggregation:!0,_threshold:t.percent,[zr]:Dr(e,a,s,c)}});return l.concat(u)}function xb(e){const t="y"===e.schema.discrete?"y":"x",n="x"===t?"y":"x",i=[e[`_${t}`]];return e.schema.time&&i.push(e.schema.time),{aggs:e.schema.aggs,id:e._id,label:e._drawLabel,measure:e[`_${n}`],position:i,threshold:e.schema.threshold,value:e.schema.thresholdKey??e[`_${n}`]}}function bb(e){const t=e?.domain;return Array.isArray(t)?{...e,domain:t.slice().reverse()}:e}class _b extends yf{_preDraw(){["x","y","x2","y2"].forEach(e=>{if(this[`_${e}Key`]){const t=this[`_${e}Key`];this.schema.aggs[t]||this.schema.discrete!==e||(this.schema.aggs[t]=(e,t)=>{const n=Array.from(new Set(e.map(t)));return 1===n.length?n[0]:n}),t!==e&&this[`_${e}Title`]===this[`_${e}Config`].title&&this.schema.discrete!==e&&(this[`_${e}Title`]=t,this[`_${e}Config`].title=t)}}),super._preDraw()}_thresholdLegend(e){return function(e,t){if(!e.schema.stacked||!t.length)return t;const n=xb(e),i=gb(t,n);return i?yb(t,i,{...n,position:[]}):t}(this,e)}_thresholdFunction(e,t,n){return function(e,t,n=t){if(!e.schema.stacked)return t;const i=xb(e),o=gb(n,i);return o?yb(t,o,i):t}(this,e,n)}toScene(){const e=yf.prototype.toScene.call(this);if(Array.isArray(this._filteredData)&&0===this._filteredData.length&&(!this._annotations||0===this._annotations.length))return e;const t=[];for(const e of["_xAxis","_x2Axis","_yAxis","_y2Axis"]){const n=this[e];n&&"function"==typeof n.toScene&&n._select&&"function"==typeof n._select.node&&n._select.node()&&t.push({type:"group",key:`plot-${e}`,children:[n.toScene()]})}return e.root.children.unshift(...t),ob(this,e),e}_wirePlotShapeEvents(e,t,n){const i=n.filter(e=>e.includes(`.${t}`)),o=n.filter(e=>!e.includes(".")),a=n.filter(e=>e.includes(".shape")),r=e=>(t,n,i,o)=>this.schema.on[e](t.data,t.i,i,o);for(const t of o)e.on(t,r(t));for(const t of a)e.on(t,r(t));for(const t of i)e.on(t,r(t))}_interactionDatum(e,t){const n=e.node,i=n&&n.interactionPoints;if(n&&"legend"!==n.interactionGroup&&Array.isArray(i)&&i.length&&t&&Array.isArray(t.point)){const e=this._nearestInteractionPoint(i,t.point);if(e){const t=e.datum;return{d:t&&t.data?t.data:t,i:"number"==typeof t.i?t.i:e.index,x:t}}}return super._interactionDatum(e,t)}_nearestInteractionPoint(e,t){const[n,i]=zx(this,t),o="y"===this.schema.discrete?"y":"x",a="y"===o?i:n;let r=null,s=1/0;for(const t of e){const e=Math.abs(t[o]-a);e<s&&(s=e,r=t)}return r}_sharedHover(e){Tx(this,e),Jx(this,e)}_draw(e){return ay(this,e)}_facetHooks(){return mb}_sizeLegendScale(){return function(e){if(!e._size)return null;const t=e._axisPersist?e._data:e._filteredData||[],n=[];let i=!1;return t.forEach((t,o)=>{ig(e._x(t,o))||ig(e._y(t,o))||(n.push(e._size(t,o)),ag(e,e.schema.shape(t,o))&&(i=!0))}),i?og(e,n):null}(this)}_insetRegion(){return function(e){const t=e._plotArea,n=e._chartTransform;return t&&n?Uu(e,{x:t.x+(n.x??0),y:t.y+(n.y??0),width:t.width,height:t.height},e=>ab.test(String(e.key))):null}(this)}_paint(e){const t=this,n=t._zoomEventTarget||t._container;return this._chartScene=vx(t,e,n&&n.node()?b.zoomTransform(n.node()):void 0),this}_zoomRescale(e,t=0){if(this._facetPanels)return!1;const n=function(e,t,n){clearTimeout(e._plotUnclipTimer);const i=e._chartScene?.find(e=>e.key===bx),o="group"===i?.type&&!!i.clip&&n>0&&1===t.k&&!t.x&&!t.y,a=wx(e,t,o);return a&&o&&(e._plotUnclipTimer=setTimeout(()=>{const n=wx(e,t);n&&(e._chartScene=n,e._drawSceneToTarget(0))},n)),a}(this,e,t);return!!n&&(this._chartScene=n,!0)}annotations(e){return arguments.length?(this._annotations=e instanceof Array?e:[e],this):this._annotations}axisPersist(e){return arguments.length?(this._axisPersist=e,this):this._axisPersist}baseline(e){return arguments.length?(function(e,t){e._userBaseline=t===O||void 0===t?void 0:t}(this,e),this):(t=this)._userBaseline??t.schema.baseline;var t}backgroundConfig(e){return arguments.length?(this._backgroundConfig=Y(this,"backgroundConfig",e,this._backgroundConfig),this):this._backgroundConfig}buffer(e){if(arguments.length){if(e)if(!0===e)this._buffer=Nf;else{this._buffer=n.assign({},this._buffer,e);for(const e in this._buffer){const t=this._buffer;!0===t[e]&&(t[e]=Nf[e])}}else this._buffer={};return this}return this._buffer}confidence(e){if(!arguments.length)return this._confidenceBands&&this._confidenceBands.length>1?this._confidenceBands:this._confidence;const t=this._confidenceBands=Fm(e);return this._confidence=!!t.length&&[t[0].lower,t[0].upper],this}confidenceConfig(e){return arguments.length?(t=this.constructor.name,(n=e)&&"object"==typeof n&&Object.getPrototypeOf(n)===Object.prototype&&Fa(t,n,$m),this._confidenceConfig=Y(this,"confidenceConfig",e,this._confidenceConfig),this):this._confidenceConfig;var t,n}discreteCutoff(e){return arguments.length?(this._discreteCutoff=e,this):this._discreteCutoff}groupPadding(e){return arguments.length?(this._groupPadding=e,this):this._groupPadding}labelConnectorConfig(e){return arguments.length?(this._labelConnectorConfig=Y(this,"labelConnectorConfig",e,this._labelConnectorConfig),this):this._labelConnectorConfig}labelPosition(e){return arguments.length?(this._labelPosition="function"==typeof e?e:N(e),this):this._labelPosition}crosshairConfig(e){return arguments.length?(this._crosshairConfig=Y(this,"crosshairConfig",e,this._crosshairConfig),this):this._crosshairConfig}trendLine(e){return arguments.length?(this._trendLine=e,this):this._trendLine}trendLineConfig(e){return arguments.length?(this._trendLineConfig=Y(this,"trendLineConfig",e,this._trendLineConfig),this):this._trendLineConfig}lineMarkerConfig(e){return arguments.length?(this._lineMarkerConfig=Y(this,"lineMarkerConfig",e,this._lineMarkerConfig),this):this._lineMarkerConfig}lineMarkers(e){return arguments.length?(this._lineMarkers=e,this):this._lineMarkers}size(e){return arguments.length?(this._size="function"!=typeof e&&e?Be(e):e,this._sizeKey="string"==typeof e?e:void 0,this):this._size}stackOffset(e){return arguments.length?(this._stackOffset=Ep(e),this):this._stackOffset}stackOrder(e){return arguments.length?(this._stackOrder=Bp(e),this):this._stackOrder}x(e){return arguments.length?("function"==typeof e?this._x=e:(this._x=Be(e),this._xKey=e),this):this._x}x2(e){return arguments.length?("function"==typeof e?this._x2=e:(this._x2=Be(e),this._x2Key=e),this):this._x2}xConfig(e){return arguments.length?(this._xConfig=Y(this,"xConfig",e,this._xConfig),this):this._xConfig}x2Config(e){return arguments.length?(this._x2Config=Y(this,"x2Config",e,this._x2Config),this):this._x2Config}y(e){return arguments.length?("function"==typeof e?this._y=e:(this._y=Be(e),this._yKey=e),this):this._y}y2(e){return arguments.length?("function"==typeof e?this._y2=e:(this._y2=Be(e),this._y2Key=e),this):this._y2}yConfig(e){return arguments.length?(this._yConfig=Y(this,"yConfig",bb(e),this._yConfig),this):this._yConfig}y2Config(e){return arguments.length?(this._y2Config=Y(this,"y2Config",bb(e),this._y2Config),this):this._y2Config}constructor(){var e;super(),this._trendLine=hg.defaults.trendLine,this._trendLineConfig={confidence:!1,confidenceConfig:{fillOpacity:.15},confidenceLevel:.95,group:"series",order:2,projection:0,projectionConfig:{strokeDasharray:"2 4"},strokeDasharray:"6 4",strokeWidth:2,tooltip:!0},ee(this,Bg),Lg(this),(e=this)._x=T("x"),e._xKey="x",e._xAxis=(new ui).align("end"),e._xConfig={gridConfig:{stroke:t=>{if("x"===e.schema.discrete?.charAt(0)||"x"===e._swarm?.cross)return"transparent";const n=e._xAxis.range(),i=e._xAxis._getPosition.bind(e._xAxis)(t.id);return n[0]===i?"transparent":Zn(e._select?.node(),e.schema.colorDefaults)}}},e.schema.xCutoff=150,e._x2=T("x2"),e._x2Key="x2",e._x2Axis=(new mi).align("start"),e._x2Config={},e._y=T("y"),e._yKey="y",e._yAxis=(new di).align("start"),e._yKey="y",e._yConfig={gridConfig:{stroke:t=>{if("y"===e.schema.discrete?.charAt(0)||"y"===e._swarm?.cross)return"transparent";const n=e._yAxis.range(),i=e._yAxis._getPosition.bind(e._yAxis)(t.id);return n[n.length-1]===i?"transparent":Zn(e._select?.node(),e.schema.colorDefaults)}}},e.schema.yCutoff=150,e._y2=T("y2"),e._y2Key="y2",e._y2Axis=(new fi).align("end"),e._y2Config={}}}K(_b.prototype,"backgroundConfig","baseline","confidenceConfig","crosshairConfig","labelConnectorConfig","lineMarkerConfig","trendLineConfig","xConfig","x2Config","yConfig","y2Config");var kb=xf({name:"AreaPlot",paintDriven:!0,ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:N("Area"),coerce:"const"}]},_b);function vb(e){const t=[()=>e.schema.translate("Share"),(t,n,i)=>{const o=Mr(i);let a=Sr(o);if(!Number.isFinite(a)){const t=e["_"+("y"===e.schema.discrete?"x":"y")];a=o?$r(o,e._legendData||[],t):NaN}return Number.isFinite(a)?`${d.formatAbbreviate(100*a,e.schema.locale)}%`:""}];return{tbody:()=>e.schema.stacked?[t]:[]}}const wb={name:"BarChart",paintDriven:!0,ctx:{},fields:[{key:"barWidth",coerce:fm},{key:"barWidthShare",default:!1},{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:N("Bar"),coerce:"const"},{key:"tooltipConfig",merge:!0,factory:function(e){const t=vb(e);return{tbody:n=>[...wm(e,n),...t.tbody()]}}},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>{if(e._legendCategories)return t.call(e,n,i);return i.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()!==e._filteredData.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()&&t.call(e,n,i)}}}]};var Sb=xf(wb,_b);const Cb={name:"Beeswarm",paintDriven:!0,ctx:{},fields:[{key:"shapeConfig",merge:!0,default:{Circle:{label:!1,trail:!1}}},{key:"swarm",default:!0}]};var Mb=xf(Cb,_b);const $b=new WeakMap;function Ab(e,t){for(;e.__d3plus__&&e.data;)t=e.i,e=e.data;return[e,t]}function zb(e){const t=e.schema.shapeConfig||{},n=(t.Box||{}).whiskerMode??t.whiskerMode;return void 0===n?["tukey","tukey"]:Zo(n)}function Db(e,t,n){if(!t)return[];const i=t=>void 0===t?"":d.formatAbbreviate(t,e.schema.locale),o=t=>e.schema.translate(t),[a,r]=Ab(t,n);if(ca(e.schema)){const t=fa(e.schema,a,r);return t?[[o("Maximum"),i(t.max)],[o("Upper Quartile"),i(t.q3)],[o("Median"),i(t.median)],[o("Lower Quartile"),i(t.q1)],[o("Minimum"),i(t.min)]]:[]}const s=function(e,t){const n=$b.get(t);if(!n)return null;const i="vertical"===n.orient,o=n.values.map(e=>{const t=i?e.y2??e.y:e.x2??e.x;return"number"==typeof t||t instanceof Date?+t:NaN}).filter(Number.isFinite).sort((e,t)=>e-t);return o.length?Jo(o,zb(e)):null}(e,a);if(!s)return[];const c=zb(e);return[["extent"===c[1]?"Maximum":"Upper Whisker",s.upperLimit],["Upper Quartile",s.third],["Median",s.median],["Lower Quartile",s.first],["extent"===c[0]?"Minimum":"Lower Whisker",s.lowerLimit]].filter(([,e])=>void 0!==e).map(([e,t])=>[o(e),i(t)])}const Fb=e=>"y"===e.schema.discrete?"x":"y";function Bb(e){const t=au(e,"Box").outlier;return"function"==typeof t?t:void 0===t||Qo(t)?null:()=>t}const Lb=(e,t)=>{const n=e[t];return"number"==typeof n||n instanceof Date?+n:NaN};function Pb(e,t,n){if(ca(e.schema)||n.charAt(0)!==Fb(e))return t;const i=Bb(e);return i?function(e,t){const n=e.schema.discrete,i="function"==typeof e.schema.facet?e.schema.facet:void 0;return h.groups(t,e=>i?`${e[n]}\0${i(e.data,e.i)}`:`${e[n]}`).map(([,e])=>e)}(e,t).flatMap(t=>function(e,t,n,i){const o=t.map(e=>Lb(e,n)).filter(Number.isFinite).sort((e,t)=>e-t);if(!o.length)return t;const{lowerLimit:a,upperLimit:r}=Jo(o,zb(e)),s=t.filter(e=>{const t=Lb(e,n);return!(t<a||t>r)||Qo(i(e,e.i))});if(s.length===t.length)return t;const c=t[0][n]instanceof Date,l=[a,r].filter(e=>Number.isFinite(e)).map(e=>({...t[0],[n]:c?new Date(e):e}));return s.concat(l)}(e,t,n,i)):t}const Rb=e=>ca(e.schema);function Eb(e){const t=function(e){const t=Bb(e);return e=>!t||Qo(t(e,e.i))}(e);return n=>function(e,t,n,i=!0){const o=[];for(const i of ra){const a=e[i],r="function"==typeof a?ua(a(t,n)):NaN;ha(r)&&o.push(r)}return i?o.concat(da(e,t,n)):o}(e.schema,n.data,n.i,t(n))}function Nb(e){const t=Lf,n=this,i=Fb(this);if(!Rb(this)){const o=Pb(this,e.data,e.x2?`${i}2`:i);return t.call(n,{...e,data:o})}if(e.x2)return t.call(n,e);const o=Eb(this),a=e.data.flatMap(e=>o(e).map(t=>({...e,[i]:t})));return t.call(n,{...e,data:a})}function Tb(e,t){const n=e=>"number"==typeof e||e instanceof Date?t(e):NaN;return t=>{const i=e(t.data,t.i);return Array.isArray(i)?i.map(n):n(i)}}const Ob=(e,t)=>{const{viz:n}=e;if(!Rb(n))return function(e){const t=e=>{for(const n of e){"group"===n.type&&t(n.children);for(const e of n.owners||[])"Box"===e.shapeType&&e.datum&&$b.set(Ab(e.datum,e.index)[0],e.datum)}};return t(e),e}(cx(e,t));const i="y"===Fb(n)?e.y:e.x,o={};for(const e of[...ra,"boxOutliers"]){const t=n.schema[e];"function"==typeof t&&(o[e]=Tb(t,i))}return cx({...e,shapeConfig:{...e.shapeConfig,...o}},t)};var Wb=xf({name:"BoxWhisker",paintDriven:!0,setup:e=>{e._buffer={...e._buffer,Box:Nb},e._plotShapeEmitters={Box:Ob},e._plotAxisValues=(t,n)=>function(e,t,n){return Rb(e)&&n===Fb(e)?t.flatMap(Eb(e)):[]}(e,t,n),e._plotAxisRows=(t,n)=>Pb(e,t,n)},ctx:{},fields:[{key:"boxMax",coerce:sa},{key:"boxMedian",coerce:sa},{key:"boxMin",coerce:sa},{key:"boxOutliers",coerce:sa},{key:"boxQ1",coerce:sa},{key:"boxQ3",coerce:sa},{key:"discrete",default:"x"},{key:"shape",default:N("Box"),coerce:"const"},{key:"tooltipShared",default:!1},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,n)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)n=(t=t.data).i;const i=e.schema.label;if(i)return i(t,n);const o=e._drawDepth+(Rb(e)?1:0),a=e._ids(t,n).slice(0,o);return a[a.length-1]},tbody:(t,n)=>Db(e,t,n)})}]},_b);const jb=e=>e*Math.PI/180,Hb=e=>180*e/Math.PI;function Ib(e,t,n,i){const[o,a]=t,r=a-o,s=Number.isFinite(e)&&r?(e-o)/r:0;return n+Math.max(0,Math.min(1,s))*(i-n)}function Gb(e,t=[],n=void 0,i=10){const o=[0,...e,...t.flatMap(e=>[e.min,e.max])].filter(e=>"number"==typeof e&&Number.isFinite(e)),[a,r]=n??[],c=Number.isFinite(a)?a:Math.min(...o);let l=Number.isFinite(r)?r:Math.max(...o);l>c||(l=c+1);const[h,u]=s.scaleLinear().domain([c,l]).nice(i).domain();return[Number.isFinite(a)?c:h,Number.isFinite(r)?l:u]}function Vb(e,t){return Math.max(2,Math.round(Math.abs(Hb(t-e))/45))}function qb(e,t,n,i){const[o,a]=e,r=a-o;if(!1===t)return{major:[],minor:[]};const c=s.scaleLinear().domain(e),l="number"==typeof t?Math.max(1,t):i;let h;if(Array.isArray(t))h=t.filter(e=>Number.isFinite(e)&&e>=o&&e<=a).sort((e,t)=>e-t);else{const e=c.ticks(l),t=e.length>1?e[1]-e[0]:r;h=[o,...e.filter(e=>e-o>=t/2&&a-e>=t/2),a]}const u=n?c.ticks(Math.max(1,5*(h.length-1||l))).filter(e=>e>o&&e<a&&!h.some(t=>((e,t,n)=>Math.abs(e-t)<=1e-9*n)(t,e,r))):[];return{major:h,minor:u}}function Yb(e,t,n){const[i,o]=t,a=[];let r=i;for(const t of e??[]){if(!t)continue;const e=f.clamp(Number.isFinite(t.min)?t.min:r,i,o),s=f.clamp(Number.isFinite(t.max)?t.max:o,i,o);r=s,s>e&&a.push({min:e,max:s,color:t.color??n})}return a}function Kb(e,t){const n=Math.min(e,t),i=Math.max(e,t),o=[n,i],a=Math.PI/2;for(let e=Math.ceil(n/a);e*a<=i;e++)o.push(e*a);const r=[0,...o.map(e=>Math.sin(e))],s=[0,...o.map(e=>-Math.cos(e))];return{x0:Math.min(...r),x1:Math.max(...r),y0:Math.min(...s),y1:Math.max(...s)}}function Ub(e,t){return{x0:Math.min(e.x0,t.x0),x1:Math.max(e.x1,t.x1),y0:Math.min(e.y0,t.y0),y1:Math.max(e.y1,t.y1)}}function Xb(e,t,n){const i=n.x1-n.x0||1,o=n.y1-n.y0||1,a=Math.max(0,Math.min(e/i,t/o));return{cx:e/2-(n.x0+n.x1)/2*a,cy:t/2-(n.y0+n.y1)/2*a,radius:a}}function Qb(e,t,n){const i=.2*t,o=.7*t;return`M${-t},0L${-i},${-e}L${i},${-e}L${t},0L${o},${n}L${-o},${n}Z`}function Zb(e,t){const{indicator:n,hasBands:i,hasValue:o,extent:a}=t,r=t.hasName&&o,s="progress"!==n,c=function(e,t,n,i){const o=i?Math.max(1,n):1,a=o>1?Math.max(2,.02*e):0;let r=e*t;return o>1&&o*r+(o-1)*a>.5*e&&(r=Math.max(1,(.5*e-(o-1)*a)/o)),Array.from({length:o},(t,n)=>{const i=e-n*(r+a);return{inner:Math.max(0,i-r),outer:i}})}(e,f.clamp(t.thickness,.02,1),t.rows,!s),l=e,h=c[c.length-1].inner,u=s?l:h-.025*e,d=s?h:u-Math.max(2,.035*e),m=(s||!i?h:d)-.03*e,p=.07*e,g=t.tickFontSize??f.clamp(.075*e,8,16),y=m-p-.03*e-.8*g,x=Math.max(3,.055*e),b=o?f.clamp(e*(s?.2:.3),10,72):0,_=r?f.clamp(.085*e,9,20):0,k=.03*e,v=b+(r?k+_:0);let w;w=s?x+.06*e:a.y1>=.3?-v/2:-v-k;const S=w+b/2;return{outer:l,inner:h,rings:c,bandOuter:u,bandInner:d,tickOuter:m,majorLength:p,minorLength:p/2,tickLabelRadius:y,tickFontSize:g,hubRadius:x,needleLength:(h+l)/2,needleHalfWidth:Math.max(2,.03*e),needleTail:.12*e,valueY:S,valueFontSize:b,valueMaxWidth:Math.max(0,y)*(s?1.3:1.6),nameY:S+b/2+k+_/2,nameFontSize:_,nameMaxWidth:1.2*e}}function Jb(e,t,n){if(e.schema.label)return!0;return(e.schema.groupBy??[]).some(e=>void 0!==e(t,n))}function e_(e){const t=e.schema.axisConfig??{},n=t.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?n:void 0}const t_=({viz:e})=>{const{width:t,height:n}=ie(e),i=e._filteredData??[],o=e.schema.value,a=i.map((e,t)=>Number(o(e,t))),r=Array.isArray(e.schema.bands)?e.schema.bands:[],s=jb(Number(e.schema.startAngle)||0),c=jb(Number(e.schema.endAngle)||0),l=e.schema.ticks,h="number"==typeof l?l:Vb(s,c),u=Gb(a,r,e.schema.domain,h),d=Yb(r,u,e.schema.colorDefaults?.missing??"#ced4da"),f=qb(u,l,!1!==e.schema.minorTicks,h),m=1===i.length,p={indicator:"progress"===e.schema.indicator?"progress":"needle",thickness:Number(e.schema.thickness)||.2,hasBands:d.length>0,rows:i.length,hasValue:m,hasName:m&&Jb(e,i[0],0),extent:Kb(s,c),tickFontSize:e_(e)},g=Xb(Math.max(0,t-4),Math.max(0,n-4),function(e){const t=100,n=Zb(t,e);if(!n.valueFontSize){const i="progress"===e.indicator?0:n.needleTail/t;return Ub(e.extent,{x0:0,x1:0,y0:0,y1:i})}const i=(n.nameFontSize?n.nameY+n.nameFontSize/2:n.valueY+n.valueFontSize/2)/t,o=(n.valueY-n.valueFontSize/2)/t,a="progress"===e.indicator?0:n.needleTail/t;return Ub(e.extent,{x0:-.5,x1:.5,y0:Math.min(o,0),y1:Math.max(i,a)})}(p)),y=i.map((e,t)=>({__d3plus__:!0,data:e,i:t,value:a[t],angle:Ib(a[t],u,s,c)}));return e.ctx.gauge={cx:g.cx+2,cy:g.cy+2,radius:g.radius,domain:u,start:s,end:c,ticks:f,bands:d,dial:p},{shapeData:y}};function n_(e){if(!Array.isArray(e))return[];const t=[];let n=!1;for(const i of e)"number"==typeof i?Number.isFinite(i)&&(t.push({max:i}),n=!0):i&&"object"==typeof i&&t.push({...i});const i=t[t.length-1];return n&&i&&void 0!==i.max&&t.push({}),t}function i_(e,t,n){const i=[...e,...t.flatMap(e=>[e.min,e.max])].filter(e=>"number"==typeof e&&Number.isFinite(e));return{extent:i.length?[Math.min(...i),Math.max(...i)]:[],input:n}}function o_(e,t=5){return Gb(e.extent,[],e.input,t)}function a_(e,t,n,i,o){const a=t[1]-t[0]||1;return e.every((t,r)=>{if(!r)return!0;return(t-e[r-1])/a*n>=(i(t)+i(e[r-1]))/2+o})}function r_(e,t,n,i,o=70,a=8){if(!1===t)return{domain:o_(e),ticks:[]};if(Array.isArray(t)){const n=o_(e);return{domain:n,ticks:qb(n,t,!1,5).major}}if("number"==typeof t){const n=Math.max(1,t),i=o_(e,n);return{domain:i,ticks:qb(i,n,!1,n).major}}const r=Math.max(1,Math.floor(Math.max(0,n)/o));let s={domain:o_(e,1),ticks:[]};for(let t=r;t>=1;t--){const o=o_(e,t),r=qb(o,t,!1,t).major;if(s={domain:o,ticks:r},a_(r,o,n,i,a))return s}return{domain:s.domain,ticks:s.domain.slice()}}function s_(e,t){const n=function(e,t){const[n,i]=t,o=i-n;return Number.isFinite(e)&&o?Math.max(0,Math.min(1,(e-n)/o)):0}(t,e.domain),{band:i}=e;return"vertical"===e.orient?i.y+i.height*(1-n):i.x+i.width*n}function c_(e){const[t,n]=e;return Math.max(t,Math.min(n,0))}function l_(e,t,n,i){const{band:o}=e,a=s_(e,t),r=s_(e,n),s=Math.min(a,r),c=Math.abs(r-a),l=Math.max(0,Math.min(1,i));if("vertical"===e.orient){const e=o.width*l;return{x:o.x+(o.width-e)/2,y:s,width:e,height:c}}const h=o.height*l;return{x:s,y:o.y+(o.height-h)/2,width:c,height:h}}function h_(e,t,n){const i=s_(e,t);return"vertical"===e.orient?{...n,y:i,height:0}:{...n,x:i,width:0}}function u_(e,t,n){const{band:i}=e,o=s_(e,t),a=Math.max(0,Math.min(1,n));if("vertical"===e.orient){const e=i.width*(1-a)/2;return[[i.x+e,o],[i.x+i.width-e,o]]}const r=i.height*(1-a)/2;return[[o,i.y+r],[o,i.y+i.height-r]]}function d_(e){return e.axis?"vertical"===e.orient?7+e.tickLabelWidth:7+e.tickFontSize:0}function f_(e){return e.count>0&&e.width>0&&e.height>0?"vertical"===e.orient?function(e){const{width:t,height:n,count:i,labelHeight:o}=e,a=d_(e),r="row"===e.axis?a:0,s="shared"===e.axis?a:0,c=o?o+12:0,l=e.axis?e.tickFontSize/2:0,h=2+c+l,u=Math.max(0,n-h-Math.max(2,l)-2),d=Math.max(0,t-s-4),m=d/i,p=Math.min(Math.max(0,m-r),f.clamp(.45*(m-r),4,e.bulletSize)),g=r+p,y=Math.min(m,Math.max(g+Math.max(16,p),e.labelWidth+12)),x=2+s+(d-y*i)/2;return Array.from({length:i},(t,n)=>{const i=x+n*y,o=i+(y-p)/2+r/2;return{band:{x:o,y:h,width:p,height:u},label:{x:o+p/2,y:2,anchor:"middle",maxWidth:Math.max(0,y-8)},axis:"row"===e.axis||"shared"===e.axis&&0===n,hit:{x:i,y:2,width:y,height:h+u-2}}})}(e):function(e){const{width:t,height:n,count:i,labelHeight:o}=e,a=d_(e),r="row"===e.axis?a:0,s="shared"===e.axis?a:0,c=Math.min(e.labelWidth,.35*t),[l,h]=e.axis?e.tickOverhang:[0,0],u=c?2+c+Math.max(12,l):2+l,d=Math.max(0,t-u-2-h),m=Math.max(0,n-s-4),p=m/i,g=Math.min(Math.max(0,p-r),f.clamp(.62*(p-r),4,e.bulletSize)),y=g+r,x=Math.max(12,.6*g),b=Math.min(p,Math.max(y,o)+x),_=Math.max(0,(o-g)/2),k=b*(i-1)+y,v=2+Math.max(_,(m-k)/2);return Array.from({length:i},(t,n)=>{const a=v+n*b,r={x:u,y:a,width:d,height:g},s=Math.min(a,a+g/2-o/2);return{band:r,label:{x:2+c,y:a+g/2,anchor:"end",maxWidth:c},axis:"row"===e.axis||"shared"===e.axis&&n===i-1,hit:{x:0,y:s,width:u+d,height:Math.max(a+y,a+g/2+o/2)-s}}})}(e):[]}function m_(e,t){const n=function(e,t=.36,n=.12){if(e<=0)return[];if(1===e)return[(t+n)/2];const i=(t-n)/(e-1);return Array.from({length:e},(e,n)=>t-n*i)}(e.length);return e.map((e,i)=>e.color?e:{...e,color:t(n[i])})}function p_(e,t,n){if("function"!=typeof e)return NaN;const i=e(t,n);return null==i||""===i?NaN:Number(i)}function g_(e,t,n){return e._ids(t,n).join("-")}function y_(e,t,n){const i=e.schema.bands;return n_("function"==typeof i?i(t,n):i)}function x_(e,t,n){return[p_(e.schema.value,t,n),p_(e.schema.target,t,n),p_(e.schema.forecast,t,n)]}function b_(e,t){const n=!!e.schema.sharedDomain,i=new Map;return t.forEach((t,o)=>{const a=n?"*":g_(e,t,o),r=i_(x_(e,t,o),y_(e,t,o),function(e,t,n){const i=e.schema.domain,o="function"==typeof i?i(t,n):i;return Array.isArray(o)?o:void 0}(e,t,o)),s=i.get(a);var c,l;i.set(a,s?(l=r,i_([...(c=s).extent,...l.extent],[],c.input)):r)}),i}const __=(e,t,i,o=400)=>e?n.textWidth(e,{"font-family":t,"font-size":i,"font-weight":o}):0;function k_(e,t,n,i){const o=e.ctx.bulletFacet,a=e.schema.sharedDomain?"*":g_(e,n,i);return o?.get(a)??t.get(a)??{extent:[],input:void 0}}function v_(e,t){const n=e.some(e=>e.name),i=e.some(e=>e.subLabel);return{labelWidth:Math.max(0,...e.map(e=>__(e.name,t,13,600)),...e.map(e=>__(e.subLabel,t,11))),labelHeight:(n?13:0)+(i?11+(n?2:0):0)}}const w_=({viz:e})=>{const{width:t,height:n}=ie(e),i=e._filteredData??[],o="vertical"===e.schema.orient?"vertical":"horizontal",s=function(e,t,n){const i=(e.schema.axisConfig??{}).shapeConfig??{},o=i.labelConfig??{},s=Ia(e),c=r.colorContrast(s,e.schema.colorDefaults),l=x.interpolateRgb(s,c),h=tu(o.fontColor,t,n)??c,u=tu(o.fontFamily,t,n)??e.schema.fontFamily,d=tu(o.fontSize,t,n),f=e.schema.tickFormat;return{background:s,mix:l,trackFill:tu(i.fill,t,n)??l(.08),tickStroke:tu(i.stroke,t,n)??l(.55),tickStrokeWidth:tu(i.strokeWidth,t,n)??1,fontColor:h,mutedColor:x.interpolateRgb(s,h)(.68),fontFamily:a.fontFamilyStringify(u),tickFontSize:"number"==typeof d&&d>0?d:10,tickFormat:e=>`${f(e)}`}}(e,i[0]??{},0),c=s.fontFamily,l=function(e,t){const n=e.schema.subLabel,i=b_(e,t);return t.map((t,o)=>{const a="function"==typeof n?n(t,o):void 0,[r,s,c]=x_(e,t,o);return{d:t,i:o,value:r,target:s,forecast:c,name:Jb(e,t,o)?`${e._drawLabel(t,o)??""}`:"",subLabel:null==a?"":`${a}`,extent:k_(e,i,t,o)}})}(e,i),h=e.schema.ticks,u=e=>__(s.tickFormat(e),c,s.tickFontSize),d=l.map(e=>o_(e.extent,10)),f=f_({orient:o,width:t,height:n,count:l.length,bulletSize:Math.max(1,Number(e.schema.bulletSize)||1),...v_(l,c),axis:!1!==h&&(e.schema.sharedDomain?"shared":"row"),tickFontSize:s.tickFontSize,tickLabelWidth:Math.max(0,...d.flatMap(e=>qb(e,10,!1,10).major.map(u))),tickOverhang:[Math.max(0,...d.map(e=>u(e[0])/2)),Math.max(0,...d.map(e=>u(e[1])/2))]}),m="vertical"===o,p=f.map((t,n)=>{const i=l[n],a=r_(i.extent,h,m?t.band.height:t.band.width,m?()=>1.2*s.tickFontSize:u,m?45:70);return{__d3plus__:!0,data:i.d,i:i.i,key:g_(e,i.d,i.i),value:i.value,target:i.target,forecast:i.forecast,name:i.name,subLabel:i.subLabel,track:{orient:o,band:t.band,domain:a.domain},bands:Yb(m_(y_(e,i.d,i.i),s.mix),a.domain,s.mix(.2)),ticks:t.axis?a.ticks:[],axis:t.axis,label:t.label,hit:t.hit}});return e.ctx.bullet={orient:o,style:s,nameFontSize:13,subFontSize:11},{shapeData:p}};function S_(e,t,n){return{type:"path",key:e,interactive:!1,d:i.arcPath(t),arc:t,paint:{fill:n}}}function C_(e,t,i,o,a=8,r=400){const s=(e,i)=>n.textWidth(e,{"font-family":t,"font-size":i,"font-weight":r});let c=s(e,i);c>o&&c>0&&(c=s(e,i=Math.max(a,i*o/c)));let l=e;for(;c>o&&l.length>1;)if(l=l.slice(0,-1),c=s(`${l.trimEnd()}…`,i),c<=o)return{text:`${l.trimEnd()}…`,size:i,width:c};return{text:l,size:i,width:c}}function M_(e,t,i,o,a){return{type:"text",key:e,interactive:!1,x:0,y:0,transform:{x:i,y:o},lines:[{text:t,x:0,y:0,width:a.width??n.textWidth(t,{"font-family":a.family,"font-size":a.size})}],font:{family:a.family,size:a.size,weight:a.weight??400,anchor:"middle",baseline:"middle"},paint:{fill:a.color}}}function $_(e,t,n){return e.map(e=>{const i=Math.sin(e),o=Math.cos(e);return`M${t*i},${-t*o}L${n*i},${-n*o}`}).join("")}function A_(e,t,n,i){const{domain:o,start:a,end:r,ticks:s,bands:c}=n,l=e=>Ib(e,o,a,r),h=t.rings.map((t,n)=>S_(`${e}-track-${n}`,{innerRadius:t.inner,outerRadius:t.outer,startAngle:a,endAngle:r},i.trackFill));c.forEach((n,i)=>h.push(S_(`${e}-band-${i}`,{innerRadius:t.bandInner,outerRadius:t.bandOuter,startAngle:l(n.min),endAngle:l(n.max)},n.color)));const u={fill:"none",stroke:i.tickStroke,strokeLinecap:"round"};return s.minor.length&&h.push({type:"path",key:`${e}-minor-ticks`,interactive:!1,d:$_(s.minor.map(l),t.tickOuter,t.tickOuter-t.minorLength),paint:{...u,strokeWidth:i.tickStrokeWidth/2,strokeOpacity:.75}}),s.major.length&&h.push({type:"path",key:`${e}-major-ticks`,interactive:!1,d:$_(s.major.map(l),t.tickOuter,t.tickOuter-t.majorLength),paint:{...u,strokeWidth:i.tickStrokeWidth}}),t.tickLabelRadius>0&&s.major.forEach((n,o)=>{const a=l(n),r=t.tickLabelRadius;h.push(M_(`${e}-tick-${o}`,i.tickFormat(n),r*Math.sin(a),-r*Math.cos(a),{size:t.tickFontSize,family:i.fontFamily,color:i.fontColor}))}),h}function z_(e,t,n,i,o){const a=[];if(i){const o=C_(i,n.fontFamily,t.valueFontSize,t.valueMaxWidth,8,600);a.push(M_(`${e}-value`,o.text,0,t.valueY,{size:o.size,family:n.fontFamily,color:n.fontColor,weight:600,width:o.width}))}if(o&&t.nameFontSize){const i=C_(o,n.fontFamily,t.nameFontSize,t.nameMaxWidth);a.push(M_(`${e}-name`,i.text,0,t.nameY,{size:i.size,family:n.fontFamily,color:n.fontColor,width:i.width}))}return a}function D_(e,t,n,i,o){return{type:"text",key:e,x:0,y:0,transform:{x:n,y:i},lines:[{text:t,x:0,y:0,width:o.width}],font:{family:o.family,size:o.size,weight:o.weight??400,anchor:o.anchor,baseline:"middle"},paint:{fill:o.color}}}function F_(e,t,n){const{track:i}=e,[o,a]=i.domain,r=c_(i.domain),s=(e,t,n,o)=>{const a=l_(i,t,n,1);return((e,t,n,i)=>({type:"rect",key:e,interactive:!1,...t,enterRect:i,paint:{fill:n}}))(e,a,o,h_(i,r,a))},c=[s(`${t}-track`,o,a,n.trackFill)];if(e.bands.forEach((e,n)=>c.push(s(`${t}-band-${n}`,e.min,e.max,e.color))),!e.ticks.length)return c;const l="vertical"===i.orient,{band:h}=i,u=l?h.x:h.y+h.height,d=e.ticks.map(e=>{const t=s_(i,e);return l?`M${u-4},${t}L${u},${t}`:`M${t},${u}L${t},${u+4}`}).join("");c.push({type:"path",key:`${t}-ticks`,interactive:!1,d:d,paint:{fill:"none",stroke:n.tickStroke,strokeWidth:n.tickStrokeWidth}});return e.ticks.forEach((e,o)=>{const a=s_(i,e),r=C_(n.tickFormat(e),n.fontFamily,n.tickFontSize,1/0);c.push({...D_(`${t}-tick-${o}`,r.text,l?u-7:a,l?a:u+7+n.tickFontSize/2,{size:n.tickFontSize,family:n.fontFamily,color:n.fontColor,anchor:l?"end":"middle",width:r.width}),interactive:!1})}),c}function B_(e,t,n){const{style:i,nameFontSize:o,subFontSize:a}=n,{label:r}=e,s=[];if(e.name&&s.push({text:e.name,size:o,weight:600,color:i.fontColor,kind:"name"}),e.subLabel&&s.push({text:e.subLabel,size:a,weight:400,color:i.mutedColor,kind:"sub"}),!(s.length&&r.maxWidth>0))return[];const c=s.reduce((e,t)=>e+t.size,0)+2*(s.length-1);let l="vertical"===n.orient?r.y:r.y-c/2;return s.map(n=>{const o=C_(n.text,i.fontFamily,n.size,r.maxWidth,8,n.weight),a=D_(`${t}-${n.kind}`,o.text,r.x,l+n.size/2,{size:o.size,family:i.fontFamily,color:n.color,anchor:r.anchor,width:o.width,weight:n.weight});return l+=n.size+2,{...a,datum:e.data,index:e.i}})}function L_(e,t,n,i){const{track:o,data:a,i:r}=t,s=[],c=c_(o.domain),l=au(e,"Rect"),h=iu(l,a,r),u=e.schema.valueFormat,d=[t.name,Number.isFinite(t.value)?u(t.value,a):""];Number.isFinite(t.target)&&d.push(`${e.schema.translate("Target")} ${u(t.target,a)}`);const f={datum:a,index:r,aria:{label:`${d.filter(Boolean).join(", ")}.`}},m=e.schema.forecastConfig??{};if(Number.isFinite(t.forecast)){const e=tu(m.size,a,r)??.6,i=tu(m.fill,a,r)??tu(l.fill,a,r),h=l_(o,c,t.forecast,e),u={type:"rect",key:`${n}-forecast`,...h,enterRect:h_(o,c,h),shapeType:"Rect",paint:{fill:nu({...l,...m},a,r,i),opacity:tu(m.opacity,a,r)??.35},...f};s.push(u);const d=Vy(m,u,a,r);d&&s.push(d)}if(Number.isFinite(t.value)){const i=Number(e.schema.measureSize),u=l_(o,c,t.value,Number.isFinite(i)?i:.35),d={type:"rect",key:`${n}-measure`,...u,enterRect:h_(o,c,u),shapeType:"Rect",paint:h,...f};s.push(d);const m=Vy(l,d,a,r);m&&s.push(m)}const p=e.schema.targetConfig??{};if(Number.isFinite(t.target)){const e=tu(p.size,a,r)??.75;s.push({type:"line",key:`${n}-target`,points:u_(o,t.target,e),shapeType:"Line",paint:{fill:"none",stroke:tu(p.stroke,a,r)??i.style.fontColor,strokeWidth:tu(p.strokeWidth,a,r)??3},...f})}return s}function P_(e){return"function"==typeof e?e:"string"==typeof e?Be(e):"number"==typeof e&&N(e)}const R_={name:"Bullet",layoutStage:w_,emit:({viz:e,shapeData:t})=>{const n=t??[],i=e.ctx.bullet;if(!n.length||!i)return[];const o=new Map;return n.map(t=>{const n=o.get(t.key)??0;o.set(t.key,n+1);const a=`bullet-${t.key}${n?`-${n}`:""}`,r={type:"rect",key:`${a}::hit`,...t.hit,datum:t.data,index:t.i,paint:{fill:"transparent"}};return{type:"group",key:a,children:[{type:"group",key:`${a}-static`,interactive:!1,aria:{hidden:!0},children:F_(t,a,i.style)},r,...B_(t,a,i),...L_(e,t,a,i)]}})},facet:{aspect:2,share:(e,t)=>b_(e,t.flat()),panel:(e,t)=>(t.shared&&t.scales instanceof Map&&(e.ctx.bulletFacet=t.scales),()=>{e.ctx.bulletFacet=void 0})},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"bulletSize",default:40},{key:"domain"},{key:"forecast",default:T("forecast"),coerce:P_},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>{const o=e._filteredData??[],a=new Set(o.map((t,n)=>g_(e,t,n)));return!(i.length>=a.size)&&t.call(e,n,i)}}},{key:"measureSize",default:.35},{key:"orient",default:"horizontal"},{key:"sharedDomain",default:!1},{key:"subLabel",default:!1,coerce:P_},{key:"target",default:T("target"),coerce:P_},{key:"tickFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"ticks"},{key:"value",default:T("value"),coerce:e=>P_(e)||T("value")},{key:"valueFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"zoom",default:!1},{key:"forecastConfig",merge:!0,default:{opacity:.35,size:.6}},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>Ia(e),strokeWidth:1})},{key:"targetConfig",merge:!0,default:{size:.75,strokeWidth:3}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>function(e,t,n){const i=e.schema.valueFormat,o=[];for(const[a,r]of[["value","Value"],["target","Target"],["forecast","Forecast"]]){const s=p_(e.schema[a],t,n);Number.isFinite(s)&&o.push([e.schema.translate(r),`${i(s,t)}`])}return o}(e,t,n)})}]};var E_=xf(R_);const N_={name:"BumpChart",paintDriven:!0,setup:e=>{const t=e;t.y2((t,n)=>e._y(t,n)),t.yConfig({tickFormat:t=>{const n=e._formattedData??[],i=n[0].x instanceof Date?n[0].x.getTime():n[0].x,o=n.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===i),a=o.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.y2Config({tickFormat:t=>{const n=e._formattedData??[],i=n[n.length-1].x instanceof Date?n[n.length-1].x.getTime():n[n.length-1].x,o=n.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===i),a=o.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.ySort((t,n)=>e._y(n)-e._y(t)),t.y2Sort((t,n)=>e._y(n)-e._y(t))},facet:{axes:"all"},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"discrete",default:"x"},{key:"shape",default:N("Line"),coerce:"const"}]};var T_=xf(N_,_b);const O_=/^(\d{4})-(\d{2})-(\d{2})$/;function W_(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function j_(e){if(Array.isArray(e))return e.length?j_(e[0]):null;if(e instanceof Date)return isNaN(+e)?null:W_(e);if("number"==typeof e)return Number.isFinite(e)?W_(new Date(e)):null;if("string"!=typeof e||!e.trim())return null;const t=O_.exec(e.trim());if(t){const[e,n,i]=[+t[1],+t[2]-1,+t[3]],o=new Date(e,n,i);return o.setFullYear(e),o.getMonth()===n&&o.getDate()===i?o:null}const n=new Date(e);return isNaN(+n)?null:W_(n)}function H_(e){return`${`${e.getFullYear()}`.padStart(4,"0")}-${`${e.getMonth()+1}`.padStart(2,"0")}-${`${e.getDate()}`.padStart(2,"0")}`}function I_(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),i=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((i-n)/864e5)}function G_(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function V_(e,t){return((e.getDay()-t)%7+7)%7}function q_(e,t,n){return Math.floor((I_(t,e)+V_(t,n))/7)}const Y_=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function K_(e,t){if("number"==typeof e&&Number.isFinite(e))return(Math.round(e)%7+7)%7;if("string"==typeof e&&e.length>=2){const t=e.toLowerCase(),n=Y_.findIndex(e=>e.startsWith(t));if(n>=0)return n}return c.findWeekStart("string"==typeof t?t:"")}function U_(e){if(!e.length)return null;let t=e[0],n=e[0];for(const i of e)+i<+t&&(t=i),+i>+n&&(n=i);return[t,n]}function X_(e,t,n){const i=[];if(+t<+e)return i;if("month"===n){let n=e.getFullYear(),o=e.getMonth();const a=12*t.getFullYear()+t.getMonth();for(;12*n+o<=a;)i.push({key:`${H_(new Date(n,o,1)).slice(0,7)}`,start:new Date(n,o,1),end:new Date(n,o+1,0)}),o+=1,o>11&&([n,o]=[n+1,0]);return i}for(let n=e.getFullYear();n<=t.getFullYear();n++)i.push({key:`${n}`,start:new Date(n,0,1),end:new Date(n,11,31)});return i}function Q_(e,t){return q_(e.end,e.start,t)+1}function Z_(e,t){const n=I_(e.start,e.end)+1,i=V_(e.start,t),o=[];for(let t=0;t<n;t++){const n=G_(e.start,t);o.push({date:n,key:H_(n),week:Math.floor((t+i)/7),day:(t+i)%7})}return o}function J_(e){return X_(e.start,e.end,"month")}function ek(e){return"string"==typeof e&&c.locale[e]||c.locale["en-US"]}function tk(e,t,n){const i=void 0===e?n:e;if("function"==typeof i){const e=i;return t=>`${e(t)??""}`}return"string"==typeof i&&i?g.timeFormatLocale(t).format(i):null}function nk(e){const t=e.dateTime.replace(/[,.]?\s*%X/g,"").replace(/[\s,.]+$/,"").replace(/%e/g,"%-d").trim()||e.date;return/%[aA]/.test(t)?t:`%A, ${t}`}function ik(e,t){const[n=""]=Array.from(e.trim());try{return n.toLocaleUpperCase(t)}catch{return n.toUpperCase()}}function ok(e){const{count:t,gridColumns:n,gridRows:i,insetTop:o,insetLeft:a,gap:r,width:s,height:c}=e,l=Math.max(1,t),h=e.columns?[Math.min(l,Math.max(1,Math.round(e.columns)))]:Array.from({length:l},(e,t)=>t+1);let u;for(const e of h){const t=Math.ceil(l/e),h=(s-e*a-(e-1)*r)/(e*n),d=(c-t*o-(t-1)*r)/(t*i),f=Math.max(0,Math.min(h,d));(!u||f>u.cell+1e-9)&&(u={cell:f,columns:e,rows:t})}const{cell:d,columns:f,rows:m}=u,p=a+n*d,g=o+i*d;return{cell:d,columns:f,rows:m,blockWidth:p,blockHeight:g,width:f*p+(f-1)*r,height:m*g+(m-1)*r}}function ak(e,t,n){return"vertical"===n?[t,e]:[e,t]}function rk(e,t){return"vertical"===t?{columns:7,rows:e}:{columns:e,rows:7}}function sk(e,t,n,i){const{week:o,day:a}=e,{week:r,day:s}=t,c=e=>Math.round(100*e)/100;return`${[[o+1,a],[o,a],[o,7],[r,7],[r,s+1],[r+1,s+1],[r+1,0],[o+1,0]].map(([e,t],o)=>{const[a,r]=ak(e,t,i);return`${o?"L":"M"}${c(a*n)},${c(r*n)}`}).join("")}Z`}function ck(e){return 0===e.day?e.week:e.week+1}function lk(e,t){return e>=t?[0,1,2,3,4,5,6]:[1,3,5]}function hk(e,t){return e>0&&t>0?Math.min(e,t/3):0}const uk=new Date(2023,0,1);function dk(e){return Math.max(3,Math.round(.4*e))}function fk(e,t){return Array.from({length:7},(n,i)=>e(G_(uk,(t+i)%7)))}function mk(e,t,n,i,o){const a=n.fontSize,r=dk(a),s=1.15*a+r,c=a+r,l=n.weekday?i+r:0;if("month"===e){return{top:(n.title.length?s:0)+("vertical"===t&&n.weekday?c:0),left:"horizontal"===t?l:0}}return"vertical"===t?{top:(n.year?s:0)+(n.weekday?c:0),left:n.month?o+r:0}:{top:n.month?c:0,left:l+(n.year?s:0)}}function pk(e,t,n){const i=e=>Math.round(100*e)/100;return e.replace(/(-?[\d.]+),(-?[\d.]+)/g,(e,o,a)=>`${i(+o+t)},${i(+a+n)}`)}function gk(e){const{start:t,end:n,period:i,orient:o,weekStart:a,width:r,height:s,labels:c}=e,l=X_(t,n,i),h=Math.max(1,...l.map(e=>Q_(e,a))),u=c.weekday?fk(c.weekday,a):[],d=c.month?Math.max(0,...Array.from({length:12},(e,t)=>c.measure(c.month(new Date(2023,t,1))))):0,f=Math.max(0,...u.map(c.measure)),m=mk(i,o,c,f,d),p=rk(h,o),g="month"===i?1.5*c.fontSize:c.fontSize,y=ok({count:l.length,gridColumns:p.columns,gridRows:p.rows,insetTop:m.top,insetLeft:m.left,gap:g,width:r,height:s,columns:"month"===i?void 0:"vertical"===o?l.length:1}),{cell:x}=y,b=Math.max(0,(r-y.width)/2),_=Math.max(0,(s-y.height)/2),k=[],v=[],w=[];return l.forEach((t,n)=>{const r=b+n%y.columns*(y.blockWidth+g),s=_+Math.floor(n/y.columns)*(y.blockHeight+g),l={block:t,left:r,top:s,x:r+m.left,y:s+m.top};for(const e of Z_(t,a)){const[n,i]=ak(e.week,e.day,o);k.push({...e,block:t.key,x:l.x+n*x,y:l.y+i*x,size:x})}c.weekday&&v.push(...function(e,t,n,i){const{labels:o,orient:a}=n,r=o.fontSize,s=dk(r),c="vertical"===a;let l=t,h=lk(i,1.25*r);if(c){const e=(e,t)=>Math.max(...e.map(o.measure))<=t,n=t.map(o.narrow);e(t,i-2)?h=[0,1,2,3,4,5,6]:e(n,i)?[l,h]=[n,[0,1,2,3,4,5,6]]:e(n,2*i-2)?[l,h]=[n,[0,2,4,6]]:h=[]}return h.map(t=>({key:`${e.block.key}-weekday-${t}`,kind:"weekday",text:l[t],x:c?e.x+(t+.5)*i:e.x-s,y:c?e.y-s-r/2:e.y+(t+.5)*i,anchor:c?"middle":"end"}))}(l,u,e,x)),"year"===i&&c.month&&v.push(...function(e,t,n,i){const{labels:o,orient:a,weekStart:r}=t,s=o.month,c=o.fontSize,l=dk(c),h=[];let u=-1/0;for(const t of J_(e.block)){const d=ck({week:q_(t.start,e.block.start,r),day:V_(t.start,r)});if(d>=i)continue;const f=s(t.start),m=d*n,p="vertical"===a?c:o.measure(f);m<u||m+("vertical"===a?0:p)>i*n+l||(u=m+p+l,h.push({key:`${e.block.key}-month-${t.key}`,kind:"month",text:f,x:"vertical"===a?e.x-l:e.x+m,y:"vertical"===a?e.y+m+n/2:e.y-l-c/2,anchor:"vertical"===a?"end":"start"}))}return h}(l,e,x,Q_(t,a)));const h=function(e,t,n,i){const{labels:o,orient:a,period:r}=t,s=o.fontSize,c=`${e.block.key}-${"month"===r?"title":"year"}`;if("month"===r){const t=o.title.map(t=>t(e.block.start)).find((e,t,i)=>t===i.length-1||1.1*o.measure(e)<=n.blockWidth);return void 0===t?null:{key:c,kind:"title",text:t,x:e.left,y:e.top+.6*s,anchor:"start"}}if(!o.year)return null;const l=o.year(e.block.start);return"vertical"===a?{key:c,kind:"year",text:l,x:e.x+i/2,y:e.top+.6*s,anchor:"middle"}:{key:c,kind:"year",text:l,x:e.left+.6*s,y:e.y+7*n.cell/2,anchor:"middle",rotate:-90}}(l,e,y,p.columns*x);h&&v.push(h),"year"===i&&w.push(...function(e,t,n,i){return J_(e.block).map(o=>{const a=n=>({week:q_(n,e.block.start,t),day:V_(n,t)}),r=sk(a(o.start),a(o.end),n,i);return{key:`${e.block.key}-outline-${o.key}`,d:pk(r,e.x,e.y)}})}(l,a,x,o))}),{blocks:l,fit:y,cells:k,labels:v,outlines:w}}function yk(e,t,n){const i=e.schema.date;return j_("function"==typeof i?i(t,n):void 0)}function xk(e,t){const n=[];return t.forEach((t,i)=>{const o=yk(e,t,i);o&&n.push(o)}),U_(n)}function bk(e){return"month"===e.schema.period?"month":"year"}function _k(e){const t=e.schema.orient;return"horizontal"===t||"vertical"===t?t:"month"===bk(e)?"vertical":"horizontal"}function kk(e){const t=e.schema.calendarLabelConfig??{},n=t.fontFamily??e.schema.fontFamily;return{fontColor:"string"==typeof t.fontColor?t.fontColor:void 0,fontFamily:a.fontFamilyStringify(n),fontSize:"number"==typeof t.fontSize?t.fontSize:11,fontWeight:t.fontWeight??400}}function vk(e){const t=ek(e.schema.locale);return tk(nk(t),t,!1)}function wk(e,t,i){const o=ek(e.schema.locale),a=[];if("month"===t){const t=tk(e.schema.monthFormat,o,!1);if(t)a.push(t);else if(!1!==e.schema.monthFormat)for(const e of["%B %Y","%b %Y","%b"])a.push(tk(e,o,!1))}return{fontSize:i.fontSize,measure:e=>n.textWidth(e,{"font-family":i.fontFamily,"font-size":i.fontSize,"font-weight":i.fontWeight}),weekday:tk(e.schema.weekdayFormat,o,"%a"),month:"year"===t?tk(e.schema.monthFormat,o,"%b"):null,year:"year"===t?tk(e.schema.yearFormat,o,"%Y"):null,title:a,narrow:t=>ik(t,e.schema.locale)}}const Sk=({viz:e})=>{const t=e._filteredData??[],n=new Map;t.forEach((t,i)=>{const o=yk(e,t,i);if(!o)return;const a=H_(o);n.has(a)||n.set(a,{datum:t,i:i})});const i=e.ctx.calendarSharedExtent??xk(e,t);if(e.ctx.calendarLayout=void 0,!i)return{shapeData:[]};const{width:o,height:a}=ie(e),r=bk(e),s=kk(e),c=gk({start:i[0],end:i[1],period:r,orient:_k(e),weekStart:K_(e.schema.weekStart,e.schema.locale),width:o,height:a,labels:wk(e,r,s)});e.ctx.calendarLayout=c,e.ctx.calendarDateFormat=vk(e),e.ctx.calendarLabelStyle=s;return{shapeData:c.cells.map(e=>{const t=n.get(e.key);return t?{...e,datum:t.datum,i:t.i}:e})}};function Ck(e,t){const n=x.interpolateRgb(e,t);return{empty:n(.09),outline:n(.45),text:n(.75)}}function Mk(e,t,n){const i=e.schema.colorScale;if("function"!=typeof i)return;const o=i(t,n);return null!=o&&""!==o&&"boolean"!=typeof o&&Number.isFinite(+o)?+o:void 0}function $k(e,t,n){return"function"!=typeof e.schema.colorScale||void 0!==Mk(e,t,n)}function Ak(e,t,n){if(!e.schema.monthOutline)return[];const i=e.schema.monthOutlineConfig??{},o=i.strokeDasharray;return t.outlines.map(e=>({type:"path",key:`calendar-${e.key}`,d:e.d,interactive:!1,paint:{fill:"none",stroke:i.stroke??n,strokeWidth:i.strokeWidth??1,...o?{strokeDasharray:o}:{}}}))}const zk=({viz:e,shapeData:t})=>{const i=t??[],o=e.ctx.calendarLayout;if(!i.length||!o)return[];const a=e.ctx.calendarLabelStyle,s=Ia(e),c=Ck(s,r.colorContrast(s,e.schema.colorDefaults)),l=au(e,"Rect"),h=o.fit.cell,u=Math.min(Math.max(0,Number(e.schema.cellPadding)||0),h/2),d=Math.max(0,h-u),f={viz:e,sc:l,emptyFill:e.schema.emptyFill??c.empty,padding:u,side:d,radius:hk(Number(e.schema.cellRadius)||0,d),noData:e.schema.translate("No Data"),dateFormat:e.ctx.calendarDateFormat},m=i.map(e=>function(e,t){const{viz:n,sc:i,emptyFill:o,noData:a}=t,r={type:"rect",key:`calendar-${e.key}`,x:e.x+t.padding/2,y:e.y+t.padding/2,width:t.side,height:t.side,...t.radius?{rx:t.radius,ry:t.radius}:{}},{datum:s,i:c}=e;if(!s){const n=t.dateFormat?t.dateFormat(e.date):e.key;return{...r,interactive:!1,paint:{fill:o},aria:{label:`${n}, ${a}.`}}}const l=Mk(n,s,c??0),h=$k(n,s,c??0),u=h?tu(i.fill,s,c):o,d=tu(i.ariaLabel,s,c)??e.key,f=h?l:a;return{...r,datum:s,index:c,shapeType:"Rect",paint:{fill:h?nu(i,s,c,u):u,stroke:tu(i.stroke,s,c),strokeWidth:tu(i.strokeWidth,s,c),opacity:tu(i.opacity,s,c)??1},aria:{label:`${void 0===f?d:`${d}, ${f}`}.`}}}(e,f)),p=i.filter(e=>e.datum),g=m.filter(e=>e.datum),y=e=>n.textWidth(e,{"font-family":a.fontFamily,"font-size":a.fontSize,"font-weight":a.fontWeight}),x=o.labels.map(e=>function(e,t,n,i){const o="year"===e.kind||"title"===e.kind;return{type:"text",key:`calendar-label-${e.key}`,interactive:!1,x:0,y:0,transform:{x:e.x,y:e.y,...e.rotate?{rotate:e.rotate}:{}},lines:[{text:e.text,x:0,y:0,width:i(e.text)}],font:{family:t.fontFamily,size:t.fontSize,weight:o?600:t.fontWeight,anchor:e.anchor,baseline:"middle"},paint:{fill:n}}}(e,a,a.fontColor??c.text,y));return[...m,...qy(l,g,e=>[p[e].datum,p[e].i]),...Ak(e,o,c.outline),...x]},Dk=e=>void 0!==e.date?e.date:e.time,Fk={name:"Calendar",layoutStage:Sk,emit:zk,insetRegion:function(e){const{width:t,height:n}=ie(e);return{bounds:{x:e._margin.left,y:e._margin.top,width:t,height:n},obstacles:Ku(e._chartScene||[],e._chartTransform,void 0,!0)}},defaults:{hoverOutline:!0},facet:{aspect:3,share:(e,t)=>U_(t.flatMap(t=>xk(e,t)??[])),panel:(e,{shared:t,scales:n})=>(e.ctx.calendarSharedExtent=t&&n?n:void 0,()=>{e.ctx.calendarSharedExtent=void 0})},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellRadius",default:2},{key:"date",default:Dk,coerce:e=>"function"==typeof e?e:Be(e)},{key:"emptyFill"},{key:"monthFormat"},{key:"monthOutline",default:!0},{key:"orient"},{key:"period",default:"year"},{key:"weekStart"},{key:"weekdayFormat"},{key:"yearFormat"},{key:"zoom",default:!1},{key:"colorScale",default:T("value"),coerce:rr},{key:"groupBy",factory:e=>[(t,n)=>{const i=yk(e,t,n);return i?H_(i):t.id}]},{key:"label",coerce:"const",factory:e=>(t,n)=>{const i=yk(e,t,n);return i?vk(e)(i):""}},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>!!e._legendCategories&&t.call(e,n,i)}},{key:"calendarLabelConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,default:{hoverOpacity:1}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Value"),(t,n)=>{const i=Mk(e,t,n);return void 0===i?"":d.formatAbbreviate(i,e.schema.locale)}]]})},{key:"monthOutlineConfig",merge:!0,default:{}}]};var Bk=xf(Fk);function Lk(e){const t=(t,n)=>{const i=e._id(t,n);return Array.isArray(i)?i:[i]};return n=>{const i=new Set;(e._facetPanels?e._facetPanels.map(e=>e.scene):[e._chartScene||[]]).forEach(e=>Ze(e,e=>i.add(e)));const o=new Set;return n.forEach(e=>t(e,0).forEach(e=>o.add(e))),(e,a)=>!e.__d3plus__&&(i.has(e)?n.has(e):t(e,a).some(e=>o.has(e)))}}function Pk(e){if(null==e||""===e||"boolean"==typeof e)return;const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function Rk(e,t,n){const i=Pk(n.close(e,t));if(void 0===i)return;const o=Pk(n.open(e,t))??i,a=Pk(n.high(e,t)),r=Pk(n.low(e,t));return{open:o,high:Math.max(a??-1/0,o,i),low:Math.min(r??1/0,o,i),close:i}}function Ek(e,t){return t>=e?"up":"down"}function Nk(e,t){if(Number.isFinite(e)&&Number.isFinite(t)&&0!==e)return(t-e)/Math.abs(e)}function Tk(e,t){let n=1/0,i=-1/0;for(const{d:o,i:a}of e){const e=Rk(o,a,t);e&&(e.low<n&&(n=e.low),e.high>i&&(i=e.high))}return n<=i?[n,i]:void 0}function Ok(e,t){const n=Array.from(new Set(e.filter(Number.isFinite))).sort((e,t)=>e-t);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,n[e]-n[e-1]);return Number.isFinite(i)&&i>0?i:t}function Wk(e,t){const n=Number.isFinite(t)?Math.min(1,Math.max(0,t)):.7;return Math.max(1,e*n)}const jk=e=>Math.round(e-.5)+.5;function Hk(e,t,n){const i=Math.min(n.open,n.close),o=Math.max(n.open,n.close),a=Math.min(n.high,i),r=Math.max(n.low,o),s=t/2;let c="";return a<i&&(c+=`M${e},${a}V${i}`),r>o&&(c+=`M${e},${o}V${r}`),c+=`M${e-s},${i}H${e+s}V${o}H${e-s}Z`,c}function Ik(e,t,n){const i=t/2;return`M${e},${n.high}V${n.low}M${e-i},${n.open}H${e}M${e},${n.close}H${e+i}`}const Gk=["open","high","low","close","volume"],Vk=new WeakMap;function qk(e){if("function"==typeof e)return e;if("string"!=typeof e)return N(e);const t=Be(e);return Vk.set(t,e),t}function Yk(e){const t=T(e);return Vk.set(t,e),t}function Kk(e){return"function"==typeof e?Vk.get(e):void 0}const Uk=(e,t)=>e.map(t).map(Pk).filter(e=>void 0!==e),Xk=(e,t)=>Uk(e,t)[0],Qk=(e,t)=>Uk(e,t).at(-1),Zk=(e,t)=>{const n=Uk(e,t);return n.length?Math.max(...n):void 0},Jk=(e,t)=>{const n=Uk(e,t);return n.length?Math.min(...n):void 0},ev=(e,t)=>{const n=Uk(e,t);return n.length?n.reduce((e,t)=>e+t,0):void 0},tv={open:Xk,high:Zk,low:Jk,close:Qk,volume:ev},nv=new Set(Object.values(tv)),iv=e=>nv.has(e);function ov(e,t){const n=new Map;for(const e of Gk){const i=Kk(t[e]);void 0!==i&&n.set(i,tv[e])}for(const t of Object.keys(e))iv(e[t])&&!n.has(t)&&delete e[t];n.forEach((t,n)=>{e[n]&&!iv(e[n])||(e[n]=t)})}function av(e,t,n){let i;for(const o of Gk){const a=t[o];if("function"!=typeof a||void 0!==Kk(a))continue;const r=n[o],s="function"!=typeof r||iv(r)?tv[o]:r;(i??(i={}))[o]=s(e,t=>a(t,e.indexOf(t)))}return i}const rv=e=>Object.fromEntries(Gk.map(t=>[t,e.schema[t]])),sv=new WeakMap;function cv(e,t){return(n,i)=>{const o=sv.get(e)?.get(n);return o&&t in o?o[t]:e.schema[t](n,i)}}function lv(e){return{open:cv(e,"open"),high:cv(e,"high"),low:cv(e,"low"),close:cv(e,"close")}}function hv(e,t,n,i=4){let[o,a]=e;const r=n.invert,s=(e,t)=>{const i=n(e);if(!r||!Number.isFinite(i))return e;const o=Number(r(i+t));return Number.isFinite(o)?o:e},c=s(t[1],-i),l=s(t[0],i);return c>a&&(a=c),l<o&&(o=l),[o,a]}function uv({data:e,x:t,y:n,x2:i}){if(i)return[t,n];!function(e,t){if(e.padding)return void e.padding(1);const n=Array.from(new Set(t.filter(Number.isFinite))).sort((e,t)=>e-t);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,n[e]-n[e-1]);if(!Number.isFinite(i))return;const[o,a]=e.domain().map(Number);e.domain([new Date(o-i),new Date(a+i)])}(t,e.map(e=>+e.x));const o=Tk(e.map(e=>({d:e.data,i:e.i})),lv(this));if(!o)return[t,n];const a=hv(n.domain().slice().reverse(),o,n);return n.domain(a.slice().reverse()),[t,n]}const dv=["day","week","month","quarter","year"],fv=[2,5,10,20,50,100,200,500,1e3];function mv(e){if(e instanceof Date)return e;if("string"!=typeof e&&"number"!=typeof e)return e;const t=n.date(e);return t instanceof Date&&!isNaN(+t)?t:e}function pv(e){const t=!e.getHours()&&!e.getMinutes()&&!e.getSeconds();return g.timeFormat(t?"%b %-d, %Y":"%b %-d, %Y %-I:%M %p")(e)}function gv(e,t){const n=e.getFullYear(),i=e.getMonth();switch(t){case"day":return 31*(12*n+i)+e.getDate();case"week":return+k.timeMonday.floor(e);case"month":return 12*n+i;case"quarter":return 4*n+Math.floor(i/3);default:return n}}function yv(e,t){if(!e.length)return[];const n=Math.max(1,Math.floor(t)),i=dv.map(t=>function(e,t){const n=[];for(let i=1;i<e.length;i++)gv(e[i],t)!==gv(e[i-1],t)&&n.push(e[i]);return n}(e,t)),o=i[i.length-1],a=i.concat(fv.map(e=>o.filter(t=>t.getFullYear()%e===0))).filter((e,t,n)=>{return e.length&&!(t&&(i=e,o=n[t-1],i.length===o.length&&i.every((e,t)=>+e===+o[t])));var i,o}),r=a.filter(e=>e.length<=n),s=r.length?r:a.slice(-1);return s.length?s.flatMap(t=>t.length>1?[[e[0],...t],t]:[[e[0],...t]]):[[e[0]]]}function xv(e){const t=new Map(e.map((e,t)=>[+e,t])),n=(n,i)=>{const o=t.get(+n);return Boolean(o)&&gv(e[o],i)!==gv(e[o-1],i)},i=new WeakMap;return function(e){if(!(e instanceof Date))return String(e);const t=this?Cn(this):void 0;if(!t?.length)return pv(e);let o,a=i.get(t);a||i.set(t,a=function(e,t){return dv.slice().reverse().find(n=>e.slice(1).every(e=>t(e,n)))??"day"}(t,n));for(const n of t)+n<+e&&(o=n);return function(e,t,n){const i=!t||t.getFullYear()!==e.getFullYear();return"year"===n?g.timeFormat("%Y")(e):"day"===n||"week"===n?g.timeFormat(i?"%b %-d, %Y":"%b %-d")(e):t?g.timeFormat(i?"%Y":"%b")(e):g.timeFormat("%b %Y")(e)}(e,o,a)}}function bv(e){const t=function(e){const t=e._filteredData||[],n=new Map;return t.forEach((t,i)=>{const o=e._x?e._x(t,i):void 0;o instanceof Date&&!isNaN(+o)&&!n.has(+o)&&n.set(+o,o)}),Array.from(n.values()).sort((e,t)=>+e-+t)}(e);return{labels:yv(t,(e.schema.width-e._margin.left-e._margin.right-60)/72),tickFormat:xv(t)}}const _v={height:.2,gap:16,axisConfig:{},shapeConfig:{fillOpacity:.5}};function kv(e){return null==e||!1===e?void 0:qk(e)}const vv=e=>"function"==typeof e.schema.volume;function wv(e){const t=e.schema.volumeConfig??{};return{..._v,...t}}function Sv(e,t,n){return vv(e)?Pk(cv(e,"volume")(t,n)):void 0}function Cv(e,t){if(!(t>0))return{height:0,gap:0};const n=Number(e.height),i=Number.isFinite(n)&&n>0?n:_v.height,o=Math.min(i<=1?i*t:i,.5*t),a=Math.max(0,Number.isFinite(Number(e.gap))?Number(e.gap):_v.gap);return{height:Math.round(o),gap:a}}function Mv(e){const t=s.scaleLinear().domain([0,e>0?e:1]).nice(2);return{domain:t.domain(),ticks:t.ticks(2)}}function $v(e,t){return h.max(t,(t,n)=>Sv(e,t,n))??0}const Av=new WeakMap;function zv(e){return"panel"===e._facetStep&&e._plotFacetScales?Av.get(e)??0:$v(e,e._filteredData||[])}function Dv(e){const t=e._yConfig?.labels;return!(Array.isArray(t)&&!t.length)}function Fv(e,t){return d.formatAbbreviate(t,e.schema.locale)}function Bv(e,t){const{domain:n,ticks:i}=Mv(zv(e)),o=Dv(e);return(new di).renderMode("compute").select(null).config(Jp(e,{locale:e.schema.locale,scale:"linear",domain:[n[1],n[0]],range:t,ticks:i,labels:o?i.filter(e=>e>0):[],tickFormat:t=>Fv(e,t),gridSize:0,rounding:"none",title:!1,height:t[1],width:t[1]})).config(wv(e).axisConfig)}function Lv(e){e._plotInsetBottom=t=>{if(!vv(e))return 0;const{height:n,gap:i}=Cv(wv(e),t);return n?n+i:0},e._plotMinLeft=()=>vv(e)&&Dv(e)?function(e){const t=e.outerBounds();return t.width?t.width+e.padding():0}(Bv(e,[0,100]).measure()):0}function Pv(e){const t=e.insetBottom??0;if(!(t>0))return;const n=e.yRange[1]-(e.x2Height??0),{gap:i}=wv(e.viz);return{top:n+Math.min(i,t),bottom:n+t,left:e.xRange[0],right:e.xRange[e.xRange.length-1]}}const Rv=e=>"path"===e.type||String(e.key).endsWith("::hit");function Ev(e,t,n,i,o){const{viz:a}=e,r=Pv(e);if(!r||!t.size)return[];const{domain:s}=Mv(zv(a)),c=r.bottom-r.top,l=new Map;t.forEach(({cx:e,width:t},n)=>{const i=Sv(a,n.data,n.i);if(void 0===i||i<0)return;const o=Math.min(c,i/s[1]*c);l.set(n,{cx:e,width:t,top:r.bottom-o})});const h=wv(a),u=eu("Path").renderMode("compute").config(au(a,i)).config(n).config(Ae.bind(a)(h.shapeConfig)).config({d:e=>{const{cx:t,width:n,top:i}=l.get(e),o=n/2;return`M${t-o},${i}H${t+o}V${r.bottom}H${t-o}Z`},hitArea:e=>{const{cx:t,width:n}=l.get(e),i=Math.max(n,6);return{x:t-i/2,y:r.top,width:i,height:c}},id:e=>`${e.id}_${e.discrete}_volume`,label:!1,x:0,y:0}),d=u.schema.fill,f=u.schema.texture;u.config({texture:(e,t)=>o(f(e,t),d(e,t))}).data(Array.from(l.keys())),a._wirePlotShapeEvents(u,i,e.events);const m=su(u).map(e=>{const n=e.datum,o=n&&Rv(e)?{interactionPoints:t.get(n)?.interactionPoints}:{};return{...e,shapeType:i,...o}}),p=Bv(a,[r.top,r.bottom]);p.render();const g=p.toScene();return[...m,Tv({...g,key:"candlestick-volume-axis",transform:{x:r.left-Nv(p,g),y:0}})]}function Nv(e,t){const n=(t.children||[]).find(e=>"bar"===e.key&&"line"===e.type),i=n?.points?.[0]?.[0];if(Number.isFinite(i))return i;const o=e.outerBounds();return o.x+o.width}function Tv(e){const t=e.children;return{...e,interactionGroup:"axis",...t?{children:t.map(Tv)}:{}}}function Ov(e,t){if(Math.abs(e)<1)return d.formatAbbreviate(e,t,".3~g");const n=d.formatAbbreviate(1.5,t,".1f").charAt(1),[i,o=""]=d.formatAbbreviate(e,t,",.2f").split(n);return`${i}${n}${o.padEnd(2,"0")}`}function Wv(e,t){return`${e>0?"+":""}${d.formatAbbreviate(100*e,t,".2f")}%`}function jv(e,t,n){const i=e._x?e._x(t,n):void 0,o=e._xConfig?.tickFormat,a=mv(i);return"function"==typeof o?String(o(a)):a instanceof Date?pv(a):String(i??"")}function Hv(e,t,n){const i=Rk(t,n,lv(e));if(!i)return[];const o=t=>e.schema.translate(t),a=function(e){const t=e._yConfig?.tickFormat;return"function"==typeof t?e=>String(t(e)):t=>Ov(t,e.schema.locale)}(e),r=[[kg(e,"x"),jv(e,t,n)],[o("Open"),a(i.open)],[o("High"),a(i.high)],[o("Low"),a(i.low)],[o("Close"),a(i.close)]],s=Nk(i.open,i.close);void 0!==s&&r.push([o("Change"),Wv(s,e.schema.locale)]);const c=Sv(e,t,n);return void 0!==c&&r.push([o("Volume"),Fv(e,c)]),r}function Iv(e,t,n){const[i,...o]=Hv(e,t,n);return`${Vv(e,t,n,i?.[1])}: ${o.map(([e,t])=>`${e} ${t}`).join(", ")}.`}function Gv(e,t,n){const i=Sv(e,t,n),o=void 0===i?"":` ${Fv(e,i)}`;return`${Vv(e,t,n,jv(e,t,n))}: ${e.schema.translate("Volume")}${o}.`}function Vv(e,t,n,i){return[e._drawLabel(t,n),i].filter(e=>void 0!==e&&""!==e).join(", ")}const qv="Candlestick",Yv=(e,t)=>"function"==typeof e?e(t.data,t.i):e;function Kv(e,t,n,i,o){const a=lv(e),r=e.schema.variant,s=Math.min(Math.abs(o[o.length-1]-o[0]),40),c=t.map(e=>n(e.x)),l=Wk(Ok(c,s),Number(e.schema.bodyWidth)),h=l>=2?2*Math.round(l/2):l,u=new Map;return t.forEach((e,t)=>{const n=Rk(e.data,e.i,a);if(!n||!Number.isFinite(c[t]))return;const o={open:jk(i(n.open)),high:jk(i(n.high)),low:jk(i(n.low)),close:jk(i(n.close))};if(![o.open,o.high,o.low,o.close].every(Number.isFinite))return;const s=jk(c[t]);u.set(e,{cx:s,width:h,px:o,direction:Ek(n.open,n.close),d:"ohlc"===r?Ik(s,h,o):Hk(s,h,o)})}),u}function Uv(e,t){if(!e)return e;const n="string"==typeof t?l.color(t):null;if(!n)return e;const i="object"==typeof e?{...e}:{texture:e};return i.stroke||(i.stroke=n.darker(1).formatHex()),i}const Xv=e=>{const{viz:t,x:n,y:i,xRange:o}=e,a=e.values,r=Kv(t,a,n,i,o);if(!r.size)return[];const s=e=>r.get(e),c=t.schema.shapeConfig[qv],l=eu("Path").renderMode("compute").config(au(t,qv)).config(function(e,t){const n=n=>Yv("up"===t(n).direction?e.schema.upColor:e.schema.downColor,n);return{fill:i=>{const{direction:o}=t(i);return"ohlc"===e.schema.variant||"up"===o&&e.schema.hollow?"none":n(i)},stroke:n,strokeWidth:1,strokeLinecap:"butt"}}(t,s)).config(c?Ae.bind(t)(c):{}).config({ariaLabel:e=>Iv(t,e.data,e.i),d:e=>s(e).d,hitArea:e=>{const{cx:t,width:n,px:i}=s(e),o=Math.max(n,6);return{x:t-o/2,y:i.high-2,width:o,height:i.low-i.high+4}},id:e=>`${e.id}_${e.discrete}`,label:!1,x:0,y:0}),h=l.schema.fill,u=l.schema.backgroundImage,d=l.schema.texture;l.config({backgroundImage:(e,t)=>"none"!==h(e,t)&&u(e,t),texture:(e,t)=>Uv(d(e,t),h(e,t))}).data(Array.from(r.keys())),t._wirePlotShapeEvents(l,qv,e.events);const f=(e,t)=>[{x:t.cx,y:t.px.close,datum:e,index:e.i}],m=su(l).map(e=>{const t=e.datum,n=t&&r.get(t),i=n&&Rv(e)?{interactionPoints:f(t,n)}:{};return{...e,shapeType:qv,...i}});if(!vv(t)||!Pv(e))return m;const p=new Map;r.forEach((e,t)=>p.set(t,{cx:e.cx,width:e.width,interactionPoints:f(t,e)}));const g=Ev(e,p,function(e,t){return{ariaLabel:t=>Gv(e,t.data,t.i),fill:n=>Yv("up"===t(n).direction?e.schema.upColor:e.schema.downColor,n),stroke:"none",strokeWidth:0}}(t,s),qv,Uv),y=e.yRange[0]-(e.x2Height??0);return[{type:"group",key:"candlestick-price",clip:{type:"rect",x:o[0],y:y,width:o[o.length-1]-o[0],height:e.yRange[1]-e.yRange[0]},children:m},...g]};const Qv=e=>e.ctx.candlestick;function Zv(e){const t=Qv(e),n=cv(e,"close");Object.defineProperty(e,"_x",{configurable:!0,enumerable:!0,get:()=>e.schema.skipGaps?t.xDate:t.x,set:e=>{e!==t.xDate&&e!==t.x&&(t.x=e)}}),Object.defineProperty(e,"_y",{configurable:!0,enumerable:!0,get:()=>n,set:t=>{t!==n&&(e.schema.close=t)}}),Object.defineProperty(e,"_yKey",{configurable:!0,enumerable:!0,get:()=>t.yKey??e.schema.translate("Close"),set:n=>{t.yKey="y"===n?void 0:n,void 0!==t.yKey&&"function"==typeof e.schema.close&&function(e,t){Vk.set(e,t)}(e.schema.close,n)}})}const Jv={name:"Candlestick",paintDriven:!0,facet:{aspect:16/9},setup:e=>{const t=T("date");e.ctx.candlestick={x:t,xDate:(t,n)=>mv(Qv(e).x(t,n))},e._xKey="date",Zv(e),function(e){const t=new WeakMap;sv.set(e,t),e._mergeRows=n=>{const i=o.merge(n,e.schema.aggs);if(n.length>1){const o=av(n,rv(e),e.schema.aggs);o&&t.set(i,o)}return i}}(e),Lv(e),e._buffer={...e._buffer,[qv]:uv},e._plotShapeEmitters={[qv]:Xv},e._plotColumnHighlight=Lk(e),e._tooltipAxisRows=!1,e._yTitle=null;const n=e._preDraw.bind(e);e._preDraw=()=>{!function(e){const t=Qv(e),n=e.schema.time;void 0!==n&&n!==t.time||(t.time=e.schema.skipGaps?void 0:(t,n)=>e._x(t,n),e.schema.time=t.time)}(e),function(e){ov(e.schema.aggs,rv(e))}(e),n()};const i=e._draw.bind(e);e._draw=t=>(e._plotAxisDefaults=e.schema.skipGaps?{x:bv(e)}:void 0,"chrome"===e._facetStep&&function(e){Av.set(e,$v(e,e._filteredData||[]))}(e),i(t))},ctx:{},fields:[{key:"open",coerce:qk,factory:()=>Yk("open")},{key:"high",coerce:qk,factory:()=>Yk("high")},{key:"low",coerce:qk,factory:()=>Yk("low")},{key:"close",coerce:qk,factory:()=>Yk("close")},{key:"volume",coerce:kv},{key:"volumeConfig",merge:!0,default:_v},{key:"variant",default:"candlestick"},{key:"upColor",default:"#2f9e44"},{key:"downColor",default:"#e03131"},{key:"hollow",default:!0},{key:"bodyWidth",default:.7},{key:"skipGaps",default:!0},{key:"discrete",default:"x"},{key:"legend",default:!1,coerce:"const"},{key:"shape",default:N(qv),coerce:"const"},{key:"timeline",default:!1},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>Hv(e,t,n)})}]};var ew=xf(Jv,_b);const tw=({viz:e})=>{const t=e,{width:n,height:i}=ie(t),o=Array.isArray(t.schema.nodes)&&t.schema.nodes.length>0,a=Array.isArray(t.schema.links)&&t.schema.links.length>0;if(!o&&!a)return t.ctx.nodeLookup={},t.ctx.adjacency={},{viz:e};const r=(o?t.schema.nodes:function(e,t,n){const i=new Set,o=[];for(const a of e){const e=a[t];i.has(e)||(i.add(e),o.push(e));const r=a[n];i.has(r)||(i.add(r),o.push(r))}return o.map(e=>({id:e}))}(t.schema.links,t.schema.linksSource,t.schema.linksTarget)).map((e,n)=>({__d3plus__:!0,data:e,node:e,i:n,id:t.schema.nodeId(e,n),shape:"Path"})),s={};r.forEach((e,t)=>{s[String(e.id)]=t}),t.ctx.nodeLookup=s;const c=r.length,l=Array.from({length:c},()=>new Array(c).fill(0)),u={},d=(e,t)=>{var n,i;((n=u)[i=String(e)]??(n[i]=[])).push(t)};t.schema.links.forEach((e,n)=>{const i=s[String(e[t.schema.linksSource])],o=s[String(e[t.schema.linksTarget])];null!=i&&null!=o&&(l[i][o]+=t.schema.value(e,n)||0,d(r[i].id,r[o].id),d(r[o].id,r[i].id))}),t.ctx.adjacency=u;const f=Math.min(n,i)/2,m=Math.min(.28*f,90),p=Math.max(0,f-m),g=Math.min(t.schema.arcThickness,p),x=Math.max(0,p-g),b=null!=t.schema.padAngle?t.schema.padAngle:t.schema.padPixel/(p||1),_=(t.schema.directed?v.chordDirected():v.chord()).padAngle(b).sortSubgroups(h.descending)(l);_.groups.forEach(e=>{const t=r[e.index];t&&(t.group=e)});const k=y.arc().innerRadius(x).outerRadius(p),w=t.schema.arrows,S="function"==typeof w||!!w&&"source"!==w,C="number"==typeof t.schema.arrowSize?t.schema.arrowSize:void 0;let M;if(S){const e=v.ribbonArrow().radius(x).headRadius(C??Math.max(10,.75*g));M=t=>e(t)??""}else{const e=v.ribbon().radius(x);M=t=>e(t)??""}return function(e,t,n){e.forEach(e=>{const i=e.group;if(!i)return;const o=(i.startAngle+i.endAngle)/2,a=o-Math.PI/2;e.labelX=Math.cos(a)*t,e.labelY=Math.sin(a)*t;let r=180*o/Math.PI-90;o>Math.PI?(r+=180,e.labelBounds={x:-(n+4),y:-7.5,width:n,height:15},e.labelAnchor="end"):(e.labelBounds={x:4,y:-7.5,width:n,height:15},e.labelAnchor="start"),e.labelRotate=r})}(r,p,m),t.ctx.chordCtx={nodes:r,chords:_,arcFn:e=>k(e)??"",ribbonFn:M},t.ctx.chordWidth=n,t.ctx.chordHeight=i,{shapeData:r}},nw={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",rotate(e){const t=e.r??e.data?.r;return"number"==typeof t?t:0},rotateAnchor(e){const t=e.rotateAnchor??e.data?.rotateAnchor;return Array.isArray(t)?t:[(e.w??0)/2,(e.h??0)/2]},fontColor(e,t){const n="function"==typeof this._fill?this._fill(e,t):this._fill;return"string"==typeof n?r.colorContrast(n):"black"}};function iw(e){const t=$o(e);if(!t.length)return[];const n=(new ro).config({...nw,...e.labelConfig??{}}).data(t).renderMode("compute");try{const e=n.toScene();return Array.isArray(e?.children)?e.children:[]}catch{return[]}}function ow(e){return arguments.length?(this._hover=e,this.schema.legend&&this._legendClass&&this._legendClass.hover(e),this._sceneRenderer&&this._scheduleSceneRepaint(),dt(this,"hover",e),this):this._hover}const aw={name:"Chord",layoutStage:tw,emit:({viz:e})=>{const t=e.ctx.chordCtx;if(!t)return[];const n=[],i=au(e,"Path"),o=e.schema.chordOpacity??.6;n.push(...function(e,t,n,i){const o=[],a=[];for(let r=0;r<t.chords.length;r++){const s=t.chords[r],c=t.nodes[s.source.index],l=t.nodes[s.target.index];if(!c||!l)continue;const h=tu(n.fill,c.data,c.i),u="string"==typeof h?h:void 0,d=tu(n.opacity,c.data,c.i),f={type:"path",shapeType:"Chord",key:`chord-ribbon-${c.id}-${l.id}`,d:t.ribbonFn(s),datum:{source:{id:c.id},target:{id:l.id},value:s.source.value},index:r,paint:{fill:nu(n,c.data,c.i,h),fillOpacity:i,stroke:u,strokeOpacity:1,opacity:"number"==typeof d?d:1},aria:{label:`${e._drawLabel(c.data,c.i)} to ${e._drawLabel(l.data,l.i)}, ${s.source.value}.`}};o.push(f);const m=Vy(n,{...f,paint:{...f.paint,opacity:(f.paint?.opacity??1)*i}},c.data,c.i);m&&a.push(m)}return[...o,...a]}(e,t,i,o));const a=[],r=t.nodes.filter(e=>Boolean(e.group));for(const n of r){const o=iu(i,n.data,n.i);a.push({type:"path",key:`chord-arc-${n.id}`,d:t.arcFn(n.group),datum:n.data,index:n.i,paint:o,aria:{label:`${e._drawLabel(n.data,n.i)}, ${n.group.value}.`}})}if(n.push(...a,...qy(i,a,e=>[r[e].data,r[e].i])),r.length){const t=iw({data:r,label:t=>{const n=t;return e._drawLabel(n.data,n.i)},x:e=>e.labelX??0,y:e=>e.labelY??0,aes:()=>({}),rotate:e=>e.labelRotate??0,id:e=>`chord-label-${e.id}`,labelBounds:e=>e.labelBounds??!1,labelConfig:{...ru(e,"Path"),fontResize:!1,padding:0,textAnchor:e=>(e.data??e).labelAnchor??"start",verticalAlign:"middle"}});n.push(...t)}return n},chartTransform:e=>oe(e,e.ctx.chordWidth,e.ctx.chordHeight),chartBodyRect:e=>{const t=e.ctx.chordWidth??0,n=e.ctx.chordHeight??0;return{x:-t/2,y:-n/2,width:t,height:n}},setup:e=>{const t=e;e.schema.color=(t,n)=>e.schema.groupBy[0](t,n)??e.schema.nodeId(t,n),e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,o,a,r)=>{if(n(i,o,a,r),e._focus&&e._focus===i.id)return t.hover(!1),e.schema.on.mouseenter.bind(e)(i,o,a,r),void(e._focus=void 0);const s=i;if(s.source&&s.target){const n=s.source.id,i=s.target.id;return void t.hover((t,o)=>{if(t.source&&t.target)return t.source.id===n&&t.target.id===i;const a=e.schema.nodeId(t,o);return a===n||a===i})}const c=e.schema.nodeId(i,o),l=e.ctx.adjacency[String(c)]??[],h=[c,...l];t.hover((t,n)=>t.source&&t.target?t.source.id===c||t.target.id===c:h.includes(e.schema.nodeId(t,n)))},t.links=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:Be(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:Be(e),this):this.schema.value},t.hover=ow},facet:{aspect:1},ctx:{},fields:[{key:"arcThickness",default:20},{key:"arrows",default:!1},{key:"arrowSize"},{key:"chordOpacity",default:.6},{key:"directed",default:!0},{key:"links",default:T("links")},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:T("nodes")},{key:"nodeId",default:T("id")},{key:"padAngle"},{key:"padPixel",default:2},{key:"value",default:N(1)},{key:"shape",default:N("Path"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>({Path:{label:!1}})},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})}]};var rw=xf(aw);function sw(e,t){return[()=>e.schema.translate("Share"),(n,i,o)=>{const a=t=>`${d.formatAbbreviate(100*t,e.schema.locale)}%`;if(o._isColorScaleBucket){const n=Pa(e,o.color,e.schema[t]);return null==n?"":a(n)}const r=Cr(o);return Number.isFinite(r)?a(r):""}]}function cw(e,t=()=>!0){const n=e.schema.legend;return(i,o)=>(o.length!==e._filteredData.length||!t(e))&&n.call(e,i,o)}const lw=({viz:e})=>{const{width:t,height:n}=ie(e),i=e.schema.shapeConfig??{},o=3*("number"==typeof i.strokeWidth?i.strokeWidth:2)/2,a=Math.max(0,Math.min(t,n)/2-o),r=e.ctx.pie,s=e.schema.padAngle??0,c=e.schema.padPixel??0,l=e.schema.sort,h=e.schema.value,u=r.padAngle(s||c/a).sort(l).value(h)(e._filteredData),d=u.reduce((e,t)=>e+t.value,0);u.forEach((e,t)=>{e.__d3plus__=!0,e.i=t;const n=d?e.value/d:0;e.share=n,wr(e.data,n)});const f=e.schema.innerRadius;return e.ctx.arcData=L.arc().innerRadius("function"==typeof f?f:()=>f).outerRadius(a),e.ctx.pieData=u,e.ctx.pieWidth=t,e.ctx.pieHeight=n,e.ctx.pieOuterRadius=a,{shapeData:u}};const hw={name:"Pie",layoutStage:lw,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const o=e.ctx.arcData,a=e=>o(e)??"",s=o.innerRadius(),c=o.outerRadius(),l=au(e,"Path"),h=e._pendingEnterOrigin,u=h?.parentStartAngle,m=h?.parentEndAngle,p=void 0!==u&&void 0!==m?{start:u,span:m-u}:void 0,g=Boolean(e._pendingExitReunion),y=e.schema.value,x=e.schema.locale,b=e=>`${d.formatAbbreviate(100*(e.share??0),x)}%`,_={viz:e,arcMaker:a,resolveInnerRadius:s,resolveOuterRadius:c,sc:l,value:y,sharePct:b,flipSource:p,isReunionDraw:g},k=n.map((e,t)=>function(e,t,n){const{viz:o,arcMaker:a,resolveInnerRadius:r,resolveOuterRadius:s,sc:c,value:l,sharePct:h,flipSource:u,isReunionDraw:d}=n,f=tu(c.fill,e.data,e.i??0),m=tu(c.stroke,e.data,e.i??0),p=tu(c.strokeWidth,e.data,e.i??0),g={innerRadius:r(e,e.i??0),outerRadius:s(e,e.i??0),startAngle:e.startAngle,endAngle:e.endAngle,padAngle:e.padAngle},y=u?{...g,startAngle:u.start+e.startAngle/i.FULL_TURN*u.span,endAngle:u.start+e.endAngle/i.FULL_TURN*u.span}:void 0,x=d?{...g,startAngle:0,endAngle:i.FULL_TURN}:void 0;return{type:"path",key:`pie-${o._ids(e.data,e.i??0).join("-")}`,d:a(e),arc:g,flipFromArc:y,reunionFromArc:x,shapeType:"Pie",transform:{x:0,y:0},startAngle:e.startAngle,endAngle:e.endAngle,datum:e.data,paint:{fill:nu(c,e.data,e.i??0,f),stroke:m,strokeWidth:p,opacity:1},aria:{label:`${t+1}. ${o._drawLabel(e.data,e.i??0)}, ${l(e.data,e.i??0)}, ${h(e)}.`}}}(e,t,_)),v=n.map(e=>{const t=f.largestRect(f.path2polygon(a(e)),{angle:0,nTries:40});if(!t)return!1;const n=t.cx-t.width/2,i=t.cy-t.height/2;if(t.height<50)return[{angle:t.angle,width:t.width,height:t.height,x:n,y:i}];const o=Math.min(32,.3*(t.height-10))+10;return[{angle:t.angle,width:t.width,height:t.height-o,x:n,y:i},{angle:t.angle,width:t.width,height:o,x:n,y:i+t.height-o}]}),w=iw({data:n,label:(t,i)=>{const o=e._drawLabel(n[i].data,n[i].i??i),a=v[i];return a&&a.length>1?[o,b(n[i])]:[o]},x:()=>0,y:()=>0,aes:()=>({}),rotate:N(0),id:(e,t)=>`pie-label-${t}`,labelBounds:(e,t)=>v[t],labelConfig:{fontColor:t=>{const n=t.data??t,i=tu(l.fill,n.data,n.i??0);return r.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)",e.schema.colorDefaults)},fontResize:!0,textAnchor:"middle",verticalAlign:e=>{if(e&&1===e.l)return"top";const t=!(!e||!e.data)&&v[n.indexOf(e.data)];return t&&t.length>1?"bottom":"middle"},...ru(e,"Path")}});!function(e,t){for(const n of e){const e=n;if(e.shapeType="Label",!t)continue;const o=e.transform??{},a=o.x??0,r=o.y??0,s=Math.hypot(a,r),c=Math.atan2(a,-r),l=c<0?c+i.FULL_TURN:c,h=t.start+l/i.FULL_TURN*t.span;e.flipFromTransform={x:s*Math.sin(h),y:-s*Math.cos(h)}}}(w,p);const S=qy(l,k,e=>[n[e].data,n[e].i??0]);return[...k,...S,...w]},insetRegion:Uu,chartTransform:e=>oe(e,e.ctx.pieWidth,e.ctx.pieHeight),chartBodyRect:e=>{const t=e.ctx.pieOuterRadius??0;return{x:-t,y:-t,width:2*t,height:2*t}},facet:{aspect:1},ctx:{pie:y.pie()},fields:[{key:"innerRadius",default:0},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"sort",factory:e=>{const t=e.schema.value;return(e,n)=>t(n)-t(e)}},{key:"legendSort",factory:e=>{const t=e.schema.value;return(e,n)=>t(n)-t(e)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e.ctx.pieData;return i?`${++i[n].index}. ${e._drawLabel(t,n)}, ${e.schema.value(t,n)}.`:""},Path:{labelConfig:{fontResize:!0}},stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:2})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"value")]})},{key:"legend",coerce:"const",factory:cw}]};var uw=xf(hw);var dw=xf({name:"Donut",emit:hw.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:e=>()=>{const{width:t,height:n}=ie(e);return(h.min([t,n])??0)/4}}]},uw);const fw="::connector";function mw(e,t){const n="x"===t?"y":"x",i=new Map;for(const o of e){const e=`${o[t]}`;let a=i.get(e);a||i.set(e,a={});const r=o[n];f.finite(r)&&((!a.lo||r<a.lo[n])&&(a.lo=o),(!a.hi||r>a.hi[n])&&(a.hi=o))}const o=[];return i.forEach(({lo:e,hi:t},i)=>{e&&t&&e!==t&&e[n]!==t[n]&&o.push({category:i,lo:e,hi:t})}),o}function pw(e){const t={...e,interactive:!1};return delete t.datum,t}function gw(e){const{viz:t}=e,n="x"===t.schema.discrete?"x":"y",i=mw(e.values,n);if(!i.length)return[];const o=i.flatMap(({category:e,lo:t,hi:n})=>[{__d3plus__:!0,data:t,i:t.i,category:e},{__d3plus__:!0,data:n,i:n.i,category:e}]),a=t=>{const n=e.shapeConfig[t];return e=>n(e.data,e.data.i)},r=eu("Line").renderMode("compute").config(e.shapeConfig).data(o),s=au(t,"Line");return void 0===t.schema.shapeConfig.duration&&delete s.duration,r.config(s).config({curve:"linear",hitArea:!1,id:e=>`${e.category}${fw}`,label:!1,x:a("x"),y:a("y")}),su(r).map(pw)}const yw=(e,t)=>{const n=de({...e.shapeConfig,id:e=>`${e.id}_${e.discrete}`});return[...gw(e),...ux.Circle({...e,shapeConfig:n},t)]};function xw(e,t,n){const i=new Map;e.forEach((e,o)=>{const a=`${t(e,o)}`,r=n(e,o),s=i.get(a);f.finite(r)?s&&f.finite(s[0])?i.set(a,[Math.min(s[0],r),Math.max(s[1],r)]):i.set(a,[r,r]):s||i.set(a,[NaN,NaN])});const o=new Map;return i.forEach(([e,t],n)=>o.set(n,f.finite(e)?t-e:0)),o}function bw(e,t,n){const i=t=>e().get(`${n(t)}`)??0;return(e,n)=>"ascending"===t?i(e)-i(n):i(n)-i(e)}function _w(e,t){t.axis&&t.sort&&e.schema[`${t.axis}Sort`]===t.sort&&(e.schema[`${t.axis}Sort`]=void 0),t.axis=t.sort=void 0;const n=e.schema.gapSort;if("ascending"!==n&&"descending"!==n)return;const i="x"===e.schema.discrete?"x":"y";if(e.schema[`${i}Sort`])return;const o=e[`_${i}`],a=e["_"+("x"===i?"y":"x")],r=new WeakMap,s="y"===i?"ascending"===n?"descending":"ascending":n;t.axis=i,t.sort=e.schema[`${i}Sort`]=bw(()=>{const t=e._filteredData||[];let n=r.get(t);return n||r.set(t,n=xw(t,o,a)),n},s,e=>o(e,0))}function kw(e){const t=e._select&&"function"==typeof e._select.node?e._select.node():null,i=t?n.backgroundColor(t):"rgb(255, 255, 255)";return r.colorContrast(i,e.schema.colorDefaults)===e.schema.colorDefaults.dark?r.colorGray[500]:r.colorGray[700]}const vw={name:"Dumbbell",paintDriven:!0,setup:e=>{const t={};e.ctx.dumbbell=t,e._plotShapeEmitters={Circle:yw},e._plotColumnHighlight=Lk(e);const n=e._preDraw.bind(e);e._preDraw=()=>{_w(e,t),n()}},ctx:{},fields:[{key:"discrete",default:"y"},{key:"gapSort",default:!1},{key:"shapeConfig",merge:!0,factory:e=>({Circle:{label:!1,trail:!1},Line:{label:!1,stroke:()=>kw(e),strokeWidth:3}})}]};var ww=xf(vw,_b);var Sw=xf({name:"LinePlot",paintDriven:!0,ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:N("Line"),coerce:"const"}]},_b);const Cw={name:"FanChart",paintDriven:!0,ctx:{},fields:[{key:"forecast",default:"auto"}]};var Mw=xf(Cw,Sw);function $w(e,t,n){if(e<=0||!(t>0))return[];const i=e>1?Math.min(.95,Math.max(0,n||0)):0,o=t/(e-i),a=o*(1-i);return Array.from({length:e},(e,t)=>({start:t*o,end:t*o+a}))}function Aw(e){return Number.isFinite(e)&&e>0?e:0}function zw(e){return e.reduce((e,t)=>Math.max(e,Aw(t)),0)}function Dw(e,t,n=0){const i=Math.max(zw(e),Aw(n));return e.map(e=>i>0?Aw(e)/i*t:0)}function Fw(e){const t=e.length;if(t<2)return e.map(()=>0);const n=[];for(let i=0;i<t-1;i++){const t=e[i+1].s-e[i].s;n.push(t>0?(e[i+1].w-e[i].w)/t:0)}const i=e.map((e,i)=>{if(0===i)return n[0];if(i===t-1)return n[t-2];const o=n[i-1],a=n[i];return o*a<=0?0:(o+a)/2});for(let e=0;e<t-1;e++){const t=n[e];if(0===t){i[e]=0,i[e+1]=0;continue}const o=i[e]/t,a=i[e+1]/t,r=o*o+a*a;if(r>9){const n=3/Math.sqrt(r);i[e]=n*o*t,i[e+1]=n*a*t}}return i}function Bw(e,t,n){if(!e.length)return[];if(!n)return e.flatMap((e,n)=>[{s:e.start,w:t[n],m:0},{s:e.end,w:t[n],m:0}]);const i=e.length-1,o=e.map((e,n)=>({s:e.start,w:t[n]}));o.push({s:e[i].end,w:t[i]});const a=Fw(o);return o.map((e,t)=>({...e,m:a[t]}))}function Lw(e,t,n,i){const o=t.s-e.s;if(!(o>0))return e.w;const a=Math.min(1,Math.max(0,(n-e.s)/o));if("smooth"!==i)return e.w+(t.w-e.w)*a;const r=a*a,s=r*a;return(2*s-3*r+1)*e.w+(s-2*r+a)*o*e.m+(-2*s+3*r)*t.w+(s-r)*o*t.m}function Pw(e,t){return e.w===t.w&&0===e.m&&0===t.m}function Rw(e,t,n,i,o=12){const a=[];if(!(n>t))return a;for(let r=0;r<e.length-1;r++){const s=e[r],c=e[r+1],l=Math.max(t,s.s),h=Math.min(n,c.s);if(!(h>l&&c.s>s.s))continue;const u="smooth"!==i||Pw(s,c)?1:Math.max(1,Math.ceil(o*(h-l)/(c.s-s.s)));for(let e=0;e<=u;e++){const t=l+(h-l)*e/u,n=Lw(s,c,t,i),o=a[a.length-1];o&&o[0]===t&&o[1]===n||a.push([t,n])}}return a}const Ew=e=>Math.round(100*e)/100;function Nw(e,t,n){if(e.length<2)return"";const i=(e,t)=>"horizontal"===n?`${Ew(e)},${Ew(t)}`:`${Ew(t)},${Ew(e)}`,o=e.map(([e,n])=>i(e,t-n/2)),a=e.slice().reverse().map(([e,n])=>i(e,t+n/2));return`M${o.join("L")}L${a.join("L")}Z`}function Tw(e){if(!e.length)return{min:0,max:0};const t=e.map(e=>e[1]);return{min:Math.min(...t),max:Math.max(...t)}}function Ow(e){const t=(e,t)=>Number.isFinite(e)&&Number.isFinite(t)&&0!==t?e/t:NaN;return{first:e.map(n=>t(n,e[0])),previous:e.map((n,i)=>i?t(n,e[i-1]):NaN)}}function Ww(e){var t;return(t=e.ctx).funnelRates??(t.funnelRates=new WeakMap)}function jw(e,t){const n=e.schema.sort;return"function"==typeof n?t.slice().sort(n):t}function Hw(e){const t=Number(e.ctx.funnelScaleMax);return Number.isFinite(t)&&t>0?t:0}function Iw(e){return"horizontal"===e.schema.orient?"horizontal":"vertical"}function Gw(e){return"smooth"===e.schema.curve?"smooth":"linear"}function Vw(e,t,{width:n,height:i},o){const a=Iw(e),r=Gw(e),s=e.schema.value,c=t.map((e,t)=>Number(s(e,t))),l="vertical"===a,h=Math.max(0,(l?i:n)-4),u=Math.max(0,(l?n:i)-4),d=$w(t.length,h,Number(e.schema.stagePadding)).map(e=>({start:e.start+2,end:e.end+2})),f=Dw(c,u,o),m=Bw(d,f,!!e.schema.taper),p=Ow(c);return{stages:t.map((e,t)=>{const n=d[t],i=Rw(m,n.start,n.end,r),o=t?Rw(m,d[t-1].end,n.start,r):[];return{__d3plus__:!0,data:e,i:t,value:c[t],first:p.first[t],previous:p.previous[t],start:n.start,end:n.end,points:i,neck:o,...Tw(i)}}),shared:{orient:a,curve:r,center:(l?n:i)/2,breadth:u,offset:2}}}const qw=({viz:e})=>{const t=jw(e,e._filteredData??[]),{stages:n,shared:i}=Vw(e,t,ie(e),Hw(e)),o=Ww(e);for(const e of n)o.set(e.data,{first:e.first,previous:e.previous});return e.ctx.funnel=i,{shapeData:n}};function Yw(e){return!0===e||"both"===e?["first","previous"]:"first"===e||"previous"===e?[e]:Array.isArray(e)?["first","previous"].filter(t=>e.includes(t)):[]}function Kw(e,t,n,i){const{fontMax:o,padding:a,lineHeight:r}=i,s=t.width-2*a,c=t.height-2*a;if(!(e.length&&s>0&&c>0))return 0;const l=Math.max(...e.map(e=>n(e,o))),h=c/(e.length*r),u=l>0?s/l*o:o,d=Math.min(o,h,u);return Math.floor(2*d)/2}function Uw(e,t,n,i,o){for(let a=e.length;a>0;a--){const r=e.slice(0,a),s=Kw(r,t,i,o),c=n?Kw(r,n,i,o):0;if(s>=o.fontMin&&s>=.8*c)return{position:"inside",fontSize:s,lines:r};if(c>=o.fontMin)return{position:"outside",fontSize:c,lines:r}}return null}function Xw(e,t,n,i=1/0){const o=e.map(e=>Uw(e.lines,e.inside,e.outside,t,e.fixed?{...n,fontMin:e.fixed,fontMax:e.fixed}:n)),a=o.flatMap((t,n)=>t&&!e[n].fixed?[n]:[]);if(!a.length)return{plans:o,fontSize:0};const r=Math.min(i,...a.map(e=>o[e].fontSize));for(const i of a){const a=o[i],s="inside"===a.position||Kw(a.lines,e[i].inside,t,n)>=r;o[i]={...a,position:s?"inside":"outside",fontSize:r}}return{plans:o,fontSize:r}}function Qw(e,t,n,i){const o=t*n,a="top"===i?e.y:e.y+(e.height-o)/2;return Array.from({length:t},(t,i)=>({x:e.x,y:a+i*n,width:e.width,height:n}))}function Zw(e,t){return`${d.formatAbbreviate(100*t,e.schema.locale)}%`}function Jw(e,t){const n=e.schema.valueFormat,i=[e._drawLabel(t.data,t.i)];if(Number.isFinite(t.value)&&i.push(`${n(t.value,t.data)}`),!t.i)return i;const o=Yw(e.schema.conversion);for(const n of o){const o="first"===n?t.first:t.previous;if(!Number.isFinite(o))continue;const a=e.schema.translate("first"===n?"of first":"of previous");i.push(`${Zw(e,o)} ${a}`)}return i}function eS(e,t){const n=e.end-e.start,i=t.center+e.max/2+6,o=Math.max(0,(t.breadth-e.max)/2-6);return"horizontal"===t.orient?{inside:{x:e.start,y:t.center-e.min/2,width:n,height:e.min},outside:{x:e.start,y:i,width:n,height:o}}:{inside:{x:t.center-e.min/2,y:e.start,width:e.min,height:n},outside:{x:i,y:e.start,width:o,height:n}}}function tS(e,t){return{x:e.x+t,y:e.y+t,width:Math.max(0,e.width-2*t),height:Math.max(0,e.height-2*t)}}function nS(e,t,n){const i=(e,i)=>{const o=tu(e,t,n);return"number"==typeof o&&o>0?o:i};return{fontMin:i(e.fontMin,10),fontMax:i(e.fontMax,16),padding:4,lineHeight:1.2}}function iS(e,t,i,o=1/0){const r=ru(e,"Path"),s=t[0],c=s?nS(r,s.data,s.i):nS({},{},0),l=a.fontFamilyStringify((s?tu(r.fontFamily,s.data,s.i):void 0)??e.schema.fontFamily),h=t.map(t=>{const{inside:n,outside:o}=eS(t,i),a=tu(r.fontSize,t.data,t.i);return{lines:Jw(e,t),inside:n,outside:o,fixed:"number"==typeof a&&a>0?a:void 0}}),{plans:u,fontSize:d}=Xw(h,(e,t)=>Number(n.textWidth(e,{"font-family":l,"font-size":t,"font-weight":600}))||0,c,o),f=new Map;return u.forEach((e,n)=>{e&&f.set(t[n].data,e)}),{plans:f,fontSize:d,sizing:c,user:r}}function oS(e,t,n){return t.length?iS(e,t,n).fontSize:0}function aS(e){const t=Number(e.ctx.funnelLabelSize);return Number.isFinite(t)&&t>0?t:1/0}function rS(e,t,n){const i=au(e,"Path"),{plans:o,sizing:a,user:s}=iS(e,t,n,aS(e)),c="horizontal"===n.orient,l=new Map;for(const e of t){const t=o.get(e.data);if(!t)continue;const{inside:i,outside:a}=eS(e,n),r="inside"===t.position?i:a,s="outside"===t.position&&c?"top":"middle",h=Qw(tS(r,4),t.lines.length,1.2*t.fontSize,s);l.set(e.data,{stage:e,plan:t,boxes:h})}const h=e=>l.get((e&&e.data)??e);return iw({data:t.map(e=>e.data),datum:e=>e,label:e=>l.get(e)?.plan.lines??!1,labelBounds:e=>{const t=l.get(e)?.boxes;return!!t&&t.map(e=>({...e,y:e.y-1,height:e.height+2}))},x:()=>0,y:()=>0,aes:()=>({}),rotate:N(0),id:(t,n)=>`funnel-label-${e._ids(t,n).join("-")}`,labelConfig:{fontResize:!1,padding:0,lineHeight:e=>1.2*(h(e)?.plan.fontSize??a.fontMin),fontWeight:e=>e&&0===e.l?600:400,textAnchor:e=>"outside"!==h(e)?.plan.position||c?"middle":"start",verticalAlign:"top",fontColor:t=>{const n=h(t);if(!n||"outside"===n.plan.position)return Ga(e);const o=tu(i.fill,n.stage.data,n.stage.i);return"string"==typeof o?r.colorContrast(o,e.schema.colorDefaults):Ga(e)},...s,fontSize:e=>h(e)?.plan.fontSize??a.fontMin}})}function sS(e,t={}){return{...t,...e.schema.connectorConfig??{}}}function cS(e,t,n,i={}){const o=e.schema.connectorConfig??{},a=t.data,r=t.i,s=tu(o.fill,a,r)??n;return{fill:nu(sS(e,i),a,r,s),opacity:tu(o.opacity,a,r),stroke:tu(o.stroke,a,r),strokeWidth:tu(o.strokeWidth,a,r)}}function lS(e,t){const n=e.schema.valueFormat,i=Number.isFinite(t.value)?`, ${n(t.value,t.data)}`:"";return`${t.i+1}. ${e._drawLabel(t.data,t.i)}${i}.`}const hS=({viz:e,shapeData:t})=>{const n=t??[],i=e.ctx.funnel;if(!n.length||!i)return[];const o=au(e,"Path"),a=t=>`funnel-${e._ids(t.data,t.i).join("-")}`,r=[],s=[],c=[];for(const t of n){const n=iu(o,t.data,t.i);r.push({type:"path",key:a(t),d:Nw(t.points,i.center,i.orient),datum:t.data,index:t.i,shapeType:"Path",paint:n,aria:{label:lS(e,t)}});const l=Nw(t.neck,i.center,i.orient);if(!1!==e.schema.connector&&l){const n=tu(o.fill,t.data,t.i);s.push({type:"path",key:`${a(t)}-neck`,d:l,datum:t.data,index:t.i,interactive:!1,aria:{hidden:!0},paint:cS(e,t,"string"==typeof n?n:void 0,o)}),c.push(t)}}const l=qy(sS(e,o),s,e=>[c[e].data,c[e].i]),h=qy(o,r,e=>[n[e].data,n[e].i]),u=!1===(e.schema.shapeConfig??{}).label?[]:rS(e,n,i);return[...s,...l,...r,...h,...u]};function uS(e,t,n){if(!1===(e.schema.shapeConfig??{}).label)return 0;const i=ie(e),o=t.filter(e=>e.length).map(t=>{const{stages:o,shared:a}=Vw(e,jw(e,t),i,n);return oS(e,o,a)}).filter(e=>e>0);return o.length?Math.min(...o):0}function dS(e,t){const n=e.schema.value,i=zw(t.flatMap(e=>e.map((e,t)=>Number(n(e,t)))));return{max:i,fontSize:uS(e,t,i)}}function fS(e,t){const n=e.ctx.funnelScaleMax,i=e.ctx.funnelLabelSize,o=t.shared?t.scales:void 0;return e.ctx.funnelScaleMax=o?o.max:void 0,e.ctx.funnelLabelSize=o&&o.fontSize?o.fontSize:void 0,()=>{e.ctx.funnelScaleMax=n,e.ctx.funnelLabelSize=i}}const mS={scales:"independent",share:dS,panel:fS};function pS(e,t,n){const i=Number(e.schema.value(t,n)),o=e.schema.valueFormat,a=[];Number.isFinite(i)&&a.push([e.schema.translate("Value"),`${o(i,t)}`]);const r=t?Ww(e).get(t):void 0,s=r?r.first:NaN,c=r?r.previous:NaN;return Number.isFinite(c)&&(Number.isFinite(s)&&a.push([e.schema.translate("% of First Stage"),Zw(e,s)]),a.push([e.schema.translate("% of Previous Stage"),Zw(e,c)])),a}const gS={name:"Funnel",layoutStage:qw,emit:hS,insetRegion:Uu,facet:mS,ctx:{},fields:[{key:"connector",default:!0},{key:"conversion",default:!1},{key:"curve",default:"linear"},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(n,i)=>{const o=new Set(e._filteredData.map((t,n)=>e._ids(t,n).join("_")));return!(i.length>=o.size)&&t.call(e,n,i)}}},{key:"orient",default:"vertical"},{key:"sort"},{key:"stagePadding",default:.3},{key:"taper",default:!1},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:"string"==typeof e?Be(e):N(e)},{key:"valueFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"zoom",default:!1},{key:"connectorConfig",merge:!0,default:{opacity:.35}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>pS(e,t,n)})}]};var yS=xf(gS);function xS(e){const t=Ia(e),n=r.colorContrast(t,e.schema.colorDefaults),i=x.interpolateRgb(t,n);return{track:i(.12),tick:i(.6),text:n}}const bS={name:"Gauge",layoutStage:t_,emit:({viz:e,shapeData:t})=>{const n=t??[],o=e.ctx.gauge;if(!(n.length&&o&&o.radius>0))return[];const r=1===n.length,s=n[0],c=Zb(o.radius,o.dial),l=function(e,t,n){const i=(e.schema.axisConfig??{}).shapeConfig??{},o=i.labelConfig??{},r=xS(e),s=tu(o.fontFamily,t,n)??e.schema.fontFamily,c=e.schema.tickFormat;return{trackFill:tu(i.fill,t,n)??r.track,tickStroke:tu(i.stroke,t,n)??r.tick,tickStrokeWidth:tu(i.strokeWidth,t,n)??1,fontColor:tu(o.fontColor,t,n)??r.text,fontFamily:a.fontFamilyStringify(s),tickFormat:e=>`${c(e)}`}}(e,s.data,s.i),h=e.schema.valueFormat,u=r&&Number.isFinite(s.value)?`${h(s.value,s.data)}`:"",d=o.dial.hasName?e._drawLabel(s.data,s.i):void 0,f={type:"group",key:"gauge-dial",interactive:!1,aria:{hidden:!0},children:[...A_("gauge",c,o,l),...z_("gauge",c,l,u,d)]},m={viz:e,layout:c,shared:o,single:r},p=[f,...n.flatMap(e=>function(e,t){const{viz:n,layout:o,shared:a,single:r}=t,s=`gauge-${n._ids(e.data,e.i).join("-")}`,c=au(n,"Path"),l=iu(c,e.data,e.i),h=n.schema.valueFormat,u=`${[Jb(n,e.data,e.i)?n._drawLabel(e.data,e.i):"",h(e.value,e.data)].filter(Boolean).join(", ")}.`,d={datum:e.data,index:e.i,shapeType:"Path",aria:{label:u}},f="progress"===a.dial.indicator,m=o.rings[f?e.i:0],p={startAngle:a.start,endAngle:a.end},g={rotate:Hb(e.angle)},y={type:"path",key:`${s}-indicator::hit`,d:r?i.arcPath({innerRadius:0,outerRadius:o.outer,...p}):f?i.arcPath({innerRadius:m.inner,outerRadius:m.outer,...p}):Qb(o.needleLength,3*o.needleHalfWidth,o.needleTail),transform:r||f?void 0:g,datum:e.data,index:e.i,paint:{fill:"transparent"}};if(!Number.isFinite(e.value))return[y];if(f){const t={innerRadius:m.inner,outerRadius:m.outer,startAngle:a.start,endAngle:e.angle},n={type:"path",key:`${s}-indicator`,d:i.arcPath(t),arc:t,paint:l,...d},o=Vy(c,n,e.data,e.i);return o?[y,n,o]:[y,n]}const x={type:"path",key:`${s}-indicator`,d:Qb(o.needleLength,o.needleHalfWidth,o.needleTail),transform:g,paint:l,...d};return r?[y,x,{type:"circle",key:`${s}-hub`,cx:0,cy:0,r:o.hubRadius,paint:l,...d}]:[y,x]}(e,m))];return r||"progress"===o.dial.indicator||p.push({type:"circle",key:"gauge-hub",interactive:!1,cx:0,cy:0,r:c.hubRadius,paint:{fill:l.fontColor,stroke:Ia(e),strokeWidth:1.5}}),[{type:"group",key:"gauge",transform:{x:o.cx,y:o.cy},children:p}]},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"domain"},{key:"endAngle",default:120},{key:"indicator",default:"needle"},{key:"minorTicks",default:!0},{key:"startAngle",default:-120},{key:"thickness",default:.2},{key:"tickFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"ticks"},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>Ia(e),strokeWidth:()=>"progress"===e.schema.indicator?0:1.5})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Value"),(t,n)=>{const i=Number(e.schema.value(t,n));return Number.isFinite(i)?`${e.schema.valueFormat(i,t)}`:""}]]})},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:"string"==typeof e?Be(e):N(e)},{key:"valueFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"zoom",default:!1}]};var _S=xf(bS);const kS=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["tile.openstreetmap.org"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["openstreetmap.fr/hot"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, tiles by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a>"},{matches:["stadiamaps.com"],text:"© <a href='https://stadiamaps.com/' target='_blank'>Stadia Maps</a> © <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["World_Light_Gray_Base","World_Dark_Gray_Base"],text:"Powered by <a href='https://www.esri.com/' target='_blank'>Esri</a> | Esri, HERE, Garmin, © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, and the GIS user community"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}],vS={light:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",dark:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}"},wS=e=>"object"==typeof e&&null!==e&&"light"in e&&"dark"in e;function SS(e,t){return wS(e)?t?e.dark:e.light:e}function CS(e){return wS(e.schema.tileUrl)||wS(e.schema.ocean)}function MS(e){if(e._ssr||"undefined"==typeof window||"function"!=typeof getComputedStyle)return!1;let t=e._select?.node()??null;for(;t;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e)return l.lab(e).l<50;t=t.parentElement}const n=getComputedStyle(document.documentElement).colorScheme||"";return!!n.includes("dark")&&(!n.includes("light")||"function"==typeof matchMedia&&matchMedia("(prefers-color-scheme: dark)").matches)}function $S(e,t){const n=t&&e.objects[t]?t:Object.keys(e.objects)[0];return C.feature(e,n)}function AS(e){return e._filteredData.filter((t,n)=>e.schema.point(t,n)instanceof Array)}function zS(e,t){const n=`scale${e.schema.pointSizeScale.charAt(0).toUpperCase()}${e.schema.pointSizeScale.slice(1)}`;return B[n]().domain(h.extent(t,(t,n)=>e.schema.pointSize(t,n))).range([e.schema.pointSizeMin,e.schema.pointSizeMax])}const DS=({viz:e})=>{const t=e,n=e.ctx,{width:i,height:o}=ie(t),a=t.schema.topojson?$S(t.schema.topojson,t.schema.topojsonKey):{type:"FeatureCollection",features:[]};n.coordData=a,t.schema.topojsonFilter&&(a.features=a.features.filter(t.schema.topojsonFilter));const r=P.geoPath().projection(t.schema.projection);n.path=r;const s=AS(t),c=t._filteredData.filter((e,n)=>!(t.schema.point(e,n)instanceof Array)).reduce((e,n,i)=>(e[t._id(n,i)]=n,e),{}),l=a.features.reduce((e,n)=>{const i=t.schema.topojsonId(n);return e.push({__d3plus__:!0,data:c[i],feature:n,id:i}),e},[]),u=zS(t,s);if(t._sizeLegendFinal=s.length?u:null,!t._zoomSet||!n.extentBounds){n.effectivePadding=void 0;const e=t.schema.fitObject?$S(t.schema.fitObject,t.schema.fitKey):a;n.extentBounds={type:"FeatureCollection",features:t.schema.fitFilter?e.features.filter(t.schema.fitFilter):e.features.slice()},n.extentBounds.features=function(e,t){return e.reduce((e,n)=>{const i=n;if(!i.geometry)return e;const o={type:i.type,id:i.id,geometry:{coordinates:i.geometry.coordinates,type:i.geometry.type}};if("MultiPolygon"===i.geometry.type&&i.geometry.coordinates.length>1){const e=[],n=[];i.geometry.coordinates.forEach(n=>{o.geometry.coordinates=[n],e.push(t.area(o))}),o.geometry.coordinates=[i.geometry.coordinates[e.indexOf(h.max(e))]];const a=t.centroid(o);i.geometry.coordinates.forEach(e=>{o.geometry.coordinates=[e],n.push(f.pointDistance(t.centroid(o),a))});const r=h.quantile(e.reduce((t,i,o)=>(n[o]&&t.push(e[o]/n[o]),t),[]),.9);o.geometry.coordinates=i.geometry.coordinates.filter((t,i)=>{const o=n[i];return 0===o||e[i]/o>=r})}return e.push(o),e},[])}(n.extentBounds.features,r),!n.extentBounds.features.length&&s.length&&function(e,t,n,i){const o=[[void 0,void 0],[void 0,void 0]];n.forEach((t,n)=>{const i=e.schema.projection(e.schema.point(t,n));(void 0===o[0][0]||i[0]<o[0][0])&&(o[0][0]=i[0]),(void 0===o[1][0]||i[0]>o[1][0])&&(o[1][0]=i[0]),(void 0===o[0][1]||i[1]<o[0][1])&&(o[0][1]=i[1]),(void 0===o[1][1]||i[1]>o[1][1])&&(o[1][1]=i[1])}),t.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:o.map(t=>e.schema.projection.invert(t))}}]};const a=h.max(n,(t,n)=>i(e.schema.pointSize(t,n)));t.effectivePadding={top:e.schema.projectionPadding.top+a,right:e.schema.projectionPadding.right+a,bottom:e.schema.projectionPadding.bottom+a,left:e.schema.projectionPadding.left+a}}(t,n,s,u)}const d=n.effectivePadding||t.schema.projectionPadding;return t.schema.projection=t.schema.projection.fitExtent(n.extentBounds.features.length?[[d.left,d.top],[i-d.right,o-d.bottom]]:[[0,0],[i,o]],n.extentBounds.features.length?n.extentBounds:{type:"Sphere"}),n.geomapWidth=i,n.geomapHeight=o,n.geomapCtx={topoData:l,pathFn:e=>r(e.feature),pointData:s,pointR:(e,n)=>u(t.schema.pointSize(e,n)),pointSort:(e,n)=>t.schema.pointSize(n)-t.schema.pointSize(e),pointX:(e,n)=>t.schema.projection(t.schema.point(e,n))[0],pointY:(e,n)=>t.schema.projection(t.schema.point(e,n))[1]},{shapeData:l}},FS={geoAlbers:S.geoAlbers,geoAlbersUsa:R.geoAlbersUsa??S.geoAlbersUsa,...R.geoAlbersUsaTerritories&&{geoAlbersUsaTerritories:R.geoAlbersUsaTerritories},geoAzimuthalEqualArea:S.geoAzimuthalEqualArea,geoAzimuthalEquidistant:S.geoAzimuthalEquidistant,geoConicConformal:S.geoConicConformal,geoConicEqualArea:S.geoConicEqualArea,geoConicEquidistant:S.geoConicEquidistant,geoEqualEarth:S.geoEqualEarth,geoEquirectangular:S.geoEquirectangular,geoGnomonic:S.geoGnomonic,geoMercator:S.geoMercator,geoMiller:M.geoMiller,geoNaturalEarth1:S.geoNaturalEarth1,geoOrthographic:S.geoOrthographic,geoRobinson:M.geoRobinson,geoStereographic:S.geoStereographic,geoTransverseMercator:S.geoTransverseMercator,geoWinkel3:M.geoWinkel3};function BS(e){const{width:t,height:n}=ie(e);return[[0,0],[t,n]]}function LS(e){return SS(e.schema.tileUrl,Boolean(e._basemapDark))}function PS(e){const t=!!e.schema.tiles&&function(e){const t=kS.find(t=>t.matches.some(t=>e.includes(t)));return!!t&&t.text}(LS(e)),n=e.schema.attribution;n&&n!==e._tileAttribution||(e.schema.attribution=t||""),e._tileAttribution=t}function RS(e){const t=e._draw.bind(e);e._draw=function(n){e._basemapDark=MS(e),CS(e)&&function(e){if(e._themeWatch||e._ssr||"undefined"==typeof window)return;const t=()=>{const t=e._select?.node();t&&t.isConnected&&CS(e)&&MS(e)!==e._basemapDark&&e.render?.()},n="function"==typeof matchMedia?matchMedia("(prefers-color-scheme: dark)"):null;n?.addEventListener?.("change",t);const i="function"==typeof MutationObserver?new MutationObserver(t):null;for(const e of[document.documentElement,document.body])e&&i?.observe(e,{attributes:!0});e._themeWatch=!0}(e),PS(e);const i=t(n),{width:o,height:a}=ie(e);return tr(e,{kind:"geomap",width:o,height:a,duration:e.schema.duration,ocean:e._facetStep?"transparent":SS(e.schema.ocean,Boolean(e._basemapDark))}),e._zoomSet=!0,i}}function ES(e){!function(e){const t=e;t.fitFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.fitFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.fitFilter=e=>t.includes(e.id),this}return this.schema.fitFilter},t.fitKey=function(e){return arguments.length?(this.schema.fitKey=e,this._zoomSet=!1,this):this.schema.fitKey},t.fitObject=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"fitObject"),this._zoomSet=!1,this):this.schema.fitObject},t.point=function(e){return arguments.length?(this.schema.point="function"==typeof e?e:N(e),this):this.schema.point},t.pointSize=function(e){return arguments.length?(this.schema.pointSize="function"==typeof e?e:N(e),this):this.schema.pointSize}}(e),function(e){const t=e;t.projection=function(e){return arguments.length&&"geoMercator"!==e&&t.tiles(!1),arguments.length?(this.schema.projection="string"==typeof e?(n=e,Object.hasOwn(FS,n)?FS[n]():(pe(`Geomap received unknown projection "${n}"; using geoMercator. Pass the projection itself to use one not built in, e.g. .projection(${n}()).`),S.geoMercator())):e,this):this.schema.projection;var n},t.projectionPadding=function(e){return arguments.length?(this.schema.projectionPadding=n.parseSides(e),this):this.schema.projectionPadding},t.projectionRotate=function(e){return arguments.length?(this.schema.projection.rotate(e),t.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}(e),function(e){const t=e;t.tiles=function(e){return arguments.length?(this.schema.tiles=e,PS(this),this):this.schema.tiles},t.tileUrl=function(e){return arguments.length?(this.schema.tileUrl=e,PS(this),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}(e),function(e){const t=e;t.topojson=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"topojson"),this._zoomSet=!1,this):this.schema.topojson},t.topojsonFill=function(e){return arguments.length?(this.schema.topojsonFill="function"==typeof e?e:N(e),this):this.schema.topojsonFill},t.topojsonFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.topojsonFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.topojsonFilter=e=>t.includes(e.id),this}return this.schema.topojsonFilter},t.topojsonKey=function(e){return arguments.length?(this.schema.topojsonKey=e,this._zoomSet=!1,this):this.schema.topojsonKey},t.topojsonId=function(e){return arguments.length?(this.schema.topojsonId="function"==typeof e?e:T(e),this):this.schema.topojsonId}}(e)}const NS={name:"Geomap",layoutStage:DS,sizeLegendScale:e=>{const t=AS(e);return t.length?zS(e,t):null},emit:({viz:e})=>{const t=e.ctx.geomapCtx;if(!t)return[];const n=function(e){const t=[],n="panel"===e._facetStep;if(e._ssr||n){const n=SS(e.schema.ocean,Boolean(e._basemapDark));if(n&&"transparent"!==n){const{width:i,height:o}=ie(e);t.push({type:"rect",key:"geomap-ocean",x:0,y:0,width:i,height:o,paint:{fill:n}})}}const i=e._ssrTiles;if((i&&i.size||n&&!e._ssr)&&"function"==typeof e._computeTileList)for(const n of e._computeTileList()){const e=i&&i.size?i.get(n.key):n.url;e&&t.push({type:"image",key:`geomap-tile-${n.key}`,x:n.x,y:n.y,width:n.size,height:n.size,href:e,preserveAspectRatio:"none",interactive:!1})}return t}(e);if(t.topoData&&t.topoData.length){const i=au(e,"Path"),o=e.schema.colorScale,a=n.length;for(let a=0;a<t.topoData.length;a++){const r=t.topoData[a],s=r.data??r,c=iu(i,s,a),l=o?`, ${o(s,a)}`:"";n.push({type:"path",key:`geomap-path-${r.id}`,d:t.pathFn(r),datum:s,paint:{...c,vectorEffect:c.vectorEffect??"non-scaling-stroke"},aria:{label:`${e._drawLabel(s,a)}${l}.`}})}n.push(...qy(i,n.slice(a),e=>{const n=t.topoData[e];return[n.data??n,e]}))}if(t.pointData&&t.pointData.length){const i=au(e,"Circle"),o=t.pointSort?[...t.pointData].sort(t.pointSort):t.pointData,a=n.length;for(let a=0;a<o.length;a++){const r=o[a],s=iu(i,r,a);n.push({type:"circle",key:`geomap-point-${e._id(r,a)}`,cx:0,cy:0,r:t.pointR(r,a),transform:{x:t.pointX(r,a),y:t.pointY(r,a)},datum:r,paint:{...s,vectorEffect:s.vectorEffect??"non-scaling-stroke"},aria:{label:`${e._drawLabel(r,a)}, ${e.schema.pointSize(r,a)}.`},...i.trail?{trail:!0}:{},...i.trailPersist?{trailPersist:i.trailPersist}:{}})}n.push(...qy(i,n.slice(a),e=>[o[e],e]))}return n},insetRegion:Uu,colorScaleShape:(e,t,n)=>e.schema.point(t,n)instanceof Array?e.schema.shape(t,n):"Path",chartClip:ae,setup:e=>{const t=e;e._zoomSet=!1,e.schema.tiles=!0,e._tileGen=w.tile(),function(e){e._renderTiles=function(e=fc(this),t=0){if(this._ssr)return;if(this._facetPanels||this._facetStep)return void this._tileGroup?.selectAll("image.d3plus-geomap-tile").remove();let n=[];this.schema.tiles&&(n=this._tileGen.extent(BS(this)).scale(this.schema.projection.scale()*(2*Math.PI)*e.k).translate(e.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(t).attr("transform",e));const i=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(n,([e,t,n])=>`${e}-${t}-${n}`);i.exit().transition().duration(t).attr("opacity",0).remove();const o=n.scale/e.k,a=i.enter().append("image").attr("class","d3plus-geomap-tile");a.attr("opacity",0).transition().duration(t).attr("opacity",1),i.interrupt(),i.merge(a).attr("width",o).attr("height",o).attr("xlink:href",([e,t,n])=>LS(this).replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${n}`).replace("{x}",`${e}`).replace("{y}",`${t}`)).attr("x",([t])=>t*o+n.translate[0]*o-e.x/e.k).attr("y",([,t])=>t*o+n.translate[1]*o-e.y/e.k)},e._computeTileList=function(){if(!this.schema.tiles)return[];const e=this._tileGen.extent(BS(this)).scale(this.schema.projection.scale()*(2*Math.PI)).translate(this.schema.projection.translate())(),t=e.scale;return e.map(([n,i,o])=>({key:`${n}-${i}-${o}`,url:LS(this).replace("{s}","a").replace("{z}",`${o}`).replace("{x}",`${n}`).replace("{y}",`${i}`),x:n*t+e.translate[0]*t,y:i*t+e.translate[1]*t,size:t}))}}(e),RS(e),ES(e),t.tileUrl(vS),e.schema.topojsonFill=()=>e._basemapDark?"#3d3e44":"#f5f5f3"},ctx:{},fields:[{key:"fitObject",default:!1},{key:"noDataMessage",default:!1},{key:"ocean",default:{light:"#d0cfd4",dark:"#222327"}},{key:"point",default:T("point")},{key:"pointSize",default:N(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:S.geoMercator()},{key:"projectionPadding",default:n.parseSides(20)},{key:"shape",default:N("Circle"),coerce:"const"},{key:"topojson",default:!1},{key:"topojsonFill",default:N("#f5f5f3")},{key:"topojsonFilter",default:e=>!["010"].includes(e.id)},{key:"topojsonId",default:T("id")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>`${e._drawLabel(t,n)}, ${e.schema.pointSize(t,n)}`,hoverOpacity:1,Path:{ariaLabel:(t,n)=>{const i=e.schema.colorScale,o=i?`, ${i(t,n)}`:"";return`${e._drawLabel(t,n)}${o}.`},fill:(t,n)=>{const i=e.ctx.coordData?.features??[],o=e.schema.colorScale;if(o&&!i.includes(t)){const n=o(t);if(null!=n){if(e._colorScaleClass._colorScale)return e._colorScaleClass._colorScale(n);let t=e._colorScaleClass.color();return t instanceof Array&&(t=t[t.length-1]),t}}return e.schema.topojsonFill(t,n)},on:{mouseenter:(t,n,i,o)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseenter.bind(e)(t,n,i,o),"mousemove.shape":(t,n,i,o)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on["mousemove.shape"].bind(e)(t,n,i,o),mouseleave:(t,n,i,o)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseleave.bind(e)(t,n,i,o)},stroke:(t,n)=>{const i=e.schema.shapeConfig.Path,o="function"==typeof i.fill?i.fill(t,n):i.fill,a=l.color(o);return a?a.darker().toString():o},strokeWidth:1},Circle:{trail:!0}})}]};var TS=xf(NS);const OS=new WeakMap;function WS(e){const t=T(e);return OS.set(t,e),t}function jS(e){return"function"==typeof e?OS.get(e)??Le(e):void 0}function HS(e,t,n){!e||void 0!==e.title&&e.title!==t||(e.title=n)}function IS(e,t){let[n,i]=t.domain??h.extent(e),o=Boolean(t.domain);if(n===i&&([n,i]=[n-.5,i+.5],o=!0),t.width&&t.width>0)return function(e,t,n){const i=Math.floor(e/n)*n,o=Math.max(Math.ceil(t/n)*n,i+n);return h.range(0,Math.round((o-i)/n)+1).map(e=>i+e*n)}(n,i,t.width);let a=h.bin();o&&(a=a.domain([n,i]));const r=t.thresholds??h.thresholdSturges,s=a.thresholds(r)(e);return[s[0].x0,...s.map(e=>e.x1)]}function GS(e,t){const{value:n,panel:i=()=>""}=t,o=e.map((e,t)=>({d:e,i:t,v:Number(n(e,t))})).filter(e=>e.d&&Number.isFinite(e.v));if(!o.length)return[];const a=t.sharedEdges?IS(o.map(e=>e.v),t):void 0;return h.groups(o,e=>i(e.d,e.i)).flatMap(([,e])=>function(e,t,n){const{group:i=()=>"",normalize:o="count"}=n,a=h.bin().domain([t[0],t[t.length-1]]).thresholds(t.slice(1,-1)),r=e.length,s=[];for(const[,t]of h.groups(e,e=>i(e.d,e.i))){const e=a(t.map(e=>e.v)),n=t[0].d;e.forEach(e=>{const t=e.x0,i=e.x1,a=e.length,c="density"===o?a/(r*(i-t)):"relative"===o?a/r:a;s.push({...n,x0:t,x1:i,x:(t+i)/2,count:a,y:c})})}return s}(e,a??IS(e.map(e=>e.v),t),t))}const VS={count:"Count",density:"Density",relative:"Relative Frequency"};function qS(e){for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}const YS=e=>Array.isArray(e.x);function KS(e){const t=e.ctx.histogram;e._data!==t.bins&&(t.raw=e._data),e._sourceData=t.raw;const n=function(e,t){if(e.schema.timeFilter)return e.schema.timeFilter;const n=e._data;e._data=t;try{return Hh(e)}finally{e._data=n}}(e,t.raw),i=e.schema.filter,o=n?t.raw.filter(n):t.raw,a=i?o.filter(i):o,r=Ie(e)?e.schema.facet:void 0,s=e.schema.groupBy,c=jS(e.schema.value),l=GS(a,{value:e.schema.value,group:(e,t)=>s.map(n=>`${n(e,t)}`).join("_"),panel:r?(e,t)=>Gh(Vh(r(e,t))):void 0,sharedEdges:"independent"!==Ne(e.schema.facetConfig).scales,thresholds:e.schema.binThresholds,domain:e.schema.binDomain,width:e.schema.binWidth,normalize:e.schema.binNormalize}),h=l.every((e,t)=>s.every(n=>void 0===n(e,t)));l.forEach(t=>{c&&delete t[c],h&&(t.id=c??e.schema.translate("Value"))});const u=n?t.raw.filter((e,t)=>!n(e,t)):[];t.bins=e._data=u.length?[...l,...u]:l,t.binned=new Set(l);const d=e.schema.translate(VS[e.schema.binNormalize]??VS.count);HS(e._yConfig,t.yTitle,d),t.yTitle=d,HS(e._xConfig,t.xTitle,c),t.xTitle=c}const US={name:"Histogram",paintDriven:!0,thresholdFunction:(e,t)=>t,defaults:{groupPadding:1},setup:e=>{const t={raw:[],bins:[],binned:new Set};e.ctx.histogram=t,e._filterApplied=e=>t.binned.has(e),e.stackOrder("key"),e.schema.shapeConfig.Bar={...e.schema.shapeConfig.Bar,label:!1},e._discreteExtent=e=>[e.x0,e.x1];const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(t,i,o,a)=>{if(n(t,i,o,a),1===e.schema.shapeConfig.hoverOpacity)return;const r=qS(t),s=`${e._id(r,i)}`;e.hover((t,n)=>{const i=qS(t);return`${e._id(i,n)}`===s&&(YS(i)||i.x0===r.x0)})};const i=e._preDraw.bind(e);e._preDraw=()=>{KS(e),i()}},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"binThresholds"},{key:"binDomain"},{key:"binWidth"},{key:"binNormalize",default:"count"},{key:"discrete",default:"x"},{key:"shape",default:N("Bar"),coerce:"const"},{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:e=>{const t=t=>d.formatAbbreviate(t,e.schema.locale),n=e=>{const n=qS(e);return`${t(n.x0)} – ${t(n.x1)}`},i=(t,n)=>e.schema.groupBy.some(e=>void 0!==e(qS(t),n));return{title:(t,o)=>i(t,o)?e._drawLabel(qS(t),o):n(t),tbody:(o,a)=>{const r=qS(o),s=[];if(YS(r))return[[e.schema.translate(VS.count),t(r.count)]];i(o,a)&&s.push([e.schema.translate("Range"),n(o)]),s.push([e.schema.translate(VS.count),t(r.count)]);const c=e.schema.binNormalize;return"count"!==c&&s.push([e.schema.translate(VS[c]),t(r.y)]),s}}}},{key:"value",default:WS("value"),coerce:e=>"string"==typeof e?Be(e):"function"==typeof e?e:N(e)}]};var XS=xf(US,_b);function QS(e,t){const{aggs:n,drawDepth:i,groupBy:a,label:r,threshold:s,thresholdKey:c}=t,l=h.sum(e,c);if(!s||!c)return e;return function e(t,u){if(u<i)return[...h.group(t,a[u])].reduce((t,[,n])=>{const i=e(n,u+1)??[];return t.concat(i)},[]);if(u===i){const e=Math.min(1,Math.max(0,s(t)));if(!isFinite(e)||isNaN(e))return null;const i=[],h=[],d=e*l;for(let e=0;e<t.length;e++){const n=t[e];c(n)<d?i.push(n):h.push(n)}if(i.length<2)return t;const f=o.merge(i,n);return f._isAggregation=!0,f._threshold=e,f[zr]=Dr(i,(e,t)=>t,r??(e=>a[u](e)),c),h.push(f),h}throw new Error("Depth is higher than the amount of grouping levels.")}(e,0)??e}function ZS(e,t,n={}){const{level:i=0,path:o=[],index:a=()=>0}=n;if(!t.length)return{children:[],own:e};const[r,...s]=t,c=[],l=new Map;for(const t of e){const e=r(t,a(t));if(null==e){c.push(t);continue}const n=l.get(e);n?n.push(t):l.set(e,[t])}return{children:[...l].map(([e,t])=>{const n=[...o,e];if(!s.length)return{key:e,path:n,level:i,rows:t,own:t};const r=ZS(t,s,{level:i+1,path:n,index:a});return{key:e,path:n,level:i,rows:t,own:r.own,children:r.children.length?r.children:void 0}}),own:c}}function JS(e){const{children:t,rows:n}=e.data;return!t&&1===n.length&&!0===n[0]._isAggregation}function eC(e){return(t,n)=>{const i=JS(t),o=JS(n);return i&&!o?1:!i&&o?-1:e(t,n)}}function tC(e){if(!(_r in e))return e;const t={...e};return t.share===t[_r]&&delete t.share,delete t[_r],t}function nC(e,t){const n=o.merge(e.map(tC),t);return delete n._isAggregation,delete n._threshold,delete n[zr],n}function iC(e,t){const{data:n,keys:i,firstLevel:o,focusPath:a,sum:r,sort:s,aggs:c}=e;if(!n.length)return[];const l=e=>n.indexOf(e),h=ZS(n,i,{level:o,path:a,index:l}),u={key:a[a.length-1],path:a,level:o-1,rows:n,own:h.own,children:h.children};let d=A.hierarchy(u,e=>e.children).sum(e=>e.own.reduce((e,t)=>e+(Number(r(t))||0),0));s&&(d=d.sort(s));const f=A.partition().size([e.breadth??1,i.length+1])(d),m=f.value??0,p=[],g=new Map;for(const e of f.descendants()){if(0===e.depth&&!a.length)continue;const n=e.value??0;if(!(n>0)||e.x1-e.x0<=0)continue;const i=e.data,o=!i.children&&1===i.rows.length,r=o?i.rows[0]:nC(i.rows,c),s=e.parent?e.parent.value??0:n,h={id:JSON.stringify(i.path),path:i.path,level:i.level,depth:e.depth,datum:r,i:o?l(r):void 0,value:n,share:m?n/m:0,parentShare:s?n/s:0,x0:e.x0,x1:e.x1,hasChildren:Boolean(e.children&&e.children.length)},u={...h,...t(h),parent:e.parent?g.get(e.parent.data):void 0};g.set(i,u),p.push(u)}return p}function oC(e){const t=[];for(let n=e;n;n=n.parent)t.push(n);return t}function aC(e){const t=e._history?.[e._history.length-1],n=e._filteredData??[],i=e.schema.groupBy;if(!t||void 0===t.groupDepth||!n.length)return{level:-1,path:[]};const o=Math.min(t.groupDepth,e._drawDepth-1);if(o<0)return{level:-1,path:[]};return{level:o,path:i.slice(0,o+1).map(e=>e(n[0],0))}}function rC(e,t,n){const i=e.ctx[t];if(i&&i.data===e._filteredData)return i.base;const o=n();return e.ctx[t]={data:e._filteredData,base:o},o}function sC(e,t){const n=new Set(t.map(e=>e.id));return e.filter(e=>!n.has(e.id))}function cC(e,t){const n=e.find(e=>0===e.depth);if(!n)return;return t.filter(e=>e.depth>0&&(e=>e.path.length<=n.path.length&&e.path.every((e,t)=>e===n.path[t]))(e)).sort((e,t)=>t.path.length-e.path.length)[0]}function lC(e,t,n){const i=new Map,o=cC(e,t);if(!o)return i;const a=new Set(e.map(e=>e.id));for(const e of t)a.has(e.id)||i.set(e.id,n(e,o));return i}function hC(e,t){if(0===t.depth||t.datum._isAggregation)return!1;const n=e.schema.groupBy.length-1;return t.hasChildren||t.level===e._drawDepth&&t.level<n}function uC(e,t){return 0===t.depth?Boolean(e._history?.length):hC(e,t)}function dC(e){e.hover(!1),e._tooltipClass?.data([]).render()}function fC(e,t){return`${d.formatAbbreviate(100*t,e.schema.locale)}%`}function mC(e,t,n){const i=e._tooltipClass,o=e.schema.tooltipConfig;if(void 0===o.title){const n=e._drawLabel(t.datum,t.i??0,t.level);Ur(i.title(()=>n),Kr(e,e._lastScenePick))}if(void 0===o.footer){const n=!!uC(e,t)&&e.schema.translate(hC(e,t)?"Click to Expand":"Click to Zoom Out");i.footer(n)}const a=function(e,t){if(t&&t.parent&&0!==t.parent.depth)return[e.schema.translate("Share of Parent"),fC(e,t.parentShare)]}(e,t);a&&function(e,t){if(!Array.isArray(e)||1!==e.length||!Array.isArray(e[0]))return!1;const n=e[0];return n.length===t.length&&n.every((e,n)=>e===t[n])}(o.tbody,n)&&i.tbody([...o.tbody,a]),(void 0===o.title||void 0===o.footer||a)&&i.render()}function pC(e,t,n){const{prefix:i}=n,o=e.schema.on,a=o.mouseenter,r=o["mousemove.shape"],s=t=>function(e,t,n){let i=t;for(;i&&i.__d3plus__&&i.data;)i=i.data;const o=e.ctx[`${n}Nodes`];return i&&o?o.get(i):void 0}(e,t,i),c=t=>{if(e.ctx[`${i}Hovered`]=t,1===e.schema.shapeConfig.hoverOpacity)return;const n=function(e){return new Set(oC(e).map(e=>e.datum))}(t);var o;o=e=>n.has(e),e.hover(o)};return{mouseenter:(t,n,i,o)=>{const r=s(t);r?c(r):a.call(e,t,n,i,o)},"mousemove.shape":(n,o,a,l)=>{r.call(e,n,o,a,l);const h=s(n);if(!h)return;e.ctx[`${i}Hovered`]!==h&&c(h);const u=Boolean(e.schema.on.click);e._select?.style("cursor",u||uC(e,h)?"pointer":"auto"),e._tooltipClass&&e.schema.tooltip(n,o)&&mC(e,h,t)},"click.shape":(t,i,o,a)=>{a?.stopPropagation?.();const r=s(t);r&&(0===r.depth?function(e){const t=e._history?.pop();if(!t)return;dC(e);const n={depth:t.depth,filter:t.filter};e.config(n).render()}(e):hC(e,r)&&function(e,t,n){var i;const o=e.schema.groupBy,a=aC(e),r=e.schema.filter,s=o.slice(0,t.level+1),c=t.path;dC(e);const l={depth:e.schema.depth,filter:r,groupId:c[t.level],groupDepth:t.level};((i=e)._history??(i._history=[])).push(l),e.ctx[`${n.prefix}ZoomOrigin`]=n.origin(t);const h={filter:(e,t)=>(!r||r(e,t))&&s.every((n,i)=>n(e,t)===c[i])};if(void 0!==e.schema.depth){const n=t.level-a.level;h.depth=Math.min(o.length-1,e._drawDepth+n)}e.config(h).render()}(e,r,n))}}}function gC(e,t){return QS(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey,label:(t,n)=>e._drawLabel(t,n)})}const yC=(e,t)=>(t.value??0)-(e.value??0);function xC(e,t){return eC(t)}function bC(e){return"function"==typeof e?e:Be(e)}function _C(e,t){e.schema.thresholdKey=t}function kC(e){const t=e.schema.sum;return(e,n)=>t(n)-t(e)}function vC(e,t){const{prefix:n}=t;e.ctx[`${n}DefaultColor`]=e.schema.color,e.ctx[`${n}DefaultFill`]=e.schema.shapeConfig.fill,Object.assign(e.schema.on,pC(e,(e.schema.tooltipConfig.tbody??[])[0]??[],t))}const wC={step:.22,max:.6};function SC(e,t={}){const{step:n,max:i}={...wC,...t};return e<=0?0:Math.max(0,Math.min(i,n*e))}function CC(e,t,n,i){const o=function(e,t,n="Path"){const i=e.shapeConfig??{},o=i[n]??{};return!1!==e.shade&&!e.colorScale&&!e.colorOrdinal&&e.color===t.color&&i.fill===t.fill&&void 0===o.fill}(e,n,i),a=e.shadeConfig??{};return e=>{const n=tu(t.fill,e.datum,e.i??0);if("string"==typeof n)return o?function(e,t){return e&&t>0&&l.color(e)?r.colorLighter(e,t):e}(n,SC(e.level,a)):n}}function MC(e){const{width:t,height:n,orient:i}=e,o=Math.max(0,t),a=Math.max(0,n);return"vertical"===i?{depth:a,breadth:o}:{depth:o,breadth:a}}function $C(e,t,n){const i=Math.max(0,e),o=Math.max(0,t)+(n?1:0);if(o<1)return[[0,0]];const a=i/o,r=n?[]:[[0,0]];for(let e=0;e<o;e++)r.push([e*a,(e+1)*a]);return r}function AC(e,t,n){const{breadth:i}=MC(n),o=e.x0*i,a=e.x1*i,[r,s]=t;return"vertical"===n.orient?{x:o,y:r,width:a-o,height:s-r}:{x:r,y:o,width:s-r,height:a-o}}function zC(e,t,n,i,o){const a=n.x1-n.x0||1,r=e=>Math.min(1,Math.max(0,(e-n.x0)/a)),s=t-n.depth,c=i[i.length-1]?.[1]??0,l=s<0?[0,0]:i[s]??[c,c];return AC({x0:r(e.x0),x1:r(e.x1)},l,o)}function DC(e,t){return"vertical"===t?{x:e.x+e.width/2,y:e.y,width:0,height:0}:{x:e.x,y:e.y+e.height/2,width:0,height:0}}function FC(e,t,n){const o=new Map;for(const n of e){if(!t.has(n.id))continue;const e=n.parent;o.set(n.id,e?(o.get(e.id)??-1)+1:0)}const a=Math.max(0,...o.values())+1,r=new Map,s=new Map;for(const t of e){const e=o.get(t.id);void 0!==e&&(r.set(t.id,DC(t,n)),s.set(t.id,{start:i.cubicInOut(e/a),end:i.cubicInOut((e+1)/a)}))}return{rects:r,windows:s}}function BC(e){const{bands:t,frame:n,...i}=e;return iC({...i,breadth:1},e=>AC(e,t[e.depth]??[0,0],n))}function LC(e){return"vertical"===e?"vertical":"horizontal"}const PC=({viz:e})=>{const{width:t,height:n}=ie(e),i={width:Math.max(0,t),height:Math.max(0,n),orient:LC(e.schema.orient)};e.ctx.icicleWidth=i.width,e.ctx.icicleHeight=i.height,e.ctx.icicleNodes=new Map,e.ctx.icicleGhosts=[];const o=function(e){return rC(e,"iciclePass",()=>{const t={laid:e.ctx.icicleLaid,bands:e.ctx.icicleBands,frame:e.ctx.icicleFrame,origin:e.ctx.icicleZoomOrigin};return e.ctx.icicleZoomOrigin=void 0,t})}(e),a=e._filteredData??[];if(!a.length)return e.ctx.icicleLaid=[],e.ctx.icicleBands=void 0,e.ctx.icicleFrame=i,e.ctx.icicleEnterRects=new Map,e.ctx.icicleEnterWindows=new Map,{shapeData:[]};const r=aC(e),s=e.schema.groupBy.slice(r.level+1,e._drawDepth+1),c=$C(MC(i).depth,s.length,r.path.length>0),l=BC({data:a,keys:s,firstLevel:r.level+1,focusPath:r.path,sum:e.schema.sum,sort:e.schema.sort,aggs:e.schema.aggs,bands:c,frame:i}),{laid:h,bands:u,origin:d}=o;e.ctx.icicleGhosts=d&&h?function(e,t,n,i,o){return sC(e,t).map(e=>({id:e.id,datum:e.datum,i:e.i,level:e.level,rect:zC(e,e.depth,n,i,o)}))}(h,l,d,c,i):[];const f=h&&u&&o.frame?function(e,t,n,i){return lC(e,t,(e,t)=>zC(e,e.depth,{x0:t.x0,x1:t.x1,depth:t.depth},n,i))}(h,l,u,o.frame):new Map,m=Boolean(d)||Boolean(h&&cC(h,l)),p=new Set((h??[]).map(e=>e.id)),g=m?{rects:f,windows:new Map}:FC(l,new Set(l.filter(e=>!p.has(e.id)).map(e=>e.id)),i.orient);e.ctx.icicleEnterRects=g.rects,e.ctx.icicleEnterWindows=g.windows,e.ctx.icicleLaid=l,e.ctx.icicleBands=c,e.ctx.icicleFrame=i;const y=e.ctx.icicleNodes;for(const e of l)wr(e.datum,e.share),y.set(e.datum,e);return{shapeData:l}},RC=1e-6;function EC(e={}){return{fontMin:8,fontMax:24,padding:2,lineHeight:1.2,maxLines:3,...e}}function NC(e){const t=[];let n=!1;for(const i of a.textSplit(e))n?t[t.length-1]+=i.replace("­",""):t.push(i.replace("­","")),n=i.endsWith("­");return t}function TC(e,t){const n=NC(e).map(e=>e.trim()).filter(Boolean);if(!n.length)return{words:[],space:0};const[i,...o]=t([" ",...n]);return{words:o,space:i}}function OC(e,t,n){return("function"==typeof e?e(t,0):e)??n}function WC(e,t,i){const o={"font-family":n.fontExists(OC(i.fontFamily,t,a.fontFamily)),"font-size":100,"font-weight":OC(i.fontWeight,t,400)};return TC(e,e=>n.textWidth(e,o).map(e=>e/100))}function jC(e,t,n){let i=1,o=0;for(const a of e.words){const r=a*t;if(r>n+RC)return 1/0;const s=o?o+e.space*t+r:r;s>n+RC?(i++,o=r):o=s}return i}function HC(e,t,n){if(!e(t))return null;let i=t,o=Math.max(t,n);for(;i<o;){const t=Math.ceil((i+o)/2);e(t)?i=t:o=t-1}return i}function IC(e,t,n={}){const{width:i,height:o}=e;if(!(t.words.length&&i>0&&o>0))return null;const a=EC(n),r=(e,n)=>HC(i=>function(e,t,n,i,o={}){const{padding:a,lineHeight:r,maxLines:s}=EC(o),c=n-2*a;if(c<=0)return!1;for(let n=1;n<=s;n++){if(n*r*t+2*a>i)return!1;if(jC(e,t,c)<=n)return!0}return!1}(t,i,e,n,a),a.fontMin,a.fontMax),s=r(i,o),c=o>i?r(o,i):null,l=e.x+i/2,h=e.y+o/2;return null!==s&&(null===c||s>=c)?{orientation:"upright",x:l,y:h,width:i,height:o,rotate:0,fontSize:s}:null===c?null:{orientation:"rotated",x:l,y:h,width:o,height:i,rotate:-90,fontSize:c}}function GC(e,t){return e._drawLabel(t.datum,t.i??0,t.level)}function VC(e,t){return(e.ctx.icicleGhosts??[]).map(e=>({type:"rect",key:`icicle-${e.id}`,...e.rect,paint:{fill:t(e),opacity:1}}))}const qC={out:.06,in:.06};function YC(e){let t=e;for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}const KC={prefix:"icicle",origin:function(e){return{x0:e.x0,x1:e.x1,depth:e.depth}}},UC={name:"Icicle",layoutStage:PC,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=au(e,"Rect"),o=e.schema.sum,a=e.schema.locale,s=function(e,t){return CC(e.schema,t,{color:e.ctx.icicleDefaultColor,fill:e.ctx.icicleDefaultFill},"Rect")}(e,i),c=e.ctx.icicleEnterRects??new Map,l=e.ctx.icicleEnterWindows??new Map,h=n.map(t=>{const n=t.i??0;return{type:"rect",key:`icicle-${t.id}`,x:t.x,y:t.y,width:t.width,height:t.height,enterRect:c.get(t.id),enterWindow:l.get(t.id),datum:t.datum,paint:{fill:nu(i,t.datum,n,s(t)),stroke:tu(i.stroke,t.datum,n),strokeWidth:tu(i.strokeWidth,t.datum,n),opacity:tu(i.opacity,t.datum,n)??1},aria:{label:`${GC(e,t)}, ${o(t.datum)}, ${d.formatAbbreviate(100*t.share,a)}%`}}}),u=qy(i,h,e=>[n[e].datum,n[e].i??0]),f=ru(e,"Rect")??{},m="number"==typeof f.fontMin?f.fontMin:8,p="number"==typeof f.fontMax?f.fontMax:24,g=function(e,t,n,i){const o=new Map;for(const a of t){const t=IC(a,WC(GC(e,a),a.datum,n),i);t&&o.set(a,t)}return o}(e,n,f,{fontMin:m,fontMax:p}),y=n.filter(e=>g.has(e)),x=e=>g.get(e),b=e.ctx.icicleNodes,_=iw({data:y,label:t=>GC(e,t),x:e=>x(e).x,y:e=>x(e).y,rotate:e=>x(e).rotate,aes:()=>({}),id:e=>`icicle-${e.id}`,datum:e=>e.datum,labelBounds:e=>{const{width:t,height:n}=x(e);return{x:-t/2,y:-n/2,width:t,height:n}},labelConfig:{fontMax:p,fontMin:m,split:NC,fontResize:!0,padding:2,textAnchor:"middle",verticalAlign:"middle",fontColor:t=>{const n=b.get(YC(t)),i=n?s(n):void 0;return r.colorContrast(i??"rgb(255, 255, 255)",e.schema.colorDefaults)},...f}});for(const e of _)e.fadeSwap=qC;const k=new Map(n.map(e=>[e.datum,l.get(e.id)]));for(const e of[...u,..._])e.datum&&(e.enterWindow=k.get(YC(e.datum)));return[...VC(e,s),...h,...u,..._]},thresholdFunction:gC,setup:e=>vC(e,KC),ctx:{},fields:[{key:"orient",default:"horizontal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...wC})},{key:"sort",default:yC,decorate:xC},{key:"sum",default:T("value"),coerce:bC,onSet:_C},{key:"shapeConfig",merge:!0,factory:e=>({Rect:{labelConfig:{fontResize:!0}},stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:kC},{key:"legend",coerce:"const",factory:cw}]};var XC=xf(UC);const QC="::stem";function ZC(e,t,n){const i=(e.transform?.x??0)+e.x,o=(e.transform?.y??0)+e.y,a=i+e.width,r=o+e.height;if("x"===t){const t=i+e.width/2;return!f.finite(n)||Math.abs(o-n)<=Math.abs(r-n)?{x:t,y:o,x0:t,y0:r}:{x:t,y:r,x0:t,y0:o}}const s=o+e.height/2;return!f.finite(n)||Math.abs(a-n)<=Math.abs(i-n)?{x:a,y:s,x0:i,y0:s}:{x:i,y:s,x0:a,y0:s}}function JC(e){const t=[];for(const n of e)t.push({__d3plus__:!0,data:n,i:n.i,end:!1}),t.push({__d3plus__:!0,data:n,i:n.i,end:!0});return t}function eM(e,t){let n=0;for(const i of e){const e="function"==typeof t?t(i.data,i.i):t;f.finite(e)&&e>n&&(n=e)}return n}function tM(e){const t=this.schema.shapeConfig.Circle,n=eM(e.data,t?.r);return Bf.call(this,{...e,buffer:n+2})}function nM(e){const t=e.datum,n={...e,datum:t?.data??e.datum,shapeType:"Circle"};return delete n.interactionPoints,n}function iM(e,t,n){const{viz:i}=e,o=e=>n.get(e.data),a=eu("Line").renderMode("compute").config(e.shapeConfig).data(JC(t));i._wirePlotShapeEvents(a,"Circle",e.events);const r=au(i,"Line");return void 0===i.schema.shapeConfig.duration&&delete r.duration,a.config(r).config({curve:"linear",id:e=>`${e.data.id}${QC}`,label:!1,x:e=>e.end?o(e).x:o(e).x0,y:e=>e.end?o(e).y:o(e).y0}),su(a).map(nM)}function oM(e,t,n){const i=de({...e.shapeConfig,x:e=>n.get(e).x,y:e=>n.get(e).y});return ux.Circle({...e,shapeConfig:i,values:t},"Circle")}const aM=(e,t)=>{const n=ux.Bar(e),i=function(e,t){const{viz:n}=e,i="y"===n.schema.discrete?"y":"x",o="x"===i?"y":"x",a="x"===i?e.y:e.x,r=new Map;for(const e of t){if("rect"!==e.type||"Bar"!==e.shapeType||`${e.key}`.endsWith("::hit"))continue;const t=e.datum;if(!t||r.has(t))continue;const n=void 0!==t[`${o}2`],s=n?t[`${o}2`]:t[o];r.set(t,ZC(e,i,a(s,n?`${o}2`:void 0)))}return r}(e,n),o=e.values.filter(e=>i.has(e)),a=n.filter(e=>`${e.key}`.endsWith(pp));return[...iM(e,o,i),...a,...oM(e,o,i)]},rM=wb.fields.find(e=>"legend"===e.key),sM=e=>(t,n)=>{const i=e.schema.shapeConfig.fill;return"function"==typeof i?i(t,n):i},cM={name:"Lollipop",paintDriven:!0,setup:e=>{e._buffer={...e._buffer,Bar:tM},e._plotShapeEmitters={Bar:aM},e._plotCircleShapes=["Bar"],e._plotColumnHighlight=Lk(e)},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},rM,{key:"shape",default:N("Bar"),coerce:"const"},{key:"legendConfig",merge:!0,default:{shape:"Circle"}},{key:"shapeConfig",merge:!0,factory:e=>({Bar:{label:!1},Circle:{label:!1,trail:!1},Line:{label:!1,stroke:sM(e)}})}]};var lM=xf(cM,_b);function hM(e){const t=t=>{const n=t.map(t=>{const n=function(e){for(let t=0;t<e.length;t++){const n=(e[t].data||[]).find(t=>t.id===e.key);if(n)return n}}(t);return n&&n.data?e(n.data,n.i??0):`${t.key}`}),i=new Map;n.forEach((e,n)=>i.set(e,(i.get(e)??0)+function(e){let t=0;for(let n=0;n<e.length;n++)t+=Math.abs(+e[n][1]||0);return t}(t[n])));const o=Array.from(i.keys()).sort((e,t)=>i.get(t)-i.get(e)),a=new Map(o.map((e,t)=>[e,t]));return t.map((e,t)=>t).sort((e,t)=>a.get(n[e])-a.get(n[t])||e-t)};return t.__d3plusStackOrder=!0,t}function uM(e){return e._stackOffset===Ep("expand")}function dM(e,t){return`${d.formatAbbreviate(100*e,t)}%`}function fM(e){return e.schema.stacked&&uM(e)?{[bf(e)]:{rounding:"none",tickFormat:t=>dM(t,e.schema.locale)}}:{}}function mM(e){return"y"===bf(e)?{x:"all",y:"outer"}:{x:"outer",y:"all"}}function pM(e){return e.schema.stacked&&uM(e)?{[bf(e)]:!0}:{}}const gM={name:"Marimekko",paintDriven:!0,defaults:{groupPadding:1},facet:{axes:mM,fixedAxes:pM},setup:e=>{e._stackOffset=Ep("expand"),e._stackOrder=hM((t,n)=>e._ids(t,n).slice(0,e._drawDepth+1).join("_"));const t=e._preDraw.bind(e);e._preDraw=()=>{e._plotAxisDefaults=fM(e),t()}},ctx:{},fields:[{key:"barWidth",coerce:fm,factory:function(e){return mm((t,n)=>{const i="y"===e.schema.discrete?e._x:e._y;return i?i(t,n??0):void 0},"Bar Total")}},{key:"barWidthShare",default:!0},{key:"stacked",default:!0},{key:"tooltipShared",default:!1}]};var yM=xf(gM,Sb);function xM(e){const t=this._filteredData,n=(this.schema.rowList||o.unique(t.map(this.schema.row))).sort(this.schema.rowSort),i=(this.schema.columnList||o.unique(t.map(this.schema.column))).sort(this.schema.columnSort);if(!n.length||!i.length)return{rowValues:[],columnValues:[],shapeData:[]};var a,r;return{rowValues:n,columnValues:i,shapeData:(a=n,r=i,[].concat(...a.map(e=>r.map(t=>[e,t])))).map(([e,n])=>{const i={__d3plusTooltip__:!0,__d3plus__:!0,column:n,row:e},o=t.findIndex((t,i)=>this.schema.row(t,i)===e&&this.schema.column(t,i)===n);return o>=0?(i.i=o,i.data=t[o]):i.data={row:e,column:n},i})}}const bM=({viz:e})=>{const t=xM.bind(e)(e._filteredData),{rowValues:n,columnValues:i,shapeData:o}=t;if(!n.length||!i.length)return{shapeData:[]};const{width:a,height:r}=ie(e),s=a/i.length<120||void 0;e._padding={top:0,right:0,bottom:0,left:0};const c=e.ctx.rowAxis,l=e.ctx.columnAxis,h=e.schema.rowConfig,u=e.schema.columnConfig;c.domain(n).height(r-e._padding.bottom-e._padding.top).maxSize(a/4).width(a).config(h).measure();const d=c.outerBounds().width;e._padding.left+=d,l.domain(i).range([e._margin.left+e._padding.left,e._margin.left+a-e._padding.right]).height(r).maxSize(r/4).width(a).labelRotation(s).config(u).measure();const f=l.outerBounds().height;e._padding.top+=f,c.renderMode("compute").select(void 0).height(r-e._padding.bottom).maxSize(d).range([f+l.padding(),void 0]).render();const m=c.toScene();var p;m&&((p=e)._chartScene||(p._chartScene=[])).push({type:"group",key:"matrix-row-axis",transform:{x:e._margin.left,y:0},children:m.children??[]});l.renderMode("compute").select(void 0).range([e._margin.left+e._padding.left+c.padding(),e._margin.left+a-e._padding.right]).maxSize(f).render();const g=l.toScene();var y;g&&((y=e)._chartScene||(y._chartScene=[])).push({type:"group",key:"matrix-column-axis",transform:{x:0,y:0},children:g.children??[]});const x=c._getPosition.bind(c),b=l._getPosition.bind(l),_=n.length>1?x(n[1])-x(n[0]):c.height(),k=i.length>1?b(i[1])-b(i[0]):l.width();return e.ctx.columnScale=b,e.ctx.rowScale=x,e.ctx.cellWidth=k,e.ctx.cellHeight=_,{shapeData:o}},_M={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},kM=(e,t)=>`${e}`.localeCompare(`${t}`),vM={name:"Matrix",layoutStage:bM,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.ctx.columnScale,o=e.ctx.rowScale,a=e.ctx.cellWidth,r=e.ctx.cellHeight,s=e.schema.cellPadding??0,c=au(e,"Rect"),l=e.schema.colorScale,h=n.map((e,t)=>{const n=tu(c.fill,e,t),h=tu(c.stroke,e,t),u=tu(c.strokeWidth,e,t),d=a-s,f=r-s,m=i(e.column)+a/2-d/2,p=o(e.row)+r/2-f/2,g=l?`, ${l(e.data??e,t)}`:"";return{type:"rect",key:`matrix-${t}`,x:m,y:p,width:d,height:f,datum:e,paint:{fill:nu(c,e,t,n),stroke:h,strokeWidth:u},aria:{label:`${e.row}, ${e.column}${g}.`}}});return[...h,...qy(c,h,e=>[n[e],e])]},chartTransform:e=>({x:0,y:e._margin.top}),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(n,i,o,a)=>{if(t(n,i,o,a),Ra(o)||Ra(n))return;const r=ze.bind(e)("row",n,i),s=ze.bind(e)("column",n,i),c=e.schema.colorScale;e.hover((t,n)=>!(ze.bind(e)("row",t,n)!==r&&ze.bind(e)("column",t,n)!==s||"function"==typeof c&&"number"!=typeof c(t,n)))}},facet:{aspect:1},ctx:{rowAxis:new hi,columnAxis:new hi},fields:[{key:"cellPadding",default:2},{key:"column",default:T("column"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"row",default:T("row"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:kM},{key:"rowSort",default:kM},{key:"rowConfig",merge:!0,default:{orient:"left",..._M}},{key:"columnConfig",merge:!0,default:{orient:"top",..._M}},{key:"label",coerce:"const",factory:e=>(t,n)=>`${ze.bind(e)("row",t,n)} / ${ze.bind(e)("column",t,n)}`}]};var wM=xf(vM);function SM(e){const t=e._filteredData.reduce((t,n,i)=>(t[e._id(n,i)]=n,t),{});let n=e.schema.nodes.reduce((t,n,i)=>(t[((t,n)=>`${e._id(t,n)||e.schema.nodeGroupBy[h.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](t,n)}`)(n,i)]=n,t),{});const i=Array.from(new Set(Object.keys(t).concat(Object.keys(n)))).map((i,o)=>{const a=t[i],r=n[i];if(void 0===r)return!1;const s=(e,t=e=>void 0!==e)=>void 0!==a&&t(e(a))?e(a):e(r);return{__d3plus__:!0,data:a||r,i:o,id:i,fx:s(e._x,e=>!isNaN(e)),fy:s(e._y,e=>!isNaN(e)),node:r,r:e._size?s(e._size):e.schema.sizeMin,shape:s(e.schema.shape)}}).filter(e=>!!e);return n={},i}function CM(e,t){const n=t.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=n;const i=new Map;for(const e of t)i.set(e.node,e);const o=e.schema.links.map(t=>{const o=typeof t.source;return{size:e.schema.linkSize(t),source:"number"===o?i.get(e.schema.nodes[t.source]):"string"===o?n[t.source]:n[t.source.id],target:"number"===o?i.get(e.schema.nodes[t.target]):"string"===o?n[t.target]:n[t.target.id]}});return e.ctx.linkLookup=o.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{}),o}function MM(e,t,n){if(!t.some(e=>void 0===e.fx||void 0===e.fy))return;const i=`${t.map(e=>e.id).join("\0")}|${n.map(e=>`${e.source.id}>${e.target.id}:${e.size}`).join("\0")}`,o=e.ctx.networkForceCache;o&&o.key===i?t.forEach((e,t)=>{e.fx=o.positions[t][0],e.fy=o.positions[t][1]}):(!function(e,t){const n=B.scaleLinear().domain(h.extent(t,e=>e.size)).range([.1,.5]),i=z.forceSimulation().force("link",z.forceLink(t).id(e=>e.id).distance(1).strength(e=>n(e.size)).iterations(4)).force("charge",z.forceManyBody().strength(-1)).stop(),o=1-Math.pow(.001,.01);i.velocityDecay(0),i.alphaMin(.001),i.alphaDecay(o),i.alphaDecay(0),i.nodes(e),i.tick(100).stop();const a=e.map(e=>[e.vx??0,e.vy??0]);let r=0,s=0,c=0;if(2===a.length)r=100;else if(a.length>2){const e=D.polygonHull(a)||[],t=f.largestRect(e,{verbose:!0});r=t.angle,s=t.cx,c=t.cy}e.forEach(e=>{const t=f.pointRotate([e.vx??0,e.vy??0],Math.PI/180*r*-1,[s,c]);e.fx=t[0],e.fy=t[1]})}(t,n),e.ctx.networkForceCache={key:i,positions:t.map(e=>[e.fx,e.fy])})}function $M(e,t,n,i){const o=h.extent(t.map(e=>e.fx)),a=h.extent(t.map(e=>e.fy)),r=B.scaleLinear().domain(o).range([0,n]),s=B.scaleLinear().domain(a).range([0,i]),c=(o[1]-o[0])/(a[1]-a[0])||1,l=n/i;if(c>l){const e=i*l/c;s.range([(i-e)/2,i-(i-e)/2])}else{const e=n*c/l;r.range([(n-e)/2,n-(n-e)/2])}t.forEach(e=>{e.x=r(e.fx),e.y=s(e.fy)});const u=h.extent(t.map(e=>e.r));let d=e.schema.sizeMax||h.max([1,h.min(h.merge(t.map(e=>t.map(t=>e===t?null:f.pointDistance([e.x??0,e.y??0],[t.x??0,t.y??0])))))/2]);const m=B[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(u).range([u[0]===u[1]?d:h.min([d/2,e.schema.sizeMin]),d]),p=r.domain(),g=s.domain(),y=p[1]-p[0],x=g[1]-g[0];t.forEach(e=>{const t=m(e.r)+3,n=e.x??0,i=e.y??0;p[0]>r.invert(n-t)&&(p[0]=r.invert(n-t)),p[1]<r.invert(n+t)&&(p[1]=r.invert(n+t)),g[0]>s.invert(i-t)&&(g[0]=s.invert(i-t)),g[1]<s.invert(i+t)&&(g[1]=s.invert(i+t))});const b=p[1]-p[0],_=g[1]-g[0];d*=h.min([y/b,x/_]),m.range([u[0]===u[1]?d:h.min([d/2,e.schema.sizeMin]),d]),r.domain(p),s.domain(g);const k=(c>l?n:i)/2;return t.forEach(e=>{e.x=r(e.fx),e.fx=e.x,e.y=s(e.fy),e.fy=e.y,e.r=m(e.r)||k,e.width=2*e.r,e.height=2*e.r}),m}const AM=({viz:e})=>{const t=e,{width:n,height:i}=ie(t);Array.isArray(t._filteredData)||(t._filteredData=[]),Array.isArray(t.schema.nodes)||(t.schema.nodes=[]),Array.isArray(t.schema.links)||(t.schema.links=[]);const o=SM(t),a=CM(t,o);MM(t,o,a);const r=$M(t,o,n,i);t._sizeLegendFinal=t._size?r:null,function(e,t,n){const i=h.extent(t,e=>e.size);if(i[0]!==i[1]){const o=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(i).range([e.schema.linkSizeMin,n.range()[0]]);t.forEach(e=>{e.size=o(e.size)})}}(t,a,r);const s=au(t,"Path",t.schema.shapeConfig,"edge");delete s.on;const c={label:e=>!!(o.length<=t.schema.dataCutoff||t._hover&&t._hover(e)||t._active&&t._active(e))&&t._drawLabel(e.data||e.node,e.i)},l=Array.from(h.groups(o,e=>e.shape));return t.ctx.networkCtx={links:a,linkConfig:s,linkD:e=>`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeGroups:l,nodeShapeConfig:c},{shapeData:o}};function zM(e,t,n){const i="function"==typeof e?e(t,n):e;return!0===i||"target"===i?{source:!1,target:!0}:"source"===i?{source:!0,target:!1}:"both"===i?{source:!0,target:!0}:{source:!1,target:!1}}const DM=e=>Math.round(100*e)/100;function FM(e,t,n,i){const o=.6*i,a=e-Math.cos(n)*i,r=t-Math.sin(n)*i,s=Math.cos(n+Math.PI/2),c=Math.sin(n+Math.PI/2);return`M${DM(e)},${DM(t)}L${DM(a+s*o)},${DM(r+c*o)}L${DM(a-s*o)},${DM(r-c*o)}Z`}function BM(e,t,n,i,o,a=1){const r=Math.atan2(i-t,n-e);return{x:n-Math.cos(r)*(o+a),y:i-Math.sin(r)*(o+a),angle:r}}function LM(e,t,n,i){const o="function"==typeof e?e(t,n):e;return"number"==typeof o?o:Math.max(6,3*i)}function PM(e){const t=zM(e.arrows,e.datum,e.i);if(!t.source&&!t.target)return[];const n=LM(e.arrowSize,e.datum,e.i,"number"==typeof e.strokeWidth?e.strokeWidth:1),{source:i,target:o,datum:a,fill:r,keyPrefix:s}=e,c=[];if(t.target){const e=BM(i.x,i.y,o.x,o.y,o.r??0,1);c.push(RM({key:`${s}-t`,datum:a,x:e.x,y:e.y,angle:e.angle,size:n,fill:r}))}if(t.source){const e=BM(o.x,o.y,i.x,i.y,i.r??0,1);c.push(RM({key:`${s}-s`,datum:a,x:e.x,y:e.y,angle:e.angle,size:n,fill:r}))}return c}function RM(e){return{type:"path",key:e.key,d:FM(e.x,e.y,e.angle,e.size),datum:e.datum,interactive:!1,paint:{fill:e.fill,...void 0!==e.opacity?{opacity:e.opacity}:{}}}}function EM(e,t,n,i,o,a,r){return PM({arrows:e.schema.arrows,arrowSize:e.schema.arrowSize,strokeWidth:o,datum:n,i:a,keyPrefix:r,fill:"string"==typeof i?i:void 0,source:t.source,target:t.target})}function NM(e,t,n,i,o){const a=`network-${e}-${t.id}`;if("Circle"===e)return{type:"circle",key:a,cx:t.x,cy:t.y,r:t.r,...i};if("Rect"===e){const e=Number(t.width??tu(n.width,i.datum,o)??0),r=Number(t.height??tu(n.height,i.datum,o)??0);return{type:"rect",key:a,x:t.x-e/2,y:t.y-r/2,width:e,height:r,...i}}return null}function TM(e,t,n){return`${e._id(t,n)||e.schema.nodeGroupBy[h.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](t,n)}`}function OM(e,t,n){const i=b.zoomTransform((e._zoomEventTarget||e._container).node()),{x:o=0,y:a=0}=e._chartTransform||{};e._zoomToBounds([[(t[0]+o)*i.k+i.x,(n[0]+a)*i.k+i.y],[(t[1]+o)*i.k+i.x,(n[1]+a)*i.k+i.y]])}function WM(e,t){!function(e,t){e.schema.on["click.shape"]=(n,i,o,a)=>{if(e._tooltipClass.data([]).render(),e._drawDepth>=e.schema.groupBy.length-1){const r=TM(e,n,i);if(e._focus&&e._focus===r)t.active(!1),e.schema.on.mouseenter.bind(e)(n,i,o,a),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const n=e.ctx.linkLookup[r]??[],i=e.ctx.nodeLookup[r];if(!i)return;const o=[r],a=[i.x-i.r,i.x+i.r],s=[i.y-i.r,i.y+i.r];n.forEach(e=>{o.push(e.id),e.x-e.r<a[0]&&(a[0]=e.x-e.r),e.x+e.r>a[1]&&(a[1]=e.x+e.r),e.y-e.r<s[0]&&(s[0]=e.y-e.r),e.y+e.r>s[1]&&(s[1]=e.y+e.r)}),t.active((t,n)=>t.source&&t.target?t.source.id===r||t.target.id===r:o.includes(TM(e,t,n))),e._focus=r,OM(e,a,s)}}}}(e,t),function(e,t){e.schema.on["click.legend"]=(n,i,o,a)=>{const r=e._ids(n,i),s=r[r.length-1],c=e._id(n,i);if(e._drawDepth>=e.schema.groupBy.length-1){if(e._focus&&e._focus===c)t.active(!1),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const n=(Array.isArray(c)?c:[c]).map(t=>e.ctx.nodeLookup[String(t)]),i=[`${s}`],o=[n[0].x-n[0].r,n[0].x+n[0].r],a=[n[0].y-n[0].r,n[0].y+n[0].r];n.forEach(e=>{i.push(e.id),e.x-e.r<o[0]&&(o[0]=e.x-e.r),e.x+e.r>o[1]&&(o[1]=e.x+e.r),e.y-e.r<a[0]&&(a[0]=e.y-e.r),e.y+e.r>a[1]&&(a[1]=e.y+e.r)}),t.active((t,n)=>{if(t.source&&t.target)return i.includes(t.source.id)&&i.includes(t.target.id);const o=e._ids(t,n);return i.includes(`${o[o.length-1]}`)}),e._focus=c,OM(e,o,a)}e.schema.on.mouseenter.bind(e)(n,i,o,a),e.schema.on["mousemove.legend"].bind(e)(n,i,o,a)}}}(e,t),function(e,t){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,o,a,r)=>{n(i,o,a,r);const s=TM(e,i,o),c=e.ctx.linkLookup[s]??[],l=e.ctx.nodeLookup[s];if(!l)return;const h=[s],u=[l.x-l.r,l.x+l.r],d=[l.y-l.r,l.y+l.r];c.forEach(e=>{h.push(e.id),e.x-e.r<u[0]&&(u[0]=e.x-e.r),e.x+e.r>u[1]&&(u[1]=e.x+e.r),e.y-e.r<d[0]&&(d[0]=e.y-e.r),e.y+e.r>d[1]&&(d[1]=e.y+e.r)}),t.hover((t,n)=>t.source&&t.target?t.source.id===s||t.target.id===s:h.includes(`${e._ids(t,n)[e._drawDepth]}`))}}(e,t)}const jM={name:"Network",layoutStage:AM,sizeLegendScale:(e,{width:t,height:n})=>function(e,t,n){if(!e._size)return null;if(!Array.isArray(e._filteredData)||!Array.isArray(e.schema.nodes)||!Array.isArray(e.schema.links))return null;const i=SM(e);if(!i.length)return null;const{nodeLookup:o,linkLookup:a}=e.ctx,r=CM(e,i);return e.ctx.nodeLookup=o,e.ctx.linkLookup=a,MM(e,i,r),$M(e,i,t,n)}(e,t,n),emit:({viz:e})=>{const t=e.ctx.networkCtx;if(!t)return[];const n=[];if(t.links&&t.links.length&&n.push(...function(e,t){const n=[];for(let i=0;i<t.links.length;i++){const o=t.links[i],a=o,r=iu(t.linkConfig,a,i);"number"==typeof o.size&&(r.strokeWidth=o.size);const s="number"==typeof o.size?`, ${o.size}`:"",c=o.source.id??"",l=o.target.id??"";n.push({type:"path",key:`network-link-${c}-${l}-${i}`,d:t.linkD(o),datum:a,paint:r,aria:{label:`${ou(e,o.source,0)} to ${ou(e,o.target,0)}${s}.`}}),n.push(...EM(e,o,a,r.stroke,r.strokeWidth,i,`network-arrow-${c}-${l}-${i}`))}return n}(e,t)),t.nodeGroups&&t.nodeGroups.length)for(const[i,o]of t.nodeGroups){if(!o.length)continue;const a={...au(e,i),...t.nodeShapeConfig},s=[];for(let t=0;t<o.length;t++){const r=o[t],c=r.data??r,l=iu(a,c,r.i??t);void 0===l.vectorEffect&&(l.vectorEffect="non-scaling-stroke");const h=e._size,u=h?`, ${h(c,r.i??t)}`:"",d={label:`${ou(e,r,t)}${u}.`},f=NM(i,r,a,{datum:c,paint:l,aria:d},r.i??t);if(!f)continue;n.push(f);const m=Vy(a,f,c,r.i??t);m&&s.push(m)}n.push(...s);const c=t.nodeShapeConfig.label;if(c){const t=iw({data:o,label:(e,t)=>c(e,t),x:e=>e.x,y:e=>e.y,aes:e=>{const t=e;return"Circle"===i?{r:t.r,width:2*t.r,height:2*t.r}:{width:t.width??0,height:t.height??0}},rotate:N(0),id:e=>`network-label-${e.id}`,labelBounds:(e,t,n)=>{const o=n;if("Circle"===i){const e=o.r??0;return{width:1.5*e,height:1.5*e,x:.75*-e,y:.75*-e}}const a=o.width??0,r=o.height??0;return{width:a,height:r,x:-a/2,y:-r/2}},labelConfig:{...a.labelConfig??{fontResize:!0},fontColor:t=>{const n=t.data??t,i=tu(a.fill,n.data??n,n.i??0);return r.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)",e.schema.colorDefaults)},...ru(e,i)}});n.push(...t)}}return n},insetRegion:Uu,setup:e=>{const t=e;WM(e,t),function(e){e.links=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},e.nodes=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},e.nodeGroupBy=function(e){if(!arguments.length)return this.schema.nodeGroupBy;const t=e instanceof Array?e:[e];return this.schema.nodeGroupBy=t.map(e=>{if("function"==typeof e)return e;const t=e;return this.schema.aggs[t]||(this.schema.aggs[t]=(e,t)=>{const n=Array.from(new Set(e.map(t)));return 1===n.length?n[0]:n}),Be(t)}),this},e.size=function(e){return arguments.length?(this._size="function"!=typeof e&&e?Be(e):e,this._sizeKey="string"==typeof e?e:void 0,this):this._size},e.x=function(e){if(!arguments.length)return this._x;if("function"==typeof e)this._x=e;else{const t=e;this._x=Be(t),this.schema.aggs[t]||(this.schema.aggs[t]=h.mean)}return this},e.y=function(e){if(!arguments.length)return this._y;if("function"==typeof e)this._y=e;else{const t=e;this._y=Be(t),this.schema.aggs[t]||(this.schema.aggs[t]=h.mean)}return this},e.hover=ow}(t),e._x=T("x"),e._y=T("y");const n=t._draw.bind(e);t._draw=function(t){const i=n(t),{width:o,height:a}=ie(e);return tr(e,{kind:"network",width:o,height:a,duration:e.schema.duration}),i}},facet:{aspect:1},ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"links",default:[]},{key:"linkSize",default:N(1),coerce:e=>"function"==typeof e?e:N(e)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[T("id")]},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:N("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e._size,o=i?`, ${i(t,n)}`:"";return`${e._drawLabel(t,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#adb5bd"}})}]};var HM=xf(jM);const IM=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const n=e.schema.height-e._margin.top-e._margin.bottom,i=e.schema.width-e._margin.left-e._margin.right,a=Math.min(n,i),r=o.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),s=e.schema.packOpacity,c=e.ctx.pack.padding(e.schema.layoutPadding).size([a,a])(A.hierarchy({key:r.key,values:r},e=>e.values).sum(e.schema.sum).sort(e.schema.sort)).descendants().filter((e,t)=>{const n=e;n.__d3plus__=!0,n.i=t,n.id=n.parent?n.parent.data.key:"root";const i=n.data;return i.__d3plusOpacity__=n.height?s(i,t):1,i.__d3plusTooltip__=!n.height,!n.children||n.children.length>1});return e.ctx.packDiameter=a,e.ctx.packOffsetX=(i-a)/2,e.ctx.packOffsetY=(n-a)/2,{shapeData:c}};function GM(e,t=[]){return e.values?e.values.forEach(e=>{t.push(e),GM(e,t)}):t.push(e),t}const VM=e=>Array.isArray(e)?e:[e],qM={name:"Pack",layoutStage:IM,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=au(e,"Circle"),o=(e.schema.shapeConfig.Circle??{}).label,a=n.map((t,n)=>{const o=t.data,a=tu(i.fill,o,n),r=tu(i.stroke,o,n),s=tu(i.strokeWidth,o,n);return{type:"circle",key:`pack-${t.id}-${t.i}`,cx:t.x,cy:t.y,r:t.r,shapeType:"Pack",datum:o,paint:{fill:nu(i,o,n,a),stroke:r,opacity:o.__d3plusOpacity__,strokeWidth:s},aria:{label:`${e._drawLabel(o,t.i)}, ${t.value}.`}}}),r=iw({data:n,label:(e,t)=>{const n=e;return!n.children&&(o?o(n.data,t):!!n.parent&&(n.data.id??!1))},x:e=>e.x,y:e=>e.y,datum:e=>e.data,aes:e=>{const t=e.r;return{r:t,width:2*t,height:2*t}},rotate:N(0),id:e=>e.id,labelBounds:(e,t,n)=>{const i=n.r;return{width:1.6*i,height:.8*i,x:.8*-i,y:.4*-i}},labelConfig:{fontResize:!0,...ru(e,"Circle")}}),s=qy(i,a,e=>[n[e].data,e]);return[...a,...s,...r]},insetRegion:Uu,chartTransform:e=>({x:e._margin.left+(e.ctx.packOffsetX??0),y:e._margin.top+(e.ctx.packOffsetY??0)}),chartBodyRect:e=>{const t=e.ctx.packDiameter??0;return{x:0,y:0,width:t,height:t}},setup:e=>{const t=e.hover.bind(e);e.hover=n=>(t(n),e.schema.legend&&e._legendClass.hover(n),e)},facet:{aspect:1},ctx:{pack:A.pack()},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0)},{key:"sum",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"packOpacity",default:N(.25),coerce:e=>"function"==typeof e?e:N(e)},{key:"shape",default:N("Circle"),coerce:e=>"function"==typeof e?e:N(e)},{key:"shapeConfig",merge:!0,factory:()=>({Circle:{label:e=>{const t=e;return!(!t.parent||t.children)&&t.id},labelConfig:{fontResize:!0},opacity:e=>e.__d3plusOpacity__}})},{key:"legend",coerce:"const",factory:cw},{key:"on",merge:!0,factory:e=>{const t=e.schema.on["mousemove.legend"],n=e.schema.on["mousemove.shape"],i=t=>e.hover(t);return{mouseenter:()=>{},"mousemove.legend":(n,o,a,r)=>{t(n,o,a,r);const s=e._ids(n,o),c=GM(n);i(e=>(Object.keys(e).filter(e=>"value"!==e&&!e.startsWith("__d3plus")).every(t=>null!=n[t]&&VM(e[t]).every(e=>VM(n[t]).includes(e)))?c.push(e):s.includes(e.key)&&c.push(...GM(e,[e])),c.includes(e)))},"mousemove.shape":(e,t,o,a)=>{e.__d3plusTooltip__&&n(e,t,o,a);const r=GM(e,[e]);i(e=>r.includes(e))}}}}]};var YM=xf(qM);function KM(e){return"number"==typeof e&&Number.isFinite(e)}function UM(e){return null==e||""===e||"number"==typeof e&&!Number.isFinite(e)}function XM(e,t=[]){const n=new Set(t),i=[],o=new Map;for(const t of e)for(const e of Object.keys(t)){if(n.has(e)||e.startsWith("_"))continue;const a=t[e];o.has(e)||(o.set(e,!0),i.push(e)),UM(a)||KM(a)||o.set(e,!1)}return i.filter(t=>o.get(t)&&e.some(e=>KM(e[t])))}function QM(e){const t=e.filter(e=>!UM(e));return t.length&&t.every(KM)?"numeric":"categorical"}function ZM(e,t,n={}){const i=Array.isArray(n.domain)?n.domain:void 0;if("numeric"===t){const[t,n]=h.extent(e.filter(KM));return[i&&KM(i[0])?i[0]:t??0,i&&KM(i[i.length-1])?i[i.length-1]:n??0]}if(i)return i.map(String);return Array.from(new Set(e.filter(e=>!UM(e)).map(String))).sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))}function JM(e,t,n={},i){return e.map(e=>{const o=n[e]??{},a=t.map(t=>t[e]),r="point"===o.scale||"band"===o.scale?"categorical":QM(a),s=i?.[e]??ZM(a,r,o);return{key:e,title:"string"==typeof o.title?o.title:e,type:r,domain:s,reverse:Boolean(o.reverse)}})}function e$(e,t,n={}){const i={};for(const o of JM(e,t,n))i[o.key]=o.domain;return i}function t$(e){return e<=50?1:Math.max(.1,Math.round(100*Math.sqrt(50/e))/100)}function n$(e,t,n){if(e<=0)return[];if(1===e)return[(t+n)/2];const i=(n-t)/(e-1);return Array.from({length:e},(e,n)=>t+i*n)}const i$=1e4;function o$(e,t,n){const i=(new ro).data(e.map(e=>({id:`pc-title-${e.key}`,text:e.text}))).x((t,n)=>e[n].x).y((t,n)=>e[n].y).width((t,n)=>e[n].width).height((t,n)=>e[n].height).config(t);return n&&i.locale(n),i}function a$(e,t,n){if(!e.length)return[];const i=e.map((e,t)=>({key:`${t}`,text:e,x:0,y:0,width:i$,height:i$}));return o$(i,{...t,padding:0},n)._textData().map(e=>Math.ceil(Math.max(0,...e.widths)))}function r$(e,t,n){if(!e.length)return 0;const i=o$(e.map(e=>({...e,height:i$})),{...t,padding:0},n)._textData();return Math.ceil(Math.max(0,...i.map(e=>e.lines.length*e.lH)))}function s$(e,t,n){return e.length?o$(e,{...t,padding:0},n).toScene().children.map(e=>{const t={...e,interactive:!1,interactionGroup:"axis"};return delete t.datum,delete t.index,t}):[]}function c$(e,t){const n=e.domain.slice();return("numeric"===e.type?"horizontal"===t!==e.reverse:e.reverse)?n.reverse():n}function l$(e){if(!e)return{};const t={...e};return delete t.domain,delete t.reverse,delete t.title,t}function h$(e,t){const n=e.schema.axisConfig??{};return{fontColor:Ga(e),fontSize:12,textAnchor:"horizontal"===t?"middle":"end",verticalAlign:"horizontal"===t?"bottom":"middle",...n.titleConfig??{}}}function u$(e,t,n){const i=e.schema.dimensionConfig??{},o=(new hi).orient("horizontal"===n?"left":"bottom").align("start");o.renderMode("compute").select(null),o.config(Jp(e,{})).config(e.schema.axisConfig??{}).config(l$(i[t.key])),o.gridSize(0).title(!1);const a=o.scale();return"categorical"===t.type&&"point"!==a&&"band"!==a&&o.scale("point"),"numeric"!==t.type||"point"!==a&&"band"!==a||o.scale("linear"),o.domain(c$(t,n)),o}function d$(e,t){let n=0,i=t;for(const o of e){const e=o._d3Scale?.range()??[0,t];n=Math.max(n,Math.min(...e)),i=Math.min(i,Math.max(...e))}return i>n?[n,i]:[0,t]}function f$(e,t,n){const i=e=>{const t=e.children,n={...e,interactionGroup:"axis",interactive:!1};return delete n.datum,t&&(n.children=t.map(i)),n},o=e.toScene();return i({type:"group",key:`pc-axis-${t}`,transform:n,children:o.children})}function m$(e,t,n,i,o){const a=e._d3Scale,r="numeric"===t.type&&a&&"function"==typeof a.invert?e=>Number(a.invert(e-i)):void 0;return{dim:t,offset:n,start:i+o[0],end:i+o[1],position:n=>{const o=e._getPosition((e=>"categorical"===t.type?String(e):e)(n));return"number"==typeof o&&Number.isFinite(o)?i+o:NaN},invert:r}}function p$(e,t,n,i,o){return!t.length||n<=0||i<=0?{axes:[],nodes:[]}:"vertical"===o?function(e,t,n,i){const o=t.length,a=h$(e,"vertical"),r=e.schema.locale,s=a$(t.map(e=>e.title),a,r),c=Math.min(Math.max(0,...s)+4,.25*n),l=c?c+8:0,h=Math.max(0,n-l),u=Math.max(20,i/o*.5),d=t.map(t=>u$(e,t,"vertical").width(h).height(u).maxSize(u));d.forEach(e=>e.measure());const f=d.map(e=>e.outerBounds().height||0),m=r$(t.slice(0,1).map(e=>({key:e.key,text:"M",x:0,y:0,width:c||1,height:0})),a,r),p=n$(o,Math.max(4,m/2),i-Math.max(4,f[o-1])),g=o>1?p[1]-p[0]:i,y=d$(d,h),x=[],b=d.map((e,n)=>{e.range(y).render();const i=ni(e),o=i?i.points[0][1]:0;return x.push(f$(e,t[n].key,{x:l,y:p[n]-o})),m$(e,t[n],p[n],l,y)}),_=c?t.map((e,t)=>({key:e.key,text:e.title,x:0,y:p[t]-g/2,width:c,height:g})).filter(e=>e.text):[];return x.push(...s$(_,a,r)),{axes:b,nodes:x}}(e,t,n,i):function(e,t,n,i){const o=t.length,a=h$(e,"horizontal"),r=e.schema.locale,s=a$(t.map(e=>e.title),a,r),c=Math.max(30,n/o*.6),l=t.map(t=>u$(e,t,"horizontal").height(i).width(c).maxSize(c));l.forEach(e=>e.measure());const h=l.map(e=>e.outerBounds().width||0);let u=o>1?n/o:n,d=[],f=0,m=0;for(let e=0;e<2;e++)d=s.map(e=>Math.min(e+4,Math.max(u-8,40))),f=Math.max(h[0],d[0]/2,4),m=Math.max(d[o-1]/2,4),u=o>1?(n-f-m)/(o-1):n-f-m;const p=n$(o,f,n-m),g=t.map((e,t)=>({key:e.key,text:e.title,x:p[t]-d[t]/2,y:0,width:d[t],height:0})).filter(e=>e.text),y=r$(g,a,r),x=y?y+8:0;g.forEach(e=>e.height=y);const b=Math.max(0,i-x);l.forEach(e=>e.height(b).measure());const _=d$(l,b),k=[],v=l.map((e,n)=>{e.range(_).render();const i=ni(e),o=i?i.points[0][0]:h[n];return k.push(f$(e,t[n].key,{x:p[n]-o,y:x})),m$(e,t[n],p[n],x,_)});return k.push(...s$(g,a,r)),{axes:v,nodes:k}}(e,t,n,i)}function g$(e,t,n="horizontal"){return t.map(t=>{const i=e[t.key];if(UM(i))return null;const o=t.position(i);return"number"==typeof o&&Number.isFinite(o)?"horizontal"===n?[t.offset,o]:[o,t.offset]:null})}function y$(e,t="linear",n="horizontal"){const i="bump"===t?"horizontal"===n?y.curveBumpX:y.curveBumpY:y.curveLinear;return y.line().defined(e=>null!==e).x(e=>e[0]).y(e=>e[1]).curve(i)(e)??""}function x$(e){const t=e.schema.dimensions;if(Array.isArray(t))return t.map(String);const n=e._groupByRaw,i=(Array.isArray(n)?n:[n]).filter(e=>"string"==typeof e);return XM(e._data??[],["id",...i])}function b$(e){return"vertical"===e?"vertical":"horizontal"}function _$(e,t,n,i){const o=e.end-e.start,{dim:a}=e,r={id:`${n.left},${n.top}|${t}|${a.key}`,key:a.key,title:a.title,orient:t,type:a.type,domain:a.domain,position:e.position,invert:e.invert,alongStart:e.start};return"horizontal"===t?{...r,x:n.left+e.offset-i/2,y:n.top+e.start,width:i,height:o}:{...r,x:n.left+e.start,y:n.top+e.offset-i/2,width:o,height:i}}const k$=({viz:e})=>{var t;const n=(t=e.ctx).brushQueue??(t.brushQueue=[]),i=e._filteredData??[],o=x$(e);if(e.ctx.dimensions=[],e.ctx.axisNodes=[],!i.length||!o.length)return{shapeData:[]};const a=JM(o,i,e.schema.dimensionConfig??{},e.ctx.sharedDomains);e.ctx.dimensions=a;const r=b$(e.schema.orient),s="bump"===e.schema.curve?"bump":"linear",{width:c,height:l}=ie(e),h=p$(e,a,c,l,r);e.ctx.axisNodes=h.nodes;const u=e.schema.brushConfig??{},d="number"==typeof u.width?u.width:20;for(const t of h.axes)n.push(_$(t,r,e._margin,d));const f=h.axes.map(e=>({key:e.dim.key,offset:e.offset,position:e.position})),m=new Map;return{shapeData:i.map((t,n)=>{const i=`${e._id(t,n)}`,o=m.get(i)??0;return m.set(i,o+1),{data:t,i:n,id:o?`${i}-${o}`:i,d:y$(g$(t,f,r),s,r)}})}};function v$(e){return 2===e.length&&e.every(e=>KM(e))}function w$(e,t){if(v$(t)){if(!KM(e))return!1;const[n,i]=t[0]<=t[1]?t:[t[1],t[0]];return e>=n&&e<=i}return null!=e&&t.includes(String(e))}function S$(e,t){if(!t)return!0;for(const n of Object.keys(t))if(!w$(e[n],t[n]))return!1;return!0}function C$(e){return Boolean(e&&Object.keys(e).length)}function M$(e,t){const n=Math.min(e[0],e[1]),i=Math.max(e[0],e[1]);if("numeric"===t.type){if(!t.invert)return null;const e=t.invert(n),o=t.invert(i);return KM(e)&&KM(o)?e<=o?[e,o]:[o,e]:null}const o=t.domain.filter(e=>{const o=t.position(e);return o>=n&&o<=i}).map(String);return o.length?o:null}function $$(e,t,n=6){if(v$(e)){if("numeric"!==t.type)return null;const n=t.position(e[0]),i=t.position(e[1]);return KM(n)&&KM(i)?n<=i?[n,i]:[i,n]:null}const i=new Set(e.map(String)),o=t.domain.filter(e=>i.has(String(e))).map(e=>t.position(e)).filter(KM);return o.length?[Math.min(...o)-n,Math.max(...o)+n]:null}const A$="d3plus-parallel-brushes",z$="d3plus-parallel-brush",D$=new WeakMap;function F$(e){return"horizontal"===e.orient?e.height:e.width}function B$(e,t){if(!e)return null;const n=$$(e,t);if(!n)return null;const i=F$(t),o=Math.max(0,Math.min(i,n[0]-t.alongStart)),a=Math.max(0,Math.min(i,n[1]-t.alongStart));return a>o?[o,a]:null}function L$(e,n){const i=D$.get(e)?.clearLabel,o=t.select(e).attr("tabindex",n?0:null);o.selectAll(":scope > title").remove(),n&&i&&o.insert("title",":first-child").text(i)}function P$(e,n,i,o){const a=D$.get(n);if(!a)return;const r=a.target.key,s={...e.schema.brushes??{}};i?s[r]=i:delete s[r],e.schema.brushes=s;const c=n.parentNode;c&&t.select(c).selectAll(`g.${z$}`).each(function(e){const a=D$.get(this);a&&e.key===r&&(L$(this,Boolean(i)),(this!==n||o)&&t.select(this).call(a.brush.move,B$(i??void 0,a.target)))});const l=e.schema.on?.brush;"function"==typeof l&&l.call(e,s),e._scheduleSceneRepaint()}function R$(e,t){const n=D$.get(t),i=e.schema.brushes??{};return!(!n||!(n.target.key in i))&&(n.active=!1,P$(e,t,null,!0),!0)}function E$(e,n,i){const o=e._select&&"function"==typeof e._select.node?e._select.node():null;if(!o||"function"!=typeof o.querySelector)return;const a=!1!==e.schema.brushing&&!e._ssr&&n.length>0,r=t.select(o).selectAll(`:scope > g.${A$}`).data(a?[0]:[]);if(r.exit().remove(),!a)return;const s=r.enter().append("g").attr("class",`d3plus-viz-brush ${A$}`).merge(r),c=Array.from(new Map(n.map(e=>[e.id,e])).values()),l=s.selectAll(`g.${z$}`).data(c,e=>e.id);l.exit().remove();const h=e.schema.brushes??{},u=t=>e.schema.translate(t);l.enter().append("g").attr("class",z$).merge(l).each(function(n){const o=t.select(this);let a=D$.get(this);if(!a){const t="horizontal"===n.orient?p.brushY():p.brushX();a={brush:t,target:n,signature:"",active:!1,clearLabel:""},D$.set(this,a);const i=this;t.on("start brush end",t=>function(e,t,n){const i=D$.get(t);if(!i||!n.sourceEvent)return;const o=i.target;i.active="end"!==n.type;const a=n.selection;P$(e,t,a&&Math.abs(a[1]-a[0])>=1?M$([a[0]+o.alongStart,a[1]+o.alongStart],o):null,"end"===n.type&&"categorical"===o.type)}(e,i,t)),o.on("dblclick.clear",t=>{t.preventDefault(),t.stopPropagation(),R$(e,i)}).on("keydown.clear",t=>{"Escape"===t.key&&R$(e,i)&&(t.preventDefault(),t.stopPropagation())})}if(a.target=n,a.clearLabel=`${n.title}: ${u("Double-click or Escape to Clear")}`,o.attr("transform",`translate(${n.x},${n.y})`),a.active)return;const r=`${n.width}x${n.height}`;a.signature!==r&&(a.brush.extent([[0,0],[n.width,n.height]]),o.call(a.brush),a.signature=r),function(e,t,n){const i=e.selectAll("rect.selection"),o=[["fill",t.fill],["fill-opacity",t.fillOpacity],["stroke",t.stroke],["stroke-width",t.strokeWidth]];for(const[e,t]of o)null!=t&&i.attr(e,`${t}`);e.selectAll("rect.overlay").attr("aria-label",n)}(o,i,`${n.title}: ${u("Drag to Filter")}`),o.call(a.brush.move,B$(h[n.key],n)),L$(this,n.key in h)})}function N$(e,t,n){if(UM(n))return"";const i=e.schema.dimensionConfig??{},o=i[t]?.tickFormat;return"function"==typeof o?`${o(n)}`:KM(n)?d.formatAbbreviate(n,e.schema.locale):String(n)}function T$(e,t){return(e.ctx.dimensions??[]).map(n=>[n.title,N$(e,n.key,t[n.key])])}const O$="pc-line-",W$="::hit";function j$(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.min(1,Math.max(0,e)):t$(t)}function H$(e,t,n,i){const o=i.map(n=>`${n.title} ${N$(e,n.key,t[n.key])}`).join(", ");return`${e._drawLabel(t,n)}${o?`: ${o}`:""}.`}const I$=({viz:e,shapeData:t})=>{const n=t??[],i=e.ctx.axisNodes??[];if(!n.length)return i;const o=e.ctx.dimensions??[],a=au(e,"Line"),r=j$(e.schema.lineOpacity,n.length),s=[];return n.forEach(t=>{if(!t.d)return;const{data:n,i:i}=t,c=`${O$}${t.id}`,l=tu(a.strokeOpacity,n,i);s.push({type:"path",shapeType:"Line",key:c,d:t.d,datum:n,index:i,paint:{fill:"none",stroke:tu(a.stroke,n,i),strokeWidth:tu(a.strokeWidth,n,i),strokeOpacity:"number"==typeof l?l:r,strokeDasharray:tu(a.strokeDasharray,n,i),opacity:tu(a.opacity,n,i)},aria:{label:H$(e,n,i,o)}}),s.push({type:"path",shapeType:"Line",key:`${c}${W$}`,d:t.d,datum:n,index:i,paint:{fill:"none",stroke:"transparent",strokeWidth:8},aria:{hidden:!0}})}),[...s,...i]},G$=e=>"string"==typeof e.key&&e.key.includes(O$),V$=e=>"string"==typeof e.key&&e.key.endsWith(W$),q$=e=>"number"==typeof e.z&&e.z>0;function Y$(e,t){if(G$(e))return t(e);const n=e.children;return n&&n.length?{...e,children:n.map(e=>Y$(e,t))}:e}function K$(e){if(G$(e))return!V$(e)&&q$(e)?1:0;const t=e.children;return t?t.reduce((e,t)=>e+K$(t),0):0}function U$(e,t){const n=C$(t.brushes),i=1===K$(e);return n||i?Y$(e,e=>{const o={...e.paint??{}};if(n&&!S$(e.datum,t.brushes)){if(!V$(e)){const e="number"==typeof o.strokeOpacity?o.strokeOpacity:1;o.strokeOpacity=t.inactiveOpacity??.3*e,"string"==typeof o.stroke&&(o.stroke=r.colorGrayscale(o.stroke))}const n={...e,paint:o,interactive:!1};return delete n.z,n}return i&&q$(e)&&!V$(e)?(o.strokeOpacity=1,{...e,paint:o}):e}):e}function X$(e){const t={};for(const[n,i]of Object.entries(e))t[n]="function"==typeof i?i():i;return t}const Q$={name:"ParallelCoordinates",layoutStage:k$,emit:I$,decorateScene:function(e,t){const n=X$(e.schema.brushConfig??{}),i=e.ctx.brushQueue;i&&(e.ctx.brushQueue=void 0,E$(e,i,n));const o=U$(t.root,{brushes:e.schema.brushes,inactiveOpacity:"number"==typeof n.inactiveOpacity?n.inactiveOpacity:void 0});return o===t.root?t:{...t,root:o}},facet:{aspect:1.5,axes:"all",share:(e,t)=>e$(x$(e),t.flat(),e.schema.dimensionConfig??{}),panel:(e,t)=>{const n=e.ctx.sharedDomains;return e.ctx.sharedDomains=t.shared?t.scales:void 0,()=>{e.ctx.sharedDomains=n}}},ctx:{},fields:[{key:"brushes",default:{}},{key:"brushing",default:!0},{key:"curve",default:"linear"},{key:"dataCutoff",default:2e3},{key:"dimensions"},{key:"lineOpacity",default:"auto"},{key:"orient",default:"horizontal"},{key:"zoom",default:!1},{key:"axisConfig",merge:!0,default:{}},{key:"brushConfig",merge:!0,factory:e=>({fill:()=>Ga(e),fillOpacity:.12,stroke:()=>Ga(e),strokeWidth:1,width:20})},{key:"dimensionConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,factory:e=>({Line:{stroke:(t,n)=>{const i=e.schema.shapeConfig.fill;return"function"==typeof i?i(t,n):i},strokeWidth:1.5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:t=>T$(e,t)})}]};var Z$=xf(Q$);function J$(e){return{barConfig:{stroke:()=>Ga(e),strokeWidth:1},gridConfig:{stroke:()=>Zn(e._select?.node(),e.schema.colorDefaults),strokeWidth:1},shapeConfig:{fill:N("none"),labelConfig:{fontColor:()=>Ga(e),fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Ga(e),strokeWidth:N(1)}}}function eA(e){return[()=>e.schema.translate("Value"),(t,n)=>{const i=Number(e.schema.value(t,n));return Number.isFinite(i)?d.formatAbbreviate(i,e.schema.locale):""}]}function tA(e,t,n,o){const a=au(e,"Path"),r=t.filter(e=>e.arc.outerRadius>e.arc.innerRadius&&e.arc.endAngle>e.arc.startAngle),s=r.map(t=>{const r=iu(a,t.data,t.i);return{type:"path",key:`${n}-${e._ids(t.data,t.i).join("-")}-${t.slot}`,d:i.arcPath(t.arc),arc:t.arc,datum:t.data,index:t.i,paint:{...r,opacity:r.opacity??1},aria:{label:o(t)}}}),c=qy(a,s,e=>[r[e].data,r[e].i]);return[...s,...c]}function nA(e,t,n){const i=t.flatMap(t=>n(e,t)).filter(Number.isFinite);return{extent:i.length?[Math.min(...i),Math.max(...i)]:[]}}function iA(e,t){const n=e.ctx.polarSharedExtent,i=t.scales;return e.ctx.polarSharedExtent=t.shared&&i?i.extent:void 0,()=>{e.ctx.polarSharedExtent=n}}function oA(e){const t=e.ctx.polarSharedExtent;return Array.isArray(t)?t:[]}function aA(e){return{aspect:1,scales:"independent",share:(t,n)=>nA(t,n,e),panel:iA}}const rA=1e-9;function sA(e,t,n,i,o,a=10){const r=Math.abs(Math.cos(e)),s=Math.abs(Math.sin(e));let c=1/0;return r>rA&&(c=Math.min(c,(i/2-n/2*s)/r-t-a)),s>rA&&(c=Math.min(c,(o/2-n/2*r)/s-t-a)),c}function cA(e){const{labels:t,width:n,height:i,measure:o,wrap:a}=e,r=e.padding??10,s=e.maxLines??2,c=Math.max(0,Math.min(n,i)/2),l=c*(e.minRadiusShare??.5),h=t.map(e=>o(e)),u=function(e,t,n,i=10){let o=Math.min(t,n)/2;for(const a of e){const e=Math.abs(Math.cos(a.angle)),r=Math.abs(Math.sin(a.angle));e>rA&&(o=Math.min(o,(t/2-a.height/2*r)/e-i-a.width)),r>rA&&(o=Math.min(o,(n/2-a.height/2*e)/r-i-a.width))}return Math.max(0,o)}(t.map((e,t)=>({angle:e.angle,width:h[t],height:e.lineHeight})),n,i,r);if(u>=l)return{radius:u,labels:t.map((e,t)=>({wrapWidth:h[t]+1,width:h[t],height:e.lineHeight,lines:1,truncated:!1}))};const d=e=>t.map((t,o)=>{if(h[o]<=sA(t.angle,e,t.lineHeight,n,i,r))return{wrapWidth:h[o]+1,width:h[o],height:t.lineHeight,lines:1,truncated:!1};const c=sA(t.angle,e,t.lineHeight*s,n,i,r),l=Math.max(0,c),u=a(t,l,s);return{wrapWidth:l,width:Math.max(0,...u.widths),height:Math.max(1,u.lines.length)*t.lineHeight,lines:u.lines.length,truncated:u.truncated}}),f=e=>e.every(e=>!e.truncated);let m=l,p=d(m);if(!f(p))return{radius:l,labels:p};let g=c;for(let e=0;e<16&&g-m>.5;e++){const e=(m+g)/2,t=d(e);f(t)?(m=e,p=t):g=e}return{radius:m,labels:p}}function lA(e,t){const n=Array.isArray(t)?t.filter(Number.isFinite):[],i=e.filter(Number.isFinite).concat(n),o=Math.min(0,...i),a=Math.max(0,...i);if(Array.isArray(t)){return{domain:[o,a],ticks:Array.from(new Set(n)).sort((e,t)=>e-t)}}const r=Math.max(1,Math.round(t)),c=s.scaleLinear().domain([o,a]).nice(r),[l,h]=c.domain();return{domain:[l,h],ticks:c.ticks(r)}}function hA(e,t,n){const i=t[1]-t[0];return i?(e-t[0])/i*n:0}const uA={"stroke-width":"strokeWidth","stroke-opacity":"strokeOpacity","stroke-dasharray":"strokeDasharray"};function dA(e,t){const n={...e};for(const[e,i]of Object.entries(t??{}))n[uA[e]??e]=i;return n}const fA=(e,t,n)=>"function"==typeof e?e(t,n):e;function mA(e,t,n){const i={fill:"none"},o=fA(e.stroke,t,n);"string"==typeof o&&(i.stroke=o);const a=Number(fA(e.strokeWidth,t,n));Number.isFinite(a)&&(i.strokeWidth=a);const r=Number(fA(e.strokeOpacity,t,n));Number.isFinite(r)&&(i.strokeOpacity=r);const s=Number(fA(e.opacity,t,n));Number.isFinite(s)&&(i.opacity=s);const c=fA(e.strokeDasharray,t,n),l=(Array.isArray(c)?c:"string"==typeof c?c.split(/[\s,]+/):[]).map(Number).filter(Number.isFinite);return l.length&&(i.strokeDasharray=l),i}const pA=2*Math.PI,gA=(e,t,i,o)=>{const a=e.schema.axisConfig,r=(new ro).config({...nw,...a.shapeConfig?.labelConfig??{}}).schema,s={data:i,i:o,text:t},c=Number(r.fontSize(s,o))||10;return{fontFamily:String(n.fontExists(r.fontFamily(s,o))||"sans-serif"),fontSize:c,fontWeight:r.fontWeight(s,o),lineHeight:Number(r.lineHeight(s,o))||1.2*c}};function yA(e,{domain:t,ticks:n},i,o=e=>hA(e,t,i),a="radar"){const r=e.schema.axisConfig,s=n.map(e=>({value:e,r:o(e)}));return function(e,t,n,i,o,a="radar"){if(!(t>0))return[];const r=e.filter(e=>e.r>0&&e.r<t),s=[...r,{value:n,r:t}].map((e,t)=>({type:"circle",key:t===r.length?`${a}-ring-outer`:`${a}-ring-${e.value}`,interactive:!1,cx:0,cy:0,r:e.r,paint:mA(t===r.length?o:i,e,t)}));return[{type:"group",key:`${a}-radial-circles`,interactive:!1,children:s}]}(s,i,t[1],dA({},r.gridConfig),dA({},r.barConfig),a)}function xA(e,{domain:t,ticks:i},o,r,s="radar"){if(!e.schema.levelLabels)return[];const c=e.schema.levelLabelConfig??{},l=c.fontSize??10,h=c.fontWeight??400,u=a.fontFamilyStringify(c.fontFamily??e.schema.fontFamily??a.fontFamily),f={"font-family":u,"font-size":l,"font-weight":h},m=e.schema.levelFormat,p=function(e){const{ticks:t,domain:n,radius:i,angle:o,format:a,measure:r,fontSize:s}=e,c=e.toRadius??(e=>hA(e,n,i)),l=o*Math.PI/180,h=Math.sin(l),u=-Math.cos(l),d=-u,f=h,m=d>1e-6?"start":d<-1e-6?"end":"middle",p=(e,t,n,i)=>(Math.abs(n)*e+Math.abs(i)*t)/2,g=t.filter(e=>e>=n[0]&&e<=n[1]).map(e=>{const t=c(e),n=a(e),i=r(n),o=s,l=3+p(i,o,d,f),g=t-2-p(i,o,h,u);return{value:e,text:n,r:t,x:g*h+l*d,y:g*u+l*f,width:i,height:o,anchor:m}}),y=Math.max(0,...g.map(e=>2*p(e.width,e.height,h,u)));let x=1/0;for(let e=1;e<g.length;e++)x=Math.min(x,g[e].r-g[e-1].r);const b=x>0?Math.max(1,Math.ceil((y+2)/x)):g.length;return g.filter((e,t)=>t%b===0)}({ticks:i,domain:t,radius:o,angle:Number(e.schema.levelLabelAngle)||0,format:t=>"function"==typeof m?String(m(t)):d.formatAbbreviate(t,e.schema.locale),measure:e=>n.textWidth(e,f),fontSize:l,toRadius:r});return function(e,t,n="radar"){if(!e.length)return[];const i=[];for(const o of e){const e="start"===o.anchor?-o.width/2:"end"===o.anchor?o.width/2:0;i.push({type:"text",key:`${n}-level-label-${o.value}`,interactive:!1,x:0,y:0,transform:{x:o.x+e,y:o.y},lines:[{text:o.text,x:0,y:.35*t.fontSize,width:o.width}],font:{family:t.fontFamily,size:t.fontSize,weight:t.fontWeight,anchor:o.anchor,baseline:"alphabetic"},paint:{fill:t.fontColor,opacity:t.fontOpacity}})}return[{type:"group",key:`${n}-level-labels`,interactive:!1,children:i}]}(p,{fontColor:c.fontColor??Ga(e),fontFamily:u,fontOpacity:c.fontOpacity??1,fontSize:l,fontWeight:h},s)}const bA=1e-9;function _A(e,t,n,i,o=6){const a=Math.sin(e),r=-Math.cos(e);return{x:(t+o)*a+a*n/2-n/2,y:(t+o)*r+r*i/2-i/2,width:n,height:i}}function kA(e,t,n,i=6){let o=Math.min(t,n)/2;for(const a of e){const e=Math.abs(Math.sin(a.angle)),r=Math.abs(Math.cos(a.angle));e>bA&&(o=Math.min(o,(t/2-a.width/2*(1+e))/e-i)),r>bA&&(o=Math.min(o,(n/2-a.height/2*(1+r))/r-i))}return Math.max(0,o)}function vA(e,t,n,i=6){const o=Math.abs(Math.sin(e));return o<=bA?n:Math.max(0,2*(n/2-(t+i)*o)/(1+o))}const wA=(e,t,n=2)=>e.x<t.x+t.width+n&&t.x<e.x+e.width+n&&e.y<t.y+t.height+n&&t.y<e.y+e.height+n;function SA(e,t,n=6,i=2){if(e.length<2)return!1;const o=e.map(e=>({angle:e.angle,p:_A(e.angle,t,e.width,e.height,n)})).sort((e,t)=>e.angle-t.angle);for(let e=0;e<o.length;e++){const t=o[(e+1)%o.length];if(t!==o[e]&&wA(o[e].p,t.p,i))return!0}return!1}function CA(e){const{angles:t,widths:n,lineHeight:i,width:o,height:a}=e,r=e.padding??6,s=Math.max(0,Math.min(o,a)/2)*(e.minRadiusShare??.5),c=kA(t.map((e,t)=>({angle:e,width:n[t],height:i})),o,a,r);return c>=s?{radius:c,labels:n.map(e=>({width:e,height:i,lines:1}))}:{radius:s,labels:t.map((e,t)=>{const a=vA(e,s,o,r);return n[t]<=a?{width:n[t],height:i,lines:1}:{width:a,height:2*i,lines:2}})}}function MA(e){const t=(180*(e-Math.PI/2)/Math.PI%360+360)%360;return Math.sin(e)<-1e-9?{rotate:t-180,anchor:"end"}:{rotate:t,anchor:"start"}}function $A(e,t,i,o,r=!0){const s=Math.max(0,Math.min(i,o)/2);if(!r||!t.length)return{radius:s,labels:[]};const c=e.schema.outerPadding,l=t.map((t,n)=>gA(e,t.text,t.data,n)),h=t.map((e,t)=>n.textWidth(e.text,(e=>({"font-family":l[e].fontFamily,"font-size":l[e].fontSize,"font-weight":l[e].fontWeight}))(t))),u=Math.max(...l.map(e=>e.lineHeight)),d=Math.max(0,i-4),f=Math.max(0,o-4),m="number"==typeof c?Math.max(0,s-c):void 0,p=CA({angles:t.map(e=>e.angle),widths:h.map(e=>(e=>Math.max(e+2,12))("number"==typeof c?Math.min(e,c):e)),lineHeight:u+2,width:d,height:f}),g=m??p.radius,y=t.map((e,t)=>({angle:e.angle,width:p.labels[t].width,height:p.labels[t].height}));if(!SA(y,g)){const e=t.map((e,t)=>{const n=y[t],i=_A(e.angle,g,n.width,n.height);return{__d3plus__:!0,data:e.data,id:e.key,text:e.text,x:0,y:0,rotate:0,textAnchor:(a=Math.sin(e.angle),a>.3?"start":a<-.3?"end":"middle"),verticalAlign:(o=-Math.cos(e.angle),o<-.3?"bottom":o>.3?"top":"middle"),labelBounds:i};var o,a});return{radius:g,labels:e}}return function(e,{fonts:t,widths:n,innerW:i,innerH:o,fixed:r,outerPadding:s}){const c=cA({labels:e.map((e,n)=>({text:e.text,angle:e.angle-Math.PI/2,lineHeight:t[n].lineHeight,i:n})),width:i,height:o,padding:6,measure:e=>n[e.i],wrap:(e,n,i)=>a.textWrap().fontFamily(t[e.i].fontFamily).fontSize(t[e.i].fontSize).fontWeight(t[e.i].fontWeight).lineHeight(t[e.i].lineHeight).width(n).height(t[e.i].lineHeight*i).maxLines(i)(e.text)}),l=r??c.radius,h=e.map((e,n)=>{const{rotate:i,anchor:o}=MA(e.angle),a=Math.max(12,"number"==typeof s?s:c.labels[n].wrapWidth),r=2*t[n].lineHeight,h="start"===o?6:-a-6;return{__d3plus__:!0,data:e.data,id:e.key,text:e.text,x:l*Math.sin(e.angle),y:-l*Math.cos(e.angle),rotate:i,textAnchor:o,verticalAlign:"middle",labelBounds:{x:h,y:-r/2,width:a,height:r},rotateAnchor:[-h,r/2]}});return{radius:l,labels:h}}(t,{fonts:l,widths:h,innerW:d,innerH:f,fixed:m,outerPadding:c})}function AA(e,t,n){if(!t.length)return[];const i=e.schema.axisConfig,o=iw({data:t,label:e=>e.text,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.rotate,id:e=>`${n}-label-${e.id}`,labelBounds:e=>e.labelBounds,labelConfig:{...i.shapeConfig?.labelConfig??{},verticalAlign:e=>e.data?.verticalAlign??"middle"}});for(const e of o)e.interactive=!1;return o.length?[{type:"group",key:`${n}-labels`,interactive:!1,children:o}]:[]}function zA(e,t,n,i,o){return{rings:yA(e,t,n,i,o),labels:xA(e,t,n,i,o)}}function DA(e,t,n,i,o="sqrt"){const a=t[1]-t[0],r=Number.isFinite(e)&&a?(e-t[0])/a:0,s=Math.max(0,Math.min(1,r));return"linear"===o?n+s*(i-n):Math.sqrt(n*n+s*(i*i-n*n))}function FA(e,t=0,n=2*Math.PI){const i=Math.max(0,Math.floor(e)),o=i?n/i:0;return Array.from({length:i},(e,n)=>({startAngle:t+n*o,endAngle:t+(n+1)*o,angle:t+(n+.5)*o}))}function BA(e){const t=new Map;return e.map(({slot:e,value:n})=>{const i=t.get(e)??0,o=i+(Number.isFinite(n)&&n>0?n:0);return t.set(e,o),{slot:e,y0:i,y1:o}})}function LA(e,t,n){return e>0?e:t>0&&n>0?t/n:0}function PA(e,t,n=void 0){const i=lA(e,t),[o,a]=n??[],r="number"==typeof o&&Number.isFinite(o),c="number"==typeof a&&Number.isFinite(a);if(!r&&!c)return i;const l=r?o:i.domain[0],h=c?a:i.domain[1];if(!(h>l))return i;const u=Array.isArray(t)?i.ticks.filter(e=>e>=l&&e<=h):s.scaleLinear().domain([l,h]).ticks(Math.max(1,Math.round(t)));return{domain:[l,h],ticks:u}}function RA(e,t){const n=Number("function"==typeof e?e(t):e);return!Number.isFinite(n)||n<=0?0:Math.min(n,.95*t)}function EA(e,t,n,i){const o=Math.max(0,Math.min(.95,i.inset)),a=e.endAngle-e.startAngle;return{innerRadius:t,outerRadius:n,startAngle:e.startAngle+a*o/2,endAngle:e.endAngle-a*o/2,padAngle:LA(i.padAngle,i.padPixel,Math.hypot(t,n))}}function NA(e,t,n){const i=e.schema.value,o=h.groups(t.map((e,t)=>({d:e,i:t})),e=>n(e.d,e.i)),a=new Map(o.map(([e],t)=>[e,t])),r=t.map((e,t)=>Number(i(e,t))),s=BA(t.map((e,t)=>({slot:a.get(n(e,t)),value:r[t]}))),c=o.map((e,t)=>Math.max(0,...s.filter(e=>e.slot===t).map(e=>e.y1)));return{bySlot:o,values:r,stack:s,tops:c}}function TA(e,t,n){return NA(e,t,n).tops}function OA(e,t){const{width:n,height:a}=ie(e),r=t.rows??e._filteredData??[],s=e.schema.aggs,{bySlot:c,values:l,stack:h,tops:u}=NA(e,r,t.slotOf),d=PA(u.concat(oA(e)),e.schema.levels,e.schema.domain),f=(e=>(Number(e.schema.startAngle)||0)*Math.PI/180)(e),m=FA(c.length,f,t.sweep).map((e,t)=>({...e,key:c[t][0]})),p=$A(e,m.map((e,n)=>{const i=c[n][1].map(e=>e.d);return{key:e.key,text:t.slotLabel(e.key,i),angle:e.angle,data:1===i.length?i[0]:o.merge(i,s)}}),Math.max(0,n-4),Math.max(0,a-4)),g=Math.max(0,p.radius),y=RA(e.schema.innerRadius,g),x=e=>DA(e,d.domain,y,g,t.scale),b={inset:t.slotPadding,padAngle:Number(e.schema.padAngle)||0,padPixel:Number(e.schema.padPixel)||0},_=r.map((e,t)=>{const n=h[t],i=m[n.slot];return{__d3plus__:!0,data:e,i:t,slot:i.key,value:l[t],y0:n.y0,y1:n.y1,arc:EA(i,x(n.y0),x(n.y1),b)}}),k=m.map(e=>EA(e,y,g,b)),v=zA(e,d,g,x,t.key),w=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[];t.trackPaint&&w.push(function(e,t,n,o){return{type:"group",key:`${e}-tracks`,interactive:!1,children:n.map((n,a)=>({type:"path",key:`${e}-track-${t[a].key}`,interactive:!1,d:i.arcPath(n),arc:n,paint:o}))}}(t.key,m,k,t.trackPaint)),w.push(...v.rings,...AA(e,p.labels,t.key),...v.labels);const S={inner:y,outer:g,levels:d,scale:t.scale,slots:m,tracks:k};return e.ctx.polar=S,{wedges:_,frame:S}}function WA(e){const t=e.schema.metric;return"function"==typeof t?(e,n)=>`${t(e,n)}`:(t,n)=>e._ids(t,n).join("-")}const jA=(e,t)=>TA(e,t,WA(e)),HA=({viz:e})=>{const t=e.schema.metric,{wedges:n}=OA(e,{key:"polararea",slotOf:WA(e),slotLabel:(n,i)=>"function"!=typeof t&&i.length?e._drawLabel(i[0],0):n,scale:"linear"===e.schema.radialScale?"linear":"sqrt",slotPadding:0,sweep:2*Math.PI});return{shapeData:n}},IA=({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i="function"==typeof e.schema.metric;return tA(e,n,"polararea",t=>{const n=e._drawLabel(t.data,t.i),o=d.formatAbbreviate(t.value,e.schema.locale);return i?`${n}, ${t.slot}, ${o}.`:`${n}, ${o}.`})},GA={name:"PolarArea",layoutStage:HA,emit:IA,insetRegion:Uu,chartTransform:e=>{const{width:t,height:n}=ie(e);return oe(e,t,n)},chartBodyRect:e=>{const t=e.ctx.polar?.outer??0;return{x:-t,y:-t,width:2*t,height:2*t}},facet:aA(jA),ctx:{},fields:[{key:"discrete",default:"metric"},{key:"domain"},{key:"innerRadius",default:0},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"metric",coerce:e=>"function"==typeof e?e:"string"==typeof e?Be(e):void 0},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"radialScale",default:"sqrt"},{key:"startAngle",default:0},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"legend",coerce:"const",factory:cw},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:J$},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>{const[t,n]=eA(e);return{tbody:[[(n,i)=>{const o=e.schema.metric;return"function"==typeof o?`${o(n,i)}`:t()},n]]}}},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})}]};var VA=xf(GA);const qA=({viz:e})=>{const t=e._filteredData;if(!t)return{shapeData:[]};const i=e.schema.start,a=e.schema.end,r=e._id,s=e.schema.axisConfig,c="time"===s?.scale,l=t.map((e,t)=>({__d3plus__:!0,data:e,end:c?n.date(a(e,t)):a(e,t),i:t,id:r(e,t),start:c?n.date(i(e,t)):i(e,t)})).filter(e=>Number(e.end)-Number(e.start)>0).sort((e,t)=>Number(e.start)-Number(t.start));let u;if(e.schema.groupBy.length>1&&e._drawDepth>0){const t=[];for(let n=0;n<e._drawDepth;n++)t.push(t=>e.schema.groupBy[n](t.data,t.i));u=o.nestGroups(l,t)}else u=[{values:l}];const d=(e=>{let t=0;return e.forEach(e=>{let n=[];e.values.forEach(e=>{n=n.map(t=>!(!1!==t&&t<=e.start)&&t);const i=n.indexOf(!1);i<0?(e.lane=t+n.length,n.push(e.end)):(n[i]=e.end,e.lane=t+i)}),t+=n.length}),t})(u);return((e,t,n)=>{const i={domain:[h.min(t,e=>Number(e.start))??0,h.max(t,e=>Number(e.end))??0],height:e.schema.height-e._margin.top-e._margin.bottom,width:e.schema.width-e._margin.left-e._margin.right},o=e.ctx.axisTest,a=e.ctx.axis;o.config(i).config(e.schema.axisConfig).measure(),a.config(i).config(e.schema.axisConfig).renderMode("compute").select(void 0).render();const r=a.toScene();var s;r&&((s=e)._chartScene||(s._chartScene=[])).push({type:"group",key:"priestley-axis",transform:{x:e._margin.left,y:e._margin.top},children:r.children??[]});const c=B.scaleBand().domain(h.range(0,n,1).map(String)).paddingInner(e.schema.paddingInner).paddingOuter(e.schema.paddingOuter).rangeRound([e.schema.height-e._margin.bottom-o.outerBounds().height-o.schema.padding,e._margin.top+o.schema.padding]);e.ctx.xScale=a._d3Scale,e.ctx.yScale=c,e.ctx.bandWidth=c.bandwidth()})(e,l,d),{shapeData:l}},YA={name:"Priestley",layoutStage:qA,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.ctx.xScale,o=e.ctx.yScale,a=e.ctx.bandWidth,s=au(e,"Rect"),c=n.map((t,n)=>{const r=tu(s.fill,t.data,n),c=tu(s.stroke,t.data,n),l=tu(s.strokeWidth,t.data,n),h=`${e._drawLabel(t.data,n)}, ${t.start} - ${t.end}.`,u=Math.abs(i(t.end)-i(t.start)),d=u>2?u-2:u,f=i(t.start)+(i(t.end)-i(t.start))/2-d/2,m=(o(String(t.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${t.id}-${n}`,transform:{x:f,y:m},x:0,y:-a/2,width:d,height:a,datum:t.data,paint:{fill:nu(s,t.data,n,r),stroke:c,strokeWidth:l},aria:{label:h}}}),l=iw({data:n,label:(t,i)=>e._drawLabel(n[i].data,i),x:(e,t)=>{const o=n[t];return i(o.start)+(i(o.end)-i(o.start))/2},y:(e,t)=>(o(String(n[t].lane))??0)+a/2,aes:(e,t)=>{const o=n[t],r=Math.abs(i(o.end)-i(o.start));return{width:r>2?r-2:r,height:a}},rotate:N(0),id:(e,t)=>`priestley-label-${n[t].id}-${t}`,labelBounds:(e,t,n)=>{const{width:i,height:o}=n;return{x:-i/2,y:-o/2,width:i,height:o}},labelConfig:{fontColor:t=>{const n=t.data??t,i=tu(s.fill,n.data,n.i);return r.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)",e.schema.colorDefaults)},fontResize:!1,textAnchor:"start",verticalAlign:"top",...ru(e,"Rect")}}),h=qy(s,c,e=>[n[e].data,e]);return[...c,...h,...l]},chartTransform:()=>{},setup:e=>{e.schema.aggs.start||(e.schema.aggs.start=h.min),e.schema.aggs.end||(e.schema.aggs.end=h.max)},ctx:{axis:(new hi).align("end").orient("bottom"),axisTest:(new hi).align("end").gridSize(0).orient("bottom")},fields:[{key:"paddingInner",default:.05},{key:"paddingOuter",default:.05},{key:"axisConfig",merge:!0,default:{scale:"time"}},{key:"end",default:T("end"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{const n="function"==typeof t?null:t;n&&!e.schema.aggs[n]&&(e.schema.aggs[n]=h.max)}},{key:"start",default:T("start"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{const n="function"==typeof t?null:t;n&&!e.schema.aggs[n]&&(e.schema.aggs[n]=h.min)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e.schema.start(t,n),o=e.schema.end(t,n);return`${e._drawLabel(t,n)}, ${i} - ${o}.`}})}]};var KA=xf(YA);function UA(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function XA(e,t,n){const i=Array.isArray(n)?n.map(String):[];return e.forEach((e,n)=>{const o=`${t(e,n)}`;i.includes(o)||i.push(o)}),i}function QA(e,t){return e.length>0&&`${t}`===e[0]?-1:1}function ZA(e,t){return e.reduce((e,n,i)=>e+(UA(t(n,i))??0),0)}function JA(e,t,n){const i=new Map;return e.forEach((e,o)=>{const a=`${n(e,o)}`;i.set(a,(i.get(a)??0)+(UA(t(e,o))??0))}),i}function ez(e,t){const{category:n,side:i,value:o,comparison:a,frame:r}=t,s=new Map,c=new Map;return e.forEach((e,t)=>{const l=`${r?r(e,t):""}\0${n(e,t)}\0${i(e,t)}`;s.set(l,(s.get(l)??0)+Math.abs(UA(o(e,t))??0)),a&&c.set(l,(c.get(l)??0)+Math.abs(UA(a(e,t))??0))}),Math.max(0,...s.values(),...c.values())}function tz(e){return e>0?[-e,e]:[-1,1]}function nz(e,t=0){const n=Math.abs(e);return n<=2*t?0:n}function iz(e,t=()=>0){return n=>e("number"==typeof n?nz(n,t()):n)}function oz(e,t,n){const i=e.slice().sort((e,t)=>e.y-t.y);if(!i.length)return[];const o=n/2,a=[[t,i[0].y-o]];for(const e of i)a.push([e.x,e.y-o],[e.x,e.y+o]);return a.push([t,i[i.length-1].y+o]),a}function az(e,t){const n=Array.from(new Set(e)).sort((e,t)=>e-t);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,n[e]-n[e-1]);return Number.isFinite(i)?i:t}function rz(e){return Array.isArray(e)?e.map(Number):"string"==typeof e&&e.trim()?e.trim().split(/[\s,]+/).map(Number):"number"==typeof e?[e]:void 0}function sz(e,t,n){return"function"==typeof e?e(t,n):e}function cz(e,t){const{left:n,right:i,top:o,height:a}=t,r=[[n,f.clamp(t.inner[0],n,i)],[f.clamp(t.inner[1],n,i),i]];return e.slice(0,2).map((e,t)=>({text:e,x:r[t][0],y:o,width:Math.max(0,r[t][1]-r[t][0]),height:a}))}function lz(e,t,n){const i=e.slice(),o=i.findIndex(e=>e.key===bx);if(o>=0&&t.length){const e=i[o];"group"===e.type&&(i[o]={...e,children:[...e.children,...t]})}else i.push(...t);return i.push(...n),i}function hz(e,t){const n=e._xFunc,i=e._yFunc,o=e._plotArea;if(!(n&&i&&o&&e._filteredData?.length))return{outlines:[],overlays:[]};const a=t.comparison?function(e){const{sides:t,categories:n,data:i,category:o,side:a,comparison:r,divisor:s,x:c,y:l,fallbackStep:h,config:u}=e,d=e.inset??0,f=az(n.map(e=>l(e)),h);return t.flatMap((e,h)=>{const m=new Map;if(i.forEach((t,n)=>{if(`${a(t,n)}`!==e)return;const i=UA(r(t,n));if(void 0===i)return;const c=`${o(t,n)}`;m.set(c,(m.get(c)??0)+Math.abs(i)/(s||1))}),!m.size)return[];const p=QA(t,e),g=c(p*d),y=n.map(e=>({y:l(e),x:c(p*((m.get(`${e}`)??0)+d))})),x={fill:"none",stroke:sz(u.stroke,e,h),strokeWidth:sz(u.strokeWidth,e,h),strokeOpacity:sz(u.strokeOpacity,e,h)},b=rz(sz(u.strokeDasharray,e,h));return b&&(x.strokeDasharray=b),[{type:"line",key:`pyramid-comparison-${h}`,points:oz(y,g,f),curve:"linear",paint:x,interactive:!1,interactionGroup:"axis"}]})}({sides:t.sides,categories:e._yAxis?.domain()??[],data:e._filteredData,category:e._y,side:t.side,comparison:t.comparison,divisor:t.divisor,x:n,y:i,fallbackStep:o.height,config:e.schema.comparisonConfig,inset:t.inset}):[],r=[n(-t.inset),n(t.inset)],s=e._plotInsetTop??0,c=t.showTitles&&s>0?function(e,t,n){return e.renderMode("compute").select(void 0).data(t.map((e,t)=>({...e,id:`pyramid-side-${t}`}))).config(n).render(),[{type:"group",key:"pyramid-side-titles",interactionGroup:"axis",children:e.toScene().children??[]}]}(t.titleBox,cz(t.labels,{left:o.x,right:o.x+o.width,inner:r,top:e._margin.top-(e._chartTransform?.y??e._margin.top),height:s}),{...e.schema.fontFamily?{fontFamily:e.schema.fontFamily}:{},...e.schema.sideTitleConfig}):[];return{outlines:a,overlays:[...t.gutter?t.gutter(r):[],...c]}}function uz(e,t,n){const{outlines:i,overlays:o}=hz(e,n);return function(e,t,n){if(!t.length&&!n.length)return e;const i=e.root.children.find(e=>"viz-chart-cells"===e.key),o=i&&"children"in i?i.children.find(e=>"viz-zoom"===e.key):void 0,a=o&&"children"in o?o.children.find(e=>"viz-chart-body"===e.key):void 0;return a&&"group"===a.type?(a.children=lz(a.children,t,n),e):e}(t,i,o)}function dz(e){return 1e-9*(e>0?e:1)}function fz(e){return(t,n)=>{Lp(t,n);const i=e();if(i)for(const e of t)for(const t of e){const e=t[0]<0?-i:i;t[0]+=e,t[1]+=e}}}function mz(e,t,n){const i=i=>{const o=e[i];return"function"==typeof o?o(t,n):o},o=i("fontFamily")??a.fontFamily;return{family:a.fontFamilyStringify(o),size:Number(i("fontSize"))||12,weight:i("fontWeight")??400,padding:Number(i("padding"))||0}}function pz(e,t,i=n.textWidth){let o=0,a=0;return e.forEach((e,n)=>{const r=t[n],s=i(e,{"font-family":r.family,"font-size":r.size,"font-weight":r.weight});o=Math.max(o,s),a=Math.max(a,r.padding)}),Math.ceil(o+2*a)}function gz(e,t){const n=e.map(()=>!1);let i;e.forEach((e,o)=>{(void 0===i||Math.abs(e-i)>=t)&&(n[o]=!0,i=e)});const o=e.length-1;if(o>0&&!n[o]){n[o]=!0;for(let i=o-1;i>=0&&Math.abs(e[o]-e[i])<t;i--)n[i]=!1}return n}function yz(e){return{...e._yAxis?.shapeConfig()?.labelConfig??{},...e._yConfig?.shapeConfig?.labelConfig??{}}}function xz(e,t){const n=e._yConfig?.tickFormat;return"function"==typeof n?`${n(t)}`:`${t}`}const bz=e=>1.2*e.size+2*e.padding;function _z(e,t,n,i,o){if("center"!==e)return{x:{...o.x},y:{...o.y}};return{x:{break:[[-t,t],...Array.isArray(i)?Array.isArray(i[0])?i:[i]:[]],breakConfig:{gap:n,lines:!1,mask:!1,size:0,space:n,stroke:"transparent"}},y:{barConfig:{stroke:"transparent"},tickSize:0,ticks:[]}}}const kz=new WeakMap,vz=e=>e.ctx.pyramid,wz=e=>e.schema.groupBy[0],Sz=(e,t)=>`${d.formatAbbreviate(100*t,e.schema.locale)}%`;function Cz(e){const t=vz(e),n=function(e){return(t,n)=>{const i=vz(e),o=i.value(t,n),a=UA(o);if(void 0===a)return o;const r=e.schema.percent?i.total?Math.abs(a)/i.total:0:Math.abs(a);return QA(i.sides,wz(e)(t,n))*r}}(e);t.value=e._x,Object.defineProperty(e,"_x",{configurable:!0,enumerable:!0,get:()=>n,set:e=>{e!==n&&(t.value=e)}})}function Mz(e,t){const n=e._xConfig,i=n.tickFormat;void 0===i||i===t.tickFormat?(n.tickFormat=t.tickFormat=iz(function(e){return e.schema.percent?t=>Sz(e,t):t=>d.formatAbbreviate(t,e.schema.locale)}(e),()=>t.inset),t.wrapped.add(n.tickFormat)):"function"!=typeof i||t.wrapped.has(i)||(n.tickFormat=iz(i,()=>t.inset),t.wrapped.add(n.tickFormat))}function $z(e,t,n){const i=e._xConfig,o=void 0!==i.domain&&(a=i.domain,r=t.domain,Array.isArray(a)&&Array.isArray(r)&&a.length===r.length&&a.every((e,t)=>e===r[t]));var a,r;if(void 0!==i.domain&&!o)return;if(!e.schema.symmetric||Sf(e,"x"))return o&&delete i.domain,void(t.domain=void 0);i.domain=t.domain=tz(n+t.inset);const s=e._plotAxisDefaults??{};e._plotAxisDefaults={...s,x:{...s.x,rounding:"outside"}}}function Az(e,t,n){var i;const o=e.schema.categoryPosition;(i=t).restore??(i.restore=function(e){return{y:{barConfig:{...e._yAxis.barConfig()},tickSize:e._yAxis.tickSize()},x:{breakConfig:{...e._xAxis.breakConfig()}}}}(e));const a="center"===o;t.inset=a?dz(n):0;let r=0;if(a){const t=function(e){const t=e._y;return Array.from(new Set(e._data.map((e,n)=>t(e,n))))}(e),n=yz(e),i=t.map((e,t)=>mz(n,e,t));r=pz(t.map(t=>xz(e,t)),i)}e._plotAxisDefaults=_z(o,t.inset,r,e.schema.xBreak,t.restore)}function zz(e){const t=vz(e);t.sides=XA(e._data,wz(e),e.schema.sides);const n=e._legendData||e._filteredData||[];t.total=ZA(n,t.value);const i=e.schema.comparison;t.comparisonTotal=i?ZA(n,i):0,Mz(e,t);const o=function(e,t){const n=!!e._axisPersist,i=n?e._data:e._filteredData,o=n&&e.schema.time?e.schema.time:void 0,a=(t,n)=>{if(!e.schema.percent)return t;const a=o?JA(i,t,o):void 0;return(e,i)=>{const r=a?a.get(`${o(e,i)}`)??0:n,s=UA(t(e,i));return void 0!==s&&r?s/r:0}},r=e.schema.comparison;return ez(i,{category:e._y,side:wz(e),value:a(t.value,t.total),comparison:r?a(r,t.comparisonTotal):void 0,frame:o})}(e,t);Az(e,t,o),$z(e,t,o),function(e,t){const n=e._xConfig,i=e._xTitle;e.schema.percent?void 0!==n.title&&n.title!==i&&n.title!==t.title||(n.title=t.title=e.schema.translate("Percent of Total")):void 0!==t.title&&(n.title===t.title&&(n.title=i),t.title=void 0)}(e,t),e._plotInsetTop=function(e){if(!e.schema.sideTitles)return 0;const t=e.schema.sideTitleConfig,n="number"==typeof t.fontSize?t.fontSize:14,i="number"==typeof t.padding?t.padding:0;return Math.ceil(1.2*n+2*i)}(e)}function Dz(e,t){const n=wz(e);return t.map(t=>{const i=e._data.findIndex((e,i)=>`${n(e,i)}`===t);return i>=0?e._drawLabel(e._data[i],i,0):t})}function Fz(e){const t=vz(e);return{sides:t.sides,labels:Dz(e,t.sides),side:wz(e),comparison:e.schema.comparison,divisor:e.schema.percent?t.comparisonTotal:1,titleBox:t.titleBox,showTitles:!!e.schema.sideTitles,inset:t.inset,gutter:t.inset?n=>function(e,t,n){const i=e._yFunc,[o,a]=n;if(!(i&&e._yAxis&&a>o))return[];const r=e._yAxis.domain()??[],s=yz(e),c=r.map(e=>i(e)),l=r.map((e,t)=>mz(s,e,t)),h=gz(c,Math.max(0,...l.map(bz))),u=az(c,e._plotArea?.height??0);return function(e,t,n){return e.renderMode("compute").select(void 0).data(t).config({fontColor:n,fontFamily:e=>e.font.family,fontSize:e=>e.font.size,fontWeight:e=>e.font.weight,textAnchor:"middle",verticalAlign:"middle"}).render(),[{type:"group",key:"pyramid-categories",interactionGroup:"axis",children:e.toScene().children??[]}]}(t,r.flatMap((t,n)=>{if(!h[n])return[];const i=Math.max(u,1.5*l[n].size);return[{id:`pyramid-category-${n}`,text:xz(e,t),x:o,y:c[n]-i/2,width:a-o,height:i,font:l[n]}]}),"string"==typeof s.fontColor?s.fontColor:Ga(e))}(e,t.labelBox,n):void 0}}const Bz={name:"Pyramid",paintDriven:!0,thresholdFunction:(e,t)=>t,defaults:{groupPadding:1},setup:e=>{e.ctx.pyramid={value:e._x,sides:[],total:0,comparisonTotal:0,wrapped:new WeakSet,titleBox:new ro,inset:0,labelBox:new ro},Cz(e),e._stackOffset=fz(()=>vz(e).inset),e._stackGroup=()=>"group",e._stackOrder=hM((t,n)=>e._ids(t,n).slice(1,e._drawDepth+1).join("_")),e.schema.color=(t,n)=>{const i=e.schema.groupBy;return i[Math.max(0,Math.min(e._drawDepth??0,i.length-1))](t,n)},e.schema.shapeConfig.Bar={...e.schema.shapeConfig.Bar,label:!1},e.schema.shapeConfig.ariaLabel=(t,n)=>{const i=e._xConfig.tickFormat;return`${e._drawLabel(t,n)}, ${e._y(t,n)}: ${i(e._x(t,n))}.`};const t=e._preDraw.bind(e);e._preDraw=()=>{t(),zz(e)}},decorateScene:(e,t)=>e._facetPanels?t:uz(e,t,Fz(e)),facet:{scene:(e,t)=>function(e,t,n){const{outlines:i,overlays:o}=hz(e,n);return i.length||o.length?lz(t,i,o):t}(e,t,Fz(e))},ctx:{},fields:[{key:"baselineBreak",default:!1},{key:"categoryPosition",default:"center"},{key:"comparison",coerce:e=>{if("string"!=typeof e)return e||void 0;const t=Be(e);return kz.set(t,e),t}},{key:"comparisonConfig",merge:!0,factory:e=>({stroke:()=>Ga(e),strokeDasharray:"4 3",strokeOpacity:1,strokeWidth:1.5})},{key:"discrete",default:"y"},{key:"percent",default:!1},{key:"sideTitles",default:!0},{key:"sideTitleConfig",merge:!0,factory:e=>({fontColor:()=>Ga(e),fontSize:14,fontWeight:600,padding:2,textAnchor:"middle",verticalAlign:"middle"})},{key:"sides"},{key:"stacked",default:!0},{key:"symmetric",default:!0},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>function(e,t,n){const i=vz(e),o=UA(i.value(t,n));if(void 0===o)return[];const a=[],r=!!e.schema.percent;if(r){const t=e._xKey;a.push(["string"==typeof t?t:e.schema.translate("Value"),d.formatAbbreviate(Math.abs(o),e.schema.locale)])}else i.total&&a.push([e.schema.translate("Percent of Total"),Sz(e,Math.abs(o)/i.total)]);const s=e.schema.comparison,c=s?UA(s(t,n)):void 0;if(s&&void 0!==c){const t=kz.get(s)??e.schema.translate("Comparison");a.push([t,r?Sz(e,i.comparisonTotal?Math.abs(c)/i.comparisonTotal:0):d.formatAbbreviate(Math.abs(c),e.schema.locale)])}return a}(e,t,n)})}]};var Lz=xf(Bz,Sb);const Pz=2*Math.PI,Rz=({viz:e})=>{const{width:i,height:r}=ie(e),s=e.schema.metric,c=e.schema.value,l=e._filteredData,u=h.groups(l,s),d=h.groups(l,e._id,s),f=d.flatMap(([,e])=>e.map(([,e])=>h.sum(e,(e,t)=>c(e,t)))),m=lA(f,e.schema.levels),{domain:p}=m;if(!f.length||p[0]===p[1])return e.ctx.groupData=[],e.ctx.pathConfig={},{shapeData:[]};const{radius:g,polarAxis:y}=function(e,t,i,r){const s=t.length,c=e.schema.aggs,l=e.schema.outerPadding,h=t.map(([t,n],i)=>{const a=o.merge(n,c),r=gA(e,String(t),a,i);return{key:t,data:a,font:r,text:String(t),angle:pA/s*i,lineHeight:r.lineHeight}});let u,d;if("number"==typeof l)u=Math.max(0,Math.min(i,r)/2-l),d=h.map(()=>({wrapWidth:l}));else{const e=cA({labels:h,width:i-4,height:r-4,measure:({text:e,font:t})=>n.textWidth(e,{"font-family":t.fontFamily,"font-size":t.fontSize,"font-weight":t.fontWeight}),wrap:({text:e,font:t},n,i)=>a.textWrap().fontFamily(t.fontFamily).fontSize(t.fontSize).fontWeight(t.fontWeight).lineHeight(t.lineHeight).width(n).height(t.lineHeight*i).maxLines(i)(e)});u=e.radius,d=e.labels}const f=h.map(({key:e,data:t,font:n,angle:i},o)=>{const a=2*n.lineHeight,r=d[o].wrapWidth,c=parseInt(String(360-360/s*o/90),10)%4+1;let l=360/s*o,h="start",f=10;return 2!==c&&3!==c||(f=-r-10,h="end",l+=180),{__d3plus__:!0,data:t,i:o,id:e,key:e,angle:l,textAnchor:h,labelBounds:{x:f,y:-a/2,width:r,height:a},rotateAnchor:[-f,a/2],x:u*Math.cos(i),y:u*Math.sin(i)}}).sort((e,t)=>Number(e.key)-Number(t.key));return{radius:u,polarAxis:f}}(e,u,i,r);(Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[]).push(...yA(e,m,g),...function(e,t){const n=e.schema.axisConfig,i=[],o=iw({data:t,label:e=>e.id,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.angle||0,id:e=>e.id,labelBounds:e=>e.labelBounds,labelConfig:n.shapeConfig?.labelConfig??{}});o.length&&i.push({type:"group",key:"radar-axis-labels",children:o});const a=au(e,"Path",n.shapeConfig??{}),r=t.map((e,t)=>({type:"path",key:`radar-spoke-${e.id}`,interactive:!1,d:`M0,0 ${e.x},${e.y}`,paint:iu(a,e,t)}));return r.length&&i.push({type:"group",key:"radar-axis-spokes",interactive:!1,children:r}),i}(e,y),...xA(e,m,g));const x=u.length,b=d.map(([t,n])=>{const i=n.map(([,e],t)=>{const n=hA(h.sum(e,(e,t)=>c(e,t)),p,g),i=Pz/x*t;return{x:n*Math.cos(i),y:n*Math.sin(i)}}),a=`M ${i[0].x} ${i[0].y} ${i.map(e=>`L ${e.x} ${e.y}`).join(" ")} L ${i[0].x} ${i[0].y}`,r=e.schema.aggs;return{__d3plus__:!0,arr:n.map(([,e])=>o.merge(e,r)),id:t,points:i,d:a,data:o.merge(n.map(([,e])=>o.merge(e,r)),r)}}),_=((e,n,i)=>{const o=au(e,"Path"),a=Object.keys(o.on??{});o.on={};for(const r of a)o.on[r]=(o,a,s,c)=>{const l=o.points.map(e=>e.x+n/2),u=o.points.map(e=>e.y+i/2),d=t.pointer(c,e._select.node()),f=l.map(e=>Math.abs(e-d[0])),m=u.map(e=>Math.abs(e-d[1])),p=f.map((e,t)=>e+m[t]);e.schema.on[r].call(e,o.arr[p.indexOf(h.min(p))],a,s,c)};return o})(e,i,r);return e.ctx.groupData=b,e.ctx.pathConfig=_,{shapeData:b}},Ez={name:"Radar",layoutStage:Rz,emit:({viz:e})=>{const t=e.ctx.groupData,n=e.ctx.pathConfig;if(!t||!n||!t.length)return[];const i=[];for(let o=0;o<t.length;o++){const a=t[o],r=a.data??a,s=iu(n,r,o);i.push({type:"path",key:`radar-${a.id}`,d:a.d,datum:r,paint:s,aria:{label:`${e._drawLabel(r,o)}.`}})}const o=qy(n,i,e=>[t[e].data??t[e],e]);return[...i,...o]},chartTransform:e=>{const{width:t,height:n}=ie(e);return oe(e,t,n)},chartBodyRect:e=>{const{width:t,height:n}=ie(e);return{x:-t/2,y:-n/2,width:t,height:n}},facet:{aspect:1},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabelConfig",default:{},merge:!0},{key:"levelLabels",default:!0},{key:"levels",default:6},{key:"metric",default:T("metric"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"outerPadding",default:"auto"},{key:"shape",default:N("Path"),coerce:"const"},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"axisConfig",merge:!0,factory:e=>({barConfig:{stroke:()=>Ga(e),strokeWidth:1},gridConfig:{stroke:()=>Zn(e._select?.node(),e.schema.colorDefaults),strokeWidth:1},shapeConfig:{fill:N("none"),labelConfig:{fontColor:()=>Ga(e),fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Ga(e),strokeWidth:N(1)}})}]};var Nz=xf(Ez);function Tz(e,t,n,i){const o=Math.max(0,Math.floor(e));if(!(o&&n>t))return[];const a=(n-t)/o,r=Math.max(0,Math.min(.95,i));return Array.from({length:o},(e,t)=>{const i=n-t*a;return{inner:i-a*(1-r),outer:i}})}function Oz(e,t,n,i=0){if(!(e>0&&t>0))return 0;let o=t;return n<Math.PI/2&&(o=Math.min(o,e*Math.tan(Math.max(0,n)))),Math.max(0,o-i)}function Wz(e,t,n){const i=Math.sin(e),o=-Math.cos(e),a=i-n*Math.cos(e),r=o-n*Math.sin(e);return Ub(Kb(e,t),{x0:Math.min(i,a),x1:Math.max(i,a),y0:Math.min(o,r),y1:Math.max(o,r)})}const jz=(e,t)=>tu((e.schema.axisConfig.shapeConfig?.labelConfig??{}).fontColor,t,0)??Ga(e);function Hz(e){const t=Number(e.schema.maxAngle??270)||270;return Math.max(1,Math.min(360,t))*Math.PI/180}const Iz=Math.PI/6;function Gz(e){return 2*Math.PI-Hz(e)>=Iz-1e-9}function Vz(e,t,i){const o=function(e,t){const n=e.schema.axisConfig.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?Math.min(n,.9*t):Math.max(8,Math.min(14,.6*t))}(e,i);return t.map((t,i)=>{const a=e._drawLabel(t,i),r=gA(e,a,t,i),s=n.textWidth(a,{"font-family":r.fontFamily,"font-size":o,"font-weight":r.fontWeight});return{d:t,i:i,text:a,font:r,size:o,width:s}})}function qz(e,t){const{width:o,height:a}=ie(e),r=e.schema.value,s=t.map((e,t)=>Number(r(e,t))),c=(Number(e.schema.startAngle)||0)*Math.PI/180,l=c+Hz(e),h=Gz(e),u=e.schema.ticks,d="number"==typeof u?u:Vb(c,l),f=Gb(s.concat(oA(e)),[],e.schema.domain,d),m=qb(f,u,!1,d).major,p=e=>Ib(e,f,c,l),g=function(e,t,i){const o=e.schema.tickFormat,a={},r=t.map((t,r)=>{const s=`${o(t)}`,c=gA(e,s,a,r),l={"font-family":c.fontFamily,"font-size":c.fontSize,"font-weight":c.fontWeight};return{t:t,text:s,font:c,angle:i(t),width:n.textWidth(s,l)}}),s=jz(e,a);return{margin:r.length?Math.max(...r.map(e=>Math.max(e.width,e.font.fontSize)))+6:0,nodes:e=>{const t=r.map(t=>_A(t.angle,e,t.width,t.font.fontSize)),n=t.length,i=n>1&&wA(t[0],t[n-1])?n-1:n;return r.slice(0,i).map((e,n)=>{const i=t[n];return{type:"text",key:`radialbar-tick-${n}`,interactive:!1,x:0,y:0,transform:{x:i.x+i.width/2,y:i.y+i.height/2},lines:[{text:e.text,x:0,y:0,width:e.width}],font:{family:e.font.fontFamily,size:e.font.fontSize,weight:e.font.fontWeight,anchor:"middle",baseline:"middle"},paint:{fill:s}}})}}}(e,m,p),{outer:y,cx:x,cy:b}=function(e,t,n){const{width:i,height:o,margin:a,start:r,end:s}=n,c=Math.max(0,i-2*a),l=Math.max(0,o-2*a),h=Number(e.schema.trackPadding)||0,u=e=>Xb(c,l,Wz(r,s,e));let d=u(0);for(let n=0;n<2&&t.length&&d.radius>0;n++){const n=RA(e.schema.innerRadius,d.radius),i=Tz(t.length,n,d.radius,h)[0];d=u((Math.max(0,...Vz(e,t,i.outer-i.inner).map(e=>e.width))+6)/d.radius)}return{outer:d.radius,cx:d.cx-c/2,cy:d.cy-l/2}}(e,h?t:[],{width:Math.max(0,o-4),height:Math.max(0,a-4),margin:g.margin,start:c,end:l}),_=RA(e.schema.innerRadius,y),k={inner:_,outer:y,domain:f,start:c,end:l,ticks:m,cx:x,cy:b},v=Tz(t.length,_,y,Number(e.schema.trackPadding)||0),w=p(Math.max(f[0],Math.min(f[1],0))),S=t.map((t,n)=>{const i=p(s[n]);return{__d3plus__:!0,data:t,i:n,slot:e._ids(t,n).join("-"),value:s[n],y0:0,y1:s[n],arc:{innerRadius:v[n].inner,outerRadius:v[n].outer,startAngle:Math.min(w,i),endAngle:Math.max(w,i)}}}),C=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[];return!1!==e.schema.track&&C.push(function(e,t,n,o){const a=e.schema.trackConfig??{};return{type:"group",key:"radialbar-tracks",interactive:!1,children:t.map((t,r)=>{const s={innerRadius:n[r].inner,outerRadius:n[r].outer,startAngle:o.start,endAngle:o.end};return{type:"path",key:`radialbar-track-${e._ids(t,r).join("-")}`,interactive:!1,d:i.arcPath(s),arc:s,paint:iu(a,t,r)}})}}(e,t,v,k)),C.push(...function(e,t,n){const i=dA({},e.schema.axisConfig.gridConfig),o=t.ticks.map((e,o)=>{const a=n(e),[r,s]=[Math.sin(a),-Math.cos(a)];return{type:"path",key:`radialbar-grid-${o}`,interactive:!1,d:`M${t.inner*r},${t.inner*s}L${t.outer*r},${t.outer*s}`,paint:mA(i,{value:e,r:t.outer},o)}});return o.length?[{type:"group",key:"radialbar-grid",interactive:!1,children:o}]:[]}(e,k,p)),m.length&&C.push({type:"group",key:"radialbar-ticks",interactive:!1,children:g.nodes(y)}),h&&C.push(...function(e,t,n,i){const o=2*Math.PI-(n.end-n.start),a=i.length?i[0].outer-i[0].inner:0,r=[];if(Vz(e,t,a).forEach(({d:t,i:a,text:s,font:c,size:l})=>{const h=i[a],u=(h.inner+h.outer)/2,d=Oz(u,n.outer,o,6);if(l<6||d<2*l)return;const f=C_(s,c.fontFamily,l,d,6,c.fontWeight);r.push({type:"text",key:`radialbar-label-${e._ids(t,a).join("-")}`,interactive:!1,x:0,y:0,transform:{x:-6,y:-u},lines:[{text:f.text,x:0,y:0,width:f.width}],font:{family:c.fontFamily,size:f.size,weight:c.fontWeight,anchor:"end",baseline:"middle"},paint:{fill:jz(e,t)}})}),!r.length)return[];const s=180*n.start/Math.PI;return[{type:"group",key:"radialbar-labels",interactive:!1,transform:s?{rotate:s}:void 0,children:r}]}(e,t,k,v)),e.ctx.polar=k,{wedges:S,frame:k}}function Yz(e){const t=(e._filteredData??[]).slice(),n=e.schema.sort;return"function"==typeof n?t.sort(n):t}const Kz=e=>(t,n)=>e._ids(t,n).join("-"),Uz=(e,t)=>{if("angle"===e.schema.discrete)return TA(e,t,Kz(e));const n=e.schema.value;return t.map((e,t)=>Number(n(e,t)))},Xz=({viz:e})=>{const t=Yz(e);if("angle"===e.schema.discrete){const n=Number(e.schema.maxAngle??360)||360,i=e.schema.trackConfig??{},{wedges:o}=OA(e,{key:"radialbar",rows:t,slotOf:Kz(e),slotLabel:(t,n)=>n.length?e._drawLabel(n[0],0):"",scale:"linear",slotPadding:Number(e.schema.trackPadding)||0,sweep:Math.max(1,Math.min(360,n))*Math.PI/180,trackPaint:!1!==e.schema.track&&t.length?iu(i,t[0],0):void 0});return{shapeData:o}}const{wedges:n}=qz(e,t);return{shapeData:n}},Qz=({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const o="angle"===e.schema.discrete,a=e.ctx.polar;return[...n.map((t,n)=>{const r=o?{...a.tracks[n],padAngle:0}:{innerRadius:t.arc.innerRadius,outerRadius:t.arc.outerRadius,startAngle:a.start,endAngle:a.end};return{type:"path",key:`radialbar-${e._ids(t.data,t.i).join("-")}-${t.slot}::hit`,d:i.arcPath(r),datum:t.data,index:t.i,paint:{fill:"transparent"}}}),...tA(e,n,"radialbar",t=>`${e._drawLabel(t.data,t.i)}, ${d.formatAbbreviate(t.value,e.schema.locale)}.`)]},Zz={name:"RadialBar",layoutStage:Xz,emit:Qz,insetRegion:Uu,chartTransform:e=>{const{width:t,height:n}=ie(e),i=oe(e,t,n),o=e.ctx.polar;return{x:(i.x??0)+(o?.cx??0),y:(i.y??0)+(o?.cy??0)}},chartBodyRect:e=>{const t=e.ctx.polar?.outer??0;return{x:-t,y:-t,width:2*t,height:2*t}},facet:aA(Uz),ctx:{},fields:[{key:"discrete",default:"radius"},{key:"domain"},{key:"innerRadius",default:e=>e/4},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"maxAngle"},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"sort",factory:e=>(t,n)=>{const i=e.schema.value;return i(n)-i(t)}},{key:"startAngle",default:0},{key:"tickFormat",factory:e=>t=>d.formatAbbreviate(t,e.schema.locale)},{key:"ticks"},{key:"track",default:!0},{key:"trackPadding",default:.25},{key:"value",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"legend",coerce:"const",factory:e=>cw(e,e=>"angle"===e.schema.discrete||Gz(e))},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:e=>G(J$(e),{gridConfig:{stroke:()=>!1===e.schema.track?Zn(e._select?.node(),e.schema.colorDefaults):n.backgroundColor(e._select?.node())}})},{key:"trackConfig",merge:!0,factory:e=>({fill:()=>xS(e).track})},{key:"shapeConfig",merge:!0,factory:e=>({stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[eA(e)]})}]};var Jz=xf(Zz);const eD=2*Math.PI,tD=({viz:e})=>{const{rowValues:t,columnValues:n,shapeData:i}=xM.bind(e)(e._filteredData),{width:o,height:a}=ie(e);if(!t.length||!n.length)return e.ctx.radialMatrixWidth=o,e.ctx.radialMatrixHeight=a,{shapeData:[]};e.ctx.radialMatrixWidth=o,e.ctx.radialMatrixHeight=a;const r=100,s=(h.min([a-100,o-200])??0)/2,c=n.slice().reverse();c.unshift(c.pop());const l=c.length,u=c.map((e,t)=>{const n=t/l*eD,i=Math.round(180*n/Math.PI),o=Math.floor((i+90)/90%4+1),a=[0,180].includes(i)?-50:[2,3].includes(o)?-100:0,r=[90,270].includes(i)?-25:[2,1].includes(o)?-50:0;return{key:e,angle:i,quadrant:o,radians:n,x:s*Math.sin(n+Math.PI)+a,y:s*Math.cos(n+Math.PI)+r}}),d=e.schema.columnConfig;((e,t,n,i,o)=>{const a=e.ctx.columnLabels;a.renderMode("compute").select(void 0).data(t).x(e=>e.x).y(e=>e.y).text(e=>e.key).width(n).height(i).config(o).render();const r=a.toScene();var s;r&&((s=e)._chartScene||(s._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:r.children??[]})})(e,d.labels instanceof Array?u.filter(e=>d.labels.includes(e.key)):u,r,50,d.shapeConfig?.labelConfig);const f=(0,e.schema.innerRadius)(s),m=(s-f)/t.length,p=u.length>1?u[1].radians-u[0].radians:eD,g=t.slice().reverse(),y=new Map;g.forEach((e,t)=>y.set(e,t));const x=new Map;n.forEach((e,t)=>x.set(e,t));const b=e.schema.cellPadding,_=L.arc().padAngle(b/s).innerRadius(e=>f+(y.get(e.row)??0)*m+b/2).outerRadius(e=>f+((y.get(e.row)??0)+1)*m-b/2).startAngle(e=>u[x.get(e.column)??0].radians-p/2).endAngle(e=>u[x.get(e.column)??0].radians+p/2);return e.ctx.arcData=_,{shapeData:i}},nD=(e,t)=>`${e}`.localeCompare(`${t}`),iD={name:"RadialMatrix",layoutStage:tD,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.ctx.arcData,o=au(e,"Path"),a=e.schema.colorScale,r=n.map((t,n)=>{const r=tu(o.fill,t,n),s=tu(o.stroke,t,n),c=tu(o.strokeWidth,t,n),l=a?`, ${a(t.data??t,n)}`:"";return{type:"path",key:`rm-${e._ids(t,n).join("-")}`,d:i(t),datum:t,paint:{fill:nu(o,t,n,r),stroke:s,strokeWidth:c},aria:{label:`${t.row}, ${t.column}${l}.`}}});return[...r,...qy(o,r,e=>[n[e],e])]},chartTransform:e=>oe(e,e.ctx.radialMatrixWidth,e.ctx.radialMatrixHeight),chartBodyRect:e=>{const t=e.ctx.radialMatrixWidth??0,n=e.ctx.radialMatrixHeight??0;return{x:-t/2,y:-n/2,width:t,height:n}},setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(n,i,o,a)=>{if(t(n,i,o,a),Ra(o)||Ra(n))return;const r=ze.bind(e)("row",n,i),s=ze.bind(e)("column",n,i);e.hover((t,n)=>ze.bind(e)("row",t,n)===r||ze.bind(e)("column",t,n)===s)}},facet:{aspect:1},ctx:{columnLabels:new ro},fields:[{key:"cellPadding",default:2},{key:"column",default:T("column"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"row",default:T("row"),coerce:e=>"function"==typeof e?e:Be(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:nD},{key:"rowSort",default:nD},{key:"innerRadius",default:e=>e/5,coerce:e=>"function"==typeof e?e:N(e)},{key:"columnConfig",merge:!0,factory:e=>({shapeConfig:{labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)},padding:5,textAnchor:e=>[0,180].includes(e.angle)?"middle":[2,3].includes(e.quadrant)?"end":"start",verticalAlign:e=>[90,270].includes(e.angle)?"middle":[2,1].includes(e.quadrant)?"bottom":"top"}}})},{key:"label",coerce:"const",factory:e=>(t,n)=>`${ze.bind(e)("row",t,n)} / ${ze.bind(e)("column",t,n)}`}]};var oD=xf(iD);function aD(e,t={}){const n=e.filter(e=>Number.isFinite(e)).sort((e,t)=>e-t);if(!n.length)return null;const i=f.kernelDensity(n,t);return{values:n,n:n.length,min:n[0],q1:h.quantileSorted(n,.25),median:h.quantileSorted(n,.5),q3:h.quantileSorted(n,.75),max:n[n.length-1],mean:h.mean(n),curve:i,peak:i.reduce((e,t)=>Math.max(e,t[1]),0)}}function rD(e,t){const n=new Map;e.forEach((e,i)=>{if(!e)return;const o=t.value(e,i),a=null==o||""===o?NaN:Number(o);if(!Number.isFinite(a))return;const r=t.key(e,i);let s=n.get(r);s||n.set(r,s={first:e,rows:[],values:[]}),s.rows.push(e),s.values.push(a)});const i=[];return n.forEach((e,n)=>{const o=aD(e.values,t.density);o&&i.push({key:n,first:e.first,summary:{...o,rows:e.rows,observed:e.values}})}),i}function sD(e,t="area"){if("width"===t)return e=>e.peak>0?1/e.peak:0;if("count"===t){const t=e.reduce((e,t)=>Math.max(e,t.peak*t.n),0);return e=>t>0?e.n/t:0}const n=e.reduce((e,t)=>Math.max(e,t.peak),0);return()=>n>0?1/n:0}function cD(e,t){const n=e.slice();if("ascending"!==t&&"descending"!==t)return n;const i="ascending"===t?1:-1;return n.map((e,t)=>({g:e,i:t})).sort((e,t)=>i*(e.g.summary.median-t.g.summary.median)||e.i-t.i).map(({g:e})=>e)}function lD(e,t){if(!e.length||t<e[0][0]||t>e[e.length-1][0])return 0;let n=0,i=e.length-1;for(;i-n>1;){const o=n+i>>1;e[o][0]<=t?n=o:i=o}const[o,a]=e[n],[r,s]=e[i];return r===o?Math.max(a,s):a+(s-a)*(t-o)/(r-o)}const hD="__d3plusDensity";function uD(e){for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}function dD(e){const t=uD(e);return t?t[hD]:void 0}function fD(e){return`density-${e.id}`}function mD(e){const t=e.schema.groupBy,n=[e.schema.facet,e.schema.time].filter(Boolean);return(e,i)=>[...t,...n].map(t=>`${t(e,i)}`).join("\0")}function pD(e){const t=e.ctx.density;e._data!==t.rows&&(t.raw=e._data),e._sourceData=t.raw;const n=t.layout.valueAxis(e),i="x"===n?"y":"x",o=e.schema.groupBy,a=jS(e.schema.value),r=rD(t.raw,{value:e.schema.value,key:mD(e),density:e.schema.densityConfig}),s=cD(r,e.schema.medianSort),c=sD(r.map(e=>e.summary),e.schema.densityScale),l=r.every(e=>o.every(t=>void 0===t(e.first,0))),h=a??e.schema.translate("Value");t.categories=new Map,t.rows=e._data=s.map((e,r)=>{const s={...e.first};a&&delete s[a],l&&(s.id=h);const u=l?h:`${o[0](e.first,0)}`;return t.categories.has(u)||t.categories.set(u,t.categories.size),s[i]=u,s[n]=e.summary.median,s[hD]={summary:e.summary,order:r,scale:c(e.summary)},s});const u={x:e._xConfig,y:e._yConfig};t.titleAxis&&t.titleAxis!==n&&HS(u[t.titleAxis],t.title,void 0),HS(u[n],t.titleAxis===n?t.title:void 0,a),t.title=a,t.titleAxis=n}function gD({data:e,x:t,y:n,x2:i,y2:o}){if(i||o)return[t,n];const a=this.ctx.density,r=a.layout.valueAxis(this),s="x"===r?t:n,c="x"===r?n:t,l=s.domain().slice(),h=l[0]>l[1];h&&l.reverse(),e.forEach(e=>{const t=dD(e)?.summary.curve;t&&t.length&&(l[0]=Math.min(l[0],t[0][0]),l[1]=Math.max(l[1],t[t.length-1][0]))}),h&&l.reverse(),s.domain(l);const[u,d]=a.layout.categoryPadding(this);return c.padding&&c.padding(u),c.align&&c.align(d),[t,n]}function yD(e,t){e.ctx.density={raw:[],rows:[],layout:t,categories:new Map},e._buffer={...e._buffer,Area:gD},e._plotShapeEmitters={...e._plotShapeEmitters,Area:t.emit},e._sharedHover=()=>{};const n=function(e){return(t,n)=>{const i=e.ctx.density,o="x"===i.layout.valueAxis(e)?"y":"x",a=e=>i.categories.get(`${uD(e)?.[o]}`)??0;return i.layout.reverse?a(n)-a(t):a(t)-a(n)}}(e),i=e._preDraw.bind(e);e._preDraw=()=>{pD(e);const o="x"===t.valueAxis(e)?"y":"x",a="x"===o?"y":"x";e.schema[`${a}Sort`]===n&&(e.schema[`${a}Sort`]=void 0),e.schema[`${o}Sort`]||(e.schema[`${o}Sort`]=n),i()}}function xD(e,t,n){const i=t=>d.formatAbbreviate(t,e.schema.locale),o=t=>e.schema.translate(t),a=dD(t);if(!a){const a=Number(e.schema.value(uD(t),n));return Number.isFinite(a)?[[jS(e.schema.value)??o("Value"),i(a)]]:[]}const r=a.summary;return[[o("Observations"),i(r.n)],[o("Maximum"),i(r.max)],[o("Upper Quartile"),i(r.q3)],[o("Median"),i(r.median)],[o("Lower Quartile"),i(r.q1)],[o("Minimum"),i(r.min)]]}function bD(){return[{key:"densityScale",default:"area"},{key:"medianSort",default:!1},{key:"shape",default:N("Area"),coerce:"const"},{key:"tooltipShared",default:!1},{key:"value",default:WS("value"),coerce:e=>"string"==typeof e?Be(e):"function"==typeof e?e:N(e)}]}function _D(e){return[{key:"densityConfig",merge:!0,default:{kernel:"gaussian",points:80,cut:e}},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:(t,n)=>xD(e,t,n)})}]}function kD(e,t,n){return n?n.rotate?null:(e-(n[t]??0))/(n.scale??1):e}function vD(e,t,n){const o=(e,a)=>{if("group"===e.type){const n=n=>{const i=a(n);return null===i?null:kD(i,t,e.transform)};return void e.children.forEach(e=>o(e,n))}if("path"!==e.type)return;const r=n.get(`${e.key}`.replace(/::hit$/,""));if(void 0===r)return;const s=a(r),c=null===s?null:kD(s,t,e.transform);null!==c&&Number.isFinite(c)&&(e.enterD=i.flattenPath(e.d,t,c))};e.forEach(e=>o(e,e=>e))}function wD(e,t){e.forEach(e=>{if("group"===e.type)wD(e.children,t);else if("rect"===e.type){const{x:n,y:i,width:o,height:a}=e;e.enterRect="x"===t?{x:n+o/2,y:i,width:0,height:a}:{x:n,y:i+a/2,width:o,height:0}}})}function SD(e,t,n){return Math.abs(e)/Math.max(1,t-1+2*n)}function CD(e,t){const{position:n,step:i,gap:o,split:a}=t,r=Math.max(1,i>o?i-o:i),s=new Map;e.forEach((e,t)=>{s.has(e)||s.set(e,[]),s.get(e).push(t)});const c=new Array(e.length);return s.forEach((e,t)=>{const i=n(t),o=e.length;if(a&&2===o)return c[e[0]]={center:i,half:r/2,side:"start"},void(c[e[1]]={center:i,half:r/2,side:"end"});const s=r/o,l=o>1?Math.min(2,s/4):0;e.forEach((e,t)=>{c[e]={center:i-r/2+s*(t+.5),half:Math.max(.5,(s-l)/2),side:"both"}})}),c}function MD(e,t,n){return e.map(([e,i])=>({value:e,extent:i*t*n}))}function $D(e,t){const{center:n,side:i}=e;return["end"===i?n:n-t,"start"===i?n:n+t]}function AD(e){const t=Number(e.schema.overlap);return Number.isFinite(t)&&t>0?t:0}function zD(e){return e>0?[e/2,1]:[0,.5]}const DD=(e,t)=>{const{viz:n,values:i,x:o,y:a,yRange:r,yDomain:s}=e,c=AD(n),l=s,h=l.map(e=>a(e,"y")).sort((e,t)=>e-t);let u=SD(r[r.length-1]-r[0],l.length,zD(c)[0]);for(let e=1;e<h.length;e++)u=Math.min(u,h[e]-h[e-1]);const d=c*u,f=i.filter(e=>dD(e)).map(e=>({row:e,base:a(e.y,"y")})).sort((e,t)=>e.base-t.base),m=[];f.forEach(({row:e,base:t})=>{const n=dD(e);n.summary.curve.forEach(([i,a])=>{m.push({...e,id:fD(e),__pos:o(i),__base:t,__top:t-a*n.scale*d})})});const p=e=>e.__pos,g=e=>e.__base,y={x:p,x0:p,x1:null,y:g,y0:g,y1:e=>e.__top},x=cx({...e,values:m,shapeConfig:{...e.shapeConfig,...y}},t);return vD(x,"y",new Map(f.map(({row:e,base:t})=>[fD(e),t]))),x},FD={name:"Ridgeline",paintDriven:!0,setup:e=>yD(e,{valueAxis:()=>"x",categoryPadding:e=>zD(AD(e)),reverse:!0,emit:DD}),ctx:{},fields:[{key:"discrete",default:"y"},{key:"overlap",default:1.5},...bD(),..._D(3),{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var BD=xf(FD,_b);function LD(e,t){const n=(h.min([t,e])||0)/2/3;return{width:e,height:t,ringWidth:n,primaryRing:n,secondaryRing:2*n}}function PD(e,t){const n=e.schema.sizeMin,i=e.schema.sizeMax;return Math.min(i??1/0,Math.max(n??0,t))}function RD(e,t,n,i,o,a){if(o.forEach(e=>e.ring=1),a.forEach(e=>e.ring=2),e._size){const r=[t,...o,...a];r.forEach(t=>t.size=Number(e._size(t.data,t.i)));const s=r.map(e=>e.size).filter(e=>Number.isFinite(e));if(s.length){const t=function(e,t,n,i){const{ringWidth:o,primaryRing:a,secondaryRing:r}=t,s=Math.sin(Math.PI/Math.max(n,2)),c=Math.max(1,Math.floor(h.min([o/4,a*s-1,r*s-1]))),l=Math.min(e.schema.sizeMax??1/0,c),u=Math.min(l/2,e.schema.sizeMin??3),d=h.extent(i),f=`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`;return B[f]().domain(d).range([d[0]===d[1]?l:u,l])}(e,n,i,s);return r.forEach(n=>n.r=Number.isFinite(n.size)?t(n.size):PD(e,0)),t}}const{ringWidth:r}=n,s=r/2,c=r/4;let l=s/2-4;s/2-4<8&&(l=h.min([s/2,8])||0);let u=c/2-4;return c/2-4<4&&(u=h.min([c/2,4])||0),u>r/10&&(u=r/10),u>l&&u>10&&(u=.75*l),l>1.5*u&&(l=1.5*u),o.forEach(t=>t.r=PD(e,Math.floor(l))),a.forEach(t=>t.r=PD(e,Math.floor(u))),null}function ED(e,t,n){if("object"==typeof n)return t[n.id];const i=t[n];if(i)return i;if(!isNaN(n)){const e=t[parseFloat(n)];if(e)return e}if("number"==typeof n){const i=e.schema.nodes&&e.schema.nodes[n];if(null==i)return;return"object"==typeof i&&t[i.id]||t[i]}}function ND(e,t,n,i,o){const{width:a,height:r,primaryRing:s,secondaryRing:c}=o;i.x=a/2,i.y=r/2,i.r=e.schema.sizeMin?h.max([e.schema.sizeMin,.65*s]):e.schema.sizeMax?h.min([e.schema.sizeMax,.65*s]):.65*s;const l=[i],u=[];(n[e.schema.center]||[]).forEach(t=>{const i=t.source.id===e.schema.center?t.target:t.source;i.edges=n[i.id].filter(t=>t.source.id!==e.schema.center||t.target.id!==e.schema.center),i.edge=t,l.push(i),u.push(i)}),u.sort((e,t)=>e.edges.length-t.edges.length);const d=[];let f=0;u.forEach(e=>{const t=e.id;e.edges=e.edges.filter(e=>!l.includes(e.source)&&e.target.id===t||!l.includes(e.target)&&e.source.id===t),f+=e.edges.length||1,e.edges.forEach(e=>{const{source:n,target:i}=e,o=i.id===t?n:i;l.push(o)})});const m=2*Math.PI;let p=0;u.forEach((e,t)=>{const n=e.edges,i=n.length||1,o=m/f*i;0===t&&(p-=o/2);const l=p+o/2-m/4;e.radians=l,e.x=a/2+s*Math.cos(l),e.y=r/2+s*Math.sin(l),p+=o,n.forEach((t,n)=>{const o=t.source.id===e.id?t.target:t.source,s=m/f,h=l-s*i/2+s/2+s*n;o.radians=h,o.x=a/2+c*Math.cos(h),o.y=r/2+c*Math.sin(h),d.push(o)})});const g=RD(e,i,o,f,u,d);return{nodes:[i].concat(u).concat(d),primaries:u,secondaries:d,radius:g}}function TD(e,t,i){const{ringWidth:o}=i;t.forEach(t=>{if(t.id===e.schema.center){const{bounds:o,inside:r}=function(e,t,i,o,r){const{primaryRing:s}=i;if(!e._size)return{bounds:{x:-s/2,y:-s/2,width:s,height:s},inside:!0};const c=t.r??0,l=c*Math.SQRT2;return l>=Math.max(0,...String(o??"").split(/\s+/).map(e=>n.textWidth(e,{"font-family":a.fontFamilyStringify(r),"font-size":9})))&&l>=12.6?{bounds:{x:-l/2,y:-l/2,width:l,height:l},inside:!0}:{bounds:{x:-s/2,y:c+3,width:s,height:s/2},inside:!1}}(e,t,i,e._drawLabel(t.data||t.node,t.i),e.schema.fontFamily);return t.labelBounds=o,void(t.labelInside=r)}const r=e.schema.shapeConfig.labelConfig,s=1.4*(r?.fontSize&&r.fontSize(t)||11),c=2*s,l=o-t.r;let h=t.radians*(180/Math.PI),u=t.r+5,d="start";(h<-90||h>90)&&(u=-t.r-l-5,d="end",h+=180),t.labelBounds={x:u,y:-s/2,width:l,height:c},t.rotate=h,t.textAnchor=d})}function OD(e){if(Array.isArray(e._filteredData)||(e._filteredData=[]),Array.isArray(e.schema.nodes)||(e.schema.nodes=[]),Array.isArray(e.schema.links)||(e.schema.links=[]),!e._filteredData.length&&!e.schema.nodes.length&&!e.schema.links.length)return null;const t=e._filteredData.reduce((t,n,i)=>(t[e._id(n,i)]=n,t),{}),n=function(e,t){let n=e.schema.nodes;!n.length&&e.schema.links.length&&(n=Array.from(new Set(e.schema.links.reduce((e,t)=>e.concat([t.source,t.target]),[]))).map(e=>"object"==typeof e?e:{id:e}));const i=n.reduce((t,n,i)=>(t[e.schema.nodeGroupBy?e.schema.nodeGroupBy[e._drawDepth](n,i):e._id(n,i)]=n,t),{}),o=Array.from(new Set(Object.keys(t).concat(Object.keys(i)))).map((n,o)=>{const a=t[n],r=i[n];return void 0!==r&&{__d3plus__:!0,data:a||r,i:o,id:n,node:r,shape:void 0!==a&&void 0!==e.schema.shape(a)?e.schema.shape(a):e.schema.shape(r)}}).filter(e=>!!e),a=o.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=a;const r=e.schema.links.map(t=>({source:ED(e,a,t.source),target:ED(e,a,t.target),size:e.schema.linkSize(t)})).filter(e=>e.source&&e.target),s=r.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t),e),{});return{nodes:o,nodeLookup:a,links:r,linkMap:s}}(e,t);let i=n.nodeLookup[e.schema.center];return i||null==e.schema.center||isNaN(e.schema.center)||(i=n.nodeLookup[parseFloat(e.schema.center)]),i&&(e.schema.center=i.id),{data:t,graph:n,center:i}}const WD=({viz:e})=>{const t=e;t._sizeLegendFinal=null;const i=OD(t);if(!i)return t.ctx.nodeLookup={},t.ctx.linkLookup={},t.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const{graph:{nodeLookup:o,links:a,linkMap:s},center:c}=i;if(!c)return t.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const{width:l,height:u}=ie(t),d=[],f=LD(l,u),{nodes:m,primaries:p,secondaries:g,radius:y}=ND(t,0,s,c,f);return t._sizeLegendFinal=y,function(e,t,n,i,o,a,r,s){const{width:c,height:l,ringWidth:h,primaryRing:u,secondaryRing:d}=r;n.forEach(e=>{const r=e.edge;["source","target"].forEach(e=>{r[e]=t.find(t=>t.id===r[e].id)}),s.push(r),o[e.id].forEach(o=>{const r=o.source.id===e.id?o.target:o.source;if(r.id===a.id)return;let f=i.find(e=>e.id===r.id);if(f||(f=n.find(e=>e.id===r.id)),!f)return;o.spline=!0;const m=c/2,p=l/2,g=u+.5*(d-u);["source","target"].forEach((n,i)=>{const a=o[n],r=a.radians,s=a.ring,c=a.x,l=a.y,u=a.r,d=2===s?r+Math.PI:r;o[`${n}X`]=c+Math.cos(d)*u,o[`${n}Y`]=l+Math.sin(d)*u,o[`${n}BisectX`]=m+g*Math.cos(r),o[`${n}BisectY`]=p+g*Math.sin(r),o[n]=t.find(e=>e.id===a.id);const y=o[n];void 0===y.edges&&(y.edges={});const x=0===i?o.target.id:o.source.id,b=y.edges;y.id===e.id?b[x]={angle:e.radians+Math.PI,radius:h/2}:b[x]={angle:f.radians,radius:h/2}}),s.push(o)})})}(0,m,p,g,s,c,f,d),TD(t,m,f),function(e,t,i,o,a){e.ctx.linkLookup=o.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{});const s=h.extent(o,e=>e.size);if(s[0]!==s[1]){const n=h.min(t,e=>e.r),i=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(s).range([e.schema.linkSizeMin,n]);o.forEach(e=>{e.size=i(e.size)})}const c=au(e,"Path",e.schema.shapeConfig,"edge");delete c.on;const l=t=>t.id===e.schema.center&&!1!==i[t.id]?.labelInside,u={label:n=>!!(t.length<=e.schema.dataCutoff||e._hover&&e._hover(n)||e._active&&e._active(n))&&e._drawLabel(n.data||n.node,n.i),labelBounds:e=>e.labelBounds,labelConfig:{fontColor:t=>{const o=t.data??t;if(o.id===e.schema.center&&!1!==i[o.id]?.labelInside){const t=tu(au(e,o.key??o.shape).fill,o.data??o,o.i);return r.colorContrast("string"==typeof t?t:"rgb(255, 255, 255)",e.schema.colorDefaults)}return r.colorContrast(e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)",e.schema.colorDefaults)},fontResize:e=>l(e.data??e),padding:0,textAnchor:t=>{const n=t.data??t;return n.id!==e.schema.center||l(n)?i[n.id]?.textAnchor||au(e,n.key??n.shape).labelConfig.textAnchor:"middle"},verticalAlign:e=>l(e.data??e)?"middle":"top"},rotate:e=>i[e.id].rotate||0},d=Array.from(h.groups(t,e=>e.shape));e.ctx.ringsCtx={edges:a,nodeGroups:d,linkConfig:c,linkD:e=>e.spline?`M${e.sourceX},${e.sourceY}C${e.sourceBisectX},${e.sourceBisectY} ${e.targetBisectX},${e.targetBisectY} ${e.targetX},${e.targetY}`:`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeShapeConfig:u}}(t,m,o,a,d),{shapeData:m}};function jD(e,t,n,i,o,a){const r=e.schema.arrows,s=`${t.source.id}-${t.target.id}-${a}`,c="string"==typeof i?i:void 0;if(!t.spline)return PM({arrows:r,arrowSize:e.schema.arrowSize,strokeWidth:o,datum:n,i:a,keyPrefix:`rings-arrow-${s}`,fill:c,source:t.source,target:t.target});const l=zM(r,n,a);if(!l.source&&!l.target)return[];const h=LM(e.schema.arrowSize,n,a,"number"==typeof o?o:1),u=[];if(l.target&&null!=t.targetX){const e=Math.atan2(t.targetY-t.targetBisectY,t.targetX-t.targetBisectX);u.push(RM({key:`rings-arrow-t-${s}`,datum:n,x:t.targetX,y:t.targetY,angle:e,size:h,fill:c}))}if(l.source&&null!=t.sourceX){const e=Math.atan2(t.sourceY-t.sourceBisectY,t.sourceX-t.sourceBisectX);u.push(RM({key:`rings-arrow-s-${s}`,datum:n,x:t.sourceX,y:t.sourceY,angle:e,size:h,fill:c}))}return u}function HD(e,t,n,i,o){const a=`rings-${e}-${t.id}`;if("Circle"===e)return{type:"circle",key:a,cx:0,cy:0,r:t.r,...i};if("Rect"===e){const e=Number(tu(n.width,i.datum,o)??2*t.r),r=Number(tu(n.height,i.datum,o)??2*t.r);return{type:"rect",key:a,x:-e/2,y:-r/2,width:e,height:r,...i}}return null}const ID={name:"Rings",layoutStage:WD,sizeLegendScale:(e,{width:t,height:n})=>function(e,t,n){if(!e._size)return null;const{nodeLookup:i}=e.ctx,o=OD(e);if(e.ctx.nodeLookup=i,!o||!o.center)return null;const{graph:a,center:r}=o;return ND(e,a.nodeLookup,a.linkMap,r,LD(t,n)).radius}(e,t,n),emit:({viz:e})=>{const t=e.ctx.ringsCtx;if(!t)return[];const n=[];if(t.edges&&t.edges.length)for(let i=0;i<t.edges.length;i++){const o=t.edges[i],a=o,r=iu(t.linkConfig,a,i);"number"==typeof o.size&&(r.strokeWidth=o.size);const s="number"==typeof o.size?`, ${o.size}`:"";n.push({type:"path",key:`rings-link-${o.source.id}-${o.target.id}`,d:t.linkD(o),datum:a,paint:r,aria:{label:`${ou(e,o.source,0)} to ${ou(e,o.target,0)}${s}.`}}),n.push(...jD(e,o,a,r.stroke,r.strokeWidth,i))}if(t.nodeGroups&&t.nodeGroups.length){const i=t.nodeShapeConfig;for(const[o,a]of t.nodeGroups){if(!a.length)continue;const r={...au(e,o),...t.nodeShapeConfig},s=[];for(let t=0;t<a.length;t++){const c=a[t],l=c.data??c,h=iu(r,l,c.i??t);void 0===h.vectorEffect&&(h.vectorEffect="non-scaling-stroke");const u=i.rotate?i.rotate(c):0,d=u?{x:c.x,y:c.y,rotate:u}:{x:c.x,y:c.y},f=e._size,m=f?`, ${f(l,c.i??t)}`:"",p=HD(o,c,r,{datum:l,paint:h,transform:d,aria:{label:`${ou(e,c,t)}${m}.`}},c.i??t);if(!p)continue;n.push(p);const g=Vy(r,p,l,c.i??t);g&&s.push(g)}if(n.push(...s),i.label&&i.labelBounds){const t=i.label,r=i.labelBounds,s=iw({data:a,label:(e,n)=>t(e,n),x:e=>e.x,y:e=>e.y,aes:e=>({r:e.r}),rotate:e=>i.rotate?i.rotate(e):0,id:e=>`rings-label-${e.id}`,labelBounds:(e,t)=>r(e),labelConfig:{...ru(e,o),...i.labelConfig}});n.push(...s)}}}return n},insetRegion:Uu,setup:e=>{!function(e){const t=e,n=(e,t,n,i)=>o.addToQueue.bind(e)(t,n,i);t.links=function(e,t){return arguments.length?(n(this,e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(n(this,e,t,"nodes"),this):this.schema.nodes},t.linkSize=function(e){return arguments.length?(this.schema.linkSize="function"==typeof e?e:N(e),this):this.schema.linkSize},t.nodeGroupBy=function(e){if(!arguments.length)return this.schema.nodeGroupBy;const t=e instanceof Array?e:[e];return this.schema.nodeGroupBy=t.map(e=>"function"==typeof e?e:(this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const n=Array.from(new Set(e.map(t)));return 1===n.length?n[0]:n}),Be(e))),this},t.size=function(e){return arguments.length?(this._size="function"!=typeof e&&e?Be(e):e,this._sizeKey="string"==typeof e?e:void 0,this):this._size},t.hover=ow}(e);const t=e;e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const n=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,o,a,r)=>{if(n(i,o,a,r),e._focus&&e._focus===i.id)return t.hover(!1),e.schema.on.mouseenter.bind(e)(i,o,a,r),void(e._focus=void 0);const s=e.schema.nodeGroupBy&&e.schema.nodeGroupBy[e._drawDepth](i,o)?e.schema.nodeGroupBy[e._drawDepth](i,o):e._id(i,o),c=e.ctx.linkLookup[s]??[],l=e.ctx.nodeLookup[s];if(!l)return;const h=[l.id],u=[l.x-l.r,l.x+l.r],d=[l.y-l.r,l.y+l.r];c.forEach(e=>{h.push(e.id),e.x-e.r<u[0]&&(u[0]=e.x-e.r),e.x+e.r>u[1]&&(u[1]=e.x+e.r),e.y-e.r<d[0]&&(d[0]=e.y-e.r),e.y+e.r>d[1]&&(d[1]=e.y+e.r)}),t.hover((t,n)=>{const i=t;return i.source&&i.target?i.source.id===l.id||i.target.id===l.id:h.includes(e._ids(t,n)[e._drawDepth])})},e.schema.on["click.shape"]=t=>{e.hover?.(!1),e._tooltipClass?.data([]).render(),e.schema.center=t.id,e._margin={bottom:0,left:0,right:0,top:0},e._padding={bottom:0,left:0,right:0,top:0},Rd(e),Hd(e),e._sceneRenderer&&e._drawSceneToTarget(e.schema.duration)}},facet:{aspect:1},ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"center"},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>{const n=t;return t&&n.source&&n.target?`${n.source.id} → ${n.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)}})},{key:"links",default:[]},{key:"linkSize",default:N(1)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:N("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i=e._size,o=i?`, ${i(t,n)}`:"";return`${e._drawLabel(t,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#adb5bd",strokeWidth:1}})}]};var GD=xf(ID);const VD=(e,t)=>e.sourceLinks.length?e.depth:t-1;const qD=(e,t)=>e.y0-t.y0,YD=(e,t)=>qD(e.source,t.source)||e.index-t.index,KD=(e,t)=>qD(e.target,t.target)||e.index-t.index,UD=e=>e.value;function XD(e,t){const n=e.length;let i=new Set(e),o=new Set,a=0;for(;i.size;){for(const e of i)if(e[t]=a,"depth"===t)for(const{target:t}of e.sourceLinks)o.add(t);else for(const{source:t}of e.targetLinks)o.add(t);if(++a>n)throw new Error("circular link");i=o,o=new Set}}function QD(e,t,n,i){for(let o=1,a=t.length;o<a;++o){const a=t[o];for(const t of a){let i=0,o=0;for(const{source:n,value:a}of t.targetLinks){const r=a*(t.layer-n.layer);i+=oF(e,n,t)*r,o+=r}if(!(o>0))continue;const a=(i/o-t.y0)*n;t.y0+=a,t.y1+=a,nF(e,t)}void 0===e.sort&&a.sort(qD),JD(e,a,i)}}function ZD(e,t,n,i){for(let o=t.length-2;o>=0;--o){const a=t[o];for(const t of a){let i=0,o=0;for(const{target:n,value:a}of t.sourceLinks){const r=a*(n.layer-t.layer);i+=aF(e,t,n)*r,o+=r}if(!(o>0))continue;const a=(i/o-t.y0)*n;t.y0+=a,t.y1+=a,nF(e,t)}void 0===e.sort&&a.sort(qD),JD(e,a,i)}}function JD(e,t,n){const i=t.length>>1,o=t[i];tF(e,t,o.y0-e.py,i-1,n),eF(e,t,o.y1+e.py,i+1,n),tF(e,t,e.y1,t.length-1,n),eF(e,t,e.y0,0,n)}function eF(e,t,n,i,o){for(;i<t.length;++i){const a=t[i],r=(n-a.y0)*o;r>1e-6&&(a.y0+=r,a.y1+=r),n=a.y1+e.py}}function tF(e,t,n,i,o){for(;i>=0;--i){const a=t[i],r=(a.y1-n)*o;r>1e-6&&(a.y0-=r,a.y1-=r),n=a.y0-e.py}}function nF(e,{sourceLinks:t,targetLinks:n}){if(void 0===e.linkSort){for(const{source:e}of n)e.sourceLinks.sort(KD);for(const{target:e}of t)e.targetLinks.sort(YD)}}function iF(e,t){if(void 0===e.linkSort)for(const{sourceLinks:e,targetLinks:n}of t)e.sort(KD),n.sort(YD)}function oF(e,t,n){let i=t.y0-(t.sourceLinks.length-1)*e.py/2;for(const{target:o,width:a}of t.sourceLinks){if(o===n)break;i+=a+e.py}for(const{source:e,width:o}of n.targetLinks){if(e===t)break;i-=o}return i}function aF(e,t,n){let i=n.y0-(n.targetLinks.length-1)*e.py/2;for(const{source:o,width:a}of n.targetLinks){if(o===t)break;i+=a+e.py}for(const{target:e,width:o}of t.sourceLinks){if(e===n)break;i-=o}return i}const rF=({viz:e})=>{const t=e,{width:n,height:i}=ie(t),o=Array.isArray(t.schema.nodes)&&t.schema.nodes.length>0,a=Array.isArray(t.schema.links)&&t.schema.links.length>0;if(!o&&!a)return t.ctx.nodeLookup={},t.ctx.linkLookup={},{viz:e};let r;if(o)r=t.schema.nodes;else{const e=new Set,n=[];for(const i of t.schema.links){const o=i[t.schema.linksSource];e.has(o)||(e.add(o),n.push(o));const a=i[t.schema.linksTarget];e.has(a)||(e.add(a),n.push(a))}r=n.map(e=>({id:e}))}const s=r.map((e,n)=>({__d3plus__:!0,data:e,i:n,id:t.schema.nodeId(e,n),node:e,shape:"Rect"})),c=s.reduce((e,t,n)=>(e[String(t.id)]=n,e),{});t.ctx.nodeLookup=c;const l=a?t.schema.links.map((e,n)=>({source:c[String(e[t.schema.linksSource])],target:c[String(e[t.schema.linksTarget])],value:t.schema.value(e,n)})):[];t.ctx.linkLookup=l.reduce((e,t)=>(e[t.source]||(e[t.source]=[]),e[t.source].push(t.target),e[t.target]||(e[t.target]=[]),e[t.target].push(t.source),e),{}),t.ctx.sankey.nodeAlign(t.schema.nodeAlign).nodePadding(t.schema.nodePadding).nodeWidth(t.schema.nodeWidth).nodes(s).nodeSort(t.schema.nodeSort).links(l).linkSort(t.schema.linkSort).iterations(t.schema.iterations).size([n,i])();const u=Array.from(h.groups(s,e=>e.shape));return t.ctx.sankeyCtx={links:l,nodeGroups:u,pathFn:t.ctx.path},{shapeData:s}};function sF(e,t,n,i,o){const a=[],r=zM(e.schema.arrows,n,i);if(r.source||r.target){const s="number"==typeof t.width?t.width:2,c=tu(e.schema.arrowSize,n,i),l="number"==typeof c?c:Math.max(8,Math.min(s,28)),h="string"==typeof o.stroke?o.stroke:void 0;r.target&&"number"==typeof t.y1&&a.push(RM({key:`sankey-arrow-t-${t.source.id}-${t.target.id}`,datum:n,x:t.target.x0,y:t.y1,angle:0,size:l,fill:h,opacity:1})),r.source&&"number"==typeof t.y0&&a.push(RM({key:`sankey-arrow-s-${t.source.id}-${t.target.id}`,datum:n,x:t.source.x1,y:t.y0,angle:Math.PI,size:l,fill:h,opacity:1}))}return a}const cF={center:e=>e.targetLinks.length?e.depth:e.sourceLinks.length?h.min(e.sourceLinks,e=>e.target.depth)-1:0,justify:VD,left:e=>e.depth,right:(e,t)=>t-1-e.height};const lF={name:"Sankey",layoutStage:rF,emit:({viz:e})=>{const t=e.ctx.sankeyCtx;if(!t)return[];const n=[],i=e.schema.shapeConfig?.Path??{};if(t.links&&t.links.length)for(let o=0;o<t.links.length;o++){const a=t.links[o],r=a,s=iu(i,r,o);n.push({type:"path",shapeType:"Link",key:`sankey-link-${a.source.id??""}-${a.target.id??""}`,d:t.pathFn(a),datum:r,paint:s,aria:{label:`${ou(e,a.source,0)} to ${ou(e,a.target,0)}, ${a.value}.`}}),n.push(...sF(e,a,r,o,s))}if(t.nodeGroups&&t.nodeGroups.length)for(const[i,o]of t.nodeGroups){if(!o.length)continue;const t=au(e,i),a=n.length;for(let a=0;a<o.length;a++){const r=o[a],s=r.data??r,c=iu(t,s,r.i??a),l={label:`${ou(e,r,a)}.`};if("Rect"===i)n.push({type:"rect",key:`sankey-${i}-${r.id}`,x:r.x0,y:r.y0,width:r.x1-r.x0,height:r.y1-r.y0,datum:s,paint:c,aria:l});else if("Circle"===i){const e=Number(tu(t.r,s,r.i??a)??0);n.push({type:"circle",key:`sankey-${i}-${r.id}`,cx:(r.x0+r.x1)/2,cy:(r.y0+r.y1)/2,r:e,datum:s,paint:c,aria:l})}}n.push(...qy(t,n.slice(a),e=>{const t=o[e];return[t.data??t,t.i??e]}))}return n},setup:e=>{const t=e;!function(e){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(n,i,o,a)=>{if(t(n,i,o,a),e._focus&&e._focus===n.id)return e.hover(!1),e.schema.on.mouseenter.bind(e)(n,i,o,a),void(e._focus=void 0);const r=n;if(r.source&&r.target){const t=r.source.id,n=r.target.id;return void e.hover((i,o)=>{if(i.source&&i.target)return i.source.id===t&&i.target.id===n;const a=e.schema.nodeId(i,o);return a===t||a===n})}const s=e.schema.nodeId(n,i),c=e.ctx.nodeLookup[String(s)],l=e.ctx.nodeLookup,h=Object.keys(l).reduce((e,t)=>(e[l[t]]=isNaN(Number(t))?t:parseInt(t,10),e),{}),u=e.ctx.linkLookup[c]??[],d=[s];u.forEach(e=>d.push(h[e])),e.hover((t,n)=>t.source&&t.target?t.source.id===s||t.target.id===s:d.includes(e.schema.nodeId(t,n)))}}(t),t.links=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(o.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeAlign=function(e){return arguments.length?(this.schema.nodeAlign="function"==typeof e?e:cF[e],this):this.schema.nodeAlign},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:Be(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:Be(e),this):this.schema.value},t.hover=ow},ctx:{sankey:function(){const e={x0:0,y0:0,x1:1,y1:1,dx:24,dy:8,py:8,align:VD,sort:void 0,linkSort:void 0,iterations:6};let t=[],n=[];const i=()=>{const i=t,o=n;!function(e,t,n){for(const[e,n]of t.entries())n.index=e,n.sourceLinks=[],n.targetLinks=[];const i=new Map(t.map((e,t)=>[t,e])),o=e=>{const t=i.get(e);if(!t)throw new Error("missing: "+e);return t};for(const[e,t]of n.entries()){t.index=e;const n=t;"object"!=typeof n.source&&(t.source=o(n.source)),"object"!=typeof n.target&&(t.target=o(n.target)),t.source.sourceLinks.push(t),t.target.targetLinks.push(t)}if(null!=e.linkSort)for(const{sourceLinks:n,targetLinks:i}of t)n.sort(e.linkSort),i.sort(e.linkSort)}(e,i,o);for(const e of i)e.value=void 0===e.fixedValue?Math.max(h.sum(e.sourceLinks,UD),h.sum(e.targetLinks,UD)):e.fixedValue;return XD(i,"depth"),XD(i,"height"),function(e,t){const n=function(e,t){const n=h.max(t,e=>e.depth)+1,i=(e.x1-e.x0-e.dx)/(n-1),o=new Array(n);for(const a of t){const t=Math.max(0,Math.min(n-1,Math.floor(e.align(a,n))));a.layer=t,a.x0=e.x0+t*i,a.x1=a.x0+e.dx,o[t]?o[t].push(a):o[t]=[a]}if(e.sort)for(const t of o)t.sort(e.sort);return o}(e,t);e.py=Math.min(e.dy,(e.y1-e.y0)/(h.max(n,e=>e.length)-1)),function(e,t){const n=h.min(t,t=>(e.y1-e.y0-(t.length-1)*e.py)/h.sum(t,UD));for(const i of t){let t=e.y0;for(const o of i){o.y0=t,o.y1=t+o.value*n,t=o.y1+e.py;for(const e of o.sourceLinks)e.width=e.value*n}t=(e.y1-t+e.py)/(i.length+1);for(let e=0;e<i.length;++e){const n=i[e];n.y0+=t*(e+1),n.y1+=t*(e+1)}iF(e,i)}}(e,n);for(let t=0;t<e.iterations;++t){const i=Math.pow(.99,t),o=Math.max(1-i,(t+1)/e.iterations);ZD(e,n,i,o),QD(e,n,i,o)}}(e,i),function(e){for(const t of e){let e=t.y0,n=e;for(const n of t.sourceLinks)n.y0=e+n.width/2,e+=n.width;for(const e of t.targetLinks)e.y1=n+e.width/2,n+=e.width}}(i),{nodes:i,links:o}};return i.nodeAlign=t=>(e.align=t,i),i.nodeSort=t=>(e.sort=t,i),i.nodeWidth=t=>(e.dx=+t,i),i.nodePadding=t=>(e.dy=e.py=+t,i),i.nodes=e=>(t=e,i),i.links=e=>(n=e,i),i.linkSort=t=>(e.linkSort=t,i),i.size=t=>(e.x1=+t[0],e.y1=+t[1],i),i.iterations=t=>(e.iterations=+t,i),i}(),path:y.linkHorizontal().source(e=>[e.source.x1,e.y0]).target(e=>[e.target.x0,e.y1])},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"iterations",default:6},{key:"links",default:T("links")},{key:"linkSort"},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:T("nodes")},{key:"nodeAlign",default:VD},{key:"nodeId",default:T("id")},{key:"nodePadding",default:8},{key:"nodeSort"},{key:"nodeWidth",default:30},{key:"value",default:N(1)},{key:"shape",default:N("Rect"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>{const e=e=>Math.max(1,Math.abs(e.source.y1-e.source.y0)*(e.value/e.source.value)-2);return{Path:{fill:"none",hoverStyle:{"stroke-width":e},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:e},Rect:{}}}},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})}]};var hF=xf(lF);var uF=xf({name:"StackedArea",paintDriven:!0,ctx:{},fields:[{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:vb}]},kb);const dF=2*Math.PI;function fF(e,t,n="equal",i){const o=Math.max(0,e);if(t<1)return[[0,o]];const a=t+1,r=void 0!==i&&Number.isFinite(i)?Math.min(Math.max(0,i),o):"area"===n?o*Math.sqrt(1/a):o/a,s=e=>"area"===n?Math.sqrt(r*r+(o*o-r*r)*e/t):r+(o-r)*e/t,c=[[0,r]];for(let e=1;e<=t;e++)c.push([s(e-1),s(e)]);return c}function mF(e,t,n,i){const o=n.endAngle-n.startAngle||1,a=e=>Math.min(dF,Math.max(0,(e-n.startAngle)/o*dF)),r=t-n.depth,s=i[i.length-1]?.[1]??0,[c,l]=r<0?[0,0]:i[r]??[s,s];return{innerRadius:c,outerRadius:l,startAngle:a(e.startAngle),endAngle:a(e.endAngle)}}function pF(e,t,n){if(t)return t;if(!n)return 0;const i=Math.sqrt(e.innerRadius**2+e.outerRadius**2);return i?n/i:0}function gF(e){return e<=180?e-90:e-270}function yF(e){return e>90&&e<270?e-180:e>=270?e-360:e}const xF=2*Math.PI;function bF(e){const{radii:t,...n}=e;return iC({...n,breadth:xF},e=>{const[n,i]=t[e.depth]??[0,0];return{startAngle:e.x0,endAngle:e.x1,innerRadius:n,outerRadius:i}})}const _F=aC;const kF=({viz:e})=>{const{width:t,height:n}=ie(e);e.ctx.sunburstWidth=t,e.ctx.sunburstHeight=n,e.ctx.sunburstNodes=new Map,e.ctx.sunburstGhosts=[];const i=function(e){return rC(e,"sunburstPass",()=>{const t={laid:e.ctx.sunburstLaid,radii:e.ctx.sunburstRadii,origin:e.ctx.sunburstZoomOrigin};return e.ctx.sunburstZoomOrigin=void 0,t})}(e),o=e._filteredData??[];if(!o.length)return e.ctx.sunburstLaid=[],e.ctx.sunburstRadii=void 0,e.ctx.sunburstEnterArcs=new Map,e.ctx.sunburstOuterRadius=0,{shapeData:[]};const a=e.schema.shapeConfig??{},r="number"==typeof a.strokeWidth?a.strokeWidth:1,s=Math.max(0,Math.min(t,n)/2-3*r/2),c=_F(e),l=e.schema.groupBy.slice(c.level+1,e._drawDepth+1),h=fF(s,l.length,e.schema.ringSize,function(e,t){const n=e.schema.innerRadius,i="function"==typeof n?n(t):n;return"number"==typeof i&&Number.isFinite(i)?i:void 0}(e,s)),u=bF({data:o,keys:l,firstLevel:c.level+1,focusPath:c.path,sum:e.schema.sum,sort:e.schema.sort,aggs:e.schema.aggs,radii:h}),{laid:d,radii:f,origin:m}=i;e.ctx.sunburstGhosts=m&&d?function(e,t,n,i){return sC(e,t).map(e=>({id:e.id,datum:e.datum,i:e.i,level:e.level,arc:mF(e,e.depth,n,i)}))}(d,u,m,h):[],e.ctx.sunburstEnterArcs=d&&f?function(e,t,n){return lC(e,t,(e,t)=>mF(e,e.depth,{startAngle:t.startAngle,endAngle:t.endAngle,depth:t.depth},n))}(d,u,f):new Map,e.ctx.sunburstLaid=u,e.ctx.sunburstRadii=h;const p=e.ctx.sunburstNodes;for(const e of u)wr(e.datum,e.share),p.set(e.datum,e);return e.ctx.sunburstOuterRadius=s,{shapeData:u}},vF=2*Math.PI,wF=1e-6;function SF(e,t){const n=t.rotate*Math.PI/180,i=Math.cos(n),o=Math.sin(n),a=t.width/2,r=t.height/2,s=(e,n)=>[t.x+e*i-n*o,t.y+e*o+n*i],c=[s(-a,-r),s(a,-r),s(a,r),s(-a,r)];if(c.some(([t,n])=>Math.hypot(t,n)>e.outerRadius+wF))return!1;if(e.innerRadius>0){const n=-t.x*i-t.y*o,s=t.x*o-t.y*i;if(Math.hypot(Math.max(Math.abs(n)-a,0),Math.max(Math.abs(s)-r,0))<e.innerRadius-wF)return!1}const l=e.endAngle-e.startAngle;if(l>=vF-wF)return!0;const h=[...c];if(l>Math.PI)for(let e=1;e<8;e++){const t=e/8;h.push(s(2*a*t-a,-r),s(2*a*t-a,r),s(-a,2*r*t-r),s(a,2*r*t-r))}return h.every(t=>function(e,[t,n]){const i=((Math.atan2(t,-n)-e.startAngle)%vF+vF)%vF;return i<=e.endAngle-e.startAngle+wF||i>=vF-wF}(e,t))}function CF(e,t,n,i,o){const a=a=>SF(e,{x:t,y:n,width:a,height:o,rotate:i});if(!a(wF))return 0;let r=0,s=2*e.outerRadius;for(let e=0;e<16;e++){const e=(r+s)/2;a(e)?r=e:s=e}return r}function MF(e,t,n,i,o,a){const{padding:r,lineHeight:s,maxLines:c}=a;for(let a=1;a<=c;a++){const c=a*s*o+2*r,l=CF(e,t[0],t[1],n,c);if(l<=2*r)return null;if(jC(i,o,l-2*r)<=a)return{width:l,height:c}}return null}function $F(e,t,n,i,o={}){const a=EC(o),r=HC(o=>Boolean(MF(e,t,n,i,o,a)),a.fontMin,a.fontMax);if(null===r)return null;return{fontSize:r,...MF(e,t,n,i,r,a)}}function AF(e,t,n={}){const i=e.endAngle-e.startAngle;if(!(t.words.length&&i>0&&e.outerRadius>e.innerRadius))return null;const o=EC(n);if(e.innerRadius<=0&&i>=vF-wF){const n=$F(e,[0,0],0,t,o);return n?{orientation:"center",x:0,y:0,rotate:0,...n}:null}const a=(e.startAngle+e.endAngle)/2,r=(e.innerRadius+e.outerRadius)/2,s=[r*Math.sin(a),-r*Math.cos(a)],{tangential:c,radial:l}={tangential:yF(h=(180*a/Math.PI%360+360)%360),radial:gF(h)};var h;const u=$F(e,s,c,t,o),d=$F(e,s,l,t,o),f=(e,t,n)=>({orientation:e,x:s[0],y:s[1],rotate:t,...n});return u&&(!d||u.fontSize>=d.fontSize)?f("tangential",c,u):d?f("radial",l,d):null}function zF(e,t,n){const i=0===e.depth;return{innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,padAngle:i?0:pF(e,t,n)}}function DF(e,t){return e._drawLabel(t.datum,t.i??0,t.level)}const FF=TC;const BF={out:.06,in:.06},LF={prefix:"sunburst",origin:e=>({startAngle:e.startAngle,endAngle:e.endAngle,depth:e.depth})},PF={name:"Sunburst",layoutStage:kF,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const o=au(e,"Path"),a=Number(e.schema.padAngle)||0,s=Number(e.schema.padPixel)||0,c=e.schema.sum,l=e.schema.locale,h=function(e,t){return CC(e.schema,t,{color:e.ctx.sunburstDefaultColor,fill:e.ctx.sunburstDefaultFill},"Path")}(e,o),u=e.ctx.sunburstEnterArcs??new Map,f=n.map(t=>{const n=t.i??0,r=zF(t,a,s),f=h(t);return{type:"path",key:`sunburst-${t.id}`,d:i.arcPath(r),arc:r,enterArc:u.has(t.id)?{...u.get(t.id),padAngle:0}:void 0,datum:t.datum,paint:{fill:nu(o,t.datum,n,f),stroke:tu(o.stroke,t.datum,n),strokeWidth:tu(o.strokeWidth,t.datum,n),opacity:tu(o.opacity,t.datum,n)??1},aria:{label:`${e._drawLabel(t.datum,n,t.level)}, ${c(t.datum)}, ${d.formatAbbreviate(100*t.share,l)}%`}}}),m=qy(o,f,e=>[n[e].datum,n[e].i??0]),p=function(e,t){return(e.ctx.sunburstGhosts??[]).map(e=>{const n={...e.arc,padAngle:0};return{type:"path",key:`sunburst-${e.id}`,d:i.arcPath(n),arc:n,paint:{fill:t(e),opacity:1}}})}(e,h),g=ru(e,"Path")??{},y="number"==typeof g.fontMin?g.fontMin:8,x="number"==typeof g.fontMax?g.fontMax:24,b=function(e,t,n,i){const{fontMin:o,fontMax:a,padAngle:r,padPixel:s}=i,c=new Map;for(const i of t){const t=WC(DF(e,i),i.datum,n),l=AF(zF(i,r,s),t,{fontMin:o,fontMax:a});l&&c.set(i,l)}return c}(e,n,g,{fontMin:y,fontMax:x,padAngle:a,padPixel:s}),_=iw({data:n.filter(e=>b.has(e)),label:t=>DF(e,t),x:e=>b.get(e).x,y:e=>b.get(e).y,rotate:e=>b.get(e).rotate,aes:()=>({}),id:e=>`sunburst-${e.id}`,datum:e=>e.datum,labelBounds:e=>{const{width:t,height:n}=b.get(e);return{x:-t/2,y:-n/2,width:t,height:n}},labelConfig:{fontMax:x,fontMin:y,split:NC,fontResize:!0,padding:0,textAnchor:"middle",verticalAlign:"middle",fontColor:t=>{let n=t;for(;n&&n.__d3plus__&&n.data;)n=n.data;const i=e.ctx.sunburstNodes.get(n),o=i?h(i):void 0;return r.colorContrast(o??"rgb(255, 255, 255)",e.schema.colorDefaults)},...g}});for(const e of _)e.fadeSwap=BF;return[...p,...f,...m,..._]},insetRegion:Uu,thresholdFunction:gC,chartTransform:e=>oe(e,e.ctx.sunburstWidth,e.ctx.sunburstHeight),chartBodyRect:e=>{const t=e.ctx.sunburstOuterRadius??0;return{x:-t,y:-t,width:2*t,height:2*t}},setup:e=>vC(e,LF),facet:{aspect:1},ctx:{},fields:[{key:"innerRadius"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"ringSize",default:"equal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...wC})},{key:"sort",default:yC,decorate:xC},{key:"sum",default:T("value"),coerce:bC,onSet:_C},{key:"shapeConfig",merge:!0,factory:e=>({Path:{labelConfig:{fontResize:!0}},stroke:()=>n.backgroundColor(e._select?.node()),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:kC},{key:"legend",coerce:"const",factory:cw}]};var RF=xf(PF);function EF(e,t){return o.merge(t.values.map(t=>t.key&&t.values?EF(e,t):t),e.schema.aggs)}function NF(e,t,n){const i=e.ctx.tree.separation(e.schema.separation).size([t,n])(A.hierarchy({key:"root",values:o.nest(e._filteredData,e.schema.groupBy.slice(0,e._drawDepth+1))},e=>e.key&&e.values?e.values:null).sort(e.schema.sort)).descendants().filter(t=>(t.depth??0)<=e.schema.groupBy.length&&!!t.parent);return i.forEach((t,n)=>{const i=t.data;i.key&&i.values&&(t.data=EF(e,i)),t.__d3plus__=!0,t.i=n,t.data.depth=t.depth}),i}const TF=({viz:e})=>{const t=e.schema.orient,i="vertical"===t,a="horizontal"===t,r=i?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,c=a?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,l=i?"left":"top",u=NF(e,c,r),{labelHeight:d,labelWidths:f}=function(e,t,n,i,a,r,c){let l=e.schema.shapeConfig.r;if("function"!=typeof l){const e=l;l=()=>e}const u=h.max(t,e=>1===e.depth?l(e.data,e.i):0),d=h.max(t,e=>e.children?0:l(e.data,e.i)),f=h.extent(t,e=>e.y),m=h.min([n?50:100,(f[1]-u-d)/(e.schema.groupBy.length+1)]);e.ctx.labelHeight=m;const p=o.nest(t,e=>e.depth).map(t=>{const n=t.values;return n.reduce((t,i,o)=>{const r=o<n.length-1?n[o+1].x:a+e._margin[c],s=o?n[o-1].x:e._margin[c];return h.min([t,r-i.x,i.x-s])},a)});e.ctx.labelWidths=p;const g=s.scaleLinear().domain(f).range([u+m,r-d-m]);return t.forEach(e=>{const t=g(e.y);i?(e.y=e.x,e.x=t):e.y=t}),{labelHeight:m,labelWidths:p}}(e,u,i,a,c,r,l);return function(e,t,i,a,r,s){const c=e.schema.shapeConfig,l=t.filter(e=>(e.depth??0)>1).map(e=>n.assign({},e)),h=function(e,t,n,i,o){const a=e.schema.label;return{id:(t,n)=>e._ids(t.data,n)[(t.depth??1)-1],label:(t,n)=>{if(a)return a(t.data,n);const i=e._ids(t.data,n).slice(0,t.depth??1);return i[i.length-1]},labelConfig:{fontResize:!1,textAnchor:t=>{const n=t.data??t;return i?"middle":n.children&&n.depth!==e._drawDepth+1?"end":"start"},verticalAlign:e=>{const t=e.data??e;return i?1===t.depth?"bottom":"top":"middle"}},hitArea:(a,r,s)=>{const c=t,l=s.r??(i?s.height/2:s.width/2),h=n[(a.depth??1)-1];return{width:i?h:2*l+h,height:o?c:2*l+c,x:i?-h/2:a.children&&a.depth!==e.schema.groupBy.length?-(l+h):-l,y:o?-c/2:a.children&&a.depth!==e.schema.groupBy.length?-(l+t):-l}},labelBounds:(o,a,r)=>{const s=t,c=i?"height":"width",l=r.r??(i?r.height/2:r.width/2),h=n[(o.depth??1)-1],u=i?"width":"height",d=i?"x":"y",f=i?"y":"x";return{[u]:h,[c]:s,[d]:-h/2,[f]:o.children&&o.depth!==e.schema.groupBy.length?-(l+s):l}}}}(e,i,a,r,s),u=e.schema.shape,d=o.nest(t,e=>u(e.data)),f=d.map(e=>e.key),m=(e.ctx.previousShapes??[]).filter(e=>!f.includes(e)),p=d.concat(m.map(e=>({key:e,values:[]})));e.ctx.linksData=l,e.ctx.linkD=e=>{let t=c.r;"function"==typeof t&&(t=t(e.data,e.i));const n=(e.parent.x??0)-(e.x??0)+(r?0:t),i=(e.parent.y??0)-(e.y??0)+(r?t:0),o=r?0:-t,a=r?-t:0;return r?`M${o},${a}C${o},${(a+i)/2} ${n},${(a+i)/2} ${n},${i}`:`M${o},${a}C${(o+n)/2},${a} ${(o+n)/2},${i} ${n},${i}`},e.ctx.shapeGroups=p,e.ctx.shapeConfig=h,e.ctx.previousShapes=f}(e,u,d,f,i,a),{shapeData:u}};function OF(e,t,n){const i=t.data??t,o=t.i??0,a=t.x??0,r=t.y??0;switch(e){case"Circle":{const e=Number(tu(n.r,i,o)??0);return{geom:{type:"circle",cx:a,cy:r,r:e},aes:{r:e}}}case"Rect":{const e=Number(tu(n.width,i,o)??0),t=Number(tu(n.height,i,o)??0);return{geom:{type:"rect",x:a-e/2,y:r-t/2,width:e,height:t},aes:{width:e,height:t}}}case"Path":return{geom:{type:"path",d:String(tu(n.d,i,o)??"")},aes:{}};default:return null}}const WF={name:"Tree",layoutStage:TF,emit:({viz:e})=>{const t=e.ctx.linksData,n=e.ctx.linkD,i=e.ctx.shapeGroups,o=e.ctx.shapeConfig;if(!i||!o)return[];const a=[];if(t&&t.length&&n){const i=au(e,"Path");for(let o=0;o<t.length;o++){const r=t[o],s=r.data??r,c=iu(i,s,o),l=e._ids(s,o)[(r.depth??1)-1],h=r.x??0,u=r.y??0;a.push({type:"path",key:`tree-link-${l}`,d:n(r),datum:s,paint:c,transform:{x:h,y:u},aria:{label:`${e._drawLabel(s,r.i??o)}.`}})}}for(const{key:t,values:n}of i){if(!n.length)continue;const i={...au(e,t),...o},r=n,s=[];for(let n=0;n<r.length;n++){const c=r[n],l=c.data??c,h=OF(t,c,i);if(!h)continue;const u=o.id(c,n),d=iu(i,l,n),f={...h.geom,key:`tree-${t}-${u}`,datum:l,paint:d,aria:{label:`${e._drawLabel(l,n)}.`}};a.push(f);const m=Vy(i,f,l,n);m&&s.push(m)}a.push(...s);const c=iw({data:r,label:(e,t)=>o.label(e,t),x:e=>e.x??0,y:e=>e.y??0,aes:e=>OF(t,e,i)?.aes??{},rotate:N(0),id:(e,t)=>o.id(e,t),labelBounds:(e,t,n)=>o.labelBounds(e,t,n),labelConfig:{...ru(e,t),...o.labelConfig}});a.push(...c)}return a},insetRegion:Uu,ctx:{tree:A.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(e,t)=>e.parent===t.parent?1:2},{key:"shape",default:N("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>(e.ctx.linksData&&e._chartScene,e._drawLabel(t,n)),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return r.colorContrast(t,e.schema.colorDefaults)}},Path:{fill:"none",stroke:()=>e.schema.colorDefaults.missing,strokeWidth:2},r:N(7),width:N(12),height:N(12)})},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,n)=>e._drawLabel(t,n,(t.depth??1)-1)})},{key:"legendTooltip",merge:!0,factory:e=>({title:ur.bind(e)})}]};var jF=xf(WF);const HF={fontSize:11,fontWeight:600,padding:3};function IF(e){if(!1===e.schema.groupLabels)return null;const t=e.schema.groupLabelConfig??{};return{...HF,fontFamily:e.schema.fontFamily,...t}}function GF(e){return Math.ceil(1.2*e.fontSize+2*e.padding)}function VF(e,t){const{drawDepth:n,padding:i,style:o}=e;return e=>{const a=e;if(!o||a.depth<1||a.depth>n||null==a.data.key||!function(e,t,n){return t>=2*GF(n)&&e>=3*n.fontSize+2*n.padding}(a.x1-a.x0,a.y1-a.y0,o))return i;const r=GF(o);return t.set(a,r),r+i}}function qF(e){return e.ancestors().reverse().slice(1).map(e=>`${e.data.key}`).join("/")}const YF=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const{width:n,height:i}=ie(e),a=o.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),r=A.hierarchy({values:a},e=>e.values).sum(e.schema.sum).sort(e.schema.sort),s=e.schema.layoutPadding,c=new Map,l=IF(e),h=e.ctx.treemap.padding(s).paddingTop(VF({drawDepth:e._drawDepth,padding:s,style:l},c)).size([n,i]).tile(e.schema.tile)(r),u=[];h.children&&function n(i){for(const a of i){if(a.depth<=e._drawDepth){n(a.children??[]);continue}const i=a.data,r=i.values??[],s=1===r.length?t.indexOf(r[0]):void 0,c=a;c.__d3plus__=!0,c.id=i.key,c.i=void 0!==s&&s>-1?s:void 0,c.data=o.merge(r,e.schema.aggs),c.x=a.x0+(a.x1-a.x0)/2,c.y=a.y0+(a.y1-a.y0)/2,u.push(c)}}(h.children);const d=e.schema.sort;u.slice().sort(d).forEach((e,t)=>{e.data.rank=t});const f=h.value;!function(e,t){for(const[n,i]of e){const e=n.leaves().map(e=>e.data),a=o.merge(e,t.aggs);delete a._isAggregation,delete a._threshold,delete a[zr],a[Ge]=n.depth-1;const r=t.label?t.label(a,0):void 0;null!=r&&!1!==r&&""!==r&&(a[Ve]=`${r}`),wr(a,(n.value??0)/t.total),n.groupHeader={__d3plus__:!0,data:a,depth:n.depth-1,id:qF(n),x0:n.x0,y0:n.y0,x1:n.x1,y1:Math.min(n.y1,n.y0+i)}}}(c,{aggs:e.schema.aggs,label:l?.label,total:f});const m=e.schema.sum;return u.forEach(e=>{const t=m(e.data)/f;e.share=t,wr(e.data,t)}),{shapeData:u}};function KF(e,t,n){if(!t.length)return[];const i=new Map,o=t=>{let o=i.get(t);return void 0===o&&(o=tu(n.fill,t.data,0)??function(e,t,n){const i=()=>x.interpolateRgb(Ia(e),Ga(e))(.7);if(e.schema.colorScale)return i();const o=au(e,"Rect"),a=l.color(`${tu(o.fill,t,n)}`);return a?a.darker(.8).formatHex():i()}(e,t.data,0),i.set(t,o)),o},a=e.schema.sum,s=t=>e._drawLabel(t.data,0,t.depth),c=t.map(t=>({type:"rect",key:`treemap-group-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:o(t)},aria:{label:`${s(t)}, ${a(t.data)}, ${d.formatAbbreviate(100*Cr(t.data),e.schema.locale)}%`}})),h=new Map(t.map(e=>[e.data,e])),u=iw({data:t,label:e=>s(e),x:e=>e.x0,y:e=>e.y0,aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:N(0),id:e=>`group-${e.id}`,datum:e=>e.data,labelBounds:(e,t,n)=>{const{width:i,height:o}=n;return{x:0,y:0,width:i,height:o}},labelConfig:{fontColor:i=>{const a=h.get(i.data)??t[0];return tu(n.fontColor,a.data,0)??r.colorContrast(o(a),e.schema.colorDefaults)},...n.fontFamily?{fontFamily:n.fontFamily}:{},fontResize:!1,fontSize:n.fontSize,fontWeight:n.fontWeight,maxLines:1,padding:n.padding,textAnchor:"start",verticalAlign:"middle"}});for(const e of u)e.shapeType="Label";return[...c,...u]}const UF={treemapBinary:A.treemapBinary,treemapDice:A.treemapDice,treemapResquarify:A.treemapResquarify,treemapSlice:A.treemapSlice,treemapSliceDice:A.treemapSliceDice,treemapSquarify:A.treemapSquarify},XF=e=>!!e.children&&1===e.children.length&&!0===e.children[0].data._isAggregation,QF={name:"Treemap",layoutStage:YF,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=e.schema.locale,o=e._drawLabel,a=au(e,"Rect"),s=n.map(t=>{const n=tu(a.fill,t.data,t.i),r=tu(a.stroke,t.data,t.i),s=tu(a.opacity,t.data,t.i),c=tu(a.strokeWidth,t.data,t.i);return{type:"rect",key:`treemap-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:nu(a,t.data,t.i,n),stroke:"string"==typeof r||null==r?r:String(r),opacity:s,strokeWidth:c},aria:{label:`${o(t.data,t.i??0)}, ${e.schema.sum(t.data)}, ${d.formatAbbreviate(100*t.share,i)}%`}}}),c=iw({data:n,label:e=>{const t=e;return[o(t.data,t.i??0),`${d.formatAbbreviate(100*t.share,i)}%`]},x:e=>{const t=e;return t.x0+(t.x1-t.x0)/2},y:e=>{const t=e;return t.y0+(t.y1-t.y0)/2},aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:N(0),id:e=>e.id,labelBounds:(e,t,n)=>{const{width:i,height:o}=n;let a=Math.min(32,.5*(o-10));return a<8&&(a=0),[{width:i,height:o-a,x:-i/2,y:-o/2},{width:i,height:a+10,x:-i/2,y:o/2-a-10}]},labelConfig:{fontMax:32,textAnchor:e=>e&&0===e.l?"start":"middle",verticalAlign:e=>e&&0===e.l?"top":"bottom",fontColor:t=>{const n=t&&t.data?t.data:t,i=tu(a.fill,n,n.i);return"string"==typeof i?r.colorContrast(i,e.schema.colorDefaults):void 0},...ru(e,"Rect")}});for(const e of c)e.shapeType="Label";const l=qy(a,s,e=>[n[e].data,n[e].i]),h=IF(e),u=h?KF(e,function(e){const t=new Set;for(const n of e){let e=n.parent;for(;e;e=e.parent)e.groupHeader&&t.add(e.groupHeader)}return[...t].sort((e,t)=>e.depth-t.depth)}(n),h):[];return[...s,...l,...c,...u]},thresholdFunction:(e,t)=>QS(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey,label:(t,n)=>e._drawLabel(t,n)}),ctx:{treemap:A.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"groupLabels",default:!0},{key:"groupLabelConfig",default:{},merge:!0},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0),decorate:(e,t)=>{const n=t;return(e,t)=>{const i=XF(e),o=XF(t);return i&&!o?1:!i&&o?-1:n(e,t)}}},{key:"sum",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"tile",default:A.treemapSquarify,coerce:e=>{if("string"!=typeof e)return e;const t=`treemap${e.charAt(0).toUpperCase()}${e.slice(1)}`;return UF[t]??A.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,n)=>{const i="number"==typeof t.rank?`${t.rank+1}. `:"",o=e.schema.sum;return`${i}${e._drawLabel(t,n)}, ${o(t,n)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[sw(e,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:e=>{const t=e.schema.sum;return(e,n)=>t(n)-t(e)}},{key:"legend",coerce:"const",factory:cw}]};var ZF=xf(QF);function JF(e){const t=Array.isArray(e)?e:[e];return new Set(t.filter(e=>"box"===e||"quartiles"===e||"points"===e))}function eB(e){const t=e=>{e.interactive=!1;const n=e.children;n&&n.forEach(t)};return e.forEach(t),e}function tB(e,t,n){const i=e.value(t);return e.vertical?{x:n,y:i}:{x:i,y:n}}function nB(e,t,i,o){const{viz:a}=e,r=t.map(e=>e.slot.half*("both"===e.slot.side?.16:.08)),s=Math.max(3,Math.min(10,Math.min(...r))),c=i.vertical,l=a._select&&"function"==typeof a._select.node?a._select.node():null,h=l?n.backgroundColor(l):"#fff",u=t.map(({row:e,meta:t,slot:n})=>{const r=`density-box-${e.id}`,l="both"===n.side?n.center:n.center+("start"===n.side?-1:1)*Math.min(4,n.half/4),u=t.summary.values.map((e,t)=>({...tB(i,e,l),id:r,i:t})),d=eu("Box").renderMode("compute").config({id:e=>e.id,orient:c?"vertical":"horizontal",rectWidth:s,rectConfig:{fill:o,stroke:o,strokeWidth:0},medianConfig:{fill:h},outlierConfig:{Circle:{fill:o,r:1.5,strokeWidth:0}},whiskerConfig:{endpoint:"Rect",endpointConfig:{Rect:{fill:o,height:c?1:s/2,width:c?s/2:1}},lineConfig:{stroke:o,strokeWidth:1}}}).config(a.schema.innerConfig?.box??{}).data(u);return d.render(),{type:"group",key:r,children:su(d)}});return wD(u,c?"x":"y"),eB(u)}function iB(e,t,n,i){const{viz:o}=e,a=o.schema.innerConfig?.quartiles??{},r=(e,o)=>{const r=[],s=new Map;t.forEach(({row:t,meta:i,slot:o})=>{e.forEach(e=>{const a=i.summary[e],c=lD(i.summary.curve,a)*i.scale*o.half,[l,h]=$D(o,c),u=`density-${e}-${t.id}`;s.set(u,o.center),r.push({id:u,...tB(n,a,l)},{id:u,...tB(n,a,h)})})});const c=eu("Line").renderMode("compute").config({stroke:i,strokeWidth:1,strokeDasharray:o,curve:"linear"}).config(a).data(r);c.render();const l=su(c);return vD(l,n.vertical?"x":"y",s),eB(l)};return[...r(["q1","q3"],"4 3"),...r(["median"],"0")]}function oB(e,t,n){const{viz:i,events:o}=e,a=i.schema.innerConfig?.points??{},r="number"==typeof a.r?a.r:2.5,s=Im(t.map(({meta:e})=>e.summary.observed.map(e=>({value:n.value(e),r:r}))),{padding:.5,extent:Math.max(1,Math.min(...t.map(e=>e.slot.half*("both"===e.slot.side?.8:.4)))),overflow:"shrink"}),c=[];t.forEach(({row:e,meta:t,slot:i},o)=>{const a="both"===i.side?0:("start"===i.side?-1:1)*i.half*.45;t.summary.observed.forEach((r,l)=>{const h=t.summary.rows[l];c.push({__d3plus__:!0,data:h,i:l,id:`density-point-${e.id}-${l}`,...tB(n,r,i.center+a+s.offsets[o][l])})})});const l=eu("Circle").renderMode("compute").config(au(i,"Circle")).config({r:r*s.scale,label:!1,x:e=>e.x,y:e=>e.y}).config(a).data(c);return i._wirePlotShapeEvents(l,"Circle",o),l.render(),su(l)}function aB(e,t,n){const i=JF(e.viz.schema.inner);if(!t.length||!i.size)return[];const o=Ga(e.viz),a=(e,t)=>t.length?[{type:"group",key:`violin-${e}`,children:t}]:[];return[...i.has("points")?a("points",oB(e,t,n)):[],...i.has("quartiles")?a("quartiles",iB(e,t,n,o)):[],...i.has("box")?a("box",nB(e,t,n,o)):[]]}const rB=(e,t)=>{const{viz:n,values:i,x:o,y:a,xRange:r,yRange:s,xDomain:c,yDomain:l}=e,h="y"!==n.schema.discrete,u=h?o:a,d=h?a:o,f=h?"x":"y",m=h?r:s,p=h?c:l,g=p.map(e=>u(e,f)).sort((e,t)=>e-t);let y=SD(m[m.length-1]-m[0],p.length,.5);for(let e=1;e<g.length;e++)y=Math.min(y,g[e]-g[e-1]);const x=i.filter(e=>dD(e)),b=CD(x.map(e=>`${e[f]}`),{position:e=>u(e,f),step:y,gap:n._groupPadding??0,split:Boolean(n.schema.split)}),_=x.map((e,t)=>({row:e,meta:dD(e),slot:b[t]})),k=[];_.forEach(({row:e,meta:t,slot:n})=>{MD(t.summary.curve,t.scale,n.half).forEach(t=>{const[i,o]=$D(n,t.extent);k.push({...e,id:fD(e),__pos:d(t.value),__low:i,__high:o})})});const v=e=>e.__pos,w=e=>e.__low,S=e=>e.__high,C=h?{x:w,x0:w,x1:S,y:v,y0:v,y1:null}:{x:v,x0:v,x1:null,y:S,y0:S,y1:w},M=cx({...e,values:k,shapeConfig:{...e.shapeConfig,...C}},t);return vD(M,f,new Map(_.map(({row:e,slot:t})=>[fD(e),t.center]))),M.concat(aB(e,_,{vertical:h,value:e=>d(e)}))},sB={name:"Violin",paintDriven:!0,defaults:{groupPadding:16},setup:e=>yD(e,{valueAxis:e=>"y"===e.schema.discrete?"x":"y",categoryPadding:()=>[.5,.5],emit:rB}),ctx:{},fields:[{key:"discrete",default:"x"},{key:"inner",default:"box"},{key:"split",default:!1},...bD(),..._D(2),{key:"innerConfig",merge:!0,default:{box:{},quartiles:{},points:{}}},{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var cB=xf(sB,_b);const lB=e=>Number.isFinite(e)&&e>0?e:0;function hB(e,t){const n=e.map(lB),i=n.reduce((e,t)=>e+t,0),o=Math.max(0,Math.round(lB(t)));if(!i||!o)return n.map(()=>0);const a=n.map(e=>e/i*o),r=a.map(Math.floor);let s=o-r.reduce((e,t)=>e+t,0);const c=a.map((e,t)=>({i:t,r:e-r[t],v:n[t]})).filter(e=>e.v>0).sort((e,t)=>t.r-e.r||t.v-e.v||e.i-t.i);for(let e=0;s>0&&c.length;e=(e+1)%c.length)r[c[e].i]++,s--;return r}function uB(e,{cells:t,unit:n}){if(void 0!==n&&lB(n)){const t=e.map(lB).reduce((e,t)=>e+t,0);return hB(e,Math.round(t/n))}return hB(e,t)}function dB(e,{rows:t,columns:n,fillDirection:i,unit:o}){const a=Math.max(1,Math.round(lB(t))||1),r=Math.max(1,Math.round(lB(n))||1);if(void 0===o||!lB(o))return{rows:a,columns:r};const s=Math.max(1,e);return"column"===i?{rows:a,columns:Math.ceil(s/a)}:{rows:Math.ceil(s/r),columns:r}}function fB(e,{rows:t,columns:n,fillDirection:i,fillStart:o}){let a="column"===i?e%t:Math.floor(e/n),r="column"===i?Math.floor(e/t):e%n;return o.startsWith("bottom")&&(a=t-1-a),o.endsWith("right")&&(r=n-1-r),{row:a,column:r}}function mB(e,t,{rows:n,columns:i,padding:o}){const a=lB(e),r=lB(t),s=Math.max(1,n),c=Math.max(1,i);let l=lB(o),h=Math.min((a+l)/c,(r+l)/s);l>.4*h&&(l=.4*Math.min(a/c,r/s),h=Math.min((a+l)/c,(r+l)/s));const u=Math.max(0,h-l);return{size:u,padding:l,x:(a-(c*u+(c-1)*l))/2,y:(r-(s*u+(s-1)*l))/2}}const pB=["top-left","top-right","bottom-left","bottom-right"];function gB(e){const t=e.schema.fillStart,n=Number(e.schema.unit);return{fillDirection:"column"===e.schema.fillDirection?"column":"row",fillStart:pB.includes(t)?t:"top-left",unit:n>0&&Number.isFinite(n)?n:void 0}}const yB=({viz:e})=>{const t=e._filteredData??[];if(!t.length)return{shapeData:[]};const n=e.schema.sum,i=e.schema.sort,o=t.map((e,t)=>t);"function"==typeof i&&o.sort((e,n)=>i(t[e],t[n])||e-n);const a=o.map(e=>Number(n(t[e],e))),r=a.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0),s=a.map(e=>r&&Number.isFinite(e)&&e>0?e/r:0);o.forEach((e,n)=>wr(t[e],s[n]));const{fillDirection:c,fillStart:l,unit:h}=gB(e),u=dB(0,{rows:Number(e.schema.rows),columns:Number(e.schema.columns),fillDirection:c}),d=uB(a,{cells:u.rows*u.columns,unit:h}),f=dB(d.reduce((e,t)=>e+t,0),{...u,fillDirection:c,unit:h}),{width:m,height:p}=ie(e),g=mB(m,p,{...f,padding:Number(e.schema.cellPadding)||0}),y=g.size+g.padding,x=[];let b=0;return o.forEach((n,i)=>{const o=t[n],a=e._ids(o,n).join("-"),r=s[i];for(let e=0;e<d[i];e++,b++){const t=fB(b,{...f,fillDirection:c,fillStart:l});x.push({__d3plus__:!0,data:o,i:n,id:`${a}-${e}`,k:b,n:e,...t,x:g.x+t.column*y,y:g.y+t.row*y,size:g.size,share:r})}}),e.ctx.waffleTotal=r,e.ctx.waffleGrid=f,e.ctx.waffleGeometry=g,{shapeData:x}};function xB(e,t){const{x:n,y:i,size:o}=e;if("circle"===t)return{type:"circle",cx:n+o/2,cy:i+o/2,r:o/2};const a={type:"rect",x:n,y:i,width:o,height:o};if("rounded"!==t)return a;const r=.25*o;return{...a,rx:r,ry:r}}function bB(e){return"rounded"===e||"circle"===e?e:"square"}function _B(e,t){return null!=e&&Number.isFinite(e)?`${d.formatAbbreviate(100*e,t)}%`:""}function kB(e,t){const n=e.schema.sum;if(t._isColorScaleBucket)return Pa(e,t.color,n);const i=Mr(t),o=Cr(i);return Number.isFinite(o)?o:$r(i,e._legendData||[],e=>n(e,0))}function vB(e){const t=()=>e.schema.locale;return[[()=>e.schema.translate("Value"),(n,i,o)=>{if(o&&o._isColorScaleBucket)return"";const a=e.schema.sum,r=Number(a(n,i));return Number.isFinite(r)?d.formatAbbreviate(r,t()):""}],[()=>e.schema.translate("Share"),(n,i,o)=>_B(kB(e,o??{}),t())]]}const wB=e=>!0===e._isAggregation,SB={name:"Waffle",layoutStage:yB,emit:({viz:e,shapeData:t})=>{const n=t??[];if(!n.length)return[];const i=bB(e.schema.cellShape),o=au(e,"circle"===i?"Circle":"Rect"),a=e.schema.icon,r=e.schema.sum,s=e.schema.locale,c=(e,t)=>a?tu(a,e,t):void 0,l=n.map(t=>{const{data:n,i:a}=t,l=c(n,a),h=tu(o.fill,n,a),u=l?{fill:"transparent"}:{fill:nu(o,n,a,h),stroke:tu(o.stroke,n,a),strokeWidth:tu(o.strokeWidth,n,a)},f=0===t.n?`${e._drawLabel(n,a)}, ${r(n,a)}, ${d.formatAbbreviate(100*t.share,s)}%`:void 0;return{...xB(t,i),key:`waffle-${t.id}`,index:a,datum:n,paint:{...u,opacity:tu(o.opacity,n,a)},aria:f?{label:f}:{hidden:!0}}}),h=qy(a?{...o,backgroundImage:(e,t)=>c(e,t)||tu(o.backgroundImage,e,t),backgroundImageFit:(e,t)=>c(e,t)?"contain":tu(o.backgroundImageFit,e,t)}:o,l,e=>[n[e].data,n[e].i]);return[...l,...h]},insetRegion:Uu,thresholdFunction:(e,t)=>QS(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey,label:(t,n)=>e._drawLabel(t,n)}),facet:{aspect:1},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellShape",default:"square"},{key:"columns",default:10},{key:"fillDirection",default:"row"},{key:"fillStart",default:"top-left"},{key:"icon"},{key:"rows",default:10},{key:"sort",factory:e=>(e=>(t,n)=>{const i=e.schema.sum;return i(n)-i(t)})(e),decorate:(e,t)=>{const n=t;return(e,t)=>{const i=wB(e),o=wB(t);return i&&!o?1:!i&&o?-1:n(e,t)}}},{key:"sum",default:T("value"),coerce:e=>"function"==typeof e?e:Be(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"unit"},{key:"zoom",default:!1},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:vB(e)})},{key:"legendTooltip",merge:!0,factory:e=>({tbody:vB(e)})},{key:"legendSort",factory:e=>(e=>(t,n)=>{const i=e.schema.sort;return"function"==typeof i?i(t,n):0})(e)}]};var CB=xf(SB);const MB={increase:"Increase",decrease:"Decrease",total:"Total"};function $B(e,t,n){const i=t[`${e}Color`];if("string"==typeof i&&i)return i;const o={...r.colorDefaults,...n};return"increase"===e?o.on:"decrease"===e?o.off:o.sequential}function AB(e,t){return"total"===e.kind?t(e.end):e.change>0?`+${t(e.change)}`:t(e.change)}const zB=e=>"total"===e.kind?e.end>=0:e.change>=0,DB={height:20,width:56,minWidth:64,gap:2};function FB(e,t,n){const i=zB(e),{gap:o}=DB;if(n){const e=Math.max(t.width,DB.minWidth),n=DB.height;return{x:-e/2,y:i?-t.height-n-o:t.height+o,width:e,height:n}}const a=DB.width;return{x:i?t.width+o:-t.width-a-o,y:-t.height/2,width:a,height:t.height}}function BB(e,t){const n=zB(e);return t?{textAnchor:"middle",verticalAlign:n?"bottom":"top"}:{textAnchor:n?"start":"end",verticalAlign:"middle"}}function LB(e,t,n){return e&&"total"!==e.kind?[[n("Running Total"),t(e.end)]]:[]}function PB(e,t){return({data:n,x:i,y:o,x2:a})=>{if(a||!t.labels())return[i,o];const r=t.vertical(),s=r?o:i,c=n.map(t=>t.data?e(t.data):void 0).filter(e=>!!e),l=s.range(),h=Math.abs(l[l.length-1]-l[0]);if(!c.length||!h)return[i,o];const u=s.domain().slice();r&&u.reverse();const d=r?DB.height+DB.gap:DB.width+DB.gap,f=function(e,t,n){let[i,o]=e;const a=Math.min(Math.max(n,0),.45);if(!a||!t.length)return[i,o];let r=-1/0,s=1/0;for(const e of t)zB(e)?r=Math.max(r,e.end):s=Math.min(s,e.end);for(let e=0;e<8;e++){const e=o-i;Number.isFinite(r)&&(o=Math.max(o,r+a*e)),Number.isFinite(s)&&(i=Math.min(i,s-a*e))}return[i,o]}([u[0],u[1]],c,d/h);return r&&f.reverse(),s.domain(f),[i,o]}}function RB(e,t,n){const i=[],o=e=>{if("rect"===e.type&&"Bar"===e.shapeType&&e.datum?.data){const o=e.datum.data,a=t(o),r=n?(e.transform?.x??0)+(e.x??0):(e.transform?.y??0)+(e.y??0),s=(n?e.width:e.height)??0;a&&Number.isFinite(r)&&Number.isFinite(s)&&i.push({step:a,datum:o,lo:r,hi:r+s})}e.children?.forEach(o)};return e.forEach(o),i}function EB(e,t,n){const i=new Map;for(const t of e){let e=i.get(t.step.series);e||i.set(t.step.series,e=new Map),e.has(t.step.index)||e.set(t.step.index,t)}const o=[];return i.forEach(e=>{e.forEach(i=>{const a=e.get(i.step.index-1);if(!a||!i.step.joins)return;const r=t(a.step.end);if(!Number.isFinite(r))return;const s=i.lo+i.hi>=a.lo+a.hi,c=s?a.hi:a.lo,l=s?i.lo:i.hi;o.push(n?{from:a,x1:c,y1:r,x2:l,y2:r}:{from:a,x1:r,y1:c,x2:r,y2:l})})}),o}function NB(e,t,n){return"function"==typeof e?e(t,n):e}function TB(e,t){return e.map((e,n)=>{const i=e.from.datum,o={fill:"none",stroke:NB(t.stroke,i,n),strokeWidth:NB(t.strokeWidth,i,n),strokeOpacity:NB(t.strokeOpacity,i,n)},a=rz(NB(t.strokeDasharray,i,n));return a&&(o.strokeDasharray=a),{type:"line",key:`waterfall-connector-${e.from.step.series}-${e.from.step.index}`,points:[[e.x1,e.y1],[e.x2,e.y2]],curve:"linear",paint:o,interactive:!1,interactionGroup:"axis"}})}const OB=["increase","decrease","total"],WB=e=>"number"==typeof e&&Number.isFinite(e)?e:void 0;function jB(e,t){const n=Number(e instanceof Date?+e:e)-Number(t instanceof Date?+t:t);return Number.isNaN(n)?0:n}function HB(e,t,n){const i=e.values.filter(e=>void 0!==e),o=i.reduce((e,t)=>e+t,0),{series:a,index:r}=n;if(e.subtotal){const n=i.length?o:t;return{series:a,index:r,category:e.category,kind:"total",start:0,end:n,change:n-t,joins:r>0&&(s=n,c=t,Math.abs(s-c)<=1e-9*Math.max(1,Math.abs(s),Math.abs(c)))}}var s,c;if(i.length)return{series:a,index:r,category:e.category,kind:o<0?"decrease":"increase",start:t,end:t+o,change:o,joins:r>0}}function IB(e,t){const{category:n,series:i,value:o,subtotal:a,sort:r}=t,s=new Map;e.forEach((e,t)=>{const o=`${i(e,t)}`,a=n(e,t),r=a instanceof Date?""+ +a:`${a}`;let c=s.get(o);c||s.set(o,c=new Map);const l=c.get(r);l?l.rows.push([e,t]):c.set(r,{category:a,rows:[[e,t]]})});const c=new Map;return s.forEach((e,t)=>{const n=Array.from(e.values());!function(e,t){t?e.sort((e,n)=>t(e.rows[0][0],n.rows[0][0])):e.sort((e,t)=>jB(e.category,t.category))}(n,r);let i=0,s=0;for(const e of n){const n=HB({category:e.category,values:e.rows.map(([e,t])=>WB(o(e,t))),subtotal:!!a&&e.rows.some(([e,t])=>!!a(e,t))},i,{series:t,index:s});n&&(i=n.end,s++,e.rows.forEach(([e])=>c.set(e,n)))}}),c}function GB(e){const t=new Set;for(const n of e)n&&t.add(n.kind);return OB.filter(e=>t.has(e))}function VB(e,t){return void 0===WB(e)&&t&&"total"===t.kind?t.end:e}function qB(e){return t=>{for(const n of t){const t=n.key;for(const i of n){const n=(i.data??[]).find(e=>e.id===t),o=n&&n.data?e(n.data):void 0;o&&(i[0]=Math.min(o.start,o.end),i[1]=Math.max(o.start,o.end))}}}}const YB="__d3plusWaterfallKind",KB=e=>e.ctx.waterfall,UB=e=>"y"===e.schema.discrete?"y":"x",XB=e=>"x"===UB(e)?"y":"x";function QB(e){for(;e&&(e.__d3plus__||e.__d3plusShape__)&&e.data;)e=e.data;return e}function ZB(e,t,n){const i="function"==typeof e.schema.facet?e.schema.facet:void 0,o=n&&"function"==typeof e.schema.time?e.schema.time:void 0,a=KB(e).accessors[UB(e)],r=o&&t.length&&o(t[0],0)!==a(t[0],0)?o:void 0;return(t,n)=>{const o=[e._ids(t,n).slice(0,(e._drawDepth??0)+1).join("_")];return i&&o.unshift(`${i(t,n)}`),r&&o.unshift(`${r(t,n)}`),o.join("|")}}function JB(e){const t=e.schema[`${UB(e)}Sort`];return"function"==typeof t&&t!==KB(e).ySort?t:void 0}const eL=e=>e instanceof Date?""+ +e:`${e}`;function tL(e){const t=KB(e),n=e.schema.ySort;void 0===n||n===t.ySort?"y"===UB(e)?e.schema.ySort=t.ySort=function(e,t){const n=n=>e.get(eL(t(n,0)))??-1;return(e,t)=>n(t)-n(e)}(function(e,t){const n=new Map;e.forEach((e,i)=>{const o=t(e,i),a=eL(o);n.has(a)||n.set(a,o)});const i=Array.from(n.entries()).sort((e,t)=>jB(e[1],t[1]));return new Map(i.map(([e],t)=>[e,t]))}(e._data||[],t.accessors.y),t.accessors.y):t.ySort&&(e.schema.ySort=t.ySort=void 0):t.ySort=void 0}function nL(e,t,n){const i=KB(e);if(!t||!t.length||i.laidOut.has(t))return;i.laidOut.add(t);IB(t,{category:i.accessors[UB(e)],series:ZB(e,t,n),value:i.accessors[XB(e)],subtotal:e.schema.subtotal,sort:JB(e)}).forEach((e,t)=>i.steps.set(t,e))}function iL(e,t){const n=QB(t);if(n)return nL(e,e._filteredData,!1),e._axisPersist&&nL(e,e._data,!0),KB(e).steps.get(n)}function oL(e,t){const n=QB(t);if(!n)return;const i=n[YB];return"string"==typeof i?i:iL(e,n)?.kind}function aL(e){const t=QB(e)?.[YB];return"string"==typeof t?t:void 0}function rL(e){const t=e[`_${XB(e)}Config`];return t&&"function"==typeof t.tickFormat?t.tickFormat:t=>d.formatAbbreviate(t,e.schema.locale)}const sL=new WeakSet;const cL=(e,t)=>{const n=oL(e,t);return n?e.schema.translate(MB[n]):void 0},lL=e=>"x"===UB(e);const hL={name:"Waterfall",paintDriven:!0,thresholdFunction:(e,t)=>t,setup:e=>{e.ctx.waterfall={accessors:{x:e._x,y:e._y},steps:new WeakMap,laidOut:new WeakSet},function(e){const t=KB(e);["x","y"].forEach(n=>{const i=`_${n}`,o=e[i];sL.has(o)||(t.accessors[n]=o);const a=(i,o)=>{const a=t.accessors[n](i,o);return XB(e)!==n||void 0!==WB(a)?a:VB(a,iL(e,i))};sL.add(a),Object.defineProperty(e,i,{configurable:!0,enumerable:!0,get:()=>a,set:e=>{sL.has(e)||(t.accessors[n]=e)}})})}(e),e._stackOffset=qB(t=>iL(e,t)),e._stackGroup=(t,n)=>e._ids(t,n).slice(0,e._drawDepth+1).join("_"),e._stackShares=!1,e.schema.color=t=>oL(e,t),function(e){const t=e.schema.shapeConfig.fill;e.schema.shapeConfig.fill=(n,i)=>{const o=oL(e,n);return o?$B(o,e.schema,e.schema.colorDefaults):t(n,i)};const n=(t,n,i)=>{const o=iL(e,t);return o?BB(o,lL(e))[n]:i},i=e.schema.shapeConfig.Bar??{};e.schema.shapeConfig.Bar={...i,ariaLabel:(t,n)=>{const i=iL(e,t);return i?`${i.category}, ${cL(e,t)}: ${AB(i,rL(e))}.`:e._drawLabel(QB(t),n)},label:t=>{const n=iL(e,t);return!!n&&AB(n,rL(e))},labelBounds:(t,n,i)=>{const o=iL(e,t);return!!o&&FB(o,i,lL(e))},labelConfig:{...i.labelConfig??{},fontColor:()=>Ga(e),fontResize:!1,fontSize:12,fontStroke:"transparent",fontStrokeWidth:0,padding:0,textAnchor:e=>n(e,"textAnchor","middle"),verticalAlign:e=>n(e,"verticalAlign","middle")}}}(e),function(e){const t=(t,n)=>cL(e,t)??e._drawLabel(t,n),n=e.schema.legendConfig;e.schema.legendConfig={...n,label:t,shapeConfig:{...n.shapeConfig??{},ariaLabel:t}},e.schema.legendSort=(t,n)=>OB.indexOf(oL(e,t))-OB.indexOf(oL(e,n)),delete e.schema.on["click.legend"];const i=e.schema.on.mouseenter;e.schema.on.mouseenter=function(t,n,o,a){const r=aL(t);if(!r)return i.call(this,t,n,o,a);1!==e.schema.shapeConfig.hoverOpacity&&e.hover(t=>oL(e,t)===r)}}(e),e._buffer={...e._buffer,Bar:PB(t=>iL(e,t),{vertical:()=>lL(e),labels:()=>!1!==e.schema.shapeConfig.Bar?.label})},e._plotUnderlay=(t,n,i)=>{if(!e.schema.connectors)return[];const o=lL(e);return TB(EB(RB(t,t=>iL(e,t),o),o?e=>i(e):e=>n(e),o),e.schema.connectorConfig)};const t=e._preDraw.bind(e);e._preDraw=()=>{!function(e){const t=KB(e);t.steps=new WeakMap,t.laidOut=new WeakSet}(e),tL(e),t();const n=e._filteredData||[];e._legendData=GB(n.map(t=>iL(e,t))).map(e=>({[YB]:e}))}},ctx:{},fields:[{key:"connectors",default:!0},{key:"decreaseColor"},{key:"increaseColor"},{key:"legend",coerce:"const",factory:()=>(e,t)=>t.length>1},{key:"stacked",default:!0},{key:"subtotal",coerce:e=>"string"==typeof e?Be(e):"function"==typeof e?e:void 0},{key:"totalColor"},{key:"connectorConfig",merge:!0,factory:e=>({stroke:()=>Ga(e),strokeDasharray:"",strokeOpacity:.6,strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,n)=>function(e,t,n){const i=QB(t);if(aL(i))return cL(e,i)??"";const o=e._drawLabel(i,n);return"undefined"===o?cL(e,i)??o:o}(e,t,n),tbody:t=>LB(iL(e,t),rL(e),e.schema.translate)})}]};var uL=xf(hL,Sb);e.Area=Io,e.AreaPlot=kb,e.Axis=hi,e.AxisBottom=ui,e.AxisLeft=di,e.AxisRight=fi,e.AxisTop=mi,e.BOTTOM_RIGHT_CONTRIBUTORS=Td,e.Bar=Vo,e.BarChart=Sb,e.BaseClass=$e,e.Beeswarm=Mb,e.Box=Sa,e.BoxWhisker=Wb,e.Bullet=E_,e.BumpChart=T_,e.CANDLESTICK_SHAPE=qv,e.CONNECTOR_KEY_SUFFIX=fw,e.Calendar=Bk,e.Candlestick=ew,e.Chord=rw,e.Circle=Uo,e.ColorScale=Gi,e.DEFAULT_AGGS=tv,e.DEFAULT_BAND_OPACITY=Am,e.DENSITY=hD,e.DOMAIN_CLIP_KEY=wy,e.Donut=dw,e.Dumbbell=ww,e.END_LABEL_AXIS_CONFIG=Hg,e.FACET_ASPECT=Re,e.FACET_PADDING=20,e.FACET_TITLE_DEFAULTS=Pe,e.FanChart=Mw,e.Funnel=yS,e.Gauge=_S,e.Geomap=TS,e.Histogram=XS,e.INSET_PRIORITY=Va,e.Icicle=XC,e.Image=Ma,e.LABEL_COMBOS=ud,e.Legend=bi,e.Line=ya,e.LinePlot=Sw,e.Lollipop=lM,e.MARK_TYPES=Qe,e.Marimekko=yM,e.Matrix=wM,e.Message=Ji,e.NO_SIDES=hd,e.Network=HM,e.Pack=YM,e.ParallelCoordinates=Z$,e.Path=Aa,e.Pie=uw,e.Plot=_b,e.PolarArea=VA,e.Priestley=KA,e.Pyramid=Lz,e.RADIAL_BAR_MIN_LABEL_GAP=Iz,e.RESET=O,e.RESOLVES_RESET=j,e.Radar=Nz,e.RadialBar=Jz,e.RadialMatrix=oD,e.Rect=Yo,e.Ridgeline=BD,e.Rings=GD,e.STEM_KEY_SUFFIX=QC,e.Sankey=hF,e.Shape=jo,e.SizeLegend=Zi,e.StackedArea=uF,e.Sunburst=RF,e.TOP_LEFT_CONTRIBUTORS=Ah,e.TextBox=ro,e.Timeline=yo,e.Tooltip=Mo,e.Tree=jF,e.Treemap=ZF,e.VIOLIN_PADDING=.5,e.VOLUME_DEFAULTS=_v,e.Violin=cB,e.Viz=yf,e.Waffle=CB,e.Waterfall=uL,e.Whisker=_a,e.absoluteFormat=iz,e.accessor=T,e.addDays=G_,e.aggregateFunctionFields=av,e.alignAxisLine=Qg,e.alignInsets=gd,e.allotEndLabelWidths=Kg,e.applyAxisBreaks=hn,e.applyBarWidths=ym,e.applyBulletLayout=w_,e.applyCalendarLayout=Sk,e.applyChordLayout=tw,e.applyFunnelLayout=qw,e.applyGaugeLayout=t_,e.applyGeomapLayout=DS,e.applyIcicleLayout=PC,e.applyLineStates=U$,e.applyMatrixLayout=bM,e.applyNetworkLayout=AM,e.applyPackLayout=IM,e.applyPaddedDomains=Zm,e.applyParallelLayout=k$,e.applyPieLayout=lw,e.applyPolarAreaLayout=HA,e.applyPriestleyLayout=qA,e.applyRadarLayout=Rz,e.applyRadialBarLayout=Xz,e.applyRadialMatrixLayout=tD,e.applyRingsLayout=WD,e.applySankeyLayout=rF,e.applySunburstLayout=kF,e.applySwarmLanes=Km,e.applyTreeLayout=TF,e.applyTreemapLayout=YF,e.applyWaffleLayout=yB,e.autoForecastStart=function(e){const t=am(Array.from(rm(e).values()));return t?t.value:null},e.autoLineOpacity=t$,e.axisBarNodes=fn,e.axisDomain=c$,e.axisPositions=n$,e.backContribution=Bc,e.backdropDecor=nx,e.backgroundImageNode=Vy,e.backgroundImageNodes=qy,e.bandAxisDefaults=bv,e.bandOpacityTargets=Pm,e.bandPolygon=by,e.bandRows=yg,e.bandStep=az,e.barKey=dm,e.barSpanAxisConfig=km,e.barWidthAccessor=fm,e.barWidthLabel=vm,e.barWidthTooltipRows=wm,e.baselineBreakAxisConfig=ep,e.baselineBreakStyle=cn,e.baselineDomainAxis=wf,e.beeswarmDef=Cb,e.betweenPoints=Uf,e.binData=GS,e.blockDays=Z_,e.blockGrid=rk,e.blockMonths=J_,e.blockWeeks=Q_,e.bottomRightClearance=nc,e.bottomRightControlsBox=Zs,e.bottomRightControlsDrop=tc,e.bottomRightControlsFeature=Wd,e.bottomRightControlsInset=ec,e.bottomRightControlsShortfall=ic,e.boundOrValue=Em,e.breakGap=dn,e.breakLineNodes=gy,e.breakLinePaint=py,e.breakStyle=sn,e.breakTickValues=un,e.broadcastLegend=pt,e.broadcastLink=dt,e.brokenBarScene=mn,e.brokenScale=on,e.brokenScaleTicks=an,e.brushFromPixels=M$,e.brushTarget=_$,e.bulletAxis=r_,e.bulletBands=n_,e.bulletDef=R_,e.bulletExtents=b_,e.bulletStack=f_,e.calendarBlocks=X_,e.calendarDateFormat=vk,e.calendarDateSpecifier=nk,e.calendarDayKey=H_,e.calendarDef=Fk,e.calendarEmit=zk,e.calendarFormatter=tk,e.calendarInsets=mk,e.calendarLabelStyle=kk,e.calendarLayout=gk,e.calendarOrient=_k,e.calendarPalette=Ck,e.calendarPeriod=bk,e.calendarTimeLocale=ek,e.candleAriaLabel=Iv,e.candleChange=Nk,e.candleDirection=Ek,e.candlePath=Hk,e.candleTexture=Uv,e.candleTooltipRows=Hv,e.candleWidth=Wk,e.candlestickBuffer=uv,e.candlestickDef=Jv,e.canvasTooCoarse=$l,e.categoryGaps=xw,e.categoryStep=SD,e.cellCornerRadius=hk,e.chordDef=aw,e.clampBarConfig=op,e.clearPanelSlots=Ac,e.clearStrip=R$,e.clipToPlotArea=Fy,e.closestFreeOffset=Tm,e.coerceFacet=Ee,e.colorScaleFeature=fu,e.colorValue=Mk,e.columnHighlight=Lk,e.compareCategories=jB,e.compareFacetValues=qh,e.comparisonOutline=oz,e.computeAxisLayout=function(e){return Vn(e),{bounds:e._outerBounds,d3Scale:e._d3Scale,d3ScaleNegative:e._d3ScaleNegative,getPosition:t=>e._getPosition(t),availableTicks:e._availableTicks,visibleTicks:e._visibleTicks,margin:e._margin}},e.computeFilteredData=Ih,e.computeSizeLegend=Ki,e.computeTimeFilter=Hh,e.confidenceBands=Bm,e.configOpenDomain=kf,e.configPrep=Ae,e.configWarnings=function(e){if(!arguments.length)return ue;ue=!!e},e.connectorBars=RB,e.connectorNodes=TB,e.connectorSegments=EB,e.connectorStroke=kw,e.constant=N,e.conversionModes=Yw,e.conversionRates=Ow,e.cornerControlsHeight=wu,e.cornerPlacements=Su,e.curveFactory=If,e.curvePolyline=Yy,e.dashArray=rz,e.dateExtent=U_,e.daysBetween=I_,e.defaultCalendarDate=Dk,e.defaultSizeLegendValues=Yi,e.densityAt=lD,e.densityGroups=rD,e.densityMeta=dD,e.densityShapeId=fD,e.densityStats=aD,e.densityTooltipRows=xD,e.densityWidthScale=sD,e.detectDimensions=XM,e.dimensionAxisConfig=l$,e.dimensionDomain=ZM,e.dimensionTitleStyle=h$,e.dimensionTooltipRows=T$,e.dimensionType=QM,e.discreteDirection=Jy,e.discreteOrder=im,e.discreteRank=om,e.domainEnds=Vg,e.drawChart=Rd,e.drawFacets=Pd,e.drawWithInset=rd,e.dumbbellDef=vw,e.dumbbellEmit=yw,e.dumbbellSpans=mw,e.emitCandlesticks=Xv,e.emitEndLabels=Zg,e.emitFillBetween=Qf,e.emitForecast=tx,e.emitInner=aB,e.emitLineBands=Oy,e.emitVolume=Ev,e.endLabelSpace=Yg,e.expandArea=yd,e.extraBandValues=Nm,e.facetActive=Ie,e.facetAreaMargin=Cd,e.facetBodyNode=wd,e.facetDimensions=cd,e.facetFilteredData=Xh,e.facetGrid=ld,e.facetGroups=Uh,e.facetKey=Gh,e.facetOuterAxes=je,e.facetPanelAt=Mc,e.facetPanelNode=Sd,e.facetScalesShared=He,e.facetTimeFilter=Qh,e.facetTitleBand=Dd,e.facetTitleNodes=vd,e.facetTitleStyle=Ad,e.facetTitleTexts=zd,e.fanChartDef=Cw,e.fillBetweenDefaults=Yf,e.fillBetweenPairs=Kf,e.finiteValue=Pk,e.firstValue=Xk,e.fitCalendar=ok,e.fitFontSize=Kw,e.fitInset=nd,e.fitSwarms=Im,e.fittedArea=sd,e.forEachSceneRow=Ze,e.forecastDashOr=ox,e.forecastDefaults=nm,e.forecastLineDash=ix,e.forecastRow=sm,e.forecastRows=ax,e.forecastStart=lm,e.formatChange=Wv,e.formatDimensionValue=N$,e.formatFacetValue=Zh,e.formatPrice=Ov,e.formatShare=_B,e.frameTotals=JA,e.frozenAxis=ry,e.funnelCurve=Gw,e.funnelDef=gS,e.funnelEmit=hS,e.funnelFacetHooks=mS,e.funnelFacetPanel=fS,e.funnelLabelNodes=rS,e.funnelOrder=jw,e.funnelOrient=Iw,e.funnelStages=Vw,e.funnelTooltipRows=pS,e.gapComparator=bw,e.gaugeDef=bS,e.geomapDef=NS,e.getTopLeftContributions=zh,e.groupFacets=Kh,e.growFromLine=vD,e.growRectsFromCenter=wD,e.gutterAxisDefaults=_z,e.gutterInset=dz,e.gutterStackOffset=fz,e.gutterWidth=pz,e.hasBrushes=C$,e.hasColorValue=$k,e.hasFullConfigDomain=Cf,e.hasOpenUserEnd=Af,e.hasUserDomain=Sf,e.histogramDef=US,e.icicleBands=$C,e.icicleCollapse=zC,e.icicleDef=UC,e.icicleLabelBox=IC,e.icicleLayout=BC,e.icicleRect=AC,e.icicleRootEdge=DC,e.icicleStagger=FC,e.inheritedFillStyle=em,e.innerSet=JF,e.insetBackground=Qa,e.insetComponentOffset=Ja,e.insetFrame=Xa,e.insetOrient=Ua,e.insetPlacementFor=Ka,e.insetStyle=qa,e.installDensity=yD,e.installFluent=ee,e.installVolumeStrip=Lv,e.isAggregatedBranch=JS,e.isBrokenScale=en,e.isDomainClip=Ly,e.isExpandOffset=uM,e.isFluentAccessor=Z,e.isInsetPending=Ya,e.isMissing=UM,e.isNumeric=KM,e.isNumericRange=v$,e.isOneSided=_f,e.keyedAccessor=qk,e.kindColor=$B,e.labelAlign=BB,e.labelBarWidth=mm,e.labelBox=FB,e.labelExpansions=fd,e.labelGutter=md,e.labelKey=dd,e.labelMetrics=TC,e.labelOverhang=xd,e.labelPadding=dk,e.labelSizeCap=aS,e.labelsXEnds=Gg,e.largestRadius=eM,e.largestRemainder=hB,e.largestValue=zw,e.lastValue=Qk,e.layerOpacities=Rm,e.layoutAxes=p$,e.layoutBarSpans=gm,e.layoutCandles=Kv,e.layoutEndLabels=Ug,e.legendFeature=Th,e.legendLabelsWhole=Ph,e.lineAriaLabel=H$,e.lineBoxes=Qw,e.lineCurve=Gf,e.linePoints=g$,e.lineRows=function(e){const t=e.find(([e])=>"Line"===e);return t?t[1]:[]},e.linkAs=ht,e.linkKeys=st,e.linkMembers=function(e){return Array.from(Je.get(e)??[])},e.linkPredicate=lt,e.linkValues=ct,e.linkedColorDefaults=rt,e.listAxis=rb,e.lollipopBuffer=tM,e.lollipopDef=cM,e.lollipopEmit=aM,e.marimekkoAxisDefaults=fM,e.marimekkoDef=gM,e.marimekkoFacetAxes=mM,e.marimekkoFixedAxes=pM,e.marimekkoPercentText=dM,e.markBoxes=Ku,e.maskBreaks=_y,e.maskPath=xy,e.matrixDef=vM,e.maxValue=Zk,e.measureAxis=Vn,e.measureBars=pm,e.measureEndLabels=qg,e.measureFacetTitles=kd,e.mergeBranch=nC,e.mergeConfig=G,e.mergeConfigBag=Y,e.minValue=Jk,e.monotoneSlopes=Fw,e.monthLabelWeek=ck,e.monthOutlinePath=sk,e.narrowName=ik,e.neckConfig=sS,e.neckPaint=cS,e.nestPartition=ZS,e.nestSunburst=ZS,e.networkDef=jM,e.normalizeBreaks=tn,e.ohlcAccessors=lv,e.ohlcBarPath=Ik,e.ohlcExtent=Tk,e.openEnd=ap,e.openEndAxisConfig=zf,e.outsideBaselineBreak=np,e.packDef=qM,e.panelAxisConfig=hb,e.panelBase=pd,e.panelLabels=Md,e.panelTitle=Bd,e.parallelCoordinatesDef=Q$,e.parallelDimensionKeys=x$,e.parallelEmit=I$,e.parallelOrient=b$,e.parallelPath=y$,e.parseCalendarDate=j_,e.partitionFocus=aC,e.partitionLayout=iC,e.partitionLineage=oC,e.partitionShadeAmount=SC,e.partitionSort=eC,e.partitionSplit=NC,e.percentText=Zw,e.periodDate=mv,e.periodSpacing=Ok,e.pieDef=hw,e.pixelCenter=jk,e.pixelsFromBrush=$$,e.placeEndLabels=Xg,e.planFunnelLabels=Xw,e.planLabel=Uw,e.planStageLabels=iS,e.plotAxisConfig=Jm,e.plotAxisRounding=Mf,e.plotEmit=xx,e.plotFacetHooks=mb,e.plotFacetInsets=fb,e.plotFacetPanel=db,e.plotPaint=function(e,t){return _x(e,t).nodes},e.polarAreaDef=GA,e.polarAreaDomainValues=jA,e.polarAreaEmit=IA,e.polarAreaSlotOf=WA,e.polarAxisConfig=J$,e.polarBoxesOverlap=wA,e.polarCategoryLayout=$A,e.polarCategoryNodes=AA,e.polarFacetHooks=aA,e.polarFacetPanel=iA,e.polarHorizontalLayout=CA,e.polarInnerRadius=RA,e.polarLabelFitRadius=kA,e.polarLabelPlacement=_A,e.polarLabelRoom=vA,e.polarLabelsCollide=SA,e.polarLevelNodes=zA,e.polarLevels=PA,e.polarPadAngle=LA,e.polarRadius=DA,e.polarSharedExtent=oA,e.polarSlotArc=EA,e.polarSlotTops=TA,e.polarSlots=FA,e.polarSpokeRotation=MA,e.polarStack=BA,e.polarValueRow=eA,e.polarWedgeLayout=OA,e.polarWedgeNodes=tA,e.prefixKeys=bd,e.priestleyDef=YA,e.profileKnots=Bw,e.profileSlice=Rw,e.pyramidDef=Bz,e.pyramidExtent=ez,e.pyramidSides=XA,e.pyramidStackOrder=hM,e.pyramidTotal=ZA,e.radarDef=Ez,e.radialBarDef=Zz,e.radialBarDomainValues=Uz,e.radialBarEmit=Qz,e.radialBarFootprint=Wz,e.radialBarLabelRoom=Oz,e.radialBarRows=Yz,e.radialBarSweep=Hz,e.radialBarTrackLabels=Gz,e.radialBarTrackLayout=qz,e.radialBarTracks=Tz,e.radialMatrixDef=iD,e.rangeText=bg,e.readOhlc=Rk,e.registerLink=ot,e.renderAxes=hy,e.reserveBottomRight=Od,e.resolveBaselineBreak=ln,e.resolveBrushStyle=X$,e.resolveConfidenceBands=Fm,e.resolveDimensions=JM,e.resolveFacetAxes=Oe,e.resolveFacetConfig=Ne,e.resolveLineOpacity=j$,e.resolveLink=it,e.resolveSaveConfig=vl,e.resolveSpec=Fh,e.resolveSwarm=Ym,e.resolveWeekStart=K_,e.resolvesReset=K,e.ridgeOverlap=AD,e.ridgelineDef=FD,e.ridgelineEmit=DD,e.ridgelinePadding=zD,e.ringsDef=ID,e.roundOpenEnd=rp,e.roundPlotOpenEnds=cp,e.roundedDomain=On,e.rowBands=Lm,e.rowDate=yk,e.rowLegend=cw,e.rowPasses=S$,e.rowsExtent=xk,e.runLayout=xu,e.runPostDrawFeatures=Hd,e.runStages=ne,e.runVizPipeline=jd,e.sankeyDef=lF,e.saveChart=Al,e.saveContribution=Ul,e.saveFilename=bl,e.saveFormats=xl,e.savePixelRatio=Ml,e.sceneInsetRegion=Uu,e.searchContribution=wh,e.secondaryAxisRounding=$f,e.segmentWidth=Lw,e.seriesForecastStarts=rm,e.shareFunnelLabelSize=uS,e.shareFunnelScale=dS,e.sharePlotScales=cb,e.sharePolarScale=nA,e.shareRow=sw,e.sharedDomains=e$,e.sharedScaleMax=Hw,e.sideClip=Xf,e.sideControlsDrop=vu,e.sideSign=QA,e.sideTitleBoxes=cz,e.sizeLegendContribution=Nd,e.sliceExtent=Tw,e.slicePath=Nw,e.slotEdge=ex,e.slotPosition=ak,e.snapMagnitude=nz,e.sortByMedian=cD,e.sortFacetValues=Yh,e.splitDash=Uy,e.splitLength=Ky,e.stageAria=lS,e.stageBoxes=eS,e.stageLabelSize=oS,e.stageLines=Jw,e.stageSpans=$w,e.stageWidths=Dw,e.startOfDay=W_,e.stemFromBar=ZC,e.stemPoints=JC,e.stepLabel=AB,e.stepValue=VB,e.stripLength=F$,e.stripSelection=B$,e.stripSize=Cv,e.subtitleFeature=$u,e.sumValue=ev,e.summarizeBeforePreDraw=pD,e.sunburstDef=PF,e.sunburstFocus=_F,e.sunburstLabelBox=AF,e.sunburstLabelMetrics=FF,e.sunburstLayout=bF,e.sunburstPadAngle=pF,e.sunburstRadii=fF,e.sunburstSplit=NC,e.svgForSave=Cl,e.swarmExtent=Wm,e.swarmFitScale=Hm,e.swarmHidesAxis=Um,e.swarmLayout=Om,e.swarmPlacements=Xm,e.symmetricDomain=tz,e.syncBrushDom=E$,e.syncDefaultAggs=ov,e.syncGapSort=_w,e.tableViewContribution=gl,e.thinBands=gz,e.timelineFeature=Au,e.titleFeature=Mu,e.titleHeight=r$,e.titleNodes=s$,e.titleWidths=a$,e.toFacetValue=Vh,e.topLeftControlsFeature=Dh,e.totalFeature=zu,e.treeDef=WF,e.treemapDef=QF,e.trendForecastStart=cm,e.unionExtent=sb,e.unregisterLink=at,e.unwrapBreakMasks=vy,e.unwrapDomainClips=Py,e.unwrapRow=uD,e.userAxisDomain=Df,e.userDomainBreaksBaseline=tp,e.valueAxis=bf,e.valueAxisExtent=ip,e.valueDirection=Zf,e.valuePasses=w$,e.violinDef=sB,e.violinEdges=$D,e.violinEmit=rB,e.violinOutline=MD,e.violinSlots=CD,e.vizDraw=tf,e.vizPostThresholdCtx=uf,e.vizPreDraw=df,e.volumeAccessor=kv,e.volumeAriaLabel=Gv,e.volumeScale=Mv,e.volumeStripRect=Pv,e.waffleCellGeometry=mB,e.waffleCellGeometryNode=xB,e.waffleCellPosition=fB,e.waffleCellShape=bB,e.waffleCounts=uB,e.waffleDef=SB,e.waffleFillOptions=gB,e.waffleGrid=dB,e.waffleShare=kB,e.waffleTooltipRows=vB,e.waterfallDef=hL,e.waterfallKinds=GB,e.waterfallStackOffset=qB,e.waterfallStep=HB,e.waterfallSteps=IB,e.waterfallTooltipRows=LB,e.weekIndex=q_,e.weekdayLabelSlots=lk,e.weekdayNames=fk,e.weekdaySlot=V_,e.widenDomain=hv,e.withFacetPanel=$c,e.wrapLineCount=jC,e.xAxisRounding=eg,e.zoomSizeLegendScale=Ui});
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@d3plus/color"),require("@d3plus/data"),require("d3-color"),require("d3-selection"),require("@d3plus/dom"),require("@d3plus/render"),require("@d3plus/text"),require("d3-scale"),require("@d3plus/locales"),require("d3-array"),require("d3-transition"),require("@d3plus/format"),require("@d3plus/math"),require("@floating-ui/dom"),require("d3-brush"),require("d3-time-format"),require("d3-time"),require("d3-shape"),require("d3-interpolate"),require("d3-zoom"),require("d3-delaunay"),require("@d3plus/export"),require("d3-chord"),require("d3-tile"),require("d3-geo"),require("topojson-client"),require("d3-geo-projection"),require("d3-composite-projections"),require("d3-hexbin"),require("d3-contour"),require("d3-hierarchy"),require("d3-force"),require("d3-polygon")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","@d3plus/color","@d3plus/data","d3-color","d3-selection","@d3plus/dom","@d3plus/render","@d3plus/text","d3-scale","@d3plus/locales","d3-array","d3-transition","@d3plus/format","@d3plus/math","@floating-ui/dom","d3-brush","d3-time-format","d3-time","d3-shape","d3-interpolate","d3-zoom","d3-delaunay","@d3plus/export","d3-chord","d3-tile","d3-geo","topojson-client","d3-geo-projection","d3-composite-projections","d3-hexbin","d3-contour","d3-hierarchy","d3-force","d3-polygon"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).d3plus=t.d3plus||{},t.d3plus,t.d3plus,t.d3,t.d3,t.d3plus,t.d3plus,t.d3plus,t.d3,t.d3plus,t.d3,t.d3,t.d3plus,t.d3plus,t.FloatingUIDOM,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3plus,t.d3,t.d3,t.d3,t.topojson,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3,t.d3)}(this,function(t,e,n,i,o,r,a,s,c,l,h,u,d,f,m,p,g,y,x,b,_,k,v,w,M,S,C,$,A,z,D,L,F,N){"use strict";function B(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var E=B(c),R=B(x),P=B(S),T=B(A),O=Object.freeze({__proto__:null,get Area(){return La},get Bar(){return Na},get Box(){return ds},get Circle(){return Pa},get Image(){return ms},get Line(){return rs},get Path(){return gs},get Rect(){return Ea},get Shape(){return za},get Whisker(){return cs}});const W=new WeakMap;function H(t){const e=function(){return t};return W.set(e,{value:t}),e}function j(t){return"function"==typeof t?W.get(t):void 0}function I(t,e){return void 0===e?e=>e[t]:n=>void 0===n[t]?e:n[t]}const G=new WeakMap;function q(t){const e=I(t);return"string"==typeof t&&G.set(e,t),e}function V(t){return"function"==typeof t?G.get(t):void 0}const Y=Object.freeze({background:"#ffffff",text:e.colorDefaults.dark,textMuted:"#767676",axis:e.colorDefaults.dark,gridline:e.colorGray[200],accent:"#228be6",hidden:"#aaa",link:e.colorGray[500],colorScale:Object.freeze({max:e.colorDefaults.sequential,mid:e.colorDefaults.light,min:e.colorDefaults.off}),tooltip:Object.freeze({background:e.colorDefaults.light,text:e.colorDefaults.dark,border:"rgba(0, 0, 0, 0.25)",shadow:"0 1px 5px rgba(0, 0, 0, 0.25)",divider:"rgba(0, 0, 0, 0.1)"}),overlay:Object.freeze({background:"rgba(255, 255, 255, 0.75)",text:"rgba(0, 0, 0, 0.75)",border:"rgba(0, 0, 0, 0.25)"}),table:Object.freeze({background:"#fff",text:e.colorGray[900],header:"#fff",border:"#ccc",rule:"#e0e0e0"})}),K=Object.freeze({background:e.colorGray[900],text:e.colorDefaults.light,textMuted:e.colorGray[500],axis:e.colorDefaults.light,gridline:e.colorGray[800],accent:"#4dabf7",hidden:e.colorGray[600],link:e.colorGray[700],colorScale:Object.freeze({max:"#4dabf7",mid:e.colorGray[800],min:"#ff6b6b"}),tooltip:Object.freeze({background:e.colorGray[800],text:e.colorDefaults.light,border:"rgba(255, 255, 255, 0.2)",shadow:"0 1px 5px rgba(0, 0, 0, 0.6)",divider:"rgba(255, 255, 255, 0.15)"}),overlay:Object.freeze({background:"rgba(24, 25, 28, 0.75)",text:"rgba(255, 255, 255, 0.85)",border:"rgba(255, 255, 255, 0.25)"}),table:Object.freeze({background:e.colorGray[900],text:e.colorDefaults.light,header:e.colorGray[900],border:e.colorGray[700],rule:e.colorGray[800]})});function U(t){const e=i.lab(t).l;return Number.isFinite(e)&&e<50}function X(t,e){const n=i.rgb(t);return n.opacity=e,n.formatRgb()}const Z=t=>"object"==typeof t&&null!==t&&!Array.isArray(t);function Q(t,n={dark:!1},i={}){if("light"===t||"dark"===t||Z(t)){const e=Z(t)?t:{},n="dark"===t||"dark"===e.base||!e.base&&"string"==typeof e.background&&U(e.background),i=n?K:Y,{colorScale:o,tooltip:r,overlay:a,table:s,...c}=e;return delete c.base,Object.freeze({...i,...c,colorScale:{...i.colorScale,...o},tooltip:{...i.tooltip,...r},overlay:{...i.overlay,...a},table:{...i.table,...s},dark:n,painted:!0})}const o=n.dark?K:Y,r=n.background??o.background,a=i.dark||e.colorDefaults.dark,s=e.colorContrast(r,i);return Object.freeze({...o,background:r,text:s,axis:s,gridline:s===a?e.colorGray[200]:e.colorGray[800],dark:n.dark,painted:!1})}function J(t,e,n){if(!t)return n;const i=e(t);return i===e(Y)?n:i}function tt(t,e,n){return J(t,t=>t.colorScale[e],n)}function et(t,n,i,o=!1){return t?.dark?e.colorRampDark(n,i,{background:t.background,ordinal:o}):e.colorRamp(n,i,{ordinal:o})}function nt(t,e,n){const i={...t};for(const t of Object.keys(n))void 0!==n[t]&&i[t]===e[t]&&(i[t]=n[t]);return i}const it="D3PLUS-COMMON-RESET";function ot(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}const rt=Symbol("d3plus.resolvesReset");function at(t){return ot(t)?st({},t):Array.isArray(t)?t.slice():t}function st(t,e,n){for(const i of Object.keys(e)){const o=e[i],r=ot(n)?n[i]:void 0;if(o===it)void 0===r?delete t[i]:t[i]=at(r);else if(ot(o)){const e=t[i];t[i]=st(ot(e)?e:{},o,r)}else t[i]=at(o)}return t}function ct(t,e,n){return st(at(t),e,n)}function lt(t){return t===it||ot(t)&&Object.values(t).some(lt)}function ht(t,e){if("function"==typeof t.coerce)return t.coerce(e);switch(t.coerce){case"accessor":return"function"==typeof e?e:"string"==typeof e?I(e):H(e);case"const":return"function"==typeof e?e:H(e);default:return e}}function ut(t,e,n,i){const o=lt(n)?t._defaultConfig?.()[e]:void 0;if(n===it)return ot(o)?ct({},o):{};const r=arguments.length>3?i:t.schema[e];return ct(ot(r)?r:{},ot(n)?n:{},o)}function dt(t,...e){for(const n of e){const e=t[n];if("function"!=typeof e)throw new Error(`resolvesReset: "${n}" is not a method`);e[rt]=!0}}function ft(t,e,n){return n===it?at(t._defaultConfig?.()[e]):ut(t,e,n)}const mt=Symbol("d3plus.fluentAccessor"),pt=new WeakMap;function gt(t){return"function"==typeof t&&mt in t}function yt(t,e){for(let n=t;n&&n!==Object.prototype;n=Object.getPrototypeOf(n)){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return!gt(t.value)}return!1}function xt(t,e,n={}){t.schema||(t.schema={});for(const i of e){const e=i.key,o=e in n;if("default"in i||void 0!==i.factory){const n="default"in i?i.default:i.factory(t);let o=ht(i,n);i.decorate&&(o=i.decorate(t,o));const r=t.schema[e],a=i.merge&&ot(o)?ct(ot(r)?r:{},o):o;t.schema[e]=a,i.onSet?.(t,a)}else if(o&&void 0===t.schema[e]){const o=ht(i,n[e]);t.schema[e]=o,i.onSet?.(t,o)}}const i=Object.getPrototypeOf(t);if(!i)return;let o=pt.get(i);if(o||pt.set(i,o=new WeakSet),!o.has(e)){o.add(e);for(const t of e){if(yt(i,t.key))continue;const e=t.key;i[e]=function(...n){if(!n.length)return this.schema[e];const i=ht(t,n[0]),o=t.merge?ft(this,e,i):i;return this.schema[e]=o,t.onSet?.(this,o),this},t.merge&&(i[e][rt]=!0),Object.defineProperty(i[e],mt,{value:!0})}}}const bt={drawDepth:"_drawDepth",id:"_id",ids:"_ids",drawLabel:"_drawLabel",timeFilter:"_timeFilter",filteredData:"_filteredData",legendData:"_legendData"};function _t(t,e){let n=t;const i=t.viz;for(const t of e){const e=t(n);n=Object.assign({},n,e);for(const t of Object.keys(e)){const n=bt[t],o=e[t];n&&void 0!==o&&(i[n]=o)}}return n}function kt(t){return{width:t.schema.width-t._margin.left-t._margin.right,height:t.schema.height-t._margin.top-t._margin.bottom}}function vt(t,e,n){return{x:t._margin.left+e/2,y:t._margin.top+n/2}}function wt(t){const{width:e,height:n}=kt(t);return{type:"rect",x:t._margin.left,y:t._margin.top,width:e,height:n}}function Mt(t,e,n,i){if(function(t){return!0===t.paintDriven}(e))throw new Error(`runChartDraw cannot drive ${e.name} — it's a paint-driven chart (ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely on Plot._paint to populate _chartScene imperatively; their _draw should NOT call runChartDraw.`);t._chartScene=[];const o=_t({viz:t},[n]);if(!Array.isArray(t._chartScene))throw new Error(`runChartDraw: stage for ${e.name} replaced viz._chartScene with a non-array value (got ${typeof t._chartScene}). Stages should use \`(v._chartScene ||= []).push(...)\` rather than reassigning.`);const r=t._chartScene.slice(),a=e.emit(o);t._chartScene=[...r,...a],t._chartTransform=i?i(t):function(t){return{x:t._margin.left,y:t._margin.top}}(t),t._chartClip=e.chartClip?e.chartClip(t):void 0,t._bodyRect=e.chartBodyRect?e.chartBodyRect(t):{x:0,y:0,...kt(t)}}const St=t=>Number(r.date(Number(t)));function Ct(t,e,n,i){const o=t._xFunc,a=t._yFunc,s=t._x,c=t._y,l=t._id,h=t.schema.time;if(!(o&&a&&s&&c&&t._data&&h))return[];const u=function(t){const e=new Set,n=t=>!0===t||"number"==typeof t&&t>0,i=t=>{for(const o of t)!n(o.trailPersist)||"circle"!==o.type&&"rect"!==o.type||e.add(o.key),"group"===o.type&&i(o.children)};return i(t.root.children),e}(e);if(!u.size)return[];const d=new Set;t._data.forEach((t,e)=>d.add(St(h(t,e))));const f=[...d].filter(t=>t>n&&t<i).sort((t,e)=>t-e);if(!f.length)return[];const m=new Map;t._data.forEach((t,e)=>{const n=l(t,e);if(!u.has(n))return;let i=m.get(n);i||m.set(n,i=new Map),i.set(St(h(t,e)),{d:t,i:e})});const p=e=>t._yTime?r.date(e):e;return f.map(e=>({sequence:e,positions:[...u].flatMap(n=>{const i=m.get(n)?.get(e);return i?[{key:n,x:o((l=s(i.d,i.i),t._xTime?r.date(l):l)),y:a(p(c(i.d,i.i)))}]:[];var l})})).filter(t=>t.positions.length>0)}const $t=new WeakSet,At=new Set,zt=new WeakMap;let Dt=!0;function Lt(t){return $t.add(t),t}function Ft(t){return"object"==typeof t&&null!==t&&$t.has(t)}function Nt(t,e){Bt(`${t} received unknown property "${e}".`)}function Bt(t){Dt&&!At.has(t)&&(At.add(t),console.warn(t))}function Et(t,e,n){if(!Dt)return;let i=zt.get(t);i||zt.set(t,i=new Set),i.has(e)||(i.add(e),console.warn(n))}const Rt=["d3plus-render-svg","d3plus-render-canvas"];function Pt(t){return(t?.elements?.()??[]).filter(t=>"svg"===t.localName||"canvas"===t.localName)}const Tt=new WeakMap;function Ot(t){const e=(Array.isArray(t)?t:[t]).flatMap(t=>"string"==typeof t?t.split(/\s+/).filter(Boolean):[]);return Array.from(new Set(e))}function Wt(t,e,n=[]){const i=Ot(e);for(const e of Tt.get(t)??[])i.includes(e)||n.includes(e)||t.classList.remove(e);for(const e of i)t.classList.add(e);Tt.set(t,i)}function Ht(t){for(const{el:e,keep:n}of t._classNameTargets())Wt(e,t.schema.className,n)}const jt=t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;");function It(t){const e=t.constructor;return Object.prototype.hasOwnProperty.call(e,"_displayName")?e._displayName:e.name}function Gt(t,e){if(!ot(t)||!lt(t))return t;const n={...t},i=r.isObject(e)?e:{};for(const t of Object.keys(n))t.startsWith("_")||(n[t]===it?void 0===i[t]?delete n[t]:n[t]=i[t]:n[t]=Gt(n[t],i[t]));return n}const qt=new Set(["config","constructor","destroy","layout","measure","parent","render","renderMode","toCanvas","toSVGString","toScene"]);function Vt(t){let e=[];do{e=e.concat(Object.getOwnPropertyNames(t)),t=Object.getPrototypeOf(t)}while(t&&t!==Object.prototype);return e.filter(t=>0!==t.indexOf("_")&&!qt.has(t))}function Yt(t,e,n){if(!n.has(t)){n.add(t),t.schema.colorDefaults={...t.schema.colorDefaults,...e};for(const i of[...Object.values(t),...Object.values(t.ctx)])i instanceof Kt&&Yt(i,e,n)}}class Kt{config(t){const e=this._defaultConfig();if(arguments.length){for(const n in t)if({}.hasOwnProperty.call(t,n))if(n in this){const i=t[n],o=this[n];i===it&&"on"===n?this.schema.on=e[n]:o[rt]?o.call(this,i):i===it?o.call(this,e[n]):o.call(this,Gt(i,e[n]))}else Ft(t)||Nt(`${It(this)}.config()`,n);return this}{const t={};return Vt(Object.getPrototypeOf(this)).forEach(e=>{t[e]=this[e]()}),t}}_defaultConfig(){if(!this._configDefault){const t={};Vt(Object.getPrototypeOf(this)).forEach(e=>{const n=this[e]();n!==this&&(t[e]=r.isObject(n)?r.assign({},n):n)}),this._configDefault=t}return this._configDefault}locale(t){return arguments.length?(this.schema.locale=l.findLocale(t),this):this.schema.locale}className(t){return arguments.length?(this.schema.className=t,Ht(this),this):this.schema.className}_classNameTargets(){return Pt(this._sceneRenderer).map(t=>({el:t,keep:Rt}))}colorDefaults(t){if(!arguments.length)return this.schema.colorDefaults;const{scale:e,...n}=t??{},i={...n};return Array.isArray(e)?i.scale=c.scaleOrdinal().range(e):e&&(i.scale=e),Yt(this,i,new WeakSet),this}on(t,e){return 2===arguments.length?(this.schema.on[t]=e,this):arguments.length?"string"==typeof t?this.schema.on[t]:(this.schema.on=Object.assign({},this.schema.on,t),this):this.schema.on}parent(t){return arguments.length?(this.schema.parent=t,this):this.schema.parent}translate(t){return arguments.length?(this.schema.translate=t,this):this.schema.translate}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ut(this,"shapeConfig",t),this):this.schema.shapeConfig}constructor(){this.schema={},this.ctx={},this.schema.colorDefaults={...e.colorDefaults},this.schema.locale="en-US",this.schema.on={},this.schema.parent={},this.schema.translate=(t,e=this.schema.locale)=>{const n=l.translateLocale[e],i=t;return n&&n[i]?n[i]:t},this._uuid=crypto.randomUUID()}}function Ut(){if("undefined"==typeof window||"function"!=typeof window.matchMedia)return!1;try{return!!window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function Xt(t){const e=t.schema.reducedMotion;return!0===e||!1!==e&&Ut()}function Zt(t){return Xt(t)?0:Number(t.schema.duration)||0}function Qt(t=this.schema.shapeConfig,e="shape",n=!1){const i={duration:Zt(this),on:{}},o=t=>(e,n,i,o)=>{if(!t)return t;let r;for(;e.__d3plus__;)r&&(e.__d3plusParent__=r),r=e,n=e.i,e=e.data||e.feature;return t.bind(this)(e,n,i||r,o)},r=(t,n)=>{for(const i in n)({}.hasOwnProperty.call(n,i)&&!i.includes(".")||i.includes(`.${e}`))&&(t.on[i]=o(n[i]))},a=t=>t.map(t=>t instanceof Array?a(t):"object"==typeof t?s({},t):"function"==typeof t?o(t):t),s=(t,e)=>{for(const n in e)({}).hasOwnProperty.call(e,n)&&("on"===n?r(t,e[n]):"sort"===n?t[n]=e[n]:"function"==typeof e[n]?t[n]=o(e[n]):e[n]instanceof Array?t[n]=a(e[n]):"object"==typeof e[n]?(t[n]||(t[n]={}),t[n].on={},s(t[n],e[n])):t[n]=e[n]);return t};return s(i,t),this.schema.on&&r(i,this.schema.on),n&&t[n]&&(s(i,t[n]),t[n].on&&r(i,t[n].on)),Lt(i)}function Jt(t,e,n){return e[t]||this.schema[t](e,n)}function te(t){const e=t._select,n=e&&"function"==typeof e.node?e.node():null;if(!(n instanceof Element))return;const i=n,o=t.schema.width??400,r=t.schema.height??200;t._sceneRenderer?t._sceneRenderer.resize(o,r):(t._sceneRenderer=new a.SvgRenderer,t._sceneRenderer.mount({container:i,width:o,height:r}));const s={root:{type:"group",key:"root",children:[t.toScene()]},width:o,height:r};t._sceneRenderer.drawScene(s,{duration:0}),Ht(t)}Kt._displayName="BaseClass",dt(Kt.prototype,"shapeConfig");const ee={fontSize:12,fontWeight:600,padding:4,textAnchor:"middle"},ne=4/3;function ie(t){return"function"==typeof t?t:"string"==typeof t&&t?q(t):void 0}function oe(t){const e=t??{},n=t=>"number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0;return{columns:n(e.columns),rows:n(e.rows),padding:"number"==typeof e.padding&&e.padding>=0?e.padding:20,sort:e.sort??"ascending",scales:"shared"===e.scales||"independent"===e.scales?e.scales:void 0,axes:ae(e.axes),title:!1===e.title||"function"==typeof e.title?e.title:void 0,titleConfig:{...ee,...e.titleConfig??{}}}}const re=t=>"outer"===t||"all"===t;function ae(t){if(re(t))return t;if(!t||"object"!=typeof t)return;const{x:e,y:n}=t,i={};return re(e)&&(i.x=e),re(n)&&(i.y=n),i.x||i.y?i:void 0}function se(t,e){return"object"==typeof t?t[e]:t}function ce(t,e,n,i){const o="function"==typeof n.axes?n.axes(t):n.axes,r=n.fixedAxes?n.fixedAxes(t):{},a=t=>"outer"===(se(e.axes,t)??se(o,t)??"outer")&&(i||!!r[t]);return{x:a("x"),y:a("y")}}function le(t,e){return"shared"===(t.scales??e.scales??"shared")}function he(t){return"function"==typeof t.schema.facet}const ue="__d3plusGroupDepth",de="__d3plusGroupLabel";function fe(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}function me(t){const e=fe(t),n=e?e[ue]:void 0;return"number"==typeof n?n:void 0}function pe(t,e,n){const i=fe(e);return t.slice(0,n+1).map(t=>t(i,0))}function ge(t,e,n,i){const o=fe(n);return!!o&&e.every((e,n)=>{const r=t[n](o,i);return r===e||Array.isArray(r)&&r.includes(e)})}function ye(t,e,n){return n.some((n,i)=>!ge(t,e,n,i))}function xe(t){return"legend"===t.kind}function be(t){if(t)for(let e=t.length-1;e>=0;e--){const n=t[e];if(!xe(n))return n}}function _e(t){const e=be(t);return e&&t.splice(t.lastIndexOf(e),1),e}function ke(t,e){return t.length===e.length&&t.every(t=>e.includes(t))}function ve(t){return{kind:"legend",hidden:[...t._hidden],solo:[...t._solo]}}function we(t,e){var n;return!!t.schema.legendHistory&&((!ke(e.hidden,t._hidden)||!ke(e.solo,t._solo))&&(((n=t)._history??(n._history=[])).push(e),!0))}function Me(t,e){t._hidden=[...e.hidden],t._solo=[...e.solo]}function Se(t){if(!t._hidden.length&&!t._solo.length)return;const e={hidden:t._hidden,solo:t._solo};return t._hidden=[],t._solo=[],e}function Ce(t){if(t._history){t._history=t._history.filter(t=>!xe(t));for(const e of t._history)delete e.legend}}const $e=new Set(["rect","circle","line","area","path"]);function Ae(t,e){const n=new Set,i=t=>{if($e.has(t.type)&&void 0!==t.datum){const i=t.datum,o=i&&i.data?i.data:i;if(void 0!==o&&!n.has(o)){n.add(o);const i="number"==typeof t.index?t.index:"number"==typeof o.i?o.i:0;e(o,i,t)}}const o=t.children;o&&o.forEach(i)};t.forEach(i)}const ze=new Map,De=new Map,Le=new Set,Fe=new WeakMap;function Ne(t){const e=t.schema.link;if(!e)return null;const n="string"==typeof e?{group:e}:e;if(!n.group)return null;const i="function"==typeof n.by?n.by:"string"==typeof n.by?I(n.by):(e,n)=>t._id?.(e,n);return{group:n.group,by:i,hover:!1!==n.hover,active:!1!==n.active,highlight:!1!==n.highlight,legend:!1!==n.legend,color:!1!==n.color}}function Be(t){Ee(t);const e=Ne(t);if(!e)return;let n=ze.get(e.group);n||ze.set(e.group,n=new Set),n.add(t),t._linkGroup=e.group}function Ee(t){const e=t._linkGroup;if(void 0===e)return;const n=ze.get(e);n&&(n.delete(t),n.size||(ze.delete(e),De.delete(e))),t._linkGroup=void 0}function Re(t){const e=t.schema.colorDefaults,n=t._linkGroup;if(void 0===n||e.scale!==t._autoColorScale)return e;if(!Ne(t)?.color)return e;let i=De.get(n);return i||(i=c.scaleOrdinal().range(e.scale.range()),De.set(n,i)),{...e,scale:i}}function Pe(t){const e=Array.isArray(t)?t:[t],n=[];for(const t of e)null!=t&&n.push(t instanceof Date?""+ +t:`${t}`);return n}function Te(t,e,n){const i=new Set,o=(t,o)=>{if(n(t,o))for(const n of Pe(e(t,o)))i.add(n)},r=t._chartScene;return r&&r.length?Ae(r,o):(t._filteredData??[]).forEach(o),i}function Oe(t,e){return(n,i)=>Pe(t.by(n,i)).some(t=>e.has(t))}function We(t,e){Fe.set(t,e)}function He(t,e,n){if(Le.has(e.group))return;const i=ze.get(e.group);if(i&&!(i.size<2)){Le.add(e.group);try{for(const e of i){if(e===t)continue;const i=Ne(e);i&&n(e,i)}}finally{Le.delete(e.group)}}}function je(t,e,n){const i=Fe.get(t);if(Fe.delete(t),void 0===n)return;const o=Ne(t);if(!o||!o[e])return;const r="function"==typeof n?i??n:null;let a=null;He(t,o,(n,i)=>{if(!i[e])return;const s=n[e];s&&(r&&!a&&(a=Te(t,o.by,r)),s.call(n,!!a&&Oe(i,a)))})}function Ie(t,e,n){const i=t._id(e,n);return Array.isArray(i)?i:[i]}function Ge(t,e,n){const i=new Set;return n.length?((t._legendData??[]).forEach((o,r)=>{if(Ie(t,o,r).some(t=>n.includes(t)))for(const t of Pe(e.by(o,r)))i.add(t)}),i):i}function qe(t){const e=Ne(t);if(!e||!e.legend)return;const n=Ge(t,e,t._hidden),i=Ge(t,e,t._solo);He(t,e,(t,e)=>{if(!e.legend||!t._legendData?.length)return;const o=[],r=[];t._legendData.forEach((a,s)=>{const c=Pe(e.by(a,s)),l=Ie(t,a,s),h=t=>{for(const e of l)t.includes(e)||t.push(e)};i.size&&c.some(t=>i.has(t))?h(r):n.size&&c.length&&c.every(t=>n.has(t))&&h(o)});const a=(t,e)=>t.length===e.length&&t.every(t=>e.includes(t));a(o,t._hidden)&&a(r,t._solo)||(t._hidden=r.length?[]:o,t._solo=r,t.render?.())})}function Ve(t){const e=t.schema.shapeConfig;return Boolean(t._hoverOutline)||1!==e?.hoverOpacity}const Ye={},Ke=new WeakMap;function Ue(){return"undefined"!=typeof IntersectionObserver}function Xe(t,e,n,i=0,r){const a=function(t){return!t||"undefined"!=typeof window&&t===window?null:"string"==typeof t?o.select(t).node():"undefined"!=typeof Element&&t instanceof Element?t:null}(e),s=a||Ye;let c=Ke.get(s);if(!c){const t=new Map,e=new IntersectionObserver(e=>{e.forEach(e=>{t.get(e.target)?.forEach(t=>{clearTimeout(t.timer),t.timer=void 0,e.isIntersecting?t.delay>0?t.timer=setTimeout(t.onVisible,t.delay):t.onVisible():t.onHidden?.()})})},{root:a,rootMargin:"25% 0px"});c={targets:t,io:e},Ke.set(s,c)}const{targets:l,io:h}=c,u={delay:i,onHidden:r,onVisible:n};let d=l.get(t);return d||l.set(t,d=new Set),d.add(u),h.unobserve(t),h.observe(t),()=>{clearTimeout(u.timer),d.delete(u),d.size||(l.delete(t),h.unobserve(t))}}function Ze(t){if(!(t.schema.detectVisible&&t.schema.detectVisibleUnload&&Ue()))return t._unloadUnobserve?.(),void(t._unloadUnobserve=void 0);t._unloadUnobserve||(t._unloadUnobserve=Xe(t._select.node(),t.schema.scrollContainer,()=>function(t){t._unloaded&&(t._unloaded=!1,t._instantNextDraw=!0,t._forceVisible=!0,t.render())}(t),0,()=>function(t){if(t._unloaded)return;t._unloaded=!0,t._resizePoll=clearTimeout(t._resizePoll);const e=t._select.node()?.parentNode;e&&t._resizeObserver?.unobserve(e),t._tooltipClass.data([]).render(),null!=t._sceneRepaintRAF&&(cancelAnimationFrame(t._sceneRepaintRAF),t._sceneRepaintRAF=void 0),t._sceneRenderer&&"function"==typeof t._sceneRenderer.destroy&&(t._sceneRenderer.destroy(),t._sceneRenderer=void 0),t._select.selectAll("g.data-table").remove()}(t)))}function Qe(t){return t instanceof Array?t.some(n.isData):n.isData(t)}function Je(t){const e=JSON.stringify(t)??"";let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return`${e.length}:${(n>>>0).toString(36)}`}function tn(t,e,i){return new Promise((o,r)=>{let a;const s={_cache:!1,_lrucache:t._lrucache,_data:[],config:t=>{a=t}},c=function(t){return(t instanceof Array?t:[t]).map(t=>{if(!n.isData(t))return t;if("string"==typeof t)return{url:t,cache:"no-cache"};const e=t;return"cache"in e?e:{...e,cache:"no-cache"}})}(e);n.load.call(s,c,i,"data",(t,e)=>{t?r(t):o({data:e??[],config:a})})})}function en(t){t._dataPollStop?.(),t._dataPollStop=void 0,t._dataPollFor=void 0}function nn(t){const e=t.schema.dataFormat;return"function"==typeof e?e:void 0}function on(t){return[t.schema.dataPollingInterval,t._userData,nn(t),t.schema.detectVisible,t.schema.scrollContainer]}function rn(t,e){const n=t._userData,i=nn(t),o=t._select?.node()?.ownerDocument;let r=!1;const a=function(t){let e,n=!1,i=!1,o=!1,r=!1;const a=()=>{e=setTimeout(c,t.interval)},s=()=>{o=!1,i=!0,Promise.resolve().then(t.fetch).then(e=>{n||(r=!1,t.onData(e))},e=>{n||(r||t.onError(e),r=!0)}).catch(e=>{n||t.onError(e)}).finally(()=>{i=!1,n||a()})};function c(){e=void 0,n||(t.paused()?o=!0:s())}return a(),{stop(){n=!0,clearTimeout(e),e=void 0},resume(){n||!o||i||t.paused()||s()}}}({interval:e,fetch:()=>tn(t,n,i),onData:e=>function(t,{data:e,config:n}){const i=Je(e);i!==t._dataSignature&&(t._dataSignature=i,n&&t.config(n),t._data=e,t.schema.timeFilter||(t._timelineSelection=!1),t.render())}(t,e),onError:t=>{console.warn("d3plus: dataPollingInterval could not refresh the data; keeping the last data and retrying.",t)},paused:()=>r||"hidden"===o?.visibilityState}),s=()=>{"hidden"!==o?.visibilityState&&a.resume()};o?.addEventListener("visibilitychange",s);const c=t.schema.detectVisible&&Ue()?Xe(t._select.node(),t.schema.scrollContainer,()=>{r=!1,a.resume()},0,()=>{r=!0}):void 0;t._dataPollFor=on(t),t._dataPollStop=()=>{a.stop(),o?.removeEventListener("visibilitychange",s),c?.()}}function an(t){const e=t.schema.dataPollingInterval,n="number"==typeof e&&e>0&&isFinite(e);if(n&&!Qe(t._userData)&&Bt(`${It(t)}: dataPollingInterval only polls data loaded from a URL.`),!n||t._ssr||!Qe(t._userData))return void en(t);const i=on(t),o=t._dataPollFor;o&&o.every((t,e)=>t===i[e])||(en(t),rn(t,e))}const sn=["data","links","nodes","topojson"];function cn(t){return sn.includes(t)}function ln(t,e){const n=t.schema[`${e}Format`];return"function"==typeof n?n:void 0}function hn(t,e,n,i){if(!i)return n;const o=i(n);if("data"===e&&ot(o)){const{data:e,...n}=o;return t.config?.(n),e||[]}return o||[]}function un(t,e,n){`_${e}`in t?t[`_${e}`]=n:t.schema[e]=n}function dn(t,e,i){var o;const r=i[0];i.length>1&&(t.schema[`${e}Format`]=i[1]),n.addToQueue.call(t,r,void 0,e),((o=t)._loaders??(o._loaders={}))[e]={source:r,applied:void 0}}function fn(t){const e=t._loaders;if(!e)return;const i=t._queue??[];for(const o of sn){const r=e[o];if(!r||i.some(t=>t[3]===o))continue;const a=ln(t,o);r.applied!==a&&(Qe(r.source)?n.addToQueue.call(t,r.source,void 0,o):(un(t,o,hn(t,o,r.source,a)),r.applied=a))}}function mn(t,e,n){if(!cn(e))return n;const i=ln(t,e),o=t._loaders?.[e];return o&&(o.applied=i),i}function pn(...t){return t.map(t=>"topojson"===t?{key:"topojsonFormat",onSet:t=>{t._zoomSet=!1}}:{key:`${t}Format`})}function gn(t=s.textSplit){return(e,n)=>t(e,n).reduce((t,e)=>{const n=t.length-1;return n>=0&&t[n].endsWith(s.softHyphen)?t[n]=t[n].slice(0,-1)+e:t.push(e),t},[])}const yn=gn();function xn(t,e){if(t.truncated)return{fits:!1,result:t};if(!t.lines.slice(0,-1).some(t=>t.endsWith("-")))return{fits:!0,result:t};const n=e();return n.truncated?{fits:!1,result:t}:{fits:!0,result:n}}function bn(t){let e=(t%360+360)%360;return e>180&&(e-=360),e>90?e-=180:e<-90&&(e+=180),0===e?0:e}function _n(t){return"number"==typeof t&&Number.isFinite(t)?bn(t):-90}const kn={rotate:!1,angle:0,slant:!1};const vn=t=>"top"===t?30:-30;function wn(t){return"number"==typeof t?Number.isFinite(t)&&0!==bn(t):!0===t}function Mn(t,e){return!(!wn(t)||"number"!=typeof t)&&(!e||90!==Math.abs(bn(t)))}function Sn(t,e){const n=Math.abs(t)*Math.PI/180;return e?n:Math.PI/2-n}function Cn(t){return"bottom"===t?{x:0,y:1}:"top"===t?{x:0,y:-1}:"left"===t?{x:-1,y:0}:{x:1,y:0}}function $n(t,e){const n=e*Math.PI/180,i=Cn(t),o=Math.cos(n)*i.x+Math.sin(n)*i.y;return Math.abs(o)<1e-9?"middle":o<0?"end":"start"}function An(t,e,n,i,o,r){const a=e*Math.PI/180,s=Math.cos(a),c=Math.sin(a),l=-Math.sin(a),h=Math.cos(a),u=Cn(t),d=$n(t,e),f=Math.abs(l*u.x+h*u.y),m=u.x*(r+i/2*f),p=u.y*(r+i/2*f),g="end"===d?n:"start"===d?0:n/2,y=i/2,x=(t,e)=>({x:m+(t-g)*s+(e-y)*l,y:p+(t-g)*c+(e-y)*h}),b=x(n/2,o/2);return{x:b.x-n/2,y:b.y-o/2,width:n,height:o,corners:[x(0,0),x(n,0),x(n,i),x(0,i)]}}function zn(t,e,n,i){const o="top"===t||"bottom"===t,r=An(t,e,n,i,i,0).corners.map(t=>o?t.x:t.y);return[Math.max(0,-Math.min(...r)),Math.max(0,Math.max(...r))]}function Dn(t,e,n,i,o){const r=Sn(t,e),a=Math.sin(r);return a<1e-9?{width:i,height:n}:{width:Math.max(0,(n-o*Math.cos(r))/a),height:Math.max(o,i*a)}}function Ln(t,e,n){if(e<2)return n;const i=t.map(({text:t,fontFamily:i,fontSize:o,lineHeight:a})=>{const c={"font-family":i,"font-size":o},l=r.textWidth(`${t}`,c),h=`${t}`.split(/\s+/).filter(Boolean),u=Math.max(0,...h.map(t=>r.textWidth(t,c))),d=s.textWrap().fontFamily(i).fontSize(o).lineHeight(a).split(yn).height(a*(e+1));return function(t,e,n,i,o=1.08){for(let r=Math.max(1,n);r<i;r*=o)if(t(r)<=e)return Math.ceil(r);return i}(e=>d.width(e)(`${t}`).lines.filter(t=>""!==t).length,e,Math.max(u+1,l/e),n)});return Math.min(n,Math.max(0,...i))}function Fn(t,e){const n=t.lines.length,i=n?(n-1)*t.lineHeight+t.fS:0;if(t.slant){const n=Math.sin(Sn(t.angle,e));return n<1e-9?t.width:i/n}return Boolean(t.rotate)!==e?t.width:i}function Nn(t,e,n,i){const o=t=>e[t.i]-2*t.fP,r=new Set(t.filter(t=>!t.fits)),a=(e,n,i)=>{for(let o=e+n;o>=0&&o<t.length;o+=n)if(!(t[o].truncated||i&&r.has(t[o])))return t[o]},s=(t,e)=>{const s=[a(t.i,-1,e),a(t.i,1,e)].filter(t=>void 0!==t).map(e=>2*(Math.abs(e.position-t.position)-(t=>r.has(t)?Math.min(t.width,o(t)):t.width)(e)/2-t.fP)),c=Math.floor(s.length?Math.min(...s):Math.max(...n)-Math.min(...n));return c>o(t)&&i(t,c),t.fits};let c=Math.min(...n);const l=t.map(t=>{const e=Math.max(0,2*(t.position-c));return c+=e,e});[...r].sort((t,e)=>l[e.i]-l[t.i]).forEach(t=>{r.delete(t),s(t,!1)||s(t,!0),t.truncated=!t.fits})}function Bn(t,e,n){let i=1;const o=n=>t.some((i,o)=>o>=n&&o%n===0&&function(t,e,n){return Math.abs(e.position-t.position)-(Fn(t,n)+Fn(e,n))/2<e.fP}(t[o-n],i,e));for(;i<t.length&&o(i);)i++,n?.(i,!1);i>1&&n?.(i,!0),t.forEach((t,e)=>t.truncated=e%i!==0)}function En(t,e){const n=t.slice().reverse();t.forEach(i=>{const{fP:o,i:r,position:a}=i,s=t=>Fn(t,e);let c=r?n.find(t=>t.i<r&&!t.truncated):void 0;if(r===t.length-1)for(;c&&a-s(i)/2-o<c.position+s(c)/2;)c.truncated=!0,c=n.find(t=>t.i<r&&!t.truncated);i.truncated=!!c&&a-s(i)/2-o<c.position+s(c)/2})}function Rn(t,e,n,i){const o=h.min([t.schema.maxSize,t.schema.width]),r=h.min([t.schema.maxSize,t.schema.height]);return e?r-n-i-t._margin.top-t._margin.bottom:o-n-i-t._margin.left-t._margin.right}function Pn(t,e){const{labels:n,rangeOuter:i,horizontal:o,hBuff:r,p:a,tickFormat:c,offset:l=1,ownSpace:u}=e,d=o&&!t._labelRotation&&Tn(t,n);t._shownLabels=n;const f={horizontal:o,hBuff:r,p:a,tickFormat:c,wholeLine:d};let m=function(t,e){const{fontSize:n}=t.schema.shapeConfig.labelConfig,i=t.schema.shapeConfig.labelConfig.fontFamily||s.fontFamily,o=t.schema.shapeConfig.labelConfig.padding,r=t._labelRotation?t._labelAngle:0,a=!!t._labelRotation&&t._labelSlant;return e.map((e,s)=>{const c="function"==typeof i?i(e,s):i,l="function"==typeof o?o(e,s):o,h="function"==typeof n?n(e,s):n,u=t._getPosition(e);return{d:e,i:s,fF:c,fP:l,fS:h,lineHeight:t.schema.shapeConfig.lineHeight?t.schema.shapeConfig.lineHeight(e,s):1.4*h,position:u,rotate:t._labelRotation,angle:r,slant:a}})}(t,n);const p=function(t,e,n){return"band"===t.schema.scale?t._d3Scale.bandwidth():e.reduce((i,o,r)=>{const{position:a}=o,s=r?a-(a-e[r-1].position):1===e.length?n[0]:a-(e[r+1].position-a),c=Math.abs(a-s),l=r==e.length-1?1===e.length?n[1]:a+(a-e[r-1].position):a-(a-e[r+1].position),u=Math.abs(a-l),d="point"===t.schema.scale?1:2;return h.max([h.max([c,u])*d,i])},0)}(t,m,i);f.slantWidth=function(t,e,n){const i=e[0];if(!i?.slant)return;const{horizontal:o,hBuff:r,p:a,tickFormat:s,space:c}=n,l=e=>t.schema.shapeConfig.lineHeight?t.schema.shapeConfig.lineHeight(e.d,e.i):Math.ceil(1.4*e.fS),h=Dn(i.angle,o,Rn(t,o,r,a),c-2*i.fP,l(i));return Ln(e.map(t=>({text:s(t.d),fontFamily:t.fF,fontSize:t.fS,lineHeight:l(t)})),((t,e)=>Math.max(1,Math.min(3,Math.floor(t/e+1e-9))))(h.height,l(i)),h.width)}(t,m,{...f,space:p});const g=u?function(t,e){return t.length<2?t.map(()=>Math.abs(e[e.length-1]-e[0])):t.map((e,n)=>{const i=[t[n-1],t[n+1]].filter(t=>void 0!==t).map(t=>Math.abs(e-t));return Math.min(...i)})}(m.map(t=>t.position),i):void 0,y=new Map,x=(e,n=(g?g[e.i]:p)-2*e.fP)=>{e.space=n;const{lines:i,widths:r,width:a,height:c,fits:l}=function(t,e,n,i){const{horizontal:o,hBuff:r,p:a,tickFormat:c}=n,{d:l,i:u,fF:d,fP:f,fS:m,rotate:p,space:g,angle:y,slant:x}=e,b=p?"width":"height",_=p?"height":"width",k=t.schema.shapeConfig.lineHeight?t.schema.shapeConfig.lineHeight(l,u):void 0,v=c(l),w=h.min([t.schema.maxSize,t.schema.width]),M=Rn(t,o,r,a),S=x?Dn(y,o,M,g,k??Math.ceil(1.4*m)):void 0,C=i&&JSON.stringify([v,d,f,m,k,p,x&&y,x&&n.slantWidth,g]),$=C?i.get(C):void 0;if($)return{...$,lines:$.lines.slice(),widths:$.widths.slice()};const A=s.textWrap().fontFamily(d).fontSize(m).lineHeight(k);let z,D;return S?A.split(yn).width(Math.min(S.width,n.slantWidth??1/0)).height(S.height):(A[_](o?g:M),A[b](o?M:g)),n.wholeLine?(A.width(t.schema.width-2*a),z=A(v),D=!z.truncated&&z.lines.filter(t=>""!==t).length<=1):(z=A(v),D=xn(z,()=>A.split(yn)(v)).fits,o&&!p&&`${v}`.trim()&&!z.lines.some(t=>""!==t)&&(A.width(w-2*a),z=A(v))),z.fits=D,z.lines=z.lines.filter(t=>""!==t),z.width=z.lines.length?Math.ceil(h.max(z.widths)):0,z.height=z.lines.length?Math.ceil(z.lines.length*A.lineHeight())+f:0,C&&i.set(C,{lines:z.lines.slice(),widths:z.widths.slice(),width:z.width,height:z.height,fits:D}),z}(t,e,f,y);return o&&!e.rotate?e.space=Math.max(e.space,Math.ceil(a)):!o&&!e.rotate&&c-e.fP>e.space&&(e.space=Math.ceil(c)),Object.assign(e,{lines:i,widths:r,width:a,height:c,fits:l})};m=m.map(t=>x(t));const b=(e,n=e)=>{t._shownLabels=e.map(t=>t.d),n.forEach(t=>x(t))};return On(t.schema.scale)?Bn(m,o,d?(t,e)=>{const n=m.filter((e,n)=>n%t===0);b(n,e?m:n)}:void 0):g&&o&&!t._labelRotation?Nn(m,g,t._d3Scale.range(),x):d?function(t,e,n){let i=t;for(let o=0;o<4;o++){En(t,e);const o=t.filter(t=>!t.truncated);if(o.length===i.length&&o.every((t,e)=>t===i[e]))return;i=o,n(i,t)}}(m,o,b):En(m,o),l>1&&function(t=[],e){let n=0;t.forEach(i=>{const o=t[i.i-1],r=i.rotate&&e||!i.rotate&&!e?"width":"height",a=i.rotate&&e||!i.rotate&&!e?"height":"width";o?o.position+o[a]/2>i.position-i[a]/2&&(n?(i.offset=o[r],n=0):n=1):n=1})}(m,o),m}function Tn(t,e){const{scale:n}=t.schema;return"time"===n||On(n)&&e.length>0&&e.every(t=>t instanceof Date||!isNaN(t))}function On(t){return["band","ordinal","point"].includes(t)}function Wn(t,e){return t.slant?function(t,e,n,i){const o=Sn(t,e);return n*Math.sin(o)+i*Math.cos(o)}(t.angle,e,t.width,t.height-t.fP)+(e?t.fP:0):t[t.rotate||!e?"width":"height"]}const Hn=t=>"function"==typeof t&&"brokenSpec"in t;function jn(t,e,n){if(!Array.isArray(t)||!t.length)return[];const i=(Array.isArray(t[0])?t:[t]).filter(t=>Array.isArray(t)&&2===t.length).map(t=>t.map(Number)).filter(t=>t.every(Number.isFinite)&&t[0]!==t[1]).map(t=>t[0]<t[1]?[t[0],t[1]]:[t[1],t[0]]).sort((t,e)=>t[0]-e[0]),o=[];for(const t of i){const e=o[o.length-1];e&&t[0]<=e[1]?e[1]=Math.max(e[1],t[1]):o.push([t[0],t[1]])}return o.filter(([t,i])=>t>e&&i<n)}function In(t){const[e,n]=t.domain,i=Math.min(e,n),o=Math.max(e,n),r=e<=n?t.range[0]:t.range[1],a=e<=n?t.range[1]:t.range[0],s=Math.sign(a-r)||1,c=t.breaks.reduce((t,[e,n])=>t+n-e,0),l=(Math.abs(a-r)-t.breaks.length*t.space)/(o-i-c),h=[i],u=[r];let d=i;for(const[e,n]of t.breaks){const i=u[u.length-1]+s*l*(e-d);h.push(e,n),u.push(i,i+s*t.space),d=n}return h.push(o),u.push(a),{values:h,pixels:u}}function Gn(t){let{values:e,pixels:n}=In(t),i=c.scaleLinear().domain(e).range(n);const o=e=>{const n=+e,o=(e=>{const n=t.edge;if(!n)return;const i=(e-n.value)/(n.edge-n.value);return i<1?i<=0?n.position:n.position+i*(n.edgePosition-n.position):void 0})(n);return void 0!==o?o:i(n)},r=()=>{({values:e,pixels:n}=In(t)),i=c.scaleLinear().domain(e).range(n)};return o.brokenSpec=t,o.domain=e=>void 0===e?t.domain.slice():(t.domain=Array.from(e,Number),r(),o),o.range=e=>void 0===e?t.range.slice():(t.range=Array.from(e,Number),r(),o),o.copy=()=>Gn({...t,breaks:t.breaks.map(t=>[t[0],t[1]])}),o.invert=e=>{const n=t.edge;if(n){const t=(e-n.position)/(n.edgePosition-n.position);if(t<=0)return n.value;if(t<1)return n.value+t*(n.edge-n.value)}return i.invert(e)},o.segments=()=>{const i=[];for(let t=0;t<e.length;t+=2)i.push({domain:[e[t],e[t+1]],range:[n[t],n[t+1]]});return t.domain[0]>t.domain[1]?i.reverse().map(t=>({domain:[t.domain[1],t.domain[0]],range:[t.range[1],t.range[0]]})):i},o.ticks=n=>c.scaleLinear().domain([e[0],e[e.length-1]]).ticks(n).filter(e=>!t.breaks.some(([t,n])=>e>t&&e<n)),o}function qn(t,e,n){const i=new Set,o=[],r=t=>{const e=Number(t);i.has(e)||(i.add(e),o.push(t))},a=new Set(t.brokenSpec.breaks.flat());for(const i of t.segments()){const t=c.scaleLinear().domain(i.domain).range(i.range),o=e(t);o.forEach(r);const s=o.map(Number);i.domain.filter(t=>a.has(t)&&!s.includes(t)).forEach(e=>{n&&!n(e,s,t)||r(e)})}return o}const Vn=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function Yn(t,e="breakConfig"){return Kn(t.schema[e])}function Kn(t){const e=t||{};return{angle:Vn(e.angle,30),gap:Math.max(0,Vn(e.gap,5)),size:Math.max(0,Vn(e.size,10)),space:Math.max(0,Vn(e.space,36)),mask:!1!==e.mask,lines:!1!==e.lines}}const Un=t=>Yn(t,"baselineBreakConfig");function Xn(t,e){const{baseline:n,baselineBreak:i,scale:o}=t.schema;if(!i||"linear"!==o||!t._d3Scale)return null;if("number"!=typeof n||!Number.isFinite(n))return null;const r=t._d3Scale.domain().map(Number);if(2!==r.length||r.some(t=>!Number.isFinite(t)))return null;const a=Math.min(r[0],r[1]),s=Math.max(r[0],r[1]);if(a===s||n>=a&&n<=s)return null;const c=n<a?a:s,l=r[0]===c?0:1,h=e[l],u=e[1-l],{space:d}=Un(t);if(!d||Math.abs(u-h)<=2*d)return null;return{value:n,position:h,edge:c,edgePosition:h+Math.sign(u-h)*d}}function Zn(t,e){if(t._baselineBreak=Xn(t,e),t._breaks=[],"linear"!==t.schema.scale||!t._d3Scale)return;const n=t._baselineBreak,i=t._d3Scale.domain().map(Number),o=e.slice(0,2).map(t=>n&&t===n.position?n.edgePosition:t),{space:r,mask:a}=Yn(t);let s=jn(t.schema.break,Math.min(...i),Math.max(...i));if(Math.abs(o[1]-o[0])-s.length*r<2*r&&(s=[]),!n&&!s.length)return;const c=Gn({domain:i,range:o,breaks:s,space:r,edge:n});t._d3Scale=c;const l="number"==typeof t.schema.baseline?t.schema.baseline:0;n&&t._breaks.push({start:n.value,end:n.edge,startPosition:n.position,endPosition:n.edgePosition,baseline:!0,mask:Un(t).mask}),s.forEach(([e,n])=>{const[i,o]=Math.abs(n-l)<Math.abs(e-l)?[n,e]:[e,n];t._breaks.push({start:i,end:o,startPosition:c(i),endPosition:c(o),baseline:!1,mask:a})})}function Qn(t,e,n=!0){const i=e.filter(e=>{const n=Number(e);return!t.some(t=>n>Math.min(t.start,t.end)&&n<Math.max(t.start,t.end))});return n&&t.forEach(t=>{t.baseline&&!i.some(e=>Number(e)===t.start)&&i.push(t.start)}),i}function Jn(t,e){const{gap:n}=Yn(t,e.baseline?"baselineBreakConfig":"breakConfig"),i=(e.startPosition+e.endPosition)/2;return[i-n/2,i+n/2]}function ti(t,e,n){const i=n(t.schema.barConfig),o=t._breaks||[];return o.length?ei(t,o,e,i,n):[{type:"line",key:"bar",points:e,paint:i}]}function ei(t,e,n,i,o){const r=t._position.horizontal,a=r?0:1,s=n[0][1-a],c=(t,e)=>r?[t,e]:[e,t],l=n.map(t=>t[a]),h=e.find(t=>t.baseline);h&&l.push(h.startPosition);const u=Math.min(...l),d=Math.max(...l),f=["top","left"].includes(t.schema.orient)?-1:1,m=e.map(e=>Jn(t,e)).sort((t,e)=>t[0]-e[0]),p=[];let g=u;m.forEach(([t,e])=>{p.push([g,t]),g=e}),p.push([g,d]);const y=h?h.startPosition<=u?0:p.length-1:-1,x=y>0;let b=0;const _=p.map(([t,e],n)=>{const o=n===y?"bar-baseline":b++?"bar-"+(b-1):"bar",r=[c(t,s),c(e,s)];return{type:"line",key:o,points:x?r.reverse():r,paint:i}});y>0&&_.unshift(..._.splice(y,1));let k=0;return e.forEach(e=>{const n=e.baseline?"baselineBreakConfig":"breakConfig",{angle:i,size:r}=Yn(t,n),a=o(t.schema[n]),l=Math.sign(e.endPosition-e.startPosition),h=i*Math.PI/180,u=Math.sin(h)*r,d=Math.cos(h)*r,m=t=>[c(t,s),c(t-l*u,s+f*d)],p=e.baseline?"baseline-break":"break-"+k++,[g,y]=Jn(t,e),[x,b]=l<0?[y,g]:[g,y];_.push({type:"line",key:`${p}-0`,points:m(x),paint:a},{type:"line",key:`${p}-1`,points:m(b),paint:a})}),_}const ni=864e5;function ii(t){if(t instanceof Date)return+t;if("number"!=typeof t&&"string"!=typeof t)return NaN;const e=r.date(t);return e instanceof Date?+e:NaN}function oi(t){return"weekends"===t||"object"==typeof(e=t)&&null!==e&&!Array.isArray(e)&&("days"in t?Array.isArray(t.days)&&t.days.every(t=>Number.isInteger(t)&&t>=0&&t<=6):"hours"in t?(n=t.hours,Array.isArray(n)&&2===n.length&&n.every(t=>"number"==typeof t&&t>=0&&t<=24)):"values"in t?Array.isArray(t.values):"bounds"in t&&(Array.isArray(t.bounds)&&2===t.bounds.length&&t.bounds.every(t=>Number.isFinite(ii(t)))));var e,n}function ri(t){if(!t)return[];return(Array.isArray(t)?t:[t]).filter(oi)}const ai=t=>"object"==typeof t&&"boolean"==typeof t.marker?t.marker:"object"==typeof t&&"bounds"in t;function si(t,e,n,i){const o=n?y.utcDay:y.timeDay;let r=o.floor(new Date(t));for(;+r<=e;){const t=o.offset(r,1);i(r,t),r=t}}function ci(t,e,n){const i=new Date(+t),o=Math.floor(e),r=Math.round(60*(e-o));return n?i.setUTCHours(o,r,0,0):i.setHours(o,r,0,0),+i}function li(t,e,n,i=!1){if(!(e<=n))return[];const o=t.flatMap(t=>function(t,e,n,i){const o=[];if("weekends"===t||"days"in t){const r=new Set("weekends"===t?[0,6]:t.days);si(e,n,i,(t,e)=>{r.has(i?t.getUTCDay():t.getDay())&&o.push([+t,+e])})}else if("hours"in t){const[r,a]=t.hours;if(r===a)return o;si(e-ni,n,i,(t,e)=>{const n=ci(t,r,i),s=ci(r<a?t:e,a,i);s>n&&o.push([n,s])})}else if("values"in t){const e=i?y.utcDay:y.timeDay;t.values.forEach(t=>{const n=ii(t);if(!Number.isFinite(n))return;const i=e.floor(new Date(n));o.push([+i,+e.offset(i,1)])})}else{const[e,n]=t.bounds.map(ii);e!==n&&o.push(e<n?[e,n]:[n,e])}return o}(t,e,n,i).map(([e,n])=>({start:e,end:n,marker:ai(t)}))).filter(t=>t.end>e&&t.start<=n).sort((t,e)=>t.start-e.start),r=[];for(const t of o){const e=r[r.length-1];e&&t.start<=e.end?(e.end=Math.max(e.end,t.end),e.marker=e.marker||t.marker):r.push({...t})}return r}function hi(t,e){let n=0,i=t.length-1,o=-1;for(;n<=i;){const r=n+i>>1;t[r].start<=e?(o=r,n=r+1):i=r-1}return o}function ui(t,e,n,i=!1){const o=li(t,e,n,i);return r=>{const a=+r;if(!Number.isFinite(a))return!1;if(a<e||a>n)return di(t,a,i);const s=hi(o,a);return s>=0&&a<o[s].end}}function di(t,e,n=!1){const i=+e;return li(t,i,i,n).some(t=>t.start<=i&&i<t.end)}function fi(t,e,n,i=!1){if(!(e<n))return 0;const o=li(t,e,n,i).reduce((t,i)=>t+Math.max(0,Math.min(n,i.end)-Math.max(e,i.start)),0);return n-e-o}function mi(t,e=!1){const n=Date.UTC(2001,0,1);return fi(t,n,n+8*ni,e)<=0}function pi(t,e,n,i=!1){if(!n||!Number.isFinite(n)||mi(t,i))return e;const o=n>0;let r=Math.abs(n),a=e,s=Math.max(2*r,7*ni);for(let e=0;e<32;e++){const e=o?a:a-s,n=o?a+s:a,c=li(t,e,n,i);for(const t of o?c:c.reverse()){const e=o?t.start-a:a-t.end;if(e>0&&(o?r<e:r<=e))return o?a+r:a-r;e>0&&(r-=e),(o?t.end>a:t.start<a)&&(a=o?t.end:t.start)}const l=o?n-a:a-e;if(l>0&&r<=l)return o?a+r:a-r;l>0&&(r-=l,a=o?n:e),s*=2}return a}const gi=t=>"function"==typeof t&&"rangeBreaks"in t,yi=(t,e,n)=>gi(t)?t.visible(e,n):+n-+e,xi=(t,e,n)=>gi(t)?t.offset(e,n):new Date(+e+n);function bi(t,e,n,i,o){const[r,a]=e,s=Math.min(r,a),c=Math.max(r,a),[l,h]=n,u=r<=a?l:h,d=r<=a?h:l,f=Math.sign(d-u)||1,m=Math.abs(d-u),p=li(t,s,c,i),g=p.map(t=>({...t,start:Math.max(t.start,s),end:Math.min(t.end,c)})).filter(t=>t.end>t.start),y=m-g.filter(t=>t.marker&&t.start>s&&t.end<c).length*o>=2*o?o:0,x=g.map(t=>({...t,space:t.marker&&t.start>s&&t.end<c?y:0})),b=x.reduce((t,e)=>t+e.end-e.start,0),_=c-s-b,k=x.reduce((t,e)=>t+e.space,0),v=!(_>0),w=v?0:(m-k)/_,M=[];let S=s,C=0;return x.forEach(t=>{C+=(t.start-S)*w,M.push(C),C+=t.space,S=t.end}),{lo:s,hi:c,start:u,dir:f,length:m,rate:w,all:p,gaps:x,at:M,empty:v}}function _i(t,e={}){const n=Boolean(e.utc),i=Math.max(0,e.space??0);let o=[+new Date(2e3,0,1),+new Date(2e3,0,2)],r=[0,1],a=bi(t,o,r,n,i);const s=()=>{a=bi(t,o,r,n,i)},l=e=>{const i=+e;if(!Number.isFinite(i))return NaN;const{start:o,dir:s,empty:c}=a;return c?(r[0]+r[1])/2:o+s*function(t,e,n,i){const{lo:o,hi:r,length:a,rate:s,gaps:c,at:l}=t;if(i<o)return-fi(e,i,o,n)*s;if(i>r)return a+fi(e,r,i,n)*s;const h=hi(c,i);if(h<0)return(i-o)*s;const u=c[h];return i<u.end?l[h]+u.space*(i-u.start)/(u.end-u.start):l[h]+u.space+(i-u.end)*s}(a,t,n,i)};l.rangeBreaks=t,l.domain=t=>void 0===t?o.map(t=>new Date(t)):(o=Array.from(t,t=>+t).slice(0,2),s(),l),l.range=t=>void 0===t?r.slice():(r=Array.from(t,Number).slice(0,2),s(),l),l.copy=()=>_i(t,e).domain(o).range(r),l.invert=e=>function(t,e,n,i){const{lo:o,hi:r,start:a,dir:s,rate:c,gaps:l,at:u,empty:d}=t;if(d||!c)return new Date(o);const f=(i-a)*s;if(f<0)return new Date(pi(e,o,f/c,n));const m=h.bisectRight(u,f)-1;let p;if(m<0)p=o+f/c;else{const t=l[m],e=f-u[m];p=e<t.space?t.start+e/t.space*(t.end-t.start):t.end+(e-t.space)/c}return new Date(p>r?pi(e,r,p-r,n):p)}(a,t,n,e),l.gaps=()=>a.gaps.map(t=>({...t})),l.isHidden=e=>{const i=+e,{lo:o,hi:r,all:s}=a;if(i<o||i>r)return li(t,i,i,n).some(t=>t.start<=i&&i<t.end);const c=hi(s,i);return c>=0&&i<s[c].end},l.visible=(e,i)=>{const o=+e,r=+i;return o<=r?fi(t,o,r,n):-fi(t,r,o,n)},l.offset=(e,i)=>new Date(pi(t,+e,i,n));const u=()=>(n?c.scaleUtc:c.scaleTime)().domain([a.lo,a.hi]);return l.ticks=(t=10)=>{const e=function(t,e,n,i){const{lo:o,hi:r,all:a,gaps:s,empty:c}=t;if(c)return o!==r||i.isHidden(o)?[]:[o];const l=r-o-s.reduce((t,e)=>t+e.end-e.start,0),u=Math.max(1,Math.round(e*(r-o)/l)),d=n.ticks(u).map(Number),f=new Map;for(const t of d){const e=hi(a,t),n=e>=0&&t<a[e].end,i=n?a[e].end:t;i<=r&&f.set(i,n||!0===f.get(i))}const m=d.slice(1).map((t,e)=>t-d[e]),p=m.length?h.quantile(m,.5)/2:0,g=[...f].filter(([,t])=>t).map(([t])=>t);return[...f].filter(([t,e])=>e||!g.some(e=>Math.abs(i.visible(e,t))<=p)).map(([t])=>t).sort((t,e)=>t-e)}(a,t,u(),l).map(t=>new Date(t));return o[0]>o[1]&&e.reverse(),e},l.tickFormat=(t,e)=>u().tickFormat(t,e),l}function ki(t){if(null==t)return;const e=r.date(t);return e instanceof Date&&!isNaN(+e)?e:void 0}function vi(t){return t.map(ki).filter(t=>void 0!==t)}function wi(t){if("time"!==t.schema.scale)return t._data??[];const e=function(t,e){const n=ri(t.schema.rangeBreaks);if(!n.length||!e.length)return e;const[i,o]=h.extent(e,Number),r=ui(n,i,o);return e.filter(t=>!r(t))}(t,vi(t._data??[])),n=(t.schema.domain??[]).map(ki);if(n.length<2||n.some(t=>void 0===t))return e;const[i,o]=h.extent(n);return e.filter(t=>t>=i&&t<=o)}function Mi(t,e){const[n,i]=h.extent(e.domain()).map(Number);return t.filter(t=>+t>=n&&+t<=i)}function Si(t){return t.schema.timeLocale||l.locale[t.schema.locale]||l.locale["en-US"]}function Ci(t){const{_scaleData:e,schema:{domain:n}}=t,i=t._d3Scale,o=i?.range?i.range():[];return Bi(t,"timeReference",[e,n,i,...o],()=>{const o=!e.length&&i?t._getLabels():[];return vi(e.length?e:o.length>1?o:n).sort((t,e)=>+t-+e)})}function $i(t,e){const n=Si(t),i=function(t){return"time"===t.schema.scale?Ci(t):Li(t)}(t);return(i.length?Bi(t,"dateLabel",[i,n],()=>d.dateFullFormatter(i,Ai(n)))(e):d.formatDateFull(e,[e],Ai(n))).replace(/^Q/,n.quarter)}function Ai(t){let e=zi.get(t);return e||zi.set(t,e=g.timeFormatLocale(t).format),e}const zi=new WeakMap,Di=t=>t instanceof Date&&!isNaN(+t);function Li(t){const{_scaleData:e,schema:{domain:n}}=t;return Bi(t,"dateCategories",[n,e],()=>{const t=t=>Array.isArray(t)?t.filter(Di):[],i=t(n),o=i.length?i:t(e),r=new Set;return o.filter(t=>!r.has(+t)&&!!r.add(+t)).sort((t,e)=>+t-+e)})}function Fi(t){const e=t._shownLabels;if(!e)return;const n=Ni.get(t);if(n&&n[0]===e)return n[1];const i=vi(e).sort((t,e)=>+t-+e);return Ni.set(t,[e,i]),i}const Ni=new WeakMap;function Bi(t,e,n,i){const o=n.flatMap(t=>Array.isArray(t)?[t,t.length]:[t]);let r=Ei.get(t);r||Ei.set(t,r=new Map);const a=r.get(e);if(a&&a.fingerprint.length===o.length&&a.fingerprint.every((t,e)=>t===o[e]))return a.value;const s=i();return r.set(e,{fingerprint:o,value:s}),s}const Ei=new WeakMap;function Ri(t){const e=t._d3Scale;if("time"!==t.schema.scale||!e)return;const n=ri(t.schema.rangeBreaks);if(!n.length)return;const{space:i,mask:o}=Yn(t),r=_i(n,{space:i});r.domain(e.domain()),r.range(e.range()),t._d3Scale=r,r.gaps().filter(t=>t.space>0).forEach(e=>t._breaks.push({start:e.start,end:e.end,startPosition:r(e.start),endPosition:r(e.end),baseline:!1,mask:o}))}function Pi(t,e){const n=t._d3Scale;return gi(n)?e.filter(t=>!n.isHidden(Number(t))):e}function Ti(t){const e=new Set;return t.map(t=>y.timeDay.floor(t)).filter(t=>!e.has(+t)&&!!e.add(+t)).sort((t,e)=>+t-+e)}function Oi(t){let e;return n=>{const i=function(t,e){const n=t._d3Scale,i=Number(e instanceof Date?+e:e);if(!gi(n)||!Number.isFinite(i))return;const o=y.timeDay.floor(new Date(i));return+o!==i&&0===n.visible(o,i)?o:void 0}(t,n);if(!i)return;const o=Ci(t);return e&&e.dates===o&&e.format===g.timeFormat||(e={dates:o,format:g.timeFormat,label:d.dateFormatter(Ti(o),g.timeFormat)}),e.label(i,Fi(t))}}const Wi=t=>"number"==typeof t&&t>=1e3&&t<=2999;function Hi(t){return t.length>0&&t.every(t=>Wi(t)&&Number.isInteger(t))}function ji(t){const e=t.schema.domain??[];return!(!e.length||!e.every(Wi))&&Hi(t._scaleData.length?t._scaleData:e)}function Ii(t,e="en-US"){return d.formatAbbreviate(t,e,"~f")}const Gi=t=>t<0||Object.is(t,-0),qi=t=>Math.pow(10,Math.floor(Math.log10(Math.abs(t))))*Math.pow(-1,Gi(t)?1:0),Vi=t=>Math.pow(10,Math.ceil(Math.log10(Math.abs(t))))*Math.pow(-1,Gi(t)?1:0),Yi=t=>{const e=`${t}`;if(e.includes("e-")||"0"===e)return 0;const n=e.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(n)return+`${n[1]}${+n[2]+1}`;const i=e.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return i?+`${i[1]}${+i[2]}`:t};function Ki(t,e,n){const i=t=>{if(o){if(!t)return 0;const e=`${t}`.match(/0\.(0*)/);if(e)return+`0.${Array(e[1].length+1).fill(0).join("")}1`}return`${Math.round(Math.abs(t))}`.length},o=t.every(t=>Math.abs(t)<1),r=[i(t[0]),i(t[1])].filter(Boolean).sort();if(!r.length)return;const a=t.some(t=>Gi(t))&&t.some(t=>t>0),s=1===r.length?r[0]:r[0]>1&&r[0]===r[1]?r[0]-1:"outside"!==e&&a?h.max(r):r[0]+(r[1]-r[0])/2;let c=s<1?Yi(s):+`1${Array(Math.floor(Yi(s))-1).fill(0).join("")}`;c>=Math.abs(t[1]-t[0])&&(c/=2);const l=t[1]<t[0],u=[Math["outside"===e?l?"ceil":"floor":l?"floor":"ceil"](t[0]/c)*c,Math["outside"===e?l?"floor":"ceil":l?"ceil":"floor"](t[1]/c)*c];return"log"===n&&(0===u[0]&&(u[0]=t[0]),0===u[1]&&(u[1]=t[1])),u.map(Yi)}const Ui=["linear","log","pow","sqrt"];function Xi(t,e,n){if(["linear","pow","sqrt"].includes(n))return Ki(t,e,n);if("log"===n){const i=[],o=t[1]<t[0];i[0]=("outside"===e?Gi(t[0])?o?qi:Vi:o?Vi:qi:Gi(t[0])?o?Vi:qi:o?qi:Vi)(t[0]),i[1]=("inside"===e?Gi(t[1])?o?qi:Vi:o?Vi:qi:(Gi(t[1]),o?qi:Vi))(t[1]);const r=i[1]<i[0];return i[0]!==i[1]&&i.some(t=>Math.abs(t)>10)&&r===o?i:Ki(t,e,n)}}const Zi=(t,e)=>t<0?-Math.pow(-t,e):Math.pow(t,e);function Qi(t,e){return t.map(t=>{const n=Math.min(...e.map(e=>Math.abs(e-t)).filter(t=>t>0));return function(t,e){if(!(e>0&&Number.isFinite(e)))return t;let n=Math.floor(Math.log10(Math.max(Math.abs(t),e)))+1;for(;n>-30;n--)for(const i of[5,2,1]){const o=i*Math.pow(10,n),r=Math.round(t/o)*o;if(Math.abs(r-t)<=e)return+r.toPrecision(12)}return t}(t,n/3)})}function Ji(t,e,n){let i,o,r;const a=(n,i)=>(r&&r.dates===n&&r.format===g.timeFormat||(r={dates:n,format:g.timeFormat,label:d.dateFormatter(n,g.timeFormat)}),r.label(i,Fi(t)).replace(/^Q/g,e.quarter)),s=Oi(t),c=t.schema.tickFormat;return c?e=>c.call(t,e):e=>{if(Di(e)&&(t=>["band","ordinal","point"].includes(t.schema.scale))(t))return a(o??(o=Li(t)),e);if(isNaN(e)||["band","ordinal","point"].includes(t.schema.scale))return e;if("time"===t.schema.scale)return s(e)??a(Ci(t),e);if("linear"===t.schema.scale&&"smallest"===t.schema.tickSuffix){const n="object"==typeof t.schema.locale?t.schema.locale:l.formatLocale[t.schema.locale],{separator:i,suffixes:o}=n,r=e>=1e3?o[t._tickUnit+8]:"",a=e/Math.pow(10,3*t._tickUnit);return`${d.formatAbbreviate(a,n,`,.${a.toString().length}r`)}${i}${r}`}{const o=n(),r=o[1]<o[0],a=r?o.length-1:0,s=r?0:o.length-1,c="inside"===t.schema.rounding?o.indexOf(e)===a?t.schema.roundingInsideMinPrefix:o.indexOf(e)===s?t.schema.roundingInsideMaxPrefix:"":"",l="inside"===t.schema.rounding?o.indexOf(e)===a?t.schema.roundingInsideMinSuffix:o.indexOf(e)===s?t.schema.roundingInsideMaxSuffix:"":"";i??(i=ji(t));return`${c}${i?Ii(e,t.schema.locale):d.formatAbbreviate(e,t.schema.locale)}${l}`}}}function to(t){const{labels:e}=t.schema;return Array.isArray(e)&&e.length&&e.every(Array.isArray)?e:void 0}function eo(t,e,n,i){const o=function(t,e,n){let i=n?n.slice():[],[o,r]=e;t.schema.range&&(void 0!==t.schema.range[0]&&(o=t.schema.range[0]),void 0!==t.schema.range[t.schema.range.length-1]&&(r=t.schema.range[t.schema.range.length-1])),(void 0===i[0]||i[0]<o)&&(i[0]=o),(void 0===i[1]||i[1]>r)&&(i[1]=r);const a=r-o;if("ordinal"===t.schema.scale&&t.schema.domain.length>i.length)if(n===t.schema.range){const e=t.schema.domain.length+1;i=h.range(e).map(t=>i[0]+a*(t/(e-1))).slice(1,e),i=i.map(t=>t-i[0]/2)}else{const e=t.schema.domain.length,n=i[1]-i[0];i=h.range(e).map(t=>i[0]+n*(t/(e-1)))}return i}(t,e,void 0!==i?i:t.schema.range),r=`scale${t.schema.scale.charAt(0).toUpperCase()}${t.schema.scale.slice(1)}`,a=t.schema.domain.slice();var s;if(t._d3Scale=E[r]().domain("time"===t.schema.scale?function(t){const e=t.schema.domain.map(ki),n=t._scaleData;return e.some(t=>void 0===t)&&n.length?h.extent(n):e}(t):a).range(o),"pow"===t.schema.scale&&t._d3Scale.exponent&&t._d3Scale.exponent("number"==typeof(s=t.schema.exponent)&&Number.isFinite(s)&&s>0?s:1),"none"!==t.schema.rounding){const e=Xi(a,t.schema.rounding,t.schema.scale);e&&t._d3Scale.domain(e)}t.schema.reverse&&t._d3Scale.domain(t._d3Scale.domain().slice().reverse()),t._d3Scale.padding&&t._d3Scale.padding(t.schema.scalePadding),t._d3Scale.align&&t._d3Scale.align(t.schema.scaleAlign),t._d3Scale.paddingInner&&t._d3Scale.paddingInner(t.schema.paddingInner),t._d3Scale.paddingOuter&&t._d3Scale.paddingOuter(t.schema.paddingOuter),t._d3ScaleNegative=null,"log"===t.schema.scale&&function(t){const e=t._d3Scale.domain(),n=t._scaleData;if(0===e[0]){const t=h.min([h.min(n),Math.abs(e[1])]);e[0]=0===t||1===t?1e-6:t<=1?qi(t):1,Gi(e[1])&&(e[0]*=-1)}else if(0===e[e.length-1]){const t=h.min([h.min(n),Math.abs(e[0])]);e[e.length-1]=0===t||1===t?1e-6:t<=1?qi(t):1,Gi(e[0])&&(e[e.length-1]*=-1)}const i=t._d3Scale.range();if(Gi(e[0])&&Gi(e[e.length-1]))t._d3ScaleNegative=t._d3Scale.copy().domain(e).range(i),t._d3Scale=null;else if(e[0]>0&&e[e.length-1]>0)t._d3Scale.domain(e).range(i);else{const o=e.map(t=>Math.log10(Math.abs(t))).map(t=>t||-1e-6),r=o[0]/h.sum(o)*(i[1]-i[0]);let a=h.min([h.min(n.filter(t=>t>=0)),Math.abs(e[1])]);1===a&&(a=1e-6);let s=h.min([h.min(n.filter(Gi)),Math.abs(e[0])]);1===s&&(s=1e-6);const c=0===a?1e-6:a<=1?qi(a):1,l=0===s?-1e-6:s<=1?qi(s):1,u=h.min([Math.abs(c),Math.abs(l)]);t._d3ScaleNegative=t._d3Scale.copy(),(Gi(e[0])?t._d3Scale:t._d3ScaleNegative).domain([Gi(e[0])?u:-u,e[1]]).range([i[0]+r,i[1]]),(Gi(e[0])?t._d3ScaleNegative:t._d3Scale).domain([e[0],Gi(e[0])?-u:u]).range([i[0],i[0]+r])}}(t),Zn(t,o),Ri(t);const{ticks:c,labels:l}=function(t){const e=to(t),n=e?e[Math.min(t._labelSet??0,e.length-1)]:t.schema.labels,i=t.schema.ticks||(e?n:void 0);let o=(i?"time"===t.schema.scale?vi(i):i:(t._d3Scale?t._d3Scale.ticks:t._d3ScaleNegative?.ticks)?t._getTicks():t.schema.domain).slice(),r=(n?"time"===t.schema.scale?vi(n):n:(t._d3Scale?t._d3Scale.ticks:t._d3ScaleNegative?.ticks)?t._getLabels():o).slice();return"time"===t.schema.scale&&(o=o.map(Number),r=r.map(Number)),o=Pi(t,o),r=Pi(t,r),t._breaks.length&&(o=Qn(t._breaks,o),r=Qn(t._breaks,r,!n)),o=o.sort((e,n)=>t._getPosition(e)-t._getPosition(n)),r=r.sort((e,n)=>t._getPosition(e)-t._getPosition(n)),{ticks:o,labels:r}}(t);!function(t,e){if("linear"===t.schema.scale&&"smallest"===t.schema.tickSuffix){const n=e.filter(t=>t>=1e3);if(n.length>0){const e=Math.min(...n);let i=1;for(;i&&i<7&&e/Math.pow(10,3*i)>=1;)t._tickUnit=i,i+=1}}}(t,l);const u=function(t,e,n){const i=[];return t._availableTicks=e,e.forEach((e,o)=>{let r=n({id:e,tick:!0},o);"Circle"===t.schema.shape&&(r*=2);const a=t._getPosition(e);!i.length||Math.abs(f.closest(a,i.filter(t=>!1!==t))-a)>2*r?i.push(a):i.push(!1)}),e=e.filter((t,e)=>!1!==i[e]),t._visibleTicks=e,e}(t,c,n);return{range:o,ticks:u,labels:l}}function no(t){const e=Si(t);g.timeFormatDefaultLocale(e);const{width:n,height:i,x:o,y:r,horizontal:a,opposite:c}=t._position,l=t.schema.padding,u=[l,t.schema[n]-l],d="Circle"===t.schema.shape?t.schema.shapeConfig.r:"Rect"===t.schema.shape?t.schema.shapeConfig[n]:t.schema.shapeConfig.strokeWidth,f="function"!=typeof d?()=>d:d,m=t._margin={top:0,right:0,bottom:0,left:0};!function(t){Ei.delete(t)}(t),t._scaleData=wi(t);let p=[],y=[],x=[];const b=function(t,e,n){const i=Ji(t,e,n),o=t.schema.rotatedTickFormat;return o?e=>(t._labelRotation?o:i)(e):i}(t,e,()=>x);t._labelFormat=b;const _=e=>({range:y,ticks:x,labels:p}=eo(t,u,f,e));t._labelSet=0,_(),function(t,e){if(!t.schema.title)return;const{range:n,p:i,height:o,margin:r}=e,{fontFamily:a,fontSize:c,lineHeight:l}=t.schema.titleConfig,h=s.textWrap().fontFamily("function"==typeof a?a():a).fontSize("function"==typeof c?c():c).lineHeight("function"==typeof l?l():l).width(n[n.length-1]-n[0]-2*i).height(t.schema[o]-t.schema.tickSize-2*i),u=h(t.schema.title).lines.length;r[t.schema.orient]=u*h.lineHeight()+i}(t,{range:y,p:l,height:i,margin:m});const{hBuff:k,wBuff:v}=function(t,e,n,i){let o="Circle"===t.schema.shape?"function"==typeof t.schema.shapeConfig.r?t.schema.shapeConfig.r({tick:!0}):t.schema.shapeConfig.r:"Rect"===t.schema.shape?"function"==typeof t.schema.shapeConfig[i]?t.schema.shapeConfig[i]({tick:!0}):t.schema.shapeConfig[i]:t.schema.tickSize,r=n({tick:!0});return"Rect"===t.schema.shape&&(o/=2),"Circle"!==t.schema.shape&&(r/=2),{hBuff:o,wBuff:r}}(t,0,f,i),w=a&&!On(t.schema.scale)&&so(t,p,b),M={rangeOuter:u,horizontal:a,hBuff:k,p:l,tickFormat:b,rescale:_,ownSpace:w},S=t._labelRotationSetting;oo(t,function(t,e){return wn(t)?{rotate:!0,angle:_n(t),slant:Mn(t,e)}:kn}(S,a));let C=ro(t,{range:y,labels:p},M);const $=to(t)?.length??0;for(let e=1;e<$&&co(C);e++)t._labelSet=e,C=ro(t,_(),M);void 0===S&&a&&(C=function(t,e,n){const{labels:i,tickFormat:o,ownSpace:r,rangeOuter:a,relayout:s}=n,c=Tn(t,i),l=so(t,i,o)?t=>co(t):c?t=>t.length&&!t[0].fits?1:0:void 0,h=l?l(e):0;if(!l||!h||r&&2*h<e.length)return e;let u={turn:kn,misses:h,data:e},d=kn;for(const e of[{rotate:!0,angle:vn(t.schema.orient),slant:!0},{rotate:!0,angle:-90,slant:!1}]){oo(t,d=e);const n=s(),i=l(n)+(c&&n[0]?.truncated?1:0)+(e.slant&&io(t,n,a).some(t=>t>1)?1:0);if(i<u.misses&&(u={turn:e,misses:i,data:n}),!i)break}return u.turn===d?u.data:(oo(t,u.turn),s())}(t,C,{labels:p,tickFormat:b,ownSpace:w,rangeOuter:u,relayout:()=>ro(t,_(),M)})),function(t,e,n){const i=new Set(e.filter(t=>t.truncated).map(t=>t.d));i.size&&(t._visibleTicks=n.filter(t=>!i.has(t)))}(t,C,x),t._labelOverflow=io(t,C,y);const A=h.max(C,t=>t.height)||0;!function(t,e){const n=t.schema.labelOffset?h.max(e,t=>t.offset||0):0;e.forEach(t=>t.offset=t.offset?n:0)}(t,C);const z=function(t,e){const{textData:n,rangeOuter:i,hBuff:o,horizontal:r,p:a,width:s,height:c,x:l,y:u,opposite:d,margin:f}=e,m="Line"===t.schema.shape?0:o,p=t._outerBounds={[c]:(h.max(n,t=>Math.ceil(Wn(t,r)+(t.offset??0)))||0)+(n.length?a:0),[s]:i[i.length-1]-i[0],[l]:i[0]};return p[c]="number"==typeof t.schema.fixedSize?t.schema.fixedSize:h.max([t.schema.minSize,p[c]]),t._labelSpace=p[c],f[t.schema.orient]+=o,f[d]=void 0!==t.schema.gridSize?h.max([t.schema.gridSize,m]):t.schema[c]-f[t.schema.orient]-p[c]-a,p[c]+=f[d]+f[t.schema.orient],p[u]="start"===t.schema.align?t.schema.padding:"end"===t.schema.align?t.schema[c]-p[c]-t.schema.padding:t.schema[c]/2-p[c]/2,p}(t,{textData:C,rangeOuter:u,hBuff:k,horizontal:a,p:l,width:n,height:i,x:o,y:r,opposite:c,margin:m});return{ticks:x,labels:p,range:y,textData:C,tickFormat:b,hBuff:k,wBuff:v,tickGet:f,labelHeight:A,bounds:z}}function io(t,e,n){const i=e.filter(t=>!t.truncated&&t.slant);if(!i.length)return[0,0];const o=Math.min(n[0],n[n.length-1]),r=Math.max(n[0],n[n.length-1]),a=e=>zn(t.schema.orient,e.angle,e.width,e.height-e.fP),s=i[0],c=i[i.length-1];return[Math.max(0,a(s)[0]-(s.position-o)),Math.max(0,a(c)[1]-(r-c.position))]}function oo(t,e){t._labelRotation=e.rotate,t._labelAngle=e.angle,t._labelSlant=e.slant}function ro(t,e,n){const{rangeOuter:i,horizontal:o,hBuff:r,p:a,tickFormat:s,rescale:c,ownSpace:l}=n;let{labels:h}=e,u=Pn(t,{labels:h,rangeOuter:i,horizontal:o,hBuff:r,p:a,tickFormat:s,ownSpace:l});const d=t.schema.labelOffset&&u.some(t=>t.truncated);d&&(u=Pn(t,{labels:h,rangeOuter:i,horizontal:o,hBuff:r,p:a,tickFormat:s,ownSpace:l,offset:2}));let[f,m]=e.range;for(let e=0;e<3;e++){const e=u.filter(t=>!t.truncated),n=[0,1].map(n=>{const r=e[n?e.length-1:0];if(!r)return 0;const{height:a,position:s,rotate:c,width:l}=r,h=n?i[1]:i[0],u=r.slant?zn(t.schema.orient,r.angle,l,a-r.fP)[n]:(c||!o?a:l)/2,d=n?h-s:s-h;return d>=u?0:u-d}),p=m-f-(i[1]-i[0])/2,g=n[0]+n[1],y=g>p&&e.some(t=>t.slant)?Math.max(0,p)/g:1,x=[f+n[0]*y,m-n[1]*y];if(t.schema.range&&(void 0!==t.schema.range[0]&&(x[0]=t.schema.range[0]),void 0!==t.schema.range[t.schema.range.length-1]&&(x[1]=t.schema.range[t.schema.range.length-1])),x[0]===f&&x[1]===m)break;const b=ao(u);if([f,m]=x,({labels:h}=c(x)),u=Pn(t,{labels:h,rangeOuter:i,horizontal:o,hBuff:r,p:a,tickFormat:s,ownSpace:l,offset:d?2:1}),ao(u)===b&&!u.some(t=>t.slant))break}return u}function ao(t){const e=t.filter(t=>!t.truncated);return[e[0],e[e.length-1]].map(t=>t?`${t.d instanceof Date?+t.d:t.d}`:"").join(",")}function so(t,e,n){const i=t=>!(t instanceof Date)&&isNaN(t);return On(t.schema.scale)?e.some(i):Array.isArray(t.schema.labels)&&!!n&&e.some(t=>i(n(t)))}function co(t){return t.filter(t=>!t.fits||t.truncated).length}function lo(t){if(t._theme)return t._theme.background;const e=t._select,n=e&&"function"==typeof e.node?e.node():null;return n?r.backgroundColor(n):"rgb(255, 255, 255)"}function ho(t,n={}){return e.colorContrast(t,n)===(n.dark||e.colorDefaults.dark)?e.colorGray[200]:e.colorGray[800]}function uo(t){return t._theme?.text??e.colorContrast(lo(t),t.schema.colorDefaults)}function fo(t){return t._theme?.axis??uo(t)}function mo(t){return t._theme?.gridline??ho(lo(t),t.schema.colorDefaults)}function po(t,n){if(!n)return e.colorLegible(t);const o=i.hsl(t);return Number.isFinite(o.l)?(o.l<.65&&(o.l=.65),o.toString()):t}const go=t=>"function"==typeof t._preDraw;function yo(t,e,n=new WeakSet){if(!n.has(t)){n.add(t),t._theme=e;for(const i of[...Object.values(t),...Object.values(t.ctx)])i instanceof Kt&&!go(i)&&yo(i,e,n)}}function xo(t){return()=>fo(t)}function bo(t){return{angle:30,gap:5,lineConfig:{},lines:!0,mask:!0,size:10,space:36,stroke:xo(t),"stroke-width":1}}function _o(t,e,n,i=0){const o=e=>{if("function"==typeof e)try{return e.call(t,n,i)}catch{return}return e},r={},a=o(e.stroke);null!=a&&(r.stroke=String(a));const s=o(e["stroke-width"]);null!=s&&(r.strokeWidth=Number(s));const c=o(e["stroke-opacity"]);null!=c&&(r.strokeOpacity=Number(c));const l=o(e["stroke-linecap"]);null!=l&&(r.strokeLinecap=l);const h=o(e["stroke-dasharray"]);if(null!=h){const t=String(h).split(/[\s,]+/).map(Number).filter(t=>Number.isFinite(t));t.length&&(r.strokeDasharray=t)}const u=o(e.opacity);null!=u&&(r.opacity=Number(u));const d=o(e.fill);return null!=d&&(r.fill=String(d)),r}function ko(t){if(!t._d3Scale&&!t._d3ScaleNegative)return null;const{height:e,x:n,y:i,opposite:o}=t._position,r=t._margin[o],a=["top","left"].includes(t.schema.orient)?t._outerBounds[i]+t._outerBounds[e]-r:t._outerBounds[i]+r,s="point"===t.schema.scale&&t._d3Scale.align?t._d3Scale.align():.5,c="band"===t.schema.scale?t._d3Scale.step()-t._d3Scale.bandwidth():"point"===t.schema.scale?t._d3Scale.step()*t._d3Scale.padding()*2*s:0,l="band"===t.schema.scale?t._d3Scale.step():"point"===t.schema.scale?t._d3Scale.step()*t._d3Scale.padding()*2*(1-s):0,h=(t._d3ScaleNegative?t._d3ScaleNegative.domain():[]).concat(t._d3Scale?t._d3Scale.domain():[]).sort((t,e)=>t-e);if(!h.length)return null;const u=t._getPosition(h[0])-c,d=t._getPosition(h[h.length-1])+l;return{points:"x"===n?[[u,a],[d,a]]:[[a,u],[a,d]]}}function vo(t,e,n,i=.5){if(e.length<3)return!1;const o=e.map(n).sort((t,e)=>t-e),r=n(t);if(![r,...o].every(Number.isFinite))return!1;const a=o.length-1,s=Math.abs(r-o[0])<=Math.abs(r-o[a]),c=s?o[0]:o[a],l=s?o[1]:o[a-1],h=Math.abs(c-l);return!!h&&Math.abs(r-c)-h*i<=1e-9*h}const wo=936e5;function Mo(t,e,n){const i=E.scaleLinear().domain([200,1200]).range([8,28]),o=t.range(),r=Math.abs(o[1]-o[0]);let a=Math.floor(i(r));if("time"===this.schema.scale)if(n.length){const t=h.extent(n),i=n.reduce((t,e,n,i)=>{if(n){const o=Math.abs(e-i[n-1]);o<t&&(t=o)}return t},1/0),o=Math.round((t[1]-t[0])/i);a=h.min([a*(e?2:.5),o])}else a=e?2*a:a/2;return Math.floor(a)}function So(t,e=!1){if(Hn(t))return qn(t,t=>So.call(this,t,e),e?void 0:(t,e,n)=>!vo(t,e,t=>n(t)));let n;const i=t.copy(),o="time"===this.schema.scale?Mi(this._scaleData,t):[];if(o.length){const e=h.extent(o),n=e.map(e=>t(e));i.domain(e).range(n)}const a=i.domain(),s=a[1]<a[0],c=Mo.call(this,i,e,o);if(e||"log"!==this.schema.scale){if(i.exponent&&1!==i.exponent())n=function(t,e,n,i=!1){const[o,r]=t.map(Number),a=Math.min(o,r),s=Math.max(o,r);if(!Number.isFinite(a)||!Number.isFinite(s)||a===s||!e)return a===s&&Number.isFinite(a)?[a]:[];const c=Math.max(1,Math.round(n)),l=Zi(a,e),h=Zi(s,e),u=t=>Array.from({length:t+1},(n,i)=>Zi(l+(h-l)*i/t,1/e)),d=u(c),f=Qi(d,d);let m=f;if(i){const t=u(2*c),e=t.filter((t,e)=>e%2);m=f.concat(Qi(e,t))}const p=Array.from(new Set(m)).filter(t=>t>=a&&t<=s).sort((t,e)=>t-e);return r<o?p.reverse():p}(a,i.exponent(),Math.max(1,c/2),e);else if(n=i.ticks(c),!e&&!["log","time"].includes(this.schema.scale)&&n.length>1){const t=Math.abs(2*Yi(n[1]-n[0]));n=n.filter(e=>{const n=Math.abs(e)%t,i=Yi(n);return i!==n?!i||i===t:0===n})}}else{const t=a.map(t=>Math.log10(t)%1==0?t:(s?Vi:qi)(t)),e=t[1]<t[0],o=t.map(t=>(Gi(t)?-1:1)*([-1,1].includes(t)||Math.abs(t)<1?1:Math.log10(Math.abs(t)))),r=Math.ceil((Math.abs(o[1]-o[0])+1)/(.65*c));n=r<=1&&o[0]===o[1]||e!==s?i.ticks(c).filter(t=>+`${t}`.replace("0.","")%2==0):h.range(o[0],o[1],o[1]<o[0]?-1:1).concat([o[1]]).filter(t=>Math.abs(t)%r===0).map(t=>+(""+(Gi(t)?-1:1)*(t?Math.pow(10,Math.abs(t)):Math.sign(1/t)>0?1:-1)).replace(/9+/g,"1"))}if("time"===this.schema.scale&&this._scaleData.length){const t=this._scaleData.map(Number);n=n.filter(e=>{const n=+e;return t.find(t=>t>=n-wo&&t<=n+wo)})}return function(t,e,n,i,o){if(!1===t.schema.domainTicks)return e;const a=n[1]<n[0],s=e.map(Number),c=(t.schema.ticks??[]).map(e=>Number("time"===t.schema.scale?r.date(e):e)),l=t=>!e.map(Number).includes(Number(t))&&(!o||c.includes(Number(t))||!vo(Number(t),s,t=>i(t))),h=n=>!t._d3ScaleNegative||Gi(n)===e.some(t=>Gi(t));return h(n[a?1:0])&&l(n[0])&&e.unshift(n[0]),h(n[a?0:1])&&l(n[1])&&e.push(n[1]),e}(this,n,a,i,!e)}function Co(t,e,n){const{x:i,y:o,width:r,height:a}=An(t.schema.orient,e.angle,e.width,e.height-e.fP,e.height,n);return{x:i,y:o,width:r,height:a}}function $o(t,e,n){const{fP:i,fS:o,lineHeight:r,lines:a,width:s}=e,c=r*a.length;return{x:-s/2+((e.angle??-90)>0?-1:1)*(o/4),y:"bottom"===t.schema.orient?n+(s-c)/2+i:n-(s+c)/2-2*i,width:s,height:e.height}}const Ao=[{key:"align",coerce:"identity",default:"middle"},{key:"baseline",coerce:"identity",default:0},{key:"baselineBreak",coerce:"identity",default:!1},{key:"break",coerce:"identity",default:!1},{key:"domain",coerce:"identity",default:[0,10]},{key:"domainTicks",coerce:"identity",default:!0},{key:"duration",coerce:"identity",default:600},{key:"exponent",coerce:"identity",default:1},{key:"grid",coerce:"identity"},{key:"gridLog",coerce:"identity",default:!1},{key:"gridSize",coerce:"identity"},{key:"height",coerce:"identity",default:400},{key:"labels",coerce:"identity"},{key:"labelOffset",coerce:"identity",default:!1},{key:"fixedSize",coerce:"identity"},{key:"maxSize",coerce:"identity"},{key:"minSize",coerce:"identity"},{key:"padding",coerce:"identity",default:5},{key:"paddingInner",coerce:"identity",default:.1},{key:"paddingOuter",coerce:"identity",default:.1},{key:"range",coerce:"identity"},{key:"rangeBreaks",coerce:"identity",default:!1},{key:"renderMode",coerce:"identity",default:"full"},{key:"reverse",coerce:"identity",default:!1},{key:"rotatedTickFormat",coerce:"identity"},{key:"rounding",coerce:"identity",default:"none"},{key:"roundingInsideMinPrefix",coerce:"identity",default:"< "},{key:"roundingInsideMinSuffix",coerce:"identity",default:""},{key:"roundingInsideMaxPrefix",coerce:"identity",default:""},{key:"roundingInsideMaxSuffix",coerce:"identity",default:"+"},{key:"scale",coerce:"identity",default:"linear"},{key:"scaleAlign",coerce:"identity",default:.5},{key:"scalePadding",coerce:"identity",default:.5},{key:"shape",coerce:"identity",default:"Line"},{key:"tickFormat",coerce:"identity"},{key:"ticks",coerce:"identity"},{key:"tickSize",coerce:"identity",default:8},{key:"tickSuffix",coerce:"identity",default:"normal"},{key:"timeLocale",coerce:"identity",default:void 0},{key:"title",coerce:"identity"},{key:"width",coerce:"identity",default:400}];class zo extends Kt{_getDomain(){let t=[];this._d3ScaleNegative&&(t=this._d3ScaleNegative.domain()),this._d3Scale&&(t=t.concat(this._d3Scale.domain())),this._baselineBreak&&(t=t.concat([this._baselineBreak.value]));const e=["band","ordinal","point"].includes(this.schema.scale)?t:h.extent(t);return t[0]>t[1]?e.reverse():e}_givenDomain(t=!1){const e=(t?this._d3ScaleNegative:this._d3Scale).domain();return this.schema.reverse?e.slice().reverse():e}_getPosition(t){if("log"===this.schema.scale){if(0===t)return(this._d3Scale||this._d3ScaleNegative).range()[this._d3Scale?0:1];const e=Gi(t)?this._d3ScaleNegative:this._d3Scale;return e?e(t):0}return this._d3Scale?this._d3Scale(t):0}_getRange(){let t=[];return this._d3ScaleNegative&&(t=this._d3ScaleNegative.range()),this._d3Scale&&(t=t.concat(this._d3Scale.range())),this._baselineBreak&&t.push(this._baselineBreak.position),t[0]>t[1]?h.extent(t).reverse():h.extent(t)}_getLabels(){let t=[];if(this._d3ScaleNegative&&(t=t.concat(So.bind(this)(this._d3ScaleNegative,!1))),this._d3Scale&&(t=t.concat(So.bind(this)(this._d3Scale,!1))),"log"===this.schema.scale){if(t.some(t=>Gi(t))&&t.some(t=>t>0)){const e=h.min([...this._d3ScaleNegative.domain().map(Math.abs),...this._d3Scale.domain()]);t.includes(e)||t.splice(t.findIndex(t=>t>e),0,e),t.includes(-e)&&t.includes(e)&&t.splice(t.indexOf(-e),1)}}return t}_getTicks(){const t="time"===this.schema.scale&&this._d3Scale?Mi(this._scaleData,this._d3Scale):this._scaleData;if(["band","ordinal","point","time"].includes(this.schema.scale)&&t.length&&t.length<this.schema.width/4)return t;let e=[];return this._d3ScaleNegative&&(e=e.concat(So.bind(this)(this._d3ScaleNegative,!0))),this._d3Scale&&(e=e.concat(So.bind(this)(this._d3Scale,!0))),"log"===this.schema.scale&&e.includes(-1)&&e.includes(1)&&e.splice(e.indexOf(-1),1),e}toScene(){return function(t){const e=[],n=t._gridLineData??[];(function(t){if(!t._gridLineData||!t._gridLineData.length)return[];const{height:e,x:n,y:i,opposite:o}=t._position,r=t._margin[o],a=["top","left"].includes(t.schema.orient)?t._outerBounds[i]+t._outerBounds[e]-r:t._outerBounds[i]+r,s=["top","left"].includes(t.schema.orient)?r:-r,c="band"===t.schema.scale?t._d3Scale.bandwidth()/2:0,l="x"===n;return(t._gridLineData??[]).map(e=>{const n=t._getPosition(e.id)+c;return{points:[l?[n,a]:[a,n],l?[n,a+s]:[a+s,n]]}})})(t).forEach((i,o)=>{const r=_o(t,t.schema.gridConfig,n[o],o);e.push({type:"line",key:`grid-${o}`,points:i.points,paint:r})});const i=t._tickShape&&"function"==typeof t._tickShape.toScene?t._tickShape.toScene():null;if(i&&e.push(i),t._tickShape){const n=t._tickShape._labelClass;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){const t=n.toScene();t&&Array.isArray(t.children)&&e.push(...t.children)}}const o=ko(t);let r;o&&e.push(...ti(t,o.points,e=>_o(t,e))),t._titleClass&&"function"==typeof t._titleClass.toScene&&t._titleClass._data&&t._titleClass._data.length&&e.push(t._titleClass.toScene());const a=t._select&&"function"==typeof t._select.node?t._select.node():null;if(a&&"function"==typeof a.getAttribute){const t=a.getAttribute("transform");if(t){const e=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(t);e&&(r={x:Number(e[1]),y:Number(e[2])})}}return{type:"group",key:`Axis-${t._uuid.slice(0,8)}`,...r?{transform:r}:{},children:e}}(this)}render(t){if(void 0===this._select&&"compute"!==this.schema.renderMode)if(this._managesOwnScenePaint){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width",`${this.schema.width}px`),t.setAttribute("height",`${this.schema.height}px`),document.body.appendChild(t),this.select(t)}else{const t=document.createElement("div");document.body.appendChild(t),this.select(t)}const e=no(this),{ticks:n,labels:i}=e,o=this._select,a="compute"===this.schema.renderMode&&(void 0===this._select||null===this._select||"function"==typeof this._select.node&&null===this._select.node())?null:r.elem(`g#d3plus-Axis-${this._uuid}`,{parent:o});this._group=a;const s=(0!==this.schema.gridSize?this.schema.grid||"log"===this.schema.scale&&!this.schema.gridLog?i:n:[]).map(t=>({id:t}));this._gridLineData=s;const c=function(t,e){const{ticks:n,labels:i,textData:o,tickFormat:r,hBuff:a,labelHeight:s}=e,{height:c,x:l,y:h,horizontal:u,opposite:d}=t._position,f=["top","left"].includes(t.schema.orient),m=t.schema.padding,p=t._margin,g=t._outerBounds,y=i.filter((t,e)=>o[e].lines.length&&!n.includes(t)),x=o.some(t=>t.rotate);let b=n.concat(y).map(e=>{const y=o.find(t=>t.d===e),b=t._getPosition(e),_=y?y.space:0,k=y?y.fP:0,v=y&&t.schema.labelOffset?y.offset??0:0,w=u?_:g.width-p[t._position.opposite]-a-p[t.schema.orient]+m,M=!u&&y&&"number"==typeof t.schema.fixedSize?Math.max(w,Math.ceil(y.width)+m):w,S=p[d],C=(a+v)*(f?-1:1),$=f?g[h]+g[c]-S:g[h]+S;return{id:e,labelBounds:y?.slant?Co(t,y,Math.abs(C)+(u?k:m)):x&&y?$o(t,y,C):{x:u?-_/2:"left"===t.schema.orient?-M-m+C:C+m,y:u?"bottom"===t.schema.orient?C+k:C-s-k:-_/2,width:u?_:M,height:u?s:_},rotate:!!y&&y.rotate,angle:y?y.angle:0,size:i.includes(e)||"log"===t.schema.scale&&Math.log10(Math.abs(e))%1==0?C:n.includes(e)?Math.ceil(C/2):t._scaleData.find(t=>+t===e)?Math.ceil(C/4):0,text:!(y?.truncated||!i.includes(e))&&r(e),tick:n.includes(e),[l]:b+("band"===t.schema.scale?t._d3Scale.bandwidth()/2:0),[h]:$}});return"Line"===t.schema.shape&&(b=b.concat(b.map(t=>{const e=Object.assign({},t);return e[h]=e[h]+t.size,e}))),b}(this,e);return function(t,e){t._tickShape=(new O[t.schema.shape]).renderMode("compute").select(null).data(e).duration(t.schema.duration).labelConfig({ellipsis:t=>t&&t.length?`${t}...`:"",...t._labelRotation&&t._labelSlant?{split:yn}:{},rotate:t=>{const e=void 0!==t.rotate?t:t.data;return e?.rotate?Number(e.angle??-90):0}}),t._tickShape.config(Qt.bind(t)(t.schema.shapeConfig)).labelConfig({padding:0}).render()}(this,c),function(t,e,n){const{range:i}=e,{horizontal:o}=t._position,a=t._margin,s=t._outerBounds;t._titleClass.renderMode("compute").data(t.schema.title?[{text:t.schema.title}]:[]).duration(t.schema.duration).height(a[t.schema.orient]).rotate("left"===t.schema.orient?-90:"right"===t.schema.orient?90:0).select(n?r.elem("g.d3plus-Axis-title",{parent:n}).node():null).text(t=>t.text).verticalAlign("middle").width(i[i.length-1]-i[0]).x(o?i[0]:"left"===t.schema.orient?s.x+a.left/2-(i[i.length-1]-i[0])/2:s.x+s.width-a.right/2-(i[i.length-1]-i[0])/2).y(o?"bottom"===t.schema.orient?s.y+s.height-a.bottom:s.y:i[0]+(i[i.length-1]-i[0])/2-a[t.schema.orient]/2).config(Qt.bind(t)(t.schema.titleConfig)).render()}(this,e,a),this._lastScale=this._getPosition.bind(this),"compute"===this.schema.renderMode||this._managesOwnScenePaint||te(this),t&&setTimeout(t,this.schema.duration+100),this}barConfig(t){return arguments.length?(this.schema.barConfig=ut(this,"barConfig",t),this):this.schema.barConfig}breakConfig(t){return arguments.length?(this.schema.breakConfig=ut(this,"breakConfig",t),this):this.schema.breakConfig}baselineBreakConfig(t){return arguments.length?(this.schema.baselineBreakConfig=ut(this,"baselineBreakConfig",t),this):this.schema.baselineBreakConfig}data(t){return arguments.length?(this._data=t,this):this._data}gridConfig(t){return arguments.length?(this.schema.gridConfig=ut(this,"gridConfig",t),this):this.schema.gridConfig}labelRotation(t){return arguments.length?(this._labelRotationSetting=t,this):this._labelRotationSetting}orient(t){if(arguments.length){const e=["top","bottom"].includes(t),n={top:"bottom",right:"left",bottom:"top",left:"right"};return this._position={horizontal:e,width:e?"width":"height",height:e?"height":"width",x:e?"x":"y",y:e?"y":"x",opposite:n[t]},this.schema.orient=t,this}return this.schema.orient}outerBounds(){return this._outerBounds}measure(){return no(this),this}select(t){return arguments.length?(this._select=null==t?void 0:o.select(t),this):this._select}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ut(this,"shapeConfig",t),this):this.schema.shapeConfig}titleConfig(t){return arguments.length?(this.schema.titleConfig=ut(this,"titleConfig",t),this):this.schema.titleConfig}constructor(){super(),this._scaleData=[],this._labelAngle=0,this._labelSlant=!1,this._labelOverflow=[0,0],this._d3Scale=null,this._d3ScaleNegative=null,this._baselineBreak=null,this._breaks=[],xt(this,Ao),this._data=[],this._labelRotation=!1,this._labelRotationSetting=void 0,this.schema.barConfig={stroke:xo(this),"stroke-width":1},this.schema.baselineBreakConfig=bo(this),this.schema.breakConfig=bo(this),this.schema.gridConfig=function(t){return{stroke:()=>mo(t),"stroke-width":1}}(this),this.orient("bottom"),this._outerBounds={width:0,height:0,x:0,y:0},this.schema.shapeConfig=function(t){return{fill:xo(t),height:t=>t.tick?8:0,label:t=>t.text,labelBounds:t=>t.labelBounds,labelConfig:{fontColor:xo(t),fontResize:!1,fontSize:H(12),padding:5,textAnchor:()=>{if(t._labelRotation&&t._labelSlant)return $n(t.schema.orient,t._labelAngle);const e=r.rtl();return"left"===t.schema.orient?e?"start":"end":"right"===t.schema.orient?e?"end":"start":t._labelRotation?$n(t.schema.orient,t._labelAngle):"middle"},verticalAlign:()=>"bottom"===t.schema.orient?"top":"top"===t.schema.orient?t._labelRotation?"top":"bottom":"middle"},r:t=>t.tick?4:0,stroke:xo(t),strokeWidth:1,width:t=>t.tick?8:0}}(this),this._tickUnit=0,this._titleClass=new Ir,this.schema.titleConfig=function(t){return{fontColor:xo(t),fontSize:12,textAnchor:"middle"}}(this),this._margin={top:0,right:0,bottom:0,left:0},this._availableTicks=[],this._visibleTicks=[]}}zo._displayName="Axis",dt(zo.prototype,"barConfig","breakConfig","baselineBreakConfig","gridConfig","shapeConfig","titleConfig");class Do extends zo{constructor(){super(),this.orient("bottom")}}Do._displayName="AxisBottom";class Lo extends zo{constructor(){super(),this.orient("left")}}Lo._displayName="AxisLeft";class Fo extends zo{constructor(){super(),this.orient("right")}}Fo._displayName="AxisRight";class No extends zo{constructor(){super(),this.orient("top")}}No._displayName="AxisTop";const Bo=new WeakMap;function Eo(t){const e=t._lineData,{align:n,direction:i,padding:o}=t.schema,r=t._outerBounds,a=[e,t._data,r.x,r.y,r.width,t._titleHeight,t._rtl,n,i,o],s=Bo.get(t);if(s&&s.deps.every((t,e)=>t===a[e]))return s;const c=new Map;e.forEach(t=>{const e=c.get(t.y);e?e.push(t):c.set(t.y,[t])});const l=new Map,u=new Map;c.forEach((e,n)=>{l.set(n,t._rowWidth(e)),u.set(n,h.max(e.map(t=>t.height)))});const d=h.max(t._data.map((e,n)=>t._fetchConfig("height",e,n))),f=new Map,m=[],p=[];e.forEach(e=>{const a=e.y,s=l.get(a),c="left"===n||"right"===n&&"column"===i?0:"center"===n?(r.width-s)/2:r.width-s,g=f.get(a)||{widths:0,pads:0,last:0,count:0},y=g.count?g.widths+o*(g.pads-g.last):0,x=t._rtl?e.width+o:0;m.push(y+o*(g.count?e.sentence?2:1:0)+r.x+e.shapeWidth/2+c+x),p.push(a+t._titleHeight+r.y+h.max([u.get(a),d])/2);const b=e.width?2:1;f.set(a,{widths:g.widths+e.shapeWidth+e.width,pads:g.pads+b,last:b,count:g.count+1})});const g={deps:a,x:m,y:p};return Bo.set(t,g),g}function Ro(t,e,n){const i={lines:1,newRows:[],maxLines:h.max(t._lineData.map(t=>t.words.length))};if(t._wrapLines=()=>function(t,e,n,i){if(e.lines++,e.lines>e.maxLines)return;const o=1===e.lines?t._lineData.slice():t._lineData.filter(i=>i.width+i.shapeWidth+t.schema.padding*(i.width?2:1)>n&&i.words.length>=e.lines).sort((t,e)=>e.sentence.length-t.sentence.length);if(o.length&&i>o[0].height*e.lines){let n=!1;for(let t=0;t<o.length;t++){const i=o[t],a=i.og,c=a.height*e.lines,l=a.width*(1/e.lines*1.5),u=s.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(l).height(c)(i.sentence);if(u.truncated){n=!0;break}i.width=Math.ceil(h.max(u.lines.map(t=>r.textWidth(t,{"font-family":i.f,"font-size":i.s}))))+i.s,i.height=u.lines.length*(i.lh+1)}n||t._wrapRows()}else e.newRows=[]}(t,i,e,n),t._wrapRows=()=>function(t,e,n,i){e.newRows=[];let o=1,r=0;for(let a=0;a<t._lineData.length;a++){const s=t._lineData[a],c=s.width+t.schema.padding*(s.width?2:1)+s.shapeWidth;if(h.sum(e.newRows.map(t=>h.max(t,t=>h.max([t.height,t.shapeHeight]))))>i){e.newRows=[];break}if(c>n){e.newRows=[],t._wrapLines();break}r+c<n?r+=c:"column"!==t.schema.direction&&(r=c,o++),e.newRows[o-1]||(e.newRows[o-1]=[]),e.newRows[o-1].push(s),"column"===t.schema.direction&&(r=0,o++)}}(t,i,e,n),t._wrapRows(),!i.newRows.length||h.sum(i.newRows,t._rowHeight.bind(t))+t.schema.padding>n){for(let e=0;e<t._lineData.length;e++)t._lineData[e].width=0,t._lineData[e].height=0;t._wrapRows()}return!(!i.newRows.length||h.sum(i.newRows,t._rowHeight.bind(t))+t.schema.padding>n)&&(i.newRows.forEach((e,n)=>{e.forEach(e=>{n&&(e.y=h.sum(i.newRows.slice(0,n),t._rowHeight.bind(t)))})}),h.max(i.newRows,t._rowWidth.bind(t)))}const Po=[{key:"align",coerce:"identity",default:"center"},{key:"direction",coerce:"identity",default:"row"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"id",coerce:"identity",default:I("id")},{key:"label",coerce:"const",default:I("id")},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"shape",coerce:"const",default:H("Rect")},{key:"title",coerce:"identity"},{key:"verticalAlign",coerce:"identity",default:"middle"},{key:"width",coerce:"identity",default:400}];class To extends Kt{_fetchConfig(t,e,n){const i=this.schema.shapeConfig.labelConfig,o=void 0!==this.schema.shapeConfig[t]?this.schema.shapeConfig[t]:i?.[t];return o||"lineHeight"!==t?"function"==typeof o?o(e,n):o:1.4*this._fetchConfig("fontSize",e,n)}_rowHeight(t){return h.max(t.map(t=>t.height).concat(t.map(t=>t.shapeHeight)))+this.schema.padding}_rowWidth(t){return h.sum(t.map((e,n)=>{const i=this.schema.padding*(n===t.length-1?0:e.width?2:1);return e.shapeWidth+e.width+i}))}toScene(){const t=[];let e;this._titleClass&&"function"==typeof this._titleClass.toScene&&this._titleClass._data&&this._titleClass._data.length&&t.push(this._titleClass.toScene()),(this._shapes||[]).forEach(e=>{const n=e;if(n&&"function"==typeof n.toScene&&n._data&&n._data.length){t.push(n.toScene());const e=n._labelClass;if(e&&"function"==typeof e.toScene&&e._data&&e._data.length){const n=e.toScene();n&&Array.isArray(n.children)&&t.push(...n.children)}}});const n=this._select&&"function"==typeof this._select.node?this._select.node():null;if(n&&"function"==typeof n.getAttribute){const t=n.getAttribute("transform");if(t){const n=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(t);n&&(e={x:Number(n[1]),y:Number(n[2])})}}return{type:"group",key:`Legend-${this._uuid.slice(0,8)}`,...e?{transform:e}:{},children:t}}render(t){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(o.select("body").append("div").node()),this._group=r.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=r.elem("g.d3plus-Legend-title",{parent:this._group}),this._shapeGroup=r.elem("g.d3plus-Legend-shape",{parent:this._group}),function(t){if(t._titleHeight=0,t._titleWidth=0,t.schema.title){const e=t.schema.titleConfig.fontFamily||t._titleClass.fontFamily()(),n=t.schema.titleConfig.fontSize||t._titleClass.fontSize()();let i=t.schema.titleConfig.lineHeight||t._titleClass.lineHeight();i="function"==typeof i?i():i??1.4*n;const o=s.textWrap().fontFamily(e).fontSize(n).lineHeight(i).width(t.schema.width).height(t.schema.height)(t.schema.title);t._titleHeight=i+o.lines.length+t.schema.padding,t._titleWidth=h.max(o.widths)}}(this);const e=this.schema.height-this._titleHeight;this._lineData=function(t,e){return t._data.map((n,i)=>{const o=t.schema.label(n,i),a=t.schema.shape(n,i),c=t._fetchConfig("r",n,i),l=t._fetchConfig("height",n,i);let u={data:n,i:i,id:t.schema.id(n,i),shape:a,shapeR:c,shapeWidth:"Circle"===a?2*c:"Line"===a?l:t._fetchConfig("width",n,i),shapeHeight:"Circle"===a?2*c:l,y:0};if(!o)return u.sentence=!1,u.words=[],u.height=0,u.width=0,u;const d=t._fetchConfig("fontFamily",n,i),f=t._fetchConfig("lineHeight",n,i),m=t._fetchConfig("fontSize",n,i),p=e-(t._data.length+1)*t.schema.padding,g=t.schema.width,y=s.textWrap().fontFamily(d).fontSize(m).lineHeight(f).width(g).height(p)(o);return u=Object.assign(u,y),u.width=u.lines.length?Math.ceil(h.max(u.lines.map(t=>r.textWidth(t,{"font-family":d,"font-size":m}))))+10:0,u.height=Math.ceil(u.lines.length*(f+1)),u.og={height:u.height,width:u.width},u.f=d,u.s=m,u.lh=f,u})}(this,e);let n=this._rowWidth(this._lineData);const i=this.schema.width-2*this.schema.padding;var a;return("column"===this.schema.direction||n>i)&&(n=Ro(this,i,e)),!1===n?((a=this)._titleClass.data([]),a._shapes=[],Object.assign(a._outerBounds,{width:0,height:0,x:0,y:0})):(function(t,e){const n=h.max(t._lineData,(e,n)=>h.max([e.height,t._fetchConfig("height",e.data,n)])+e.y)+t._titleHeight,i=h.max([e,t._titleWidth]);t._outerBounds.width=i,t._outerBounds.height=n;let o=t.schema.padding,r=t.schema.padding;"center"===t.schema.align?o=(t.schema.width-i)/2:"right"===t.schema.align&&(o=t.schema.width-t.schema.padding-i),"middle"===t.schema.verticalAlign?r=(t.schema.height-n)/2:"bottom"===t.schema.verticalAlign&&(r=t.schema.height-t.schema.padding-n),t._outerBounds.x=o,t._outerBounds.y=r}(this,n),function(t){t._titleClass.renderMode("compute").data(t.schema.title?[{text:t.schema.title}]:[]).duration(t.schema.duration).select(t._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[t.schema.align]).width(t.schema.width-2*t.schema.padding).x(t.schema.padding).y(t._outerBounds.y).config(t.schema.titleConfig).render()}(this),function(t){t._shapes=[];const e=Qt.bind(t)(t.schema.shapeConfig,"legend"),n={id:t=>t.id,label:t=>t.label},i=t._data.map((e,n)=>({__d3plus__:!0,data:e,i:n,id:t.schema.id(e,n),label:!!t._lineData[n].width&&t.schema.label(e,n),shape:t.schema.shape(e,n)}));t._shapes=[],["Circle","Rect"].forEach(o=>{t._shapes.push((new O[o]).renderMode("compute").parent(t).data(i.filter(t=>t.shape===o||"Line"===t.shape)).duration(t.schema.duration).labelConfig({padding:0}).select(t._shapeGroup.node()).verticalAlign("top").config(e).config(n).config(function(t,e){const n=t=>"Line"===t.shape,i=(e,n)=>t._fetchConfig(e,n.data,n.i),o=e=>t._lineData[e.i];return"Rect"===e?{width:t=>n(t)?o(t).shapeWidth:i("width",t),height:t=>n(t)?2:i("height",t)}:{r:t=>n(t)?.3*o(t).shapeHeight:i("r",t),label:t=>!n(t)&&t.label,hitArea:t=>n(t)?null:i("hitArea",t)}}(t,o)).render())})}(this)),"compute"!==this.schema.renderMode&&te(this),t&&setTimeout(t,this.schema.duration+100),this}active(t){return this._shapes.forEach(e=>e.active(t)),this}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){return this._shapes.forEach(e=>e.hover(t)),this}outerBounds(){return this._outerBounds}select(t){return arguments.length?(this._select=o.select(t),this._rtl=r.rtl(),this):this._select}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ut(this,"shapeConfig",t),this):this.schema.shapeConfig}titleConfig(t){return arguments.length?(this.schema.titleConfig=ut(this,"titleConfig",t),this):this.schema.titleConfig}constructor(){var t;super(),xt(this,Po),this._titleClass=new Ir,this._data=[],this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._shapes=[],this.schema.shapeConfig=(t=this,{fill:I("color"),height:H(12),hitArea:(e,n)=>{const i=t._lineData[n],o=h.max([i.height,i.shapeHeight]);return{width:i.width+i.shapeWidth,height:o,x:-i.shapeWidth/2,y:-o/2}},labelBounds:(e,n)=>{const i=t._lineData[n],o=i.shapeWidth/2,r=h.max([i.shapeHeight,i.height]),a=t._rtl?i.shapeWidth+i.width+2*t.schema.padding:0;return{width:i.width,height:r,x:o+5-a,y:-r/2}},labelConfig:{fontColor:()=>uo(t),fontFamily:t._titleClass.fontFamily(),fontResize:!1,fontSize:H(10),pointerEvents:H("none"),textAnchor:"start",verticalAlign:"middle"},opacity:1,r:H(6),width:H(12),x:(e,n)=>Eo(t).x[n],y:(e,n)=>Eo(t).y[n]}),this.schema.titleConfig={fontColor:()=>uo(this),fontSize:12},this._rtl=!1,this._titleHeight=0,this._titleWidth=0}}function Oo(t){const[e,n]=t.toExponential(14).split("e"),i=e.split(".")[1].replace(/0+$/,"");return Math.max(0,i.length-Number(n))}To._displayName="Legend",dt(To.prototype,"shapeConfig","titleConfig");const Wo=(t,e)=>+(t*10**e).toPrecision(15),Ho=(t,e)=>+(t/10**e).toPrecision(15)||0;function jo(t){const e=t.filter(Number.isFinite);if(!e.length)return 0;const n=h.max(e)-Math.min(...e)||Math.abs(e[0]),i=e.map(t=>Math.abs(t)<1e-9*n?0:t),o=i.filter(t=>function(t){return t.toExponential(14).split("e")[0].replace(/[-.]/g,"").replace(/0+$/,"").length||1}(t)<12),r=h.max(o.map(Oo))??0;if(o.length===i.length)return r;const a=n?Math.max(0,2-Math.floor(Math.log10(n))):0;return Math.max(r,a)}const Io=["buckets","jenks","linear","log","quantile"],Go=t=>"buckets"===t||"jenks"===t||"quantile"===t;const qo=t=>t.schema.colorMin??tt(t._theme,"min",t.schema.colorDefaults.off),Vo=t=>t.schema.colorMid??tt(t._theme,"mid",t.schema.colorDefaults.light),Yo=t=>t.schema.colorMax??tt(t._theme,"max",t.schema.colorDefaults.sequential),Ko=(t,e,n)=>et(t._theme,e,n,Boolean(t.schema.ordinalRamp)&&!t._theme?.dark),Uo=(t,n,i)=>t._theme?.dark?b.interpolateRgb.gamma(2.2)(n,Vo(t))(i):e.colorLighter(n,i);function Xo(t,e){const{scale:n}=e;let i=t.schema.buckets instanceof Array?t.schema.buckets:void 0;const o=e.diverging&&!e.colors?function(t,e,n){const{domain:i,numBuckets:o}=e,r=Math.floor(o/2),a=b.interpolateRgb.gamma(2.2)(qo(t),Vo(t)),s=h.range(0,r,1).map(t=>a(t/r)),c=(o%2?[0]:[]).map(()=>Vo(t)),l=b.interpolateRgb.gamma(2.2)(Yo(t),Vo(t)),u=h.range(0,r,1).map(t=>l(t/r)).reverse(),d=s.concat(c).concat(u);if(!n){const e=(d.length-1)/2;n=h.range(i[0],t.schema.midpoint,-(i[0]-t.schema.midpoint)/e).concat(h.range(t.schema.midpoint,i[1],(i[1]-t.schema.midpoint)/e)).concat([i[1]])}return{colors:d,buckets:n}}(t,e,i):function(t,e,n){const{allValues:i,domain:o,negative:r,positive:a,diverging:s,numBuckets:c,scale:l}=e;let{colors:u}=e;if(!u){const e=r?qo(t):Yo(t);if("buckets"===l||"quantile"===l){const n=Ko(t,e,c);u=a?n:n.slice().reverse()}else{const n=Ko(t,e,2);u=r?n.slice().reverse():n}}if(!n)if("quantile"===l){const t=1/(u.length-1);n=h.range(0,1+t/2,t).map(t=>h.quantile(i,t))}else if(s&&t.schema.color&&t.schema.centered){const e=u.indexOf(Vo(t)),i=(t.schema.midpoint-o[0])/e,r=(o[1]-t.schema.midpoint)/(u.length-e),a=h.range(o[0],t.schema.midpoint,i),s=h.range(t.schema.midpoint,o[1]+r/2,r);n=a.concat(s)}else{const t=(o[1]-o[0])/(u.length-1);n=h.range(o[0],o[1]+t/2,t)}return{colors:u,buckets:n}}(t,e,i);let r,{colors:a}=o;if(i=o.buckets,"buckets"===n||"quantile"===n)r=i,a=[a[0]].concat(a);else if("log"===n){const t=i.filter(t=>t<0);if(t.length){const e=t[0],n=t.map(t=>-Math.pow(Math.abs(e),t/e));t.forEach((t,e)=>{i[i.indexOf(t)]=n[e]})}const e=i.filter(t=>t>0);if(e.length){const t=e[e.length-1],n=e.map(e=>Math.pow(t,e/t));e.forEach((t,e)=>{i[i.indexOf(t)]=n[e]})}i.includes(0)&&(i[i.indexOf(0)]=1)}const s="buckets"===n||"quantile"===n?c.scaleThreshold:c.scaleLinear;return t._colorScale=s().domain(i).range(a),{colors:a,ticks:r,labels:void 0}}function Zo(t){const e=["bottom","top"].includes(t.schema.orient),i=e?"height":"width",o=e?"width":"height",r=e?"x":"y",a=e?"y":"x",s=t._data.map(t.schema.value).filter(t=>"number"==typeof t&&!Number.isNaN(t)).sort((t,e)=>t-e),l=function(t,e,n){const i=e.length?[e[0],e[e.length-1]]:[void 0,void 0],o="function"==typeof t?t.call(n,e.slice(),i):t;return Io.includes(o)?o:(Bt(`ColorScale received unknown scale ${JSON.stringify(o)??String(o)}; using "linear". Use one of ${Io.map(t=>`"${t}"`).join(", ")}, or a function returning one.`),"linear")}(t.schema.scale,s,t);t._scaleType=l;const u=t.schema.domain||h.extent(s),d=u[0]<t.schema.midpoint,m=u[1]>t.schema.midpoint,p=d&&m,g=h.min([t.schema.buckets instanceof Array?t.schema.buckets.length:t.schema.buckets,p&&"jenks"!==l?2*Math.floor(n.unique(s).length/2)-1:n.unique(s).length]);let y=p&&(!t.schema.color||t.schema.color instanceof Array&&!t.schema.color.includes(Vo(t)))?void 0:t.schema.color;!y||y instanceof Array||(y=Ko(t,y,g));const x={scale:l,allValues:s,domain:u,negative:d,positive:m,diverging:p,numBuckets:g,colors:y},b="jenks"===l?function(t,e){const{allValues:n,diverging:i,numBuckets:o}=e;let r,a,{colors:s}=e;const l=h.min([s?s.length:o,o,n.length]);let u;if(t.schema.buckets instanceof Array)r=t.schema.buckets;else{if(i&&t.schema.centered){const e=Math.floor(l/2),i=l%2,o=n.filter(e=>e<t.schema.midpoint),r=h.deviation(o),a=n.concat(t.schema.midpoint).filter(e=>e>=t.schema.midpoint),s=h.deviation(a),c=r>s?1:0,d=s>r?1:0,m=f.ckmeans(o,h.min([e+i*c,o.length])),p=f.ckmeans(a,h.min([e+i*d,a.length]));u=m.concat(p)}else u=f.ckmeans(n,l);r=u.map(t=>t[0])}const d=new Set(r);if(r.length!==d.size&&(a=Array.from(d)),!s)if(i){const e=[qo(t),Vo(t),Yo(t)],n=r.slice(0,l).filter((e,n)=>e<t.schema.midpoint&&r[n+1]<=t.schema.midpoint),i=r.slice(0,l).filter((e,n)=>e<=t.schema.midpoint&&r[n+1]>t.schema.midpoint),o=r.slice(0,l).filter(e=>e>t.schema.midpoint),a=n.map((i,o)=>o?Uo(t,e[0],o/n.length):e[0]),c=i.map(()=>e[1]),h=o.map((n,i)=>i===o.length-1?e[2]:Uo(t,e[2],1-(i+1)/o.length));s=a.concat(c).concat(h)}else s=Ko(t,Yo(t),o);return r.length<=l&&(s=s.slice(-r.length)),s=[s[0]].concat(s),t._colorScale=c.scaleThreshold().domain(r).range(s),{colors:s,ticks:r,labels:a}}(t,x):Xo(t,x);return t._colorScale.clamp&&t._colorScale.clamp(!0),{scale:l,allValues:s,domain:u,ticks:b.ticks,labels:b.labels,colors:b.colors,horizontal:e,height:i,width:o,x:r,y:a}}function Qo(t,e,n){const i={x:0,y:0},{axisConfig:o,labelConfig:s,axisDomain:l,labelData:h}=function(t,e,n){const{horizontal:i,height:o,width:a,domain:s,labels:c,ticks:l}=e,h=s.slice();if(t.schema.bucketAxis){const t=h[h.length-1],e=h[h.length-2],n=t?t/10:e/10,i=n>=1||n<=-1?Math.round(n).toString().length-1:-1*n.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,o=Math.pow(10,i);h[h.length-1]=t+o}const u=r.assign({domain:i?h:h.slice().reverse(),duration:t.schema.duration,height:t.schema.height,labels:c||l,orient:t.schema.orient,padding:t.schema.padding,scale:"log"===e.scale?"log":"linear",ticks:l,width:t.schema.width},t.schema.axisConfig),d=r.assign({height:t.schema[o]/2,width:t.schema[a]/2},t.schema.labelConfig);t._labelClass.config(d);const f=[];if(i&&t._labelMin){const e={"font-family":t._labelClass.fontFamily()(t._labelMin),"font-size":t._labelClass.fontSize()(t._labelMin),"font-weight":t._labelClass.fontWeight()(t._labelMin)};e["font-family"]instanceof Array&&(e["font-family"]=e["font-family"][0]);let o=r.textWidth(t._labelMin,e);o&&o<t.schema[a]/2&&(f.push(t._labelMin),o+=t.schema.padding,i&&(n.x+=o),u[a]=u[a]-o)}if(i&&t._labelMax){const e={"font-family":t._labelClass.fontFamily()(t._labelMax),"font-size":t._labelClass.fontSize()(t._labelMax),"font-weight":t._labelClass.fontWeight()(t._labelMax)};e["font-family"]instanceof Array&&(e["font-family"]=e["font-family"][0]);let o=r.textWidth(t._labelMax,e);o&&o<t.schema[a]/2&&(f.push(t._labelMax),o+=t.schema.padding,i||(n.y+=o),u[a]=u[a]-o)}return{axisConfig:u,labelConfig:d,axisDomain:h,labelData:f}}(t,e,i),{axisBounds:u,axisScale:d,scaleRange:f}=function(t,e,n,i,o){const{horizontal:a,height:s,width:c,x:l,y:h}=e;t._axisTest.renderMode("compute").select(r.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:t._group}).node()).config(i).duration(0).render();const u=t._axisTest.outerBounds();t._outerBounds[c]=t.schema[c]-2*t.schema.padding,t._outerBounds[s]=u[s]+t.schema.size,t._outerBounds[l]=t.schema.padding,t._outerBounds[h]=t.schema.padding,"middle"===t.schema.align?t._outerBounds[h]=(t.schema[s]-t._outerBounds[s])/2:"end"===t.schema.align&&(t._outerBounds[h]=t.schema[s]-t.schema.padding-t._outerBounds[s]);const d=t._outerBounds[h]+(["bottom","right"].includes(t.schema.orient)?t.schema.size:0)-(i.padding||t._axisClass.padding()),f=`translate(${o.x+(a?0:d)}, ${o.y+(a?d:0)})`;return t._axisClass.renderMode("compute").select(r.elem("g.d3plus-ColorScale-axis",r.assign(n.groupParams,{condition:!0,enter:{transform:f},update:{transform:f}})).node()).config(i).align("start").render(),{axisBounds:u,axisScale:t._axisTest._getPosition.bind(t._axisTest),scaleRange:t._axisTest._getRange()}}(t,e,n,o,i);!function(t,e,n,i){const{horizontal:o,colors:r}=e,s=t._colorScale.domain(),l=c.scaleLinear().domain(i).range(o?[0,100]:[100,0]),h=r.map((t,e)=>({offset:(e<=s.length-1?l(n(s[e])):100)/100,color:String(t)})).sort((t,e)=>t.offset-e.offset),u={type:"linear",from:o?[0,0]:[0,1],to:o?[1,0]:[0,0],stops:h};t._gradientFill=a.gradientToken(u)}(t,e,d,f);const m=function(t,e,n,i){const{height:o,width:a,x:s,y:c,ticks:l}=e,{axisScale:h,scaleRange:u,axisDomain:d,axisBounds:f,offsets:m}=i,p=(t,e)=>{const n=l[e+1]||d[d.length-1];return Math.abs(h(n)-h(t))},g=r.assign({duration:t.schema.duration,fill:l?e=>t._colorScale(e):t._gradientFill,[s]:l?(e,n)=>h(e)+p(e,n)/2-(["left","right"].includes(t.schema.orient)?p(e,n):0):u[0]+(u[1]-u[0])/2+m[s],[c]:t._outerBounds[c]+(["top","left"].includes(t.schema.orient)?f[o]:0)+t.schema.size/2+m[c],[a]:l?p:u[1]-u[0],[o]:t.schema.size},t.schema.rectConfig),y=t._outerBounds[c]+(["top","left"].includes(t.schema.orient)?f[o]:0)+m[c];return t._barGeometry={orient:t.schema.orient,position:t=>h(t)+m[s],range:[u[0]+m[s],u[1]+m[s]],cross:[y,y+t.schema.size],domain:[d[0],d[d.length-1]],...l?{ticks:l}:{}},t._rectClass.renderMode("compute").data(l||[0]).id((t,e)=>e).select(n.rectGroup.node()).config(g).render(),g}(t,e,n,{axisScale:d,scaleRange:f,axisDomain:l,axisBounds:u,offsets:i});!function(t,e,n,i,o,r){const{horizontal:a,height:s,width:c}=e;i.height=t._outerBounds[s],i.width=t._outerBounds[c],t._labelClass.renderMode("compute"),t._labelClass.config(i).data(r).select(n.labelGroup.node()).x(e=>e===t._labelMax?o.x+o.width/2+t.schema.padding:t._outerBounds.x).y(e=>o.y-t._labelClass.fontSize()(e)/2).text(t=>t).rotate(a?0:"right"===t.schema.orient?90:-90).render()}(t,e,n,s,m,h)}const Jo=t=>"bottom"===t||"top"===t;function tr(t,[e,n]){const i=Math.min(e,n),o=Math.max(e,n);return Math.min(o,Math.max(i,t))}function er(t,e){if("number"!=typeof e||!Number.isFinite(e))return null;const n=t.position(tr(e,t.domain));return Number.isFinite(n)?tr(n,t.range):null}function nr(t,e,n,i){return"bottom"===t?[[e,n[1]],[e,n[1]+i]]:"top"===t?[[e,n[0]],[e,n[0]-i]]:"right"===t?[[n[1],e],[n[1]+i,e]]:[[n[0],e],[n[0]-i,e]]}function ir(t,e){return"function"==typeof t?t(e):t}function or(t){const e=t;return e.interactive=!1,e.interactionGroup="axis",t}function rr(t){const e=ir(t.config.tickConfig?.length,t.value),n=t.cs._axisClass.schema.tickSize;return"number"==typeof e?e:"number"==typeof n?n:8}function ar(t,e,n,i){const o=t.config.tickConfig||{};return or({type:"line",key:`${t.key}-tick`,points:nr(e,n,i,rr(t)),paint:{fill:"none",stroke:ir(o.stroke,t.value)??t.tickPaint.stroke??t.ink,strokeWidth:ir(o.strokeWidth,t.value)??t.tickPaint.strokeWidth??1}})}function sr(t,n,i,o){const{cs:a,value:s}=t,c=t.config.badgeConfig||{},l=ir(c.fontSize,s)??11,h=ir(c.fontFamily,s)||`${a._labelClass.fontFamily()(o)}`,u=ir(c.fontWeight,s)??400,d=ir(c.padding,s)??3,f=ir(c.fill,s)??t.color,m=ir(c.fontColor,s)??e.colorContrast(f,a.schema.colorDefaults),p=r.textWidth(o,{"font-family":h,"font-size":l,"font-weight":u}),g=Jo(n.orient)?a.schema.width:a.schema.height,y=rr(t),x=a._axisClass.schema,b=("number"==typeof x.tickSize?x.tickSize:8)+("number"==typeof x.padding?x.padding:0),_=Math.max(d,b-y),k=function(t,e,n,i,o,r){const{width:a,height:s}=i;if(Jo(t))return{x:tr(e-a/2,[0,Math.max(0,o-a)]),y:"bottom"===t?n[1]+r:n[0]-r-s,width:a,height:s};const c=tr(e-s/2,[0,Math.max(0,o-s)]);return{x:"right"===t?n[1]+r:n[0]-r-a,y:c,width:a,height:s}}(n.orient,i,n.cross,Jo(n.orient)?{width:p+2*d,height:l+2*_}:{width:p+2*_,height:l+2*d},g,y),v=`${t.key}-badge`;return or({type:"group",key:v,children:[or({type:"rect",key:`${v}-box`,...k,rx:ir(c.rx,s)??0,paint:{fill:f,stroke:ir(c.stroke,s)??t.ink,strokeWidth:ir(c.strokeWidth,s)??1}}),or({type:"text",key:`${v}-text`,x:0,y:0,transform:{x:k.x+k.width/2,y:k.y+k.height/2},lines:[{text:o,x:0,y:0,width:p}],font:{family:h,size:l,weight:u,anchor:"middle",baseline:"middle"},paint:{fill:m}})]})}function cr(t,e){if(!e.ticks)return[];const n=function(t,e,n){let i=-1;return t.forEach((t,n)=>{e>=t&&(i=n)}),i<0?t.length?[t[0],t[1]??n]:null:[t[i],t[i+1]??n]}(e.ticks,t.value,e.domain[1]);if(!n)return[];const[i,o]=n.map(t=>er(e,t));if(null===i||null===o)return[];const r=t.config.outlineConfig||{},a=Math.min(i,o),s=Math.abs(o-i),[c,l]=e.cross,h=Jo(e.orient)?{x:a,y:c,width:s,height:l-c}:{x:c,y:a,width:l-c,height:s};return[or({type:"rect",key:`${t.key}-outline`,...h,paint:{fill:"none",stroke:ir(r.stroke,t.value)??t.ink,strokeWidth:ir(r.strokeWidth,t.value)??2}})]}function lr(t){let e;const n=(t,i)=>{if(e)return;const o=i||String(t.key).startsWith("Axis-");"group"===t.type?t.children.forEach(t=>n(t,o)):o&&"path"===t.type&&!String(t.key).endsWith("::hit")&&(e={stroke:t.paint?.stroke,strokeWidth:t.paint?.strokeWidth})};return t.children.forEach(t=>n(t,!1)),e??{}}function hr(t,e){const n=t._hoverValue,i=t._barGeometry;if(!1===t.schema.hoverMark||"number"!=typeof n||!Number.isFinite(n)||!t._colorScale||!i)return;const o=uo(t),r={cs:t,key:`${e.key}-hover`,value:n,color:String(t._colorScale(n)),ink:o,config:t.schema.hoverMarkConfig||{},tickPaint:lr(e)};e.children.push(...function(t,e){const n=er(e,t.value);if(null===n)return[];const i=function(t,e){const n=t._axisClass._labelFormat??t.schema.axisConfig.tickFormat;return`${(n?n(e):`${e}`)??""}`.replace(/<[^>]*>/g,"").trim()}(t.cs,t.value);return[...cr(t,e),ar(t,e.orient,n,e.cross),...i?[sr(t,e,n,i)]:[]]}(r,i))}const ur=[{key:"align",coerce:"identity",default:"middle"},{key:"buckets",coerce:"identity",default:5},{key:"bucketAxis",coerce:"identity",default:!1},{key:"bucketFormat",coerce:"identity"},{key:"bucketJoiner",coerce:"identity",default:(t,e)=>t!==e?`${t} - ${e}`:`${t}`},{key:"centered",coerce:"identity",default:!0},{key:"color",coerce:"identity"},{key:"colorMax",coerce:"identity"},{key:"colorMid",coerce:"identity"},{key:"colorMin",coerce:"identity"},{key:"domain",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"hoverMark",coerce:"identity",default:!0},{key:"hoverMarkConfig",merge:!0,factory:function(){return{tickConfig:{},badgeConfig:{fontSize:11,fontWeight:400,padding:3,rx:2},outlineConfig:{strokeWidth:2}}}},{key:"midpoint",coerce:"identity",default:0},{key:"ordinalRamp",coerce:"identity",default:!1},{key:"orient",coerce:"identity",default:"bottom"},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity",default:"linear"},{key:"size",coerce:"identity",default:10},{key:"value",coerce:"const",default:I("value")},{key:"width",coerce:"identity",default:400}];class dr extends Kt{render(t){void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(o.select("body").append("div").node()),this._group=r.elem("g.d3plus-ColorScale",{parent:this._select});const e=Zo(this),n=this.schema.bucketAxis||!Go(e.scale),i=u.transition().duration(this.schema.duration),a={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:i,update:{opacity:1}},s={labelGroup:r.elem("g.d3plus-ColorScale-labels",Object.assign({condition:n},a)),rectGroup:r.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:n},a)),legendGroup:r.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!n},a)),groupParams:a,gradient:n};return n?Qo(this,e,s):function(t,e,n){const{horizontal:i,allValues:o,ticks:a,colors:s}=e;t._barGeometry=void 0,r.elem("g.d3plus-ColorScale-axis",Object.assign({condition:n.gradient},n.groupParams));let c=a.reduce((e,n,i)=>{const r=t.schema.bucketFormat.bind(t)(n,i,a,o);return e.push({color:s[i+1],id:r,_isColorScaleBucket:!0}),e},[]);i||(c=c.reverse());const l=r.assign({align:i?"center":{start:"left",middle:"center",end:"right"}[t.schema.align],direction:i?"row":"column",duration:t.schema.duration,height:t.schema.height,padding:t.schema.padding,shapeConfig:r.assign({duration:t.schema.duration},t.schema.axisConfig.shapeConfig||{}),title:t.schema.axisConfig.title,titleConfig:t.schema.axisConfig.titleConfig||{},width:t.schema.width,verticalAlign:i?{start:"top",middle:"middle",end:"bottom"}[t.schema.align]:"middle"},t.schema.legendConfig);t._legendClass.renderMode("compute").data(c).select(n.legendGroup.node()).config(l).render(),t._outerBounds=t._legendClass.outerBounds()}(this,e,s),"compute"!==this.schema.renderMode&&te(this),t&&setTimeout(t,this.schema.duration+100),this}toScene(){const t=[],e=e=>{if(e&&"function"==typeof e.toScene){const n=e.toScene();n&&t.push(n)}};let n;this.schema.bucketAxis||!Go(this._scaleType)?(e(this._rectClass),e(this._axisClass),e(this._labelClass)):e(this._legendClass);const i=this._select&&"function"==typeof this._select.node?this._select.node():null;if(i&&"function"==typeof i.getAttribute){const t=i.getAttribute("transform");if(t){const e=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(t);e&&(n={x:Number(e[1]),y:Number(e[2])})}}const o={type:"group",key:`ColorScale-${this._uuid.slice(0,8)}`,...n?{transform:n}:{},children:t};return hr(this,o),o}axisConfig(t){return arguments.length?(this.schema.axisConfig=ut(this,"axisConfig",t),this):this.schema.axisConfig}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){return arguments.length?(this._hoverValue=t,this):this._hoverValue}labelConfig(t){return arguments.length?(this.schema.labelConfig=ut(this,"labelConfig",t),this):this.schema.labelConfig}labelMin(t){return arguments.length?(this._labelMin=t,this):this._labelMin}labelMax(t){return arguments.length?(this._labelMax=t,this):this._labelMax}legendConfig(t){return arguments.length?(this.schema.legendConfig=ut(this,"legendConfig",t),this):this.schema.legendConfig}outerBounds(){return this._outerBounds}rectConfig(t){return arguments.length?(this.schema.rectConfig=ut(this,"rectConfig",t),this):this.schema.rectConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}constructor(){super(),this._scaleType="linear",xt(this,ur),this._axisClass=new zo,this.schema.axisConfig={gridSize:0},this._axisTest=new zo,this.schema.bucketFormat=(t,e,n,i)=>{const o=this.schema.axisConfig.tickFormat?this.schema.axisConfig.tickFormat:Hi(i)?t=>Ii(t,this.schema.locale):d.formatAbbreviate,r=e===n.length-1;if(t===n[e+1]||r){const e=r&&t<h.max(i)?"+":"";return`${o(function(t,e){const n=jo(e);return Ho(Math.round(Wo(t,n)),n)}(t,i))}${e}`}const[a,s]=function(t,e,n,i,o){const r=n[e+1],a=jo(i),s=Wo(t,a),c=Ho(1===e&&n[0]===t?Math.floor(s)+1:Math.ceil(s),a),l=t=>Ho(Math.ceil(Wo(r,t))-1,t),h=o(Ho(Math.ceil(Wo(r,a)),a));let u=a,d=l(u);for(;o(d)===h&&l(u-1)>=c;)d=l(--u);return[c,d]}(t,e,n,i,o);return this.schema.bucketJoiner(o(a),o(s))},this._data=[],this._labelClass=new Ir,this.schema.labelConfig={fontColor:()=>uo(this),fontSize:12},this._legendClass=new To,this.schema.legendConfig={shapeConfig:{stroke:()=>this.schema.colorDefaults.dark,strokeWidth:1}},this._outerBounds={width:0,height:0,x:0,y:0},this._rectClass=(new Ea).parent(this),this.schema.rectConfig={stroke:"#999",strokeWidth:1}}}function fr(t,e,n){return n.width<=n.availableWidth/3&&n.height<=n.availableHeight/3}dr._displayName="ColorScale",dt(dr.prototype,"axisConfig","labelConfig","legendConfig","rectConfig");function mr(t){for(let e=1;e<15;e++)if(Number(t.toPrecision(e))===t)return e;return 15}function pr(t,e=3){const[n,i]=t;if(e<=1)return[i];if(2===e)return[n,i];const o=h.ticks(n,i,4*e).filter(t=>t>n&&t<i),r=.15*(i-n),a=[];for(let t=1;t<e-1;t++){const s=n+(i-n)*t/(e-1),c=o.filter(t=>!a.includes(t)&&Math.abs(t-s)<=r);c.sort((t,e)=>mr(t)-mr(e)||Math.abs(t-s)-Math.abs(e-s)),c.length&&a.push(c[0])}return[n,...a.sort((t,e)=>t-e),i]}function gr(t){const e=t.scale.domain();if(e.length<2||!Number.isFinite(e[0])||!Number.isFinite(e[1])||e[0]===e[1])return{circles:[],lines:[],labels:[],width:0,height:0};const n=t.maxRadius??1/0,i=function(t,e){const n="function"==typeof t?t(e):Array.isArray(t)?t:pr(e,t??3);return Array.from(new Set(n.filter(t=>Number.isFinite(t)))).sort((t,e)=>e-t)}(t.values,e).filter(e=>t.scale(e)<=n+.5),o=i.map(e=>Math.max(0,t.scale(e)||0)),a=Math.max(0,...o);if(!i.length||!a)return{circles:[],lines:[],labels:[],width:0,height:0};const{padding:s,fontSize:c}=t,l=1.2*c,h=i.map(e=>t.tickFormat(e)),u=h.map(e=>r.textWidth(e,{"font-family":t.fontFamily,"font-size":c})),d=t.title?String(t.title):"",f=d?r.textWidth(d,{"font-family":t.titleFontFamily,"font-size":t.titleFontSize,"font-weight":t.titleFontWeight}):0,m=d?1.2*t.titleFontSize+2:0,p=2*a+t.lineLength+t.labelPadding+Math.max(...u),g=Math.max(p,f),y=Math.min(s+g/2,s+g-p+a),x=s+m+l/2+2*a,b=i.map((t,e)=>({value:t,cx:y,cy:x-o[e],r:o[e]})),_=y+a+t.lineLength+t.labelPadding,k=[],v=[];let w,M=-1/0;if(b.forEach((e,n)=>{const i=e.cy-e.r,o=Math.max(i,M+l);M=o,k.push({value:e.value,text:h[n],x:_,y:o,width:u[n]});const r=[[e.cx,i],[e.cx+a,i]];o!==i&&r.push([e.cx+a+t.lineLength/2,o]),r.push([_-t.labelPadding,o]),v.push({value:e.value,points:r})}),d){w={text:d,x:Math.min(Math.max(y,s+f/2),s+g-f/2),y:s+t.titleFontSize,width:f}}const S=Math.max(x,M+l/2)+s;return{circles:b,lines:v,labels:k,title:w,width:Math.ceil(g+2*s),height:Math.ceil(S)}}function yr(t,e){if(1===e||!Number.isFinite(e)||e<=0)return t;const[n,i]=t.domain(),o=t.invert?Math.max(n,Math.min(i,t.invert(t(i)/e))):i,r=(o<i?h.ticks(n,o,4).filter(t=>t>n&&t<=o).pop():void 0)??o,a=n=>t(n)*e;return a.domain=()=>[n,r],a}const xr=[{key:"labelPadding",coerce:"identity",default:4},{key:"lineLength",coerce:"identity",default:6},{key:"padding",coerce:"identity",default:4},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity"},{key:"tickFormat",coerce:"identity"},{key:"title",coerce:"identity"},{key:"values",coerce:"identity"}],br=t=>s.fontFamilyStringify(void 0===t?s.fontFamily:Array.isArray(t)?t:[t]);class _r extends Kt{labelConfig(t){return arguments.length?(this.schema.labelConfig=ut(this,"labelConfig",t),this):this.schema.labelConfig}lineConfig(t){return arguments.length?(this.schema.lineConfig=ut(this,"lineConfig",t),this):this.schema.lineConfig}shapeConfig(t){return arguments.length?(this.schema.shapeConfig=ut(this,"shapeConfig",t),this):this.schema.shapeConfig}titleConfig(t){return arguments.length?(this.schema.titleConfig=ut(this,"titleConfig",t),this):this.schema.titleConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}layout(){const t=this.schema.scale;if(!t||"function"!=typeof t.domain)return this._layout={circles:[],lines:[],labels:[],width:0,height:0};const e=this.schema.labelConfig,n=this.schema.titleConfig,i=this.schema.locale;return this._layout=gr({scale:t,values:this.schema.values,tickFormat:this.schema.tickFormat??(t=>d.formatAbbreviate(t,i)),fontFamily:br(e.fontFamily),fontSize:e.fontSize??10,title:this.schema.title,titleFontFamily:br(n.fontFamily),titleFontSize:n.fontSize??11,titleFontWeight:n.fontWeight??600,lineLength:this.schema.lineLength,labelPadding:this.schema.labelPadding,padding:this.schema.padding,maxRadius:this._maxRadius}),this._layout}outerBounds(){return{width:this._layout.width,height:this._layout.height}}toScene(t=0,e=0){const n=this._layout,i=this.schema.shapeConfig,o=this.schema.lineConfig,r=this.schema.labelConfig,a=this.schema.titleConfig,s=br(r.fontFamily),c=[];return n.circles.forEach(t=>c.push({type:"circle",key:`circle-${t.value}`,interactive:!1,cx:t.cx,cy:t.cy,r:t.r,paint:{...i}})),n.lines.forEach(t=>c.push({type:"line",key:`line-${t.value}`,interactive:!1,points:t.points,paint:{fill:"none",...o}})),n.labels.forEach(t=>c.push({type:"text",key:`label-${t.value}`,interactive:!1,x:0,y:0,transform:{x:t.x,y:t.y},lines:[{text:t.text,x:0,y:0,width:t.width}],font:{family:s,size:r.fontSize??10,anchor:"start",baseline:"middle"},paint:{fill:r.fontColor}})),n.title&&c.push({type:"text",key:"title",interactive:!1,x:0,y:0,transform:{x:n.title.x,y:n.title.y},lines:[{text:n.title.text,x:0,y:0,width:n.title.width}],font:{family:br(a.fontFamily),size:a.fontSize??11,weight:a.fontWeight??600,anchor:"middle",baseline:"alphabetic"},paint:{fill:a.fontColor}}),{type:"group",key:`SizeLegend-${this._uuid.slice(0,8)}`,transform:{x:t,y:e},children:c}}render(t){return this.layout(),"compute"!==this.schema.renderMode&&(void 0===this._select&&this.select(o.select("body").append("div").node()),this.schema.width=this._layout.width,this.schema.height=this._layout.height,te(this)),t&&setTimeout(t,0),this}constructor(){super(),xt(this,xr),this._layout={circles:[],lines:[],labels:[],width:0,height:0},this.schema.labelConfig={fontColor:e.colorDefaults.dark,fontSize:10},this.schema.lineConfig={stroke:e.colorDefaults.dark,strokeOpacity:.5,strokeWidth:1},this.schema.shapeConfig={fill:e.colorDefaults.dark,fillOpacity:.05,stroke:e.colorDefaults.dark,strokeOpacity:.6,strokeWidth:1},this.schema.titleConfig={fontColor:e.colorDefaults.dark,fontSize:11,fontWeight:600}}}_r._displayName="SizeLegend",dt(_r.prototype,"labelConfig","lineConfig","shapeConfig","titleConfig");class kr{exit(t,e){t.transition().duration(e).style("opacity",0).transition().remove(),this._isVisible=!1}hide({duration:t=600,callback:e}={}){return this.mask.call(this.exit.bind(this),t),this.elem.call(this.exit.bind(this),t),e&&setTimeout(e,t+100),this._isVisible=!1,this}render({callback:t,container:e="body",duration:n=600,html:i="Please Wait",mask:a="rgba(0, 0, 0, 0.05)",style:s={}}={}){const c=o.select(e);return this.mask=c.selectAll("div.d3plus-Mask").data(a?[a]:[]),this.mask=this.mask.enter().append("div").attr("class","d3plus-Mask").style("opacity",1).merge(this.mask),this.mask.exit().call(this.exit.bind(this),n),r.stylize(this.mask,{"background-color":"transparent",bottom:"0px",left:"0px",position:"absolute",right:"0px",top:"0px"}),this.elem=c.selectAll("div.d3plus-Message").data([i]),this.elem=this.elem.enter().append("div").attr("class","d3plus-Message").style("opacity",1).merge(this.elem).html(String),r.stylize(this.elem,s),t&&setTimeout(t,100),this._isVisible=!0,this}constructor(){this._isVisible=!1}}const vr=t=>t.trim().replace(/^(['"])(.*)\1$/,"$2");function wr(t,e){const n=(Array.isArray(t)?t:t.split(",")).map(vr).filter(Boolean);if(!e)return s.fontFamilyStringify(n);const i=vr(e),o=n.indexOf(i);return s.fontFamilyStringify(o<0?[i,...n]:n.slice(o))}function Mr(t,e){let n=0;if("number"==typeof t)n=t;else if("string"==typeof t){const i=parseFloat(t);Number.isFinite(i)&&(n=t.trim().endsWith("%")?i/100*e:i)}return Math.max(0,Math.min(e,Number.isFinite(n)?n:0))}function Sr(t){if(!t)return null;if(!0===t)return{top:0,right:0,bottom:0,left:0};const e=t.padding;return r.parseSides(e??0)}function Cr(t){return t.replace(/<[^>]+>/g,"")}function $r(t,e,n){return t.map((t,i)=>{const o=e?.[i];if(!o)return t;const a=function(t,e){const n=e.map(Cr);if(t.map(t=>t.text).join("")!==n.join(""))return null;const i=n.map(()=>[]);let o=0,r=0;for(const e of t){let t=e.text;for(;t;){for(;o<n.length-1&&r>=n[o].length;)o++,r=0;const a=Math.min(t.length,n[o].length-r)||t.length;i[o].push({...e,text:t.slice(0,a)}),t=t.slice(a),r+=a}}return i}(o,t.map(t=>t.text));return a?t.map((t,e)=>{const i=a[e],o=i.reduce((t,e,o)=>{const a=o===i.length-1?e.text.trimEnd():e.text;return t+r.textWidth(a,{...n,"font-weight":e.style?.weight??n["font-weight"],"font-style":e.style?.style??"normal"})},0);return{text:t.text,width:o,runs:i}}):null})}function Ar(t){const e={};for(const n of t.split(";")){const[t,i]=n.split(":").map(t=>t.trim());t&&i&&("font-weight"===t?e.weight=/^\d+$/.test(i)?Number(i):i:"font-style"===t&&(e.style="italic"===i?"italic":"normal"))}return void 0===e.weight&&void 0===e.style?void 0:e}function zr(t,e,n){let i=t.trimEnd().replace(/&([^;&]*)/g,(t,e)=>"amp"===e?t:`&amp;${e}`).replace(/<([^A-z^/]+)/g,(t,e)=>`&lt;${e}`).replace(/<$/g,"&lt;").replace(/(<[^>^/]+>)([^<^>]+)$/g,(t,e,n)=>`${e}${n}${e.replace("<","</")}`).replace(/^([^<^>]+)(<\/[^>]+>)/g,(t,e,n)=>`${n.replace("</","<")}${e}${n}`),o=n;o&&!i.startsWith("<")&&(i=`<${o}>${i}`,i.includes(`</${o}>`)||(i+=`</${o}>`));const r=/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g,a=[];let s,c=0;for(;null!==(s=r.exec(i));){s.index>c&&a.push({text:i.slice(c,s.index)});const n=s[1],r=s[2],l=e[n];l?(o=!t.includes(`</${n}>`)&&n,a.push({text:r,style:Ar(l)})):a.push({text:r}),c=s.index+s[0].length}return c<i.length&&a.push({text:i.slice(c)}),!a.length&&i&&a.push({text:i}),{runs:a,openTag:o}}function Dr(t,e,n,i){const{lineData:o,line:r,fS:a,lH:s,w:c,h:l,vA:h,style:u,wrap:d,kept:f,padding:m,path:p}=i,g=r*s,y=t.schema.rotate(e,n);let x=p||0===y?"top"===h?0:"middle"===h?l/2-g/2:l-g:0;p?x=0:x-=.1*s;const b=function(t,e){let n=null;if(t.schema.html){const i=t.schema.html;let o=!1;const r=[];let a=!1;for(const t of e){const{runs:e,openTag:n}=zr(t,i,o);r.push(e),o=n,e.some(t=>t.style)&&(a=!0)}a&&(n=r)}return n}(t,o),_=t.schema.textAnchor(e,n),k=f.length===o.length,v=(t,e)=>o.map((n,i)=>k?t[f[i]]??e:e);return{aH:t.schema.ariaHidden(e,n),data:e,i:n,lines:o,lineRuns:b,hardBreaks:v(d.hardBreaks,!0),lineWords:"justify"===_?$r(v(d.lineWords,[]),b,u):null,fC:t.schema.fontColor(e,n),fStroke:t.schema.fontStroke(e,n),fSW:t.schema.fontStrokeWidth(e,n),fF:wr(t.schema.fontFamily(e,n),u["font-family"]),fO:t.schema.fontOpacity(e,n),fW:u["font-weight"],id:t.schema.id(e,n),pE:t.schema.pointerEvents(e,n),tA:_,vA:t.schema.verticalAlign(e,n),widths:v(d.widths,0),truncated:d.truncated,fS:a,lH:s,w:c,h:l,r:y,x:t.schema.x(e,n)+(p?0:m.left),y:t.schema.y(e,n)+(p?0:x+m.top),path:p?{d:p.d,side:p.side,offset:p.offset}:null,pad:m,yP:x,hit:Sr(t.schema.hitbox(e,n))}}const Lr={hardBreaks:[],lines:[],lineWords:[],nextWord:0,sentence:"",truncated:!1,widths:[],words:[]};function Fr(t,e,n){const i=t;let o=t.schema.text(e,n);if(void 0===o)return null;o=`${o}`.trim();const c=t.schema.fontResize(e,n),l=t.schema.lineHeight(e,n)/t.schema.fontSize(e,n);let u=c?t.schema.fontMax(e,n):t.schema.fontSize(e,n),d=c?u*l:t.schema.lineHeight(e,n),f=1,m=[],p=[],g=Lr;const y={"font-family":r.fontExists(t.schema.fontFamily(e,n)),"font-size":u,"font-weight":t.schema.fontWeight(e,n),"line-height":d},x=r.parseSides(t.schema.padding(e,n)),b=function(t,e,n){const i=t.schema.textPath(e,n);if("string"!=typeof i||!i.trim())return null;const o=a.samplePath(i).total;return o?{d:i,side:"right"===t.schema.side(e,n)?"right":"left",offset:Mr(t.schema.startOffset(e,n),o),length:o}:null}(t,e,n),{w:_,h:k}=function(t,e,n,i,o,r){const a=t.schema.height(e,n)-(i.top+i.bottom);return o?{w:o.length-o.offset,h:Math.max(a,r+1)}:{w:t.schema.width(e,n)-(i.left+i.right),h:a}}(t,e,n,x,b,d),v=t.schema.shape(e,n),w=s.textWrap().fontFamily(y["font-family"]).fontSize(u).fontWeight(y["font-weight"]).lineHeight(d).maxLines(b?1:t.schema.maxLines(e,n)).height(k).overflow(t.schema.overflow(e,n)).shape(v).width(_).split(t.schema.split).ellipsis((e,n)=>t.schema.ellipsis(e,n)).truncateWord(!!t.schema.truncateWord(e,n)),M=t.schema.fontMax(e,n),S=t.schema.fontMin(e,n),C=t.schema.verticalAlign(e,n),$=t.schema.split(o,n);return _>(c?S:0)&&(k>d||c&&k>S*l)&&(c&&(u=function(t,e,n,i,o,a,s){const c=r.textWidth(o,a),l=1.165+e/n*.1,u=e*n*("circle"===s?Math.PI/4:1),d=h.max(c),f=h.sum(c,t=>t*i)*l;if(d>e||f>u){const n=Math.sqrt(u/f),i=e/d,o=h.min([n,i]);t=Math.floor(t*o)}const m=Math.floor(.8*n);return t>m&&(t=m),t}(u,_,k,d,$,y,v)),function t(){const e=()=>{f<1&&(m=[i.schema.ellipsis("",f)])};if(c&&(u=h.max([u,S]),u=h.min([u,M]),d=u*l,w.fontSize(u).lineHeight(d),y["font-size"]=u,y["line-height"]=d),g=w(o),p=g.lines.flatMap((t,e)=>""!==t?[e]:[]),m=p.map(t=>g.lines[t]),f=m.length,g.truncated)if(c){if(u--,u<S)return u=S,void e();t()}else e()}()),m.length?Dr(t,e,n,{lineData:m,line:f,fS:u,lH:d,w:_,h:k,vA:C,style:y,wrap:g,kept:p,padding:x,path:b}):null}function Nr(t,e){return 0===t.r||"top"===t.vA?(e+1)*t.lH-(t.lH-t.fS):"middle"===t.vA?(t.h+t.fS)/2-(t.lH-t.fS)+(e-t.lines.length/2+.5)*t.lH:t.h-2*(t.lH-t.fS)-(t.lines.length-(e+1))*t.lH+2*Math.cos(Math.PI*t.r/180)}function Br(t,e,n){const i=t.lines.length-1,o=a.alignLines(t.tA,e,t.lines.map((e,n)=>({width:t.widths[n]??0,words:t.lineWords?.[n]??void 0,paragraphEnd:n===i||t.hardBreaks[n]})),n),r=t.lines.map((e,n)=>{const{x:i,width:r,wordX:a}=o.lines[n],s=t.lineWords?.[n],c=a&&s?s.flatMap((t,e)=>(t.runs??[{text:t.text}]).map((t,n)=>n?t:{...t,x:a[e]})):t.lineRuns?.[n]??void 0;return c?{text:e,x:i,width:r,runs:c}:{text:e,x:i,width:r}});return{anchor:o.anchor,lines:r}}function Er(t,e,n){return{family:t.fF,size:t.fS,weight:t.fW,anchor:e,baseline:"alphabetic",dir:n?"rtl":"ltr"}}function Rr(t){return{fill:t.fC,opacity:t.fO,...t.fStroke&&"transparent"!==t.fStroke?{stroke:t.fStroke}:{},...t.fSW?{strokeWidth:t.fSW}:{}}}function Pr(t,e){return{x:t.x,y:t.y,rotate:t.r,rotateAnchor:e}}function Tr(t,e){const{anchor:n,lines:i}=Br(t,t.w,e);if(t.path){const e=t.path.offset;return{anchor:n,lines:i.map(t=>({...t,x:t.x+e,y:0}))}}const o=function(t,e,n){return"start"!==e||n?0:2*Math.sin(Math.PI*t.r/180)}(t,n,e);return{anchor:n,lines:i.map((e,n)=>({...e,x:e.x+o,...e.runs&&o?{runs:e.runs.map(t=>void 0===t.x?t:{...t,x:t.x+o})}:{},y:Nr(t,n)}))}}function Or(t,e,n){const{anchor:i,lines:o}=Tr(t,n),r="true"===t.aH||!0===t.aH;return{type:"text",key:t.id,id:`d3plus-textBox-${s.strip(t.id)}`,datum:t.data,index:t.i,x:0,y:0,width:t.w,height:t.h,lines:o,font:Er(t,i,n),paint:Rr(t),transform:Pr(t,e),aria:r?{hidden:!0}:void 0,interactive:"none"!==t.pE,...t.path?{path:{d:t.path.d,side:t.path.side}}:{}}}function Wr(t,e,n){const i=Or(t,e,n),o=function(t,e){const n=t.hit;if(!n)return null;let i,o,r,s;if(t.path){const{points:e}=a.textPathSamples({d:t.path.d,side:t.path.side}),n=e.map(t=>t[0]),c=e.map(t=>t[1]);i=Math.min(...n)-t.fS,o=Math.min(...c)-t.fS,r=Math.max(...n)-i+t.fS,s=Math.max(...c)-o+t.fS}else i=-t.pad.left,o=-(t.yP+t.pad.top),r=t.w+t.pad.left+t.pad.right,s=t.h+t.pad.top+t.pad.bottom;return{type:"rect",key:`${t.id}::hit`,datum:t.data,index:t.i,x:i-n.left,y:o-n.top,width:r+n.left+n.right,height:s+n.top+n.bottom,paint:{fill:"transparent"},transform:Pr(t,e),aria:{hidden:!0},interactive:"none"!==t.pE}}(t,e);return o?[o,i]:[i]}const Hr={i:"font-style: italic;",em:"font-style: italic;",b:"font-weight: bold;",strong:"font-weight: bold;"},jr=[{key:"ariaHidden",coerce:"const",default:H("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(t,e)=>e?`${t.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:H("black")},{key:"fontFamily",coerce:"const",default:H(s.fontFamily)},{key:"fontMax",coerce:"const",default:H(50)},{key:"fontMin",coerce:"const",default:H(8)},{key:"fontOpacity",coerce:"const",default:H(1)},{key:"fontResize",coerce:"const",default:H(!1)},{key:"fontSize",coerce:"const",default:H(10)},{key:"fontStroke",coerce:"const",default:H("transparent")},{key:"fontStrokeWidth",coerce:"const",default:H(0)},{key:"fontWeight",coerce:"const",default:H(400)},{key:"height",coerce:"const",default:I("height",200)},{key:"hitbox",coerce:"const",default:H(!1)},{key:"id",coerce:"const",default:(t,e)=>t.id||`${e}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:H(null)},{key:"overflow",coerce:"const",default:H(!1)},{key:"padding",coerce:"const",default:H(0)},{key:"pointerEvents",coerce:"const",default:H("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:H(0)},{key:"rotateAnchor",coerce:"const",default:t=>[t.w/2,t.h/2]},{key:"shape",coerce:"const",default:t=>t.__d3plusWrapShape__??"square"},{key:"side",coerce:"const",default:H("left")},{key:"split",coerce:"identity",default:s.textSplit},{key:"startOffset",coerce:"const",default:H(0)},{key:"text",coerce:"const",default:I("text")},{key:"textAnchor",coerce:"const",default:H("start")},{key:"textPath",coerce:"const",default:H(!1)},{key:"truncateWord",coerce:"const",default:H(!1)},{key:"verticalAlign",coerce:"const",default:H("top")},{key:"width",coerce:"const",default:I("width",200)},{key:"x",coerce:"const",default:I("x",0)},{key:"y",coerce:"const",default:I("y",0)}];class Ir extends Kt{_textData(){return this._data.reduce((t,e,n)=>{const i=Fr(this,e,n);return i&&t.push(i),t},[])}toScene(){const t=r.rtl();return{type:"group",key:"textBox-group",children:this._textData().flatMap(e=>Wr(e,this.schema.rotateAnchor(e,e.i),t))}}render(t){if("compute"===this.schema.renderMode)return t&&setTimeout(t,0),this;if(void 0===this._select&&"undefined"!=typeof document){const t=o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).node();this.select(t)}if(this._select){const t=this._select,e=t&&"function"==typeof t.node?t.node():t;if(e){const t=this.toScene(),n=t.children.reduce((t,e)=>Math.max(t,(e.transform?.x??0)+(e.width??0)),0),i=t.children.reduce((t,e)=>Math.max(t,(e.transform?.y??0)+(e.height??0)),0),o="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():null,r=o&&o.width||Number(e.getAttribute("width"))||e.clientWidth||0,s=o&&o.height||Number(e.getAttribute("height"))||e.clientHeight||0,c=Math.max(r,n)||400,l=Math.max(s,i)||300;for(;e.firstChild;)e.removeChild(e.firstChild);const h={root:t,width:c,height:l},u=new a.SvgRenderer;u.mount({container:e,width:c,height:l}),u.drawScene(h),this._sceneRenderer=u,Ht(this)}}return t&&setTimeout(t,0),this}data(t){return arguments.length?(this._data=t,this):this._data}html(t){return arguments.length?(this.schema.html="boolean"==typeof t?!!t&&Hr:t,this):this.schema.html}select(t){return arguments.length?(this._select=o.select(t),this):this._select}constructor(){super(),xt(this,jr),this.schema.lineHeight=(t,e)=>1.2*this.schema.fontSize(t,e),this.schema.html=Hr}}Ir._displayName="TextBox";const Gr=t=>"function"==typeof t?t():t;function qr(t,e){const n=Gr(t),i="number"==typeof n&&Number.isFinite(n)?n:1,o=Gr(e);return{min:i,max:"number"==typeof o&&Number.isFinite(o)?Math.max(Math.floor(o),Math.ceil(i),1):1/0}}function Vr(t,e,n,i,o="hi",r="lo"){const a=i.min-1;Math.abs(e-t)<a&&("lo"===r?(e=Math.min(n-1,t+a),t=Math.max(0,e-a)):(t=Math.max(0,e-a),e=Math.min(n-1,t+a)));const s=i.max-1;return e-t>s&&("lo"===o?e=t+s:t=e-s),[t,e]}function Yr(t){const e=qr(t.brushMin,t.brushMax);return!1===t.brushing?{...e,min:1}:e}const Kr="#bbb";const Ur=t=>()=>J(t._theme,t=>t.accent,"#228be6");function Xr(t){return t.slice().sort((t,e)=>Number(t)-Number(e))}function Zr(t){return{labelBounds:e=>"buttons"===t._buttonBehaviorCurrent?{x:e.labelBounds.x,y:-t.schema.buttonHeight/2+1,width:e.labelBounds.width,height:t.schema.buttonHeight}:e.labelBounds,labelConfig:{fontColor:()=>uo(t),fontSize:()=>12,verticalAlign:()=>"buttons"===t._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===t._buttonBehaviorCurrent?function(t){return t._theme?.painted||t._theme?.dark?lo(t):"#fff"}(t):Kr,stroke:()=>"buttons"===t._buttonBehaviorCurrent?Kr:"transparent",height:e=>"buttons"===t._buttonBehaviorCurrent?t.schema.buttonHeight:e.tick?t.schema.handleSize:0,width:e=>"buttons"===t._buttonBehaviorCurrent?t._ticksWidth/t._availableTicks.length:e.tick?t.schema.domain.map(Number).includes(e.id)?2:1:0,y:e=>"buttons"===t._buttonBehaviorCurrent?"middle"===t.schema.align?t.schema.height/2:"start"===t.schema.align?t._margin.top+t.schema.buttonHeight/2:t.schema.height-t.schema.buttonHeight/2-t._margin.bottom:e.y,rx:e=>"buttons"===t._buttonBehaviorCurrent?0:t.schema.domain.map(Number).includes(e.id)?1:0,ry:e=>"buttons"===t._buttonBehaviorCurrent?0:t.schema.domain.map(Number).includes(e.id)?1:0}}function Qr(t){t.schema.brushFilter=t=>{const e=t;return!e.button&&e.detail<2},t.schema.domain=[2001,2010],t.schema.gridSize=0,t.schema.handleConfig={fill:()=>t.schema.colorDefaults.light,stroke:Ur(t),"stroke-width":2,rx:2,ry:2},t.schema.height=100,t.schema.labelOffset=!1,t._labelRotationSetting=!1,t.schema.on={},t.orient("bottom"),t._playButtonClass=new Ir,t.schema.playButtonConfig={fontColor:()=>uo(t),fontSize:15,text:()=>t._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},t.schema.selectionConfig={fill:Ur(t),"fill-opacity":()=>"buttons"===t._buttonBehaviorCurrent?.3:1,"stroke-width":0},t.schema.shape="Rect",t.schema.barConfig=r.assign({},t.schema.barConfig,{stroke:()=>"buttons"===t._buttonBehaviorCurrent?"transparent":Kr,"stroke-width":()=>"buttons"===t._buttonBehaviorCurrent?0:1}),t.schema.shapeConfig=r.assign({},t.schema.shapeConfig,Zr(t)),t._buttonBehaviorCurrent="auto",t._hiddenHandles=!1,t._paddingLeft=0,t._ticksWidth=0}const Jr=["ticks","buttons"];function ta(t,e){return Jr.includes(e)?`${t}-${e}`:null}function ea(t,e,n){if(!t)return;const i=ta(e,n);for(const n of Jr){const o=`${e}-${n}`;t.classList.toggle(o,o===i)}}function na(t,e,n,i=n){const o=Yr(t.schema);if(o.min<=1&&o.max===1/0||!n.length)return;const a=n.map(Number),s=[e[0],e[e.length-1]].map(t=>function(t,e){let n=-1;return t.forEach((i,o)=>{(n<0||Math.abs(i-e)<Math.abs(t[n]-e))&&(n=o)}),n}(a,Number(t))),c=Math.min(...s),l=Math.max(...s),[h,u]=Vr(c,l,a.length,o,"hi","hi");h===c&&u===l||([e[0],e[e.length-1]]=Xr([n[h],n[u]]),t.schema.selection=[i[h],i[u]].map(t=>r.date(t)))}const ia=[{key:"buttonPadding",coerce:"identity",default:10},{key:"brushCursor",coerce:"identity",default:"pointer"},{key:"brushing",coerce:"identity",default:!0},{key:"brushFilter",coerce:"identity"},{key:"brushMax",coerce:"const"},{key:"brushMin",coerce:"const",default:H(1)},{key:"buttonAlign",coerce:"identity",default:"middle"},{key:"buttonBehavior",coerce:"identity",default:"auto"},{key:"buttonHeight",coerce:"identity",default:24},{key:"handleSize",coerce:"identity",default:6},{key:"playButton",coerce:"identity",default:!0},{key:"playButtonInterval",coerce:"identity",default:1e3},{key:"selection",coerce:"identity"},{key:"snapping",coerce:"identity",default:!0}];class oa extends zo{_brushBrush(t){if(!t.sourceEvent||null===t.selection||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render()),this._updateDomain(t)),this._brushStyle(),t.sourceEvent&&!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const e=o.pointers(t,this._select.node());e.length&&this._brushGroup.selectAll(".handle").filter(t=>"e"===t.type).attr("x",e[0][0]-this.schema.handleSize/2)}this.schema.on.brush&&this.schema.on.brush(this.schema.selection)}_snapBrushVisual(t){const e=this._hiddenHandles?0:this.schema.handleSize;this._brushGroup.selectAll(".selection").attr("x",t[0]).attr("width",t[1]-t[0]),this._brushGroup.selectAll(".handle").attr("x",n=>("e"===n.type[n.type.length-1]?t[1]:t[0])-e/2)}_brushEnd(t){if(!t.sourceEvent)return;const e=this._updateDomain(t);this._brushStyle();const n=this._brushGroup.transition(this._transition);this.schema.brushing&&this.schema.duration||n.duration(0),n.call(this._brush.move,this._updateBrushLimit(e)),this.schema.on.end&&this.schema.on.end(this.schema.selection)}_brushStart(t){null===t.sourceEvent||this.schema.brushing&&!this.schema.snapping||(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),null!==t.selection&&this._snapBrushVisual(this._updateBrushLimit(this._updateDomain(t)))),this._brushStyle(),this.schema.on.start&&this.schema.on.start(t)}_brushStyle(){const{height:t}=this._position,e="Circle"===this.schema.shape?"function"==typeof this.schema.shapeConfig.r?2*this.schema.shapeConfig.r({tick:!0}):this.schema.shapeConfig.r:"Rect"===this.schema.shape?"function"==typeof this.schema.shapeConfig[t]?this.schema.shapeConfig[t]({tick:!0}):this.schema.shapeConfig[t]:this.schema.tickSize,n=this._brushGroup.selectAll(".selection").call(r.attrize,this.schema.selectionConfig).attr("transform","translate(0,-1)").attr("height",e+2).style("display",()=>this.schema.brushing||this._hiddenHandles?null:"none"),i=this._brushGroup.selectAll(".handle").call(r.attrize,this.schema.handleConfig).style("display",t=>this._hiddenHandles||!this.schema.brushing&&"w"===t.type?"none":null).attr("transform",t=>"buttons"===this._buttonBehaviorCurrent?`translate(${"w"===t.type?-this.schema.handleSize/2:0},-1)`:"").attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight+2:e+this.schema.handleSize);if(!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const t=+n.attr("x")||0,e=+n.attr("width")||0;i.filter(t=>"e"===t.type).attr("x",t+e/2-this.schema.handleSize/2)}if(this._brushGroup.selectAll(".overlay").attr("x",this._paddingLeft).attr("cursor",function(t){const e=t.schema.brushCursor;return"function"==typeof e?e(t._buttonBehaviorCurrent):e??null}(this)).attr("transform",`translate(0,${"buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight/2:-this.schema.handleSize})`).attr("width","buttons"===this._buttonBehaviorCurrent?this._ticksWidth:this.schema.width).attr("height","buttons"===this._buttonBehaviorCurrent?this.schema.buttonHeight:2*this.schema.handleSize),"buttons"===this._buttonBehaviorCurrent){const t="middle"===this.schema.align?this.schema.height/2-this.schema.buttonHeight/2:"start"===this.schema.align?this._margin.top:this.schema.height-this.schema.buttonHeight-this._margin.bottom;i.attr("y",t),n.attr("y",t)}}_updateDomain(t){const e=o.pointers(t,this._select.node()),n=(t.selection&&this.schema.brushing||!e.length?t.selection:[e[0][0],e[0][0]]).map(Number),i="ticks"===this._buttonBehaviorCurrent,a=Xr(this._availableTicks).map(Number),s=this._d3Scale.range(),c=this._availableTicks.map(Number),l=t=>a.indexOf(i?f.closest(+this._d3Scale.invert(t),a):c[s.indexOf(f.closest(t,s))]),h=i?a:s,u=t.selection,d=e.length?e[0][0]:NaN,m=u&&Math.abs(d-u[0])<Math.abs(d-u[1])?"lo":"hi",[p,g]=function(t,e,n,i,o=!1){const r=Math.min(...t),a=Math.max(...t),s=t["lo"===i?0:1]===r?"lo":"hi",c=o?((t,e,n)=>t===e?"lo":n)(r,a,s):"lo";return Vr(r,a,e,n,s,c)}([l(n[0]),l(n[1])],a.length,Yr(this.schema),m,!i),y=t=>s[c.indexOf(a[t])],x=i?[r.date(a[p]),r.date(a[g])]:Xr([y(p),y(g)]),b=+x[0]===+x[1];return"brush"!==t.type&&"end"!==t.type||(this.schema.selection="ticks"===this._buttonBehaviorCurrent?b?x[0]:x:b?r.date(this._availableTicks[h.indexOf(x[0])]):Xr([r.date(this._availableTicks[h.indexOf(x[0])]),r.date(this._availableTicks[h.indexOf(x[1])])])),x}_updateBrushLimit(t){const e="ticks"===this._buttonBehaviorCurrent?Xr(t.map(r.date).map(t=>this._d3Scale(t))):t;if(e[0]===e[1]&&(e[0]-=.1,e[1]+=.1),"buttons"===this._buttonBehaviorCurrent){const t=this._hiddenHandles?0:this.schema.handleSize,n=.5*(this._ticksWidth/this._availableTicks.length-t);e[0]-=n,e[1]+=n}return e}_togglePlay(){if(this._playTimer)return clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),void this._onPlayToggle?.();const t=t=>{this.selection(t).render(),this.schema.on.end&&this.schema.on.end(this.schema.selection)};let e=!0;const n=()=>{const n=Xr(("ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks)||[]);if(!n.length)return;let i=this.schema.selection||[this.schema.domain[this.schema.domain.length-1]];i instanceof Array||(i=[i]),i=i.map(r.date).map(Number),1===i.length&&i.push(i[0]);const o=n.map(Number),a=o.indexOf(i[0]),s=o.indexOf(i[i.length-1]);s===o.length-1?e?t([n[0],n[s-a]]):(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render(),this._onPlayToggle?.()):(s+1===o.length-1&&(this._playTimer&&clearInterval(this._playTimer),this._playTimer=!1),t([n[a+1],n[s+1]])),e=!1},i=Number(this.schema.duration)||0,o=i>0?i:this.schema.playButtonInterval;this._playTimer=setInterval(n,o),n(),this._onPlayToggle?.()}_isFullRangeSelected(){const t="ticks"===this._buttonBehaviorCurrent?this._availableTicks:this.schema.ticks;if(!t||t.length<2)return!1;if(null==this.schema.selection)return!1;const e=(this.schema.selection instanceof Array?this.schema.selection:[this.schema.selection]).map(r.date).map(Number),n=t.map(Number);return Math.min(...e)<=Math.min(...n)&&Math.max(...e)>=Math.max(...n)}toScene(){const t=super.toScene(),e=this._playButtonClass;return this.schema.playButton&&e&&"function"==typeof e.toScene&&e._data&&e._data.length&&t.children.push(e.toScene()),t}render(t){const{height:e,y:n}=this._position,{ticks:i,tickFormat:o}=function(t){t.schema.ticks&&(t.schema.ticks=vi(t.schema.ticks)),t._data&&(t._data=vi(t._data));let e=t.schema.ticks?t.schema.ticks:t.schema.domain.map(r.date);if(!t.schema.ticks){const n=c.scaleTime().domain(e).range([0,t.schema.width]);e=n.ticks()}const n=t.schema.timeLocale||l.locale[t.schema.locale]||l.locale["en-US"];let i;void 0===t._userFormat&&(t._userFormat=t.schema.tickFormat||!1);const o=t.schema.tickFormat=t._userFormat?t._userFormat:t=>(i&&i.format===g.timeFormat||(i={format:g.timeFormat,label:d.dateFormatter(e,g.timeFormat)}),i.label(t).replace(/^Q/g,n.quarter));return{ticks:e,tickFormat:o}}(this);!function(t,e,n){if(t._ticksWidth=t.schema.width,["auto","buttons"].includes(t.schema.buttonBehavior)){let i=0;e.forEach((e,o)=>{const{fontFamily:a,fontSize:c}=t.schema.shapeConfig.labelConfig,l="function"==typeof a?a(e,o):a,u="function"==typeof c?c(e,o):c,d=s.textWrap().fontFamily(l).fontSize(u).lineHeight(t.schema.shapeConfig.lineHeight?t.schema.shapeConfig.lineHeight(e,o):void 0)(n(e));let f=d.lines.length?Math.ceil(h.max(d.lines.map(t=>r.textWidth(t,{"font-family":l,"font-size":u}))))+u/4:0;f%2&&f++,i<f&&(i=f+2*t.schema.buttonPadding)}),t._ticksWidth=i*e.length}}(this,i,o);const u=this.schema.playButton?this.schema.playButtonConfig.width||this.schema.buttonHeight:0,f=function(t,e,n){const i=t.schema.width-n;t._buttonBehaviorCurrent="auto"===t.schema.buttonBehavior?t._ticksWidth<i?"buttons":"ticks":t.schema.buttonBehavior;const o=t._hiddenHandles="buttons"===t._buttonBehaviorCurrent&&!t.schema.brushing;if("buttons"===t._buttonBehaviorCurrent){t.schema.scale="ordinal",t.schema.domain=t.schema.ticks?t.schema.ticks:e,t.schema.ticks=t.schema.domain;const i=.5*t._ticksWidth/t.schema.ticks.length,o=t.schema.width-t._ticksWidth-n;t._paddingLeft="middle"===t.schema.buttonAlign?o/2+n:"end"===t.schema.buttonAlign?o+n:n,t.schema.range=[t._paddingLeft+i,t._paddingLeft+t._ticksWidth-i]}else t.schema.scale="time",t.schema.domain=h.extent(e),t.schema.range=[n?1.5*n:void 0,void 0],t._paddingLeft=n;return o}(this,i,u);if(super.render(t),function(t,e,n,i){const o=t._outerBounds[i],a=t._d3Scale.range(),[s,c]="buttons"===t._buttonBehaviorCurrent?[t._paddingLeft,t._paddingLeft+t._ticksWidth]:[a[0],a[a.length-1]],l=t._brush=p.brushX().extent([[s,o],[c,o+t._outerBounds[n]]]).filter(t.schema.brushFilter).handleSize(e?0:t.schema.handleSize).on("start",t._brushStart.bind(t)).on("brush",t._brushBrush.bind(t)).on("end",t._brushEnd.bind(t)),h=Xr(("ticks"===t._buttonBehaviorCurrent?t._availableTicks:t.schema.ticks)||[]),u=e=>{const n=h[h.map(Number).indexOf(+e)];return void 0===n?void 0:t._d3Scale(n)},d="ticks"===t._buttonBehaviorCurrent?h:h.map(u),f=Xr([t.schema.brushMin()>d.length?d[0]:d[d.length-t.schema.brushMin()],d[d.length-1]]),m=void 0===t.schema.selection?f:t.schema.selection instanceof Array?"buttons"===t._buttonBehaviorCurrent?Xr(t.schema.selection.map(r.date).map(u)):t.schema.selection.map(r.date):"buttons"===t._buttonBehaviorCurrent?[u(r.date(t.schema.selection))]:[t.schema.selection];1===m.length&&m.push(m[0]),na(t,m,d,h),t._updateBrushLimit(m),t._brushGroup=r.elem("g.brushGroup",{parent:t._group});const g=t._brushGroup.call(l).transition(t._transition);t.schema.duration||g.duration(0),g.call(l.move,"ticks"===t._buttonBehaviorCurrent?t._updateBrushLimit(m):m),t._outerBounds.y-=t.schema.handleSize/2,t._outerBounds.height+=t.schema.handleSize/2}(this,f,e,n),function(t,e){const n=r.elem("g.d3plus-Timeline-play",{parent:t._group}),i=t.schema.playButton?[{x:t._paddingLeft-e,y:"buttons"===t._buttonBehaviorCurrent?"middle"===t.schema.align?t.schema.height/2-t.schema.buttonHeight/2:"start"===t.schema.align?t._margin.top:t.schema.height-t.schema.buttonHeight-t._margin.bottom:t._outerBounds.y,width:e,height:t.schema.buttonHeight}]:[],o=t._isFullRangeSelected();t._playButtonClass.renderMode("compute").data(i).select(n.node()).config(Qt.bind(t)(t.schema.playButtonConfig)),o&&t._playButtonClass.config({fontColor:t.schema.colorDefaults.missing}),t._playButtonClass.render();const a=r.elem("rect.d3plus-Timeline-play-hit",{parent:n,condition:i.length>0});if(i.length){const e=i[0];a.attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height).attr("fill","transparent").attr("cursor",o?"default":"pointer").style("pointer-events",o?"none":"all").on("click",()=>{t._isFullRangeSelected()||t._togglePlay()})}}(this,u),ea(this._group?.node(),"d3plus-Timeline",this._buttonBehaviorCurrent),"compute"!==this.schema.renderMode&&this._select&&(function(t,e){const n=t._select,i=n&&"function"==typeof n.node?n.node():null;if(!(i instanceof Element))return;const o=i,r=t.schema.width??400,s=t.schema.height??100,c=t;c._sceneRenderer?c._sceneRenderer.resize(r,s):(c._sceneRenderer=new a.SvgRenderer,c._sceneRenderer.mount({container:o,width:r,height:s})),c._sceneRenderer.drawScene({root:{type:"group",key:"root",children:[e]},width:r,height:s},{duration:0}),Ht(t)}(this,this.toScene()),this._group)){const t=this._select.node(),e=this._group.node();t instanceof Element&&e instanceof Element&&e.parentNode===t&&t.appendChild(e)}return this}handleConfig(t){return arguments.length?(this.schema.handleConfig=ut(this,"handleConfig",t),this):this.schema.handleConfig}on(t,e){return 2===arguments.length?(this.schema.on[t]=e,this):arguments.length?"string"==typeof t?this.schema.on[t]:(this.schema.on=r.assign({},this.schema.on,t),this):this.schema.on}playButtonConfig(t){return arguments.length?(this.schema.playButtonConfig=ut(this,"playButtonConfig",t),this):this.schema.playButtonConfig}selectionConfig(t){return arguments.length?(this.schema.selectionConfig=ut(this,"selectionConfig",t),this):this.schema.selectionConfig}constructor(){super(),xt(this,ia),Qr(this),this._managesOwnScenePaint=!0}}function ra(t=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:t[0],y:t[1],top:t[1],right:t[0],bottom:t[1],left:t[0]})}}async function aa(t,e,n,i,o,r){const{x:a,y:s,placement:c,middlewareData:l}=await m.computePosition(t,e,{strategy:"fixed",placement:"top",middleware:[m.offset(i+o),m.flip({fallbackPlacements:["bottom"],padding:5}),m.shift({padding:5}),m.arrow({element:n})]});Object.assign(e.style,{position:"fixed",left:`${a}px`,top:`${s}px`,visibility:"visible"});const h="bottom"===c,u=parseFloat(n.style.borderRightWidth)||0;h?(n.style.transform="rotate(225deg)",n.style.top=`-${r/2+u}px`,n.style.bottom=""):(n.style.transform="rotate(45deg)",n.style.bottom=`-${r/2+u}px`,n.style.top=""),n.style.left=null!=l.arrow?.x?`${l.arrow.x}px`:""}oa._displayName="Timeline",dt(oa.prototype,"handleConfig","playButtonConfig","selectionConfig");const sa=['[id="d3plus-portal"]',".d3plus-tooltip-portal",".d3plus-tooltip",".d3plus-tooltip-title",".d3plus-tooltip-body",".d3plus-tooltip-footer",".d3plus-tooltip-arrow",".d3plus-tooltip-table",".d3plus-tooltip-thead",".d3plus-tooltip-tbody"];function ca(t,e,n,i){return`${i?`d3plus-tooltip-${i}`:"d3plus-tooltip"}-${t._uuid}-${e?t.schema.id(e,n):""}`}function la(t,e,n,i){e.append("div").attr("class",`d3plus-tooltip-${i}`).attr("id",(e,n)=>ca(t,e,n,i));const o=n.select(`.d3plus-tooltip-${i}`).html((e,n)=>t.schema[i](e,n)).style("display",(e,n)=>{const o=t.schema[i](e,n);return!1!==o&&null!=o?"block":"none"});r.stylize(o,t.schema[`${i}Style`])}function ha(t,e){e.style("background",t.schema.background).style("border-radius",t.schema.borderRadius).style("pointer-events",t.schema.pointerEvents).style("padding",t.schema.padding).style("max-width",t.schema.maxWidth).style("min-width",t.schema.minWidth).style("width",t.schema.width).style("height",t.schema.height).style("border",t.schema.border)}const ua=t=>(t._theme??Y).tooltip;const da="d3plus-tooltip",fa=[{key:"arrow",coerce:"const",default:I("arrow","")},{key:"background",coerce:"const",factory:t=>()=>J(t._theme,t=>t.tooltip.background,t.schema.colorDefaults.light)},{key:"body",coerce:"const",default:I("body","")},{key:"border",coerce:"const",factory:t=>()=>`1px solid ${ua(t).border}`},{key:"borderRadius",coerce:"const",default:H("4px")},{key:"footer",coerce:"const",default:I("footer","")},{key:"height",coerce:"const",default:H("auto")},{key:"id",coerce:"const",default:(t,e)=>`${e}`},{key:"offset",coerce:"const",default:H(5)},{key:"padding",coerce:"const",default:H("10px")},{key:"pointerEvents",coerce:"const",default:H("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:I("title","")},{key:"titleSwatch",coerce:"identity",default:!0},{key:"maxWidth",coerce:"const",default:H("300px")},{key:"minWidth",coerce:"const",default:H("200px")},{key:"width",coerce:"const",default:H("auto")}];class ma extends Kt{render(t){const e=this,n=`d3plus-tooltip-${this._uuid}-`,i=function(t){if(!t._parentEl)return r.elem("div#d3plus-portal");let e=t._portalEl??null;return e&&e.isConnected||(e=document.createElement("div"),e.setAttribute("class","d3plus-tooltip-portal"),e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="0",e.style.height="0",e.style.pointerEvents="none",document.body.appendChild(e),t._portalEl=e),o.select(e)}(this);a.resetInjectedBoxes(i.node(),sa);const s=i.selectAll(`.${da}`).filter(function(){return this.id.startsWith(n)}).data(this._data,this.schema.id),c=s.enter().append("div").attr("class",da),l=s.merge(c);return l.each(function(){this instanceof Element&&Wt(this,e.schema.className,[da])}),r.stylize(l,this.schema.tooltipStyle),la(this,c,l,"title"),la(this,c,l,"body"),function(t,e,n,i){const o=e.append("table").attr("class","d3plus-tooltip-table"),a=n.select(".d3plus-tooltip-table");r.stylize(a,t.schema.tableStyle),o.append("thead").attr("class","d3plus-tooltip-thead");const s=n.select(".d3plus-tooltip-thead");r.stylize(s,t.schema.theadStyle);const c=s.selectAll("tr").data([0]),l=c.enter().append("tr");c.exit().remove();const h=c.merge(l);r.stylize(h,t.schema.trStyle);const u=h.selectAll("th").data(t.schema.thead),d=u.enter().append("th").merge(u).html(i);r.stylize(d,t.schema.thStyle),u.exit().remove(),o.append("tbody").attr("class","d3plus-tooltip-tbody");const f=n.select(".d3plus-tooltip-tbody");r.stylize(f,t.schema.tbodyStyle);const m=f.selectAll("tr").data(t.schema.tbody),p=m.enter().append("tr");m.exit().remove();const g=m.merge(p);r.stylize(g,t.schema.trStyle);const y=g.selectAll("td").data(t=>t),x=y.enter().append("td").merge(y).html(i);r.stylize(x,t.schema.tdStyle)}(this,c,l,function(t){if("function"==typeof t){const n=o.select(this.parentNode.parentNode).datum();return t(n,e._data.indexOf(n),n)}return t}),la(this,c,l,"footer"),la(this,c,l,"arrow"),function(t,e,n,i){e.attr("id",(e,n)=>ca(t,e,n)).style("visibility","hidden").call(e=>ha(t,e)).each(function(e,n){const i=t.schema.id(e,n),o=this,r=o.querySelector(".d3plus-tooltip-arrow"),a=r.offsetHeight,s=r.getBoundingClientRect().height/2;r.style.bottom=`-${a/2}px`;const c=t.schema.position(e,n),l=Array.isArray(c)?ra(c):c;t._tooltipRefs[i]={reference:l,arrowEl:r,tooltip:o,arrowHeight:a,arrowDistance:s},aa(l,o,r,t.schema.offset(e,n),s,a)}),n.each(function(e,n){const i=t.schema.id(e,n),o=t.schema.position(e,n),r=t._tooltipRefs[i];r&&(r.reference=Array.isArray(o)?ra(o):o,aa(r.reference,r.tooltip,r.arrowEl,t.schema.offset(e,n),r.arrowDistance,r.arrowHeight))}).call(e=>ha(t,e)),i.exit().each(function(e,n){const i=t.schema.id(e,n);delete t._tooltipRefs[i]}).remove()}(this,c,l,s),t&&setTimeout(t,100),this}className(t){return arguments.length?super.className(t):super.className()}arrowStyle(t){return arguments.length?(this.schema.arrowStyle=ut(this,"arrowStyle",t),this):this.schema.arrowStyle}bodyStyle(t){return arguments.length?(this.schema.bodyStyle=ut(this,"bodyStyle",t),this):this.schema.bodyStyle}parent(t){if(!arguments.length)return this._parentEl;const e=this._parentEl,n=t||void 0;return e&&e!==n&&this._portalEl&&(this._portalEl.remove(),this._portalEl=void 0),this._parentEl=n,this}data(t){return arguments.length?(this._data=t,this):this._data}footerStyle(t){return arguments.length?(this.schema.footerStyle=ut(this,"footerStyle",t),this):this.schema.footerStyle}position(t){return arguments.length?(this.schema.position="string"==typeof t?H(o.select(t).node()||[0,0]):"function"==typeof t?t:H(t),this):this.schema.position}tableStyle(t){return arguments.length?(this.schema.tableStyle=ut(this,"tableStyle",t),this):this.schema.tableStyle}tbodyStyle(t){return arguments.length?(this.schema.tbodyStyle=ut(this,"tbodyStyle",t),this):this.schema.tbodyStyle}theadStyle(t){return arguments.length?(this.schema.theadStyle=ut(this,"theadStyle",t),this):this.schema.theadStyle}titleStyle(t){return arguments.length?(this.schema.titleStyle=ut(this,"titleStyle",t),this):this.schema.titleStyle}tooltipStyle(t){return arguments.length?(this.schema.tooltipStyle=ut(this,"tooltipStyle",t),this):this.schema.tooltipStyle}trStyle(t){return arguments.length?(this.schema.trStyle=ut(this,"trStyle",t),this):this.schema.trStyle}tdStyle(t){return arguments.length?(this.schema.tdStyle=ut(this,"tdStyle",t),this):this.schema.tdStyle}thStyle(t){return arguments.length?(this.schema.thStyle=ut(this,"thStyle",t),this):this.schema.thStyle}constructor(){super(),xt(this,fa),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=t=>[t.x,t.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":()=>ua(this).shadow,color:(t,n)=>function(t,n){const i=e.colorContrast(n,t.schema.colorDefaults);return t._theme&&n===t._theme.tooltip.background?J(t._theme,t=>t.tooltip.text,i):i}(this,this.schema.background(t,n)),"font-family":s.fontFamilyStringify(s.fontFamily)},this.schema.trStyle={"border-top":(t,e)=>e?`1px solid ${ua(this).divider}`:"none"};const t=(t,e)=>e?"right":"left";this.schema.tdStyle={"text-align":t},this.schema.thStyle={"text-align":t}}}function pa(t){const{data:e,dataFilter:n,label:i,labelBounds:o,x:r,y:a,aes:s,rotate:c,id:l,datum:h}=t,u=[];return(n?n(e):e).forEach((t,n)=>{let d=t;t.nested&&void 0!==t.key&&t.values&&(d=t.values[0],n=e.indexOf(d));let f=i(d,n);if(o&&!1!==f&&null!=f){const e=o(d,n,s(t,n));if(!e)return;f.constructor!==Array&&(f=[f]);const i=d.__d3plusShape__?d.translate?d.translate[0]:r(d.data,d.i):r(d,n),m=d.__d3plusShape__?d.translate?d.translate[1]:a(d.data,d.i):a(d,n);d.__d3plusShape__&&(d=d.data,n=d.i);for(let t=0;t<f.length;t++){const o=e.constructor===Array?e[t]:Object.assign({},e),r=c(d,n),a=d.labelConfig;let s=a&&a.rotate?a.rotate:void 0!==e.angle?e.angle:0;s+=r;const p=0!==r?[-1*o.x||0,-1*o.y||0]:[o.width/2,o.height/2];u.push({__d3plus__:!0,data:h?h(d,n):d,height:o.height,l:t,id:`${l(d,n)}_${t}`,r:s,rotateAnchor:p,...o.shape?{__d3plusWrapShape__:o.shape}:{},text:f[t],width:o.width,x:i+o.x,y:m+o.y})}}}),u}ma._displayName="Tooltip",dt(ma.prototype,"arrowStyle","bodyStyle","footerStyle","tableStyle","tbodyStyle","theadStyle","titleStyle","tooltipStyle","trStyle","tdStyle","thStyle");const ga=["squares","nylon","waves","woven","crosses","caps","hexagons"],ya=["background","fill","stroke"];function xa(t,e,n,i={}){if(!t)return!1;const o=e();if("none"===o)return!1;const a=r.isObject(t)?{...t}:{texture:t};a.background||(a.background=o),a.stroke||i.stroke||(a.stroke=n()),ga.includes(a.texture)||"function"==typeof a.texture?(a.d=a.texture,a.texture="paths"):"grid"===a.texture&&(a.orientation||i.orientation||(a.orientation=["vertical","horizontal"]),a.texture="lines"),a.fill||"paths"===a.texture||(a.fill=a.stroke);for(const t of ya){const e=a[t];e&&"object"==typeof e&&(a[t]=String(e))}const s=r.assign({},i,a);return"function"==typeof s.d&&(s.d=s.d(s.size||20)),JSON.stringify(s)}function ba(t){let e=t;for(;e.__d3plus__&&e.data;)e=e.data;return e.__d3plusShape__?e.data:e}function _a(t,e){if("number"==typeof t.width&&"number"==typeof t.height){return{x:"number"==typeof t.x?t.x:-t.width/2,y:"number"==typeof t.y?t.y:-t.height/2,width:t.width,height:t.height}}if("number"==typeof t.r){const e="number"==typeof t.cx?t.cx:0,n="number"==typeof t.cy?t.cy:0;return{x:e-t.r,y:n-t.r,width:2*t.r,height:2*t.r}}if("string"==typeof t.d){const e=f.pathBounds(t.d);return e.width>0&&e.height>0?e:null}return function(t){if(!t.length)return null;let e=1/0,n=1/0,i=-1/0,o=-1/0;for(const[r,a]of t)r<e&&(e=r),a<n&&(n=a),r>i&&(i=r),a>o&&(o=a);return!Number.isFinite(e)||i<=e||o<=n?null:{x:e,y:n,width:i-e,height:o-n}}(e)}function ka(t,e,n,i,o,r){return`M${t+(o=Math.min(o,n/2))},${e}h${n-2*o}a${o},${r=Math.min(r,i/2)} 0 0 1 ${o},${r}v${i-2*r}a${o},${r} 0 0 1 ${-o},${r}h${-(n-2*o)}a${o},${r} 0 0 1 ${-o},${-r}v${-(i-2*r)}a${o},${r} 0 0 1 ${o},${-r}Z`}function va(t,e){if("string"==typeof t.d)return{type:"path",d:t.d};if("number"==typeof t.width&&"number"==typeof t.height){const e="number"==typeof t.x?t.x:-t.width/2,n="number"==typeof t.y?t.y:-t.height/2,i="number"==typeof t.rx?t.rx:0,o="number"==typeof t.ry?t.ry:0;return i>0||o>0?{type:"path",d:ka(e,n,t.width,t.height,i||o,o||i)}:{type:"rect",x:e,y:n,width:t.width,height:t.height}}if("number"==typeof t.r){const e="number"==typeof t.cx?t.cx:0,n="number"==typeof t.cy?t.cy:0,i=t.r;return{type:"path",d:`M${e-i},${n}a${i},${i} 0 1,0 ${2*i},0a${i},${i} 0 1,0 ${-2*i},0Z`}}if(e.length>2){return{type:"path",d:`M${e.map(([t,e])=>`${t},${e}`).join("L")}Z`}}}function wa(t,e,n){if("contain"!==n){const n=_a(t,e);return n?{box:n,clip:va(t,e),preserveAspectRatio:"xMidYMid slice"}:null}let i;if("number"==typeof t.width&&"number"==typeof t.height)i=_a(t,e);else if("number"==typeof t.r){const e="number"==typeof t.cx?t.cx:0,n="number"==typeof t.cy?t.cy:0,o=t.r/Math.SQRT2;i={x:e-o,y:n-o,width:2*o,height:2*o}}else{const n=function(t,e){return"string"==typeof t.d?f.path2polygon(t.d):e}(t,e),o=n.length>2?f.largestRect(n,{angle:0}):null;i=o?{x:o.cx-o.width/2,y:o.cy-o.height/2,width:o.width,height:o.height}:_a(t,e)}return i?{box:i,preserveAspectRatio:"xMidYMid meet"}:null}function Ma(t,e,n){return t.map((t,i)=>{const o={type:"image",key:`${t.key}-bgimage-img`,x:t.box.x,y:t.box.y,width:t.box.width,height:t.box.height,href:t.url,preserveAspectRatio:t.preserveAspectRatio,interactive:!1};return{type:"group",key:`${t.key}-bgimage`,children:[o],datum:t.datum,index:t.index,interactive:!1,paint:{opacity:t.opacity??1},...t.transform?{transform:t.transform}:{},...t.clip?{clip:t.clip}:{},...e?{z:n+i}:{}}})}function Sa(t){const e=Number(t);return Number.isFinite(e)?e:void 0}function Ca(t){return null==t||""===t?void 0:String(t)}function $a(t){if(null==t||"none"===t||""===t)return;if("number"==typeof t)return[t];const e=String(t).split(/[\s,]+/).map(Number).filter(t=>Number.isFinite(t));return e.length?e:void 0}const Aa=[{key:"activeOpacity",coerce:"identity",default:.25},{key:"ariaLabel",coerce:"const",default:H("")},{key:"backgroundImage",coerce:"const",default:H(!1)},{key:"backgroundImageFit",coerce:"const",default:H("cover")},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"fill",coerce:"const",default:H("black")},{key:"fillOpacity",coerce:"const",default:H(1)},{key:"hitArea",coerce:"const"},{key:"hoverOpacity",coerce:"identity",default:.5},{key:"id",coerce:"accessor",default:(t,e)=>void 0!==t.id?t.id:e},{key:"label",coerce:"const",default:H(!1)},{key:"labelBounds",coerce:"const"},{key:"opacity",coerce:"const",default:H(1)},{key:"pointerEvents",coerce:"const",default:H("visiblePainted")},{key:"renderMode",coerce:"identity",default:"full"},{key:"role",coerce:"const",default:H("presentation")},{key:"rotate",coerce:"const",default:H(0)},{key:"rx",coerce:"const",default:H(0)},{key:"ry",coerce:"const",default:H(0)},{key:"scale",coerce:"const",default:H(1)},{key:"shapeRendering",coerce:"const",default:H("geometricPrecision")},{key:"stroke",coerce:"const"},{key:"strokeDasharray",coerce:"const",default:H("0")},{key:"strokeLinecap",coerce:"const",default:H("butt")},{key:"strokeOpacity",coerce:"const",default:H(1)},{key:"strokeWidth",coerce:"const",default:H(0)},{key:"textAnchor",coerce:"const",default:H("start")},{key:"texture",coerce:"const",default:H(!1)},{key:"vectorEffect",coerce:"const",default:H("non-scaling-stroke")},{key:"verticalAlign",coerce:"const",default:H("top")},{key:"x",coerce:"accessor",default:I("x",0)},{key:"y",coerce:"accessor",default:I("y",0)}];class za extends Kt{_aes(t,e){return{}}_getTextureKey(t,e){const n=this._styleVal(this.schema.texture,t,e);return!!n&&xa(n,()=>this._styleVal(this.schema.fill,t,e),()=>this._styleVal(this.schema.stroke,t,e),this.schema.textureDefault)}_nestWrapper(t){return(e,n)=>t(e.__d3plusShape__?e.data:e,e.__d3plusShape__?e.i:n)}_buildLabelData(){return pa({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(this):void 0,label:this.schema.label,labelBounds:this.schema.labelBounds?this.schema.labelBounds.bind(this):void 0,x:this.schema.x,y:this.schema.y,aes:this._aes.bind(this),rotate:this.schema.rotate,id:this.schema.id})}_styleVal(t,e,n){return"function"!=typeof t?t:e.nested&&void 0!==e.key&&e.values?t(e.data,e.i):t(e,n)}_sceneTransform(t,e){const n=Boolean(t.__d3plusShape__),i=n?t.data:t,o=n?t.i:e;let r,a;if(n&&t.translate){const[e,n]=String(t.translate).split(",").map(Number);r=e,a=n}else r=Number(this.schema.x(i,o)),a=Number(this.schema.y(i,o));return{x:r,y:a,scale:n&&void 0!==t.scale?Number(t.scale):Number(this.schema.scale(i,o)),rotate:n&&void 0!==t.rotate?Number(t.rotate):Number(this.schema.rotate(t.data||t,o))}}_scenePaint(t,e){const n=this._getTextureKey(t,e);return{fill:n?`pattern:${n}`:Ca(this._styleVal(this.schema.fill,t,e)),fillOpacity:Sa(this._styleVal(this.schema.fillOpacity,t,e)),stroke:Ca(this._styleVal(this.schema.stroke,t,e)),strokeWidth:Sa(this._styleVal(this.schema.strokeWidth,t,e)),strokeOpacity:Sa(this._styleVal(this.schema.strokeOpacity,t,e)),strokeDasharray:$a(this._styleVal(this.schema.strokeDasharray,t,e)),strokeLinecap:Ca(this._styleVal(this.schema.strokeLinecap,t,e)),vectorEffect:Ca(this._styleVal(this.schema.vectorEffect,t,e)),shapeRendering:Ca(this._nestWrapper(this.schema.shapeRendering)(t,e)),opacity:Sa(this._nestWrapper(this.schema.opacity)(t,e))}}_sceneGeometry(t,e){return null}toScene(){let t=this._data;this._dataFilter&&(t=this._dataFilter(t));const e=[],n=[],i=function(t,e){if(!e||t.length<2)return null;const n=t.map((t,e)=>e);n.sort((n,i)=>e(ba(t[n]),ba(t[i])));const i=new Array(t.length);return n.forEach((t,e)=>i[t]=e),i}(t,this.schema.sort);return t.forEach((t,o)=>{const r=this._sceneGeometry(t,o);if(!r)return;const a=this._nestWrapper(this.schema.id)(t,o),s=t.__d3plusShape__?t.data:t,c=this._sceneTransform(t,o),l=this._scenePaint(t,o),h=function(t,e,n,i){if(!t.__d3plusShape__||!Array.isArray(t.values))return{};const o=t.values,r=[];return o.forEach((t,o)=>{if("function"==typeof i&&!1===i(t,o))return;const a=Number(e(t,o)),s=Number(n(t,o));Number.isFinite(a)&&Number.isFinite(s)&&r.push({x:a,y:s,datum:t,index:"number"==typeof t.i?t.i:o})}),r.length?{interactionPoints:r}:{}}(t,this.schema.x,this.schema.y,this.schema.defined);if(this.schema.hitArea){const n=function(t,e,n,i,o,r,a,s,c){const l="function"==typeof t?t(e,n,i):t;if(!l)return null;if("number"!=typeof l.width&&"string"==typeof c)return{type:"path",d:c,key:`${o}::hit`,datum:r,index:n,shapeType:a,paint:{fill:"none",stroke:"transparent",strokeWidth:"number"==typeof l["stroke-width"]?l["stroke-width"]:10,vectorEffect:"non-scaling-stroke"},transform:s,aria:{hidden:!0}};return"number"!=typeof l.width||"number"!=typeof l.height?null:{type:"rect",x:"number"==typeof l.x?l.x:-l.width/2,y:"number"==typeof l.y?l.y:-l.height/2,width:l.width,height:l.height,key:`${o}::hit`,datum:r,index:n,shapeType:a,paint:{fill:"transparent"},transform:s,aria:{hidden:!0}}}(this.schema.hitArea,t,o,this._aes(t,o),a,s,this._name,c,r.d);n&&e.push(i?{...n,...h,z:i[o]}:{...n,...h})}e.push({...r,key:a,datum:s,index:o,shapeType:this._name,paint:l,transform:c,aria:{role:Ca(this._nestWrapper(this.schema.role)(t,o)),label:Ca(this._nestWrapper(this.schema.ariaLabel)(t,o))},...h,...i?{z:i[o]}:{}});const u="none"!==l.fill&&this._nestWrapper(this.schema.backgroundImage)(t,o);if(u){const e=r,i=wa(e,"string"!=typeof e.d&&"number"!=typeof e.width&&"number"!=typeof e.r?this._aes(t,o).points??[]:[],"contain"===this._nestWrapper(this.schema.backgroundImageFit)(t,o)?"contain":"cover");i&&n.push({key:a,index:o,datum:s,url:u,box:i.box,clip:i.clip,preserveAspectRatio:i.preserveAspectRatio,opacity:Sa(this._nestWrapper(this.schema.opacity)(t,o)),transform:c})}}),n.length&&e.push(...Ma(n,i,t.length)),{type:"group",key:`${this._name}-group`,children:e}}render(t){const e=this._labelClass;if(e&&"function"==typeof e.renderMode&&e.renderMode("compute"),this._labelClass.config(this.schema.labelConfig),this._labelClass.data(this._buildLabelData()),"compute"===this.schema.renderMode)return t&&setTimeout(t,0),this;if(void 0===this._select&&"undefined"!=typeof document){const t=document.createElement("div");t.style.cssText="display:block;",document.body.appendChild(t),this.select(t)}if(this._select){const t=this._select,e=t&&"function"==typeof t.node?t.node():t;e&&function(t,e){const n="svg"===(e.tagName||"").toLowerCase(),i=n?Number(e.getAttribute("width")):e.clientWidth,o=n?Number(e.getAttribute("height")):e.clientHeight,[s,c]=i&&o?[i,o]:r.getSize(e),l=i||s||400,h=o||c||300,u=t.toScene(),d=[];t._labelClass&&"function"==typeof t._labelClass.toScene&&t._labelClass._data&&t._labelClass._data.length&&d.push(...t._labelClass.toScene().children);const f={root:{...u,children:[...u.children,...d]},width:l,height:h},m=t._sceneRenderer;if(m&&"function"==typeof m.destroy&&m.destroy(),!m)for(;e.firstChild;)e.removeChild(e.firstChild);const p=new a.SvgRenderer;p.mount({container:e,width:l,height:h}),p.drawScene(f),t._sceneRenderer=p,Ht(t)}(this,e)}return t&&setTimeout(t,0),this}active(t){return arguments.length&&void 0!==t?(this.schema.active=t,this):this.schema.active}activeStyle(t){return arguments.length?(this.schema.activeStyle=ut(this,"activeStyle",t),this):this.schema.activeStyle}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){return arguments.length&&void 0!==t?(this.schema.hover=t,this):this.schema.hover}hoverStyle(t){return arguments.length?(this.schema.hoverStyle=ut(this,"hoverStyle",t),this):this.schema.hoverStyle}labelConfig(t){return arguments.length?(this.schema.labelConfig=ut(this,"labelConfig",t),this):this.schema.labelConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}sort(t){return arguments.length?(this.schema.sort=t??null,this):this.schema.sort}textureDefault(t){return arguments.length?(this.schema.textureDefault=ut(this,"textureDefault",t),this):this.schema.textureDefault}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(t="g"){super(),xt(this,Aa),this._data=[],this._labelClass=new Ir,this._name="Shape",this._tagName=t,this._textureDefs={},this.schema.stroke=(t,e)=>{const n=i.color(this.schema.fill(t,e));return n?n.darker(1).formatHex():this.schema.fill(t,e)},this.schema.activeStyle={stroke:(t,e)=>{let n=this.schema.fill(t,e);["transparent","none"].includes(n)&&(n=this.schema.stroke(t,e));const o=i.color(n);return o?o.darker(1).toString():n},"stroke-width":(t,e)=>3*(this.schema.strokeWidth(t,e)||1)},this.schema.hoverStyle={stroke:(t,e)=>{let n=this.schema.fill(t,e);["transparent","none"].includes(n)&&(n=this.schema.stroke(t,e));const o=i.color(n);return o?o.darker(.5).toString():n},"stroke-width":(t,e)=>2*(this.schema.strokeWidth(t,e)||1)},this.schema.labelConfig={fontColor:(t,n)=>e.colorContrast(this.schema.fill(t,n),this.schema.colorDefaults),fontOpacity:(t,e)=>this.schema.opacity(t,e),fontResize:!0,fontMax:50,fontMin:8,fontSize:12,padding:5,textAnchor:"start",verticalAlign:"top"},this.schema.textureDefault={}}}za._displayName="Shape",dt(za.prototype,"activeStyle","hoverStyle","labelConfig","textureDefault");const Da=[{key:"curve",coerce:"const",default:H("linear")},{key:"defined",coerce:"identity",default:()=>!0}];class La extends za{_sceneGeometry(t){const e=Number(t.x),n=Number(t.y),i=String(this.schema.curve.bind(this)(this.config())),o=R[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`],r=t=>(n,i)=>t(n,i)-e,a=t=>(e,i)=>t(e,i)-n,s=R.area().defined(this.schema.defined).curve(o).x(r(this.schema.x)).x0(r(this.schema.x0)).y(a(this.schema.y)).y0(a(this.schema.y0));return this.schema.x1?s.x1(r(this.schema.x1)):s.x1(null),this.schema.y1?s.y1(a(this.schema.y1)):s.y1(null),{type:"path",d:s(t.values)||""}}_aes(t){const e=t.values.slice().sort((t,e)=>this.schema.y1?this.schema.x(t)-this.schema.x(e):this.schema.y(t)-this.schema.y(e)),n=e.map((t,e)=>[this.schema.x0(t,e),this.schema.y0(t,e)]),i=e.reverse().map((t,e)=>this.schema.y1?[this.schema.x(t,e),this.schema.y1(t,e)]:[this.schema.x1(t,e),this.schema.y(t,e)]);let o=n.concat(i);return n[0][1]>i[0][1]&&(o=o.reverse()),o.push(o[0]),{points:o}}_dataFilter(t){const e=h.groups(t,this.schema.id).map(([e,i])=>{const o={key:e,values:i};o.data=n.merge(o.values),o.i=t.indexOf(o.values[0]);const r=h.extent(o.values.map(this.schema.x).concat(o.values.map(this.schema.x0)).concat(this.schema.x1?o.values.map(this.schema.x1):[]));o.xR=r,o.width=r[1]-r[0],o.x=r[0]+o.width/2;const a=h.extent(o.values.map(this.schema.y).concat(o.values.map(this.schema.y0)).concat(this.schema.y1?o.values.map(this.schema.y1):[]));return o.yR=a,o.height=a[1]-a[0],o.y=a[0]+o.height/2,o.nested=!0,o.translate=[o.x,o.y],o.__d3plusShape__=!0,o});return e.key=t=>t.key,e}x(t){return arguments.length?(this.schema.x="function"==typeof t?t:H(t),this.schema.x0=this.schema.x,this):this.schema.x}x0(t){return arguments.length?(this.schema.x0="function"==typeof t?t:H(t),this.schema.x=this.schema.x0,this):this.schema.x0}x1(t){return arguments.length?(this.schema.x1="function"==typeof t?t:null===t?null:H(t),this):this.schema.x1}y(t){return arguments.length?(this.schema.y="function"==typeof t?t:H(t),this.schema.y0=this.schema.y,this):this.schema.y}y0(t){return arguments.length?(this.schema.y0="function"==typeof t?t:H(t),this.schema.y=this.schema.y0,this):this.schema.y0}y1(t){return arguments.length?(this.schema.y1="function"==typeof t?t:null===t?null:H(t),this):this.schema.y1}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),xt(this,Da),this._name="Area",this.schema.labelBounds=(t,e,n)=>{const i=f.largestRect(n.points);return i?{angle:i.angle,width:i.width,height:i.height,x:i.cx-i.width/2-this.schema.x(t,e),y:i.cy-i.height/2-this.schema.y(t,e)}:null},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this.schema.x=I("x"),this.schema.x0=I("x"),this.schema.x1=null,this.schema.y=H(0),this.schema.y0=H(0),this.schema.y1=I("y")}}La._displayName="Area";const Fa=[{key:"height",coerce:"accessor",default:H(10)},{key:"width",coerce:"accessor",default:H(10)}];class Na extends za{_sceneGeometry(t,e){const n=this._getWidth(t,e),i=this._getHeight(t,e);return{type:"rect",x:null!==this.schema.x1?this._getX(t,e):-n/2,y:null===this.schema.x1?this._getY(t,e):-i/2,width:n,height:i}}_aes(t,e){return{height:this._getHeight(t,e),width:this._getWidth(t,e)}}_applyPosition(t){t.attr("width",(t,e)=>this._getWidth(t,e)).attr("height",(t,e)=>this._getHeight(t,e)).attr("x",(t,e)=>null!==this.schema.x1?this._getX(t,e):-this._getWidth(t,e)/2).attr("y",(t,e)=>null===this.schema.x1?this._getY(t,e):-this._getHeight(t,e)/2)}_getHeight(t,e){return null!==this.schema.x1?this.schema.height(t,e):Math.abs(this.schema.y1(t,e)-this.schema.y(t,e))}_getWidth(t,e){return null===this.schema.x1?this.schema.width(t,e):Math.abs(this.schema.x1(t,e)-this.schema.x(t,e))}_getX(t,e){const n=null===this.schema.x1?this.schema.x(t,e):this.schema.x1(t,e)-this.schema.x(t,e);return n<0?n:0}_getY(t,e){const n=null!==this.schema.x1?this.schema.y(t,e):this.schema.y1(t,e)-this.schema.y(t,e);return n<0?n:0}x0(t){return arguments.length?(this.schema.x0="function"==typeof t?t:H(t),this.schema.x=this.schema.x0,this):this.schema.x0}x1(t){return arguments.length?(this.schema.x1="function"==typeof t?t:null===t?null:H(t),this):this.schema.x1}y0(t){return arguments.length?(this.schema.y0="function"==typeof t?t:H(t),this.schema.y=this.schema.y0,this):this.schema.y0}y1(t){return arguments.length?(this.schema.y1="function"==typeof t?t:null===t?null:H(t),this):this.schema.y1}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("rect"),xt(this,Fa),this._name="Bar",this.schema.labelBounds=(t,e,n)=>({width:n.width,height:n.height,x:null!==this.schema.x1?this._getX(t,e):-n.width/2,y:null===this.schema.x1?this._getY(t,e):-n.height/2}),Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=I("x"),this.schema.x0=I("x"),this.schema.x1=null,this.schema.y=H(0),this.schema.y0=H(0),this.schema.y1=I("y")}}Na._displayName="Bar";const Ba=[{key:"height",coerce:"accessor",default:I("height")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0},{key:"width",coerce:"accessor",default:I("width")}];class Ea extends za{_sceneGeometry(t,e){const n=Number(this.schema.width(t,e)),i=Number(this.schema.height(t,e)),o=this._styleVal(this.schema.rx,t,e),r=this._styleVal(this.schema.ry,t,e);return{type:"rect",x:-n/2,y:-i/2,width:n,height:i,...null==o?{}:{rx:Number(o)},...null==r?{}:{ry:Number(r)},...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(t,e){return{width:this.schema.width(t,e),height:this.schema.height(t,e)}}_applyPosition(t){t.attr("width",(t,e)=>this.schema.width(t,e)).attr("height",(t,e)=>this.schema.height(t,e)).attr("x",(t,e)=>-this.schema.width(t,e)/2).attr("y",(t,e)=>-this.schema.height(t,e)/2)}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("rect"),xt(this,Ba),this._name="Rect",this.schema.labelBounds=(t,e,n)=>({width:n.width,height:n.height,x:-n.width/2,y:-n.height/2})}}Ea._displayName="Rect";const Ra=[{key:"r",coerce:"accessor",default:I("r")},{key:"trail",coerce:"identity",default:!1},{key:"trailPersist",coerce:"identity",default:0}];class Pa extends za{_applyPosition(t){t.attr("r",(t,e)=>this.schema.r(t,e)).attr("x",(t,e)=>-this.schema.r(t,e)/2).attr("y",(t,e)=>-this.schema.r(t,e)/2)}_sceneGeometry(t,e){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(t,e)),...this.schema.trail?{trail:!0}:{},...this.schema.trailPersist?{trailPersist:this.schema.trailPersist}:{}}}_aes(t,e){return{r:this.schema.r(t,e)}}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("circle"),xt(this,Ra),this._name="Circle",this.schema.labelBounds=(t,e,n)=>({width:2*n.r,height:2*n.r,x:-n.r,y:-n.r,shape:"circle"}),this.schema.labelConfig=r.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}Pa._displayName="Circle";const Ta=new Map([["Circle",Pa],["Rect",Ea]]);const Oa=t=>Ta.has(t);function Wa(t){return Array.isArray(t)?t:[t,t]}function Ha(t,e){const n=h.quantile(t,.25),i=h.quantile(t,.5),o=h.quantile(t,.75),r=i=>function(t,e,n,i,o){const r=h.min(t),a=h.max(t);if("tukey"===e){const t=n?o+1.5*(o-i):i-1.5*(o-i);return n?t>a?a:t:t<r?r:t}return"extent"===e?n?a:r:"number"==typeof e?h.quantile(t,e):void 0}(t,e[i],i,n,o);return{first:n,median:i,third:o,lowerLimit:r(0),upperLimit:r(1)}}const ja=["fill","stroke","backgroundImage","backgroundImageFit","texture","textureDefault"],Ia={fill:"white",stroke:"black"};function Ga(t,e){return Ft(t)?Lt(e):e}function qa(t){return"function"==typeof t?e=>t(e.data,e.i):t}function Va(t){const n="string"==typeof t?i.color(t):null;return n&&n.opacity?e.colorContrast(n.formatRgb(),{dark:"black",light:"white"}):"black"}function Ya(t){const e=new Set(t),n=new Set;return t.map(t=>{if(!n.has(t))return n.add(t),t;let i=1;for(;e.has(`${t}~${i}`);)i++;const o=`${t}~${i}`;return e.add(o),o})}const Ka=["boxMin","boxQ1","boxMedian","boxQ3","boxMax"];function Ua(t){if(null!=t&&!1!==t)return"function"==typeof t?t:"string"==typeof t?q(t):H(t)}function Xa(t){return Ka.some(e=>"function"==typeof t[e])}function Za(t,e){const n=function(t){return Xa(t)?Ka.filter(e=>"function"!=typeof t[e]):[]}(e);n.length&&Bt(`${t} draws precomputed boxes only when ${Ka.join(", ")} are all set; missing ${n.join(", ")}.`)}const Qa=t=>"number"==typeof t&&Number.isFinite(t),Ja=t=>"number"==typeof t||t instanceof Date?+t:NaN;function ts(t,e,n){const i="function"==typeof t.boxOutliers?t.boxOutliers(e,n):void 0;return(Array.isArray(i)?i:[i]).map(Ja).filter(Qa)}function es(t,e,n){const i=[];for(const o of Ka){const r=t[o];if("function"!=typeof r)return null;const a=Ja(r(e,n));if(!Qa(a))return null;i.push(a)}i.sort((t,e)=>t-e);const o=ts(t,e,n),[r,a,s,c,l]=i;return{min:r,q1:a,median:s,q3:c,max:l,outliers:o}}function ns(t,e,n){const i=t,o=t.first,r=t.third-o;"vertical"===t.orient?(i.height=r,i.width=n,i.x=e,i.y=o+r/2):"horizontal"===t.orient&&(i.height=n,i.width=r,i.x=o+r/2,i.y=e)}function is(t,e,n){const i=t=>{const o={...t},r=function(t,e){const n=new Set;for(let i=t;i&&"object"==typeof i&&!n.has(i);i=i.data){const t=e.get(i);if(t)return t;n.add(i)}}(t.datum,n);return r&&(o.owners=[...t.owners??[],{shapeType:e,...r}]),"group"===t.type&&(o.children=t.children.map(i)),o};return t.map(i)}const os=[{key:"curve",coerce:"const",default:H("linear")},{key:"defined",coerce:"identity",default:t=>t}];class rs extends za{_dataFilter(t){const e=h.groups(t,this.schema.id).map(([e,i])=>{const o={key:e,values:i};o.data=n.merge(o.values),o.i=t.indexOf(o.values[0]);const r=h.extent(o.values,this.schema.x);o.xR=r,o.width=r[1]-r[0],o.x=r[0]+o.width/2;const a=h.extent(o.values,this.schema.y);return o.yR=a,o.height=a[1]-a[0],o.y=a[0]+o.height/2,o.nested=!0,o.translate=[o.x,o.y],o.__d3plusShape__=!0,o});return e.key=t=>t.key,e}_sceneGeometry(t){const e=Number(t.x),n=Number(t.y),i=String(this.schema.curve.bind(this)(this.config())),o=R[`curve${i.charAt(0).toUpperCase()}${i.slice(1)}`];return{type:"path",d:R.line().curve(o).defined(this.schema.defined).x((t,n)=>this.schema.x(t,n)-e).y((t,e)=>this.schema.y(t,e)-n)(t.values)||""}}_aes(t,e){return{points:t.values.map(t=>[this.schema.x(t,e),this.schema.y(t,e)])}}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),xt(this,os),this._name="Line",this._path=R.line(),this.schema.fill=H("none"),this.schema.stroke=H("black"),this.schema.strokeWidth=H(1),this.schema.hitArea=H({d:t=>this._path(t.values),fill:"none","stroke-width":10,transform:null})}}rs._displayName="Line";const as={Circle:Pa,Rect:Ea},ss=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:I("endpoint","Rect")},{key:"length",coerce:"const",default:I("length",25)},{key:"orient",coerce:"const",default:I("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:I("x",0)},{key:"y",coerce:"const",default:I("y",0)}];class cs extends Kt{render(t){const e="compute"===this.schema.renderMode;void 0!==this._select||e||this.select(o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const n=t=>e?null:r.elem(t,{parent:this._select}).node();this._owned=new Map(this._data.map((t,e)=>[t,{datum:t,index:e}]));const i=Ya(this._data.map((t,e)=>`${t.id??e}`)),a=function(t,e){const n=[];return t._data.forEach((i,o)=>{const r=t.schema.orient(i,o),a=t.schema.x(i,o),s=t.schema.y(i,o);let c=a;"left"===r?c-=t.schema.length(i,o):"right"===r&&(c+=t.schema.length(i,o));let l=s;"top"===r?l-=t.schema.length(i,o):"bottom"===r&&(l+=t.schema.length(i,o)),n.push({__d3plus__:!0,data:i,i:o,id:e[o],x:a,y:s}),n.push({__d3plus__:!0,data:i,i:o,id:e[o],x:c,y:l})}),n}(this,i);this._line=(new rs).data(a).renderMode(e?"compute":"full").select(n("g.d3plus-Whisker")).config(Qt.bind(this)(this.schema.lineConfig,"shape")).render();const s=function(t,e){return t._data.map((n,i)=>{const o={__d3plus__:!0};o.data=n,o.i=i,o.id=`${e[i]}-end`,o.endpoint=t.schema.endpoint(n,i),o.length=t.schema.length(n,i),o.orient=t.schema.orient(n,i);let r=t.schema.x(n,i);"left"===o.orient?r-=o.length:"right"===o.orient&&(r+=o.length);let a=t.schema.y(n,i);return"top"===o.orient?a-=o.length:"bottom"===o.orient&&(a+=o.length),o.x=r,o.y=a,o})}(this,i);return this._whiskerEndpoint=[],h.groups(s,t=>t.endpoint).forEach(([t,i])=>{this._whiskerEndpoint.push((new as[t]).data(i).renderMode(e?"compute":"full").select(n(`g.d3plus-Whisker-Endpoint-${t}`)).config(Lt({height:t=>"top"===t.orient||"bottom"===t.orient?5:20,width:t=>"top"===t.orient||"bottom"===t.orient?20:5})).config(Qt.bind(this)(this.schema.endpointConfig,"shape",t)).render())}),t&&setTimeout(t,this.schema.duration+100),this}toScene(){const t=[],e=e=>{const n=e&&"function"==typeof e.toScene?e.toScene():null;n&&Array.isArray(n.children)&&t.push(...n.children)};if(e(this._line),Array.isArray(this._whiskerEndpoint))for(const t of this._whiskerEndpoint)e(t);return{type:"group",key:"d3plus-Whisker-scene",children:is(t,"Whisker",this._owned)}}active(t){this._line&&this._line.active(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.active(t))}data(t){return arguments.length?(this._data=t,this):this._data}endpointConfig(t){return arguments.length?(this.schema.endpointConfig=ut(this,"endpointConfig",t),this):this.schema.endpointConfig}hover(t){this._line&&this._line.hover(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.hover(t))}lineConfig(t){return arguments.length?(this.schema.lineConfig=ut(this,"lineConfig",t),this):this.schema.lineConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),xt(this,ss),this.schema.endpointConfig={Circle:{r:I("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[],this._owned=new Map}}cs._displayName="Whisker",dt(cs.prototype,"endpointConfig","lineConfig");const ls=t=>"function"==typeof t?t:I(t),hs=[{key:"backgroundImage",coerce:"const"},{key:"backgroundImageFit",coerce:"const"},{key:"boxMax",coerce:Ua},{key:"boxMedian",coerce:Ua},{key:"boxMin",coerce:Ua},{key:"boxOutliers",coerce:Ua},{key:"boxQ1",coerce:Ua},{key:"boxQ3",coerce:Ua},{key:"fill",coerce:"const"},{key:"id",coerce:"accessor"},{key:"orient",coerce:"const",default:I("orient","vertical")},{key:"outlier",coerce:"const",default:I("outlier","Circle")},{key:"rectWidth",coerce:"const",default:H(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"stroke",coerce:"const"},{key:"texture",coerce:"const"},{key:"textureDefault",coerce:"identity"},{key:"whiskerMode",coerce:Wa,default:["tukey","tukey"]},{key:"x",coerce:ls,default:I("x",250)},{key:"y",coerce:ls,default:I("y",250)}];function us(t,[e,i],o,r){const a={key:e,values:i};a.data=n.merge(a.values),a.i=t._data.indexOf(a.values[0]),a.id=o,a.orient=t.schema.orient(a.data,a.i);const s=a.values.map("vertical"===a.orient?t.schema.y:t.schema.x);s.sort((t,e)=>t-e);const{first:c,median:l,third:h,lowerLimit:u,upperLimit:d}=Ha(s,t.schema.whiskerMode);return Object.assign(a,{first:c,median:l,third:h}),void 0!==u&&Object.assign(a,{lowerLimit:u}),void 0!==d&&Object.assign(a,{upperLimit:d}),ns(a,e,t.schema.rectWidth(a.data,a.i)),function(t,e,n){e.values.forEach((i,o)=>{const r="vertical"===e.orient?t.schema.y(i,o):t.schema.x(i,o);if(r<e.lowerLimit||r>e.upperLimit){const a=t.schema.outlier(i,o);if(!Oa(a))return;const s={__d3plus__:!0};s.data=i,s.i=o,s.id=`${e.id}-outlier-${o}`,s.outlier=a,"vertical"===e.orient?(s.x=e.x,s.y=r,n.push(s)):"horizontal"===e.orient&&(s.y=e.y,s.x=r,n.push(s))}})}(t,a,r),a.__d3plus__=!0,a}class ds extends Kt{render(){const t="compute"===this.schema.renderMode;void 0!==this._select||t||this.select(o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const e=e=>t?null:r.elem(e,{parent:this._select}).node(),n=[],i=Xa(this.schema)?function(t,e){const{schema:n}=t;Za("Box",n);const i=t._data.map((t,e)=>({row:t,i:e,stats:es(n,t,e)})).filter(t=>t.stats),o=n.orient,r=i.map(({row:t,i:e})=>"vertical"===o(t,e)?n.x(t,e):n.y(t,e)),a=Ya(i.map(({row:t,i:e},i)=>`${(n.id?n.id(t,e):void 0)??r[i]}`));return t._owned=new Map,i.map(({row:i,i:s,stats:c},l)=>{const h=c,u={__d3plus__:!0,key:r[l],values:[i],data:i,i:s,id:a[l],orient:o(i,s),first:h.q1,median:h.median,third:h.q3,lowerLimit:h.min,upperLimit:h.max};ns(u,r[l],n.rectWidth(i,s));const d=e.length,f=n.outlier(i,s);Oa(f)&&h.outliers.forEach((t,n)=>e.push(function(t,e,n,i){const o="vertical"===t.orient;return{__d3plus__:!0,data:t.data,i:t.i,id:`${t.id}-outlier-${i}`,outlier:e,x:o?t.x:n,y:o?n:t.y}}(u,f,t,n)));const m={datum:u,index:l};for(const n of[u,...e.slice(d)])t._owned.set(n,m);return u})}(this,n):function(t,e){const n=h.groups(t._data,(e,n)=>"vertical"===t.schema.orient(e,n)?t.schema.x(e,n):t.schema.y(e,n)),i=Ya(n.map(([e,n])=>{const i=n[0];return`${(t.schema.id?t.schema.id(i,t._data.indexOf(i)):void 0)??e}`}));return t._owned=new Map,n.map((n,o)=>{const r=e.length,a=us(t,n,i[o],e),s={datum:a,index:o};for(const n of[a,...e.slice(r)])t._owned.set(n,s);return a})}(this,n),a=function(t,e){const n={...Ia};for(const i of ja){const o=t[i];void 0===o||i in e||(n[i]=qa(o))}return Ga(e,{...n,...e})}(this.schema,Qt.bind(this)(this.schema.rectConfig,"shape"));this._box=(new Ea).data(i).id(t=>`${t.id}-box`).x(t=>t.x).y(t=>t.y).renderMode(t?"compute":"full").select(e("g.d3plus-Box")).config(a).render(),this._median=(new Ea).data(i).id(t=>`${t.id}-median`).x(t=>"vertical"===t.orient?t.x:t.median).y(t=>"vertical"===t.orient?t.median:t.y).height(t=>"vertical"===t.orient?1:t.height).width(t=>"vertical"===t.orient?t.width:1).renderMode(t?"compute":"full").select(e("g.d3plus-Box-Median")).config(function(t,e){if("fill"in e)return e;const n="function"==typeof t?(e,n)=>Va(t(e,n)):()=>Va(t);return Ga(e,{...e,fill:n})}(a.fill,Qt.bind(this)(this.schema.medianConfig,"shape"))).render();const s=function(t){const e=[];return t.forEach((t,n)=>{const i=t.x,o=t.y,r=t.first-t.lowerLimit,a=t.upperLimit-t.third;if("vertical"===t.orient){const s=o-t.height/2,c=o+t.height/2;e.push({__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-top`,x:i,y:s,length:r,orient:"top"},{__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-bottom`,x:i,y:c,length:a,orient:"bottom"})}else if("horizontal"===t.orient){const s=i+t.width/2,c=i-t.width/2;e.push({__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-right`,x:s,y:o,length:a,orient:"right"},{__d3plus__:!0,data:t,i:n,id:`${t.id}-whisker-left`,x:c,y:o,length:r,orient:"left"})}}),e}(i);return this._whisker=(new cs).data(s).renderMode(t?"compute":"full").select(e("g.d3plus-Box-Whisker")).config(Qt.bind(this)(this.schema.whiskerConfig,"shape")).render(),this._whiskerEndpoint=[],h.groups(n,t=>t.outlier).forEach(([n,i])=>{const o=function(t){return Ta.get(t)}(n);var r,a;this._whiskerEndpoint.push((new o).data(i).renderMode(t?"compute":"full").select(e(`g.d3plus-Box-Outlier-${n}`)).config((r=this.schema,a=Qt.bind(this)(this.schema.outlierConfig,"shape",n),void 0===r.fill||"fill"in a?a:Ga(a,{...a,fill:qa(r.fill)}))).render())}),this}toScene(){const t=[],e=e=>{const n=e&&"function"==typeof e.toScene?e.toScene():null;n&&Array.isArray(n.children)&&t.push(...n.children)};if(e(this._box),e(this._median),e(this._whisker),Array.isArray(this._whiskerEndpoint))for(const t of this._whiskerEndpoint)e(t);return{type:"group",key:"d3plus-Box-scene",children:is(t,"Box",this._owned)}}active(t){this._box&&this._box.active(t),this._median&&this._median.active(t),this._whisker&&this._whisker.active(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.active(t))}data(t){return arguments.length?(this._data=t,this):this._data}hover(t){this._box&&this._box.hover(t),this._median&&this._median.hover(t),this._whisker&&this._whisker.hover(t),this._whiskerEndpoint&&this._whiskerEndpoint.forEach(e=>e.hover(t))}medianConfig(t){return arguments.length?(this.schema.medianConfig=ut(this,"medianConfig",t),this):this.schema.medianConfig}outlierConfig(t){return arguments.length?(this.schema.outlierConfig=ut(this,"outlierConfig",t),this):this.schema.outlierConfig}rectConfig(t){return arguments.length?(this.schema.rectConfig=ut(this,"rectConfig",t),this):this.schema.rectConfig}select(t){return arguments.length?(this._select=o.select(t),this):this._select}whiskerConfig(t){return arguments.length?(this.schema.whiskerConfig=ut(this,"whiskerConfig",t),this):this.schema.whiskerConfig}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super(),xt(this,hs),this.schema.medianConfig={},this.schema.outlierConfig={Circle:{r:I("r",5)},Rect:{height:(t,e)=>"vertical"===this.schema.orient(t,e)?5:20,width:(t,e)=>"vertical"===this.schema.orient(t,e)?20:5}},this.schema.rectConfig={strokeWidth:H(1)},this.schema.whiskerConfig={},this._whiskerEndpoint=[],this._owned=new Map}}ds._displayName="Box",dt(ds.prototype,"medianConfig","outlierConfig","rectConfig","whiskerConfig");const fs=[{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"accessor",default:I("height")},{key:"id",coerce:"identity",default:I("id")},{key:"opacity",coerce:"const",default:H(1)},{key:"pointerEvents",coerce:"const",default:H("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"url",coerce:"identity",default:I("url")},{key:"width",coerce:"accessor",default:I("width")},{key:"x",coerce:"const",default:I("x",0)},{key:"y",coerce:"const",default:I("y",0)}];class ms{config(t){if(!arguments.length)return{...this.schema,data:this._data,select:this._select};const e=t;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&("function"==typeof this[t]?this[t](e[t]):this.schema[t]=e[t]);return this}render(t){if("compute"===this.schema.renderMode)return t&&setTimeout(t,0),this;void 0===this._select&&this.select(o.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const e=this._select.selectAll(".d3plus-Image").data(this._data,this.schema.id),n=e.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",(t,e)=>this.schema.x(t,e)+this.schema.width(t,e)/2).attr("y",(t,e)=>this.schema.y(t,e)+this.schema.height(t,e)/2),i=u.transition().duration(this.schema.duration),r=this;return n.merge(e).attr("xlink:href",this.schema.url).style("pointer-events",this.schema.pointerEvents).transition(i).attr("opacity",this.schema.opacity).attr("width",(t,e)=>this.schema.width(t,e)).attr("height",(t,e)=>this.schema.height(t,e)).attr("x",(t,e)=>this.schema.x(t,e)).attr("y",(t,e)=>this.schema.y(t,e)).each(function(t,e){const n=o.select(this),i=r.schema.url(t,e);if(!(0===i.indexOf("http://")||0===i.indexOf("https://"))||0===i.indexOf(window.location.hostname)){const t=new window.Image;t.src=i,t.crossOrigin="Anonymous",t.onload=function(){const e=document.createElement("canvas");e.width=t.width,e.height=t.height;e.getContext("2d").drawImage(t,0,0),n.attr("xlink:href",e.toDataURL("image/png"))}}}),e.exit().transition(i).attr("width",(t,e)=>this.schema.width(t,e)).attr("height",(t,e)=>this.schema.height(t,e)).attr("x",(t,e)=>this.schema.x(t,e)).attr("y",(t,e)=>this.schema.y(t,e)).attr("opacity",0).remove(),t&&setTimeout(t,this.schema.duration+100),this}data(t){return arguments.length?(this._data=t,this):this._data}toScene(){return{type:"group",key:"d3plus-Image",children:(this._data||[]).map((t,e)=>({type:"image",key:`${this.schema.id(t,e)}`,x:this.schema.x(t,e),y:this.schema.y(t,e),width:this.schema.width(t,e),height:this.schema.height(t,e),href:this.schema.url(t,e),paint:{opacity:this.schema.opacity(t,e)},datum:t,index:e}))}}select(t){return arguments.length?(this._select=o.select(t),this):this._select}constructor(){xt(this,fs)}}const ps=[{key:"d",coerce:"const",default:I("path")}];class gs extends za{_sceneGeometry(t,e){return{type:"path",d:String(this.schema.d(t,e))}}_aes(t,e){return{points:f.path2polygon(this.schema.d(t,e))}}config(t){return arguments.length?(super.config(t),this):super.config()}constructor(){super("path"),xt(this,ps),this._name="Path",this.schema.labelBounds=(t,e,n)=>{const i=this.schema.labelConfig.rotate,o=f.largestRect(n.points,{angle:i?i(t,e):0});return!!o&&{angle:o.angle,width:o.width,height:o.height,x:o.cx-o.width/2,y:o.cy-o.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}gs._displayName="Path";const ys=O;let xs;function bs(t,e,n={}){const i=`${t}.${n.method??"shapeConfig"}()`,o=function(){if(!xs){xs={};for(const[t,e]of Object.entries(ys))xs[t]=new e}return xs}(),a=n.shapes??Object.fromEntries(Object.keys(o).map(t=>[t,t])),s=n.extra??{},c=Object.values(a).map(t=>o[t]);for(const t of Object.keys(e)){const n=a[t]&&o[a[t]];if(n){if(!r.isObject(e[t]))continue;for(const o of Object.keys(e[t]))o in n||s[t]?.includes(o)||Nt(i,`${t}.${o}`)}else s[""]?.includes(t)||c.some(e=>t in e)||Nt(i,t)}}class _s extends Kt{active(t){return arguments.length?(this._active=t,1!==this.schema.shapeConfig.activeOpacity&&(this.schema.legend&&this._legendClass.active(t),this._sceneRenderer&&this._scheduleSceneRepaint()),je(this,"active",t),this):this._active}data(t,e){return arguments.length?(dn(this,"data",arguments.length>1?[t,e]:[t]),this._hidden=[],this._solo=[],Ce(this),this._userData&&JSON.stringify(t)!==JSON.stringify(this._userData)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userData=t,this._dataSignature=void 0,en(this),this):this._data}facet(t){return arguments.length?(this.schema.facet=ie(t),this):this.schema.facet}facetConfig(t){return arguments.length?(this.schema.facetConfig=ut(this,"facetConfig",t),this):this.schema.facetConfig}fontFamily(t){if(arguments.length){const e={fontFamily:t},n={titleConfig:e,shapeConfig:{labelConfig:e}};return this.shapeConfig({labelConfig:e}),this.colorScaleConfig({axisConfig:n}),["axis","column","row","timeline","x","y","x2","y2"].forEach(t=>{const e=`${t}Config`;this[e]&&this[e](n)}),["back","title","total","subtitle"].forEach(t=>{const n=`${t}Config`;this[n]&&this[n](e)}),this.tooltipConfig({tooltipStyle:{"font-family":s.fontFamilyStringify(t)}}),this.schema.fontFamily=t,this}return this.schema.fontFamily}groupBy(t){if(!arguments.length)return this.schema.groupBy;this._groupByRaw=t;const e=t instanceof Array?t:[t];return this.schema.groupBy=e.map(t=>"function"==typeof t?t:(this.schema.aggs[t]||(this.schema.aggs[t]=(t,e)=>{const i=n.unique(t.map(e));return 1===i.length?i[0]:i}),q(t))),this}hover(t){if(!arguments.length)return this._hover;let e=this._hover=t;if(1!==this.schema.shapeConfig.hoverOpacity&&void 0!==t){if("function"==typeof t){const n=[...this._filteredData??[],...this._legendClass.data()??[]].filter(t),i=new Set;n.map(this._ids).forEach(t=>{for(let e=1;e<=t.length;e++)i.add(JSON.stringify(t.slice(0,e)))}),i.size&&(e=(t,e)=>{const n=this._ids(t,e),o=me(t);return i.has(JSON.stringify(void 0===o?n:n.slice(0,o+1)))})}this.schema.legend&&this._legendClass.hover(e)}return this._sceneRenderer&&void 0!==t&&(Ve(this)||this._hoverBucket)&&this._scheduleSceneRepaint(),je(this,"hover",t),this}highlight(t){return arguments.length?(this._highlight=t,this._sceneRenderer&&this._scheduleSceneRepaint(),je(this,"highlight",t),this):this._highlight}select(t){return arguments.length?(this._select=o.select(t),this):this._select}shapeConfig(t){return arguments.length?(ot(t)&&bs(It(this),t),this.schema.shapeConfig=ut(this,"shapeConfig",t),this):this.schema.shapeConfig}threshold(t){return arguments.length?("function"==typeof t?this.schema.threshold=t:isFinite(t)&&!isNaN(t)&&(this.schema.threshold=H(1*t)),this):this.schema.threshold}thresholdKey(t){return arguments.length?(this.schema.thresholdKey="function"==typeof t?t:q(t),this):this.schema.thresholdKey}time(t){return arguments.length?("function"==typeof t?this.schema.time=t:t?(this.schema.time=q(t),this.schema.aggs[t]||(this.schema.aggs[t]=(t,e)=>{const i=n.unique(t.map(e));return 1===i.length?i[0]:i}),this._userTime&&JSON.stringify(t)!==JSON.stringify(this._userTime)&&(this.schema.timeFilter=!1,this._timelineSelection=!1),this._userTime=t):(this.schema.time=void 0,this._userTime=void 0,this.schema.timeFilter=!1,this._timelineSelection=!1),this):this.schema.time}timelineDefault(t){return arguments.length?(t instanceof Array||(t=[t,t]),this.schema.timelineDefault=t.map(t=>r.date(t)).filter(t=>!1!==t),this):this.schema.timelineDefault}total(t){return arguments.length?(this.schema.total="function"==typeof t?t:!!t&&q(t),this):this.schema.total}}_s._displayName="VizBase",dt(_s.prototype,"facetConfig","shapeConfig");const ks=new WeakMap,vs=new WeakMap;function ws(t){let e=ks.get(t);return e||ks.set(t,e=new WeakMap),e}function Ms(t){return"number"==typeof t&&Number.isFinite(t)}function Ss(t,e,n){ws(t).set(e,n)}function Cs(t){const e=t.schema.linkColor,n=t.schema.links;if("function"!=typeof e||!Array.isArray(n))return[];const i=t.schema.nodes,o=vs.get(t);if(o&&o.links===n&&o.nodes===i&&o.accessor===e)return o.rows;const r=Array.isArray(i)?i:[],a=new Map;for(const t of r)t&&"object"==typeof t&&void 0!==t.id&&!a.has(`${t.id}`)&&a.set(`${t.id}`,t);const s=ws(t),c=[];return n.forEach((t,n)=>{if(!t||"object"!=typeof t)return;const i=e(function(t,e,n){const i=t=>t&&"object"==typeof t?t:n.get(`${t}`)??("number"==typeof t?e[t]:void 0)??{id:t};return{...t,source:i(t.source),target:i(t.target)}}(t,r,a),n);Ms(i)&&(s.set(t,i),c.push(t))}),vs.set(t,{links:n,nodes:i,accessor:e,rows:c}),c}function $s(t){const e="function"==typeof t.schema.colorScale?t.schema.colorScale:void 0;if(!Cs(t).length)return e;const n=ws(t);return(t,i)=>t&&"object"==typeof t&&n.has(t)?n.get(t):e?e(t,i):void 0}function As(t,e){const n=t._colorScaleClass;if(!n)return;const i=n._colorScale,o=n.color();return i?i.domain().length?i(e):i.range()[i.range().length-1]:Array.isArray(o)?o[o.length-1]:o}function zs(t){const e=t._colorScaleClass,n=$s(t);if(!e||"function"!=typeof e._colorScale||!n)return null;const i=e._colorScale;return{rows:Array.isArray(e._data)?e._data:[],colorOf:(t,e)=>{let o=t;for(;o&&o.__d3plus__&&o.data;)o=o.data;return o&&o._isColorScaleBucket?o.color:i(n(o,e))}}}function Ds(t,e,n){const i=zs(t);if(!i)return null;let o=0,r=0;return i.rows.forEach((t,a)=>{const s=n(t,a);Number.isFinite(s)&&(o+=s,i.colorOf(t,a)===e&&(r+=s))}),o?r/o:null}function Ls(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e&&e._isColorScaleBucket?e:null}function Fs(t,e){const n=t._colorScaleClass;if(!n||!$s(t))return;let i=!1;if("mousemove"===e.type||"mouseenter"===e.type){if(t._transitionEndsAt&&Date.now()<t._transitionEndsAt)return;if(!1===n.hoverMark())return;i=function(t,e){const n=$s(t);if(!e||"function"!=typeof n)return null;if(e.interactionGroup)return null;if(Ls(e.datum))return null;let i=e.datum,o="number"==typeof e.index?e.index:0;for(;i&&i.__d3plus__&&i.data;)i=i.data,"number"==typeof i.i&&(o=i.i);if(!i||"object"!=typeof i)return null;const r=n(i,o);if(null==r||""===r)return null;if("number"!=typeof r&&"string"!=typeof r)return null;const a=+r;return Number.isFinite(a)?a:null}(t,e.pick?.node)??!1}else if("mouseleave"!==e.type)return;(n.hover()??!1)!==i&&(n.hover(i),t._scheduleSceneRepaint())}function Ns(t,e,n){const o={...t.paint??{}};let r="string"==typeof o.fill?o.fill:void 0;if(r&&"transparent"!==r&&"none"!==r||(r="string"==typeof o.stroke?o.stroke:void 0),!r||"transparent"===r||"none"===r)return t;const a=i.color(r);a&&(o.stroke=a.darker(e).formatHex());const s="number"==typeof o.strokeWidth&&o.strokeWidth?o.strokeWidth:1;return o.strokeWidth=s*n,{...t,paint:o}}function Bs(t){const e="function"==typeof t._hover?t._hover:null,n="function"==typeof t._active?t._active:null,i="function"==typeof t._highlight?t._highlight:null;if(!e&&!n&&!i)return null;const o=t.schema.shapeConfig??{};let r="number"==typeof o.hoverOpacity?o.hoverOpacity:.5;const a="number"==typeof o.activeOpacity?o.activeOpacity:.25,s=!e&&!n;return e&&t._hoverBucket&&r>=1&&(r=.5),{predicate:e??n??i,dimOpacity:e?r:n?a:1,isHover:!!e,gray:s,kind:e?"hover":n?"active":"highlight",activePredicate:n}}function Es(t,e){const n=function(t){const e=t._colorScaleClass;if(!e||"function"==typeof t._hover)return null;const n=e.hover();if("number"!=typeof n||!Number.isFinite(n)||!1===e.hoverMark()||e._barGeometry||"function"!=typeof e._colorScale)return null;const i=t.schema.shapeConfig,o=i?.hoverOpacity;return{color:e._colorScale(n),dimOpacity:"number"==typeof o&&o<1?o:.5}}(e);let i,o;if(n)i=new Set([n.color]),o=n.dimOpacity;else{const n=Bs(e);if(!n)return t;i=function(t,e){const n=zs(t);if(!n)return null;const i=new Set;return n.rows.forEach((t,o)=>{e(t,o)&&i.add(n.colorOf(t,o))}),i}(e,n.predicate),o=n.dimOpacity}if(!i)return t;const r=t=>{let e=t,n=t.datum;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(n&&n._isColorScaleBucket&&!i.has(n.color)){const n=t.paint&&"number"==typeof t.paint.opacity?t.paint.opacity:1;e={...t,paint:{...t.paint??{},opacity:n*o}}}const a=e.children;return a&&a.length&&(e={...e,children:a.map(r)}),e};return t.map(r)}function Rs(t,e,n){let i=e;if(t(i,n))return!0;for(;i&&i.__d3plus__&&i.data;)if(i=i.data,t(i,n))return!0;return!1}function Ps(t,e){const n=t.datum;if(n){const i=n.data??n,o="number"==typeof t.index?t.index:"number"==typeof i.i?i.i:0;return Rs(e,i,o)}const i=t.interactionPoints;return i&&i.length?i.some((t,n)=>{const i=t.datum;return Rs(e,i,"number"==typeof i.i?i.i:n)}):null}function Ts(t,n){const i=Bs(n);if(!i)return t;const{predicate:o,dimOpacity:r,isHover:a,gray:s,kind:c,activePredicate:l}=i,h=t=>{const n=t.interactionGroup;if("axis"===n||"timeline"===n)return t;let i=t;const u=Ps(t,o);if(null!==u)if(u){if("highlight"!==c&&$e.has(t.type)){i="active"===c||!!l&&!0===Ps(t,l)?Ns(t,1,3):Ns(t,.5,2)}a&&(i={...i,z:1e6})}else{const n=t.paint??{};if(s){const o={...n};"string"==typeof n.fill&&(o.fill=e.colorGrayscale(n.fill)),"string"==typeof n.stroke&&(o.stroke=e.colorGrayscale(n.stroke)),i={...t,paint:o}}else{const e="number"==typeof n.opacity?n.opacity:1;i={...t,paint:{...n,opacity:e*r}}}}const d=i.children;return d&&d.length&&(i={...i,children:d.map(h)}),i};return t.map(h)}function Os(t){return lo(t)}function Ws(t){return uo(t)}function Hs(t){return mo(t)}const js=["sizeLegend","legend","colorScale"];function Is(t){return{padding:10,margin:6,fillOpacity:.85,strokeWidth:1,rx:4,...t.schema.legendInsetConfig||{}}}function Gs(t,e){return Boolean(t._insetPending&&t._insetPending.has(e))}function qs(t,e){const n=t._insetPlacement;return n&&n.key===e?n:null}function Vs(t,e){return qs(t,e)?.orient??"column"}function Ys(t,e){return"column"===t?{width:.4*e.width,height:.6*e.height}:{width:.6*e.width,height:.4*e.height}}function Ks(t,n){const i=Is(t),o=i.fill??Os(t);return{type:"rect",key:"viz-inset-background",x:n.x,y:n.y,width:n.width,height:n.height,rx:i.rx,ry:i.rx,paint:{fill:o,fillOpacity:i.fillOpacity,stroke:i.stroke??e.colorContrast(o,t.schema.colorDefaults),strokeOpacity:i.stroke?1:.15,strokeWidth:i.strokeWidth}}}function Us(t,e,n,i){const o=Xs(t,e,i);return o?[Ks(t,qs(t,e)),{...n,transform:o}]:[n]}function Xs(t,e,n){const i=qs(t,e);if(!i)return null;const{margin:o}=Is(t);return{x:i.x+o-(n.x??0),y:i.y+o-(n.y??0)}}function Zs(t){let e=t._select?.node()?.parentNode??null;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e instanceof HTMLElement?e:null}function Qs(t){return!!t._focus&&(t.active(!1),t._focus=void 0,t._zoomToBounds(null),!0)}function Js([t,e],n){return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function tc(t,e){const{kind:n,width:i,height:r,duration:a,ocean:s}=e,c=`d3plus-${"generic"===n?"zoom":n}`,l="geomap"===n&&s||"transparent",h=function(t,e){const n="geomap"!==e||"canvas"!==t._renderer||t._ssr?null:Zs(t);if(!n)return t._select;n.style.isolation="isolate";const i=o.select(n).selectAll(":scope > svg.d3plus-geomap-underlay").data([0]);return i.enter().insert("svg",":first-child").attr("class","d3plus-geomap-underlay").style("position","absolute").style("top","0").style("left","0").style("z-index","-1").style("overflow","hidden").style("pointer-events","none").merge(i).attr("width",t.schema.width).attr("height",t.schema.height)}(t,n),u=t._container&&t._container.classed(c)?t._container.node():null;u&&u.parentNode!==h.node()&&h.node().insertBefore(u,h.node().firstChild),h!==t._select?t._select.selectAll(":scope > svg.d3plus-geomap").remove():function(t){const e=Zs(t);e&&e.querySelector(":scope > svg.d3plus-geomap-underlay")?.remove()}(t);let d=h.selectAll(`:scope > svg.${c}`).data([0]);if(d=d.enter().insert("svg",":first-child").attr("class",c).attr("opacity",0).attr("width",i).attr("height",r).attr("x",t._margin.left).attr("y",t._margin.top).style("background-color",l).merge(d),t._container=d,d.transition().duration(a).attr("opacity",1).attr("width",i).attr("height",r).attr("x",t._margin.left).attr("y",t._margin.top),"generic"===n){let e=d.selectAll(`g.${c}-zoomGroup`).data([0]);e=e.enter().append("g").attr("class",`${c}-zoomGroup`).merge(e),t._zoomGroup=e}else if("network"===n){const e=d.selectAll(`rect.${c}-hitArea`).data([0]);e.enter().append("rect").attr("class",`${c}-hitArea`).merge(e).attr("width",i).attr("height",r).attr("fill","transparent").on("click",()=>Qs(t));const{left:n,top:o}=t._margin;t._backgroundClick=e=>{Js(e,{x:n,y:o,width:i,height:r})&&Qs(t)};let a=d.selectAll(`g.${c}-zoomGroup`).data([0]);a=a.enter().append("g").attr("class",`${c}-zoomGroup`).merge(a),t._zoomGroup=a}else{const e=d.selectAll(`rect.${c}-ocean`).data([0]);e.enter().append("rect").attr("class",`${c}-ocean`).merge(e).attr("width",i).attr("height",r).attr("fill",s||"transparent");let n=d.selectAll(`g.${c}-tileGroup`).data([0]);n=n.enter().append("g").attr("class",`${c}-tileGroup`).merge(n),t._tileGroup=n;let o=d.selectAll(`g.${c}-zoomGroup`).data([0]);o=o.enter().append("g").attr("class",`${c}-zoomGroup`).merge(o),t._zoomGroup=o}}function ec(t){const e=t.interactionPoints;if(e&&e.length>1){const t=[];for(let n=1;n<e.length;n++)t.push([Math.abs(e[n].x-e[n-1].x),Math.abs(e[n].y-e[n-1].y)]);return t}const n=function(t){switch(t.type){case"rect":case"image":return[t.width,t.height];case"circle":return[2*t.r,2*t.r];case"path":{const e=f.pathBounds(t.d);return[e.width,e.height]}case"line":{const e=f.pathBounds(a.linePath(t));return[e.width,e.height]}case"area":{const e=f.pathBounds(a.areaPath(t));return[e.width,e.height]}default:return null}}(t);return n?[n]:[]}const nc=new WeakSet;function ic(t){return nc.add(t),t}function oc(t){return"function"==typeof t&&nc.has(t)}function rc(t,e,n){const i={fill:"none",vectorEffect:"non-scaling-stroke"};return[{...t,key:`viz-focus-halo-${n}`,paint:{...i,stroke:e.halo,strokeWidth:e.strokeWidth+2}},{...t,key:`viz-focus-ring-${n}`,paint:{...i,stroke:e.stroke,strokeWidth:e.strokeWidth}}].map(t=>({...t,interactive:!1,aria:{hidden:!0}}))}function ac(t,e){const{node:n,box:i,center:o,chain:r}=t,a=e.padding;if(void 0!==t.pointIndex)return rc({type:"circle",cx:o[0],cy:o[1],r:5+a},e,"circle");if("circle"===n.type)return rc({type:"circle",cx:o[0],cy:o[1],r:i.width/2+a},e,"circle");if("path"===n.type&&function(t){const e=t.paint?.fill;return!!e&&"none"!==e&&"transparent"!==e}(n)){return function(t,e){return t.reduceRight((t,e,n)=>[{type:"group",key:`viz-focus-t${n}`,transform:e,children:t,interactive:!1}],e)}(n.transform?[...r,n.transform]:r,rc({type:"path",d:n.d},e,"path"))}return rc({type:"rect",x:i.x-a,y:i.y-a,width:i.width+2*a,height:i.height+2*a},e,"rect")}function sc(t,e){return{type:"group",key:"viz-focus",interactive:!1,aria:{hidden:!0},children:ac(t,e)}}function cc([t,e],n){if(!n)return[t,e];let i=t,o=e;if(n.rotate){const[t,e]=n.rotateAnchor??[0,0],r=n.rotate*Math.PI/180,a=Math.cos(r),s=Math.sin(r),c=i-t,l=o-e;i=t+c*a-l*s,o=e+c*s+l*a}const r=n.scale??1;return[i*r+(n.x??0),o*r+(n.y??0)]}const lc=([t,e])=>({x:t,y:e,width:0,height:0});function hc(t){switch(t.type){case"rect":case"image":return[{x:t.x,y:t.y,width:t.width,height:t.height}];case"circle":return[{x:t.cx-t.r,y:t.cy-t.r,width:2*t.r,height:2*t.r}];case"path":{const e=f.path2polygon(t.d,10);return e.length?e.map(lc):[f.pathBounds(t.d)]}case"line":return t.points.map(lc);case"area":return[...t.topline,...t.baseline].map(lc);case"text":return function(t){if(t.path)return a.pathTextBoxes(t).map(e=>{const n=a.rotatedBoxBounds(e);return{...n,x:t.x+n.x,y:t.y+n.y}});const e=t.font?.size??0,n=t.font?.baseline??"alphabetic",i="hanging"===n?0:"middle"===n?e/2:.8*e;return(t.lines||[]).filter(t=>t.text&&t.width).map(n=>({x:t.x+a.lineLeft(n,t.font),y:t.y+n.y-i,width:n.width,height:e}))}(t);default:return[]}}function uc(t){return e=>t.reduceRight((t,e)=>cc(t,e),e)}function dc(t,e){if(0===t.width&&0===t.height){const[n,i]=e([t.x,t.y]);return{x:n,y:i,width:n-n,height:i-i}}const n=[e([t.x,t.y]),e([t.x+t.width,t.y]),e([t.x,t.y+t.height]),e([t.x+t.width,t.y+t.height])],i=n.map(t=>t[0]),o=n.map(t=>t[1]),r=Math.min(...i),a=Math.min(...o);return{x:r,y:a,width:Math.max(...i)-r,height:Math.max(...o)-a}}function fc(t,e,n,i=!1){const o=[],r=(t,e)=>{for(const a of t){if(String(a.key).endsWith("::hit")||n&&n(a))continue;const t=a.transform?[...e,a.transform]:e;if("group"===a.type){r(a.children,t);continue}if(!i&&void 0===a.datum)continue;const s=uc(t);for(const t of hc(a))[t.x,t.y,t.width,t.height].every(Number.isFinite)&&o.push(dc(t,s))}};return r(t,e?[e]:[]),o}const mc={"viz-chart-cells":"shape","viz-legend":"legend"},pc=new Set(["axis","timeline","trend"]);function gc(t){const e=t;return String(e.key).endsWith("::hit")||!1===e.interactive||!!e.aria?.hidden||void 0!==e.interactionGroup&&pc.has(e.interactionGroup)}function yc(t){const e=t;return e&&e.data?e.data:e}const xc=([t,e],n)=>t>=n.x-1&&t<=n.x+n.width+1&&e>=n.y-1&&e<=n.y+n.height+1,bc=t=>[t.x,t.y,t.width,t.height].every(Number.isFinite);function _c(t,e,n,i){const o=uc(e),r=[];return(t.interactionPoints||[]).forEach((a,s)=>{if(i.has(a.datum))return;i.add(a.datum);const c=o([a.x,a.y]),l={x:c[0],y:c[1],width:0,height:0};if(!bc(l))return;const h=`${t.key}@${s}`;r.push({id:h,node:t,pointIndex:s,center:c,box:l,group:n,chain:e})}),r}function kc(t,e,n){const i=uc(t.transform?[...e,t.transform]:e),o=hc(t).filter(bc).map(t=>dc(t,i));if(!o.length)return null;const r=function(t){const e=Math.min(...t.map(t=>t.x)),n=Math.min(...t.map(t=>t.y));return{x:e,y:n,width:Math.max(...t.map(t=>t.x+t.width))-e,height:Math.max(...t.map(t=>t.y+t.height))-n}}(o),a="path"===t.type?[o.reduce((t,e)=>t+e.x,0)/o.length,o.reduce((t,e)=>t+e.y,0)/o.length]:[r.x+r.width/2,r.y+r.height/2];return{id:String(t.key),node:t,center:a,box:r,group:n,chain:e}}function vc(t){return[...t].sort((t,e)=>Math.round(t.box.x)-Math.round(e.box.x)||Math.round(t.box.y)-Math.round(e.box.y))}function wc(t){const e={shape:[],legend:[]};for(const n of t){const t=mc[String(n.key)];if(!t)continue;const i=new Set,o=(n,r,a)=>{if(gc(n))return;if("group"===n.type){const t=n.transform?[...r,n.transform]:r,e=n.clip,i=e&&"rect"===e.type?[...a,dc(e,uc(t))]:a;for(const e of n.children)o(e,t,i);return}if(!$e.has(n.type)||void 0===n.datum)return;if(0===n.paint?.opacity)return;const s=t=>a.every(e=>xc(t.center,e));if(n.interactionPoints?.length){const o=_c(n,r,t,i);return void e[t].push(...o.filter(s))}const c=yc(n.datum);if(i.has(c))return;const l=kc(n,r,t);l&&s(l)&&(i.add(c),e[t].push(l))};o(n,[],[])}return[...vc(e.shape),...vc(e.legend)]}function Mc(t,e,n){const i="x"===n?"width":"height";return Math.min(t[n]+t[i],e[n]+e[i])-Math.max(t[n],e[n])}function Sc(t,e,n){if(!e)return t[0]??null;const i="left"===n||"right"===n,o="right"===n||"down"===n?1:-1,r=i?"y":"x",a=void 0!==e.pointIndex&&function(t){const e=t.interactionPoints||[],n=t=>Math.max(...e.map(e=>e[t]))-Math.min(...e.map(e=>e[t]));return n("x")>=n("y")?"x":"y"}(e.node)===(i?"x":"y");let s=null,c=1/0,l=null,h=1/0;for(const n of t){if(n.id===e.id)continue;const t=n.center[0]-e.center[0],u=n.center[1]-e.center[1],d=o*(i?t:u);if(d<=.5)continue;const f=a&&n.node===e.node||Mc(n.box,e.box,r)>0?0:Math.abs(i?u:t);f<=d&&d+2*f<c&&(s=n,c=d+2*f);const m=Math.hypot(t,u);m<h&&(l=n,h=m)}return s??l??e}const Cc="Use arrow keys to move between data points, Enter to select, and Escape to exit.",$c={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",border:"0",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap"};function Ac(t){return String(t??"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function zc(t){const{schema:e}=t,n=Ac(e.svgTitle);if(n)return n;if("function"==typeof e.title)try{const n=Ac(e.title(t._filteredData||[]));if(n)return n}catch{}return e.translate("Chart")}function Dc(t,e){const n=t.ownerDocument,i=n.createElement("div");i.className="d3plus-keyboard-nav",i.setAttribute("tabindex","0"),i.setAttribute("role","application"),Object.assign(i.style,{position:"absolute",pointerEvents:"none",outline:"none"});const o=n.createElement("span");o.id=`${e}-keyboard-desc`;const r=n.createElement("span");r.setAttribute("aria-live","polite"),r.setAttribute("aria-atomic","true");for(const t of[o,r])Object.assign(t.style,$c),i.appendChild(t);return t.appendChild(i),{host:i,desc:o,live:r}}function Lc(t,{host:e,desc:n}){const i=e=>t.schema.translate(e);e.setAttribute("aria-label",zc(t)),e.setAttribute("aria-roledescription",i("interactive chart"));const o=t.schema.svgDesc?`${t._uuid}-desc ${n.id}`:n.id;e.setAttribute("aria-describedby",o);const r=t._keyboardGesture?.keys()??null,a=i(Cc);n.textContent=r?`${a} ${r.instructions}`:a,r?e.setAttribute("aria-keyshortcuts",r.shortcuts):e.removeAttribute("aria-keyshortcuts");const s=t._select?.node?.();Object.assign(e.style,{top:s?.style.top||"0px",left:s?.style.left||"0px",width:`${t.schema.width||0}px`,height:`${t.schema.height||0}px`})}function Fc(t,e){const n=t;return{d:n&&n.data?n.data:n,i:n&&"number"==typeof n.i?n.i:e,x:t}}const Nc={area:"Area",circle:"Circle",line:"Line",path:"Path",rect:"Rect"};function Bc(t){return"string"==typeof t.shapeType?t.shapeType:Nc[t.type]}const Ec={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function Rc(t){return wc(t._paintedScene?.root.children??[])}function Pc(t,e){return e.find(e=>e.id===t.current)??null}function Tc(t){const{node:e,pointIndex:n}=t,i=void 0!==n?e.interactionPoints?.[n]:void 0;return i?Fc(i.datum,i.index):Fc(e.datum,e.index??0)}function Oc(t,e){const{node:n,pointIndex:i}=e;if(void 0!==i?n.interactionPoints?.[i]:void 0){const i=t.schema.shapeConfig||{},o=n.shapeType&&i[n.shapeType]?.ariaLabel||i.ariaLabel;if("function"==typeof o)try{const{d:t,i:n}=Tc(e),i=o(t,n);if(i)return String(i)}catch{}}else if(n.aria?.label)return n.aria.label;const{d:o,i:r}=Tc(e);return void 0===o?"":String(t._drawLabel(o,r)??"")}function Wc(t,e){const n=t.schema.keyboardNavConfig||{},{d:i,i:o}=Tc(e),r=(t,e)=>{const n="function"==typeof t?t(i,o):t;return null==n?e:n};return{stroke:r(n.stroke,Ws(t)),strokeWidth:r(n.strokeWidth,2),padding:r(n.padding,2),halo:Os(t)}}function Hc(t,e,n){if(e.queue.push(n),void 0!==e.timer)return;const i=()=>{e.timer=void 0;const n=(t._transitionEndsAt??0)-Date.now();if(n>0)return void(e.timer=setTimeout(i,n+5));const o=e.queue.splice(0);for(const t of o)t()};i()}function jc(t,e,n,i={}){const o=n??i.at,r=o?[...o.center]:[0,0],a=t._select?.node?.(),s=a?.getBoundingClientRect?.()??{left:0,top:0},c=new MouseEvent(i.nativeType??e,{clientX:s.left+r[0],clientY:s.top+r[1],shiftKey:!!i.shiftKey}),l={type:e,point:r,pick:n?{node:n.node,datum:n.node.datum,index:n.node.index}:null,nativeEvent:c};t._routeSceneEvent?.(l)}function Ic(t,e,n){const i=e.hovered;i&&i.node.key===n.node.key||(i&&jc(t,"mouseleave",null,{nativeType:"mousemove",at:n}),jc(t,"mouseenter",n)),jc(t,"mousemove",n),e.hovered=n}function Gc(t,e){const n=e.hovered;n&&(e.hovered=null,jc(t,"mouseleave",null,{at:n}))}function qc(t,e){const{host:n}=e;let i=n.ownerDocument.activeElement===n&&!e.current;if(i)try{i=n.matches(":focus-visible")}catch{}n.style.outline=i?`2px solid ${Ws(t)}`:"none",n.style.outlineOffset=i?"-2px":""}function Vc(t,e,n,i=!0){e.current=n.id,e.chartScene=t._chartScene,e.zoom=t._zoomTransform;const o=Oc(t,n);e.live.textContent!==o&&(e.live.textContent=o),Hc(t,e,()=>{Ic(t,e,n),i&&t._scheduleSceneRepaint()}),qc(t,e)}function Yc(t,e){const n=null!==e.current;e.current=null,Hc(t,e,()=>{Gc(t,e),n&&t._scheduleSceneRepaint()}),qc(t,e)}function Kc(t,e,n){const i=n;if(i.altKey||i.ctrlKey||i.metaKey)return;if(t._keyboardGesture?.keydown(i))return void i.preventDefault();const{key:o}=i,r=Rc(t),a=Pc(e,r),s=function(t,e,n){return Ec[t]?Sc(e,n,Ec[t]):"Home"===t?e[0]??null:"End"===t?e[e.length-1]??null:void 0}(o,r,a);if(void 0!==s)i.preventDefault(),s&&Vc(t,e,s);else if(!a||"Enter"!==o&&" "!==o)a&&"Escape"===o&&(i.preventDefault(),Yc(t,e));else{i.preventDefault();const n=i.shiftKey;Hc(t,e,()=>{Ic(t,e,a),jc(t,"click",a,{shiftKey:n})})}}function Uc(t){const e=t._keyboardNav;if(e){t._keyboardNav=void 0,void 0!==e.timer&&clearTimeout(e.timer),e.queue=[],Gc(t,e);for(const[t,n]of e.listeners)e.host.removeEventListener(t,n);e.host.remove()}}function Xc(t,e){const n={...Dc(e,t._uuid),current:null,hovered:null,stale:!1,queue:[],listeners:[]};n.listeners=[["keydown",e=>Kc(t,n,e)],["focus",()=>function(t,e){if(!e.current){const n=Rc(t)[0];n&&Vc(t,e,n)}qc(t,e)}(t,n)],["blur",()=>Yc(t,n)]];for(const[t,e]of n.listeners)n.host.addEventListener(t,e);return n}function Zc(t){const e=t.schema.keyboardNav?function(t){const e=t._select?.node?.(),n=e?.parentNode;return n&&1===n.nodeType&&"http://www.w3.org/1999/xhtml"===n.namespaceURI?n:null}(t):null;if(!e)return void Uc(t);let n=t._keyboardNav;n&&n.host.parentNode!==e&&(Uc(t),n=void 0),n||(n=t._keyboardNav=Xc(t,e)),Lc(t,n);const i=t._chartScene!==n.chartScene||t._zoomTransform!==n.zoom;if(n.current&&i&&(n.stale=!0),n.stale){n.stale=!1;const e=n.current?Pc(n,Rc(t)):null;e?Vc(t,n,e,!1):Yc(t,n)}}function Qc(t,e){const n=t._keyboardNav;if(!n||!n.current)return;const i=wc(e);let o=Pc(n,i);o||(o=i[0]??null,n.current=o?o.id:null,n.stale=!0),o&&e.push(sc(o,Wc(t,o)))}const Jc=t=>t&&"function"!=typeof t?q(t):t,tl={aggs:{merge:!0},ariaHidden:{},attribution:{},attributionIcon:{},attributionStyle:{merge:!0},backControlClassName:{},backControlStyle:{},cache:{},color:{coerce:Jc},colorOrdinal:{default:!1},colorScale:{coerce:Jc},colorScaleConfig:{merge:!0},colorScaleMaxSize:{},colorScalePadding:{coerce:"const"},colorScalePosition:{coerce:"const"},dataCutoff:{},dataFormat:{},dataPollingInterval:{onSet:t=>function(t){(t._dataPollStop||t._sceneRenderer)&&(t._queue?.some(t=>"data"===t[3])||an(t))}(t)},depth:{},detectResize:{},detectResizeDelay:{},detectVisible:{},detectVisibleInterval:{},detectVisibleUnload:{},discrete:{},duration:{},filter:{},height:{},hiddenColor:{coerce:"const"},hiddenOpacity:{coerce:"const"},hoverDistance:{default:20},keyboardNav:{default:!0,onSet:(t,e)=>{e||Uc(t)}},keyboardNavConfig:{merge:!0,default:{padding:2,strokeWidth:2}},label:{coerce:"const"},labelPosition:{coerce:"const",default:"auto"},legend:{coerce:"const"},legendConfig:{merge:!0},legendFilterInvert:{coerce:"const"},legendHistory:{default:!0},legendInset:{},legendInsetConfig:{merge:!0},legendPadding:{coerce:"const"},legendPosition:{coerce:"const"},legendSort:{},legendTooltip:{merge:!0},link:{onSet:t=>Be(t)},loadingHTML:{coerce:"const"},loadingMessage:{},messageMask:{},messageStyle:{merge:!0},minimap:{},minimapClassName:{},minimapLabelStyle:{},minimapStyle:{},minimapViewportStyle:{},minimapViewportStyleActive:{},noDataHTML:{coerce:"const"},noDataMessage:{},pointLabelConfig:{merge:!0,default:{fontMin:10,fontSize:11,padding:3}},reducedMotion:{},saveControl:{},saveControlClassName:{},saveControlConfig:{merge:!0},saveControlMenuClassName:{},saveControlMenuItemStyle:{},saveControlMenuItemStyleHover:{},saveControlMenuStyle:{},saveControlStyle:{},saveControlStyleActive:{},saveControlStyleHover:{},scrollContainer:{},search:{},searchAccessor:{},searchControlClassName:{},searchControlStyle:{},searchControlStyleActive:{},searchControlStyleHover:{},shape:{coerce:"const"},sizeLegend:{coerce:"const"},sizeLegendConfig:{merge:!0},sizeLegendPosition:{},subtitle:{coerce:"const"},subtitleConfig:{merge:!0},subtitlePadding:{coerce:"const"},svgDesc:{},svgTitle:{},tableView:{},tableViewClassName:{},tableViewControlClassName:{},tableViewControlStyle:{},tableViewControlStyleActive:{},tableViewControlStyleHover:{},tableViewDownload:{},tableViewPageSize:{},tableViewSort:{},theme:{},thresholdName:{coerce:"const"},timeFilter:{},timeline:{},timelineConfig:{merge:!0},timelinePadding:{coerce:"const"},title:{coerce:"const"},titleConfig:{merge:!0},titlePadding:{coerce:"const"},tooltip:{coerce:"const"},tooltipConfig:{merge:!0},totalConfig:{merge:!0},totalFormat:{},totalPadding:{coerce:"const"},width:{},zoom:{},zoomBrushHandleSize:{},zoomBrushHandleStyle:{},zoomBrushSelectionStyle:{},zoomControlClassName:{},zoomControlIcons:{},zoomControlStyle:{},zoomControlStyleActive:{},zoomControlStyleHover:{},zoomFactor:{},zoomMax:{},zoomPadding:{},zoomPan:{},zoomScroll:{}},el=Object.entries(tl).map(([t,e])=>({key:t,...e}));function nl(t){if(!["string","number","boolean"].includes(typeof t))return;const e=`${t}`;return""===e||i.color(e)?void 0:e}function il(t,e){if(t._legendCategories&&e){for(;e.__d3plus__&&e.data;)e=e.data;return t._legendCategories.get(e)}}function ol(t,e){return il(this,t)??this._drawLabel(t,e,this._legendDepth)}function rl(t){return a.isFlipEligible(t)?"rect"===t.type?{x:t.x,y:t.y,width:t.width,height:t.height}:"circle"===t.type?{x:t.cx-t.r,y:t.cy-t.r,width:2*t.r,height:2*t.r}:"area"===t.type?f.pathBounds(a.areaPath(t)):"path"===t.type?f.pathBounds(t.d):null:null}function al(t,e){for(const n of t){if(a.isFlipEligible(n)&&e(n))return n;if("group"===n.type&&n.children.length){const t=al(n.children,e);if(t)return t}}}function sl(t){const e=t._pendingEnterOrigin;if(t._pendingEnterOrigin=void 0,e&&t._bodyRect){const n=t._bodyRect;t._resolvedEnterFrom={x:n.x+e.fx*n.width,y:n.y+e.fy*n.height,width:e.fw*n.width,height:e.fh*n.height},t._resolvedEnterFromBody=n,t._resolvedInstantExitKey=e.key}else t._resolvedEnterFrom=void 0,t._resolvedEnterFromBody=void 0,t._resolvedInstantExitKey=void 0;const n=t._pendingExitReunion;if(t._pendingExitReunion=void 0,n&&t._chartScene){const e=t.schema.groupBy?.[n.groupDepth],i=e?al(t._chartScene,t=>{const i=function(t){const e=t;return e&&e.data?e.data:e}(t.datum);return void 0!==i&&e(i,function(t,e){const n=t;return n&&"number"==typeof n.i?n.i:e??0}(t.datum,t.index))===n.groupId}):void 0;t._resolvedExitTo=i?rl(i)??void 0:void 0,t._resolvedExitToBody=n.body,t._resolvedReunionEnterKey=i?.key,t._resolvedReunionEnterFrom=i?n.body:void 0,t._resolvedInstantExitAll=Boolean(i)}else t._resolvedExitTo=void 0,t._resolvedExitToBody=void 0,t._resolvedReunionEnterKey=void 0,t._resolvedReunionEnterFrom=void 0,t._resolvedInstantExitAll=void 0}function cl(t,e,n,i){i.stopPropagation();const o=me(t);if(void 0===o){if(this._drawDepth<this.schema.groupBy.length-1){this._select.style("cursor","auto");const n=this.schema.groupBy[this._drawDepth],i=n(t,e);this.hover(!1),this.schema.tooltip(t,e)&&this._tooltipClass.data([]).render();const o=this.schema.filter,r=this._lastScenePick?.node,a=r&&rl(r);if(a&&this._bodyRect&&this._bodyRect.width&&this._bodyRect.height){const t=this._bodyRect;this._pendingEnterOrigin={fx:(a.x-t.x)/t.width,fy:(a.y-t.y)/t.height,fw:a.width/t.width,fh:a.height/t.height,key:r.key,parentStartAngle:r.startAngle,parentEndAngle:r.endAngle}}const s=Se(this);this._history.push({depth:this.schema.depth,filter:o,groupId:i,groupDepth:this._drawDepth,...s&&{legend:s}});const c=Array.isArray(i)?t=>i.includes(t):t=>t===i;this.config({depth:this._drawDepth+1,filter:(t,e)=>(!o||o(t,e))&&c(n(t,e))}).render()}}else!function(t,e,n){const i=t.schema.groupBy,o=pe(i,e,n);if(!ye(i,o,t._filteredData??[]))return;t._select.style("cursor","auto"),t.hover(!1),t._tooltipClass.data([]).render();const r=t.schema.filter;t._history.push({depth:t.schema.depth,filter:r}),t.config({filter:(t,e)=>(!r||r(t,e))&&ge(i,o,t,e)}).render()}(this,t,o)}function ll(t,e,n,i){this._select.style("cursor","auto"),this.schema.tooltip(t,e)&&this._tooltipClass.data([]).render();let o=this._id(t,e);o instanceof Array||(o=[o]);const r=this._hidden.indexOf(o[0]),a=this._solo.indexOf(o[0]),s=h.merge(this._legendClass.data().map((t,e)=>{let n=this._id(t,e);return n instanceof Array||(n=[n]),n})).length,c=this.schema.legendFilterInvert.bind(this)(this),l=this,u=ve(l),d=()=>{we(l,u),qe(l),this.render()};c?i.shiftKey?r<0&&!this._solo.length?(this._hidden=this._hidden.concat(o),a>=0&&(this._solo=[]),this._hidden.length===s&&(this._hidden=[]),d()):a>=0&&(this._solo=[],this._hidden=[],d()):(a<0&&this._hidden.length<s-1?(this._solo=o,this._hidden=[]):(this._solo=[],this._hidden=[]),d()):i.shiftKey&&a<0?(this._solo=o,this._hidden=[],d()):i.shiftKey||(r>=0?this._hidden=this._hidden.filter(t=>!o.includes(t)):a>=0?(this._solo=[],this._hidden=[]):this._solo.length&&a<0?(this._solo=this._solo.concat(o),this._solo.length===s&&(this._solo=[])):(this._hidden=this._hidden.concat(o),this._hidden.length===s&&(this._hidden=[])),d())}function hl(t,e){if(this._sharedHoverActive&&"shared"===this._sharedHoverState?.mode)return;const n=Ls(t);if(n){const t=function(t,e){const n=zs(t);return n?(t,i)=>n.colorOf(t,i)===e:null}(this,n.color);return void(t&&(this._hoverBucket=!0,this.hover(t)))}if(this._hoverBucket=!1,(!this._sharedHoverActive||!this._plotColumnHighlight)&&Ve(this)){const n=me(t);if(void 0!==n){const e=this.schema.groupBy,i=pe(e,t,n);return void this.hover((t,n)=>ge(e,i,t,n))}let i=this._id(t,e);i instanceof Array||(i=[i]),this.hover((t,e)=>{let n=this._id(t,e);return n instanceof Array||(n=[n]),i.some(t=>n.includes(t))})}}function ul(t,e){if(!Array.isArray(t)&&!Array.isArray(e))return t===e;const n=new Set([].concat(t)),i=new Set([].concat(e));return n.size===i.size&&[...n].every(t=>i.has(t))}function dl(t,e){setTimeout(()=>{let n=t;for(;n&&n.__d3plus__&&n.data;)n=n.data;if(!n)return;let i=this._hoverDatum;for(;i&&i.__d3plus__&&i.data;)i=i.data;if(i&&ul(this._id(i),this._id(n)))return;if(this._sharedHoverActive)return;Ve(this)&&this._hover&&!this._hover(t,e)||this.hover(!1);const o=this._tooltipClass.data();if(o.length&&this.schema.tooltip(t,e)){let t=o[0];for(;t.__d3plus__&&t.data;)t=t.data;ul(this._id(t),this._id(n))&&this._tooltipClass.data([]).render()}},0),this._select.style("cursor","auto")}const fl="__d3plusShare",ml="__d3plus",pl=new WeakSet;function gl(t,e){t[fl]=e,(void 0===t.share||pl.has(t))&&(t.share=e,pl.add(t))}function yl(t){return t?t[fl]:void 0}function xl(t){const e=yl(t);return Array.isArray(e)?e.reduce((t,e)=>t+e,0):"number"==typeof e?e:NaN}function bl(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}function _l(t,e,n){let i=0;for(const t of e)i+=Math.abs(+n(t))||0;return i>0?Math.abs(+n(t))/i:NaN}function kl(t){return t.startsWith(ml)}const vl=`${ml}Members`;function wl(t,e,n,i){const o=new Map;return t.forEach((t,r)=>{const a=`${e(t,r)}`,s=+i(t,r)||0,c=o.get(a);c?c.value+=s:o.set(a,{label:`${n(t,r)}`,value:s})}),Array.from(o.values()).sort((t,e)=>e.value-t.value)}const Ml=t=>`<span class="d3plus-tooltip-member" style="padding-left: 12px">${t}</span>`;function Sl(t,e,n=10){const i=function(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;const n=e?e[vl]:void 0;return n?Array.isArray(n)?n:[n]:[]}(e);if(!i.length)return[];const o=t._thresholdMemberFormat??(e=>d.formatAbbreviate(e,t.schema.locale)),r=i.slice(0,n).map(t=>[Ml(t.label),o(t.value)]),a=i.slice(n);return a.length&&r.push([Ml(`+${d.formatAbbreviate(a.length,t.schema.locale)} ${t.schema.translate("more")}`),o(a.reduce((t,e)=>t+e.value,0))]),r}function Cl(t,e,n){const i=Sl(e,n);if(!i.length)return t;const o=t.tbody();return t.tbody((t,e)=>{const n="function"==typeof o?o(t,e):o;return[...Array.isArray(n)?n:[],...i]}),t}const $l=10,Al="display: inline-block; flex: none; margin-right: 6px; width: 10px; height: 10px;";function zl(t,e){if(!t)return"";if("Line"===e){const e=6;return`<span class="d3plus-tooltip-swatch d3plus-tooltip-swatch-line" style="${Al} position: relative"><span style="position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: ${t}"></span><span style="position: absolute; left: ${($l-e)/2}px; top: ${($l-e)/2}px; width: ${e}px; height: ${e}px; border-radius: 50%; background: ${t}"></span></span>`}return`<span class="d3plus-tooltip-swatch" style="${Al} border-radius: ${"Circle"===e?"50%":"1px"}; background: ${t}"></span>`}function Dl(t,e){return t?null==e||!1===e||""===e?"":`<span style="display: inline-flex; align-items: center">${t}<span>${e}</span></span>`:`${e}`}const Ll=t=>"string"==typeof t&&"none"!==t&&"transparent"!==t?t:void 0;function Fl(t,e){for(const n of t){if(n.key===e)return n;const t=n.children&&Fl(n.children,e);if(t)return t}}const Nl=["::hit","::confidence","::stem"];function Bl(t,e){const n=e&&e.key;if("string"!=typeof n)return e;let i=n;for(const t of Nl)for(;i.endsWith(t);)i=i.slice(0,-t.length);return i===n?e:Fl(t._chartScene||[],i)||e}function El(t,e){const n=Bl(t,e);return n&&Rl(n)}function Rl(t){const e=t.paint;if(e)return"Line"===t.shapeType?Ll(e.stroke)??Ll(e.fill):Ll(e.fill)??Ll(e.stroke)}const Pl=t=>!!t.paint&&"Label"!==t.shapeType&&"text"!==t.type,Tl=t=>t.shapeType??("circle"===t.type?"Circle":void 0);function Ol(t){let e=t;for(;e&&"object"==typeof e&&e.data&&"object"==typeof e.data&&!Array.isArray(e.data);)e=e.data;return e}function Wl(t,e,n){for(const i of t){if(Pl(i)&&!`${i.key}`.endsWith("::hit")&&"legend"===i.interactionGroup===n&&Ol(i.datum)===e&&Rl(i))return i;const t=i.children&&Wl(i.children,e,n);if(t)return t}}function Hl(t,e){if(!e||!e.node)return"";const n=e.node,i=Pl(n)?El(t,n):void 0;if(i&&!e.isLegend)return zl(i,Tl(n));const o=t._paintedScene?.root,r=i?n:o&&Wl([o],Ol(e.d),!!e.isLegend);if(!r)return"";const a=r.datum?.shape;return zl(El(t,r),e.isLegend&&"string"==typeof a?a:Tl(r))}function jl(t,e){if(!e||!1===t.schema.titleSwatch)return t;const n=t.schema.title;return t.title((t,i)=>Dl(e,n(t,i)))}function Il(t,e,n,i){const o=i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY],r=h.merge(this._legendClass.data().map((t,e)=>{let n=this._id(t,e);return n instanceof Array||(n=[n]),n})).length;if(t&&this.schema.tooltip(t,e)){let i=this._id(t,e);i instanceof Array&&(i=i[0]);const a=this.schema.translate,s=ll.bind(this).toString(),c=Object.keys(this.schema.on).some(t=>["click","click.legend"].includes(t)&&this.schema.on[t]&&this.schema.on[t].toString()!==s),l=this.schema.on["click.legend"]&&this.schema.on["click.legend"].toString()===s,h=this._drawDepth<this.schema.groupBy.length-1;this._select.style("cursor",c||l&&h?"pointer":"auto");const u=this.schema.legendFilterInvert.bind(this)(this),d=this._solo.includes(i),f=this._hidden.includes(i);this._tooltipClass.data([n||t]).footer(!!l&&(u?this._solo.length&&!d||f?a("Click to Highlight"):1===this._solo.length&&d||this._hidden.length===r-1?a("Click to Show All"):`${a("Click to Highlight")}<br />${a("Shift+Click to Hide")}`:this._solo.length&&!d||f?`${a("Click to Show")}<br />${a("Shift+Click to Highlight")}`:1===this._solo.length&&d||this._hidden.length===r-1?a("Click to Show All"):`${a("Click to Hide")}<br />${a("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():ol.bind(this)).titleSwatch(!0).position(o).config(Qt.bind(this)(this.schema.tooltipConfig)).config(Qt.bind(this)(this.schema.legendTooltip)),Cl(this._tooltipClass,this,t),jl(this._tooltipClass,Hl(this,this._lastScenePick)).render()}}function Gl(t){if(!t)return null;const{touches:e,changedTouches:n}=t,i=e?.[0]??n?.[0]??t;return"number"==typeof i.clientX&&"number"==typeof i.clientY?[i.clientX,i.clientY]:null}function ql(t,e){if(!e)return!1;if("wheel"===e.type||"touchmove"===e.type)return!0;if("mousemove"!==e.type)return!1;const n=Gl(e);return!t||!n||n[0]!==t[0]||n[1]!==t[1]}function Vl(t){return!!t._gestureHover?.moving}function Yl(t,e){t._gestureHover={press:Gl(e.sourceEvent),moving:!1}}function Kl(t,e){const n=t._gestureHover;n&&!n.moving&&ql(n.press,e.sourceEvent)&&(n.moving=!0,function(t,e){t._nearestHover&&(t._nearestHover.key=null);const n=(t._zoomEventTarget||t._container)?.node(),i=Gl(e),o=n?.getBoundingClientRect(),r=i&&o?[i[0]-o.left,i[1]-o.top]:[0,0];t._routeSceneEvent?.({type:"mouseleave",point:r,pick:null,nativeEvent:e});const a=t._tooltipClass;a&&a.data().length&&a.data([]).render()}(t,e.sourceEvent))}function Ul(t){t._gestureHover=void 0}function Xl(t,e){const n=t._facetPanels;if(!n||!n.length||!e)return;const i=t._zoomTransform,o=i&&i.scale?i.scale:1,r=(e[0]-(i?.x??0))/o,a=(e[1]-(i?.y??0))/o;return n.find(t=>{const e=t.cell;return r>=e.x&&r<=e.x+e.width&&a>=e.y&&a<=e.y+e.height})}function Zl(t,e,n){if(!e)return n();const i=t,o=function(t){return{_chartScene:t.scene,_chartTransform:t.chartTransform,...t.state}}(e),r={};for(const t of Object.keys(o))r[t]=i[t],i[t]=o[t];try{return n()}finally{for(const t of Object.keys(o))i[t]===o[t]&&(i[t]=r[t])}}function Ql(t,e){const n=t;for(const t of e)for(const e of Object.keys(t.state))n[e]=void 0}function Jl(t,e,[n,i],[o,r]){const a=o-n,s=r-i,c=a*a+s*s,l=c?Math.max(0,Math.min(1,((t-n)*a+(e-i)*s)/c)):0;return Math.hypot(t-(n+l*a),e-(i+l*s))}function th(t,e,n){let i=!1,o=1/0;for(let r=0,a=n.length-1;r<n.length;a=r++){const[s,c]=n[r],[l,h]=n[a];c>e!=h>e&&t<(l-s)*(e-c)/(h-c)+s&&(i=!i),o=Math.min(o,Jl(t,e,n[a],n[r]))}return i?0:o}function eh(t,e){const n=t.map((t,e)=>e).filter(e=>Number.isFinite(t[e].x)&&Number.isFinite(t[e].y)),i=function(t,e){let n=e.x,i=e.y,o=e.x+e.width,r=e.y+e.height;for(const e of t)n=Math.min(n,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),r=Math.max(r,e.y);return{x:n,y:i,width:o-n,height:r-i}}(n.map(e=>t[e]),e),o=k.Delaunay.from(n,e=>t[e].x,e=>t[e].y),r=new Map(n.map((t,e)=>[t,e])),a=t=>Number.isFinite(t.r)?Math.max(0,t.r):0,s=n.reduce((e,n)=>Math.max(e,a(t[n])),0);let c;const l=t=>{const e=(c??(c=o.voronoi([i.x,i.y,i.x+i.width,i.y+i.height]))).cellPolygon(t);return e?e.slice(0,-1):null},h=t=>[...o.neighbors(t)].filter(t=>t>=0);return{points:t,bounds:i,nearest:(e,i,r=1/0)=>{if(!n.length||!Number.isFinite(e)||!Number.isFinite(i))return null;const c=o.find(e,i),u=o=>Math.hypot(t[n[o]].x-e,t[n[o]].y-i),d=r+s;if(u(c)>d)return null;let f=null,m=1/0;const p=new Set([c]),g=[c];for(;g.length;){const o=g.shift(),s=n[o],c=t[s],y=u(o),x=Math.max(0,y-a(c));x<=r&&(!f||x<f.distance||x===f.distance&&(y<m||y===m&&s<f.index))&&(f={index:s,point:c,distance:x},m=y);for(const t of h(o)){if(p.has(t))continue;p.add(t);const n=l(t);n&&th(e,i,n)<=d&&g.push(t)}}return f},cell:t=>{const e=r.get(t);return void 0===e?null:l(e)},neighbors:t=>{const e=r.get(t);return void 0===e?[]:h(e).map(t=>n[t]).sort((t,e)=>t-e)}}}const nh=["Circle","Rect"];function ih(t,e=nh){const n=Bc(t);return!!n&&e.includes(n)&&!t.owners?.length}function oh(t,e){return wc(t).filter(t=>"shape"===t.group&&void 0===t.pointIndex&&e(t.node)).map(t=>({x:t.center[0],y:t.center[1],r:Math.min(t.box.width,t.box.height)/2,item:t}))}function rh(t){const e=Number(t.schema.hoverDistance);if(!(e>0&&t._pointMark))return 0;const n="x"===t.schema.discrete||"y"===t.schema.discrete;return t.schema.tooltipShared&&n?0:e}function ah(t,e){const n=t._paintedScene;if(e.index&&e.index.scene===n)return e.index;const i=oh(n?.root.children??[],e=>!!t._pointMark?.(e)),o=new Map;for(const e of i){const n=Xl(t,[e.x,e.y])?.key??"";o.has(n)||o.set(n,[]),o.get(n).push(e)}const r={x:0,y:0,width:Number(t.schema.width)||0,height:Number(t.schema.height)||0},a=new Map([...o].map(([t,e])=>[t,eh(e,r)])),s=new Map(i.map(t=>[String(t.item.node.key),t.item]));return e.index={scene:n,panels:a,byKey:s},e.index}function sh(t,e){var n;if(!e||!rh(t)||!t._pointMark(e))return;const i=(n=t)._nearestHover??(n._nearestHover={key:null}),o=String(e.key).replace(/::hit$/,"");return ah(t,i).byKey.get(o)}function ch(t,e,n){var i;const o=rh(t);if(!o||!n)return e;if(e){const n=e.node;if(t._pointMark(n))return e;if(n.interactionGroup&&"axis"!==n.interactionGroup)return e;if("text"===n.type&&void 0!==n.datum)return e}const r=ah(t,(i=t)._nearestHover??(i._nearestHover={key:null})),a=t._facetPanels?.length?Xl(t,n):null;if(void 0===a)return e;const s=r.panels.get(a?.key??""),c=s?.nearest(n[0],n[1],o);if(!c)return e;const l=c.point.item.node;return{node:l,datum:l.datum,index:l.index}}function lh(t,e){var n;if(Vl(t))return;const i=e=>t._routeSceneEvent?.(e),o=(n=t)._nearestHover??(n._nearestHover={key:null}),r=e.nativeEvent?.type,a="mousemove"===r;if("mouseenter"===e.type||"mouseleave"===e.type){if(a)return;const n=e.nativeEvent?.relatedTarget;if("mouseleave"===e.type&&o.surface?.aroundScene(n??null)&&rh(t))return;return o.key="mouseenter"===e.type&&e.pick?String(e.pick.node.key):null,void i(e)}const s=ch(t,e.pick,e.point),c=s===e.pick?e:{...e,pick:s};if("click"===e.type&&!s&&e.point&&t._backgroundClick?.(e.point),"mousemove"===e.type&&a){const t=s?String(s.node.key):null;if(t!==o.key){const{point:n,nativeEvent:r}=e;null!==o.key&&i({type:"mouseleave",point:n,pick:null,nativeEvent:r}),o.key=t,s&&i({type:"mouseenter",point:n,pick:s,nativeEvent:r})}}i(c)}function hh(t){const e=(t._sceneRenderer?.elements?.()??[]).find(t=>"svg"===t.localName||"canvas"===t.localName)??t._select?.node?.();if(!e)return{left:0,top:0};const n="svg"===e.localName&&"function"==typeof e.getScreenCTM?e.getScreenCTM():null;if(n)return{left:n.e,top:n.f};const i=e.getBoundingClientRect();return{left:i.left,top:i.top}}function uh(t,e){const n=e.left+t.x,i=e.top+t.y,o={x:n,y:i,left:n,top:i,right:n+t.width,bottom:i+t.height,width:t.width,height:t.height};return{getBoundingClientRect:()=>o}}function dh(t,e){const n=sh(t,e);return n?uh(n.box,hh(t)):void 0}function fh(t,e,n,i){if(t&&this.schema.tooltip(t,e)){const e=cl.bind(this).toString(),o=Object.keys(this.schema.on).some(t=>["click","click.shape"].includes(t)&&this.schema.on[t]&&this.schema.on[t].toString()!==e),r=this.schema.on["click.shape"]&&this.schema.on["click.shape"].toString()===e,a=me(t),s=void 0===a?this._drawDepth<this.schema.groupBy.length-1:ye(this.schema.groupBy,pe(this.schema.groupBy,t,a),this._filteredData??[]);if(this._select.style("cursor",o||r&&s?"pointer":"auto"),this._sharedHoverActive)return;const c=dh(this,this._lastScenePick?.node)??(i.touches?[i.touches[0].clientX,i.touches[0].clientY]:[i.clientX,i.clientY]);let l=n||t;for(;l&&l.__d3plus__&&l.data;)l=l.data;this._tooltipClass.data([l]).footer(!(!r||!s)&&this.schema.translate("Click to Expand")).title((t,e)=>this._drawLabel(t,e)).titleSwatch(!0).position(c).config(Qt.bind(this)(this.schema.tooltipConfig)),Cl(this._tooltipClass,this,l),jl(this._tooltipClass,Hl(this,this._lastScenePick)).render()}}function mh(){return"undefined"==typeof window||window.innerWidth>600}class ph{get(t){if(!this._map.has(t))return;const e=this._map.get(t);return this._map.delete(t),this._map.set(t,e),e}set(t,e){this._map.delete(t),this._map.size>=this._cap&&this._map.delete(this._map.keys().next().value),this._map.set(t,e)}constructor(t){this._cap=t,this._map=new Map}}const gh={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`400 12px/1 ${s.fontFamilyStringify(s.fontFamily)}`,gap:"4px",height:"20px","justify-content":"center",margin:0,padding:"0 6px",width:"auto"};function yh(t){t.schema.on={"click.shape":cl.bind(t),"click.legend":ll.bind(t),mouseenter:hl.bind(t),mouseleave:dl.bind(t),"mousemove.shape":fh.bind(t),"mousemove.legend":Il.bind(t)},t._queue=[];const e=e=>{const{width:n,height:i}=e[0].contentRect;(n!==t.schema.width&&t._autoWidth||i!==t.schema.height&&t._autoHeight)&&n&&i&&(t._setSVGSize(n,i),t._callback||t.render())},n=function(t,e){let n;return function(...i){const o=this;clearTimeout(n),n=setTimeout(()=>t.apply(o,i),e)}}(e,t.schema.detectResizeDelay);t._resizeObserver="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(i=>{const{width:o,height:r}=i[0].contentRect;if(t._resizeSettled)n(i);else{if(!o||!r)return;t._resizeSettled=!0,e(i)}}),t.schema.scrollContainer="undefined"==typeof window?"":window}const xh="rgba(255, 255, 255, 0.7)",bh={"border-radius":"3px 0 0 0",display:"flex","align-items":"center",gap:"4px",font:`400 10px/1.4 ${s.fontFamilyStringify(s.fontFamily)}`,background:xh,color:e.colorContrast(xh)},_h={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},kh={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},vh=!1,wh={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},Mh={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Sh=!1;const Ch={background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)","border-radius":"2px","box-sizing":"border-box"},$h={background:"rgba(0, 0, 0, 0.15)",border:"1px solid rgba(0, 0, 0, 0.5)","border-radius":"2px",cursor:"grab"},Ah={background:"rgba(0, 0, 0, 0.25)",cursor:"grabbing"},zh={bottom:"2px",right:"3px",color:"rgba(0, 0, 0, 0.75)",font:`400 9px/1 ${s.fontFamilyStringify(s.fontFamily)}`,"pointer-events":"none"};const Dh={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},Lh={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Fh=!1;const Nh={"align-items":"center","box-sizing":"border-box",display:"inline-flex",font:`900 15px/1 ${s.fontFamilyStringify(s.fontFamily)}`,height:"20px","justify-content":"center",margin:0,padding:0,width:"20px"},Bh={"background-color":"AccentColor","border-color":"AccentColor",color:"AccentColorText"},Eh=!1,Rh={background:"Canvas",border:"1px solid rgba(128, 128, 128, 0.5)","border-radius":"3px","box-shadow":"0 2px 6px rgba(0, 0, 0, 0.2)",color:"CanvasText","margin-top":"4px",padding:"2px 0"},Ph={background:"none",border:"none",color:"inherit",font:`12px/1.2 ${s.fontFamilyStringify(s.fontFamily)}`,margin:0,padding:"4px 10px"},Th={background:"rgba(128, 128, 128, 0.2)"};function Oh(t){t.schema.aggs={},xt(t,el),function(t){t._renderer="svg",t.schema.ariaHidden=!0,t.schema.attribution=!1,t.schema.attributionIcon=void 0,t.schema.attributionStyle=bh,t.schema.cache=!0,t.schema.theme="auto"}(t),function(t){t.schema.color=(e,n)=>t.schema.groupBy[0](e,n);const n=c.scaleOrdinal().range(e.colorDefaults.scale.range());t.schema.colorDefaults={...e.colorDefaults,scale:n},t._autoColorScale=n,t._colorScaleClass=new dr,t.schema.colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},t.schema.colorScalePadding=mh,t.schema.colorScalePosition=H("auto"),t.schema.colorScaleMaxSize=600}(t),function(t){t._data=[],t.schema.dataCutoff=100,t.schema.dataPollingInterval=!1,t.schema.detectResize=!0,t.schema.detectResizeDelay=400,t.schema.detectVisible=!0,t.schema.detectVisibleInterval=1e3,t.schema.detectVisibleUnload=!0,t.schema.duration=600,t.schema.reducedMotion="auto",t.schema.fontFamily=s.fontFamily,t._hidden=[],t.schema.hiddenColor=()=>J(t._theme,t=>t.hidden,"#aaa"),t.schema.hiddenOpacity=H(.5),t._history=[],t.schema.groupBy=[I("id")],t.schema.facetConfig={}}(t),function(t){t.schema.legend=(e,n)=>{if(t._alongLegendHide)return!1;if(t._legendCategories)return n.length>1;const i=h.max(n,(e,n)=>{if(e._isAggregation)return 1;const i=t.schema.groupBy[t._legendDepth].bind(t)(e,n);return i instanceof Array?i.length:1});return n.length>1&&(i??0)<=2},t._defaultLegend=t.schema.legend,t._legendClass=new To,t.schema.legendConfig={label:ol.bind(t),shapeConfig:{ariaLabel:ol.bind(t),labelConfig:{fontColor:()=>Ws(t),fontResize:!1,padding:0}}},t.schema.legendFilterInvert=H(!1),t.schema.legendPadding=mh,t.schema.legendPosition=H("auto");const e=e=>il(t,e)??t._drawLabel(e);t.schema.legendSort=(t,n)=>e(t).localeCompare(e(n)),t.schema.legendTooltip={},t._sizeLegendClass=new _r,Object.assign(t.schema,{sizeLegend:fr,sizeLegendConfig:{},sizeLegendPosition:"right"})}(t),function(t){t.schema.loadingHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${t.schema.translate("Loading Visualization")}</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${t.schema.translate("Powered by D3plus")}</a></sub>\n </div>`,t.schema.loadingMessage=!0,t._lrucache=new ph(10),t._messageClass=new kr,t.schema.messageMask="rgba(0, 0, 0, 0.05)",t.schema.messageStyle={bottom:"0",left:"0",position:"absolute",right:"0","text-align":"center",top:"0"},t.schema.noDataHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${t.schema.translate("No Data Available")}</strong>\n </div>`,t.schema.noDataMessage=!0}(t),yh(t),function(t){t.schema.shape=H("Rect"),t.schema.shapeConfig={ariaLabel:(e,n)=>t._drawLabel(e,n),fill:(n,o)=>{for(;n.__d3plus__&&n.data;)o=(n=n.data).i;if(t.schema.colorScale){const e=t.schema.colorScale(n,o);if(null!=e)return As(t,e)}const r=t.schema.color(n,o);if(i.color(r))return r;const a="string"==typeof r?r:JSON.stringify(r);return t.schema.colorOrdinal&&t._ordinalColorScale?t._ordinalColorScale(a):e.colorAssign(a,Re(t))},labelConfig:{fontColor:ic((n,i)=>{const o="function"==typeof t.schema.shapeConfig.fill?t.schema.shapeConfig.fill(n,i):t.schema.shapeConfig.fill;return e.colorContrast(o,t.schema.colorDefaults)})},opacity:H(1),stroke:(e,n)=>{const o="function"==typeof t.schema.shapeConfig.fill?t.schema.shapeConfig.fill(e,n):t.schema.shapeConfig.fill,r=i.color(o);return r?r.darker(.25).toString():o},role:"presentation",strokeWidth:H(0)},t._solo=[]}(t),function(t){t._subtitleClass=new Ir,t.schema.subtitleConfig={ariaHidden:!0,fontColor:()=>Ws(t),fontSize:12,padding:5,textAnchor:"middle"},t.schema.subtitlePadding=mh,t.schema.svgDesc="",t.schema.svgTitle="",t.schema.timeline=!0,t._timelineClass=(new oa).align("end"),t.schema.timelineConfig={padding:5},t.schema.timelinePadding=mh,t.schema.threshold=H(1e-4),t.schema.thresholdKey=void 0,t.schema.thresholdName=()=>t.schema.translate("Values"),t._titleClass=new Ir,t.schema.titleConfig={ariaHidden:!0,fontColor:()=>Ws(t),fontSize:16,padding:5,textAnchor:"middle"},t.schema.titlePadding=mh,t.schema.tooltip=H(!0),t._tooltipClass=new ma,t.schema.tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},t._totalClass=new Ir,t.schema.totalConfig={fontColor:()=>Ws(t),fontSize:10,padding:5,textAnchor:"middle"},t.schema.totalFormat=e=>`${t.schema.translate("Total")}: ${d.formatAbbreviate(e,t.schema.locale)}`,t.schema.totalPadding=mh}(t),function(t){t.schema.zoom=!0,t._zoomBehavior=_.zoom(),t._zoomBrush=p.brush(),t.schema.zoomBrushHandleSize=1,t.schema.zoomBrushHandleStyle={fill:"#444"},t.schema.zoomBrushSelectionStyle={fill:"#777","stroke-width":0},t.schema.zoomControlClassName=void 0,t.schema.zoomControlIcons=void 0,t.schema.zoomControlStyle=_h,t.schema.zoomControlStyleActive=kh,t.schema.zoomControlStyleHover=vh,t.schema.zoomFactor=2,t.schema.zoomMax=void 0,t.schema.zoomPadding=20,t.schema.zoomPan=!0,t.schema.zoomScroll="modifier"}(t),function(t){t.schema.tableView=!0,t.schema.tableViewClassName=void 0,t.schema.tableViewControlClassName=void 0,t.schema.tableViewControlStyle=wh,t.schema.tableViewControlStyleActive=Mh,t.schema.tableViewControlStyleHover=Sh,t.schema.tableViewDownload=!0,t.schema.tableViewPageSize=50,t.schema.tableViewSort=!0}(t),function(t){t.schema.minimap=!0,t.schema.minimapClassName=void 0,t.schema.minimapStyle=Ch,t.schema.minimapViewportStyle=$h,t.schema.minimapViewportStyleActive=Ah,t.schema.minimapLabelStyle=zh}(t),function(t){t.schema.backControlClassName=void 0,t.schema.backControlStyle=gh}(t),function(t){t.schema.search=!0,t.schema.searchAccessor=(e,n)=>t._drawLabel(e,n),t.schema.searchControlClassName=void 0,t.schema.searchControlStyle=Dh,t.schema.searchControlStyleActive=Lh,t.schema.searchControlStyleHover=Fh}(t),function(t){t.schema.saveControl=!0,t.schema.saveControlClassName=void 0,t.schema.saveControlConfig={},t.schema.saveControlMenuClassName=void 0,t.schema.saveControlMenuItemStyle=Ph,t.schema.saveControlMenuItemStyleHover=Th,t.schema.saveControlMenuStyle=Rh,t.schema.saveControlStyle=Nh,t.schema.saveControlStyleActive=Bh,t.schema.saveControlStyleHover=Eh}(t)}const Wh=t=>t.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Hh={AccentColor:"Highlight",AccentColorText:"HighlightText"};function jh(t,e,n){const i=Wh(e);t.style.setProperty(i,n);const o=Hh[n];o&&!t.style.getPropertyValue(i)&&t.style.setProperty(i,o)}function Ih(t,e,n){return n&&t===e?{}:t||{}}function Gh(t,e,n,i){const{base:o,active:r={},hover:a={}}=e;for(const e of new Set([...Object.keys(o),...Object.keys(r),...Object.keys(a)]))t.style.removeProperty(Wh(e));for(const e of[o,n?a:{},i?r:{}])for(const n in e){const i=e[n];null!=i&&!1!==i&&jh(t,n,String(i))}}function qh(t,e,n){const i=Boolean(t[`${e}ClassName`]),o=(n,o)=>Ih(t[`${e}Style${n}`],o,i);return{base:o("",n.base),active:o("Active",n.active),hover:o("Hover",n.hover)}}function Vh(t){return String(t??"").replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[t]))}function Yh(t){return Boolean(t._brushing)}function Kh(t){return qh(t.schema,"zoomControl",{base:_h,active:kh,hover:vh})}function Uh(t,e,n=!1){Gh(e,Kh(t),n,e.classList.contains("active"))}const Xh='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',Zh=`<svg ${Xh}><line x1="12" y1="4" x2="12" y2="20"/><line x1="4" y1="12" x2="20" y2="12"/></svg>`,Qh=`<svg ${Xh}><line x1="4" y1="12" x2="20" y2="12"/></svg>`,Jh=`<svg ${Xh}><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>`,tu=`<svg ${Xh} stroke-dasharray="4 3"><rect x="4" y="4" width="16" height="16" rx="1"/></svg>`;function eu(t,e,n){const i=t.schema.zoomControlIcons?.[e];return"string"==typeof i?i:"function"==typeof i?(t=>`<span class="zoom-control-icon" data-icon="${t}" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>`)(e):n}const nu={zoomIn:"zoom-in",zoomOut:"zoom-out",zoomReset:"zoom-reset",zoomBrush:"zoom-brush"},iu={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"4px",boxSizing:"border-box",paddingTop:"4px",paddingRight:"4px"};function ou(t){const e=t.schema.zoomControlClassName?` ${t.schema.zoomControlClassName}`:"",n=(n,i,o,r)=>`<button type="button" class="zoom-control ${n}${r?" active":""}${e}" aria-label="${t.schema.translate(i)}"${void 0===r?"":` aria-pressed="${r}"`}>${o}</button>`;return n("zoom-in","Zoom In",eu(t,"zoomIn",Zh))+n("zoom-out","Zoom Out",eu(t,"zoomOut",Qh))+n("zoom-reset","Reset Zoom",eu(t,"zoomReset",Jh))+n("zoom-brush","Brush Zoom",eu(t,"zoomBrush",tu),Yh(t))}function ru(t){let e=t._select&&t._select.node()?t._select.node().parentNode:null;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e instanceof HTMLElement?e:null}function au(t){return Boolean(t.schema.zoom)&&!t._ssr}const su={width:96,height:24};function cu(t){if(!au(t))return null;const e=ou(t),{base:n}=Kh(t),i=`${e}|${JSON.stringify(n)}`,o=t._zoomControlsBox;if(o&&o.signature===i)return o;let r=su;const a=ru(t);if(a){const n=document.createElement("div");n.className="d3plus-zoom-control";for(const t in iu)n.style.setProperty(Wh(t),iu[t]);n.style.setProperty("display","inline-flex"),n.style.setProperty("position","absolute"),n.style.setProperty("visibility","hidden"),n.style.setProperty("pointer-events","none"),n.innerHTML=e,n.querySelectorAll(".zoom-control").forEach(e=>Uh(t,e)),a.appendChild(n);const i=n.getBoundingClientRect();a.removeChild(n),i.width&&i.height&&(r={width:Math.ceil(i.width),height:Math.ceil(i.height)})}return t._zoomControlsBox={...r,signature:i},t._zoomControlsBox}function lu(t){const e=cu(t);return e&&e.height?e.height+4:0}function hu(t){return{width:t.reduce((t,e,n)=>t+e.width+(n?6:0),0),height:Math.max(0,...t.map(t=>t.height))}}function uu(t){const e=t._bottomRightBox;return e&&e.width&&e.height?e:null}function du(t){const e=uu(t);return e&&!e.inset?e:null}function fu(t,e,n){const i=du(t);if(!i||"right"===i.side||e>=i.bottom+i.height)return 0;const o=i.width-n;return o>0?o+6:0}function mu(t,e){const n=du(t);return n?Math.max(0,n.bottom+n.height-e):0}function pu(t,e,n,i){return{inset:"bottom"===e?fu(t,n,i):0,drop:"left"===e||"right"===e?mu(t,n):0}}function gu(t,e){const n=du(t);return n&&"bottom"===n.side?Math.max(0,n.bottom+n.height-e):0}function yu(t,e){const n=du(t);return n&&"right"===n.side?Math.max(0,n.width+6-e):0}function xu(t,e){const n=t._zoomTransform?.scale??1;if(e.inset)return function(t,e,n){const i=qs(t,"sizeLegend");if(!i)return null;const{margin:o}=Is(t),r=e.items.map(t=>({item:t,paint:t.paint(n)})).filter(t=>Boolean(t.paint));if(!r.length)return null;const a=r.reduce((t,e,n)=>t+e.paint.width+(n?6:0),0)+2*o,s=Math.max(...r.map(t=>t.paint.height))+2*o,c="left"===i.alignX?i.x:"center"===i.alignX?i.x+(i.width-a)/2:i.x+i.width-a,l="top"===i.alignY?i.y:"middle"===i.alignY?i.y+(i.height-s)/2:i.y+i.height-s,h=[Ks(t,{...i,x:c,y:l,width:a,height:s})];let u=c+a-o;const d=l+s-o;for(const{item:t,paint:e}of r)h.push({type:"group",key:t.key,transform:{x:u-e.width,y:d-e.height},children:[e.node]}),u-=e.width+6;return{type:"group",key:"viz-bottomRight",children:h}}(t,e,n);const i=[];let o=t.schema.width;const r=t.schema.height-e.bottom;return e.items.forEach(t=>{const e=t.paint(n);e&&i.push({type:"group",key:t.key,transform:{x:o-e.width,y:r-e.height},children:[e.node]}),o-=t.width+6}),i.length?{type:"group",key:"viz-bottomRight",children:i}:null}const bu=new WeakMap;function _u(t){bu.delete(t)}function ku(t){return{type:"htmlOverlay",key:"viz-zoom-controls",x:0,y:0,width:t.schema.width,style:iu,className:"d3plus-zoom-control",html:ou(t),events:{".zoom-in":{click:()=>Fu.bind(t)(t.schema.zoomFactor)},".zoom-out":{click:()=>Fu.bind(t)(1/t.schema.zoomFactor)},".zoom-reset":{click:()=>Fu.bind(t)(0)},".zoom-brush":{click:e=>{const n=e.target.closest(".zoom-brush");if(!n)return;const i=!Yh(t);n.classList.toggle("active",i),n.setAttribute("aria-pressed",String(i)),Uh(t,n,n.matches(":hover")),$u.bind(t)(i)}}},onUpdate:e=>{e.querySelectorAll(".zoom-control").forEach(e=>{e.dataset.zoomBound||(e.dataset.zoomBound="1",Uh(t,e),e.addEventListener("mouseenter",()=>Uh(t,e,!0)),e.addEventListener("mouseleave",()=>Uh(t,e)),function(t,e){var n;const i=t.schema.zoomControlIcons;if(!i)return;const o=Object.keys(nu).find(t=>e.classList.contains(nu[t])),r=o&&i[o];if(!o||"function"!=typeof r)return;const a=e.querySelector(".zoom-control-icon");if(!a)return;const s=(n=t)._zoomIconCleanup||(n._zoomIconCleanup={});s[o]?.(),s[o]=r(a)||void 0}(t,e))})}}}const vu={name:"zoom",layout:({viz:t})=>{if(t.schema.zoom?function(t){if(!t._select)return;if(!t._ssr&&(!t._container||t._container.classed("d3plus-zoom"))){const{width:e,height:n}=kt(t);tc(t,{kind:"generic",width:e,height:n,duration:Zt(t)})}"canvas"!==t._renderer&&Mu(t,t._select)}(t):function(t){t._zoomTransform=void 0,_u(t);const e=t._zoomEventTarget||t._container;e&&e.node()&&e.property("__zoom",_.zoomIdentity)}(t),!t._container||!t._zoomGroup)return{panel:null,margin:{}};const e=kt(t),n=t._zoomHeight||e.height,i=t._zoomWidth||e.width,{left:o,top:r}=t._margin,a=[[o,r],[o+i,r+n]];t._zoomBehavior.filter(e=>function(t,e){const n="modifier"===t.schema.zoomScroll;return"wheel"===e.type?!n||e.ctrlKey||e.metaKey:!function(t){const e=t.target;return Boolean(e&&"function"==typeof e.closest&&e.closest("g.d3plus-viz-timeline, g.d3plus-zoom-brush"))}(e)&&("touchstart"===e.type&&n?(e.touches?.length??0)>1||Au(t):!e.ctrlKey&&!e.button)}(t,e)).wheelDelta(zu).extent(a).scaleExtent([1,wu(t,i,n)]).translateExtent(a).on("start",e=>{Yl(t,e),t._zoomGesture?.start(e)}).on("zoom",e=>{Kl(t,e),t._zoomGesture?.zoom(e)||function(t,e){const n=e;if(!n||"object"!=typeof n||"number"!=typeof n.k)return!1;const i=bu.get(t)??{k:1,x:0,y:0};return n.k===i.k&&(n.x??0)===i.x&&(n.y??0)===i.y}(t,e.transform)||Lu.bind(t)(e.transform)}).on("end",e=>{t._zoomGesture?.end(e),Ul(t)}),t._zoomToBounds=Bu.bind(t);const s=au(t)?ku(t):null;t._zoomBrush.extent([[0,0],[i,n]]).filter(t=>!t.button&&t.detail<2).handleSize(t.schema.zoomBrushHandleSize).on("start",Pu.bind(t)).on("brush",Eu.bind(t)).on("end",Ru.bind(t));const c=t._select.selectAll(":scope > g.d3plus-zoom-brush").data([0]);return t._brushGroup=c.enter().append("g").attr("class","d3plus-zoom-brush").merge(c).attr("transform",`translate(${o}, ${r})`).call(t._zoomBrush),$u.bind(t)(Yh(t)),t._renderTiles&&t._renderTiles(Cu(t),0),{panel:s,margin:{}}}};function wu(t,e,n){return"number"==typeof t.schema.zoomMax?t.schema.zoomMax:function(t,e,n,i,o=1){const r=Math.max(1,e-2*i),a=Math.max(1,n-2*i);let s=1;for(const e of t){if(void 0===e.datum||"group"===e.type||"text"===e.type)continue;if(String(e.key).endsWith("::hit"))continue;const t=o*(e.transform?.scale??1);for(const[n,i]of ec(e)){const e=Math.min(n>0?r/(n*t):1/0,i>0?a/(i*t):1/0);Number.isFinite(e)&&e>s&&(s=e)}}return s}(t._zoomShapes||t._chartScene||[],e,n,t.schema.zoomPadding,t._chartTransform?.scale??1)}function Mu(t,e){const n=t._zoomEventTarget;n&&n.node()===e.node()||(n&&n.on(".zoom",null),t._container&&t._container.on(".zoom",null),t._zoomEventTarget=e)}function Su(t){const e="canvas"===t._renderer,n=Yh(t);t._select&&t._select.style("pointer-events",e||n?"none":null),t._container&&t._container.style("pointer-events",e?"none":null),t._brushGroup&&t._brushGroup.style("pointer-events",n?"all":null)}function Cu(t){const e=_.zoomTransform((t._zoomEventTarget||t._container).node()),{left:n,top:i}=t._margin;return _.zoomIdentity.translate(e.x+(e.k-1)*n,e.y+(e.k-1)*i).scale(e.k)}function $u(t=!1){!function(t,e){t._brushing=e}(this,t),t?this._brushGroup.style("display","inline"):this._brushGroup.style("display","none"),Su(this);const e=this._zoomEventTarget||this._container;!t&&this.schema.zoom?(e.call(this._zoomBehavior),this.schema.zoomScroll||e.on("wheel.zoom",null),Du(this),this.schema.zoomPan||e.on("mousedown.zoom mousemove.zoom",null).on("touchstart.zoom touchmove.zoom touchend.zoom touchcancel.zoom",null)):e.on(".zoom",null)}function Au(t){const e=t._zoomEventTarget||t._container;return Boolean(e&&e.node()&&_.zoomTransform(e.node()).k>1)}function zu(t){const e=t.ctrlKey&&0===t.deltaMode&&Math.abs(t.deltaY)<50;return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(e?10:1)}function Du(t){const e=t._zoomEventTarget||t._container;if(!e)return;const n="modifier"===t.schema.zoomScroll&&t.schema.zoomPan;e.style("touch-action",n?Au(t)?"none":"pan-x pan-y":null)}function Lu(t=!1,e=0){Xt(this)&&(e=0),this._zoomGroup&&(e?this._zoomGroup.transition().duration(e).attr("transform",t):this._zoomGroup.attr("transform",t));const n=t;if(n&&"object"==typeof n&&"k"in n){const t={k:n.k??1,x:n.x??0,y:n.y??0};!function(t,e){bu.set(t,{k:e.k,x:e.x,y:e.y})}(this,t),this._zoomRescale&&this._zoomRescale(t,e)?this._zoomTransform=void 0:this._zoomTransform={x:t.x,y:t.y,scale:t.k}}else!1===n&&(this._zoomTransform=void 0,_u(this));!function(t){const e=uu(t);if(!e||!t._featurePanels)return;const n=t._featurePanels.filter(t=>"viz-bottomRight"!==t.key),i=xu(t,e);t._featurePanels=i?[...n,i]:n}(this),this._drawSceneToTarget&&this._sceneRenderer&&this._drawSceneToTarget(e),Du(this),this._renderTiles&&this._renderTiles(Cu(this),e)}function Fu(t=0){if(!this._container)return;const[[e,n],[i,o]]=this._zoomBehavior.extent().bind(document)(),r=(e+i)/2,a=(n+o)/2,s=_.zoomTransform((this._zoomEventTarget||this._container).node());if(!t)return this._zoomGesture?.reset(),Nu(this,1,0,0);const c=s.k*t;Nu(this,c,r-(r-s.x)/s.k*c,a-(a-s.y)/s.k*c)}function Nu(t,e,n,i,o=Zt(t)){const[r,a]=t._zoomBehavior.scaleExtent(),[[s,c],[l,h]]=t._zoomBehavior.translateExtent(),u=Math.max(r,Math.min(a,e)),d=Math.max(l*(1-u),Math.min(s*(1-u),n)),f=Math.max(h*(1-u),Math.min(c*(1-u),i)),m=_.zoomIdentity.translate(d,f).scale(u);(t._zoomEventTarget||t._container).property("__zoom",m),Lu.bind(t)(m,o)}function Bu(t,e=Zt(this)){if(!t)return Nu(this,1,0,0,e);const[[n,i],[o,r]]=this._zoomBehavior.translateExtent(),a=this.schema.zoomPadding,s=_.zoomTransform((this._zoomEventTarget||this._container).node()),c=(t[0][0]-s.x)/s.k,l=(t[0][1]-s.y)/s.k,h=(t[1][0]-s.x)/s.k,u=(t[1][1]-s.y)/s.k,d=Math.min((o-n-2*a)/(h-c),(r-i-2*a)/(u-l));Nu(this,d,(n+o)/2-d*(c+h)/2,(i+r)/2-d*(l+u)/2,e)}function Eu(){Tu.bind(this)()}function Ru(t){if(!t.selection)return;this._brushGroup.call(this._zoomBrush.move,null),$u.bind(this)(!1),function(t){const e=ru(t)?.querySelector(".d3plus-zoom-control .zoom-brush");if(!e)return;const n=Yh(t);e.classList.toggle("active",n),e.setAttribute("aria-pressed",String(n)),Uh(t,e,e.matches(":hover"))}(this);const{left:e,top:n}=this._margin;Bu.bind(this)(t.selection.map(([t,i])=>[t+e,i+n]))}function Pu(){Tu.bind(this)()}function Tu(){this._brushGroup.selectAll(".selection").call(r.attrize,this.schema.zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(r.attrize,this.schema.zoomBrushHandleStyle||{})}function Ou(t){const e=Boolean(t.schema.backControlClassName);return Ih(t.schema.backControlStyle,gh,e)}const Wu=`<svg ${Xh}><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>`;function Hu(t){const e=t._history.pop();e&&xe(e)?(Me(t,e),qe(t),t.render()):e?(void 0!==e.groupId&&void 0!==e.groupDepth&&(t._pendingExitReunion={groupId:e.groupId,groupDepth:e.groupDepth,body:t._bodyRect}),e.legend&&Me(t,e.legend),t.config({depth:e.depth,filter:e.filter}).render()):t.depth(t._drawDepth-1).filter(!1).render()}function ju(t){const e=t.schema.backControlClassName?` ${t.schema.backControlClassName}`:"",n=t.schema.translate("Back");return`<button type="button" class="back-control${e}">${Wu}${n}</button>`}function Iu(t){return function(t){return Boolean(t._history&&t._history.length)&&!t._ssr}(t)?{key:"back",html:ju(t),styleSignature:JSON.stringify(Ou(t)),events:{".back-control":{click:()=>Hu(t)}},onUpdate:e=>{const n=e.querySelector(".back-control");n&&!n.dataset.backBound&&(n.dataset.backBound="1",function(t,e){Gh(e,{base:Ou(t)},!1,!1)}(t,n))}}:null}function Gu(t){return Boolean(t._tableView)}function qu(t){return t._tableViewPage||0}function Vu(t,e){t._tableViewPage=e}function Yu(t){return t._tableViewSort}function Ku(t){return"raw"===t._tableViewDataSource?"raw":"aggregate"}function Uu(t){if(t._tableData?.())return!1;const e=t._data,n=t._filteredData||e;return!(!e||!n||e===n)&&e.length!==n.length}function Xu(t){return qh(t.schema,"tableViewControl",{base:wh,active:Mh,hover:Sh})}function Zu(t,e,n=!1){Gh(e,Xu(t),n,e.classList.contains("active"))}function Qu(t){return JSON.stringify(Xu(t))}const Ju='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:12px;height:12px;vertical-align:middle;flex-shrink:0"',td=`<svg ${Ju}><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="12" y1="3" x2="12" y2="21"/></svg>`,ed=`<svg ${Ju}><path d="M12 3v12"/><polyline points="7 11 12 16 17 11"/><path d="M4 18v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"/></svg>`,nd=`<svg ${Ju}><polyline points="14 4 19 9 14 14"/><line x1="4" y1="9" x2="19" y2="9"/><polyline points="10 20 5 15 10 10"/><line x1="20" y1="15" x2="5" y2="15"/></svg>`,id='viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:11px;height:11px;vertical-align:middle;margin-left:4px;flex-shrink:0"',od=`<svg ${id}><polyline points="6 15 12 9 18 15"/></svg>`,rd=`<svg ${id}><polyline points="6 9 12 15 18 9"/></svg>`;function ad(t){const e=Gu(t);return`<button type="button" class="table-view-control table-view-toggle${e?" active":""}${t.schema.tableViewControlClassName?` ${t.schema.tableViewControlClassName}`:""}" aria-label="${t.schema.translate(e?"Show Chart":"Show Data Table")}" aria-pressed="${e}">${td}</button>`}function sd(t){const e=function(t){return null==t?"":t instanceof Date?t.toISOString():String(t)}(t);return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function cd(t,e,n){const i=t.schema.groupBy;return i&&i.length?i.map(t=>String(t(e,n))).join("\0"):""}function ld(t,e){const n=t._data;if(!n||!n.length)return e;const{exact:i,group:o}=function(t){const e=t._data||[],n=t._tableViewGroupOrder;if(n&&n.data===e)return n;const i=new Map,o=new Map;e.forEach((e,n)=>{const r=JSON.stringify(e);i.has(r)||i.set(r,n);const a=cd(t,e,n);o.has(a)||o.set(a,n)});const r={data:e,exact:i,group:o};return t._tableViewGroupOrder=r,r}(t);return e.map((e,n)=>({row:e,order:i.get(JSON.stringify(e))??o.get(cd(t,e,n))??Number.MAX_SAFE_INTEGER})).sort((t,e)=>t.order-e.order).map(t=>t.row)}function hd(t){const e=t._tableData?.(),n=!e&&"raw"===Ku(t)&&Uu(t);let i=((e??(n?t._data:t._filteredData||t._data))||[]).slice();const o=function(t){const e=[],n=new Set;for(const i of t)for(const t of Object.keys(i))n.has(t)||kl(t)||(n.add(t),e.push(t));return e}(i),r=Yu(t);if(r&&o.includes(r.column)){const e="desc"===r.direction?-1:1,{column:n}=r;i.sort((i,o)=>e*function(t,e,n){const i=null==t,o=null==e;return i||o?i&&o?0:i?1:-1:"number"==typeof t&&"number"==typeof e?t-e:t instanceof Date&&e instanceof Date?t.getTime()-e.getTime():String(t).localeCompare(String(e),n,{numeric:!0})}(i[n],o[n],t.schema.locale))}else n||e||(i=ld(t,i));return{rows:i,columns:o}}function ud(t,e){const n=e.length,i=t.schema.tableViewPageSize,o="number"==typeof i&&i>0?i:n||1,r=Math.max(1,Math.ceil(n/o)),a=Math.min(Math.max(0,qu(t)),r-1);Vu(t,a);const s=a*o,c=Math.min(s+o,n);return{slice:e.slice(s,c),page:a,totalPages:r,start:s,end:c,total:n}}const dd=t=>(t._theme??Y).table,fd=t=>`position:sticky;top:0;background:${dd(t).header};text-align:left;padding:6px 10px;border-bottom:2px solid ${dd(t).border};white-space:nowrap;`;function md(t,e,n){return e.map(e=>`<td style="padding:6px 10px;border-bottom:1px solid ${dd(t).rule};"><div class="d3plus-table-view-cell" style="max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${Vh(function(t,e){return null==t?"":t instanceof Date?t.toLocaleDateString(e):"number"==typeof t?t.toLocaleString(e):String(t)}(n[e],t.schema.locale))}</div></td>`).join("")}function pd(t,e){return t?`<tr aria-hidden="true" style="height:${t}px;padding:0;border:0;"><td style="padding:0;border:0;" colspan="${e}"></td></tr>`:""}function gd(t,e,n,i,o,r){const a=Math.max(e.length,1);return pd(30*i,a)+n.slice(i,o).map(n=>function(t,e,n){return`<tr style="height:30px;">${md(t,e,n)}</tr>`}(t,e,n)).join("")+pd(30*(r-o),a)}function yd(t){const e=Yu(t),{rows:n,columns:i}=hd(t),{slice:o,page:r,totalPages:a,start:c,end:l,total:h}=ud(t,n),u=o.length,d=u>300,f=h?gd(t,i,o,0,d?Math.min(u,60):u,u):`<tr><td style="padding:12px;color:${(t._theme??Y).textMuted};" colspan="${Math.max(i.length,1)}">${t.schema.translate("No Data Available")}</td></tr>`,m=i.map(n=>function(t,e,n){const i=Vh(e);if(!function(t){return!1!==t.schema.tableViewSort}(t))return`<th style="${fd(t)}">${i}</th>`;const o=n?.column===e,r=o?"desc"===n.direction?"descending":"ascending":"none",a=o?"desc"===n.direction?rd:od:"";return`<th class="tableview-sort-header" data-column="${Vh(e)}" role="button" tabindex="0" aria-sort="${r}" style="${fd(t)}cursor:pointer;user-select:none;">${i}${a}</th>`}(t,n,e)).join(""),p=a>1?`<div class="d3plus-table-view-pagination" style="display:flex;align-items:center;gap:8px;padding:6px 10px;border-top:1px solid ${dd(t).rule};font-size:12px;flex:0 0 auto;">\n <button type="button" class="tableview-page-prev"${r<=0?" disabled":""}>‹ ${t.schema.translate("Previous")}</button>\n <span>${h?c+1:0}–${l} / ${h}</span>\n <button type="button" class="tableview-page-next"${r>=a-1?" disabled":""}>${t.schema.translate("Next")} ›</button>\n </div>`:"",g=t.schema.tableViewClassName?` ${t.schema.tableViewClassName}`:"",y=ad(t)+(function(t){return!1!==t.schema.tableViewDownload}(t)?function(t){const e=t.schema.translate("Download");return`<button type="button" class="table-view-control tableview-download-csv" aria-label="${e}" title="${e} CSV">${ed}</button>`}(t):"")+(Uu(t)?function(t){const e="raw"===Ku(t),n=t.schema.tableViewControlClassName?` ${t.schema.tableViewControlClassName}`:"",i=t.schema.translate(e?"Show Aggregate Data":"Show Raw Data");return`<button type="button" class="table-view-control tableview-source-toggle${e?" active":""}${n}" aria-label="${i}" title="${i}" aria-pressed="${e}">${nd}</button>`}(t):""),x=d?"table-layout:fixed;":"";return`\n <div class="d3plus-table-view-frame" style="display:flex;flex-direction:column;width:100%;height:100%;box-sizing:border-box;background:${dd(t).background};color:${dd(t).text};font:12px/1.4 ${s.fontFamilyStringify(t.schema.fontFamily||"sans-serif")};">\n <div class="d3plus-table-view-toolbar" style="flex:0 0 auto;display:flex;gap:4px;padding:4px;">${y}</div>\n <div class="d3plus-table-view-scroll"${d?' data-tableview-virtual="1"':""} style="flex:1 1 auto;min-height:0;overflow:auto;">\n <table class="d3plus-table-view-table${g}" style="border-collapse:collapse;width:100%;${x}">\n <thead><tr>${m}</tr></thead>\n <tbody>${f}</tbody>\n </table>\n </div>\n ${p}\n </div>`}function xd(t){const{rows:e,columns:n}=hd(t),i=function(t,e){const n=[t.map(sd).join(",")];for(const i of e)n.push(t.map(t=>sd(i[t])).join(","));return n.join("\r\n")}(n,e),o=new Blob([i],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(o),a=document.createElement("a");a.href=r,a.download="table-view.csv",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}function bd(t,e){t.querySelectorAll(".table-view-control").forEach(t=>{t.dataset.tableViewBound||(t.dataset.tableViewBound="1",Zu(e,t),t.addEventListener("mouseenter",()=>Zu(e,t,!0)),t.addEventListener("mouseleave",()=>Zu(e,t)))})}function _d(t,e){const n=t.querySelector(".d3plus-table-view-scroll[data-tableview-virtual]");if(!n||n.dataset.tableviewVirtualBound)return;const i=n.querySelector("tbody");if(!i)return;n.dataset.tableviewVirtualBound="1";const{rows:o,columns:r}=hd(e),{slice:a}=ud(e,o);let s=0;const c=()=>{s=0,function(t,e,n,i,o){const r=i.length,a=Math.max(1,Math.ceil(e.clientHeight/30)),s=Math.max(0,Math.floor(e.scrollTop/30)-10),c=Math.min(r,s+a+20);n.innerHTML=gd(t,o,i,s,c,r)}(e,n,i,a,r)};n.addEventListener("scroll",()=>{s||(s=requestAnimationFrame(c))},{passive:!0}),c()}const kd="viz-table-view-overlay";function vd(t){const e=t.target.closest(".tableview-sort-header");return e?.dataset.column}function wd(t){return{type:"htmlOverlay",key:kd,x:0,y:0,width:t.schema.width,height:t.schema.height,className:"d3plus-table-view",html:yd(t),events:{".table-view-toggle":{click:()=>Sd(t)},".tableview-page-prev":{click:()=>Cd(t,-1)},".tableview-page-next":{click:()=>Cd(t,1)},".tableview-download-csv":{click:()=>xd(t)},".tableview-source-toggle":{click:()=>function(t){(function(t,e){t._tableViewDataSource=e})(t,"raw"===Ku(t)?"aggregate":"raw"),Vu(t,0),Md(t)}(t)},".tableview-sort-header":{click:e=>{const n=vd(e);n&&$d(t,n)},keydown:e=>{const n=e.key;if("Enter"!==n&&" "!==n)return;const i=vd(e);i&&(e.preventDefault(),$d(t,i))}}},onUpdate:e=>function(t,e){bd(t,e),_d(t,e)}(e,t)}}function Md(t){const e=(t._featurePanels||[]).slice(),n=e.findIndex(t=>t.key===kd);if(Gu(t)){const i=wd(t);n>=0?e[n]=i:e.push(i)}else n>=0&&e.splice(n,1);t._featurePanels=e,function(t){const e=ru(t)?.querySelector(".d3plus-top-left-controls-item .table-view-toggle");if(!e)return;const n=Gu(t);e.classList.toggle("active",n),e.setAttribute("aria-pressed",String(n)),Zu(t,e,e.matches(":hover"))}(t),t._drawSceneToTarget&&t._sceneRenderer&&t._drawSceneToTarget(0)}function Sd(t){!function(t,e){t._tableView=e}(t,!Gu(t)),Vu(t,0),Md(t)}function Cd(t,e){Vu(t,Math.max(0,qu(t)+e)),Md(t)}function $d(t,e){const n=Yu(t);!function(t,e){t._tableViewSort=e}(t,{column:e,direction:n?.column===e&&"asc"===n.direction?"desc":"asc"}),Vu(t,0),Md(t)}const Ad={name:"tableView",layout:({viz:t})=>Gu(t)?{panel:wd(t),margin:{}}:{panel:null,margin:{}}};function zd(t){return function(t){return Boolean(t.schema.tableView)&&!t._ssr}(t)?{key:"table-view",html:ad(t),styleSignature:Qu(t),events:{".table-view-toggle":{click:()=>Sd(t)}},onUpdate:e=>bd(e,t)}:null}const Dd=["png","svg","jpg"];function Ld(t){if(!Array.isArray(t))return Dd.slice();const e=[];for(const n of t){const t=String(n).toLowerCase().replace("jpeg","jpg");Dd.includes(t)&&!e.includes(t)&&e.push(t)}return e}function Fd(t){return("string"==typeof t||"number"==typeof t?String(t).replace(/<[^>]*>/g,"").replace(/[\\/:*?"<>|\p{Cc}]/gu,"").replace(/\s+/g," ").trim().slice(0,100).trim():"")||"download"}function Nd(t){return Os({_select:t._select})}function Bd(t){const e=t.schema.title;return"function"==typeof e?e(t._filteredData||[]):void 0}function Ed(t){const{filename:e,formats:n,background:i,callback:o,...r}=t.schema.saveControlConfig||{};return{filename:"string"==typeof e&&e.trim()?Fd(e):Fd(Bd(t)),formats:Ld(n),background:!1!==i&&("string"==typeof i&&i?i:Nd(t)),callback:"function"==typeof o?o:void 0,renderOptions:r}}function Rd(t){const e="canvas"===t._renderer?t.toCanvas():t._select?.node?.(),n="canvas"===t._renderer?"canvas":"svg";return e?.localName===n?e:null}const Pd=["position","top","left","content-visibility","touch-action"];function Td(t,e){let n=null;if("canvas"===t._renderer){const e=t.toSVGString();if(e){const t=(new DOMParser).parseFromString(e,"image/svg+xml");n=t.querySelector("parsererror")?null:t.documentElement}}else{const e=Rd(t);n=e?e.cloneNode(!0):null,n&&function(t){t.removeAttribute("aria-hidden");for(const e of Pd)t.style?.removeProperty(e)}(n)}if(!n||"svg"!==n.localName)return null;if(e){const t=n.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("class","d3plus-save-background"),t.setAttribute("width","100%"),t.setAttribute("height","100%"),t.setAttribute("fill",e),n.insertBefore(t,n.firstChild)}return n}function Od(t){const e=t.pixelRatio;return"number"==typeof e&&e>0?e:"number"==typeof devicePixelRatio&&devicePixelRatio>0?devicePixelRatio:1}function Wd(t,e){const n=t.getBoundingClientRect().width;return n>0&&t.width/n<e-.01}function Hd(t,e){const{filename:n,background:i,callback:o,renderOptions:r}=Ed(t),a=t=>{o?o(t):t&&console.error(t)},s=()=>a(new Error("The chart has not been rendered, so it cannot be saved."));if("svg"===e){const e=Td(t,i);return e?void v.saveElement(e,{filename:n,type:"svg",callback:a}):s()}const c=Rd(t);if(!c)return s();const l={...r,backgroundColor:i||("jpg"===e?Nd(t):void 0)},h={filename:n,type:e};"canvas"===t._renderer&&Wd(c,Od(l))&&function(t,e,n,i,o){const r=i.backgroundColor,a=Td(t,"string"==typeof r&&r),s=e.ownerDocument;if(!a||!s.body)return!1;const c=s.createElement("div");c.setAttribute("aria-hidden","true"),c.style.cssText="position:fixed;left:-100000px;top:0;";const l=s.importNode(a,!0);return c.appendChild(l),s.body.appendChild(c),v.saveElement(l,{...n,callback:t=>{c.remove(),o(t)}},i),!0}(t,c,h,l,a)||v.saveElement(c,{...h,callback:a},l)}const jd={png:"PNG image",svg:"SVG vector",jpg:"JPG image"};function Id(t){return Ld(t.schema.saveControlConfig?.formats)}function Gd(t){return qh(t.schema,"saveControl",{base:Nh,active:Bh,hover:Eh})}function qd(t,e,n=!1){Gh(e,Gd(t),n,e.classList.contains("active"))}const Vd={position:"relative",display:"inline-flex","align-items":"center"},Yd={position:"absolute",top:"100%",left:"0","z-index":"1",display:"none","flex-direction":"column","min-width":"max-content"},Kd={display:"flex"},Ud={display:"block",width:"100%","text-align":"start","white-space":"nowrap",cursor:"pointer"};function Xd(t){const e=Boolean(t.schema.saveControlMenuClassName),n=(n,i)=>Ih(t.schema[n],i,e);return{menu:n("saveControlMenuStyle",Rh),item:n("saveControlMenuItemStyle",Ph),itemHover:n("saveControlMenuItemStyleHover",Th)}}function Zd(...t){return t.flatMap(t=>Object.entries(t)).filter(([,t])=>null!=t&&!1!==t).map(([t,e])=>`${Wh(t)}:${Vh(e)}`).join(";")}function Qd(t){const e=Id(t),n=e=>t.schema.translate(e),i=n("Download"),o=t.schema.saveControlClassName?` ${Vh(t.schema.saveControlClassName)}`:"",r=(t,e)=>`<button type="button" class="save-control save-toggle${o}" aria-label="${Vh(t)}" title="${Vh(t)}"${e}>${ed}</button>`;if(1===e.length){const t=`${i} (${n(jd[e[0]])})`;return`<span class="save-root" style="${Zd(Vd)}">${r(t,` data-format="${e[0]}"`)}</span>`}const a=Xd(t),s=Zd(a.item,Ud),c=t.schema.saveControlMenuClassName?` ${Vh(t.schema.saveControlMenuClassName)}`:"",l=e.map(t=>`<button type="button" role="menuitem" tabindex="-1" class="save-menu-item" data-format="${t}" style="${s}">${Vh(n(jd[t]))}</button>`).join("");return`<span class="save-root" style="${Zd(Vd)}">`+r(i,' aria-haspopup="menu" aria-expanded="false"')+`<span class="d3plus-save-menu${c}" role="menu" aria-label="${Vh(i)}" style="${Zd(a.menu,Yd)}">${l}</span></span>`}const Jd=new WeakMap;function tf(t){return t instanceof Element?t.closest(".save-root"):null}function ef(t){return t.querySelector(".save-toggle")}function nf(t){return Array.from(t.querySelectorAll(".save-menu-item"))}function of(t){return"true"===ef(t)?.getAttribute("aria-expanded")}function rf(t,e,n){const i=ef(e),o=e.querySelector(".d3plus-save-menu");if(!i||!o)return;i.setAttribute("aria-expanded",String(n)),i.classList.toggle("active",n),qd(t,i,i.matches(":hover"));const r=n?Kd:Yd;o.style.setProperty("display",String(r.display))}function af(t,e,n=!1){Jd.get(e)?.(),Jd.delete(e),rf(t,e,!1),n&&ef(e)?.focus()}function sf(t,e,n="first"){rf(t,e,!0);const i=e.ownerDocument,o=n=>{e.isConnected&&e.contains(n.target)||af(t,e)};Jd.get(e)?.(),i.addEventListener("pointerdown",o,!0),Jd.set(e,()=>i.removeEventListener("pointerdown",o,!0));const r=nf(e);r["last"===n?r.length-1:0]?.focus()}function cf(t,e,n){const i=e.target.closest(".save-menu-item");i&&function(t,e,n){const{item:i,itemHover:o}=Xd(t);Gh(e,{base:{...i,...Ud},hover:o},n,!1)}(t,i,n)}function lf(t){return function(t){return Boolean(t.schema.saveControl)&&!t._ssr&&Id(t).length>0}(t)?{key:"save",html:Qd(t),styleSignature:JSON.stringify(Gd(t)),events:{".save-toggle":{click:e=>function(t,e){const n=tf(e.target),i=n&&ef(n);if(!n||!i)return;const o=i.dataset.format;o?Hd(t,o):of(n)?af(t,n,!0):sf(t,n)}(t,e),keydown:e=>function(t,e){const n=e.key,i=tf(e.target);i&&i.querySelector(".d3plus-save-menu")&&("ArrowDown"===n||"ArrowUp"===n?(e.preventDefault(),sf(t,i,"ArrowUp"===n?"last":"first")):"Escape"===n&&of(i)&&(e.stopPropagation(),af(t,i,!0)))}(t,e)},".d3plus-save-menu":{keydown:e=>function(t,e){const n=e.key,i=tf(e.target);if(!i)return;const o=nf(i),r=o.indexOf(e.target),a=t=>{e.preventDefault(),o[(t+o.length)%o.length]?.focus()};"ArrowDown"===n?a(r+1):"ArrowUp"===n?a(r-1):"Home"===n?a(0):"End"===n?a(o.length-1):"Escape"===n?(e.preventDefault(),e.stopPropagation(),af(t,i,!0)):"Tab"===n&&af(t,i)}(t,e)},".save-menu-item":{click:e=>function(t,e){const n=tf(e.target),i=e.target.closest(".save-menu-item");n&&i&&(af(t,n,!0),Hd(t,i.dataset.format))}(t,e),mouseover:t=>function(t){t.target.closest(".save-menu-item")?.focus()}(t),focusin:e=>cf(t,e,!0),focusout:e=>cf(t,e,!1)},".save-root":{focusout:e=>function(t,e){const n=tf(e.target),i=e.relatedTarget;n&&i&&!n.contains(i)&&of(n)&&af(t,n)}(t,e)}},onUpdate:e=>{const n=e.querySelector(".save-toggle");n&&!n.dataset.saveBound&&(n.dataset.saveBound="1",qd(t,n),n.addEventListener("mouseenter",()=>qd(t,n,!0)),n.addEventListener("mouseleave",()=>qd(t,n)))}}:null}const hf="rgb(255, 255, 255)",uf=t=>Boolean(t)&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t;function df(t){if(t._ssr||"undefined"==typeof window||"function"!=typeof getComputedStyle)return{dark:!1,background:hf};let e=t._select?.node?.()??null;for(;e;){const t=getComputedStyle(e).backgroundColor;if(uf(t))return{dark:U(t),background:t};e=e.parentElement}const n=getComputedStyle(document.documentElement).colorScheme||"",i=n.includes("dark")&&(!n.includes("light")||"function"==typeof matchMedia&&matchMedia("(prefers-color-scheme: dark)").matches);return i?{dark:i}:{dark:i,background:hf}}function ff(t){return df(t).dark}function mf(t){if("undefined"==typeof window||"undefined"==typeof document)return()=>{};const e="function"==typeof matchMedia?matchMedia("(prefers-color-scheme: dark)"):null;e?.addEventListener?.("change",t);const n="function"==typeof MutationObserver?new MutationObserver(t):null;for(const t of[document.documentElement,document.body])t&&n?.observe(t,{attributes:!0});const i=e=>{/background/.test(e.propertyName||"")&&t()};return document.addEventListener("transitionend",i),()=>{e?.removeEventListener?.("change",t),n?.disconnect(),document.removeEventListener("transitionend",i)}}function pf(t){t._themeWatch||t._ssr||"undefined"==typeof window||(t._themeWatch=mf(()=>{const e=t._select?.node?.();e&&e.isConnected&&t._theme&&!t._theme.painted&&ff(t)!==t._theme.dark&&t.render?.()}))}function gf(t){t._themeWatch?.(),t._themeWatch=void 0}function yf(t){const e=Q(t.schema.theme,df(t),t.schema.colorDefaults);return t._theme=e,yo(t,e),e.painted?gf(t):pf(t),e}function xf(t){const e=t._theme;if(!e?.painted)return;const{width:n,height:i}=t.schema,o={key:"viz-background",interactive:!1,paint:{fill:e.background}},r=function(t){if(t._ssr||!t._tileGroup||!t._margin)return;const{top:e,right:n,bottom:i,left:o}=t._margin,{width:r,height:a}=t.schema;return{x:o,y:e,width:r-o-n,height:a-e-i}}(t);if(!r)return{...o,type:"rect",x:0,y:0,width:n,height:i};const{x:a,y:s}=r;return{...o,type:"path",d:`M0,0H${n}V${i}H0ZM${a},${s}V${s+r.height}H${a+r.width}V${s}Z`}}function bf(t){const e=xf(t);return e?[e]:[]}function _f(t){return t&&(t.painted||t.dark)?t.dark?"dark":"light":""}function kf(t){const e=_f(t._theme),n=t._sceneRenderer?.elements?.()??[];for(const t of n)"div"===t.localName&&"style"in t&&(t.style.colorScheme=e)}function vf(t,e,n,i){const o={};for(const[e,n]of Object.entries(i))o[e]=J(t._theme,t=>n(t.overlay),void 0);return nt(e,n,o)}function wf(t){return Boolean(t._searchOpen)}function Mf(t){return qh(t.schema,"searchControl",{base:Dh,active:Lh,hover:Fh})}function Sf(t,e,n=!1){Gh(e,Mf(t),n,e.classList.contains("active"))}const Cf=`<svg ${Xh}><circle cx="10" cy="9" r="7"/><line x1="21" y1="20" x2="15" y2="14"/></svg>`,$f=`<svg ${Xh}><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg>`,Af={width:"0",padding:"0",border:"none",opacity:"0","pointer-events":"none"},zf={width:"120px",padding:"0 22px 0 6px",border:"1px solid #ccc","border-radius":"3px",opacity:"1","pointer-events":"auto"},Df={height:"20px","box-sizing":"border-box",margin:"0",font:`12px/1 ${s.fontFamilyStringify(s.fontFamily)}`,transition:"width 0.15s ease, opacity 0.15s ease"},Lf={position:"relative",display:"inline-block"},Ff={display:"inline-flex","align-items":"center"},Nf={position:"absolute",top:"50%",right:"2px",transform:"translateY(-50%)",display:"inline-flex","align-items":"center","justify-content":"center",visibility:"visible",width:"16px",height:"16px",margin:"0",padding:"0",border:"none",background:"none",cursor:"pointer"},Bf={...Nf,visibility:"hidden",cursor:"default"},Ef={position:"absolute",top:"100%",left:"0","margin-top":"4px",width:"100%","box-sizing":"border-box",display:"block",visibility:"visible",background:"rgba(255, 255, 255, 0.75)",border:"1px solid rgba(0, 0, 0, 0.25)",color:"rgba(0, 0, 0, 0.75)","font-size":"11px","text-align":"center",padding:"2px 4px","white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis","pointer-events":"none"},Rf={...Ef,visibility:"hidden"};function Pf(t){return Object.entries(t).map(([t,e])=>`${Wh(t)}:${e}`).join(";")}function Tf(t,e){const n=e?zf:Af;for(const e in n)t.style.setProperty(Wh(e),n[e])}function Of(t){const e=t.schema.searchControlClassName?` ${t.schema.searchControlClassName}`:"",n=t.schema.translate("Search"),i=wf(t),o=t._searchTerm||"",r=o.trim().length>0,a=Pf({...Df,...i?zf:Af,...Xt(t)?{transition:"none"}:{}}),s=Pf(r?Nf:Bf),c=Pf(Lf);return`<span class="search-root" style="${Pf(Ff)}"><button type="button" class="search-control search-toggle${i?" active":""}${e}" aria-label="${n}" aria-pressed="${i}">${Cf}</button><span class="search-input-wrap" style="${c}"><input type="text" class="search-control search-input" placeholder="${n}" aria-label="${n}" value="${Vh(o)}" style="${a}"${i?"":' tabindex="-1"'}/><button type="button" class="search-control search-clear" aria-label="${t.schema.translate("Clear")}" style="${s}"${r?"":' tabindex="-1"'}>${$f}</button><span class="search-count" aria-live="polite"></span></span></span>`}function Wf(t,e,n,i){const o=t.schema.searchAccessor(e,n);if("string"==typeof o&&o.toLowerCase().includes(i))return!0;return t._ids(e,n).some(t=>"string"==typeof t&&t.toLowerCase().includes(i))}function Hf(t,e){const n=e.trim().toLowerCase();if(!n)return[];const i=[];return Ae(t._chartScene||[],(e,o,r)=>{Wf(t,e,o,n)&&i.push({node:r,row:e,index:o})}),i}function jf(t,e){const n=Of(t),i=function(t){const e=t._featurePanels??[];for(const t of e){if("viz-top-left-controls"!==t?.key||!t.children)continue;const e=t.children.find(t=>"viz-top-left-controls-search"===t.key);if(e)return e}return null}(t);i&&(i.html=n),a.markOverlayHtmlSynced(e,n)}function If(t,e){const n=e.querySelector(".search-count");if(!n)return;const i=t._searchTerm||"",o=i.trim().length>0,r=o?Hf(t,i).length:0;"number"==typeof t._searchMatchIndex&&t._searchMatchIndex>=r&&(t._searchMatchIndex=void 0),function(t,e,n,i,o){const r=vf(t,n?Ef:Rf,Ef,{background:t=>t.background,border:t=>`1px solid ${t.border}`,color:t=>t.text});for(const t in r)e.style.setProperty(Wh(t),r[t]);const{text:a,label:s}=function(t,e,n){let i;return i=0===n?t.schema.translate("No Matches"):"number"!=typeof e?`${n} ${t.schema.translate(1===n?"Match":"Matches")}`:`${t.schema.translate("Match")} ${e+1}/${n}`,{text:i,label:i}}(t,i,o);e.textContent=n?a:"",e.setAttribute("aria-label",s)}(t,n,o,t._searchMatchIndex,r)}function Gf(t,e,n){const i=n.trim().length>0;t._searchMatchIndex=void 0;const o=e.querySelector(".search-clear");o&&function(t,e){const n=e?Nf:Bf;for(const e in n)t.style.setProperty(Wh(e),n[e]);t.tabIndex=e?0:-1}(o,i),If(t,e)}function qf(t,e){t._searchOpen=!1,t._searchTerm="",t.highlight(t._searchPrevHighlight??!1),t._searchPrevHighlight=void 0,jf(t,e),Gf(t,e,"");const n=e.querySelector(".search-toggle");n&&(n.classList.remove("active"),n.setAttribute("aria-pressed","false"),Sf(t,n,n.matches(":hover")));const i=e.querySelector(".search-input");i&&(i.value="",i.setAttribute("tabindex","-1"),Tf(i,!1))}function Vf(t,e){const n=e.currentTarget;wf(t)?qf(t,n):function(t,e){t._searchOpen=!0,t._searchPrevHighlight=t._highlight,jf(t,e);const n=e.querySelector(".search-toggle");n&&(n.classList.add("active"),n.setAttribute("aria-pressed","true"),Sf(t,n,n.matches(":hover")));const i=e.querySelector(".search-input");i&&(i.removeAttribute("tabindex"),Tf(i,!0),i.focus())}(t,n)}function Yf(t,e,n){t._searchTerm=n,t.highlight(function(t,e){const n=e.trim().toLowerCase();return n?(e,i)=>Wf(t,e,i,n):t._searchPrevHighlight??!1}(t,n)),jf(t,e),Gf(t,e,n)}function Kf(t,e,n){if("canvas"===t._renderer||"function"!=typeof t._zoomToBounds)return;const i=e.parentElement?.parentElement,o=i?.querySelector("svg");if(!i||!o)return;const r=function(t,e){const n=t.querySelectorAll("[data-key]");for(const t of n)if(t.getAttribute("data-key")===String(e))return t;return null}(i,n);if(!r)return;const a=r.getBoundingClientRect(),s=o.getBoundingClientRect();(a.width||a.height)&&t._zoomToBounds([[a.left-s.left,a.top-s.top],[a.right-s.left,a.bottom-s.top]],Zt(t))}function Uf(t,e){const n=e,i=e.currentTarget;"Escape"===n.key?qf(t,i):"Enter"===n.key&&(n.preventDefault(),function(t,e,n){const i=t._searchTerm||"";if(!i.trim())return;const o=Hf(t,i);if(!o.length)return;const r=o.length,a=t._searchMatchIndex,s=(("number"==typeof a?a:1===n?-1:0)+n+r)%r;t._searchMatchIndex=s,If(t,e),Kf(t,e,o[s].node.key)}(t,i,n.shiftKey?-1:1))}function Xf(t){return function(t){return Boolean(t.schema.search)&&!t._ssr}(t)?{key:"search",html:Of(t),styleSignature:JSON.stringify(Mf(t)),events:{".search-toggle":{click:e=>Vf(t,e)},".search-clear":{click:e=>function(t,e){const n=e.currentTarget,i=n.querySelector(".search-input");i&&(i.value=""),Yf(t,n,""),i?.focus()}(t,e)},".search-input":{input:e=>function(t,e){const n=e.target;Yf(t,e.currentTarget,n.value)}(t,e),keydown:e=>Uf(t,e)}},onUpdate:e=>{If(t,e);const n=e.querySelector(".search-toggle");n&&!n.dataset.searchBound&&(n.dataset.searchBound="1",Sf(t,n),n.addEventListener("mouseenter",()=>Sf(t,n,!0)),n.addEventListener("mouseleave",()=>Sf(t,n)));const i=e.querySelector(".search-input");i&&!i.dataset.searchBlurBound&&(i.dataset.searchBlurBound="1",i.addEventListener("blur",n=>function(t,e,n){if((t._searchTerm||"").trim().length>0)return;const i=n.relatedTarget;i&&e.contains(i)||qf(t,e)}(t,e,n)))}}:null}function Zf(t,e){if(!e.length)return null;const n=e.map(t=>`${t.key}:${t.html}|${t.styleSignature??""}`).join("||"),i=t._topLeftControlsBox;if(i&&i.signature===n)return i.measurement;const o=function(t,e){const n=ru(t);if(!n){let t=0;return{items:e.map(e=>{const n={...e,x:t};return t+=32,n}),width:Math.max(0,t-4),height:20}}const i=document.createElement("div");i.className="d3plus-top-left-controls",i.style.setProperty("display","inline-flex"),i.style.setProperty("align-items","center"),i.style.setProperty("gap","4px"),i.style.setProperty("position","absolute"),i.style.setProperty("visibility","hidden"),i.style.setProperty("pointer-events","none"),i.innerHTML=e.map(t=>`<span class="tlc-item" data-tlc-key="${t.key}" style="display:inline-flex;align-items:center;">${t.html}</span>`).join("");for(const t of e)t.onUpdate?.(i);n.appendChild(i);const o=i.getBoundingClientRect(),r=Array.from(i.querySelectorAll(":scope > .tlc-item")),a=e.map((t,e)=>{const n=r[e]?.getBoundingClientRect();return{...t,x:n?Math.round(n.left-o.left):0}});return n.removeChild(i),{items:a,width:o.width?Math.ceil(o.width):0,height:o.height?Math.ceil(o.height):0}}(t,e);return t._topLeftControlsBox={width:o.width,height:o.height,signature:n,measurement:o},o}function Qf(t,e){const n=Zf(t,e);return n?{type:"group",key:"viz-top-left-controls",children:n.items.map(t=>({type:"htmlOverlay",key:`viz-top-left-controls-${t.key}`,x:4+t.x,y:4,className:"d3plus-top-left-controls-item",html:t.html,events:t.events,onUpdate:t.onUpdate}))}:null}function Jf(t,e){const n=Zf(t,e);return n?{width:n.width?n.width+4:0,height:n.height?n.height+4:0}:null}function tm(t,e){const n=Jf(t,e);return n&&n.height?n.height+4:0}const em=[Iu,zd,lf,Xf];function nm(t){const e=[];for(const n of em){const i=n(t);i&&e.push(i)}return e}const im={name:"topLeftControls",layout:({viz:t})=>{const e=nm(t);return e.length?{panel:Qf(t,e),margin:{}}:{panel:null,margin:{}}}},om=["x","x2","y","y2"];function rm(t,e){const n=t[`_${e}Config`];return t[`_${e}Time`]||"time"===n?.scale?ri(n?.rangeBreaks):[]}function am(t,e,n){const i=t[`_${e}Config`];return!!ri(i?.rangeBreaks).length&&(n instanceof Date?!isNaN(+n):!("number"==typeof n&&String(Math.abs(n)).length<=5)&&(("string"==typeof n||"number"==typeof n)&&Number.isFinite(ii(n))))}function sm(t){const e=t._data?.[0],n=t.schema.time;if(!e||"function"!=typeof n)return[];const i=n(e,0);for(const n of om){const o=t[`_${n}`];if("function"!=typeof o||o(e,0)!==i)continue;const r=t[`_${n}Config`],a=ri(r?.rangeBreaks);if(a.length)return a}return[]}const cm=t=>t instanceof Date||"number"==typeof t?+t:NaN;function lm(t,e){let n=e;return om.forEach(e=>{const i=rm(t,e);if(!i.length||!n.length)return;const o=n.map(t=>cm(t[e])).filter(Number.isFinite);if(!o.length)return;const[r,a]=h.extent(o),s=ui(i,r,a),c=n.filter(t=>!s(cm(t[e])));c.length<n.length&&Et(t,`rangeBreaks-${e}`,`Some data falls inside ${e}Config.rangeBreaks and is not drawn.`),n=c}),n}function hm(t,e,n){const i=rm(t,e);if(!i.length)return n;const o=t[`_${e}Config`],{space:r}=Kn(o?.breakConfig),a=_i(i,{space:r});return a.domain(n.domain()),a.range(n.range()),a}function um(t){const e=t.schema.filter,n=t._filterApplied;return e&&n?(t,i)=>n(t)||e(t,i):e}function dm(t){if(!t.schema.timeline)return{min:1,max:1/0};const e=t.schema.timelineConfig||{},n=qr(e.brushMin,e.brushMax);return!1===e.brushing?{...n,min:1}:n}function fm(t,e,n){const i=[...new Set(e.map(Number))].sort((t,e)=>t-e);if(i.length<=n)return()=>!0;const o=i[i.length-n],a=t.schema.time;return(t,e)=>+r.date(a(t,e))>=o}function mm(t){const e=t.schema.timelineConfig||{},n=t.schema.timelineDefault&&t.schema.timelineDefault.length?t.schema.timelineDefault:e.selection;if(null==n||!1===n)return;const i=[].concat(n).map(t=>r.date(t)).filter(t=>t instanceof Date&&!isNaN(+t)).sort((t,e)=>+t-+e);return i.length?[i[0],i[i.length-1]]:void 0}function pm(t){let e;const n=t.schema.time,i=n&&!t.schema.timeFilter&&mm(t);if(n&&i&&t._data.length){const[t,e]=i.map(Number);return(i,o)=>{const a=Number(r.date(n(i,o)));return a>=t&&a<=e}}if(t.schema.time&&!t.schema.timeFilter&&t._data.length){const n=t._data.map(t.schema.time).map(t=>r.date(t)),i=t._data[0],o=0;e=t.schema.discrete&&`_${t.schema.discrete}`in t&&t[`_${t.schema.discrete}`](i,o)===t.schema.time(i,o)?fm(t,n,dm(t).max):fm(t,n,Math.max(1,Math.ceil(dm(t).min)))}return e}function gm(t,e,i,o,r,a=t._data){const s=[],c=[];if(a.length){const l=t.schema.timeFilter||r;let u=l?a.filter(l):a;const d=um(t);d&&(u=u.filter(d));const f=[];for(let e=0;e<=i;e++)f.push(t.schema.groupBy[e]);f.push(...function(t){const e=t.schema.discrete;if(!e)return[];const n=[],i=t;for(const o of[e,`${e}2`])`_${o}`in t?n.push(i[`_${o}`]):"function"==typeof t.schema[o]&&n.push(t.schema[o]);return n}(t));const m=function(t){let e,n=0;return i=>{if(e)return e.get(i)??-1;const o=t.indexOf(i);if(n+=o<0?t.length:o+1,n>=t.length){e=new Map;for(let n=t.length-1;n>=0;n--)e.set(t[n],n)}return o}}(t._data),p=h.rollup(u,e=>{const i=m(e[0]),r=t.schema.shape(e[0],i),a=o(e[0],i),l=t._mergeRows?t._mergeRows(e):n.merge(e,t.schema.aggs);t._hidden.includes(a)||t._solo.length&&!t._solo.includes(a)||(!t.schema.discrete&&"Line"===r||t._unmergedShapes?.includes(r)?s.push(...e):s.push(l)),c.push(l)},...f);e.filteredData=s,e._thresholdTree=p}else e.filteredData=s;e.legendData=c}function ym(t){const e="function"==typeof t.config?t.config():{};return Object.freeze(e)}function xm(t){const e=(e,n,i)=>{const o=t.schema.shape(e,n);"fill"===i&&"Line"===o&&(i="stroke");const r=t.schema.shapeConfig[o]&&t.schema.shapeConfig[o][i]?t.schema.shapeConfig[o][i]:t.schema.shapeConfig[i];return"function"==typeof r?r.bind(t)(e,n):r};return{getAttr:e,colorOf:(e,n)=>"function"==typeof t.schema.color?t.schema.color(e,n):void 0,keyOf:(t,n,i)=>[null==i?e(t,n,"fill"):"string"==typeof i?i:JSON.stringify(i),e(t,n,"opacity"),e(t,n,"texture")].join("_")}}function bm(t){const{getAttr:e,colorOf:i,keyOf:o}=xm(t),r=(t,e)=>o(t,e,i(t,e)),a=j(t.schema.legend);if(a&&!a.value)return{legendData:[],legendKey:r,getAttr:e};const s=function(t){const e=t._legendData||[];return t.schema.colorScale?e.filter((e,n)=>void 0===t.schema.colorScale(e,n)):e}(t),c=new Map;s.forEach((t,e)=>{const n=i(t,e),r=o(t,e,n),a=c.get(r);a?a.leaves.push(t):c.set(r,{leaves:[t],color:n})});const l=Array.from(c.values(),({leaves:e,color:i})=>({datum:n.merge(e,t.schema.aggs),color:i})),h=l.map(t=>t.datum),u=h.map((e,n)=>t._ids(e,n).slice(0,t._drawDepth+1));t._legendDepth=0;for(let e=0;e<=t._drawDepth;e++){const n=u.map(t=>t[e]);if(!n.some(t=>Array.isArray(t))&&Array.from(new Set(n)).length===h.length){t._legendDepth=e;break}}t._legendCategories=function(t,e){const n=t.schema.groupBy?.[t._legendDepth??0];return"function"==typeof n&&e.some((e,i)=>{const o=n.bind(t)(e,i);return Array.isArray(o)&&o.length>1})}(t,h)?function(t){const e=new WeakMap,n=new Set;for(const{datum:i,color:o}of t){const t=nl(o);if(void 0===t||n.has(t))return;n.add(t),e.set(i,t)}return e}(l):void 0;const d=t=>t._isAggregation?1:0;return h.sort((e,n)=>d(e)-d(n)||t.schema.legendSort(e,n)),{legendData:h,legendKey:r,getAttr:e}}function _m(t,e,n){const{legendData:i,legendKey:o,getAttr:a}=e,s=(e,n)=>{let i=t._id(e,n);return Array.isArray(i)&&(i=i[0]),t._hidden.includes(i)||t._solo.length>0&&!t._solo.includes(i)},c={transform:`translate(${n.x}, ${n.y})`},l=r.elem("g.d3plus-viz-legend",{condition:n.visible&&!t.schema.legendConfig.select,enter:c,parent:t._select,duration:0,update:c}).node();t._legendClass.renderMode("compute").id(o).align(n.align).direction(n.direction).duration(Zt(t)).data(n.visible?i:[]).height(n.height).locale(t.schema.locale).parent(t).select(l).shape((e,n)=>{const i=t.schema.shape(e,n);return"Circle"===i||"Line"===i?i:"Rect"}).verticalAlign(n.verticalAlign).width(n.width).shapeConfig(Qt.bind(t)(t.schema.shapeConfig,"legend")).shapeConfig({fill:(e,n)=>s(e,n)?t.schema.hiddenColor(e,n):a(e,n,"fill"),labelConfig:{fontOpacity:(e,n)=>s(e,n)?t.schema.hiddenOpacity(e,n):1}}).config(t.schema.legendConfig).render()}function km(t){const{width:e,height:n}=t.outerBounds();return!(!e||!n)&&(t._lineData||[]).every(t=>{if(!t.sentence)return!0;const e=t.lines.length;return t.width>0&&!t.truncated&&e<=`${t.sentence}`.split("\n").length&&t.height<=t.og.height})}function vm(t,e){const n=ym(t);return!1!==tp(t.schema.legendPosition.bind(t)(n),t)&&Boolean(t.schema.legend.bind(t)(n,e.legendData))}function wm(t,e,n,i=bm(t)){const o=vm(t,i)&&!t.schema.legendConfig.select;if(_m(t,i,{x:0,y:0,...Ys(e,n),align:"left",direction:e,verticalAlign:"top",visible:o}),!o)return null;const r=t._legendClass,a=(r._lineData||[]).every(t=>t.width>0),{width:s,height:c}=r.outerBounds();return a&&s&&c?{width:s,height:c}:null}function Mm(t,e,n){if(Gs(t,"legend"))return wm(t,Vs(t,"legend"),{width:t.schema.width-n.left-n.right,height:t.schema.height-n.top-n.bottom},e),{panel:null,margin:{}};const i=ym(t),o=tp(t.schema.legendPosition.bind(t)(i),t),r=["top","bottom"].includes(o),a=t.schema.legendPadding(t)?t._padding:{top:0,right:0,bottom:0,left:0},{drop:s,insetRight:c,shorten:l}=function(t,e,n,i){const o=rp(t,e,n.top,"left"===e?n.left:n.right),r=pu(t,e,n.bottom+i.bottom,n.right+i.right);return{drop:o,insetRight:r.inset,shorten:r.drop}}(t,o,n,a),h={x:r?n.left+a.left:n.left,y:(r?n.top:n.top+a.top)+s,width:(r?t.schema.width-(n.left+n.right+a.left+a.right):t.schema.width-(n.left+n.right))-c,height:(r?t.schema.height-(n.bottom+n.top):t.schema.height-(n.bottom+n.top+a.bottom+a.top))-s-l,align:r?"center":o,direction:r?"row":"column",verticalAlign:r?o:"middle",visible:vm(t,e)};let u=0;"top"===o?u=function(t,e,n,i,o){const r=n.visible&&!t.schema.legendConfig.select?sp(t,i,n.x,o,!0):[{left:0,right:0,drop:0}];for(const[i,{left:o,right:a,drop:s}]of r.entries())if(_m(t,e,{...n,x:n.x+o,y:n.y+s,width:n.width-o-a,height:n.height-s}),i===r.length-1||km(t._legendClass))return s;return 0}(t,e,h,n.top,n.right+a.right):_m(t,e,h);const d=t._legendClass.outerBounds(),f={};return!t.schema.legendConfig.select&&d.height&&(f[o]=r?u+d.height+2*t._legendClass.padding():d.width+2*t._legendClass.padding()),{panel:null,margin:f}}const Sm={name:"legend",configFields:["legend","legendConfig","legendPadding","legendPosition","legendSort"],layout:({viz:t,layoutMargin:e})=>Mm(t,bm(t),e)};function Cm(t){return t instanceof Date?""+ +t:`${t}`}function $m(t){if(null!=t&&""!==t)return t instanceof Date||"string"==typeof t||"number"==typeof t||"boolean"==typeof t?t:`${t}`}function Am(t,e){const n=t instanceof Date?+t:t,i=e instanceof Date?+e:e;return"number"==typeof n&&"number"==typeof i?n-i:`${t}`.localeCompare(`${e}`,void 0,{numeric:!0})}function zm(t,e){const n=t.slice();if(Array.isArray(e)){const t=new Map(e.map((t,e)=>[Cm(t),e])),i=e=>t.get(Cm(e))??1/0;return n.sort((t,e)=>i(t)-i(e))}return"function"==typeof e?n.sort(e):"data"===e?n:(n.sort(Am),"descending"===e?n.reverse():n)}function Dm(t,e,n){const i=new Map;t.forEach((t,n)=>{const o=$m(e(t,n));if(void 0===o)return;const r=Cm(o);let a=i.get(r);a||i.set(r,a={key:r,value:o,rows:[]}),a.rows.push(t)});const o=new Map(Array.from(i.values()).map(t=>[t.key,t]));return zm(Array.from(i.values()).map(t=>t.value),n).map(t=>o.get(Cm(t)))}function Lm(t,e){const n=t.schema.facet;if(!n)return[];const i=t._data||[],o=um(t);return Dm(o?i.filter(o):i,n,e)}function Fm(t,e,n){const i={};gm(t,i,t._drawDepth,t._id,n,e);let o=i.filteredData??[];return e.length&&i._thresholdTree&&t._thresholdFunction&&(o=t._thresholdFunction(o,i._thresholdTree,t._thresholdRows??i.legendData)),o}function Nm(t){return pm(t)}function Bm(t,e){if(t instanceof Date){const n=e.filter(t=>t instanceof Date).sort((t,e)=>+t-+e);return d.formatDate(t,n)}return`${t}`}const Em=O,Rm=t=>new Em[t];function Pm(t,e,n){return"function"==typeof t?t(e,n):t}function Tm(t,e,n,i){const o=xa(Pm(t.texture,e,n),()=>i,()=>Pm(t.stroke,e,n),t.textureDefault);return o?`pattern:${o}`:"string"==typeof i?i:void 0}function Om(t,e,n){const i=Pm(t.fill,e,n),o=Pm(t.stroke,e,n),r=Pm(t.strokeWidth,e,n),a=Pm(t.opacity,e,n),s=Pm(t.vectorEffect,e,n);return{fill:Tm(t,e,n,i),stroke:o,strokeWidth:r,opacity:a,vectorEffect:"none"===s||"non-scaling-stroke"===s?s:void 0}}function Wm(t,e,n){return t._drawLabel(e.data??e,e.i??n)}function Hm(t,e,n,i="shape"){return Qt.bind(t)(n??t.schema.shapeConfig,i,e)}function jm(t,e){const n=t.schema.shapeConfig??{},i=t=>t&&"object"==typeof t?t.labelConfig:void 0,o={...i(n),...i(n[e])};for(const t in o)oc(o[t])&&delete o[t];const{labelConfig:r}=Hm(t,e,{labelConfig:o});return r??{}}function Im(t,e={}){if(!t)return[];const n=!1!==e.shape,i=!1!==e.labels;try{t.render();const e=[];if(n&&"function"==typeof t.toScene){const n=t.toScene();n&&Array.isArray(n.children)&&e.push(...n.children)}if(i){const n=t._labelClass;if(n&&"function"==typeof n.toScene){const t=n.toScene();t&&Array.isArray(t.children)&&e.push(...t.children)}}return e}catch{return[]}}function Gm(t){const e=Cs(t);if("function"!=typeof t.schema.colorScale)return e;const i=t._colorScaleRows?t._colorScaleRows():function(t){const e=t.schema.facet,i=Array.from(h.rollup(t._data,e=>n.merge(e,t.schema.aggs),(n,i)=>`${t.schema.time?t.schema.time(n,i):"all"}-${e?Cm(e(n,i)):"all"}-${t._ids(n,i).join("_")}`).values());return i.filter((e,n)=>{const i=t.schema.colorScale(e,n);return null!=i})}(t);return e.length?[...i,...e]:i}const qm=["fillOpacity","opacity","stroke","strokeDasharray","strokeLinecap","strokeOpacity","strokeWidth"];function Vm(t){let e;const n=new Map,i=(i,o)=>{void 0===e&&(e=function(t){const e=zs(t);if(!e)return null;const n=new Map;return e.rows.forEach((t,i)=>{const o=e.colorOf(t,i);n.has(o)||n.set(o,{row:t,i:i})}),n}(t));const r=e?.get(i.color)??e?.values().next().value;if(!r)return;const{row:a,i:s}=r,c=t._colorScaleShape(a,s),l="Line"===c?"":c;return n.has(l)||n.set(l,Hm(t,l)),Pm(n.get(l)[o],a,s)};return Object.fromEntries(qm.map(t=>[t,e=>i(e,t)]))}function Ym(t,e,n){const i={opacity:e.orient?1:0,transform:`translate(${e.x}, ${e.y})`},o=r.elem("g.d3plus-viz-colorScale",{condition:n&&!t.schema.colorScaleConfig.select,enter:i,parent:t._select,duration:0,update:i}).node(),a=$s(t);a&&t._colorScaleClass.renderMode("compute").align(e.align).duration(Zt(t)).data(Gm(t)).height(e.height).locale(t.schema.locale).orient(e.orient).select(o).value(a).width(e.width).legendConfig({shapeConfig:Vm(t)}).ordinalRamp(Cs(t).length>0).config(t.schema.colorScaleConfig).hover(!1).render()}function Km(t){return tp(t.schema.colorScalePosition.bind(t)(ym(t)),t)}function Um(t,e,n){const i=Boolean($s(t))&&!1!==Km(t)&&!t.schema.colorScaleConfig.select,o=Ys(e,n),r=t.schema.colorScaleMaxSize;if(Ym(t,{x:0,y:0,width:"row"===e?h.min([r,o.width]):o.width,height:"column"===e?h.min([r,o.height]):o.height,orient:"column"===e?"right":"bottom",align:"start"},i),!i)return null;const{width:a,height:s}=t._colorScaleClass.outerBounds();return a&&s?{width:a,height:s}:null}const Xm={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:t,layoutMargin:e})=>{if(Gs(t,"colorScale"))return Um(t,Vs(t,"colorScale"),{width:t.schema.width-e.left-e.right,height:t.schema.height-e.top-e.bottom}),{panel:null,margin:{}};const n=Km(t),i=["top","bottom"].includes(n),o=$s(t)&&n,r=t.schema.colorScalePadding(t)?t._padding:{top:0,right:0,bottom:0,left:0},a=rp(t,n,e.top,"left"===n?e.left:e.right),s=pu(t,n,e.bottom+r.bottom,e.right+r.right),c=t.schema.width-(e.left+e.right+r.left+r.right)-s.inset,l=i?h.min([t.schema.colorScaleMaxSize,c]):t.schema.width-(e.left+e.right),u=t.schema.height-(e.bottom+e.top+r.bottom+r.top)-a-s.drop,d=i?t.schema.height-(e.bottom+e.top):h.min([t.schema.colorScaleMaxSize,u]);Ym(t,{x:i?e.left+r.left+(c-l)/2:e.left,y:i?e.top:e.top+r.top+a+(u-d)/2,width:l,height:d,orient:n,align:{bottom:"end",left:"start",right:"end",top:"start"}[n]||"bottom"},Boolean(o));const f={};if(o){const e=t._colorScaleClass.outerBounds();if(!t.schema.colorScaleConfig.select&&e.height){const o="function"==typeof t._colorScaleClass.padding?t._colorScaleClass.padding():t._legendClass.padding();f[n]=i?e.height+2*o:e.width+2*o}}return{panel:null,margin:f}}};function Zm(t,e){const n=t.querySelector(".d3plus-attribution-text"),i=t.querySelector(".d3plus-attribution-toggle");n&&(n.style.display=e?"":"none"),i&&i.setAttribute("aria-expanded",String(e)),t.style.borderRadius="3px 0 0 0",t.style.padding=e?"4px 6px":"2px"}const Qm={name:"attribution",configFields:["attribution","attributionIcon","attributionStyle"],layout:({viz:t})=>{let e=o.select(t._select.node().parentNode).selectAll("div.d3plus-attribution").data(t.schema.attribution?[0]:[]);const n=e.enter().append("div").attr("class","d3plus-attribution");e.exit().remove();const i=vf(t,t.schema.attributionStyle,bh,{background:t=>t.background,color:t=>t.text});e=e.merge(n).style("position","absolute").style("right",`${t._margin.right}px`).style("bottom",`${t._margin.bottom}px`).call(r.stylize,i);const a=`<span class="d3plus-attribution-text">${t.schema.attribution}</span><button type="button" class="d3plus-attribution-toggle" aria-label="${t.schema.translate("Attribution")}" aria-expanded="true">${function(t){const e=t.schema.attributionIcon;return"string"==typeof e?e:"function"==typeof e?'<span class="d3plus-attribution-icon" style="display:inline-block;width:12px;height:12px;vertical-align:middle;flex-shrink:0"></span>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" style="width:12px;height:12px;display:block"><circle cx="12" cy="12" r="10"/><line x1="12" y1="11" x2="12" y2="17"/><line x1="12" y1="7" x2="12" y2="7.01"/></svg>'}(t)}</button>`,s=e.node();if(s&&s.__d3plusHTML!==a){s.innerHTML=a,s.__d3plusHTML=a,s.querySelectorAll("a").forEach(t=>{t.style.color="inherit",t.style.textDecoration="none"});const e=s.querySelector(".d3plus-attribution-toggle");e&&(e.style.border="0",e.style.background="transparent",e.style.color="inherit",e.style.margin="0",e.style.padding="0",e.style.flexShrink="0"),function(t,e){const n=t.schema.attributionIcon;if("function"!=typeof n)return;const i=e.querySelector(".d3plus-attribution-icon");i&&(t._attributionIconCleanup?.(),t._attributionIconCleanup=n(i)||void 0)}(t,s)}const c=e.node();if(!c)return{panel:null,margin:{}};const{width:l}=kt(t);c.style.maxWidth=`${Math.min(280,l)}px`;const h=c.querySelector(".d3plus-attribution-text");h.style.whiteSpace="nowrap";const u=h.getBoundingClientRect().width>.5*l;h.style.whiteSpace="";const d=o.select(c).select(".d3plus-attribution-toggle").style("display",u?"":"none");if(!u)return o.select(c).on(".compact",null),Zm(c,!0),{panel:null,margin:{}};const f=()=>Zm(c,Boolean(t._attributionPinned||c.matches(":hover, :focus-within")));return o.select(c).on("mouseenter.compact focusin.compact",()=>Zm(c,!0)).on("mouseleave.compact focusout.compact",()=>window.setTimeout(f,0)),d.on("click.compact",()=>{t._attributionPinned=!t._attributionPinned,Zm(c,t._attributionPinned)}),Zm(c,Boolean(t._attributionPinned)),{panel:null,margin:{}}}},Jm=new Set([!1,"top","right","bottom","left"]);function tp(t,e){return"auto"===t?function(t){return t.schema.width>1.5*t.schema.height?"right":"bottom"}(e):Jm.has(t)?t:"bottom"}function ep(t,e,n={top:0,right:0,bottom:0,left:0}){const i={top:0,right:0,bottom:0,left:0},o=[];for(const r of e){if(!r.layout)continue;const e={top:n.top+i.top,right:n.right+i.right,bottom:n.bottom+i.bottom,left:n.left+i.left},a=r.layout({...t,layoutMargin:e}),{panel:s,margin:c,vizUpdate:l}=a;if(s&&o.push(s),i.top+=c.top??0,i.right+=c.right??0,i.bottom+=c.bottom??0,i.left+=c.left??0,l&&t.viz){const e=t.viz;for(const t of Object.keys(l)){e[t.startsWith("_")?t:`_${t}`]=l[t]}}}return{panels:o,margin:i}}const np=6;function ip(t,e,n){const i=cu(t);if(!i||e>=lu(t))return 0;const o=i.width-n;return o>0?o+np:0}function op(t,e,n){const i=function(t,e,n,i){const o=Jf(t,i);return!o||e>=tm(t,i)?0:Math.max(0,o.width-n)}(t,e,n,nm(t));return i>0?i+np:0}function rp(t,e,n,i){return"right"===e&&ip(t,n,i)?lu(t)-n:"left"===e&&op(t,n,i)?tm(t,nm(t))-n:0}function ap(t){return Math.max(lu(t),tm(t,nm(t)))}function sp(t,e,n,i,o){const r=function(t,e,n,i){const o=op(t,e,n),r=ip(t,e,i);return{left:o,right:r,symmetric:Math.max(o,r)}}(t,e,n,i);if(!r.left&&!r.right)return[{left:0,right:0,drop:0}];const a=[];return o&&r.left!==r.right&&a.push({left:r.symmetric,right:r.symmetric,drop:0}),a.push({left:r.left,right:r.right,drop:0}),a.push({left:0,right:0,drop:Math.max(0,ap(t)-e)}),a}function cp(t,e){const{viz:n,layoutMargin:i}=t,o=e.getText(n);if(!o)return{panel:null,margin:{}};const a=n.schema[e.paddingMethod](n)?n._padding:{right:0,left:0},s=n[e.textClassKey];s.data([{text:o}]).locale(n.schema.locale).config(n.schema[e.configKey]);const{x:c,width:l,drop:h,boxes:u}=function(t,e,n,i,o,r){const a=e.split(),s=(t,n,i)=>{e.width(n);const o=()=>{const o=e._textData();return{x:t,width:n,drop:i,boxes:o,lines:o[0]?.lines??[],truncated:!o.length||o[0].truncated}};return xn(o(),()=>{e.split(gn(a));const t=o();return e.split(a),t})},c=s(i,r,0).result;if(!c.boxes.length)return c;const l=sp(t,n,i,o,"middle"===c.boxes[0].tA);if(1===l.length)return c;for(const[t,{left:e,right:n,drop:o}]of l.entries()){const{fits:a,result:c}=s(i+e,r-e-n,o);if(a||t===l.length-1)return c}return c}(n,s,i.top,i.left+a.left,i.right+a.right,n.schema.width-(i.left+i.right+a.left+a.right));if(!u.length)return{panel:null,margin:{}};const d=u[0],f=d.lH,m=n.schema[e.configKey]?.padding??0,p=d.lines.length*f+2*m,g=i.top+h+m,y=r.rtl(),x=Br(d,l,y),b=x.lines.map((t,e)=>({...t,y:(e+1)*f-(f-d.fS)}));return{panel:{type:"text",key:e.panelKey,x:0,y:0,lines:b,font:{family:d.fF,size:d.fS,anchor:x.anchor,baseline:"alphabetic",...y?{dir:"rtl"}:{}},paint:{fill:d.fC,opacity:d.fO},transform:{x:c,y:g}},margin:{top:h+p}}}const lp={name:"title",configFields:["title","titleConfig","titlePadding"],layout:t=>cp(t,{panelKey:"viz-title",getText:t=>!!t.schema.title&&t.schema.title(t._filteredData||[]),textClassKey:"_titleClass",configKey:"titleConfig",paddingMethod:"titlePadding"})},hp={name:"subtitle",configFields:["subtitle","subtitleConfig","subtitlePadding"],layout:t=>cp(t,{panelKey:"viz-subtitle",getText:t=>!!t.schema.subtitle&&t.schema.subtitle(t._filteredData||[]),textClassKey:"_subtitleClass",configKey:"subtitleConfig",paddingMethod:"subtitlePadding"})};const up={name:"timeline",configFields:["timeline","timelineConfig","timelinePadding"],layout:({viz:t,layoutMargin:e})=>{let i=t.schema.time&&t.schema.timeline;const o=i?n.unique(t._data.map(t.schema.time)).map(t=>r.date(t)):[];i=i&&o.length>1;const a=t.schema.timelinePadding(t)?t._padding:{right:0,left:0},s={transform:`translate(${e.left+a.left}, 0)`},c=r.elem("g.d3plus-viz-timeline",{condition:i,enter:s,parent:t._select,duration:Zt(t),update:s}).node();if(!i)return{panel:null,margin:{}};const l=t._timelineClass.renderMode("compute").domain(h.extent(o)).duration(Zt(t)).height(t.schema.height-e.bottom).locale(t.schema.locale).select(c).ticks(o.sort((t,e)=>+t-+e)).width(t.schema.width-(e.left+e.right+a.left+a.right)),u=h.extent(o);if(t._timelineSelection)t._timelineSelection[0]<u[0]&&(t._timelineSelection[0]=u[0]),t._timelineSelection[1]>u[1]&&(t._timelineSelection[1]=u[1]);else{const e=h.extent((t._filteredData||[]).flatMap((e,n)=>t.schema.time(e,n)).map(t=>r.date(t)));t._timelineSelection=mm(t)||(e[0]?e:u)}l.selection(t._timelineSelection),l._onPlayToggle=()=>t._scheduleSceneRepaint();const d=sm(t);l.rangeBreaks(!!d.length&&d);const f={...t.schema.timelineConfig};return delete f.selection,l.config(f).on("brush",t=>{f.on&&f.on.brush&&f.on.brush(t)}).on("end",e=>{!function(t,e){if(Array.isArray(e)||(e=[e,e]),JSON.stringify(e)!==JSON.stringify(t._timelineSelection)){t._timelineSelection=e;const n=e.map(Number);t.timeFilter(e=>{const i=r.date(t.schema.time(e)).getTime();return i>=n[0]&&i<=n[1]}).render()}}(t,e),f.on&&f.on.end&&f.on.end(e)}).render(),ea(c,"d3plus-viz-timeline",l._buttonBehaviorCurrent),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},dp={name:"total",configFields:["total","totalConfig","totalFormat","totalPadding"],layout:t=>cp(t,{panelKey:"viz-total",getText:t=>{const e=t._filteredData||[],n="function"==typeof t.schema.total?h.sum(e.map(t.schema.total)):!(!0!==t.schema.total||!t._size)&&h.sum(e.map(t._size));return!!n&&t.schema.totalFormat(n)},textClassKey:"_totalClass",configKey:"totalConfig",paddingMethod:"totalPadding"})};function fp(t,e,n){return t.schema.minimapClassName&&e===n?{}:e||{}}function mp(t,...e){const n=new Set;for(const t of e)for(const e of Object.keys(t))n.add(e);for(const e of n)t.style.removeProperty(Wh(e));for(const n of e)for(const e in n){const i=n[e];null!=i&&!1!==i&&t.style.setProperty(Wh(e),String(i))}}function pp(t){const e=t.schema.minimapClassName?` ${t.schema.minimapClassName}`:"";return`<div class="d3plus-minimap-viewport${e}" tabindex="0" role="application" aria-label="${t.schema.translate("Pan viewport — drag or use arrow keys")}"></div><div class="d3plus-minimap-label${e}"></div>`}function gp(t){const e=function(t){return t._zoomEventTarget||t._container}(t)?.node();return e?_.zoomTransform(e):_.zoomIdentity}function yp(t){const e=t._plotZoomBase?.scales;return e?{x:Boolean(e.x||e.x2),y:Boolean(e.y||e.y2)}:{x:!0,y:!0}}const xp={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function bp(t,e,n,i,o){const[[r,a],[s,c]]=t._zoomBehavior.translateExtent(),l=yp(t),h=gp(t);Nu(t,i,l.x?(r+s)/2-e*i:h.x,l.y?(a+c)/2-n*i:h.y,o)}function _p(t,e,n,i,o){const[[r,a],[s,c]]=t._zoomBehavior.translateExtent();return[r+i/e*(s-r),a+o/n*(c-a)]}function kp(t,e,n,i,o,r){const a=r.parentElement,s=a?.querySelector(".d3plus-minimap-label");if(!a||!s)return;const c=gp(t),l=c.k>1;if(mp(a,i.outer),mp(a,{position:"absolute","box-sizing":"border-box",overflow:"hidden",opacity:l?"1":"0","pointer-events":l?"auto":"none",transition:`opacity ${Zt(t)}ms`}),!l)return;const[[h,u],[d,f]]=t._zoomBehavior.translateExtent(),m=d-h,p=f-u,g=Math.min(1,1/c.k),y=yp(t),x=y.x?g:1,b=y.y?g:1,_=(h-c.x)/c.k,k=(u-c.y)/c.k,v=Math.max(0,Math.min(1-x,m?(_-h)/m:0)),w=Math.max(0,Math.min(1-b,p?(k-u)/p:0));mp(r,i.viewport,o.dragging?i.viewportActive:{}),mp(r,{position:"absolute","box-sizing":"border-box","touch-action":"none",left:v*e+"px",top:w*n+"px",width:`${Math.max(1,x*e)}px`,height:`${Math.max(1,b*n)}px`}),mp(s,i.label),mp(s,{position:"absolute"}),s.textContent=function(t){const e=Math.round(10*t)/10;return`${e%1==0?e.toFixed(0):e.toFixed(1)}x`}(c.k)}function vp(t,e,n,i,o){const r=t=>t.target?.closest(".d3plus-minimap-viewport"),a=t=>{if(t.pointerId!==i.dragPointerId)return;i.dragging=!1;const e=r(t);e&&o(e)};return{pointerdown:e=>{const n=e,a=r(e);if(!a)return;try{a.setPointerCapture(n.pointerId)}catch{}i.dragging=!0,i.dragPointerId=n.pointerId;const s=gp(t);i.dragStart={x:n.clientX,y:n.clientY,tx:s.x,ty:s.y,k:s.k},o(a),e.preventDefault()},pointermove:n=>{const o=n;if(!i.dragging||o.pointerId!==i.dragPointerId)return;const[[r],[a]]=t._zoomBehavior.translateExtent(),s=(a-r)/e,c=yp(t),l=c.x?(o.clientX-i.dragStart.x)*s*i.dragStart.k:0,h=c.y?(o.clientY-i.dragStart.y)*s*i.dragStart.k:0;Nu(t,i.dragStart.k,i.dragStart.tx-l,i.dragStart.ty-h,0)},pointerup:a,pointercancel:a,keydown:n=>{const i=n,o=xp[i.key];if(!o)return;i.preventDefault();const[[r],[a]]=t._zoomBehavior.translateExtent(),s=(a-r)/e,c=i.shiftKey?40:10,l=gp(t),h=yp(t),u=h.x?o[0]*c*s*l.k:0,d=h.y?o[1]*c*s*l.k:0;Nu(t,l.k,l.x-u,l.y-d,Zt(t))}}}function wp(t,e,n){return{click:i=>{const o=i.target;if(o?.closest(".d3plus-minimap-viewport"))return;const r=o?.closest(".d3plus-minimap");if(!r)return;const a=i,s=r.getBoundingClientRect(),[c,l]=_p(t,e,n,a.clientX-s.left,a.clientY-s.top);bp(t,c,l,gp(t).k,Zt(t))},dblclick:e=>{e.preventDefault(),Nu(t,1,0,0)},wheel:i=>{const o=i;if(!o.ctrlKey&&!o.metaKey)return;o.preventDefault();const r=i.target?.closest(".d3plus-minimap");if(!r)return;const a=r.getBoundingClientRect(),[s,c]=_p(t,e,n,o.clientX-a.left,o.clientY-a.top),l=o.deltaY<0?t.schema.zoomFactor:1/t.schema.zoomFactor;bp(t,s,c,gp(t).k*l,0)}}}function Mp(t,e,n,i){const o=function(t){const e=t,n=(t,e)=>X(t.text,e);return{outer:vf(e,fp(t,t.schema.minimapStyle,Ch),Ch,{background:t=>t.background,border:t=>`1px solid ${t.border}`}),viewport:vf(e,fp(t,t.schema.minimapViewportStyle,$h),$h,{background:t=>n(t,.15),border:t=>`1px solid ${n(t,.5)}`}),viewportActive:vf(e,fp(t,t.schema.minimapViewportStyleActive,Ah),Ah,{background:t=>n(t,.25)}),label:vf(e,fp(t,t.schema.minimapLabelStyle,zh),zh,{color:t=>t.text})}}(t),r={dragging:!1,dragPointerId:null,dragStart:{x:0,y:0,tx:0,ty:0,k:1}},a=i=>kp(t,e,n,o,r,i),s=t.schema.minimapClassName?` ${t.schema.minimapClassName}`:"";return{type:"htmlOverlay",key:"viz-minimap",x:t.schema.width-4-e,y:i+4,width:e,height:n,className:`d3plus-minimap${s}`,html:pp(t),events:{".d3plus-minimap-viewport":vp(t,e,0,r,a),".d3plus-minimap":wp(t,e,n)},onUpdate:t=>{const e=t.querySelector(".d3plus-minimap-viewport");e&&a(e)}}}const Sp={name:"minimap",layout:({viz:t})=>{if(!(t.schema.zoom&&t.schema.minimap&&t._container&&t._zoomBehavior&&au(t)))return{panel:null,margin:{}};const e=cu(t);if(!e)return{panel:null,margin:{}};const n=kt(t),i=t._zoomHeight||n.height,o=t._zoomWidth||n.width;if(!o||!i)return{panel:null,margin:{}};const r=e.width-4;return{panel:Mp(t,r,r*(i/o),e.height),margin:{}}}};function Cp(t,e,n){const{width:i,height:o}=kt(t);return{bounds:e??{x:t._margin.left,y:t._margin.top,width:i,height:o},obstacles:fc(t._chartScene||[],t._chartTransform,n)}}const $p=12*1.4+5;function Ap(t){const e=Ys("column",{width:t.schema.width||0,height:t.schema.height||0}),n=e.width*e.height,i=function(t,e=1/0){const n=j(t.schema.legend);if(n&&!n.value)return 0;const{colorOf:i,keyOf:o}=xm(t),r=new Set,a=t._legendData||[],s=Boolean(t.schema.colorScale);let c=0;for(let n=0;n<a.length&&r.size<=e;n++){const e=a[n];s&&void 0!==t.schema.colorScale(e,n)||(r.add(o(e,c,i(e,c))),c++)}return r.size}(t,Math.floor(n/475.2399999999999)+1);return i*$p*$p<=n}function zp(t,e){return"auto"===e.bind(t)(ym(t))}const Dp={sizeLegend:["column"],legend:["column","row"],colorScale:["column","row"]};function Lp(t,e,n,i,o){if("sizeLegend"===e){const e=uu(t);return e?{width:e.width,height:e.height}:null}return"legend"===e?wm(t,n,i,o()):Um(t,n,i)}const Fp=[{alignX:"right",alignY:"bottom"},{alignX:"right",alignY:"top"},{alignX:"left",alignY:"bottom"},{alignX:"left",alignY:"top"}];function Np(t,e,n,i){const o=.5,r=t.filter(t=>t.width>=n&&t.height>=i);if(!r.length)return null;const a=t=>({right:Math.abs(t.x+t.width-(e.x+e.width))<o,left:Math.abs(t.x-e.x)<o,bottom:Math.abs(t.y+t.height-(e.y+e.height))<o,top:Math.abs(t.y-e.y)<o}),s=(t,e,o)=>({x:"right"===e?t.x+t.width-n:"left"===e?t.x:t.x+(t.width-n)/2,y:"bottom"===o?t.y+t.height-i:"top"===o?t.y:t.y+(t.height-i)/2,width:n,height:i,alignX:e,alignY:o});for(const{alignX:t,alignY:e}of Fp){const n=r.find(n=>{const i=a(n);return i[t]&&i[e]});if(n)return s(n,t,e)}const c=r[0],l=a(c);return s(c,l.right?"right":l.left?"left":"center",l.bottom?"bottom":l.top?"top":"middle")}function Bp(t){const e=t._insetRegion?.();if(!e)return null;const{padding:n}=Is(t),i=e.bounds,o={x:i.x+n,y:i.y+n,width:i.width-2*n,height:i.height-2*n};if(o.width<=0||o.height<=0)return null;const r=function(t){const e=[],{width:n,height:i}=kt(t),o=cu(t);if(o){const r=t.schema.minimap?(o.width-4)*(i/Math.max(1,n)):0;e.push({x:t.schema.width-o.width,y:0,width:o.width,height:o.height+r})}const r=Jf(t,nm(t));if(r&&e.push({x:0,y:0,width:r.width,height:r.height}),t.schema.attribution){const i=t._select?.node?.()?.parentNode,o=i?.querySelector?.("div.d3plus-attribution"),r=String(t.schema.attribution).replace(/<[^>]*>/g,""),a=Math.min(o?.offsetWidth||6*r.length+30,n/2),s=o?.offsetHeight||22,c=t.schema.width-t._margin.right,l=t.schema.height-t._margin.bottom;e.push({x:c-a,y:l-s,width:a,height:s})}return e}(t);return{rects:f.negativeSpace(o,e.obstacles,{padding:n,exclude:r}),bounds:o,area:i}}function Ep(t,e){const n=e.filter(e=>function(t,e){return"sizeLegend"===e?Boolean(uu(t)?.inset):"legend"===e?Boolean(t._legendClass?._data?.length):Boolean($s(t))&&!1!==tp(t.schema.colorScalePosition.bind(t)(ym(t)),t)&&!t.schema.colorScaleConfig.select}(t,e)),i=n.length?Bp(t):null;if(!i||!i.rects.length)return{placement:null,showing:n};const{margin:o}=Is(t);let r;const a=()=>r??(r=bm(t));for(const e of n)for(const r of Dp[e]){const s=Lp(t,e,r,i.area,a),c=s&&Np(i.rects,i.bounds,s.width+2*o,s.height+2*o);if(c)return{placement:{key:e,orient:r,...c},showing:n}}return{placement:null,showing:n}}function Rp(t,e){t._margin={...e.margin},t._padding={...e.padding},t._draw()}function Pp(t){t._insetPlacement=null;const e="function"==typeof t._insetRegion&&function(t){const e=t.schema.legendInset;return"function"==typeof e?Boolean(e.bind(t)(ym(t))):Boolean(e)}(t)?function(t){return js.filter(e=>"legend"===e?zp(t,t.schema.legendPosition)&&Ap(t):"colorScale"!==e||zp(t,t.schema.colorScalePosition))}(t):[];if(!e.length)return t._insetPending=null,void t._draw();const n={margin:{...t._margin},padding:{...t._padding}};t._insetPending=new Set(e),t._draw();const i=Ep(t,e),{showing:o}=i;let{placement:r}=i;if(o.length){if(r&&o.some(t=>t!==r.key)&&(t._insetPending=new Set([r.key]),Rp(t,n),r=Ep(t,[r.key]).placement),!r)return t._insetPending=new Set,void Rp(t,n);t._insetPlacement=r}}function Tp(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n][0]-t[n-1][0],t[n][1]-t[n-1][1]);return e}function Op(t,e=.02){if(t.length<2)return t;const[n,i]=t[0],[o,r]=t[t.length-1],a=o-n,s=r-i;return(Math.abs(a)<Math.abs(s)*e?s>0:a<0)?[...t].reverse():t}function Wp(t,e){if(t.length<2||!e)return t;const n=t.slice(1).map((e,n)=>((t,e)=>{const n=Math.hypot(e[0]-t[0],e[1]-t[1])||1;return[(e[1]-t[1])/n,-(e[0]-t[0])/n]})(t[n],e));return t.map((i,o)=>{const r=o>0?n[o-1]:null,a=o<t.length-1?n[o]:null,s=r&&a?[r[0]+a[0],r[1]+a[1]]:r??a,c=Math.hypot(s[0],s[1])||1;return[i[0]+s[0]/c*e,i[1]+s[1]/c*e]})}function Hp(t,e,n){const i=[];let o=0;for(let r=1;r<t.length;r++){const[a,s]=t[r-1],[c,l]=t[r],h=Math.hypot(c-a,l-s),u=o+h,d=t=>{const e=h?(t-o)/h:0;return[a+(c-a)*e,s+(l-s)*e]};if(u>=e&&o<=n){if(i.length||i.push(d(Math.max(e,o))),!(u<=n)){i.push(d(n));break}i.push([c,l])}o=u}return i}class jp{seek(t){const{cum:e}=this,n=this.points.length;let i=this.i;if(i>1&&e[i-1]>=t){let n=1,o=i-1;for(;n<o;){const i=n+o>>1;e[i]>=t?o=i:n=i+1}i=n}for(;i<n&&e[i]<t;)i++;return this.i=i,i}trim(t,e){const{points:n,cum:i}=this,o=[];for(let r=this.seek(t);r<n.length;r++){const[a,s]=n[r-1],[c,l]=n[r],h=Math.hypot(c-a,l-s),u=i[r-1],d=i[r],f=t=>{const e=h?(t-u)/h:0;return[a+(c-a)*e,s+(l-s)*e]};if(d>=t&&u<=e){if(o.length||o.push(f(Math.max(t,u))),!(d<=e)){o.push(f(e));break}o.push([c,l])}}return o}at(t){const e=this.seek(t);if(e>=this.points.length||!(this.cum[e-1]<=t))return;const[n,i]=this.points[e-1],[o,r]=this.points[e],a=Math.hypot(o-n,r-i),s=this.cum[e-1],c=a?(Math.max(t,s)-s)/a:0;return[n+(o-n)*c,i+(r-i)*c]}constructor(t){this.points=t,this.i=1;const e=[0];let n=0;for(let i=1;i<t.length;i++)n+=Math.hypot(t[i][0]-t[i-1][0],t[i][1]-t[i-1][1]),e.push(n);this.cum=e,this.length=n}}function Ip(t){const e=t=>Math.round(100*t)/100;return t.map(([t,n],i)=>`${i?"L":"M"}${e(t)},${e(n)}`).join("")}function Gp(t,e,n){return t.map(t=>"group"===t.type?{...t,children:Gp(t.children,e,n)}:"text"!==t.type?t:{...t,halo:!0,paint:{...t.paint,stroke:e,strokeWidth:n,strokeOpacity:1}})}function qp(t,e,n={},i={}){if(!e.length)return[];const o=Boolean(t._theme?.dark),r=(new Ir).renderMode("compute").locale(t.schema.locale).data(e.map(t=>({...t,id:t.key}))).config({fontSize:11,fontWeight:600,fontColor:t=>po(t.color,o),text:t=>t.text,textAnchor:t=>t.anchor,textPath:t=>t.d,truncateWord:!0,x:0,y:0,...n}).toScene().children;return(!1===i.halo?r:Gp(r,Os(t),3)).map(t=>{const e=t.datum;return{...t,interactive:!1,datum:e?.datum,index:e?.index??t.index,aria:{hidden:!0}}})}const Vp=new WeakMap,Yp=new WeakSet,Kp=t=>t instanceof Date?String(t.getTime()):String(t);function Up(t){if("function"==typeof t)return t;if("string"==typeof t&&t){const e=q(t);return Vp.set(e,{key:t}),e}}function Xp(t,e){return Vp.set(t,{text:e}),t}function Zp(t,e,i,o={}){const r=new Map;for(const n of t){if(!n.data)continue;const t=Kp(n[e]),i=r.get(t);i?i.data.push(n.data):r.set(t,{value:n[e],data:[n.data]})}return Array.from(r.values(),({value:t,data:e})=>{const r=1===e.length?e[0]:n.merge(e,o);return{value:t,size:Number(i(r,0)),data:r}})}function Qp(t){let e=0;return t.filter(t=>Number.isFinite(t.size)&&t.size>0).map(t=>{const n=e+t.size,i={...t,start:e,end:n,mid:(e+n)/2};return e=n,i})}function Jp(t,e,n){const i=t.schema.barWidth,o=t.schema.discrete,r=t._discreteExtent&&!Yp.has(t._discreteExtent);if("function"!=typeof i||"x"!==o&&"y"!==o||r)return function(t){t._barSpans=void 0,t._discreteExtent&&Yp.has(t._discreteExtent)&&(t._discreteExtent=void 0)}(t),[e,n];const a=Zp(n,o,i,t.schema.aggs),s=t.schema[`${o}Sort`];s&&a.sort((t,e)=>s(t.data,e.data));const c=Qp(a),l=new Map(c.map(t=>[Kp(t.value),t])),h=new WeakMap,u=t=>t.filter(t=>{const e=l.get(Kp(t[o]));return!!e&&(t.data&&h.set(t.data,e),t[o]=e.mid,!0)}),d=u(e),f=n===e?d:u(n),m=c.length?c[c.length-1].end:0,p={axis:o,spans:c,total:m,byDatum:h};t._barSpans=p,"x"===o?t._xTime=!1:t._yTime=!1;const g=t=>{const e=p.byDatum.get(t);return e?[e.start,e.end]:[0,0]};return Yp.add(g),t._discreteExtent=g,[d,f]}function tg(t){return t instanceof Date?d.formatDate(t,[t]):String(t)}function eg(t,e,n){return t.total?`${d.formatAbbreviate(e.size/t.total*100,n)}%`:""}function ng(t,e,n){const i=eg(e,n,t.schema.locale),o=t.schema.barWidthShareFormat;if("function"!=typeof o||!n.data)return i;const r=e.total?n.size/e.total:0,a=o(n.data,{share:r,size:n.size,total:e.total,text:i});return null==a?"":String(a)}function ig(t,e,n){return e?"x"===n?`${t}\n${e}`:`${t} (${e})`:t}function og(t){const e=t._barSpans;if(e&&"opposite"===t.schema.barWidthShare)return"x"===e.axis?"x2":"y2"}function rg(t,e){const n=t._barSpans;if(!n||og(t)!==e)return{};const i=n.spans.map(t=>t.mid),o=new Map(n.spans.map(e=>[e.mid,ng(t,n,e)]));return{barConfig:{"stroke-width":0},gridSize:0,labels:i,tickFormat:t=>o.get(t)??"",tickSize:0,ticks:i,title:!1}}function ag(t,e){const n=t._barSpans;if(!n||n.axis!==e)return{};const i=n.spans.map(t=>t.mid),o=new Map(n.spans.map(t=>[t.mid,tg(t.value)])),r=t=>o.get(t)??"";if(!0!==t.schema.barWidthShare)return{labels:i,ticks:i,tickFormat:r};const a=new Map(n.spans.map(i=>[i.mid,ig(tg(i.value),ng(t,n,i),e)]));return{labels:i,ticks:i,tickFormat:t=>a.get(t)??"",rotatedTickFormat:r}}function sg(t){const e=t.schema.barWidth,n=e?Vp.get(e):void 0;return n?.key?n.key:t.schema.translate(n?.text??"Width")}function cg(t,e){const n=t._barSpans,i=n&&e&&"object"==typeof e?n.byDatum.get(e):void 0;if(!n||!i)return[];const o=t.schema.locale,r=eg(n,i,o);return[[sg(t),`${d.formatAbbreviate(i.size,o)}${r?` (${r})`:""}`]]}const lg=t=>t._swarm?t._swarm.axis:"y"===t.schema.discrete?"x":"y";function hg(t){return!(!Array.isArray(t)||t.length>2)&&(void 0===t[0]||null===t[0])!=(void 0===t[1]||null===t[1])}function ug(t,e){if("x"!==e&&"y"!==e)return;const n=t[`_${e}Config`]?.domain;if(!hg(n)||!((t,e)=>t.schema.discrete!==e&&!t.schema[`${e}Sort`]&&t._swarm?.cross!==e)(t,e))return;const i=n.slice();return"y"===e&&2===i.length?i.reverse():i}const dg=(t,e)=>ug(t,e)??t.schema[`${e}Domain`];function fg(t){const e=t._userBaseline;if("number"!=typeof e||!Number.isFinite(e))return;const n=lg(t);if(t[`_${n}Time`]||t.schema[`${n}Sort`])return;const i=t[`_${n}Config`];return"log"===i?.scale&&e<=0?void 0:n}function mg(t,e){return Boolean(dg(t,e))||fg(t)===e}function pg(t,e){const n=t[`_${e}Config`]?.domain;return Array.isArray(n)&&n.some(t=>null!=t)&&!hg(n)}function gg(t,e,n){return pg(t,e)?"none":n}function yg(t,e,n){const i=t[`_${e}Config`]?.rounding;return i??gg(t,e,n)}function xg(t,e){const n=t[`_${e}Config`]?.domain;if(void 0!==n&&!ug(t,e))return!1;const i=dg(t,e);return i?hg(i):fg(t)===e}function bg(t,e){const n=t[`_${e}Config`]??{};if(!xg(t,e))return n;const i={...n};return delete i.rounding,ug(t,e)&&delete i.domain,i}function _g(t,e,n){const i=dg(t,e),o=i?i.slice():void 0;if(fg(t)!==e)return o;const r=t._userBaseline,a=n?.[1],s="number"==typeof a&&a<=r?1:0,c=o??[];return void 0===c[s]&&(c[s]=r),c}function kg(t,e){const n=t.schema[`${e}Break`],i={break:void 0!==n&&n},o=bg(t,e),r={...ag(t,e),...t._plotAxisDefaults?.[e]};if(!Object.keys(r).length)return{...i,...o};const a=Object.fromEntries(Object.entries(o).filter(([,t])=>void 0!==t));return ct({...i,...r},a)}function vg(t,e){const n=Boolean(t.schema.baselineBreak)&&lg(t)===e,{baseline:i}=t.schema;return"number"==typeof i?{baseline:i,baselineBreak:n}:{baselineBreak:n}}function wg(t,e,n,i=t.schema[`${e}Domain`]){if(!t.schema.baselineBreak||e!==lg(t)||"linear"!==n)return!1;const{baseline:o}=t.schema;if("number"!=typeof o||!Array.isArray(i))return!1;const[r,a]=i;return"number"==typeof r&&r>o||"number"==typeof a&&a<o}function Mg(t,e){const n="y"===lg(t),i=(n?t._yAxis:t._xAxis)?._baselineBreak,o=n?t._yFunc:t._xFunc;if(!i||!o)return e;const r=o(i.edge),a=o(i.value);if(!Number.isFinite(r)||!Number.isFinite(a))return e;const s=n?1:0;return e.map(t=>(t[s]-r)*(a-r)<=0?t:n?[t[0],r]:[r,t[1]])}function Sg(t,e){const n="y"===lg(t),i=n?t._yAxis:t._xAxis;if(!i||"function"!=typeof i._getRange)return;const o=i._getRange().map(Number);if(o.length<2||o.some(t=>!Number.isFinite(t)))return;const r=n?e.x2Height:0,a=n?e.yOffset:0;return[Math.min(o[0],o[o.length-1])-r-a,Math.max(o[0],o[o.length-1])-r]}function Cg(t,e,n){if(!n)return t;const[i,o]=n,r=t=>"number"==typeof t&&Number.isFinite(t)?Math.min(o,Math.max(i,t)):t,a=Object.assign({},t);for(const t of[e,`${e}0`,`${e}1`]){const e=a[t];if("function"==typeof e){const n=e;a[t]=function(...t){return r(n.apply(this,t))}}else"number"==typeof e&&(a[t]=r(e))}return a}function $g(t){return"along"===t?[]:"both"===t?["start","end"]:"start"===t?["start"]:t?["end"]:[]}function Ag(t,e,n){return $g("function"==typeof t?t(e,n):t)}function zg(t,e,n,i,o){if(!t?.value||null==e)return;const r=t.valueFormat?t.valueFormat(e,n,i):o(e);return null==r||""===r?void 0:`${r}`}function Dg(t,e){return void 0===e?`${t}`:`${t} ${e}`}function Lg(t,e){return"start"===t?`start:${e}`:`${e}`}class Fg{static key(t,e){return 1048576*t+e}add(t,e=-1){for(const[n,i]of t){const t=Fg.key(Math.floor(n/this.cell),Math.floor(i/this.cell)),o=this.cells.get(t);o?o.push([n,i,e]):this.cells.set(t,[[n,i,e]])}}nearest(t,e){const n=Math.floor(t[0]/this.cell),i=Math.floor(t[1]/this.cell);let o=1/0;for(let r=-1;r<=1;r++)for(let a=-1;a<=1;a++){const s=this.cells.get(Fg.key(n+r,i+a));if(s)for(const[n,i,r]of s){if(-1!==r&&r===e)continue;const a=t[0]-n,s=t[1]-i,c=a*a+s*s;c<o&&(o=c)}}return Math.sqrt(o)}constructor(t){this.cell=t,this.cells=new Map}}function Ng(t,e){const n=new jp(t),i=[];for(let t=0;t<=n.length;t+=e){const e=n.at(t);e&&i.push(e)}return i}function Bg(t){let e=0,n=null;for(let i=1;i<t.length;i++){const o=t[i][0]-t[i-1][0],r=t[i][1]-t[i-1][1];if(!o&&!r)continue;const a=Math.atan2(r,o);if(null!==n){let t=Math.abs(a-n);t>Math.PI&&(t=2*Math.PI-t),e+=t}n=a}return e}function Eg(t,e){return Rg.flatMap(n=>Pg(t,e,n))}const Rg=[0,.35,.7];function Pg(t,e,n){const i=Math.max(2,e.fontSize/2);return Ng(Wp(t,e.lift+n*e.fontSize),i)}function Tg(t,e){const{rect:n,minClearance:i=2}=e;let o=1/0;for(const r of Rg)for(const a of Pg(t,e,r)){if(a[0]<n.x0||a[0]>n.x1||a[1]<n.y0||a[1]>n.y1)return null;if(o=Math.min(o,e.grid.nearest(a,e.ignore)),o<i)return null}const[r,a]=t[0],[s,c]=t[t.length-1],l=Math.abs(Math.atan2(c-a,s-r)),{roomReach:h=e.fontSize,roomWeight:u=.5}=e,d=Math.min(o,h)/h;return 2*Bg(t)+.5*l-d*u}function Og(t,e,n,i){let o=null,r=1/0;const a=Math.max(4,n.fontSize/2),s=n.maxTurn??Math.PI/2;for(let c=0;c<t.length;c++){const l=new jp(t[c]);for(let t=0;t+e<=l.length;t+=a){if(i&&!i(t,c))continue;const a=Op(l.trim(t,t+e),n.steep);if(Bg(a)>s)continue;const h=Tg(a,n);null!==h&&h<r&&(r=h,o={points:a,piece:c,from:t})}}return o}function Wg(t,e,n){return Og(t,e,n)?.points??null}function Hg(t,e="Line"){const n=Hm(t,e).labelConfig??{},i={};for(const t of["fontFamily","fontSize","fontWeight"])void 0!==n[t]&&"function"!=typeof n[t]&&(i[t]=n[t]);return i}function jg(t,e,n){const i=t.schema.lineLabels;if(!i)return[];const o=function(t){const e=[],n=(t,i,o)=>{const r=t.transform??{},s=i+(r.x??0),c=o+(r.y??0);"group"===t.type&&t.children.forEach(t=>n(t,s,c));const l=t.datum;if("path"!==t.type||"Line"!==t.shapeType||`${t.key}`.endsWith("::hit")||"Line"!==l?.shape)return;const h=(t.d.match(/M[^M]*/g)??[]).map(t=>a.samplePath(t).points.map(([t,e])=>[t+s,e+c])).filter(t=>t.length>1),u=t.paint?.stroke;e.push({row:l,key:`${t.key}`,color:`${u??"#444"}`,pieces:h})};return t.forEach(t=>n(t,0,0)),e}(e),c=o.filter(t=>function(t,e,n){return"along"===("function"==typeof t?t(e,n):t)}(i,t.row.data??t.row,t.row.i??0)),l=t._alongStats;if(l&&(l.series+=o.length,l.requested+=c.length),!c.length||o.length<2)return[];const h=Hg(t),u=h.fontSize??11,d={"font-family":r.fontExists(h.fontFamily??s.fontFamily),"font-size":u,"font-weight":h.fontWeight??600},f=new Fg(u);for(const t of o)for(const e of t.pieces)f.add(Ng(e,2));const m={grid:f,rect:n,fontSize:u,lift:3.5},p=new Set,g=c.flatMap(e=>{const n=`${t._drawLabel(e.row,e.row.i??0)}`;if(p.has(n))return l&&l.placed++,[];const i=r.textWidth(n,d)+u,o=Wg(e.pieces,i,m);return o?(f.add(Eg(o,m)),p.add(n),l&&l.placed++,[{key:`line-label-along-${e.key}`,text:n,d:Ip(Wp(o,m.lift)),color:e.color,anchor:"middle"}]):[]});return qp(t,g,h)}function Ig(t){return"inside"!==t&&"outside"!==t}function Gg(t,e=0,n=3){if(t.length<3)return[];const i=e?0:1;let o=1/0,r=-1/0;for(const n of t)o=Math.min(o,n[e]),r=Math.max(r,n[e]);if(!(r>o))return[];const a=Math.ceil((r-o)/n),s=(r-o)/a,c=new Array(a+1).fill(1/0),l=new Array(a+1).fill(-1/0),h=(t,e)=>{c[t]=Math.min(c[t],e),l[t]=Math.max(l[t],e)};for(let n=1;n<t.length;n++){const r=t[n-1],a=t[n],c=a[e]-r[e],l=Math.ceil((Math.min(r[e],a[e])-o)/s-1e-9),u=Math.floor((Math.max(r[e],a[e])-o)/s+1e-9);for(let t=l;t<=u;t++)if(c){const n=(o+t*s-r[e])/c;h(t,r[i]+n*(a[i]-r[i]))}else h(t,r[i]),h(t,a[i])}const u=[];return c.forEach((t,n)=>{if(t>l[n])return;const i=(t+l[n])/2,r=o+n*s;u.push({point:e?[i,r]:[r,i],thickness:l[n]-t})}),u}function qg(t,e){const n=[];let i=[];for(const o of t)o.thickness>=e?i.push(o.point):(i.length>1&&n.push(i),i=[]);return i.length>1&&n.push(i),n}function Vg(t,e){const n=t.slice(0,1);for(let i=1;i<t.length;i++){const[o,r]=t[i-1],[a,s]=t[i],c=Math.ceil(Math.hypot(a-o,s-r)/e);for(let t=1;t<=c;t++)n.push([o+(a-o)*t/c,r+(s-r)*t/c])}return n}function Yg(t={}){const e=t=>"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0,n=e(t.fontSize)??e(t.fontMax)??16,i=Math.max(e(t.fontMin)??0,8),o=Math.min(n,i),r=[];for(let t=n;t>=o;t--)r.push(t);return r[r.length-1]!==o&&r.push(o),r}function Kg(t,n,i,o,r){const a="function"==typeof t?t(n,i):t;return"string"==typeof a&&a?a:e.colorContrast(o,r)}function Ug(t,e,n){const i="function"==typeof t?t(e,n):t;return"number"==typeof i||"string"==typeof i&&i?i:400}function Xg(t,e,n,i,o=0){const r=t.map(t=>Gg(t,o)),a=Math.max(0,...r.flat().map(t=>t.thickness));if(!n.length)return null;const s=new Fg(1.5*Math.max(...n));for(const e of t)s.add(Vg(e,2));for(const t of n){const n=t+4;if(n>a)continue;const c=r.flatMap(t=>qg(t,n)),l={grid:s,rect:i,fontSize:t,lift:-.3*t,minClearance:.2*t+2,roomReach:1.5*t,roomWeight:1.5,steep:o?Math.tan(25*Math.PI/180):void 0},h=Wg(c,e(t)+t,l);if(h)return{points:Wp(h,l.lift),fontSize:t}}return null}function Zg(t,e,n){if(e>=1)return t;const o=i.rgb(t),r=i.rgb(n);if(Number.isNaN(o.r)||Number.isNaN(r.r))return t;const a=(t,n)=>t*e+n*(1-e);return i.rgb(a(o.r,r.r),a(o.g,r.g),a(o.b,r.b)).formatHex()}function Qg(t,e,n){if(!t.schema.stacked)return[];const i=function(t,e){const n=[],i=(t,o,r)=>{const s=t.transform??{},c=o+(s.x??0),l=r+(s.y??0);if("group"===t.type&&t.children.forEach(t=>i(t,c,l)),"path"!==t.type||"Area"!==t.shapeType||!t.datum||`${t.key}`.endsWith("::hit"))return;const h=(t.d.match(/M[^M]*/g)??[]).map(t=>a.samplePath(t).points.map(([t,e])=>[t+c,e+l])).filter(t=>t.length>2),u=t.paint??{},d=("number"==typeof u.fillOpacity?u.fillOpacity:1)*("number"==typeof u.opacity?u.opacity:1);n.push({datum:t.datum,index:t.index??0,key:`${t.key}`,outlines:h,fill:Zg(`${u.fill??"#444"}`,d,e)})};return t.forEach(t=>i(t,0,0)),n}(e,Os(t));if(!i.length)return[];const o=Hm(t,"Area"),{fontColor:c}=jm(t,"Area"),l=Hg(t,"Area"),h=o.labelConfig??{},u=Yg(h),d=r.fontExists(l.fontFamily??s.fontFamily),f="y"===t.schema.discrete?1:0,m=t.schema.labelPosition,p=t._alongStats;p&&(p.series+=i.length);const g=i.flatMap(e=>{const i=e.datum.data??e.datum;if(!Ig("function"==typeof m?m(i,e.index):m))return[];const a=function(t,e,n){let i="function"==typeof t?t(e,n):t;return Array.isArray(i)&&(i=i[0]),!1===i||null==i||""===i?null:`${i}`}(o.label,e.datum,e.index);if(!a)return[];p&&p.requested++;const s=Ug(h.fontWeight,e.datum,e.index),l={"font-family":d,"font-weight":s},g=Xg(e.outlines.map(e=>Mg(t,e)),t=>r.textWidth(a,{...l,"font-size":t}),u,n,f);return g?(p&&p.placed++,[{key:`area-label-along-${e.key}`,text:a,d:Ip(g.points),color:Kg(c,e.datum,e.index,e.fill,t.schema.colorDefaults),anchor:"middle",datum:e.datum,index:e.index,fontSize:g.fontSize,fontWeight:s}]):[]});return qp(t,g,{...l,fontColor:t=>t.color,fontSize:t=>t.fontSize,fontWeight:t=>t.fontWeight},{halo:!1})}function Jg(t,e){return(n,i)=>{const o=n,r=o.__d3plus__&&o.data?o.data:n,a="number"==typeof o.i?o.i:i,s=t.schema.labelPosition;return!Ig("function"==typeof s?s(r,a):s)&&("function"==typeof e?e(n,i):e)}}function ty(t){if(t.schema.legend!==t._defaultLegend)return!1;if(t._hidden?.length||t._solo?.length)return!1;const e=t.schema.lineLabels;return"along"===e||"function"==typeof e||function(t){if(!t.schema.stacked)return!1;const e=t.schema.shape,n=t._filteredData?.[0]??{};if("Area"!==("function"==typeof e?e(n,0):e))return!1;const i=t.schema.labelPosition;return"function"==typeof i||Ig(i)}(t)||Boolean(t._alongLabelsPossible?.(t))}function ey(t,e,n){if(t<=0||e<=0)return 0;const i=Math.min(t,e*n);return i*(i/n)}function ny(t,e,n){if(t<=0)return{columns:0,rows:0};const{columns:i,rows:o}=n;if(i)return{columns:Math.min(i,t),rows:Math.max(o??0,Math.ceil(t/i))};if(o){const e=Math.ceil(t/o);return{columns:e,rows:Math.ceil(t/e)}}const r=n.gutter??{left:0,right:0,bottom:0};let a={columns:1,rows:t},s=-1,c=1/0,l=1/0;for(let i=1;i<=t;i++){const o=Math.ceil(t/i),h=(e.width-r.left-r.right-(i-1)*(n.columnPadding??n.padding))/i,u=(e.height-r.bottom-(o-1)*n.padding)/o-n.titleHeight,d=ey(h,u,n.aspect),f=i*o-t,m=u>0?Math.abs(Math.log(h/u/n.aspect)):1/0;(d>1.01*s||d>=.99*s&&(f<c||f===c&&m<l))&&(a={columns:i,rows:o},s=Math.max(d,s),c=f,l=m)}return a}function iy(t,e,n){const{columns:i,rows:o}=ny(t,e,n);if(!i)return[];const r=n.gutter??{left:0,right:0,bottom:0},a=n.padding,s=n.columnPadding??a,c=Math.max(0,(e.width-r.left-r.right-(i-1)*s)/i),l=Math.max(0,(e.height-r.bottom-(o-1)*a)/o),h=[];for(let n=0;n<t;n++){const o=Math.floor(n/i),u=n%i,d=n+i<t,f=e.x+u*(c+s)+(u?r.left:0),m=e.y+o*(l+a);h.push({index:n,row:o,column:u,x:f,y:m,width:c+(u?0:r.left)+(u===i-1?r.right:0),height:l+(d?0:r.bottom),edges:{top:0===o,right:u===i-1||n===t-1,bottom:!d,left:0===u}})}return h}const oy={top:0,right:0,bottom:0,left:0},ry=[{x:!0,y:!0},{x:!0,y:!1},{x:!1,y:!0},{x:!1,y:!1}];function ay(t){return`${t.x?"x":""}${t.y?"y":""}`}function sy(t,e={x:!1,y:!1}){const n=t[ay(e)]??oy,i={};for(const[e,o]of Object.entries(t))i[e]={top:Math.max(0,o.top-n.top),right:Math.max(0,o.right-n.right),bottom:Math.max(0,o.bottom-n.bottom),left:Math.max(0,o.left-n.left)};return i}function cy(t){const e=Object.values(t),n=(e,n)=>Math.max(0,...ry.filter(n).map(n=>t[ay(n)]?.[e]??0));return{top:Math.max(0,...e.map(t=>t.top)),right:Math.max(0,...e.map(t=>t.right)),bottom:n("bottom",t=>t.x),left:n("left",t=>t.y)}}function ly(t,e,n,i){const o=0===t.column?n.left:0,r=t.column===i-1?n.right:0,a=e+n.top,s=t.edges.bottom?n.bottom:0;return{x:t.x+o,y:t.y+a,width:Math.max(0,t.width-o-r),height:Math.max(0,t.height-a-s)}}function hy(t){const e=Object.fromEntries(["top","right","bottom","left"].map(e=>[e,Math.max(...t.map(t=>t[e]))]));return t.map(t=>({top:t.top-e.top,right:t.right-e.right,bottom:t.bottom-e.bottom,left:t.left-e.left}))}function uy(t,e){return{x:t.x-e.left,y:t.y-e.top,width:t.width+e.left+e.right,height:t.height+e.top+e.bottom}}function dy(t){const e=(e,n)=>Math.max(0,...ry.filter(n).map(n=>t[ay(n)]?.[e]??0));return e("left",t=>t.x&&!t.y)+e("right",t=>t.x)}function fy(t,e){const n="function"==typeof e?e:t=>`${e}/${t}`;return t.map(t=>{const e=t.children,i={...t,key:n(`${t.key}`)};return e&&(i.children=fy(e,n)),i})}function my(t,e,n){const i=(new Ir).data(t.map((t,e)=>({id:`facet-title-${e}`,text:t.text}))).x((e,n)=>t[n].x).y((e,n)=>t[n].y).width((e,n)=>t[n].width).height(()=>1e4).verticalAlign("top").config(e);return n&&i.locale(n),i}function py(t,e,n){if(!t.length)return 0;const i="number"==typeof e.padding?e.padding:0,o=my(t,{...e,padding:0},n)._textData(),r=Math.max(0,...o.map(t=>t.lines.length*t.lH));return r?r+2*i:0}function gy(t,e,n){if(!t.length)return[];const i="number"==typeof e.padding?e.padding:0;return my(t.map(t=>({...t,x:t.x+i,y:t.y+i,width:t.width-2*i})),{...e,padding:0},n).toScene().children.map(t=>{const e={...t,interactive:!1,interactionGroup:"facet"};return delete e.datum,delete e.index,e})}function yy(t,e,n,i){return{type:"group",key:`${t}/cells`,...i?{clip:i}:{},children:[{type:"group",key:`${t}/body`,...n?{transform:n}:{},children:e}]}}function xy(t,e,n,i){const o=[];return n&&o.push(n),e&&o.push(e),{type:"group",key:t,children:o,...i?{aria:{role:"group",label:i}}:{}}}function by(t,e){return{top:e.y,left:e.x,right:t.schema.width-e.x-e.width,bottom:t.schema.height-e.y-e.height}}function _y(t,e){const{x:n,y:i}="boolean"==typeof e?{x:e,y:e}:e;return{x:!n||t.edges.bottom,y:!i||t.edges.left}}function ky(t,e,n,i,o){if(t._filteredData=n,t._margin=by(t,i),t._padding={...e.padding},t._chartScene=[],t._chartTransform=void 0,t._chartClip=void 0,t._zoomShapes=void 0,!n.length||i.width<=0||i.height<=0)return{scene:[],zoomShapes:[],state:{}};const r=e.hooks.panel?e.hooks.panel(t,o):void 0;let a,s;t._facetStep="panel";try{t._draw(),a=t._chartScene||[],s=e.hooks.scene?e.hooks.scene(t,a):a}finally{t._facetStep=void 0,r&&r()}return{scene:s,zoomShapes:t._zoomShapes||a,chartTransform:t._chartTransform,chartClip:t._chartClip,state:e.hooks.capture?e.hooks.capture(t):{}}}function vy(t,e){return void 0!==e.titleConfig.fontColor?e.titleConfig:{...e.titleConfig,fontColor:Ws(t)}}function wy(t,e){const{title:n}=t,i=e.map(t=>t.value);return e.map(t=>!1===n?"":n?`${n(t.value,t.data)}`:Bm(t.value,i))}function My(t,e,n,i){const o=e.map((t,e)=>({text:t,x:0,y:0,width:n[e]?n[e].width:0})).filter(t=>t.text&&t.width>0);return py(o,i,t.schema.locale)}function Sy(t,e,n,i){const{config:o,hooks:r,panels:a,area:s}=e,c={columns:o.columns,rows:o.rows,padding:o.padding,titleHeight:0,aspect:("function"==typeof r.aspect?r.aspect(t):r.aspect)??ne},l=My(t,n,iy(a.length,s,c),i);c.titleHeight=l;const h=iy(a.length,s,c)[0],u=ly(h,l,oy,1);e.shared&&r.share&&(t._margin=by(t,u),e.scales=r.share(t,a.map(t=>t.data)));const d=ce(t,o,r,e.shared),f=d.x||d.y?function(t,e,n,i,o){const r=e.panels.find(t=>t.data.length)?.data,a=e.hooks.insets;if(!r||!a)return{};const s={};for(const c of ry.filter(t=>(o.x||t.x)&&(o.y||t.y)))ky(t,e,r,i,{cell:n,shared:e.shared,labels:c,scales:e.scales}),s[ay(c)]=a(t);return sy(s,function(t){return{x:!t.x,y:!t.y}}(o))}(t,e,h,u,d):{},m=cy(f);c.gutter=m,c.columnPadding=o.padding+dy(f),c.titleHeight=l+m.top;const p=iy(a.length,s,c),g=Math.max(1,...p.map(t=>t.column+1));return{cells:p,columns:g,titleHeight:l,outer:d,gutter:m,expansions:f}}function Cy(t,e,n){return{text:t,x:n.x,y:e.y,width:n.width}}function $y(t,e){const n=vy(t,e.config),i=wy(e.config,e.panels),o=Sy(t,e,i,n),{cells:r,expansions:a}=o,s=r.map(t=>ly(t,o.titleHeight,o.gutter,o.columns)),c=gy(r.map((t,e)=>Cy(i[e],t,s[e])).filter(t=>t.text),n,t.schema.locale),l=r.map(t=>_y(t,o.outer)),h=r.map((t,e)=>uy(s[e],a[ay(l[e])]??oy)),u=function(t,e,n,i,o,r){const a=e.hooks.insets,{outer:s,expansions:c}=r;if(!a||s.x===s.y)return[];const l=e.panels.map((r,s)=>{if(!r.data.length)return;ky(t,e,r.data,i[s],{cell:n[s],shared:e.shared,labels:o[s],scales:e.scales});const l=c[ay(o[s])]??oy,h=a(t);return{top:h.top-l.top,right:h.right-l.right,bottom:h.bottom-l.bottom,left:h.left-l.left}}),h=hy(l.filter(t=>!!t));let u=0;return l.map(t=>t?h[u++]:oy)}(t,e,r,h,l,o);let d=0;const f=[],m=[],p=[];return e.panels.forEach((n,o)=>{const a=r[o],s=u[o]?uy(h[o],u[o]):h[o],g=ky(t,e,n.data,s,{cell:a,shared:e.shared,labels:l[o],scales:e.scales}),y=`facet-${n.key}`,x=i[o]?c[d++]:void 0,b=g.scene.length?yy(y,fy(g.scene,y),g.chartTransform,g.chartClip):void 0;m.push(xy(y,x?{...x,key:`${y}/title`}:void 0,b,i[o])),p.push(...g.zoomShapes),f.push({key:y,value:n.value,cell:a,area:s,chartTransform:g.chartTransform,scene:g.scene,state:g.state})}),t._chartScene=m,{states:f,zoomShapes:p}}function Ay(t){const e=oe(t.schema.facetConfig),n=Lm(t,e.sort);if(!n.length||!(t._filteredData||[]).length)return!1;const i=Nm(t),o=n.map(e=>({...e,data:Fm(t,e.rows,i)})),r=o.flatMap(t=>t.data);if(!r.length)return!1;t._filteredData=r,t._insetPending=null,t._insetPlacement=null;const a=t._facetHooks?t._facetHooks():{};a.chrome&&(a.chrome(t,o.map(t=>t.data)),t._filteredData=r),t._facetStep="chrome";try{t._draw()}finally{t._facetStep=void 0}const s={...t._margin},c={...t._padding},l={x:s.left,y:s.top,width:t.schema.width-s.left-s.right,height:t.schema.height-s.top-s.bottom},h=le(e,a),{states:u,zoomShapes:d}=$y(t,{config:e,hooks:a,panels:o,area:l,shared:h,scales:void 0,padding:c});return t._filteredData=r,t._margin=s,t._padding=c,t._chartTransform=void 0,t._chartClip=void 0,t._bodyRect={...l},t._zoomShapes=d,t._facetPanels=u,t._pendingEnterOrigin=void 0,t._pendingExitReunion=void 0,Ql(t,u),!0}function zy(t){!function(t,e){const n=ty(t);if(t._alongLegendHide=n,t._alongStats={series:0,requested:0,placed:0},!n)return e();const i={...t._margin},o={...t._padding};var r;e(),(r=t._alongStats)&&r.series>1&&r.requested===r.series&&r.placed===r.requested||(t._alongLegendHide=!1,t._alongStats={series:0,requested:0,placed:0},t._margin=i,t._padding=o,e())}(t,()=>{t._facetPanels=void 0,he(t)&&Ay(t)||Pp(t)})}function Dy(t,e){const n=Ws(t),i=t._sizeLegendClass;i.renderMode("compute").locale(t.schema.locale).title(t._sizeKey).labelConfig({fontColor:n,fontFamily:t.schema.fontFamily}).titleConfig({fontColor:n,fontFamily:t.schema.fontFamily}).lineConfig({stroke:n}).shapeConfig({fill:n,stroke:n}).config(t.schema.sizeLegendConfig).scale(e);const{width:o,height:r}=i.layout();return{width:o,height:r}}function Ly(t,e){if(!t._sizeLegendClass||"function"!=typeof t._sizeLegendScale)return null;const n=t._sizeLegendScale(e);if(!n)return null;t._sizeLegendClass._maxRadius=void 0;const{width:i,height:o}=Dy(t,n);if(!i||!o)return null;const r={width:i,height:o,availableWidth:e.width,availableHeight:e.height};return t.schema.sizeLegend.bind(t)(ym(t),n,r)?{key:"sizeLegend",width:i,height:o,paint:e=>{const n=t._sizeLegendFinal;if(!n)return null;t._sizeLegendClass._maxRadius=1===e?void 0:n(n.domain()[1]);const i=Dy(t,yr(n,e));return i.width&&i.height?{node:t._sizeLegendClass.toScene(),...i}:null}}:null}const Fy=[Ly];function Ny(t,e,n){const i=[];for(const e of Fy){const o=e(t,n);o&&i.push(o)}const o="bottom"===t.schema.sizeLegendPosition?"bottom":"right",r=Gs(t,"sizeLegend");t._bottomRightBox=i.length?{...hu(i),bottom:e,side:o,inset:r,items:i}:null}const By={name:"bottomRightControls",configFields:["sizeLegend","sizeLegendConfig","sizeLegendPosition"],layout:({viz:t})=>{const e=uu(t);return{panel:e?xu(t,e):null,margin:{}}}};function Ey(t){yf(t),t._preDraw(),zy(t),Ry(t),sl(t),t._drawSceneToTarget(),kf(t)}function Ry(t){const e=ep({viz:t},[vu,Sp,im,By,Qm,Ad]);e.panels.length&&(t._featurePanels=[...t._featurePanels||[],...e.panels])}function Py(){this._tooltipClass.data([]).render()}const Ty="d3plus-viz-spacer";function Oy(t,e){return void 0===t||e?void 0:t}function Wy(t){const e=t._select?.node(),n=e?.parentNode;if(!e||!n||"http://www.w3.org/1999/xhtml"!==n.namespaceURI)return;let i=Array.from(n.children).find(t=>t.classList.contains(Ty));const o=Oy(t.schema.width,t._autoWidth),r=Oy(t.schema.height,t._autoHeight);if("canvas"===t._renderer||void 0===o&&void 0===r)i?.remove();else{if(!i){i=n.ownerDocument.createElement("div"),i.className=Ty,i.setAttribute("aria-hidden","true");const t=i.style;t.display="block",t.flex="none",t.boxSizing="content-box",t.margin="0",t.padding="0",t.border="0",t.visibility="hidden",t.pointerEvents="none",n.insertBefore(i,e.nextSibling)}i.style.width=`${o??0}px`,i.style.height=`${r??0}px`}}const Hy="d3plus-viz";const jy=":where(.d3plus-render-overlays, .d3plus-zoom-control, .d3plus-top-left-controls)",Iy=[".d3plus-zoom-control",".d3plus-top-left-controls",".d3plus-top-left-controls-item",`${jy} .tlc-item`,`${jy} .zoom-control-icon`,`${jy} .search-root`,`${jy} .search-input-wrap`,`${jy} .search-count`,".d3plus-minimap",".d3plus-minimap-viewport",".d3plus-minimap-label",".d3plus-table-view",".d3plus-table-view-frame",".d3plus-table-view-toolbar",".d3plus-table-view-scroll",".d3plus-table-view-table",".d3plus-table-view-cell",".d3plus-table-view-pagination",".d3plus-attribution",".d3plus-attribution-text",".d3plus-attribution-icon",".d3plus-Mask",".d3plus-Message"];function Gy(t,e){!function(t){const e=void 0!==t.schema.width?`${t.schema.width}px`:void 0,n=void 0!==t.schema.height?`${t.schema.height}px`:void 0;t._select.classed("d3plus-viz")||t._select.style("width",e).style("height",n).attr("width",e).attr("height",n),t._select.transition().duration(Zt(t)).style("width",e).style("height",n).attr("width",e).attr("height",n)}(t),t._select.attr("class",Hy).attr("aria-hidden",t.schema.ariaHidden).attr("aria-labelledby",`${t._uuid}-title ${t._uuid}-desc`).attr("role","img").attr("xmlns","http://www.w3.org/2000/svg").attr("xmlns:xlink","http://www.w3.org/1999/xlink").style("position","absolute").style("top",e.style("padding-top")).style("left",e.style("padding-left")).style("content-visibility",t.schema.detectVisible?"auto":null),Ht(t);"static"===e.style("position")&&e.style("position","relative"),e.style("font-family",s.fontFamilyStringify(t.schema.fontFamily)),null===t._select.attr("opacity")&&t._select.attr("opacity",1);const n=t._select.selectAll("title").data([0]),i=n.enter().append("title").attr("id",`${t._uuid}-title`);n.merge(i).text(t.schema.svgTitle);const o=t._select.selectAll("desc").data([0]),r=o.enter().append("desc").attr("id",`${t._uuid}-desc`);o.merge(r).text(t.schema.svgDesc)}function qy(t){const e=[];return t._queue.forEach(n=>{const i=mn(t,n[3],n[2]);let o=!1;const r=new Promise(e=>{n[0](n[1],i,n[3],(i,r)=>{o=!0,i?console.error(i):"data"===n[3]&&function(t,e){t._dataSignature=t.schema.dataPollingInterval?Je(e):void 0}(t,r),e()})});o||e.push(r)}),t._queue=[],e}function Vy(t,e){var n;if(t._unloaded)return;let i;!function(t){const e=t._data instanceof Array&&t._data.length>0?Object.keys(t._data[0]):[],n=t._select.selectAll("g.data-table").data(!t.schema.ariaHidden&&t._data instanceof Array&&t._data.length?[0]:[]),i=n.enter().append("g").attr("class","data-table").attr("role","table");n.exit().remove();const o=n.merge(i).selectAll("text").data(t._data instanceof Array?h.range(0,t._data.length+1):[]);o.exit().remove();const r=o.merge(o.enter().append("text").attr("role","row")).selectAll("tspan").data((n,i)=>e.map(e=>({role:i?"cell":"columnheader",text:i?t._data[i-1][e]:e})));r.exit().remove(),r.merge(r.enter().append("tspan")).attr("role",t=>t.role).attr("dy","-1000px").html(t=>t.text)}(t),Ey(t),t._instantNextDraw=!1,Ze(t),an(t),!t._messageClass._isVisible||t.schema.noDataMessage&&!t._filteredData.length||(t._messageClass.hide({duration:Zt(t)}),"0"===t._select.attr("opacity")&&t._select.transition().duration(Zt(t)).attr("opacity",1));const o=()=>{if(i=void 0,!t._fontsUnsubscribe)return;const e=t._callback?Zt(t):(t._transitionEndsAt??0)-Date.now();e>0?i=setTimeout(o,e):t.render()};(n=t)._fontsUnsubscribe??(n._fontsUnsubscribe=r.onFontsLoaded(()=>{void 0===i&&o()})),t.schema.detectResize&&(t._autoWidth||t._autoHeight)?t._resizeObserver?.observe(t._select.node().parentNode):t._resizeObserver?.unobserve(t._select.node().parentNode),e&&setTimeout(()=>{e(),t._callback=void 0},Zt(t)+100)}function Yy(t,e){t._callback=e,e?t._renderCallback=e:e=t._renderCallback,t.schema.detectVisible&&t.schema.detectVisibleUnload||(t._unloadUnobserve?.(),t._unloadUnobserve=void 0,t._unloaded=!1),t._margin={bottom:0,left:0,right:0,top:0},t._padding={bottom:0,left:0,right:0,top:0},function(t){if(void 0===t._select||"svg"!==t._select.node().tagName.toLowerCase()){const e=void 0===t._select?o.select("body").insert("div","#d3plus-portal").style("height","100dvh").style("width","100%").style("min-height","150px"):t._select,n=e.select(".d3plus-viz").size()?e.select(".d3plus-viz"):e.append("svg");t.select(n.node())}}(t),function(t){if(t._tooltipClass&&t._select?.node){const e=t._select.node()?.parentNode;e&&t._tooltipClass.parent(e)}}(t),function(t){a.resetInjectedBoxes(t._select?.node(),Iy)}(t),Wy(t);const n=function(t){return!!t._forceVisible||r.inViewport(t._select.node())}(t);!function(t,e){t.schema.width&&t.schema.height||t.schema.detectVisible&&!e||(t._autoWidth=void 0===t.schema.width||!!t._autoWidth&&t.schema.width===t._measuredWidth,t._autoHeight=void 0===t.schema.height||!!t._autoHeight&&t.schema.height===t._measuredHeight,t._setSVGSize())}(t,n),Wy(t);const i=o.select(t._select.node().parentNode);return Gy(t,i),function(t){t._visiblePoll=clearInterval(t._visiblePoll),t._resizePoll=clearTimeout(t._resizePoll),t._scrollPoll=clearTimeout(t._scrollPoll),t._visibleUnobserve?.(),t._visibleUnobserve=void 0,t.schema.scrollContainer&&o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,null)}(t),function(t,e,n){return t.schema.detectVisible&&"hidden"===t._select.style("visibility")?(t._visiblePoll=setInterval(()=>{"hidden"!==t._select.style("visibility")&&(t._visiblePoll=clearInterval(t._visiblePoll),t.render(n))},t.schema.detectVisibleInterval),!0):t.schema.detectVisible&&"none"===t._select.style("display")?(t._visiblePoll=setInterval(()=>{"none"!==t._select.style("display")&&(t._visiblePoll=clearInterval(t._visiblePoll),t.render(n))},t.schema.detectVisibleInterval),!0):!(!t.schema.detectVisible||e||(Ue()?(t._visibleUnobserve=Xe(t._select.node(),t.schema.scrollContainer,()=>{t._visibleUnobserve?.(),t._visibleUnobserve=void 0,t._forceVisible=!0,t.render(n)},t.schema.detectVisibleInterval),0):(o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,()=>{t._scrollPoll||(t._scrollPoll=setTimeout(()=>{r.inViewport(t._select.node())&&(o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,null),t.render(n)),t._scrollPoll=clearTimeout(t._scrollPoll)},t.schema.detectVisibleInterval))}),0)))}(t,n,e)||function(t,e){fn(t);const n=qy(t);t.schema.loadingMessage&&n.length&&t._messageClass.render({container:t._select.node().parentNode,duration:Zt(t),html:t.schema.loadingHTML(t),mask:!!t._filteredData&&t.schema.messageMask,style:t.schema.messageStyle}),Promise.all(n).then(()=>Vy(t,e))}(t,e),t._forceVisible=!1,o.select("body").on(`touchstart.${t._uuid}`,Py.bind(t)),t}function Ky(t,e,n,i,o){const r=ep({viz:t},[e],n);for(const t of o)i[t]+=r.margin[t],n[t]+=r.margin[t]}function Uy(t){if(t._chartScene=[],t._chartTransform=void 0,"panel"===t._facetStep)return{marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:(t._featurePanels??[]).slice()};t._featurePanels=[];const e={marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:[]},n=ym(t),i=tp(t.schema.legendPosition.bind(t)(n),t),o=tp(t.schema.colorScalePosition.bind(t)(n),t);e.legendPosition=i,e.colorScalePosition=o;const r={top:t._margin.top,right:t._margin.right,bottom:t._margin.bottom,left:t._margin.left},a=ep({viz:t},[lp,hp,dp],r);t._featurePanels.push(...a.panels),e.marginDelta.top+=a.margin.top,r.top+=a.margin.top;const s=ep({viz:t},[up],r);e.marginDelta.bottom+=s.margin.bottom,r.bottom+=s.margin.bottom,Ny(t,r.bottom,{width:t.schema.width-r.left-r.right,height:t.schema.height-r.top-r.bottom});const c=yu(t,r.right);r.right+=c,"top"!==i&&"bottom"!==i||Ky(t,Sm,r,e.marginDelta,["top","bottom"]),"top"!==o&&"bottom"!==o||Ky(t,Xm,r,e.marginDelta,["top","bottom"]),r.right-=c;const l=gu(t,r.bottom);e.marginDelta.bottom+=l,r.bottom+=l,"left"!==i&&"right"!==i&&!1!==i||Ky(t,Sm,r,e.marginDelta,["left","right"]),"left"!==o&&"right"!==o&&!1!==o||Ky(t,Xm,r,e.marginDelta,["left","right"]);const h=yu(t,r.right);e.marginDelta.right+=h,r.right+=h;const u=Math.max(0,ap(t)-e.marginDelta.top);e.marginDelta.top+=u,r.top+=u;const d=e.marginDelta;return t._margin={top:t._margin.top+d.top,right:t._margin.right+d.right,bottom:t._margin.bottom+d.bottom,left:t._margin.left+d.left},e.featurePanels=t._featurePanels.slice(),e}const Xy={x:"_x",x2:"_x2",y:"_y",y2:"_y2",size:"_size",stackOrder:"_stackOrder"},Zy=["dimensions"];const Qy=t=>null!==t&&"object"==typeof t;function Jy(t,e){return t.some(t=>t.some(t=>Qy(t)&&e in t))}function tx(t){const e=new Set;for(const n of t)for(const t of n)if(Qy(t))for(const n in t)e.add(n);return Array.from(e)}function ex(t,{key:e,field:n},i){const o=i.slice(0,10);return i.length>10&&o.push("…"),`${t} ${e}: no rows have '${n}'; fields are: ${o.join(", ")}`}function nx(t){const e=({key:t,field:e})=>`missing-field:${t}:${e}`,n=function(t){const e=new Map,n=(t,n)=>{const i=V(n);void 0===i||e.has(n)||e.set(n,{key:t,field:i})};for(const[e,i]of Object.entries(Xy))n(e,t[i]);for(const e of t._confidenceBands??[])n("confidence",e.lower),n("confidence",e.upper);const i=Object.keys(t.schema).filter(t=>"thresholdKey"!==t);for(const e of[...i,"thresholdKey"]){const i=t.schema[e];Array.isArray(i)&&"function"==typeof i[0]?i.forEach(t=>n(e,t)):n(e,i)}const o=Array.from(e.values());for(const e of Zy){const n=t.schema[e],i=Array.isArray(n)?n:[n];for(const t of i)"string"==typeof t&&o.push({key:e,field:t})}return o}(t).filter(n=>function(t,e){return Dt&&!zt.get(t)?.has(e)}(t,e(n)));if(!n.length)return;const i=function(t){return[t._sourceData??t._data,t.schema.nodes,t.schema.links].filter(t=>Array.isArray(t))}(t);if(!i.some(t=>t.some(Qy)))return;let o;for(const r of n)Jy(i,r.field)||(o??(o=tx(i)),Et(t,e(r),ex(It(t),r,o)))}function ix(t,e,n){for(;e.__d3plus__&&e.data;)n=(e=e.data).i;return t(e,n)}function ox(t,e,n){const i={noDataMessage:!1};return new h.InternSet(e.map(n)).size>t.schema.dataCutoff?i.hoverOverride={hoverOpacity:1,duration:0,stashOriginals:!0}:void 0!==t._userHover&&(i.hoverOverride={hoverOpacity:t._userHover,duration:t._userDuration,restoreOriginals:!0}),i.noDataMessage=!(!t.schema.noDataMessage||e.length),i}function rx(t){nx(t);const n=void 0!==t.schema.depth?h.min([t.schema.depth>=0?t.schema.depth:0,t.schema.groupBy.length-1]):t.schema.groupBy.length-1,{id:i,ids:o,drawLabel:r}=function(t,e){const n=t.schema.groupBy,i=t.schema.label,o=t.schema.thresholdName,r=t.schema.locale,a=t=>"number"==typeof t?`${t}`:t,s=(t,e)=>n.map(n=>`${ix(n,t,e)}`).filter(Boolean);return{id:(t,i)=>{const o=ix(n[e],t,i);return Array.isArray(o)?o.map(a):a(o)},ids:s,drawLabel:(n,a,c)=>{const l=t._drawDepth??e;if(!n)return"";const h=me(n),u=c??h??l;for(;n.__d3plus__&&n.data;)a=(n=n.data).i;if(u===h&&"string"==typeof n[de])return n[de];if(n._isColorScaleBucket)return`${n.id}`;if(n._isAggregation)return`${o(n,a)} < ${d.formatAbbreviate(100*n._threshold,r)}%`;if(i&&u===l)return`${i(n,a)}`;const f=s(n,a).slice(0,u+1),m=f.reverse().find(t=>!(t instanceof Array))||f[f.length-1];return m instanceof Array?function(t){return t.reduce((e,n,i)=>(i?i===t.length-1&&1===i?e+=` and ${n}`:i===t.length-1?e+=`, and ${n}`:e+=`, ${n}`:e+=n,e),"")}(m):`${m}`}}}(t,n);(function(t){const e=t=>!0===t||"number"==typeof t&&t>0,n=e=>t?.[e]?.trailPersist;return!!t&&(e(t.trailPersist)||e(n("Circle"))||e(n("Rect")))})(t.schema.shapeConfig)&&(t._axisPersist=!0,t.schema.timelineConfig={...t.schema.timelineConfig||{},brushing:!1});const a={};gm(t,a,n,i,pm(t)),t._drawDepth=n,t._id=i,t._ids=o,t._drawLabel=r,void 0!==a.legendData&&(t._legendData=a.legendData),t._thresholdRows=a.legendData;let s=a.filteredData||[];t._data.length&&a._thresholdTree&&(s=t._thresholdFunction(s,a._thresholdTree,t._thresholdRows),t._thresholdLegend&&a.legendData&&(t._legendData=t._thresholdLegend(a.legendData))),t._filteredData=s,function(t){if(!t.schema.colorOrdinal||t.schema.colorScale)return void(t._ordinalColorScale=void 0);const n=t._filteredData??[],i=t.schema.color,o=new Set,r=[];n.forEach((t,e)=>{const n=i(t,e),a="string"==typeof n?n:JSON.stringify(n);o.has(a)||(o.add(a),r.push(n))});const a=(r.every(t=>"number"==typeof t)?[...r].sort((t,e)=>t-e):r).map(t=>"string"==typeof t?t:JSON.stringify(t)),s=tt(t._theme,"max",(t.schema.colorDefaults??e.colorDefaults).sequential),l=et(t._theme,s,a.length||1,!0);t._ordinalColorScale=c.scaleOrdinal().domain(a).range(l)}(t);const l=ox(t,s,t._id);l.hoverOverride?.stashOriginals?(void 0===t._userHover&&(t._userHover=t.schema.shapeConfig.hoverOpacity||.5),void 0===t._userDuration&&(t._userDuration=t.schema.shapeConfig.duration||600),t.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,t.schema.shapeConfig.duration=l.hoverOverride.duration):l.hoverOverride?.restoreOriginals&&(t.schema.shapeConfig.hoverOpacity=l.hoverOverride.hoverOpacity,t.schema.shapeConfig.duration=l.hoverOverride.duration),l.noDataMessage&&(t._messageClass.render({container:t._select.node().parentNode,duration:Zt(t),html:t.schema.noDataHTML(t),mask:!1,style:t.schema.messageStyle}),t._select.transition().duration(Zt(t)).attr("opacity",0))}function ax(t,e=!1){var n;const i=(n=t)._nearestHover??(n._nearestHover={key:null}),o=t._select?.node?.(),r="canvas"===t._renderer||e?void 0:o;if(i.surface&&i.surface.el===r)return;if(i.surface?.unbind(),i.surface=void 0,!r||"function"!=typeof r.addEventListener)return;const a=e=>{const n=e,i=function(t){return(t._sceneRenderer?.elements?.()??[]).find(t=>"svg"===t.localName)}(t);return!!n&&"function"==typeof n.closest&&r.contains(n)&&!(i&&i.contains(n))&&!n.closest("g.d3plus-viz-timeline, g.d3plus-viz-brush, g.d3plus-zoom-brush")},s=e=>{const n=hh(t);return[e.clientX-n.left,e.clientY-n.top]},c=e=>a(e.target)&&rh(t)>0,l=e=>{if(!c(e))return;const n=s(e);lh(t,{type:"mousemove",point:n,pick:null,nativeEvent:e})},h=e=>{if(!c(e))return;const n=s(e);ch(t,null,n)&&(e.stopPropagation(),lh(t,{type:"click",point:n,pick:null,nativeEvent:e}))},u=e=>{if(null===i.key)return;const n=s(e);lh(t,{type:"mouseleave",point:n,pick:null,nativeEvent:e})};r.addEventListener("mousemove",l),r.addEventListener("click",h,!0),r.addEventListener("mouseleave",u),i.surface={el:r,aroundScene:a,unbind:()=>{r.removeEventListener("mousemove",l),r.removeEventListener("click",h,!0),r.removeEventListener("mouseleave",u)}}}function sx(t,e){t.interactionGroup=e;const n=t.children;if(n)for(const t of n)sx(t,e)}class cx extends _s{_preDraw(){rx(this)}toScene(){const t=bf(this);if(this._chartScene&&this._chartScene.length){const e=Ts(this._chartScene,this),n=[{type:"group",key:"viz-zoom",transform:this._zoomTransform??{x:0,y:0,scale:1},children:[{type:"group",key:"viz-chart-body",...this._chartTransform?{transform:this._chartTransform}:{},children:e}]}],i=this._chartClip??(this.schema.zoom&&this._margin?wt(this):void 0);t.push({type:"group",key:"viz-chart-cells",...i?{clip:i}:{},children:n})}const e=[["legend",this._legendClass],["colorScale",this._colorScaleClass],["timeline",this._timelineClass]];for(const[n,i]of e)if(i&&"function"==typeof i.toScene&&i._select&&"function"==typeof i._select.node&&i._select.node()){let e=i.toScene();"legend"===n?(sx(e,"legend"),e=Ts([e],this)[0]):"colorScale"===n?e=Es([e],this)[0]:"timeline"===n&&sx(e,"timeline"),t.push({type:"group",key:`viz-${n}`,children:"timeline"===n?[e]:Us(this,n,e,i.outerBounds())})}return this._featurePanels&&this._featurePanels.length&&t.push({type:"group",key:"viz-features",children:this._featurePanels}),Qc(this,t),{width:this.schema.width,height:this.schema.height,root:{type:"group",key:"viz-root",children:t}}}_draw(){Uy(this)}_sizeLegendScale(t){return null}_insetRegion(){return null}_tableData(){return null}_colorScaleShape(t,e){return this.schema.shape(t,e)}_thresholdFunction(t,e,n){return t}_thresholdLegend(t){return t}_setSVGSize(t,e){let[n,i]=t&&e?[t,e]:r.getSize(this._select.node().parentNode);n-=parseFloat(this._select.style("border-left-width")),n-=parseFloat(this._select.style("border-right-width")),i-=parseFloat(this._select.style("border-top-width")),i-=parseFloat(this._select.style("border-bottom-width")),this._autoWidth&&(this._measuredWidth=n),this._autoHeight&&(this._measuredHeight=i),this._autoWidth&&this.schema.width!==n&&(this.width(n),this._select.style("width",`${this.schema.width}px`).attr("width",`${this.schema.width}px`)),this._autoHeight&&this.schema.height!==i&&(this.height(i),this._select.style("height",`${this.schema.height}px`).attr("height",`${this.schema.height}px`))}render(t){return Yy(this,t)}toSVGString(){return function(t,e){const n=Ot(e),i=/^\s*<[a-zA-Z][^\s>/]*/.exec(t);if(!n.length||!i)return t;const o=t.indexOf(">",i[0].length),r=t.slice(0,o<0?t.length:o),a=/\sclass="([^"]*)"/.exec(r);if(!a)return`${i[0]} class="${jt(n.join(" "))}"${t.slice(i[0].length)}`;const s=a[1].split(/\s+/).filter(Boolean),c=[...s,...n.filter(t=>!s.includes(t))],l=a.index;return`${t.slice(0,l)} class="${jt(c.join(" "))}"${t.slice(l+a[0].length)}`}(this._sceneRenderer?.toSVGString?.()??"",this.schema.className)}toCanvas(){return"canvas"===this._renderer?this._sceneRenderer?.toCanvas?.():void 0}renderer(t){return arguments.length?(this._renderer="canvas"===t?"canvas":"svg",this):this._renderer}_drawSceneToTarget(t){const e="canvas"===this._renderer?"canvas":"svg",n=this._select&&this._select.node?this._select.node():null;if(!n)return;const i=function(t,e){return"canvas"===t&&"undefined"!=typeof Element&&e instanceof Element&&"svg"===e.tagName.toLowerCase()?e.parentNode??e:e}(e,n),a=this.toScene();this._paintedScene=a;const s=this.schema.width||400,c=this.schema.height||300;this._ensureSceneRenderer(e,i,s,c),Ht(this);const l=Xt(this)?0:void 0!==t?t:this._instantNextDraw?0:this.schema.duration;l>0&&null!=this._sceneRepaintRAF&&(cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),l>0&&(this._transitionEndsAt=Date.now()+l+30);const h=this._timelineSelection,u=!(!this._timelineClass||!1!==this._timelineClass.schema.brushing)&&Array.isArray(h)&&h.length?Math.max(...h.map(t=>Number(r.date(Number(t))))):void 0,d=void 0!==u&&void 0!==this._trailSeq&&u>this._trailSeq?Ct(this,a,this._trailSeq,u):void 0;if(void 0!==u&&(this._trailSeq=u),this._sceneRenderer.drawScene(a,{duration:l,sequence:u,trailCatchup:d,enterFrom:this._resolvedEnterFrom,enterFromBody:this._resolvedEnterFromBody,exitTo:this._resolvedExitTo,exitToBody:this._resolvedExitToBody,instantExitKey:this._resolvedInstantExitKey,reunionEnterKey:this._resolvedReunionEnterKey,reunionEnterFrom:this._resolvedReunionEnterFrom,instantExitAll:this._resolvedInstantExitAll}),this._resolvedEnterFrom=void 0,this._resolvedEnterFromBody=void 0,this._resolvedExitTo=void 0,this._resolvedExitToBody=void 0,this._resolvedInstantExitKey=void 0,this._resolvedReunionEnterKey=void 0,this._resolvedReunionEnterFrom=void 0,this._resolvedInstantExitAll=void 0,this._lastSceneRendered=a,Su(this),this._select&&"canvas"===e&&this._select.selectAll("g.d3plus-viz-timeline, g.d3plus-viz-brush").style("pointer-events","auto"),"canvas"===e&&function(t){if(!t.schema.zoom||t._ssr||!t._zoomBehavior||!t._brushGroup)return;const e=t._sceneRenderer,n=e&&"function"==typeof e.toCanvas?e.toCanvas():null;!n||t._zoomEventTarget&&t._zoomEventTarget.node()===n||(Mu(t,o.select(n)),$u.bind(t)(Yh(t)))}(this),ax(this),Zc(this),"svg"===e){const t="function"==typeof n.querySelector?n:null,e=t?t.querySelector(":scope > g.d3plus-viz-timeline"):null;e&&t.appendChild(e),t?.querySelectorAll(":scope > g.d3plus-zoom-brush, :scope > g.d3plus-viz-brush").forEach(e=>{e!==t.lastElementChild&&t.appendChild(e)})}}_interactionDatum(t,e){return Fc(t.datum,t.index??0)}_pointMark(t){return!1}_sharedHover(t){}_classNameTargets(){return function(t,e,n){if("canvas"===n)return Pt(e).filter(t=>"canvas"===t.localName).map(t=>({el:t,keep:Rt}));const i="undefined"!=typeof Element&&t instanceof Element&&t.classList.contains(Hy)?t:void 0;return i?[{el:i,keep:[Hy]}]:[]}(this._select?.node?.(),this._sceneRenderer,"canvas"===this._renderer?"canvas":"svg")}_facetHooks(){return{}}_ensureSceneRenderer(t,e,n,i){const o=this._sceneRenderer?.target?this._sceneRenderer.target()?.container:void 0,r=!!this._sceneRenderer?.target&&o!==e;if(!this._sceneRenderer||this._sceneRenderer.kind!==t||r){this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const o="canvas"===t?a.CanvasRenderer:a.SvgRenderer;this._sceneRenderer=new o,this._sceneRenderer.mount({container:e,width:n,height:i,pixelRatio:this._scenePixelRatio}),this._lastScenePick=null,this._sceneRenderer.on(t=>lh(this,t))}else this._sceneRenderer.resize(n,i)}_routeSceneEvent(t){Zl(this,Xl(this,t.point),()=>this._dispatchSceneEvent(t))}_dispatchSceneEvent(t){if(this._sharedHover(t),Fs(this,t),this._transitionEndsAt&&Date.now()<this._transitionEndsAt)return;const e=t.pick,n=(e,n,i,o)=>{const r=this.schema.on&&this.schema.on[e];if("function"==typeof r)try{r.call(this,n,i,o,t.nativeEvent)}catch(t){!function(t){const e=globalThis.reportError;"function"==typeof e?e(t):console.error(t)}(t)}};if("mouseleave"===t.type){const t=this._lastScenePick;if(t){n("mouseleave."+(t.isLegend?"legend":"shape"),t.d,t.i,t.x);for(const e of t.shapeTargets)n(`mouseleave.${e.shapeType}`,e.d,e.i,e.x);n("mouseleave",t.d,t.i,t.x)}return this._lastScenePick=null,void(this._hoverDatum=null)}if(!e||!e.node)return;const i=e.node;if("axis"===i.interactionGroup||"timeline"===i.interactionGroup||"trend"===i.interactionGroup)return;const o=t.nativeEvent&&t.nativeEvent.target,r="legend"===i.interactionGroup||!(!o||"function"!=typeof o.closest)&&!!o.closest('[data-key="viz-legend"]'),a=r?"legend":"shape",s=`${t.type}.${a}`,{d:c,i:l,x:h}=this._interactionDatum(e,t);if(void 0===c)return;const u=r?[]:function(t,e){const n=[],i=Bc(t);i&&n.push({shapeType:i,...e});for(const e of t.owners??[])n.some(t=>t.shapeType===e.shapeType)||n.push({shapeType:e.shapeType,...Fc(e.datum,e.index)});return n}(e.node,{d:c,i:l,x:h});this._lastScenePick={d:c,i:l,x:h,isLegend:r,shapeTargets:u,node:e.node},this._hoverDatum=h,n(s,c,l,h);for(const e of u)n(`${t.type}.${e.shapeType}`,e.d,e.i,e.x);n(t.type,c,l,h)}_scheduleSceneRepaint(){this._sceneRenderer&&("function"==typeof requestAnimationFrame?null==this._sceneRepaintRAF&&(this._sceneRepaintRAF=requestAnimationFrame(()=>{this._sceneRepaintRAF=void 0,this._drawSceneToTarget(0)})):this._drawSceneToTarget(0))}destroy(){var t;return Ee(this),Uc(this),ax(this,!0),gf(this),en(this),this._resizeObserver?.disconnect(),this._fontsUnsubscribe?.(),this._fontsUnsubscribe=void 0,this._tooltipClass.data([]).render(),o.select("body").on(`touchstart.${this._uuid}`,null),(t=this)._visiblePoll&&(t._visiblePoll=clearInterval(t._visiblePoll)),t._resizePoll&&(t._resizePoll=clearTimeout(t._resizePoll)),t._scrollPoll&&(t._scrollPoll=clearTimeout(t._scrollPoll)),t._visibleUnobserve?.(),t._visibleUnobserve=void 0,t._unloadUnobserve?.(),t._unloadUnobserve=void 0,t.schema.scrollContainer&&o.select(t.schema.scrollContainer).on(`scroll.${t._uuid}`,null),null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&(this._sceneRenderer.destroy(),this._sceneRenderer=void 0),this}constructor(){var t;super(),Oh(this),(t=this).schema.legendInset=!0,t.schema.legendInsetConfig={}}}function lx(t,e=cx){class n extends e{_draw(e){return super._draw(e),t.layoutStage&&"chrome"!==this._facetStep&&Mt(this,t,t.layoutStage,t.chartTransform),this}toScene(){const e=super.toScene();return t.decorateScene?t.decorateScene(this,e):e}_sizeLegendScale(e){return t.sizeLegendScale?t.sizeLegendScale(this,e):super._sizeLegendScale(e)}_insetRegion(){return t.insetRegion?t.insetRegion(this):super._insetRegion()}_tableData(){return t.tableData?t.tableData(this):super._tableData()}_colorScaleShape(e,n){return t.colorScaleShape?t.colorScaleShape(this,e,n):super._colorScaleShape(e,n)}_pointMark(e){return t.pointMark?t.pointMark(this,e):super._pointMark(e)}_facetHooks(){return t.facet?{...super._facetHooks(),...t.facet}:super._facetHooks()}_thresholdLegend(e){return t.thresholdFunction?t.thresholdFunction(this,e,e):super._thresholdLegend(e)}_thresholdFunction(e,n,i){return t.thresholdFunction?t.thresholdFunction(this,e,i):super._thresholdFunction(e,n,i)}constructor(){super(),function(t,e){if(e.ctx)for(const[n,i]of Object.entries(e.ctx))t.ctx[n]=i;if(e.defaults){const n=t;for(const[t,i]of Object.entries(e.defaults))n[`_${t}`]=i}e.fields&&xt(t,e.fields),e.setup&&e.setup(t)}(this,t)}}return n._displayName=t.name,Object.defineProperty(n,"name",{value:t.name}),n}function hx(t){return arguments.length?(this._hover=t,this.schema.legend&&this._legendClass&&this._legendClass.hover(t),this._sceneRenderer&&this._scheduleSceneRepaint(),je(this,"hover",t),this):this._hover}function ux(t){if("string"==typeof t)return{accessor:q(t),title:t,key:t};if("function"==typeof t)return{accessor:t,title:""};if(t&&"object"==typeof t&&"value"in t){const{value:e,title:n}=t,i=ux(e);return i?"string"==typeof n?{...i,title:n}:i:null}return null}function dx(t){return Array.isArray(t)?t.map(ux).filter(t=>null!==t):[]}function fx(t){return null==t||""===t||"number"==typeof t&&isNaN(t)}function mx(t,e){if(!e.length)return 0;if("number"==typeof t&&Number.isInteger(t))return t>=0&&t<e.length?t:0;if("string"==typeof t){const n=e.findIndex(e=>e.key===t);if(n>=0)return n;const i=e.findIndex(e=>e.title===t);if(i>=0)return i}return 0}function px(t,e,n,i){const o={id:`${e.id}→${n.id}@${i.id}`,column:t,source:e,target:n,origin:i,value:0,rows:[],paths:new Set,sy0:0,sy1:0,ty0:0,ty1:0};return e.sourceBands.push(o),n.targetBands.push(o),o}function gx(t,e,n,i=0){const o=e.map(()=>new Map),r=e.map(()=>[]),a=new Map,s=[],c=new Map,l=[],h=[],u=Math.max(0,Math.min(e.length-1,i));let d=0;return t.forEach((t,i)=>{const f=e.map(e=>e.accessor(t,i));if(!e.length||f.some(fx))return;const m=Number(n(t,i));if(!Number.isFinite(m)||m<=0)return;const p=h.length;h.push(t),d+=m;const g=f.map((t,e)=>{const n=String(t);let i=o[e].get(n);return i||(i=function(t,e,n){const i=String(e);return{id:`${t}|${i}`,column:t,category:e,label:i,value:0,first:n,rank:n,rows:[],paths:new Set,sourceBands:[],targetBands:[],x0:0,x1:0,y0:0,y1:0}}(e,t,r[e].length),o[e].set(n,i),r[e].push(i)),i.value+=m,i.rows.push(p),i}),y=g.map(t=>t.id).join("\0");let x=c.get(y);void 0===x&&(x=l.length,c.set(y,x),l.push({nodes:g,value:0,rows:[]})),l[x].value+=m,l[x].rows.push(p);const b=g[u];for(const t of g)t.paths.add(x);for(let t=0;t<g.length-1;t++){const e=`${g[t].id}\0${g[t+1].id}\0${b.id}`;let n=a.get(e);n||(n=px(t,g[t],g[t+1],b),a.set(e,n),s.push(n)),n.value+=m,n.rows.push(p),n.paths.add(x)}}),{columns:r,bands:s,paths:l,rows:h,colorBy:u,total:d}}function yx(t,e){const n=new Array(e).fill(void 0);n[t.origin.column]=t.origin.label,n[t.source.column]=t.source.label,n[t.target.column]=t.target.label;const i=n.findIndex(t=>void 0!==t);let o=n.length-1;for(;o>i&&void 0===n[o];)o--;const r=[];for(let t=i;t<=o;t++){const e=n[t];void 0!==e?r.push(e):"…"!==r[r.length-1]&&r.push("…")}return r.join(" → ")}cx._displayName="Viz";const xx=(t,e)=>t.first-e.first,bx=(t,e)=>e.value-t.value||xx(t,e);function _x(t,e){const n=new Map;let i=0;for(const t of e)n.set(t,i+t.value/2),i+=t.value;const o=new Map;for(const e of t){let t=0,i=0;for(const o of e.targetBands){const e=n.get(o.source);void 0!==e&&(t+=e*o.value,i+=o.value)}o.set(e,i?t/i:1/0)}return o}function kx(t,e="crossings"){t.columns.forEach((n,i)=>{if("function"==typeof e)n.sort((t,n)=>e(t,n)||xx(t,n));else if("data"===e)n.sort(xx);else if("crossings"===e&&i>0){const e=_x(n,t.columns[i-1]);n.sort((t,n)=>(e.get(t)??0)-(e.get(n)??0)||bx(t,n))}else n.sort(bx);n.forEach((t,e)=>t.rank=e)})}function vx(t,e,n){const i=Math.max(0,e),o=Math.max(1,Math.min(n,t>1?i/(2*t-1):i)),r=t>1?(i-o)/(t-1):0;return{x:Array.from({length:t},(e,n)=>t>1?n*r:(i-o)/2),nodeWidth:o}}function wx(t,e){const{columns:n}=t,i=n.length;if(!i)return;const{x:o,nodeWidth:r}=vx(i,e.width,e.nodeWidth),a=Math.max(0,e.top),s=Math.max(0,e.height-a),c=Math.max(...n.map(t=>t.length)),l=c>1?Math.max(0,Math.min(e.nodePadding,s/2/(c-1))):0,h=n.filter(t=>t.length).map(t=>{const e=t.reduce((t,e)=>t+e.value,0);return e>0?(s-(t.length-1)*l)/e:1/0}),u=Math.max(0,Math.min(...h,1/0)),d=Number.isFinite(u)?u:0;n.forEach((t,e)=>{const n=o[e],i=t.reduce((t,e)=>t+e.value,0)*d+Math.max(0,t.length-1)*l;let c=a+(s-i)/2;for(const e of t)e.x0=n,e.x1=n+r,e.y0=c,e.y1=c+e.value*d,c=e.y1+l});const f=(t,e)=>t.target.rank-e.target.rank||t.origin.rank-e.origin.rank,m=(t,e)=>t.source.rank-e.source.rank||t.origin.rank-e.origin.rank;for(const t of n)for(const e of t){let t=e.y0;for(const n of e.sourceBands.sort(f))n.sy0=t,t+=n.value*d,n.sy1=t;t=e.y0;for(const n of e.targetBands.sort(m))n.ty0=t,t+=n.value*d,n.ty1=t}}function Mx(t){const e=t.source.x1,n=t.target.x0,i=(e+n)/2;return`M${e},${t.sy0}C${i},${t.sy0},${i},${t.ty0},${n},${t.ty0}L${n},${t.ty1}C${i},${t.ty1},${i},${t.sy1},${e},${t.sy1}Z`}const Sx=new WeakMap;function Cx(t){return t&&"object"==typeof t?Sx.get(t):void 0}function $x(t,e){return Sx.set(t,e),t}function Ax(t){const e=Cx(t);return!e||"group"!==e.kind&&"path"!==e.kind?[t]:e.rows}const zx=new WeakMap;function Dx(t){const e=t.schema.dimensions,n=t.schema.colorBy,i=zx.get(t);if(i&&i.input===e&&i.colorBy===n)return i;const o=dx(e),r={input:e,colorBy:n,dims:o,k:mx(n,o)};return zx.set(t,r),r}function Lx(t){return(e,n)=>{const i=Cx(e),{dims:o,k:r}=Dx(t);return i?i.id:o[r]?.accessor(e,n)}}const Fx=1e4;function Nx(t,e,n){const i=(new Ir).data(t.map(t=>({id:`pc-title-${t.key}`,text:t.text}))).x((e,n)=>t[n].x).y((e,n)=>t[n].y).width((e,n)=>t[n].width).height((e,n)=>t[n].height).config(e);return n&&i.locale(n),i}function Bx(t,e,n){if(!t.length)return[];const i=t.map((t,e)=>({key:`${e}`,text:t,x:0,y:0,width:Fx,height:Fx}));return Nx(i,{...e,padding:0},n)._textData().map(t=>Math.ceil(Math.max(0,...t.widths)))}function Ex(t,e,n){if(!t.length)return 0;const i=Nx(t.map(t=>({...t,height:Fx})),{...e,padding:0},n)._textData();return Math.ceil(Math.max(0,...i.map(t=>t.lines.length*t.lH)))}function Rx(t,e,n){return t.length?Nx(t,{...e,padding:0},n).toScene().children.map(t=>{const e={...t,interactive:!1,interactionGroup:"axis"};return delete e.datum,delete e.index,e}):[]}function Px(t,e,n,i){const o=t.length,r=o>1?e[1]-e[0]:i,a=Math.max(1,r/2-4),s=[];return t.forEach((t,r)=>{if(!t)return;const c=e[r]+n/2,l={key:`${r}`,text:t,y:0,height:0};1===o?s.push({...l,x:0,width:Math.max(1,i),anchor:"middle"}):0===r?s.push({...l,x:e[r],width:a+n/2,anchor:"start"}):r===o-1?s.push({...l,x:c-a,width:a+n/2,anchor:"end"}):s.push({...l,x:c-a,width:2*a,anchor:"middle"})}),s}function Tx(t,e){return{fontColor:Ws(t),fontSize:12,fontWeight:600,textAnchor:(t,n)=>e[n]?.anchor??"middle",verticalAlign:"bottom",...t.schema.dimensionTitleConfig??{}}}function Ox(t,e,n){const i=Ex(t,e,n);for(const e of t)e.height=i;return i}function Wx(t,e,n){return Rx(t,e,n).map(t=>({...t,key:`alluvial-${String(t.key)}`}))}const Hx=()=>1;function jx(t){const e=V(t.schema.value);if(e)return e;return(0,t.schema.translate)(t.schema.value===Hx?"Count":"Value")}function Ix(t,e,n){if(t.column===n)return t.category;return`${e[t.column]?.title||`${t.column+1}`}: ${t.label}`}function Gx(t,e,n){return t.paths.slice().sort((t,e)=>{for(let n=0;n<t.nodes.length;n++){const i=t.nodes[n].rank-e.nodes[n].rank;if(i)return i}return 0}).map(i=>{const o={};i.nodes.forEach((t,n)=>{o[e[n].title||`${n+1}`]=t.category}),o[n]=i.value;const r=i.nodes[t.colorBy];return $x(o,{kind:"path",id:r.category,rows:i.rows.map(e=>t.rows[e])})})}function qx(t,e,i){return n.merge(i.map(t=>e.rows[t]),t.schema.aggs)}const Vx=({viz:t})=>{const e=t,{width:n,height:i}=kt(e),o=(e._filteredData??[]).flatMap(Ax),{dims:r,k:a}=Dx(e),s=gx(o,r,e.schema.value,a);kx(s,e.schema.nodeSort);const c=vx(r.length,n,e.schema.nodeWidth),l=Px(r.map(t=>t.title),c.x,c.nodeWidth,n),h=Tx(e,l),u=Ox(l,h,e.schema.locale);wx(s,{width:n,height:i,top:u?u+8:0,nodeWidth:e.schema.nodeWidth,nodePadding:e.schema.nodePadding});const d=s.columns.flat().map((t,n)=>({__d3plus__:!0,data:$x(qx(e,s,t.rows),{kind:"node",id:Ix(t,r,s.colorBy),node:t}),i:n,id:t.id,shape:"Rect",node:t,x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1})),f=s.bands.map(t=>({band:t,datum:$x(qx(e,s,t.rows),{kind:"band",id:t.origin.category,band:t}),text:yx(t,r.length)})),m={graph:s,dims:r,nodes:d,bands:f,titles:l,titleStyle:h,width:n,height:i};return e.ctx.alluvial=m,"panel"!==e._facetStep&&(e._filteredData=Gx(s,r,jx(e))),{shapeData:d}},Yx={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",rotate(t){const e=t.r??t.data?.r;return"number"==typeof e?e:0},rotateAnchor(t){const e=t.rotateAnchor??t.data?.rotateAnchor;return Array.isArray(e)?e:[(t.w??0)/2,(t.h??0)/2]},fontColor(t,n){const i="function"==typeof this._fill?this._fill(t,n):this._fill;return"string"==typeof i?e.colorContrast(i):"black"}};function Kx(t){const e=pa(t);if(!e.length)return[];const n=(new Ir).config({...Yx,...t.labelConfig??{}}).data(e).renderMode("compute");try{const t=n.toScene();return Array.isArray(t?.children)?t.children:[]}catch{return[]}}function Ux(t,e,n,i,o){if(!e.length||!1===n.label)return[];const r=Array.from(new Set(e.map(t=>t.x0))).sort((t,e)=>t-e),a=r.length>1?r[r.length-1]:void 0,s=t=>t.data??t,c=new Set(e.filter(t=>t.x0===a).map(s)),l=new Map;for(const t of r){const n=e.filter(e=>e.x0===t).sort((t,e)=>t.y0-e.y0);n.forEach((t,e)=>{const i=e?(t.y0+n[e-1].y1)/2:0,r=e<n.length-1?(t.y1+n[e+1].y0)/2:o,a=(t.y0+t.y1)/2;l.set(t,Math.min(a-i,r-a))})}return Kx({data:e,datum:t=>s(t),label:(e,i)=>{const o=e,r=Pm(n.label,s(o),o.i??i);return!1!==r&&(void 0===r?Wm(t,o,i):r)},x:t=>t.x0,y:t=>t.y0,aes:()=>({}),rotate:H(0),id:t=>`sankey-label-${t.id}`,labelBounds:t=>(t=>{const e=r.indexOf(t.x0),n=t.x1-t.x0,o=l.get(t)??(t.y1-t.y0)/2,s=(t.y1-t.y0)/2-o;if(t.x0===a){const i=t.x0-(r[e-1]+n)-10;return{x:-5-i,y:s,width:i,height:2*o}}return{x:n+5,y:s,width:(e<r.length-1?r[e+1]:i)-t.x1-10,height:2*o}})(t),labelConfig:{fontColor:()=>Ws(t),fontResize:!1,fontSize:12,padding:0,textAnchor:t=>c.has(t.data)?"end":"start",verticalAlign:"middle",...jm(t,"Rect")}})}function Xx(t,e){return d.formatAbbreviate(e,t.schema.locale)}const Zx=({viz:t})=>{const e=t.ctx.alluvial;if(!e)return[];const n=t,i=[],o=Hm(n,"Path"),r=Number(n.schema.bandOpacity??.5);e.bands.forEach(({band:t,datum:e,text:a},s)=>{const c=Om(o,e,s);i.push({type:"path",shapeType:"Path",key:`alluvial-band-${t.id}`,d:Mx(t),datum:e,index:s,paint:{...c,fillOpacity:r,opacity:c.opacity??1},aria:{label:`${a}, ${Xx(n,t.value)}.`}})});const a=Hm(n,"Rect");for(const t of e.nodes){const o=e.dims[t.node.column]?.title,r=o?`${o}: ${t.node.label}`:t.node.label;i.push({type:"rect",shapeType:"Rect",key:`alluvial-node-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,index:t.i,paint:Om(a,t.data,t.i),aria:{label:`${r}, ${Xx(n,t.node.value)}.`}})}var s;return i.push(...Ux(n,e.nodes,{...a,label:(s=a,(t,e)=>{const n=Pm(s.label,t,e);if(void 0!==n)return n;const i=Cx(t);return"node"===i?.kind?i.node.label:void 0})},e.width,e.height)),i.push(...Wx(e.titles,e.titleStyle,n.schema.locale)),i};function Qx(t,e){const[n,i]=t.size<=e.size?[t,e]:[e,t];for(const t of n)if(i.has(t))return!0;return!1}function Jx(t,e){const n=Cx(e),i="band"===n?.kind?n.band.paths:"node"===n?.kind?n.node.paths:null;if(!i)return null;const o=new Set;for(const e of t.bands)Qx(e.paths,i)&&o.add(e.id);for(const e of t.columns.flat())Qx(e.paths,i)&&o.add(e.id);return o}function tb(t){const e=t.schema.on.mouseenter;t.schema.on.mouseenter=function(n,i,...o){const r=t.ctx.alluvial,a=r?Jx(r.graph,n):null;if(!a)return e(n,i,...o);Ve(t)&&(t._hoverBucket=!1,t.hover(t=>{const e=function(t){const e=Cx(t);return"band"===e?.kind?e.band.id:"node"===e?.kind?e.node.id:void 0}(t);return void 0!==e&&a.has(e)}))}}function eb(t,e,n){const i=Cx(e),o=t.ctx.alluvial;return"band"===i?.kind?yx(i.band,o?o.dims.length:0):"node"===i?.kind?i.node.label:t._drawLabel(e,n)}function nb(t,e){const n=Cx(e);if("band"!==n?.kind&&"node"!==n?.kind)return[];const i=t.ctx.alluvial,o="band"===n.kind?n.band.value:n.node.value,r=t.schema.translate,a=[];if("node"===n.kind){const e=function(t,e){const n=t.ctx.alluvial;return n?.dims[e.column]?.title??""}(t,n.node);e&&a.push([e,n.node.label])}a.push([jx(t),Xx(t,o)]);const s=i?.graph.total??0;return s>0&&a.push([r("Share"),`${d.formatAbbreviate(o/s*100,t.schema.locale)}%`]),a}function ib(t){return"function"==typeof t?t:"string"==typeof t?q(t):H(t)}const ob={name:"Alluvial",layoutStage:Vx,emit:Zx,thresholdFunction:function(t,e){const n=t.schema.groupBy[0];return e.filter((t,e)=>!fx(n(t,e)))},setup:t=>{t.schema.groupBy=[Lx(t)],function(t){const e=Lx(t);t._mergeRows=i=>{const o=n.merge(i,t.schema.aggs),r=t._data.indexOf(i[0]);return $x(o,{kind:"group",id:e(i[0],r),rows:i})}}(t),tb(t),t.hover=hx},facet:{aspect:1.5},ctx:{},fields:[{key:"bandOpacity",default:.5},{key:"colorBy",default:0},{key:"dimensions",default:[]},{key:"dimensionTitleConfig",merge:!0,default:{}},{key:"nodePadding",default:10},{key:"nodeSort",default:"crossings"},{key:"nodeWidth",default:16},{key:"value",default:Hx,coerce:ib},{key:"shapeConfig",merge:!0,factory:t=>({Rect:{fill:(n,i)=>{const o=Cx(n),r=t.ctx.alluvial;if("node"===o?.kind&&o.node.column!==r?.graph.colorBy)return J(t._theme,t=>t.link,e.colorGray[500]);const a=t.schema.shapeConfig.fill;return"function"==typeof a?a(n,i):a}}})},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>eb(t,e,n),tbody:e=>nb(t,e)})}]};var rb=lx(ob);function ab(t,e){const n=t.length-1;if(n<2||e>=1)return t.slice();const[i,o]=t[0],[r,a]=t[n];return t.map(([t,s],c)=>{const l=c/n,h=i+(r-i)*l,u=o+(a-o)*l;return[h+(t-h)*e,u+(s-u)*e]})}function sb(t,e=3){if(t.length<3)return t.slice();const n=t[0],i=t[t.length-1],o=[n,n,...t,i,i],r=[n];for(let t=0;t+3<o.length;t++){const[n,i,a,s]=[o[t],o[t+1],o[t+2],o[t+3]],c=Math.hypot(a[0]-i[0],a[1]-i[1]),l=Math.min(8,Math.max(1,Math.ceil(c/e)));for(let t=1;t<=l;t++){const e=t/l,o=1-e,c=o*o*o/6,h=(3*e*e*e-6*e*e+4)/6,u=(-3*e*e*e+3*e*e+3*e+1)/6,d=e*e*e/6;r.push([c*n[0]+h*i[0]+u*a[0]+d*s[0],c*n[1]+h*i[1]+u*a[1]+d*s[1]])}}return r[r.length-1]=i,r}function cb(t,e){if(t.length<3)return t.slice();const n=new Uint8Array(t.length);n[0]=n[t.length-1]=1;const i=[[0,t.length-1]];for(;i.length;){const[o,r]=i.pop(),[a,s]=t[o],c=t[r][0]-a,l=t[r][1]-s,h=Math.hypot(c,l);let u=-1,d=0;for(let e=o+1;e<r;e++){const[n,i]=t[e],o=h?Math.abs(c*(s-i)-(a-n)*l)/h:Math.hypot(n-a,i-s);o>d&&(d=o,u=e)}u>=0&&d>e&&(n[u]=1,i.push([o,u],[u,r]))}return t.filter((t,e)=>n[e])}function lb(t,e,n){const i=ab(t,e);return cb(n?sb(i):i,.25)}const hb={strength:.85,cycles:6,iterations:50,compatibility:.4,smoothing:!0},ub=t=>Math.hypot(t[1][0]-t[0][0],t[1][1]-t[0][1]),db=t=>[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2];function fb(t,e){const n=ub(t),i=ub(e);if(!n||!i)return 0;const o=(t[1][0]-t[0][0])*(e[1][0]-e[0][0])+(t[1][1]-t[0][1])*(e[1][1]-e[0][1]);return Math.abs(o/(n*i))}function mb(t,e){const n=ub(t),i=ub(e);if(!n||!i)return 0;const o=(n+i)/2;return 2/(o/Math.min(n,i)+Math.max(n,i)/o)}function pb(t,e){const n=(ub(t)+ub(e))/2,[i,o]=db(t),[r,a]=db(e),s=Math.hypot(i-r,o-a);return n+s?n/(n+s):0}function gb(t,e){const[[n,i],[o,r]]=t,a=o-n,s=r-i,c=a*a+s*s;if(!c)return 0;const l=([t,e])=>{const o=((t-n)*a+(e-i)*s)/c;return[n+o*a,i+o*s]},h=l(e[0]),u=l(e[1]),d=Math.hypot(u[0]-h[0],u[1]-h[1]);if(!d)return 0;const[f,m]=db(t),p=Math.hypot((h[0]+u[0])/2-f,(h[1]+u[1])/2-m);return Math.max(0,1-2*p/d)}function yb(t,e){return Math.min(gb(t,e),gb(e,t))}function xb(t){if(t<=0)return 1/0;if(t>=1)return 1;const e=t=>2/((1+t)/2+2*t/(1+t));let n=1,i=2;for(;e(i)>=t;)i*=2;for(let o=0;o<50;o++){const o=(n+i)/2;e(o)>=t?n=o:i=o}return n}function bb(t){let e=1/0,n=-1/0;for(const i of t)i<e&&(e=i),i>n&&(n=i);return e<=n?[e,n]:[0,0]}function _b(t,e,n,i){const o=t.len[e],r=t.len[n],a=t.dx[e]*t.dx[n]+t.dy[e]*t.dy[n];let s=Math.abs(a)/(o*r);if(s<i)return 0;const c=(o+r)/2;if(s*=2/(c/Math.min(o,r)+Math.max(o,r)/c),s<i)return 0;if(s*=c/(c+Math.hypot(t.mx[e]-t.mx[n],t.my[e]-t.my[n])),s<i)return 0;const l=e=>[[t.x0[e],t.y0[e]],[t.x0[e]+t.dx[e],t.y0[e]+t.dy[e]]];return s*=yb(l(e),l(n)),s<i||s<=0?0:a<0?-s:s}function kb(t,e){const n=t.length,i=function(t){const e=t.length,n={x0:new Float64Array(e),y0:new Float64Array(e),dx:new Float64Array(e),dy:new Float64Array(e),len:new Float64Array(e),mx:new Float64Array(e),my:new Float64Array(e)};return t.forEach(([[t,e],[i,o]],r)=>{n.x0[r]=t,n.y0[r]=e,n.dx[r]=i-t,n.dy[r]=o-e,n.len[r]=Math.hypot(i-t,o-e),n.mx[r]=(t+i)/2,n.my[r]=(e+o)/2}),n}(t),o=Math.min(xb(e),1e6),r=e>0?(1-e)/e:1/0,a=Array.from({length:n},()=>[]),s=Array.from({length:n},()=>[]),c=t.map(db),l=Math.max(1,bb(c.flatMap(t=>[Math.abs(t[0]),Math.abs(t[1])]))[1]),h=t=>Math.min(r*(i.len[t]*(1+o)/2),4*l),u=Array.from(i.len,(t,e)=>h(e)).sort((t,e)=>t-e),d=Math.max(u[n>>1]||l,2*l/256),{cells:f,nx:m,cx:p,cy:g}=function(t,e){const[n,i]=bb(t.map(t=>t[0])),[o,r]=bb(t.map(t=>t[1])),a=Math.max(1,Math.ceil((i-n)/e)+1),s=Math.max(1,Math.ceil((r-o)/e)+1),c=Array.from({length:a*s},()=>[]),l=t=>Math.min(a-1,0|Math.max(0,(t-n)/e)),h=t=>Math.min(s-1,0|Math.max(0,(t-o)/e));return t.forEach((t,e)=>c[h(t[1])*a+l(t[0])].push(e)),{cells:c,nx:a,cx:l,cy:h}}(c,d),y=f.length/m;for(let t=0;t<n&&n>1;t++){if(!i.len[t])continue;const n=h(t);for(let o=g(i.my[t]-n);o<=g(i.my[t]+n)&&o<y;o++)for(let r=p(i.mx[t]-n);r<=p(i.mx[t]+n);r++)for(const n of f[o*m+r]){if(n<=t||!i.len[n])continue;const o=_b(i,t,n,e);o&&(a[t].push(n),s[t].push(o),a[n].push(t),s[n].push(o))}}const x=new Int32Array(n+1);for(let t=0;t<n;t++)x[t+1]=x[t]+a[t].length;return{offsets:x,neighbors:Int32Array.from(a.flat()),weights:Float32Array.from(s.flat())}}function vb(t,e){const n=Math.max(1,Math.round(e)),i=[0];for(let e=1;e<t.length;e++)i.push(i[e-1]+Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]));const o=i[i.length-1],r=[t[0]];let a=1;for(let e=1;e<n;e++){const s=o*e/n;for(;a<t.length-1&&i[a]<s;)a++;const c=i[a]-i[a-1],l=c?(s-i[a-1])/c:0;r.push([t[a-1][0]+(t[a][0]-t[a-1][0])*l,t[a-1][1]+(t[a][1]-t[a-1][1])*l])}return r.push(t[t.length-1]),r}function wb(t,e,n,i){const o=new Float64Array(t.length*i*2);return t.forEach((t,r)=>{const a=[t[0]];for(let t=0;t<n;t++){const i=2*(r*n+t);a.push([e[i],e[i+1]])}a.push(t[1]);const s=vb(a,i+1);for(let t=0;t<i;t++)o[2*(r*i+t)]=s[t+1][0],o[2*(r*i+t)+1]=s[t+1][1]}),o}function Mb(t,e,n,i,o,r,a){const{offsets:s,neighbors:c,weights:l}=n;for(let n=0;n<t.length;n++){const h=n*r,u=e[n]?.1*(r+1)/e[n]:0;for(let e=0;e<r;e++){const d=2*(h+e),f=i[d],m=i[d+1],p=e?i[d-2]:t[n][0][0],g=e?i[d-1]:t[n][0][1];let y=u*(p+(e<r-1?i[d+2]:t[n][1][0])-2*f),x=u*(g+(e<r-1?i[d+3]:t[n][1][1])-2*m);for(let t=s[n];t<s[n+1];t++){const n=l[t],o=n<0?r-1-e:e,a=2*(c[t]*r+o),s=i[a]-f,h=i[a+1]-m,u=Math.sqrt(s*s+h*h);if(u<1e-6)continue;const d=Math.abs(n)/u;y+=s*d,x+=h*d}o[d]=f+a*y,o[d+1]=m+a*x}}}function Sb(){return{entries:new Map,runs:0}}function Cb(t={}){const e=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e,n=hb;return{strength:Math.min(1,Math.max(0,e(t.strength,n.strength))),cycles:Math.max(0,e(t.cycles,n.cycles)),iterations:Math.max(0,e(t.iterations,n.iterations)),compatibility:e(t.compatibility,n.compatibility),smoothing:t.smoothing??n.smoothing}}function $b(t,e){const n=t=>Math.round(10*t),i=t.map(([t,e])=>`${n(t[0])},${n(t[1])},${n(e[0])},${n(e[1])}`).join(";");return`${e.cycles}|${e.iterations}|${e.compatibility}|${i}`}function Ab(t,e,n){const i=n?$b(t,e):"",o=n?.entries.get(i);if(o)return n.entries.delete(i),n.entries.set(i,o),o;const r=function(t){const[e,n]=bb(t.flatMap(t=>[t[0][0],t[1][0]])),[i,o]=bb(t.flatMap(t=>[t[0][1],t[1][1]])),r=1e3/(Math.max(n-e,o-i)||1);return{to:([t,n])=>[(t-e)*r,(n-i)*r],from:([t,n])=>[t/r+e,n/r+i]}}(t),a=function(t,e){const n=kb(t,e.compatibility),i=Float64Array.from(t.map(ub));let o=1,r=new Float64Array(2*t.length);t.forEach((t,e)=>{const[n,i]=db(t);r[2*e]=n,r[2*e+1]=i});let a=3,s=Math.max(0,Math.round(e.iterations));const c=Math.max(0,Math.round(e.cycles));for(let e=0;e<c;e++){e&&(r=wb(t,r,o,2*o),o*=2);let c=new Float64Array(r.length);for(let e=0;e<s;e++)Mb(t,i,n,r,c,o,a),[r,c]=[c,r];a/=2,s=Math.max(1,Math.round(2*s/3))}return t.map((t,e)=>{const n=[t[0]];for(let t=0;t<o;t++)n.push([r[2*(e*o+t)],r[2*(e*o+t)+1]]);return n.push(t[1]),n})}(t.map(([t,e])=>[r.to(t),r.to(e)]),e).map((e,n)=>{const i=e.map(r.from);return i[0]=t[n][0],i[i.length-1]=t[n][1],i});if(n)for(n.runs++,n.entries.set(i,a);n.entries.size>4;)n.entries.delete(n.entries.keys().next().value);return a}function zb(t,e={},n){if(!t.length)return[];const i=Cb(e);return Ab(t,i,n).map((e,n)=>ub(t[n])?lb(e,i.strength,i.smoothing):[t[n][0],t[n][1]])}const Db=new WeakMap,Lb=new WeakMap;function Fb(t){return t&&"object"==typeof t?Db.get(t):void 0}function Nb(t){return void 0!==Fb(t)}function Bb(t,e,n,i,o=["source","target"]){const r={...t,source:e.data,target:n.data};return Db.set(r,{index:i,raw:t,source:e,target:n,endKeys:o}),r}function Eb(t,e){const n=Fb(t),i="number"==typeof e?e:Number(e);return n&&null!==e&&""!==e&&Number.isFinite(i)&&(n.value=i),e}function Rb(t,e,n){const i=new Set(e.map(t=>Fb(t)?.value)),o=new Map(n.map(t=>[t.id,[]])),r={links:e,sized:i.size>1,byNode:o};for(const t of e){const e=Fb(t);e.graph=r;const n=new Set([e.source.id,e.target.id]);for(const e of n)o.has(e)||o.set(e,[]),o.get(e).push(t)}let a=Lb.get(t);a||Lb.set(t,a=new WeakMap);for(const t of n)t.data&&"object"==typeof t.data&&a.set(t.data,{id:t.id,graph:r});return t.ctx.linkGraph=r,r}function Pb(t){Lb.delete(t)}function Tb(t,e){if(e&&"object"==typeof e)return Lb.get(t)?.get(e)}const Ob=new Set(["ar","dv","fa","he","ps","ur","yi"]);function Wb(t){const e=`${t??""}`.split(/[-_]/)[0].toLowerCase();return Ob.has(e)}function Hb(t){return Wb(t.schema.locale)||"undefined"!=typeof document&&!!document.body&&r.rtl()?["←","→"]:["→","←"]}function jb(t,e){return void 0!==e.label?e.label:`${t._drawLabel(e.data,e.i)??e.id}`}function Ib(t,e){const n=Fb(e);if(!n)return"";const[i]=Hb(t);return`${jb(t,n.source)} ${i} ${jb(t,n.target)}`}function Gb(t,e){const n=t.schema.locale;return"number"==typeof e?Number.isFinite(e)?d.formatAbbreviate(e,n):null:"string"==typeof e?e:"boolean"==typeof e?`${e}`:e instanceof Date&&!isNaN(e.getTime())?e.toLocaleDateString(n):null}function qb(t,e){const n=Fb(e);if(!n)return[];const i=[];let o=!1;for(const[e,r]of Object.entries(n.raw)){if(n.endKeys.includes(e)||e.startsWith("__"))continue;const a=Gb(t,r);null!==a&&(r===n.value&&(o=!0),i.push([e,a]))}const r=[];return n.graph?.sized&&void 0!==n.value&&!o&&r.push([t.schema.translate("Value"),Gb(t,n.value)]),r.concat(i)}function Vb(t,e){const n=Fb(e);if(!n)return"";const i=n.graph?.sized&&void 0!==n.value?`, ${n.value}`:"";return`${jb(t,n.source)} ${t.schema.translate("to")} ${jb(t,n.target)}${i}.`}function Yb(t,e,n){const i=Fb(e),o=new Set([i.source.id,i.target.id]);return(e,r)=>{const a=Fb(e);if(a)return a.index===i.index;const s=Tb(t,e)?.id??n?.(e,r);return void 0!==s&&o.has(`${s}`)}}function Kb(t,e){return(t.byNode.get(e)??[]).map(t=>{const n=Fb(t),i=n.source.id===e;return{link:t,other:i?n.target:n.source,outgoing:i,loop:n.source.id===n.target.id,value:n.value,index:n.index}}).sort((t,e)=>(e.value??-1/0)-(t.value??-1/0)||t.index-e.index).map(({link:t,other:e,outgoing:n,loop:i,value:o})=>({link:t,other:e,outgoing:n,loop:i,value:o}))}function Ub(t,e,n){const i=Tb(t,e);if(!i)return null;const o=Kb(i.graph,i.id),r=new Set([i.id,...o.map(t=>t.other.id)]),a=new Set(o.map(t=>Fb(t.link).index));return(e,i)=>{const o=Fb(e);if(o)return a.has(o.index);const s=Tb(t,e)?.id??n?.(e,i);return void 0!==s&&r.has(`${s}`)}}function Xb(t,e){const n=t.schema.nodeTooltipLinks;return!1===n?0:!0===n?3:"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.floor(n)):e.sized?3:0}function Zb(t,e){const n=Tb(t,e);if(!n)return[];const{graph:i,id:o}=n,r=Kb(i,o),a=[[t.schema.translate("Connections"),`${r.length}`]],[s,c]=Hb(t);for(const e of r.slice(0,Xb(t,i))){const n=i.sized&&void 0!==e.value?Gb(t,e.value):"";a.push([`${e.loop?"↻":e.outgoing?s:c} ${jb(t,e.other)}`,n])}return a}function Qb(t){return{title:(e,n)=>Nb(e)?Ib(t,e):t._drawLabel(e,"number"==typeof e.i?e.i:n),tbody:e=>Nb(e)?qb(t,e):Zb(t,e)}}function Jb(t,e,n,i){const o="number"==typeof i?i:1;return{type:"path",key:`${t}::hit`,d:e,datum:n,index:Fb(n)?.index??0,paint:{fill:"none",stroke:"transparent",strokeWidth:Math.max(8,o+4)}}}function t_(t){return!!t&&("source"===t||"target"===t||"function"==typeof t?t:q(t))}function e_(t,e){const n=t.datum??t;return{row:n,index:Fb(n)?.index??e}}function n_(t,n){if(Ms(n)){const e=As(t,n);return"string"==typeof e?e:void 0}if("string"==typeof n&&""!==n)return i.color(n)?n:e.colorAssign(n,Re(t))}function i_(t){const e=t.schema.linkColor;if(!e)return()=>{};if("source"===e||"target"===e){const n=new Map;return(i,o)=>{const r=Fb(i)?.[e];if(!r)return;const a=o?.[e]?.shape,s="string"==typeof a?a:"Circle";n.has(s)||n.set(s,Hm(t,s));const c=Pm(n.get(s).fill,r.data,r.i);return"string"==typeof c?c:void 0}}return"function"!=typeof e?()=>{}:n=>{const i=e(n,Fb(n)?.index??0);return Ms(i)&&Ss(t,n,i),n_(t,i)}}const o_=[["right",1,0],["left",-1,0],["top",0,-1],["bottom",0,1],["top-right",Math.SQRT1_2,-Math.SQRT1_2],["top-left",-Math.SQRT1_2,-Math.SQRT1_2],["bottom-right",Math.SQRT1_2,Math.SQRT1_2],["bottom-left",-Math.SQRT1_2,Math.SQRT1_2]],r_=1e-6;function a_(t,e,n,i,o=0){const r=t.r+o,{x:a,y:s}=t;switch(e){case"right":return{x:a+r,y:s-i/2,width:n,height:i};case"left":return{x:a-r-n,y:s-i/2,width:n,height:i};case"top":return{x:a-n/2,y:s-r-i,width:n,height:i};case"bottom":return{x:a-n/2,y:s+r,width:n,height:i}}const c=r*Math.SQRT1_2;return{x:e.endsWith("right")?a+c:a-c-n,y:e.startsWith("top")?s-c-i:s+c,width:n,height:i}}function s_(t){let e=0;for(let n=0,i=t.length-1;n<t.length;i=n++)e+=t[i][0]*t[n][1]-t[n][0]*t[i][1];return e/2}function c_(t){const e=s_(t);if(Math.abs(e)<r_)return null;let n=0,i=0;for(let e=0,o=t.length-1;e<t.length;o=e++){const r=t[o][0]*t[e][1]-t[e][0]*t[o][1];n+=(t[o][0]+t[e][0])*r,i+=(t[o][1]+t[e][1])*r}return[n/(6*e),i/(6*e)]}function l_(t,e){const n=o_.map(t=>t[0]),i=e?c_(e):null;if(!i||!e)return n;const o=i[0]-t.x,r=i[1]-t.y,a=Math.sqrt(Math.abs(s_(e)));if(Math.hypot(o,r)<.1*a)return n;const s=Math.atan2(r,o),c=([,t,e])=>{let n=Math.abs(Math.atan2(e,t)-s);n>Math.PI&&(n=2*Math.PI-n);return 180*n/Math.PI+(t&&e?20:0)};return o_.map((t,e)=>({side:t[0],score:c(t),i:e})).sort((t,e)=>t.score-e.score||t.i-e.i).map(t=>t.side)}function h_(t,e,n){const i=[];for(let o=0;o<t.length;o++){const r=t[o],a=t[(o+t.length-1)%t.length];e(r)?(e(a)||i.push(n(a,r)),i.push(r)):e(a)&&i.push(n(a,r))}return i}const u_=(t,e,n)=>[n,t[1]+(e[1]-t[1])*(n-t[0])/(e[0]-t[0])],d_=(t,e,n)=>[t[0]+(e[0]-t[0])*(n-t[1])/(e[1]-t[1]),n];function f_(t,e){const n=t.width*t.height;if(!(n>0)||e.length<3)return 0;const i=t.x+t.width,o=t.y+t.height;let r=h_(e,e=>e[0]>=t.x,(e,n)=>u_(e,n,t.x));return r=h_(r,t=>t[0]<=i,(t,e)=>u_(t,e,i)),r=h_(r,e=>e[1]>=t.y,(e,n)=>d_(e,n,t.y)),r=h_(r,t=>t[1]<=o,(t,e)=>d_(t,e,o)),r.length<3?0:Math.min(1,Math.abs(s_(r))/n)}function m_(t,e){const n=Math.max(t.x-e.x,0,e.x-(t.x+t.width)),i=Math.max(t.y-e.y,0,e.y-(t.y+t.height));return n*n+i*i<e.r*e.r-r_}function p_(t,e){return t.x<e.x+e.width-r_&&e.x<t.x+t.width-r_&&t.y<e.y+e.height-r_&&e.y<t.y+t.height-r_}function g_(t,e){return t.x>=e.x-r_&&t.y>=e.y-r_&&t.x+t.width<=e.x+e.width+r_&&t.y+t.height<=e.y+e.height+r_}class y_{keys(t){const e=this.size,n=[];for(let i=Math.floor(t.x/e);i<=Math.floor((t.x+t.width)/e);i++)for(let o=Math.floor(t.y/e);o<=Math.floor((t.y+t.height)/e);o++)n.push(`${i},${o}`);return n}add(t,e){for(const n of this.keys(t)){const t=this.cells.get(n);t?t.push(e):this.cells.set(n,[e])}}near(t){const e=new Set;for(const n of this.keys(t))for(const t of this.cells.get(n)??[])e.add(t);return e}constructor(t){this.size=t,this.cells=new Map}}function x_(t,e,n,i={}){const o=i.gap??3,r=i.cellCoverage??.5,a=e.map(()=>({position:"hidden"})),s=t=>!!t&&[t.x,t.y,t.r].every(Number.isFinite),c=[];if(e.forEach((e,n)=>{s(t[e.circle])&&("inside"===e.position||"outside"!==e.position&&e.fitsInside?a[n]={position:"inside"}:e.width>0&&e.height>0&&c.push(n))}),!c.length)return a;const l=eh(t.map((t,e)=>({x:t.x,y:t.y,r:t.r,item:e})),n),h=c.map(t=>Math.max(e[t].width,e[t].height)),u=new y_(Math.max(16,h.reduce((t,e)=>t+e,0)/h.length));t.forEach((t,e)=>{s(t)&&u.add((t=>({x:t.x-t.r,y:t.y-t.r,width:2*t.r,height:2*t.r}))(t),e)});const d=new y_(u.size);c.sort((n,i)=>t[e[i].circle].r-t[e[n].circle].r||n-i);for(const i of c){const s=e[i],c=t[s.circle],h=l.cell(s.circle);if(h&&g_({...c,width:0,height:0},n))for(const e of l_(c,h)){const l=a_(c,e,s.width,s.height,o);if(g_(l,n)&&(![...u.near(l)].some(e=>m_(l,t[e]))&&!([...d.near(l)].some(t=>p_(l,t))||f_(l,h)<r-r_))){a[i]={position:"outside",side:e,box:l},d.add(l,l);break}}}return a}const b_=t=>r.fontExists(t??s.fontFamily);function __(t,e,n){const i=r.parseSides(e.padding??0),o=e.width-i.left-i.right,a=e.height-i.top-i.bottom,c=n.lineHeight??1.2*n.size;if(!t||o<=n.size||a<c)return!1;const l=s.textWrap().fontFamily(b_(n.family)).fontSize(n.size).fontWeight(n.weight??400).lineHeight(c).shape(e.shape??"square").width(o).height(a)(t);return!l.truncated&&l.lines.some(t=>""!==t)}function k_(t,e){const n=r.textWidth(t,{"font-family":b_(e.family),"font-size":e.size,"font-weight":e.weight??400}),i=e.lineHeight??1.2*e.size;return{width:Math.ceil(n)+2,height:Math.ceil(i)+1}}function v_(t){const e=t.schema.pointLabelConfig??{},n=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e,{fontMin:i,fontSize:o,padding:r,...a}=e;return{fontMin:n(i,10),fontSize:n(o,11),padding:n(r,3),text:a}}function w_(t,e,n){const i=t.schema.labelPosition,o="function"==typeof i?i(e,n):i;return"inside"===o||"outside"===o?o:"auto"}function M_(t,e,n){const i=v_(t),o=function(t){const{fontFamily:e,fontWeight:n}=t.text;return{size:t.fontSize,family:e,weight:n}}(i),r=[];e.forEach((t,e)=>{const n=t.text;("string"==typeof n&&n.trim()||"number"==typeof n)&&r.push({item:t,at:e,text:`${n}`.trim()})});const a=r.map(({item:e,at:n,text:r})=>{const a=w_(t,e.datum,e.index),s=e.inside??{width:2*e.r,height:2*e.r},c="auto"===a&&__(r,s,{...s.font,size:i.fontMin}),l="inside"===a||c?{width:0,height:0}:k_(r,function(t,e){const n=t=>"function"==typeof t?t(e.datum,e.index):t;return{size:t.size,family:n(t.family),weight:n(t.weight)}}(o,e));return{circle:n,...l,position:a,fitsInside:c}}),s=x_(e.map(({x:t,y:e,r:n})=>({x:t,y:e,r:Number.isFinite(n)?n:0})),a,n,{gap:i.padding}),c=new Map;return r.forEach(({item:t,text:e},n)=>c.set(t.key,{...s[n],mode:a[n].position,text:e})),c}function S_(t){const e=t.endsWith("right")?"start":t.endsWith("left")?"end":"middle";return"middle"!==e&&r.rtl()?"start"===e?"end":"start":e}function C_(t,e,n={}){if(!e.length)return[];const i=v_(t),o=new Map(e.map(t=>[`${t.id}_0`,t])),r=1.2*i.fontSize;return Kx({data:e,label:t=>t.text,labelBounds:t=>({...t.box}),x:H(0),y:H(0),aes:H({}),rotate:H(0),id:t=>t.id,datum:t=>t.datum,labelConfig:{fontColor:()=>Ws(t),...n,fontResize:!1,fontSize:i.fontSize,lineHeight:r,padding:0,pointerEvents:"none",textAnchor:t=>S_((t=>o.get(String(t.id))?.side??"right")(t)),verticalAlign:"middle",...i.text}})}function $_(t,e){const n=[];for(const[i,o]of t)"outside"===o.position&&n.push({...e(i),text:o.text,side:o.side,box:o.box});return n}function A_(t,e,n){return e&&"auto"===e.mode&&"inside"===e.position?Math.max(n,v_(t).fontMin):n}function z_(t,e,n=0,i=0){const o=e[0]-t[0],r=e[1]-t[1],a=Math.hypot(o,r),s=Math.atan2(r,o);if(!a)return{x:t[0],y:t[1],angle:s};const c=(n+Math.max(0,a-n-i)/2)/a;return{x:t[0]+o*c,y:t[1]+r*c,angle:s}}function D_(t,e,n,i,o){const r=1-o,a=r*r*r,s=3*r*r*o,c=3*r*o*o,l=o*o*o;return[a*t[0]+s*e[0]+c*n[0]+l*i[0],a*t[1]+s*e[1]+c*n[1]+l*i[1]]}function L_(t,e,n,i,o){const r=1-o,a=3*r*r*(e[0]-t[0])+6*r*o*(n[0]-e[0])+3*o*o*(i[0]-n[0]),s=3*r*r*(e[1]-t[1])+6*r*o*(n[1]-e[1])+3*o*o*(i[1]-n[1]);return a||s?Math.atan2(s,a):Math.atan2(i[1]-t[1],i[0]-t[0])}function F_(t,e,n,i,o=64){const r=[0];let a=t;for(let s=1;s<=o;s++){const c=D_(t,e,n,i,s/o);r.push(r[s-1]+Math.hypot(c[0]-a[0],c[1]-a[1])),a=c}const s=r[o]/2;let c=1;for(;c<o&&r[c]<s;)c++;const l=r[c]-r[c-1],h=(c-1+(l?(s-r[c-1])/l:0))/o,[u,d]=D_(t,e,n,i,h);return{x:u,y:d,angle:L_(t,e,n,i,h)}}function N_(t){let e=180*t/Math.PI;return e=((e+90)%180+180)%180-90,0===e?0:Math.round(1e6*e)/1e6}function B_(t){const e=t.angle*Math.PI/180,n=Math.cos(e),i=Math.sin(e),o=t.width/2,r=t.height/2;return[[-o,-r],[o,-r],[o,r],[-o,r]].map(([e,o])=>[t.x+e*n-o*i,t.y+e*i+o*n])}function E_(t,e){for(const n of[t,e])for(let i=0;i<n.length;i++){const o=n[i],r=n[(i+1)%n.length],a=r[1]-o[1],s=o[0]-r[0],c=t=>{let e=1/0,n=-1/0;for(const[i,o]of t){const t=i*a+o*s;t<e&&(e=t),t>n&&(n=t)}return[e,n]},[l,h]=c(t),[u,d]=c(e),f=1e-9*Math.hypot(a,s);if(h<=u+f||d<=l+f)return!1}return!0}const R_=t=>({x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height});function P_(t,e){return t.angle||e.angle?E_(B_(t),B_(e)):p_(R_(t),R_(e))}function T_(t,e){const n=-t.angle*Math.PI/180,i=e.x-t.x,o=e.y-t.y,r={x:i*Math.cos(n)-o*Math.sin(n),y:i*Math.sin(n)+o*Math.cos(n),r:e.r};return m_(R_({...t,x:0,y:0}),r)}function O_(t,e){return t.angle?E_(B_(t),[[e.x,e.y],[e.x+e.width,e.y],[e.x+e.width,e.y+e.height],[e.x,e.y+e.height]]):p_(R_(t),e)}function W_(t,e){const n=e.circles??[],i=e.boxes??[],o=e.labels??[],r=[],a=[];for(const e of t){const t=e.boxes??[e.box];if(!t.length||!t.every(t=>t.width>0&&t.height>0))continue;const s=t=>n.some(e=>T_(t,e))||i.some(e=>O_(t,e))||o.some(e=>P_(t,e))||a.some(e=>P_(t,e));t.some(s)||(r.push(e),a.push(...t))}return r}const H_=t=>Math.round(100*t)/100;function j_(t){return t.map(([t,e],n)=>`${n?"L":"M"}${H_(t)},${H_(e)}`).join("")}function I_(t,e,n){const i=G_(t),o=Math.max(0,e),r=Math.max(0,n);if(!o&&!r)return t.slice();if(o+r>=i){const e=q_(t,i*o/(o+r||1));return[[e.x,e.y],[e.x,e.y]]}const a=[];let s=0;const c=q_(t,o),l=q_(t,i-r);a.push([c.x,c.y]);for(let e=1;e<t.length-1;e++)s+=Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]),s>o&&s<i-r&&a.push(t[e]);return a.push([l.x,l.y]),a}function G_(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n][0]-t[n-1][0],t[n][1]-t[n-1][1]);return e}function q_(t,e){const n=t.length-1;let i=Math.max(0,e);for(let e=1;e<=n;e++){const[o,r]=t[e-1],[a,s]=t[e],c=Math.hypot(a-o,s-r);if(!c)continue;const l=Math.atan2(s-r,a-o);if(i<=c||e===n){const t=Math.min(1,i/c);return{x:o+(a-o)*t,y:r+(s-r)*t,angle:l}}i-=c}const[o,r]=t[0]??[0,0];return{x:o,y:r,angle:0}}function V_(t){return q_(t,G_(t)/2)}function Y_(t){const e=t.map(t=>t[0]),n=t.map(t=>t[1]);return[[Math.min(...e),Math.min(...n)],[Math.max(...e),Math.max(...n)]]}function K_(t,e){if(!t.length||e<=0)return 0;const[n,i]=t[0];let o=0;for(let r=1;r<t.length;r++){const[a,s]=t[r-1],[c,l]=t[r],h=c-a,u=l-s,d=Math.hypot(h,u);if(Math.hypot(c-n,l-i)>=e&&d){const t=a-n,r=s-i,c=h*h+u*u,l=2*(t*h+r*u),f=t*t+r*r-e*e,m=(-l+Math.sqrt(Math.max(0,l*l-4*c*f)))/(2*c);return o+Math.min(1,Math.max(0,m))*d}o+=d}return o}const U_=.75*Math.PI;function X_(t){return a.samplePath(t).points.map(([t,e])=>[t,e])}function Z_(t,e=0,n=0){if(t.length<2)return[];const i=Tp(t),o=K_(t,e),r=i-K_([...t].reverse(),n);return r>o?Hp(t,o,r):[]}function Q_(t,e){let n=1/0,i=0,o=0;for(let r=1;r<t.length;r++){const[a,s]=t[r-1],[c,l]=t[r],h=c-a,u=l-s,d=h*h+u*u,f=d?Math.max(0,Math.min(1,((e[0]-a)*h+(e[1]-s)*u)/d)):0,m=Math.hypot(a+h*f-e[0],s+u*f-e[1]);m<n&&(n=m,i=o+f*Math.sqrt(d)),o+=Math.sqrt(d)}return i}function J_(t,e){const n=[],i=[];let o=0,r=null;for(let e=1;e<t.length;e++){const a=t[e][0]-t[e-1][0],s=t[e][1]-t[e-1][1],c=Math.hypot(a,s);if(!c)continue;const l=Math.atan2(s,a);if(null!==r){let t=Math.abs(l-r);t>Math.PI&&(t=2*Math.PI-t),n.push(o),i.push(t)}r=l,o+=c}let a=0,s=0,c=0;for(let t=0;t<i.length;t++){for(s+=i[t];n[t]-n[c]>e;)s-=i[c++];a=Math.max(a,s)}return a}function tk(t,e,n,i=U_,o=0){const r=Tp(t);let a=Math.max(0,Math.min(n,r));for(;;){const n=Math.max(a/2,Math.min(r-a/2,e)),s=Hp(t,n-a/2,n+a/2),c=Math.min(o,Tp(s)),l=Bg(s)<=i&&(!o||J_(s,c)<=(c+2)/o);if(a<1||l)return Op(s);a*=.9}}function ek(t,e,n,i,o,r=2){if(t.length<2)return null;const a=tk(t,e,n+i+2*o,U_,r*i);if(a.length<2)return null;if(Bg(a)<=.03)return null;const s=Tp(a);if(s-2*o<Math.min(n,2*i))return null;return{stretch:a,text:Wp(Hp(a,o,s-o),-.3*i)}}function nk(t,e,n){const i=Tp(t.stretch),o=Tp(t.text),r=o?e*Math.max(0,i-2*n)/o:0,a=Math.min(i/2,r/2+n);return Hp(t.stretch,i/2-a,i/2+a)}const ik={rotate:"along",fontSize:10,padding:2,backgroundOpacity:.85,minRadius:2};function ok(t){const e=t.schema.linkLabelConfig??{},n=(t,e)=>"number"==typeof t&&Number.isFinite(t)&&t>=0?t:e,{rotate:i,fontSize:o,padding:r,backgroundOpacity:a,minRadius:s,...c}=e;return{rotate:"horizontal"===i?"horizontal":"along",fontSize:n(o,ik.fontSize)||1,padding:n(r,ik.padding),backgroundOpacity:Math.min(1,n(a,ik.backgroundOpacity)),minRadius:n(s,ik.minRadius),text:c}}function rk(t,e){return"number"==typeof t?Number.isFinite(t)?d.formatAbbreviate(t,e):"":"string"==typeof t&&t.trim()?t:""}function ak(t){const e=[],n=t=>{const i=t.children;if(i&&i.forEach(n),"text"!==t.type)return;const o=t.font?.size??0,r=t.transform??{},[s,c]=r.rotateAnchor??[0,0],l=r.rotate??0,h=l*Math.PI/180,u=Math.cos(h),d=Math.sin(h);if(t.path)for(const n of a.pathTextBoxes(t)){const t=n.x-s,i=n.y-c;e.push({x:(r.x??0)+s+t*u-i*d,y:(r.y??0)+c+t*d+i*u,width:n.width,height:n.height,angle:l+n.angle})}else for(const n of t.lines??[]){if(!n.text||!o)continue;const i=n.width||k_(n.text,{family:t.font.family,size:o,weight:t.font.weight}).width,h=a.lineLeft({x:n.x,width:i},t.font)+i/2-s,f=n.y-.3*o-c;e.push({x:(r.x??0)+s+h*u-f*d,y:(r.y??0)+c+h*d+f*u,width:i,height:o,angle:l})}};return t.forEach(n),e}function sk(t,e,n){const i=t.schema.linkLabel;if("function"!=typeof i||!e.length)return[];const o=ok(t),r={family:o.text.fontFamily,size:o.fontSize,weight:o.text.fontWeight},a=o.padding,s=[],c=[];e.forEach((e,n)=>{const{row:l,index:h}=e_(e.link,e.i),u=rk(i(l,h),t.schema.locale);if(!u)return;const d=k_(u,r),f={key:e.key,link:l,text:u,textWidth:d.width,textHeight:d.height,priority:e.priority??0,order:n},m="along"===o.rotate?e.path:null;if(m&&m.length>1){const t=ek(m,e.anchor?Q_(m,[e.anchor.x,e.anchor.y]):Tp(m)/2,d.width,o.fontSize,a,o.minRadius);if(t){const[e,n]=t.stretch[Math.floor(t.stretch.length/2)];return void c.push({base:{...f,box:{x:e,y:n,width:0,height:0,angle:0}},spot:t})}}e.anchor&&s.push({...f,box:{x:e.anchor.x,y:e.anchor.y,width:d.width+2*a,height:d.height+2*a,angle:"horizontal"===o.rotate?0:N_(e.anchor.angle)}})}),s.push(...function(t,e,n){if(!e.length)return[];const i=n.padding,o=qp(t,e.map(({base:t,spot:e})=>({key:`${t.key}-label`,text:t.text,d:Ip(e.text),color:"",anchor:"middle"})),{fontColor:()=>Ws(t),fontWeight:400,...n.text,fontResize:!1,fontSize:n.fontSize,lineHeight:1.2*n.fontSize,pointerEvents:"none"},{halo:!1}),r=new Map(o.map(t=>[String(t.key),t]));return e.flatMap(({base:t,spot:e})=>{const n=r.get(`${t.key}-label`),o="text"===n?.type?n.lines[0]:void 0;if(!n||!o||ck(o.text,t.text))return[];const a=ak([n]).map(t=>({...t,width:t.width+2*i,height:t.height+2*i}));return a.length?[{...t,box:a[Math.floor(a.length/2)],boxes:a,curve:{node:n,pad:nk(e,o.width??0,i)}}]:[]})}(t,c,o)),s.sort((t,e)=>e.priority-t.priority||t.order-e.order);return W_(s,n).map(e=>e.curve?function(t,e,n,i){const o={type:"path",key:`${e.key}-label-pad`,d:Ip(n.pad),interactive:!1,paint:{fill:"none",stroke:Os(t),strokeOpacity:i.backgroundOpacity,strokeWidth:e.textHeight+2*i.padding,strokeLinecap:"butt"}};return{type:"group",key:`${e.key}-label-group`,datum:e.link,interactive:!1,children:[o,n.node]}}(t,e,e.curve,o):function(t,e,n){const{box:i}=e,o={type:"rect",key:`${e.key}-label-pad`,x:-i.width/2,y:-i.height/2,width:i.width,height:i.height,rx:Math.min(i.height/2,3),interactive:!1,paint:{fill:Os(t),fillOpacity:n.backgroundOpacity}},r=Kx({data:[{text:e.text}],label:t=>t.text,labelBounds:()=>({x:-e.textWidth/2,y:-e.textHeight/2,width:e.textWidth,height:e.textHeight}),x:H(0),y:H(0),aes:H({}),rotate:H(0),id:()=>`${e.key}-label`,labelConfig:{fontColor:()=>Ws(t),...n.text,fontResize:!1,fontSize:n.fontSize,lineHeight:1.2*n.fontSize,padding:0,pointerEvents:"none",textAnchor:"middle",verticalAlign:"middle"}}).map(t=>{const{datum:e,...n}=t;return{...n,interactive:!1}});return{type:"group",key:`${e.key}-label-group`,datum:e.link,interactive:!1,transform:i.angle?{x:i.x,y:i.y,rotate:i.angle}:{x:i.x,y:i.y},children:[o,...r]}}(t,e,o))}const ck=(t,e)=>t!==e&&t.replace(/[\s.\u2026]+$/,"").length<3;function lk(){return[{key:"linkColor",default:!1,coerce:t_},{key:"linkLabel",coerce:Jc},{key:"linkLabelConfig",merge:!0,default:{...ik}}]}function hk(t){return void 0===t?{key:"linkSizeMax"}:{key:"linkSizeMax",default:t}}function uk(){return[{key:"linkBundle",default:!1},{key:"linkBundleConfig",merge:!0,default:{...hb}}]}function dk(t,e,n){const i="function"==typeof t?t(e,n):t;return!0===i||"target"===i?{source:!1,target:!0}:"source"===i?{source:!0,target:!1}:"both"===i?{source:!0,target:!0}:{source:!1,target:!1}}const fk=t=>Math.round(100*t)/100;function mk(t,e,n,i){const o=.6*i,r=t-Math.cos(n)*i,a=e-Math.sin(n)*i,s=Math.cos(n+Math.PI/2),c=Math.sin(n+Math.PI/2);return`M${fk(t)},${fk(e)}L${fk(r+s*o)},${fk(a+c*o)}L${fk(r-s*o)},${fk(a-c*o)}Z`}function pk(t,e,n,i,o,r=1){const a=Math.atan2(i-e,n-t);return{x:n-Math.cos(a)*(o+r),y:i-Math.sin(a)*(o+r),angle:a}}function gk(t){const e=Number.isFinite(t)?Math.max(0,t):1;return Math.max(6,Math.min(3*e,Math.max(12,1.5*e)))}function yk(t,e,n,i){const o="function"==typeof t?t(e,n):t;return"number"==typeof o?o:gk(i)}function xk(t,e){const n=Number.isFinite(t)?Math.max(0,t):0,i=Number.isFinite(e)?Math.max(0,e):0;return Math.min(n,Math.max(n/2,i/1.2))}function bk(t){const e=dk(t.arrows,t.datum,t.i),n="number"==typeof t.strokeWidth?t.strokeWidth:1,i=e.source||e.target?yk(t.arrowSize,t.datum,t.i,n):0,o=xk(i,n);return{ends:e,size:i,source:e.source?o:0,target:e.target?o:0}}function _k(t,e,n,i){const o=e[0]-t[0],r=e[1]-t[1],a=Math.hypot(o,r),s=Math.max(0,n),c=Math.max(0,i);if(!a)return[t,e];if(s+c>=a){const e=Math.min(1,s/(s+c||1)),n=[t[0]+o*e,t[1]+r*e];return[n,n]}const l=e=>[t[0]+o*e,t[1]+r*e];return[l(s/a),l(1-c/a)]}function kk([t,e,n,i],o){const r=(t,e)=>[t[0]+(e[0]-t[0])*o,t[1]+(e[1]-t[1])*o],a=r(t,e),s=r(e,n),c=r(n,i),l=r(a,s),h=r(s,c),u=r(l,h);return[[t,a,l,u],[u,h,c,i]]}function vk(t,e,n,i=64){const o=Math.max(0,e),r=Math.max(0,n);if(!o&&!r)return t;const[a,s,c,l]=t,h=[0];let u=a;for(let t=1;t<=i;t++){const e=D_(a,s,c,l,t/i);h.push(h[t-1]+Math.hypot(e[0]-u[0],e[1]-u[1])),u=e}const d=h[i],f=t=>{if(t<=0)return 0;if(t>=d)return 1;let e=1;for(;e<i&&h[e]<t;)e++;const n=h[e]-h[e-1];return(e-1+(n?(t-h[e-1])/n:0))/i};if(o+r>=d){const t=D_(a,s,c,l,f(d*o/(o+r||1)));return[t,t,t,t]}const m=f(o),p=f(d-r),g=p<1?kk(t,p)[0]:t;return m>0?kk(g,m/p)[1]:g}function wk([t,e,n,i]){return`M${fk(t[0])},${fk(t[1])}C${fk(e[0])},${fk(e[1])} ${fk(n[0])},${fk(n[1])} ${fk(i[0])},${fk(i[1])}`}function Mk(t,e,n){const[i,o]=_k([t.x,t.y],[e.x,e.y],n.source?(t.r??0)+1+n.source:0,n.target?(e.r??0)+1+n.target:0);return`M${i[0]},${i[1]} ${o[0]},${o[1]}`}function Sk(t){const e=dk(t.arrows,t.datum,t.i);if(!e.source&&!e.target)return[];const n=yk(t.arrowSize,t.datum,t.i,"number"==typeof t.strokeWidth?t.strokeWidth:1),{source:i,target:o,datum:r,fill:a,keyPrefix:s}=t,c=[];if(e.target){const t=pk(i.x,i.y,o.x,o.y,o.r??0,1);c.push(Ck({key:`${s}-t`,datum:r,x:t.x,y:t.y,angle:t.angle,size:n,fill:a}))}if(e.source){const t=pk(o.x,o.y,i.x,i.y,i.r??0,1);c.push(Ck({key:`${s}-s`,datum:r,x:t.x,y:t.y,angle:t.angle,size:n,fill:a}))}return c}function Ck(t){return{type:"path",key:t.key,d:mk(t.x,t.y,t.angle,t.size),datum:t.datum,interactive:!1,paint:{fill:t.fill,...void 0!==t.opacity?{opacity:t.opacity}:{}}}}function $k(t,e){if(!t.length)return[NaN,NaN];let n=Math.max(0,e);for(let e=t.length-1;e>0;e--){const i=t[e],o=t[e-1],r=Math.hypot(i[0]-o[0],i[1]-o[1]);if(r>=n){const t=r?n/r:0;return[i[0]+(o[0]-i[0])*t,i[1]+(o[1]-i[1])*t]}n-=r}return t[0]}function Ak(t,e=64){return Array.from({length:e+1},(n,i)=>D_(...t,i/e))}function zk(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}function Dk(t,e,n){const i=zk(e,t);return{tip:t,angle:i,base:e,cut:[t[0]-Math.cos(i)*n,t[1]-Math.sin(i)*n]}}function Lk(t,e,n={source:0,target:0}){const{ends:i,size:o}=e;if(!i.source&&!i.target)return{d:wk(t)};const r=Ak(t),a=vk(t,i.source?n.source+o:0,i.target?n.target+o:0),s=i.target?Dk($k(r,n.target),a[3],e.target):void 0,c=i.source?Dk($k([...r].reverse(),n.source),a[0],e.source):void 0;return{d:Bk(wk(a),c,s),source:c,target:s}}function Fk(t,e,n={source:0,target:0}){const i=((t=>Array.isArray(t[0]?.[0]))(t)?t:[t]).filter(t=>t.length),{ends:o,size:r}=e,a=i[0],s=i[i.length-1],c=(t,e,n)=>Dk($k(t,e),$k(t,e+r),n),l=o.source&&a?c([...a].reverse(),n.source,e.source):void 0,h=o.target&&s?c(s,n.target,e.target):void 0;return{d:Bk(i.map((t,e)=>I_(t,0===e&&l?n.source+r:0,e===i.length-1&&h?n.target+r:0)).map(j_).join(""),l,h),source:l,target:h}}const Nk=t=>Math.round(100*t)/100;function Bk(t,e,n){const i=t=>`${Nk(t[0])},${Nk(t[1])}`,o=e?`M${i(e.cut)}L${i(e.base)}${t.replace(/^M[^A-Za-z]*/,"")}`:t;return n?`${o}L${i(n.cut)}`:o}function Ek(t){const e=[];for(const n of["target","source"]){const i=t.ends[n];i&&e.push(Ck({key:t.keys?.[n]??`${t.keyPrefix}-${"target"===n?"t":"s"}`,datum:t.datum,x:i.tip[0],y:i.tip[1],angle:i.angle,size:t.size,fill:t.fill,opacity:t.opacity}))}return e}function Rk(t){return!(!t.source||!t.target||t.source!==t.target&&t.source.id!==t.target.id)}function Pk(t){if("path"!==t.type)return!1;const e=Fb(t.datum);return!!e&&e.source.id===e.target.id}const Tk=t=>Number.isFinite(t)?Math.max(0,t):0;function Ok(t){return Math.max(1.25*(Number.isFinite(t)?t:0),10)}function Wk(t,e=0){return Hk(t,e)+Tk(e)}function Hk(t,e=0){return Math.max(0,t)+Tk(e)}function jk(t,e,n,i=0){const o=Math.max(0,t.r||0),r=Tk(i)/2,a=Hk(n,i),s=Math.cos(e),c=Math.sin(e),l=-c,h=s,u=o>0?Math.min(.5,Math.asin(Math.min(1,.3*a/o))):0,d=o*Math.sin(u),f=o>0?Math.min(1.2,Math.asin(Math.min(1,(d+r)/o))):0,m=o*Math.cos(f),p=o*Math.sin(f),g=(8*(o+a+r)-2*m)/6,y=.8*a+d+1.5*r,x=(e,n)=>[t.x+s*e+l*n,t.y+c*e+h*n];return[x(m,-p),x(g,-y),x(g,y),x(m,p)]}function Ik(t,e,n,i=0){const[o,r,a,s]=jk(t,e,Math.max(0,n),i),c=Tk(i)/2,l=D_(o,r,a,s,.5),h=(t,e)=>{const n=e[0]-t[0],i=e[1]-t[1],o=Math.hypot(n,i)||1;return{x:e[0]-n/o,y:e[1]-i/o,angle:Math.atan2(i,n)}},u=Array.from({length:25},(t,e)=>D_(o,r,a,s,e/24)),d=u.map(t=>t[0]),f=u.map(t=>t[1]);return{d:wk([o,r,a,s]),apex:{x:l[0],y:l[1],angle:e+Math.PI/2},source:h(r,o),target:h(a,s),box:[[Math.min(...d)-c,Math.min(...f)-c],[Math.max(...d)+c,Math.max(...f)+c]],angle:e,points:[o,r,a,s]}}const Gk={source:1,target:1};function qk(t,e){return e.ends.source||e.ends.target?Lk(t.points,e,Gk).d:t.d}function Vk(t,e,n=0){const i={x:0,y:0,r:t.r},o=Tk(n),[r,a,s,c]=jk(i,0,Math.max(0,e),o);let l=0;for(let t=0;t<=24;t++){const[e,n]=D_(r,a,s,c,t/24);l=Math.max(l,Math.abs(Math.atan2(n,e)))}return 2*(l+Math.atan2(o/2,Math.max(0,t.r)+e/2))*1.1}function Yk(t,e){const n=e.length;if(!n)return[];const i=e.slice(1).map((t,n)=>(e[n]+t)/2),o=i.reduce((t,e)=>t+e,0),r=o+(e[0]+e[n-1])/2,a=n>1&&r>2*Math.PI?2*Math.PI/r:1;let s=t-o*a/2;return e.map((t,e)=>(e&&(s+=i[e-1]*a),s))}function Kk(t){const e=Math.floor((t-1)/2),n=[];for(let i=0;n.length<t;i++){const o=e+(i%2?(i+1)/2:-i/2);o>=0&&o<t&&n.push(o)}return n}function Uk(t,e,n){const i=e.filter(e=>e[0]!==t[0]||e[1]!==t[1]).map(e=>Math.atan2(e[1]-t[1],e[0]-t[0])).sort((t,e)=>t-e);if(!i.length)return n;let o=2*Math.PI-(i[i.length-1]-i[0]),r=i[i.length-1];for(let t=1;t<i.length;t++){const e=i[t]-i[t-1];e>o+1e-9&&(o=e,r=i[t-1])}const a=r+o/2;return Math.atan2(Math.sin(a),Math.cos(a))}function Xk(t,e,n=-Math.PI/2){const i=t[0]-e[0],o=t[1]-e[1];return i||o?Math.atan2(o,i):n}function Zk(t,e){const n=new Map;for(const i of t){const t=e.node(i).id;n.has(t)||n.set(t,[]),n.get(t).push(i)}const i=new Map;for(const t of n.values()){const n=e.node(t[0]);if(![n.x,n.y].every(Number.isFinite))continue;const o=Math.max(...t.map(t=>e.reach(t))),r=t.map((t,n)=>({loop:t,k:n,w:Tk(e.strokeWidth?.(t)??0)})).sort((t,e)=>e.w-t.w||t.k-e.k),a=Kk(t.length),s=new Array(t.length);r.forEach((t,e)=>s[a[e]]=t);const c=Yk(e.angle(n),s.map(({w:t})=>Vk(n,o,t)));s.forEach(({loop:t,w:e},r)=>i.set(t,Ik(n,c[r],o,e)))}return i}function Qk(t,e){return[[Math.min(t[0][0],e[0][0]),Math.min(t[0][1],e[0][1])],[Math.max(t[1][0],e[1][0]),Math.max(t[1][1],e[1][1])]]}function Jk(t){const e=bk(t);return e.ends.source||e.ends.target?Ek({ends:Lk(t.loop.points,e,Gk),size:e.size,datum:t.datum,keyPrefix:t.keyPrefix,fill:t.fill}):[]}function tv(t){t.links=function(){return arguments.length?(dn(this,"links",arguments),this):this.schema.links},t.nodes=function(){return arguments.length?(dn(this,"nodes",arguments),this):this.schema.nodes},t.nodeGroupBy=function(t){if(!arguments.length)return this.schema.nodeGroupBy;const e=t instanceof Array?t:[t];return this.schema.nodeGroupBy=e.map(t=>{if("function"==typeof t)return t;const e=t;return this.schema.aggs[e]||(this.schema.aggs[e]=(t,e)=>{const n=Array.from(new Set(t.map(e)));return 1===n.length?n[0]:n}),q(e)}),this},t.size=function(t){return arguments.length?(this._size="function"!=typeof t&&t?q(t):t,this._sizeKey="string"==typeof t?t:void 0,this):this._size},t.hover=hx}const ev=t=>({data:t.data,i:t.i,id:t.id});function nv(t,e,n){return`${t._id(e,n)||t.schema.nodeGroupBy[h.min([t._drawDepth,t.schema.nodeGroupBy.length-1])](e,n)}`}function iv(t){const e=t._filteredData.reduce((e,n,i)=>(e[t._id(n,i)]=n,e),{}),n=t.schema.nodes.reduce((e,n,i)=>(e[nv(t,n,i)]=n,e),{}),i=t=>"function"==typeof t?t:void 0,o=i(t._x),r=i(t._y);return Array.from(new Set(Object.keys(e).concat(Object.keys(n)))).map((i,a)=>{const s=e[i],c=n[i];if(void 0===c)return!1;const l=(t,e=t=>void 0!==t)=>void 0!==s&&e(t(s))?t(s):t(c),h=t=>!isNaN(t);return{__d3plus__:!0,data:s||c,i:a,id:i,fx:o?l(o,h):void 0,fy:r?l(r,h):void 0,node:c,r:t._size?l(t._size):t.schema.sizeMin,shape:l(t.schema.shape)}}).filter(t=>!!t)}function ov(t,e){const n=e.reduce((t,e)=>(t[e.id]=e,t),{});t.ctx.nodeLookup=n;const i=new Map;for(const t of e)i.set(t.node,t);const o=(e,o)=>"number"===o?i.get(t.schema.nodes[e]):"string"===o?n[e]:n[e.id],r=t.schema.links.map((e,n)=>{const i=typeof e.source,r=o(e.source,i),a=o(e.target,i);if(!r||!a)return{size:t.schema.linkSize(e,n),source:r,target:a};const s=Bb(e,ev(r),ev(a),n);return{size:Eb(s,t.schema.linkSize(s,n)),source:r,target:a,datum:s}});return t.ctx.linkLookup=r.reduce((t,e)=>e.source&&e.target&&e.source!==e.target?(t[e.source.id]||(t[e.source.id]=[]),t[e.source.id].push(e.target),t[e.target.id]||(t[e.target.id]=[]),t[e.target.id].push(e.source),t):t,{}),r}function rv(t,e,n){const i=_.zoomTransform((t._zoomEventTarget||t._container).node()),{x:o=0,y:r=0}=t._chartTransform||{};t._zoomToBounds([[(e[0]+o)*i.k+i.x,(n[0]+r)*i.k+i.y],[(e[1]+o)*i.k+i.x,(n[1]+r)*i.k+i.y]])}function av(){return[{key:"cluster",default:!0,coerce:t=>!1!==t},{key:"clusterConfig",merge:!0,default:{}}]}function sv(t,e){const n=t.shapeConfig??{},i=t=>(n[t]??{}).fill;return!1!==t.cluster&&!t.colorScale&&!t.colorOrdinal&&t.color===e.color&&n.fill===e.fill&&void 0===i("Circle")&&void 0===i("Rect")&&Array.isArray(t.groupBy)&&1===t.groupBy.length}function cv(t,e){var n,i;const o=f.louvain({nodes:t.map(t=>t.id),links:e.flatMap(t=>t.source&&t.target&&t.source.id!==t.target.id?[{source:t.source.id,target:t.target.id,weight:hv(t.size)}]:[])}),r=[];for(const[t,e]of o)((n=r)[i=e]??(n[i]=[])).push(`${t}`);return r}function lv(t){return t.filter(t=>t.length>1).length>1}const hv=t=>t>0&&Number.isFinite(t)?t:1;function uv(t,e,n){const i=t.map((t,e)=>({ids:[...t],order:e})).filter(t=>t.ids.length>1),o=t.filter(t=>t.length<2);if(!(n>=1)||i.length<=n)return t;const r=new Map;for(const t of i)for(const e of t.ids)r.set(e,t);const a=(t,e)=>e.ids.length-t.ids.length||t.order-e.order;for(;i.length>n;){const t=i.reduce((t,e)=>a(t,e)<0?e:t),n=new Map;for(const i of e){if(!i.source||!i.target)continue;const e=r.get(i.source.id),o=r.get(i.target.id);if(!e||!o||e===o||e!==t&&o!==t)continue;const a=e===t?o:e;n.set(a,(n.get(a)??0)+hv(i.size))}let o=i.filter(e=>e!==t).sort(a)[0];for(const[t,e]of n){const i=n.get(o)??0;(e>i||e===i&&a(t,o)<0)&&(o=t)}o.ids.push(...t.ids);for(const e of t.ids)r.set(e,o);i.splice(i.indexOf(t),1)}return[...i.sort(a).map(t=>t.ids),...o]}function dv(t,e){const n=new Map,i=new Map;for(const t of e)if(t.source&&t.target&&t.source.id!==t.target.id)for(const e of[t.source.id,t.target.id])n.set(e,(n.get(e)??0)+1),i.set(e,(i.get(e)??0)+(t.size||0));return t.map(t=>t.reduce((t,e)=>(n.get(e)??0)>(n.get(t)??0)||(n.get(e)??0)===(n.get(t)??0)&&(i.get(e)??0)>(i.get(t)??0)?e:t))}function fv(t,e){return t("{node} cluster").replace("{node}",e)}function mv(t,e,i){const o=new Map(i.map(t=>[t.id,t])),r=new Set(e.flatMap(t=>t.ids)),a=t.schema.aggs??{},s=e.map(t=>{const e=t.ids.map(t=>o.get(t).data),i=Object.keys(e[0]).filter(n=>e.every((e,i)=>`${e[n]}`===t.ids[i])),r={...a};for(const t of i)r[t]=(t,e)=>t.map(e);return n.merge(e,r)});return[...s,...i.filter(t=>!r.has(t.id)).map(t=>t.data)]}function pv(t){const n=t.ctx.clusterDefaults,i={active:!1,names:new Map,clusters:[]};if(t.ctx.clusterState=i,!sv(t.schema,n)||!Array.isArray(t.schema.nodes)||!Array.isArray(t.schema.links))return;const{nodes:o,links:r}=function(t){const{nodeLookup:e,linkLookup:n}=t.ctx,i=iv(t),o=ov(t,i);return t.ctx.nodeLookup=e,t.ctx.linkLookup=n,{nodes:i,links:o}}(t),a=(t.schema.clusterConfig??{}).max,s=uv(function(t,e,n){const i=`${e.map(t=>t.id).join("\0")}|${n.map(t=>`${t.source?.id}>${t.target?.id}:${t.size}`).join("\0")}`,o=t.ctx.clusterCache;if(o&&o.key===i)return o.clusters;const r=cv(e,n);return t.ctx.clusterCache={key:i,clusters:r},r}(t,o,r),r,"number"==typeof a?a:12);if(!lv(s))return;const c=new Map(o.map(t=>[t.id,t])),l=function(t,e,n,i){const o=(t.schema.clusterConfig??{}).label,r=e=>`${t.schema.translate(e)}`;return e.flatMap((e,a)=>{if(e.length<2)return[];const s=i.get(n[a]);return[{index:a,name:"function"==typeof o?`${o(s.data,a,e.map(t=>i.get(t).data))}`:fv(r,`${t._drawLabel(s.data,s.i)}`),ids:e,hub:s.id}]})}(t,s,dv(s,r),c).sort((t,e)=>e.ids.length-t.ids.length||t.name.localeCompare(e.name)),h=new Map;for(const e of o)h.set(e.id,`${t._drawLabel(e.data,e.i)}`);for(const t of l)for(const e of t.ids)h.set(e,t.name);t.ctx.clusterState={active:!0,names:h,clusters:l},t._legendData=mv(t,l,o);const u=Re(t);for(const t of l)e.colorAssign(t.name,u)}function gv(t,e,n){const i=t.ctx.clusterState;if(!i?.active)return;const o=t._id?.(e,n),r=Array.isArray(o)?o:[nv(t,e,n)],a=new Set(r.map(t=>i.names.get(`${t}`)));return 1===a.size?[...a][0]:void 0}function yv(t,e){return(n,i)=>{const o=t.ctx.clusterState;if(!o?.active)return e(n,i);const r=e=>{const n=gv(t,e,0),i=o.clusters.findIndex(t=>t.name===n);return i<0?o.clusters.length:i};return r(n)-r(i)||e(n,i)}}function xv(t){const e=t.schema.color,n=(n,i)=>gv(t,n,i)??e(n,i);t.schema.color=n,t.schema.legendSort=yv(t,t.schema.legendSort),t.ctx.clusterDefaults={color:n,fill:t.schema.shapeConfig.fill};const i=t._preDraw.bind(t);t._preDraw=()=>{i(),pv(t)}}function bv(t){const e=new Map;for(const n of t)e.set(n.source.id,(e.get(n.source.id)??0)+1),e.set(n.target.id,(e.get(n.target.id)??0)+1);return e}function _v(t,e){const n=t=>null==t||""===t;return n(t)||n(e)?n(t)?n(e)?0:1:-1:"number"==typeof t&&"number"==typeof e?t-e:String(t).localeCompare(String(e),void 0,{numeric:!0})}function kv(t,e){const n=(t,e)=>_v(t.label,e.label),i="function"==typeof e?(t,n)=>e(t.datum,n.datum):"label"===e?n:"group"===e?(t,e)=>_v(t.group,e.group)||n(t,e):"degree"===e?(t,e)=>e.degree-t.degree||n(t,e):()=>0;return[...t].sort((t,e)=>i(t,e)||((t,e)=>t.order-e.order)(t,e))}function vv(t,e,n){if(t<=0)return[];const i=n/t;return Array.from({length:t},(t,n)=>e+(n+.5)*i)}function wv(t,e,n){return"below"===n?"below":"both"===n?t<=e?"above":"below":"above"}function Mv(t,e,n){const i=(Math.max(0,t)+Math.max(0,e))/2,o=i>0?Math.max(0,Math.min(1,n/i)):1;return{scale:o,above:o*Math.max(0,t)/2,below:o*Math.max(0,e)/2}}const Sv=t=>Math.round(100*t)/100;function Cv(t,e,n){const i="above"===t.side?1:-1;return"vertical"===t.orient?[t.base+n*i,e]:[e,t.base-n*i]}function $v(t){const e=Math.abs(t.to-t.from)/2,n=e*t.scale,[i,o]=Cv(t,t.from,0),[r,a]=Cv(t,t.to,0),s=t.to>t.from===("above"===t.side)?1:0,[c,l]="vertical"===t.orient?[n,e]:[e,n];return`M${Sv(i)},${Sv(o)}A${Sv(c)},${Sv(l)} 0 0,${s} ${Sv(r)},${Sv(a)}`}function Av(t){const e=Math.abs(t.to-t.from)/2;return Cv(t,(t.from+t.to)/2,e*t.scale)}function zv(t,e,n){const[i,o]="target"===e?[t.to,t.from]:[t.from,t.to],r=Math.abs(i-o)/2,a=r*t.scale,s=(i+o)/2,c=i>=o?1:-1,l=a>0?Math.min(1,Math.max(0,n)/a):0,h=Math.sqrt(1-l*l),[u,d]=Cv(t,s+c*r*h,a*l),f=c*r*l,m=-a*h,p="above"===t.side?1:-1,[g,y]="vertical"===t.orient?[m*p,f]:[f,-m*p];return{x:u,y:d,angle:Math.atan2(y,g)}}function Dv(t,e,n,i){const[o,r]="target"===e?[t.to,t.from]:[t.from,t.to],a=Math.abs(o-r)/2,s=a*t.scale,c=(o+r)/2,l=o>=r?1:-1;let h=s>0?Math.asin(Math.min(1,Math.max(0,n)/s)):0;const u=Math.PI/2/512;let d=Math.max(0,i);for(;d>0&&h<Math.PI/2;){const t=Math.min(Math.PI/2,h+u),e=(h+t)/2,n=Math.hypot(a*Math.sin(e),s*Math.cos(e))*(t-h);n>=d?(h+=(t-h)*(n?d/n:0),d=0):(d-=n,h=t)}return Cv(t,c+l*a*Math.cos(h),s*Math.sin(h))}function Lv(t,e,n){const{ends:i,size:o}=e;if(!i.source&&!i.target)return{d:$v(t)};const r=r=>{if(!i[r])return;const a=zv(t,r,n[r]);return Dk([a.x,a.y],Dv(t,r,n[r],o),e[r])},a=r("source"),s=r("target"),c=Math.abs(t.to-t.from)/2,l=c*t.scale,[h,u]=a?a.base:Cv(t,t.from,0),[d,f]=s?s.base:Cv(t,t.to,0),m=t.to>t.from===("above"===t.side)?1:0,[p,g]="vertical"===t.orient?[l,c]:[c,l];return{d:Bk(`M${Sv(h)},${Sv(u)}A${Sv(p)},${Sv(g)} 0 0,${m} ${Sv(d)},${Sv(f)}`,a,s),source:a,target:s}}function Fv(t){const e=[Cv(t,t.from,0),Cv(t,t.to,0),Av(t)],n=e.map(t=>t[0]),i=e.map(t=>t[1]);return[[Math.min(...n),Math.min(...i)],[Math.max(...n),Math.max(...i)]]}function Nv(t){const{cross:e,spans:n,labelSide:i,labelBand:o,rMax:r,strokePad:a}=t,s=t.loops??{above:0,below:0},c=Math.max(0,e-2*a),[l,h]="above"===i?[n.above,n.below]:[n.below,n.above],u=Math.min(Mv(h,l,c).scale,Mv(h,0,c-o).scale),d=(t,e,n)=>Math.max(u*t/2,e?o:r,n),f=d(n.above,"above"===i,s.above),m=d(n.below,"below"===i,s.below),[p,g]="horizontal"===t.orient?[f,m]:[m,f],y=Math.max(0,(e-p-g-2*a)/2);return{scale:u,base:y+a+p}}const Bv=Math.SQRT1_2;function Ev(t,e,n,i){const o=t=>e>=t?1:Math.ceil(t/Math.max(e,1e-6));return"vertical"===i?{angle:0,step:o(n)}:t<=e?{angle:0,step:1}:e*Bv>=n?{angle:-45,step:1}:{angle:-90,step:o(n)}}function Rv(t,e,n,i){return"vertical"===i?{depth:e,spread:n/2}:0===t?{depth:n,spread:e/2}:-90===t?{depth:e,spread:n/2}:{depth:(e+n/2)*Bv,spread:(e+n/2)*Bv}}function Pv(t,e,n,i){return"horizontal"===i&&0===t?1/0:"horizontal"===i&&-45===t?Math.max(0,e/Bv-n/2):Math.max(0,e)}function Tv(t){const{at:e,base:n,gap:i,width:o,spacing:r,lineHeight:a,angle:s,side:c}=t,l="below"===c?1:-1,h={id:t.id,datum:t.datum,text:t.text,angle:s};if("vertical"===t.orient)return{...h,x:n-l*i,y:e,box:{x:"below"===c?-o:0,y:-a/2,width:o,height:a},anchor:"below"===c?"end":"start",verticalAlign:"middle"};const u=n+l*i;return 0===s?{...h,x:e,y:u,box:{x:-r/2,y:"below"===c?0:-a,width:r,height:a},anchor:"middle",verticalAlign:"below"===c?"top":"bottom"}:{...h,x:e,y:u,box:{x:"below"===c?-o:0,y:-a/2,width:o,height:a},anchor:"below"===c?"end":"start",verticalAlign:"middle"}}function Ov(t,e,n=!1){if(!e.length)return[];const i=v_(t),o=new Map(e.map(t=>[`${t.id}_0`,t])),a=t=>o.get(String(t.id)),s=Kx({data:e,label:t=>t.text,labelBounds:t=>({...t.box}),x:t=>t.x,y:t=>t.y,aes:H({}),rotate:t=>t.angle,id:t=>t.id,datum:t=>t.datum,labelConfig:{fontColor:()=>Ws(t),fontResize:!1,fontSize:i.fontSize,lineHeight:1.2*i.fontSize,padding:0,pointerEvents:"none",textAnchor:t=>{return"middle"!==(e=a(t)?.anchor??"middle")&&r.rtl()?"start"===e?"end":"start":e;var e},verticalAlign:t=>a(t)?.verticalAlign??"middle",...i.text}});return n?Gp(s,Os(t),Math.max(2,Math.round(i.fontSize/4))):s}function Wv(t){return"below"===t?"below":"above"}function Hv(t,e){return Math.max(Ok(t),Math.min(.3*Math.max(0,e),40))}function jv(t,e){return"vertical"===e?"above"===t?0:Math.PI:"above"===t?-Math.PI/2:Math.PI/2}function Iv(t,e,n){const{spacing:i,...o}=n,r=new Map(e.map(t=>[t.id,t])),a=t.filter(t=>r.has(t.id)),s=Zk(a,{node:t=>r.get(t.id),angle:()=>jv(n.side,n.orient),reach:t=>Hv(r.get(t.id).r,i),strokeWidth:t=>t.size});return a.flatMap(t=>{const e=r.get(t.id),i=s.get(t);if(!i)return[];const a="horizontal"===n.orient?e.x:e.y;return[{datum:t.datum,source:e,target:e,size:t.size,index:t.index,arc:{...o,from:a,to:a},d:i.d,loop:i}]})}function Gv(t,e,n,i){let o=0;for(const i of t){const t=e.get(i.id)??0;o=Math.max(o,t+Wk(Hv(t,n),i.size))}return"above"===Wv(i)?{above:o,below:0}:{above:0,below:o}}const qv=t=>{const e=`scale${t.charAt(0).toUpperCase()}${t.slice(1)}`;return(E[e]??E.scaleSqrt)()};function Vv(t,e){const n="number"==typeof e.sizeMax?e.sizeMax:Math.max(1,Math.min(.45*e.spacing,20));if(!t){const t=Math.min(e.sizeMin,n);return Object.assign(()=>t,{domain:void 0,range:void 0})}const i=h.extent(t);if(void 0===i[0]||i[0]===i[1]){return E.scaleLinear().domain([0,1]).range([n,n])}return qv(e.sizeScale).domain(i).range([Math.min(n/2,e.sizeMin),n])}function Yv(t,e){const n=t=>Array.isArray(t)&&t.length>1?t[0]:void 0,i=n(t.schema.groupBy);if(i)return i(e.data,e.i);const o=n(t.schema.nodeGroupBy);if(o)return o(e.node,e.i);const r=t.schema.color;return"function"==typeof r?r(e.data,e.i):void 0}function Kv(t,e,n){const i=e.length?n/e.length:n;return Vv(t._size?e.map(t=>t.r):null,{sizeMin:t.schema.sizeMin,sizeMax:t.schema.sizeMax,sizeScale:t.schema.sizeScale||"sqrt",spacing:i})}function Uv(t,e){const n=v_(t),i=Math.ceil(1.2*n.fontSize)+1,o={size:n.fontSize,lineHeight:1.2*n.fontSize},r=function(t){return!1!==Hm(t,"Circle").label}(t);return{settings:n,lineHeight:i,widths:e.map(t=>r&&t.label?k_(t.label,o).width:0)}}function Xv(t,e,n,i){const o=function(t,e,n){const i=h.extent(e);if(void 0===i[0]||i[0]===i[1])return e;const o=t.schema.linkSizeMin,r=qv(t.schema.linkSizeScale||"sqrt").domain(i).range([o,Math.max(o,n)]);return e.map(t=>r(t))}(t,[...e,...n].map(t=>t.size),i),r=n.map((t,n)=>({index:t.index,datum:t.datum,size:o[e.length+n],id:t.source.id}));return{allSizes:o,sizes:o.slice(0,e.length),loopItems:r}}function Zv(t,e,n){if(!t._size||!Array.isArray(t.schema.nodes))return null;if(!Array.isArray(t._filteredData)||!Array.isArray(t.schema.links))return null;const{nodeLookup:i,linkLookup:o}=t.ctx,r=iv(t);if(t.ctx.nodeLookup=i,t.ctx.linkLookup=o,!r.length)return null;return Kv(t,r,"vertical"===t.schema.orient?n:e)}const Qv=({viz:t})=>{const e=t,{width:n,height:i}=kt(e);Array.isArray(e._filteredData)||(e._filteredData=[]),Array.isArray(e.schema.nodes)||(e.schema.nodes=[]),Array.isArray(e.schema.links)||(e.schema.links=[]);const o="vertical"===e.schema.orient?"vertical":"horizontal",r=e.schema.arcSide||"above",a="below"===r?"above":"below",{nodes:s,links:c,loops:l}=function(t){const e=iv(t),n=ov(t,e).map((t,e)=>({...t,index:e})).filter(t=>t.source&&t.target),i=bv(n),o=new Map(t.schema.nodes.map((t,e)=>[t,e]));return{nodes:kv(e.map(e=>({...e,datum:e.data,label:`${t._drawLabel(e.data,e.i)??""}`,group:Yv(t,e),degree:i.get(e.id)??0,order:o.get(e.node)??e.i})),t.schema.nodeSort),links:n.filter(t=>!Rk(t)),loops:n.filter(t=>Rk(t))}}(e),u="horizontal"===o?n:i,d="horizontal"===o?i:n,{settings:f,lineHeight:m,widths:p}=Uv(e,s),g=function(t,e,n,i,o,r){const a=t.length;let s=0,c=e,l={angle:0,step:1},u=1/0;for(let d=0;d<3;d++){const d=a?c/a:c;if(l=Ev(h.max(t)??0,d,n,o),u=Pv(l.angle,i,n,o),"horizontal"!==o||-45!==l.angle)break;let f=0;t.forEach((t,e)=>{if(e%l.step)return;const{spread:i}=Rv(-45,Math.min(t,u),n,o),s=("below"===r?e+.5:a-e-.5)*d;f=Math.max(f,i-s)}),s="below"===r?f:0,c=e-f}return{start:s,length:c,fit:l,widthCap:u}}(p,u,m,.3*d,o,a),y=vv(s.length,g.start,g.length),x=s.length?g.length/s.length:g.length,b=Kv(e,s,g.length);e._sizeLegendFinal=e._size?b:null;const _=s.map(t=>b(t.r)||1),k=h.max(_)??0,v=s.map((t,e)=>({...t,rank:e,at:y[e]})),w=new Map(v.map(t=>[t.id,t])),M=c.map(t=>({index:t.index,datum:t.datum,size:t.size,source:w.get(t.source.id),target:w.get(t.target.id)})),S=function(t,e){let n=0,i=0;const o=t.map(t=>{const o=wv(t.source.rank,t.target.rank,e),r=Math.abs(t.target.at-t.source.at);return"above"===o?n=Math.max(n,r):i=Math.max(i,r),o});return{above:n,below:i,sides:o}}(M,r),C=k+f.padding,{shown:$,depth:A}=function(t,e,n,i){const o=t.map((t,n)=>n%e.fit.step?0:Math.min(t,e.widthCap)),r=h.max(o)??0;return{shown:o,depth:r?Rv(e.fit.angle,r,n,i).depth:0}}(p,g,m,o),{allSizes:z,sizes:D,loopItems:L}=Xv(e,M,l,h.min(_)??1),F=Gv(L,new Map(v.map((t,e)=>[t.id,_[e]])),x,r),{scale:N,base:B}=Nv({cross:d,spans:S,labelSide:a,labelBand:A?C+A:k,rMax:k,strokePad:(h.max(z)??1)/2+2,orient:o,loops:F}),E=function(t,e,n,i){return t.map((t,o)=>{const[r,a]="horizontal"===i?[t.at,n]:[n,t.at];return{__d3plus__:!0,data:t.data,i:t.i,id:t.id,fx:r,fy:a,node:t.node,shape:t.shape,x:r,y:a,r:e[o],width:2*e[o],height:2*e[o],rank:t.rank,label:t.label,group:t.group,degree:t.degree}})}(v,_,B,o),R=function(t,e,n,i,o){const r=new Map(e.map(t=>[t.id,t]));return t.map((t,e)=>{const a={...n,from:t.source.at,to:t.target.at,side:i[e]};return{datum:t.datum,source:r.get(t.source.id),target:r.get(t.target.id),size:o[e],index:t.index,arc:a,d:$v(a)}}).sort((t,e)=>Math.abs(e.arc.to-e.arc.from)-Math.abs(t.arc.to-t.arc.from)||t.index-e.index)}(M,E,{base:B,scale:N,orient:o},S.sides,D).concat(Iv(L,E,{base:B,scale:N,orient:o,side:Wv(r),spacing:x})),P=function(t,e,n,i){return t.flatMap((t,o)=>e[o]&&t.label?[Tv({...i,id:`arc-label-${t.id}`,datum:t.data,text:t.label,at:n[o],width:e[o]})]:[])}(E,$,y,{base:B,gap:C,spacing:x,lineHeight:m,angle:g.fit.angle,side:a,orient:o}),T=Hm(e,"Path",e.schema.shapeConfig,"edge");return delete T.on,function(t,e){Rb(t,[...e.links].sort((t,e)=>t.index-e.index).map(t=>t.datum),e.nodes.map(ev)),t.ctx.arcCtx=e,t.ctx.nodeLookup=Object.fromEntries(e.nodes.map(t=>[t.id,t]));const n={};for(const t of e.links){var i,o,r,a;t.loop||(((i=n)[o=t.source.id]??(i[o]=[])).push(t.target),((r=n)[a=t.target.id]??(r[a]=[])).push(t.source))}t.ctx.linkLookup=n}(e,{nodes:E,links:R,labels:P,labelHalo:S.sides.includes(a),linkConfig:T}),{shapeData:E}};function Jv(t,e,n,i){if("none"===e.paint?.fill)return null;const o=Pm(t.backgroundImage,n,i);if("string"!=typeof o||!o)return null;const r=wa(e,[],"contain"===Pm(t.backgroundImageFit,n,i)?"contain":"cover");if(!(r&&r.box.width>0&&r.box.height>0))return null;const a=e.paint?.opacity,[s]=Ma([{key:e.key,index:e.index??i??0,datum:e.datum,url:o,box:r.box,clip:r.clip,preserveAspectRatio:r.preserveAspectRatio,opacity:"number"==typeof a?a:void 0,transform:e.transform}],null,0);return s}function tw(t,e,n){if(!t.backgroundImage)return[];const i=[];return e.forEach((e,o)=>{const[r,a]=n(o),s=Jv(t,e,r,a);s&&i.push(s)}),i}function ew(t){if(t.loop)return t.loop.apex;const[e,n]=Av(t.arc);return{x:e,y:n,angle:"vertical"===t.arc.orient?Math.PI/2:0}}function nw(t){return t.loop?X_(t.loop.d):Z_(X_($v(t.arc)),t.source.r,t.target.r)}function iw(t,e){return sk(t,e.links.map((t,e)=>({key:ow(t),link:t,i:e,anchor:ew(t),path:nw(t),priority:t.size})),{circles:e.nodes.map(t=>({x:t.x,y:t.y,r:t.r}))})}const ow=t=>`arc-link-${t.source.id}-${t.target.id}-${t.index}`;function rw(t,e,n,i){const o=e.datum;if(e.loop)return Jk({arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:e.size,datum:o,i:e.index,keyPrefix:i,fill:n,loop:e.loop});const r=sw(t,e);return r.ends.source||r.ends.target?Ek({ends:Lv(e.arc,r,cw(e)),size:r.size,datum:o,keyPrefix:i,fill:n}):[]}function aw(t,e){const n=sw(t,e);return n.source||n.target?e.loop?qk(e.loop,n):Lv(e.arc,n,cw(e)).d:e.d}const sw=(t,e)=>bk({arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:e.size,datum:e.datum,i:e.index}),cw=t=>({source:t.source.r+1,target:t.target.r+1});function lw(t,e,n){const i=function(t,e){return Om(t,e.data,e.i)}(n,e);void 0===i.vectorEffect&&(i.vectorEffect="non-scaling-stroke");const o=t._size,r=o?`, ${o(e.data,e.i)}`:"",a={datum:e.data,index:e.i,paint:i,aria:{label:`${e.label}${r}.`}};if("Rect"===e.shape){const t=2*e.r;return{type:"rect",key:`arc-node-${e.id}`,x:e.x-e.r,y:e.y-e.r,width:t,height:t,...a}}return{type:"circle",key:`arc-node-${e.id}`,cx:e.x,cy:e.y,r:e.r,...a}}const hw=({viz:t})=>{const e=t.ctx.arcCtx;if(!e)return[];const n=function(t,e){const n=i_(t),i=[],o=[],r=[];for(const a of e.links){const s=a.datum,c=Om(e.linkConfig,s,a.index);c.fill="none",c.strokeWidth=a.size;const l=n(s,a);l&&(c.stroke=l);const h=ow(a);i.push({type:"path",key:h,d:aw(t,a),datum:s,index:a.index,paint:c,aria:{label:Vb(t,s)}}),o.push(Jb(h,a.d,s,a.size)),r.push(...rw(t,a,"string"==typeof c.stroke?c.stroke:void 0,`arc-arrow-${a.source.id}-${a.target.id}-${a.index}`))}return[...i,...o,...r,...iw(t,e)]}(t,e),i=[];for(const o of e.nodes){const e=Hm(t,"Rect"===o.shape?"Rect":"Circle"),r=lw(t,o,e);n.push(r);const a=Jv(e,r,o.data,o.i);a&&i.push(a)}return n.push(...i,...Ov(t,e.labels,e.labelHalo)),n};function uw(t,e,n){const i=t.ctx.arcCtx;if(!i)return null;const o=(e,n)=>nv(t,e,n);let r,a,s;const c=Fb(e);if(c)r=new Set([c.source.id,c.target.id]),s=t=>t.index===c.index,a=i.links.filter(s);else{const c=o(e,n),l=t.ctx.nodeLookup;if(!l||!l[c])return null;s=t=>t.source.id===c||t.target.id===c,a=i.links.filter(s),r=new Set([c,...a.flatMap(t=>[t.source.id,t.target.id])])}const l=new Set(a.map(t=>t.index));return{predicate:(t,e)=>{const n=Fb(t);return n?l.has(n.index):r.has(o(t,e))},box:dw(i,r,a)}}function dw(t,e,n){const i=t.nodes.filter(t=>e.has(t.id)).map(t=>[[t.x-t.r,t.y-t.r],[t.x+t.r,t.y+t.r]]).concat(n.map(t=>t.loop?t.loop.box:Fv(t.arc)));return[[Math.min(...i.map(t=>t[0][0])),Math.min(...i.map(t=>t[0][1]))],[Math.max(...i.map(t=>t[1][0])),Math.max(...i.map(t=>t[1][1]))]]}const fw=(t,e)=>rv(t,[e[0][0],e[1][0]],[e[0][1],e[1][1]]);function mw(t){const e=t;t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{n(i,o,r,a);const s=uw(t,i,o);s&&e.hover(s.predicate)},t.schema.on["click.shape"]=(n,i)=>{t._tooltipClass.data([]).render();const o=((t,e,n)=>Nb(e)?`link:${Fb(e).index}`:nv(t,e,n))(t,n,i);if(void 0!==t._focus&&t._focus===o)return e.active(!1),t._focus=void 0,void t._zoomToBounds(null);const r=uw(t,n,i);r&&(e.hover(!1),e.active(r.predicate),t._focus=o,fw(t,r.box))},t.schema.on["click.legend"]=(n,i)=>{const o=t.ctx.arcCtx;if(!o)return;const r=t._ids(n,i),a=`legend:${r[r.length-1]}`;if(t._focus===a)return e.active(!1),t._focus=void 0,void t._zoomToBounds(null);const s=(e,n)=>`${t._ids(e,n)[r.length-1]}`,c=t._id(n,i),l=new Set((Array.isArray(c)?c:[r[r.length-1]]).map(String)),h=new Set(o.nodes.filter(t=>l.has(s(t.data,t.i))).map(t=>t.id));if(!h.size)return;const u=o.links.filter(t=>h.has(t.source.id)&&h.has(t.target.id)),d=new Set(u.map(t=>t.index));e.hover(!1),e.active((t,e)=>{const n=Fb(t);return n?d.has(n.index):l.has(s(t,e))}),t._focus=a,fw(t,dw(o,h,u))}}function pw(t){const e=t.ctx.arcCtx;if(!e)return null;const n=e=>t.schema.translate(e);return[...e.nodes.map(t=>({...t.data,[n("Connections")]:t.degree})),...[...e.links].sort((t,e)=>t.index-e.index).map(t=>{const{raw:e,endKeys:i}=Fb(t.datum),o=Object.fromEntries(Object.entries(e).filter(([t])=>!i.includes(t)));return{[n("From")]:t.source.label,[n("To")]:t.target.label,...o}})]}const gw={name:"ArcDiagram",layoutStage:Qv,sizeLegendScale:(t,{width:e,height:n})=>Zv(t,e,n),emit:hw,insetRegion:Cp,tableData:pw,setup:t=>{mw(t),tv(t),xv(t);const e=t,n=e._draw.bind(t);e._draw=function(e){const i=n(e),{width:o,height:r}=kt(t);return tc(t,{kind:"network",width:o,height:r,duration:Zt(t)}),i}},pointMark:(t,e)=>ih(e)||Pk(e),ctx:{},fields:[{key:"arcSide",default:"above"},{key:"arrows",default:!1},{key:"arrowSize"},{key:"cluster",default:!0,coerce:t=>!1!==t},{key:"clusterConfig",merge:!0,default:{}},...lk(),...pn("links","nodes"),{key:"links",default:[]},{key:"linkSize",default:H(1),coerce:t=>"function"==typeof t?t:H(t)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[I("id")]},{key:"nodes",default:[]},{key:"nodeTooltipLinks"},{key:"nodeSort",default:"data"},{key:"orient",default:"horizontal"},{key:"shape",default:H("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({Path:{fill:"none",label:!1,stroke:()=>J(t._theme,t=>t.link,"#adb5bd")}})},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"tooltipConfig",merge:!0,factory:t=>Qb(t)}]};var yw=lx(gw);function xw({stackKey:t,fromZero:e}){return function({data:n,x:i,y:o,x2:r,y2:a,buffer:s=10}){const c=r?"x2":"x",l=a?"y2":"y",u="x"===this.schema.discrete?o:i,d=u.domain().slice(),f="x"===this.schema.discrete;let m,p;if(f&&d.reverse(),this.schema.stacked){const e=h.groups(n,e=>t(e,this.schema.discrete)).map(([,t])=>t.map(t=>t[f?l:c]));p=e.map(t=>h.sum(t.filter(t=>t>0))),m=e.map(t=>h.sum(t.filter(t=>t<0)))}else{const t=n.map(t=>t[f?l:c]);p=e?t.filter(t=>t>0):t,m=e?t.filter(t=>t<0):t}let g=u(h.max(p));e&&!(f?g<u(0):g>u(0))||(g+=f?-s:s),g=u.invert(g);let y=u(h.min(m));return e&&!(f?y>u(0):y<u(0))||(y+=f?s:-s),y=u.invert(y),g>d[1]&&(d[1]=g),y<d[0]&&(d[0]=y),f&&d.reverse(),u.domain(d),[i,o]}}var bw=xw({stackKey:(t,e)=>`${t[e]}_${t.group}`,fromZero:!0}),_w=xw({stackKey:(t,e)=>t[e],fromZero:!1});const kw=(t,e,n)=>{if(t.padding)t.padding(.5);else{const i=Array.from(new Set(e.map(t=>+t[n]))).reduce((e,n,i,o)=>{if(!i)return e;const r=o[i-1],a=yi(t,r,n);return!e||a<e?a:e},0),o=t.domain().slice();"y"===n&&o.reverse(),o[0]=xi(t,+o[0],-i/2),o[1]=xi(t,+o[1],i/2),"y"===n&&o.reverse(),t.domain(o)}},vw=t=>Math.pow(10,Math.ceil(Math.log10(Math.abs(t))))*Math.pow(-1,t<0?1:0);function ww(t,e,n,i,o,r,a){if(void 0===n||isNaN(o[0])||isNaN(o[1]))return o;if(a&&(o=o.slice().reverse()),o[0]===o[1]){if(o=o.slice(),"log"===e)(o=[(s=o[0],Math.pow(10,Math.floor(Math.log10(Math.abs(s))))*Math.pow(-1,s<0?1:0)),vw(o[0])])[1]<o[0]&&o.reverse();else{const t=Math.abs(parseFloat(o[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));o[0]-=t,o[1]+=t}return t.domain(a?o.slice().reverse():o),a?o.reverse():o}var s;const l=o[0]===o[1]?10:Math.abs(Math.log(o[1]-o[0])/100),h=()=>{let o=t.copy(),s=!1;if("log"===e){let e=t.domain().slice(),n=t.range().slice();if(a&&(e=e.reverse(),n=n.reverse()),s=e[0]*e[1]<0,s){const t=c.scaleLog().domain([1e-6,Math.abs(e[r])]).range([0,1])(Math.abs(e[r?0:1])),i=t/(t+1)*(n[1]-n[0]);e=(0===r?[e[0],1e-6]:[1e-6,e[1]]).map(Math.abs),n=0===r?[n[0],n[0]+i]:[n[0]+i,n[1]]}o=c.scaleLog().domain(e).range(n)}let l=!1;const h=o.range();let u;return u=o("log"===e&&s?Math.abs(n):n),a?0===r?l=u+i>h[r]:1===r&&(l=u-i<h[r]):0===r?l=u-i<h[r]:1===r&&(l=u+i>h[r]),l};if(t.invert&&h()){const s=10;if("log"===e){let e=0;for(;e<10&&h();){const n=(0===r?-1:1)*(o[r]<0?-1:1);o[r]+=o[r]*l*n,t.domain(a?o.slice().reverse():o),e++}}else if(0===r){const e=t.invert(t(n)+(i+s)*(a?1:-1));e<o[r]&&(o[r]=e,t.domain(a?o.slice().reverse():o))}else if(1===r){const e=t.invert(t(n)+(i+s)*(a?-1:1));e>o[r]&&(o[r]=e,t.domain(a?o.slice().reverse():o))}}return a?o.reverse():o}const Mw={Bar:bw,Box:_w,Circle:function({data:t,x:e,y:n,x2:i,y2:o,yScale:r,xScale:a,config:s,buffer:c}){e=e.copy(),n=n.copy();const l=i?"x2":"x",h=o?"y2":"y";let u=e.domain().slice(),d=n.domain().slice();return!e.invert&&e.padding&&kw(e,t,this.schema.discrete),!n.invert&&n.padding&&kw(n,t,this.schema.discrete),(e.invert||n.invert)&&t.forEach(t=>{const i=s?.r,o=c||2*("function"==typeof i?i(t.data,t.i):Number(i)||0);e.invert&&(u=ww(e,a??"linear",t[l],o,u,0,!1),u=ww(e,a??"linear",t[l],o,u,1,!1)),n.invert&&(d=ww(n,r??"linear",t[h],o,d,0,!0),d=ww(n,r??"linear",t[h],o,d,1,!0))}),[e,n]},Line:function({data:t,x:e,y:n,x2:i,y2:o}){const r=i?"x2":"x",a=o?"y2":"y",s="x"===this.schema.discrete?n:e,c=s.domain().slice();"x"===this.schema.discrete&&c.reverse();const l=t.map(t=>t["x"===this.schema.discrete?a:r]),u=s.invert(s(h.max(l))+("x"===this.schema.discrete?-10:10));return u>c[1]&&(c[1]=u),"x"===this.schema.discrete&&c.reverse(),s.domain(c),[e,n]},Rect:function({data:t,x:e,y:n,x2:i,y2:o,yScale:r,xScale:a,config:s}){e=e.copy(),n=n.copy();const c=i?"x2":"x",l=o?"y2":"y";let h=e.domain().slice(),u=n.domain().slice();return!e.invert&&e.padding&&kw(e,t,this.schema.discrete),!n.invert&&n.padding&&kw(n,t,this.schema.discrete),(e.invert||n.invert)&&t.forEach(t=>{if(e.invert){const n=(s?.width)(t.data,t.i);h=ww(e,a??"linear",t[c],n,h,0,!1),h=ww(e,a??"linear",t[c],n,h,1,!1)}if(n.invert){const e=(s?.height)(t.data,t.i);u=ww(n,r??"linear",t[l],e,u,0,!0),u=ww(n,r??"linear",t[l],e,u,1,!0)}}),[e,n]}};function Sw(t,e,n){const i="x"===t?[e.x,n.bottom]:"x2"===t?[e.x,n.top]:"y"===t?[n.left,e.y]:[n.right,e.y];return[[e.x,e.y],i]}function Cw(t,e){return"function"==typeof t?t(e.datum,e.index):t}function $w(t){const e=t;return e.interactive=!1,e.interactionGroup="axis",t}function Aw(t,e,n,i){const o=t.schema.axisHoverConfig.guideConfig||{},r=Cw(o.strokeDasharray,e);return e.badges.filter(t=>t.guide).map(t=>$w({type:"line",key:`plot-axis-hover-guide-${t.axis}`,points:Sw(t.axis,e.point,n),paint:{fill:"none",stroke:Cw(o.stroke,e)??i,strokeWidth:Cw(o.strokeWidth,e)??1,strokeOpacity:Cw(o.strokeOpacity,e)??1,strokeDasharray:Array.isArray(r)?r:$a(r)}}))}function zw(t,n){const i=t._plotArea;if(!i)return{guides:[],badges:[]};const o=function(t){return{left:t.x,right:t.x+t.width,top:t.y,bottom:t.y+t.height}}(i),a=n.color||J(t._theme,t=>t.textMuted,e.colorGray[500]);return{guides:Aw(t,n,o,a),badges:n.badges.map(i=>function(t,n,i,o,a){const s=t.schema.axisHoverConfig.badgeConfig||{},c=Cw(s.fontSize,n)??12,l=Cw(s.fontFamily,n)||`${t.schema.fontFamily}`,h=Cw(s.fontWeight,n)??400,u=Cw(s.padding,n)??4,d=Cw(s.fill,n)??a,f=Cw(s.fontColor,n)??e.colorContrast(d,t.schema.colorDefaults),m=r.textWidth(i.text,{"font-family":l,"font-size":c,"font-weight":h}),p=function(t,e,n,i){const{width:o,height:r}=n;return"x"===t?{x:e-o/2,y:i.bottom,width:o,height:r}:"x2"===t?{x:e-o/2,y:i.top-r,width:o,height:r}:"y"===t?{x:i.left-o,y:e-r/2,width:o,height:r}:{x:i.right,y:e-r/2,width:o,height:r}}(i.axis,i.at,{width:m+2*u,height:c+2*u},o),g=`plot-axis-hover-badge-${i.axis}`;return $w({type:"group",key:g,children:[$w({type:"rect",key:`${g}-box`,...p,rx:Cw(s.rx,n)??0,paint:{fill:d}}),$w({type:"text",key:`${g}-text`,x:0,y:0,transform:{x:p.x+p.width/2,y:p.y+p.height/2},lines:[{text:i.text,x:0,y:0,width:m}],font:{family:l,size:c,weight:h,anchor:"middle",baseline:"middle"},paint:{fill:f}})]})}(t,n,i,o,a))}}function Dw(t){const e=`curve${t.charAt(0).toUpperCase()}${t.slice(1)}`,n=R[e];return"function"==typeof n?n:R.curveLinear}function Lw(t,e){const n=Hm(t,"Line").curve,i="function"==typeof n?e?n(e,e.i):void 0:n;return"string"==typeof i&&i?i:"linear"}const Fw="fill-between",Nw=1e5;function Bw(){return{fillOpacity:.25}}function Ew(t,e){let n=[];!0===t?n=e.length>=2?[[e[0],e[1]]]:[]:Array.isArray(t)&&(n=t.every(Array.isArray)?t:[t]);const i=new Set(e);return n.filter(t=>t.length>=2).map(t=>[`${t[0]}`,`${t[1]}`]).filter(([t,e])=>t!==e&&i.has(t)&&i.has(e))}function Rw(t,e,n,i){const o=new Map;e.forEach(t=>o.set(`${t.discrete}`,t));const r=[];return t.forEach(t=>{const e=o.get(`${t.discrete}`);if(!e)return;const a={pos:n(t),a:i(t),b:i(e)};[a.pos,a.a,a.b].every(Number.isFinite)&&r.push(a)}),r}function Pw(t,e,n,i){const o=x.area().curve(Dw(i));return n?o.x(t=>t.pos).y0(e).y1(t=>t.a):o.y(t=>t.pos).x0(e).x1(t=>t.a),o(t)||""}function Tw(t){const{viz:e}=t,n=t.values,i=Ew(e.schema.fillBetween,function(t){return Array.from(new Set(t.map(t=>`${t.id}`)))}(n));if(!i.length)return[];const o="x"===(e.schema.discrete||"x"),r=t.shapeConfig.x,a=t.shapeConfig.y,s=o?r:a,c=o?a:r,l=Lw(e,n[0]);return i.flatMap(t=>function(t,e,[n,i],o){const r=e.filter(t=>`${t.id}`===n),a=e.filter(t=>`${t.id}`===i),s=Rw(r,a,o.pos,o.val);if(s.length<2)return[];const c=Ow(e,o.val,o.horizontal?"y":"x"),l=`${Fw}-${n}-${i}`,h=[{id:`${l}-${n}`,above:n,below:i,rep:r[0],edge:-c*Nw},{id:`${l}-${i}`,above:i,below:n,rep:a[0],edge:c*Nw}],u=h.flatMap(t=>{const e={...t.rep.data,above:t.above,below:t.below};return s.map(n=>({__d3plus__:!0,data:e,i:t.rep.i,id:t.id,...n}))}),d=o.horizontal?{x:t=>t.pos,x0:t=>t.pos,x1:null,y:t=>t.a,y0:t=>t.b,y1:t=>t.a}:{y:t=>t.pos,y0:t=>t.pos,y1:null,x:t=>t.a,x0:t=>t.b,x1:t=>t.a},f=Rm("Area").renderMode("compute").data(u).config({...d,curve:o.curve,duration:Zt(t),label:!1,fill:jw(t),strokeWidth:0}).config(function(t){return Hm(t,"Area",{...Hw(t),...t.schema.fillBetweenConfig})}(t));f.render();const m=Im(f);return h.flatMap(t=>{const e=m.filter(e=>e.key===t.id||e.key===`${t.id}-bgimage`);if(!e.some(e=>e.key===t.id))return[];e.forEach(t=>t.interactive=!1);const n=Pw(s,t.edge,o.horizontal,o.curve);return[{type:"group",key:`${t.id}::clip`,interactive:!1,clip:{type:"path",d:n},children:e}]})}(e,n,t,{pos:s,val:c,horizontal:o,curve:l}))}function Ow(t,e,n){const i=t[0];for(const o of t){const t=Number(o[n])-Number(i[n]),r=e(o)-e(i);if(t&&r)return Math.sign(t)===Math.sign(r)?1:-1}return"y"===n?-1:1}const Ww=["texture","textureDefault","backgroundImage","backgroundImageFit"];function Hw(t){const e=t.schema.shapeConfig??{},n=e.Area??{},i={};for(const t of Ww){const o=void 0!==n[t]?n[t]:e[t];void 0!==o&&(i[t]=o)}return i}function jw(t){return(e,n)=>{const{Line:i,stroke:o}=t.schema.shapeConfig,r=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof r?r(e,n):r}}function Iw(){return{fillOpacity:.05,fontSize:12,fontOpacity:.7,lineDasharray:"6 4",strokeDasharray:"4 4",strokeOpacity:.4,strokeWidth:1}}function Gw(t,e){return t instanceof Date?+t:f.finite(t)?t:e}function qw(t){const e=new Map;return t.forEach((t,n)=>{e.has(`${t}`)||e.set(`${t}`,n)}),t=>Gw(t,e.get(`${t}`)??NaN)}function Vw(t){return t.reduce((t,e)=>!t||e.at<t.at?e:t,void 0)}function Yw(t,e=!1){const n=qw(t.map(t=>t.value)),i=new Map;t.forEach(t=>{const e=i.get(t.series)??[];e.push({value:t.value,at:n(t.value),forecast:t.forecast}),i.set(t.series,e)});const o=new Map;for(const[t,n]of i){const i=Vw(n.filter(t=>t.forecast&&Number.isFinite(t.at)));if(!i)continue;const r=n.filter(t=>t.at<i.at);if(r.length){const e=r.reduce((t,e)=>e.at>t.at?e:t);o.set(t,{value:e.value,next:i.value,at:e.at})}else e&&o.set(t,{value:i.value,next:i.value,at:i.at})}return o}function Kw(t,e){const n=t.schema.discrete||"x",i=t.schema.forecast;let o;if("function"==typeof i)o=Boolean(i(e.data,e.i));else{const i=e["x"===n?"y":"x"];o=(t._confidence||[]).some(t=>{const n=t?t(e.data,e.i):void 0;return f.finite(n)&&n!==i})}return{series:`${e.id}`,value:e[n],forecast:o}}function Uw(t){let e;const n=[];for(const i of t._trendFits||[])i.samples.forEach((t,o)=>{const r=t[i.axis],a=Gw(r,o);t.step?n.push({value:r,at:a}):t.projected||e&&!(a>e.at)||(e={value:r,at:a})});if(!e)return null;const i=Vw(n.filter(t=>t.at>e.at));return i?{value:e.value,next:i.value,series:new Map}:null}function Xw(t,e){const n=t.schema.forecast;if(!1===n||null===n)return null;const i=function(t,e){const n=t.schema.forecast;if(!1===n||null==n)return null;const i=t.schema.discrete||"x";if(!0===n||"auto"===n||"function"==typeof n){const i=Yw(e.map(e=>Kw(t,e)),"function"==typeof n),o=Vw(Array.from(i.values()));if(!o)return null;const r=new Map(Array.from(i,([t,e])=>[t,e.value]));return{value:o.value,next:o.next,series:r}}const o=("x"===i?t._xTime:t._yTime)?r.date(n):n,a=e.map(t=>t[i]),s=qw([...a,o]),c=s(o),l=Vw(a.map(t=>({value:t,at:s(t)})).filter(t=>t.at>c));return l?{value:o,next:l.value}:{value:o}}(t,e);if(void 0!==n&&!0!==n&&"auto"!==n&&"function"!=typeof n)return i;const o=Uw(t);if(!i||!o)return i||o;const a=t.schema.discrete||"x",s=qw(e.map(t=>t[a]));return s(o.value)<s(i.value)?{...o,series:i.series}:i}function Zw(t,e,i){if(!i){const i=t.map(t=>t[e]);if(i.every(t=>"number"==typeof t))return function(t){let e=!1,i=!1,o=!1;for(const n of t)n!=n?e=!0:0===n&&(Object.is(n,-0)?o=!0:i=!0);if(e||i&&o)return n.unique([...t].sort((t,e)=>t-e));const r=Float64Array.from(t).sort(),a=[];for(let t=0;t<r.length;t++)0!==t&&r[t]===r[t-1]||a.push(r[t]);return a}(i)}return n.unique(t.sort(i??((t,n)=>t[e]-n[e])).map(t=>t[e]),t=>`${t}`)}function Qw(t,e){return Boolean(t._discreteExtent)&&t.schema.discrete===e}function Jw(t,e){return t._discreteExtent(e.data)}function tM(t,e){const n=e.filter(t=>t.data).map(e=>Jw(t,e));return[h.min(n,t=>t[0]),h.max(n,t=>t[1])]}const eM={method:"confidenceConfig",shapes:{Area:"Area",Bar:"Path"},extra:{"":["bandOpacity","capWidth","tooltip"],Bar:["capWidth"]}};const nM=[.15,.6],iM=t=>!!t&&"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype;function oM(t){const[e,n,i]=Array.isArray(t)?t:iM(t)?[t.lower,t.upper,t.label]:[],o=function(t){const e=t=>"function"==typeof t?t:!("string"!=typeof t||!t)&&q(t),n=Array.isArray(t)?[e(t[0]),e(t[1])]:[!1,!1];return!(!n[0]&&!n[1])&&n}([e,n]);if(!o)return null;const r={lower:o[0],upper:o[1]};return"string"!=typeof i&&"number"!=typeof i||(r.label=`${i}`),r}function rM(t){const e=function(t){return Array.isArray(t)&&t.length>0&&t.every(t=>Array.isArray(t)||iM(t))}(t)?t:[t];return e.map(oM).filter(t=>null!==t)}function aM(t){const e=t._confidence;if(!e)return[];const n=t._confidenceBands;return n&&n.length?n:[{lower:e[0],upper:e[1]}]}function sM(t,e,n){return e?aM(t).map((i,o)=>{const r={label:i.label??`${t.schema.translate("Band")} ${o+1}`},a=i.lower?i.lower(e,n):void 0,s=i.upper?i.upper(e,n):void 0;return f.finite(a)&&(r.lower=a),f.finite(s)&&(r.upper=s),r}):[]}function cM(t,e){if(e<=0)return[];if(f.finite(t))return Array.from({length:e},()=>t);const n=Array.isArray(t)&&t.length&&t.every(f.finite)?t:nM;if(1===n.length)return Array.from({length:e},()=>n[0]);const i=b.piecewise(b.interpolateNumber,n);return Array.from({length:e},(t,n)=>i(1===e?1:n/(e-1)))}function lM(t){let e=0;return t.map(t=>{const n=Math.min(1,Math.max(0,t)),i=e>=1?0:Math.max(0,1-(1-n)/(1-e));return e=1-(1-e)*(1-i),+i.toFixed(6)})}function hM(t,e){return null==t||"number"==typeof t&&Number.isNaN(t)?e:t}function uM(t,e){const n=aM(t).slice(1),i=[];for(const t of n)for(const n of e){const e=n.data,o=n.i;for(const n of[t.lower,t.upper]){const t=n?n(e,o):void 0;f.finite(t)&&i.push(t)}}return i}function dM(t){if(!t.length)return 0;const e=t.slice().sort((t,e)=>t[0]-e[0]);let[n,i]=e[0];for(let t=1;t<=e.length;t++){const o=e[t];if(o&&o[0]<i)o[1]>i&&(i=o[1]);else{if(n<0&&i>0)return-n<=i?n:i;o&&([n,i]=o)}}return 0}function fM(t,e=0){const n=t.map(()=>0);if(t.length<2)return n;const i=t.map((t,e)=>e).sort((e,n)=>t[e].value-t[n].value||e-n),o=2*Math.max(...t.map(t=>t.r))+e,r=[];let a=0;for(const s of i){const{value:i,r:c}=t[s];for(;a<r.length&&t[r[a]].value<i-o;)a++;const l=[];for(let o=a;o<r.length;o++){const a=r[o],s=i-t[a].value,h=c+t[a].r+e;if(s<h){const t=Math.sqrt(h*h-s*s);l.push([n[a]-t,n[a]+t])}}n[s]=dM(l),r.push(s)}return n}function mM(t,e,n=1){let i=0;return t.forEach((t,o)=>{i=Math.max(i,Math.abs(e[o])+t.r*n)}),i}const pM=(t,e)=>1===e?t:t.map(t=>({value:t.value,r:t.r*e}));function gM(t,e,n){let i=1;for(let o=0;o<12;o++){const o=mM(t,fM(pM(t,i),e*i),i);if(o<=n||0===o)break;i*=Math.max(.5,.98*Math.sqrt(n/o))}return i}function yM(t,e){const{padding:n,extent:i,overflow:o}=e,r="shrink"===o&&i>0?Math.min(1,...t.map(t=>gM(t,n,i))):1,a=t.map(t=>{const e=fM(pM(t,r),n*r);return"visible"===o?e:e.map((e,n)=>{const o=Math.max(0,i-t[n].r*r);return Math.max(-o,Math.min(o,e))})});return{offsets:a,scale:r}}const xM=t=>null==t||""===t,bM=t=>"number"==typeof t&&Number.isFinite(t)||t instanceof Date,_M=t=>t.some(bM)&&t.every(t=>xM(t)||bM(t));function kM(t,e){if(!t||!e.length)return null;const n=e.map(t=>t.x),i=e.map(t=>t.y);let o;if("x"===t||"y"===t)o=t;else if("auto"===t){if(!e.every(t=>"Circle"===t.shape))return null;i.every(xM)?o="x":n.every(xM)&&(o="y")}else o=_M(n)?"x":"y";if(!o||!_M("x"===o?n:i))return null;const r="x"===o?"y":"x",a=e.some(t=>!xM(t[r])&&!bM(t[r]));return{axis:o,cross:r,lanes:a}}function vM(t,e){const{cross:n,lanes:i}=e;for(const e of t)e[n]=i&&!xM(e[n])?`${e[n]}`:""}const wM=(t,e)=>!!t._swarm&&t._swarm.cross===e&&!t._swarm.lanes;function MM(t,e){const n=t._swarm,i=t.schema.swarmConfig||{},{axis:o,cross:r}=n,a="x"===o?e.x:e.y,s="x"===r?e.x:e.y,c="x"===r?e.xRange:e.yRange,l=Math.abs(c[c.length-1]-c[0]),h=new Map;n.lanes&&e.lanes.forEach(t=>h.set(`${t}`,s(t,r)));const u=Array.from(h.values()).sort((t,e)=>t-e);let d=u.length>1?1/0:l;for(let t=1;t<u.length;t++)d=Math.min(d,u[t]-u[t-1]);const f=(c[0]+c[c.length-1])/2,m=new Map;e.values.forEach((t,n)=>{const i=`${t[r]}`;m.has(i)||m.set(i,{rows:[],nodes:[]});const s=m.get(i);s.rows.push(t),s.nodes.push({value:a(t[o]),r:Math.max(0,Number(e.r(t,n))||0)})});const p=i.padding??1,g=Array.from(m.values()),y=yM(g.map(t=>t.nodes),{padding:p,extent:Math.max(0,d/2-p/2),overflow:i.overflow??"shrink"}),x=new Map;return g.forEach((t,e)=>{t.rows.forEach((n,i)=>{const a=h.get(`${n[r]}`)??f,s=t.nodes[i].value,c=a+y.offsets[e][i];x.set(n,{x:"x"===o?s:c,y:"x"===o?c:s,r:t.nodes[i].r*y.scale})})}),x}const SM=["x","x2","y","y2"];function CM(t,e){const n=t._plotFacetScales?.padded;if(!n)return e;const i={...e};for(const t of SM){const e=i[t];e&&n[t]&&"function"==typeof e.invert&&(i[t]=e.copy().domain(n[t]))}return i}function $M(t,e,n){if(!hg(t)||!e)return;const i=t=>null!=t,o=e.slice();return"number"==typeof n&&(o[0]>n?o[0]=n:o[1]<n&&(o[1]=n)),{pinned:[i(t[0]),i(t[1])],auto:o}}function AM(t,e,n,i){const o=e.pinned[0]?1:0,r=Xi(o?[+e.auto[0],t[1]]:[t[0],+e.auto[1]],n,i);if(!r)return;const a=r[o];if(o?a<=t[0]:a>=t[1])return;const s=t.slice();return s[o]=a,s}const zM=(t,e)=>t[`_${e}Config`]?.rounding??t._plotAxisDefaults?.[e]?.rounding??"outside",DM=({viz:t,plotScales:e,plotConfigScales:n,plotOpenEnds:i})=>{if(!e||!n||!i)return{};const o={...e};for(const e of["x","y"]){const r=i[e],a=n[`${e}ConfigScale`],s=zM(t,e);if(!r||!Ui.includes(a)||"none"===s)continue;const c=o[e],l=t=>"y"===e?t.slice().reverse():t,h=AM(l(c.domain().map(Number)),r,s,a);h&&(o[e]=c.copy().domain(l(h)))}return{plotScales:o}},LM=t=>"y"===t[0],FM=t=>t instanceof Date?""+ +t:`${t}`;function NM(t,e,n,i="data"){if(null==n||""===n)return NaN;const{plot:o}=t;if("plot"===i){const t=Number(n);return Number.isFinite(t)?LM(e)?o.y1-t*(o.y1-o.y0):o.x0+t*(o.x1-o.x0):NaN}const a=t.axes[e];if(!a)return NaN;const s=a.time?r.date(n):n;if(!1===s||void 0===s)return NaN;if(a.categories){const t=FM(s);if(!a.categories.some(e=>FM(e)===t))return function(t,e){const n=BM(e),i=t.categories||[];if(!Number.isFinite(n)||!i.length)return NaN;const o=i.map(e=>[BM(e),t.scale(e)]).sort((t,e)=>t[0]-e[0]);if(o.some(([t,e])=>!Number.isFinite(t)||!Number.isFinite(e)))return NaN;for(let t=1;t<o.length;t++){const[e,i]=o[t-1],[r,a]=o[t];if(n>=e&&n<=r)return i+(n-e)/(r-e)*(a-i)}return NaN}(a,s)}const c=a.scale(s);return"number"==typeof c&&Number.isFinite(c)?c:NaN}const BM=t=>t instanceof Date?+t:"number"==typeof t?t:NaN;function EM(t,e){const n=t.axes[e];if(!(n&&n.slots&&n.categories&&n.categories.length))return 0;const i=n.categories.map(t=>n.scale(t)).filter(t=>Number.isFinite(t)).sort((t,e)=>t-e);let o=1/0;for(let t=1;t<i.length;t++){const e=i[t]-i[t-1];e>.5&&e<o&&(o=e)}if(Number.isFinite(o))return o/2;const{plot:r}=t;return(LM(e)?r.y1-r.y0:r.x1-r.x0)/2}function RM(t,e,n,i="data"){const o=NM(t,e,n[0],i),r=NM(t,e,n[1],i);if(!Number.isFinite(o)||!Number.isFinite(r))return null;const a="data"===i?EM(t,e):0;return[Math.min(o,r)-a,Math.max(o,r)+a]}function PM(t,e,n){const i=Math.max(t[0],e),o=Math.min(t[1],n);return o-i>=.5?[i,o]:null}function TM([t,e],n,i=.5){return t>=n.x0-i&&t<=n.x1+i&&e>=n.y0-i&&e<=n.y1+i}function OM(t,e,n="data",i="data"){const o=void 0===e.x&&void 0!==e.x2?"x2":"x",r=void 0===e.y&&void 0!==e.y2?"y2":"y";return[NM(t,o,e[o],n),NM(t,r,e[r],i)]}const WM=new Set(["band","ordinal","point"]);function HM(t,e,n,i){if(!t||!t._d3Scale)return;const o=t.schema.scale,r={scale:e,time:n||"time"===o};return WM.has(o)&&(r.categories=t._d3Scale.domain(),i&&(r.slots=!0)),r}function jM(t,e){const{x:n,y:i,xRange:o,yRange:r,x2Height:a}=e,s=[r[0],r[1]].map(t=>t-a),c={x0:Math.min(o[0],o[1]),y0:Math.min(s[0],s[1]),x1:Math.max(o[0],o[1]),y1:Math.max(s[0],s[1])},l=t.schema.discrete||"x",h=t=>!!e.slots&&t[0]===l,u={x:HM(t._xAxis,t=>n(t),!!t._xTime,h("x")),y:HM(t._yAxis,t=>i(t),!!t._yTime,h("y"))};return e.x2Exists&&(u.x2=HM(t._x2Axis,t=>n(t,"x2"),!!t._x2Time,h("x2"))),e.y2Exists&&(u.y2=HM(t._y2Axis,t=>i(t,"y2"),!!t._y2Time,h("y2"))),{plot:c,axes:u}}const IM=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function GM(t,e){const n=IM(e("fontSize"),12),i=e("fontFamily")??t.schema.fontFamily;return{fontColor:e("fontColor")||Ws(t),fontFamily:"string"==typeof i||Array.isArray(i)?s.fontFamilyStringify(i):"sans-serif",fontSize:n,fontWeight:e("fontWeight")??400,lineHeight:IM(e("lineHeight"),Math.round(1.3*n)),maxWidth:Math.max(1,IM(e("maxWidth"),150))}}function qM(t,e){const n=s.textWrap().fontFamily(e.fontFamily).fontSize(e.fontSize).fontWeight(e.fontWeight).lineHeight(e.lineHeight).width(e.maxWidth).height(Number.MAX_SAFE_INTEGER)(t),i=[],o=[];return n.lines.forEach((t,e)=>{""!==t&&(i.push(t),o.push(n.widths[e]??0))}),{lines:i,widths:o,width:o.length?Math.ceil(Math.max(...o)):0,height:i.length*e.lineHeight,lineHeight:e.lineHeight}}function VM(t,e,n){return{type:"text",key:n.key,interactive:!1,x:0,y:0,transform:{x:n.x,y:n.y},lines:t.lines.map((e,n)=>({text:e,x:0,y:t.lineHeight*(n+.5),width:t.widths[n]})),font:{family:e.fontFamily,size:e.fontSize,weight:e.fontWeight,anchor:n.align,baseline:"middle"},paint:{fill:e.fontColor,opacity:n.opacity??1}}}const YM=new WeakMap;function KM(t,e,n){YM.set(t,{block:e,spots:n})}function UM(t,e){const n="end"===t.align?e.width:"middle"===t.align?e.width/2:0;return{x:t.x-n,y:t.y,width:e.width,height:e.height}}function XM(t,e,n,i){return t.find((t,o)=>{const r=UM(t,e);return(!o||((t,e)=>t.x>=e.x0-.5&&t.y>=e.y0-.5&&t.x+t.width<=e.x1+.5&&t.y+t.height<=e.y1+.5)(r,i))&&!n.some(t=>((t,e)=>t.x<e.x+e.width-.5&&e.x<t.x+t.width-.5&&t.y<e.y+e.height-.5&&e.y<t.y+t.height-.5)(r,t))})??null}function ZM(t,e){const n=Math.floor(Math.abs(e-t)/6),i=e<t?-1:1,o=Array.from({length:n+1},(e,n)=>t+i*n*6);return o[o.length-1]!==e&&o.push(e),o}function QM(t,e,n){const i=[...e],o=t=>t.flatMap(t=>{if("group"===t.type)return[{...t,children:o(t.children)}];const e=YM.get(t);if(!e||"text"!==t.type)return[t];const r=XM(e.spots,e.block,i,n);if(!r)return[];i.push(UM(r,e.block));return[{...t,transform:{...t.transform,x:r.x,y:r.y},font:{...t.font,anchor:r.align}}]});return o(t)}const JM="ReferenceLine",tS="ReferenceBand",eS=["x","y","x2","y2"],nS=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function iS(t){return(Array.isArray(t)?t:t?[t]:[]).filter(t=>!!t&&"object"==typeof t)}function oS(t){return iS(t).map(t=>({layer:"back",...t,shape:JM}))}function rS(t){return iS(t).map(t=>({layer:"back",...t,shape:tS}))}function aS(t){return eS.find(e=>void 0!==t[e]&&null!==t[e])??null}const sS=(t,e)=>LM(e)?[t.plot.y0,t.plot.y1]:[t.plot.x0,t.plot.x1];function cS(t,e){const n=aS(e);if(!n)return null;const i=NM(t,n,e[n],e.ref),[o,r]=sS(t,n);if(!Number.isFinite(i)||i<o-.5||i>r+.5)return null;const{plot:a}=t;return{axis:n,at:i,points:LM(n)?[[a.x0,i],[a.x1,i]]:[[i,a.y1],[i,a.y0]]}}function lS(t,e){const n=aS(e),i=n?e[n]:void 0;if(!n||!Array.isArray(i)||i.length<2)return null;const o=RM(t,n,[i[0],i[1]],e.ref),[r,a]=sS(t,n),s=o&&PM(o,r,a);if(!s)return null;const{plot:c}=t;return{axis:n,box:LM(n)?{x:c.x0,y:s[0],width:c.x1-c.x0,height:s[1]-s[0]}:{x:s[0],y:c.y0,width:s[1]-s[0],height:c.y1-c.y0}}}function hS(t,e,n,i="end"){const{plot:o}=t;if(LM(e.axis)){const t=e.at-4-n.height;return{x:"start"===i?o.x0+4:o.x1-4,y:t>=o.y0?t:e.at+4,align:"start"===i?"start":"end"}}const r=e.at+4+n.width<=o.x1;return{x:r?e.at+4:e.at-4,y:"start"===i?o.y1-4-n.height:o.y0+4,align:r?"start":"end"}}const uS=(t,e)=>t.flatMap(t=>e.map(e=>[t,e]));function dS(t,e,n,i="end"){const{plot:o}=t,r=hS(t,e,n,i),a="start"===i?"end":"start";if(LM(e.axis)){const t=[r.y,r.y===e.at+4?e.at-4-n.height:e.at+4],i=[[r.x,r.align],"start"===a?[o.x0+4,"start"]:[o.x1-4,"end"]],s=ZM("end"===r.align?o.x1-4-n.width:o.x0+4,"end"===r.align?o.x0+4:o.x1-4-n.width);return[...uS(i,t).map(([[t,e],n])=>({x:t,y:n,align:e})),...uS(s,t).map(([t,e])=>({x:t,y:e,align:"start"}))]}const s=[[r.x,r.align],"start"===r.align?[e.at-4,"end"]:[e.at+4,"start"]],c=o.y0+4,l=o.y1-4-n.height,h=[r.y,r.y===c?l:c],u=ZM(r.y,r.y===c?l:c);return uS([...h,...u],s).map(([t,[e,n]])=>({x:e,y:t,align:n}))}function fS(t,e,n,i="start"){const o=[t.x+4,"start"],r=[t.x+t.width-4,"end"],a="end"===i?[r,o]:[o,r],s=t.y+4,c=t.y+t.height-4-n.height,l=uS([s,c],a).map(([t,[e,n]])=>({x:e,y:t,align:n}));if(LM(e)){const[[t],[e]]=a,o="end"===i?t-n.width:t,r="end"===i?e:e-n.width;return[...l,...uS(ZM(o,r),[s,c]).map(([t,e])=>({x:t,y:e,align:"start"}))]}return[...l,...uS(ZM(s,c),a).map(([t,[e,n]])=>({x:e,y:t,align:n}))]}function mS(t,e,n,i){const o=e.label;if(null==o||!1===o||""===o)return null;const r=GM(t,t=>e[t]),a=qM(`${o}`,r);if(!a.lines.length)return null;const s=i(a),c=VM(a,r,{key:n,...s[0]});return KM(c,a,s),c}function pS(t,e,n,i){const o=cS(n,e);if(!o)return[];const r=GM(t,t=>e[t]),a={fill:"none",stroke:e.stroke||r.fontColor,strokeWidth:nS(e.strokeWidth,1),strokeOpacity:nS(e.strokeOpacity,.6)},s=function(t){const e=t.dash??t.strokeDasharray;return!0===e?[4,4]:!1!==e?$a(e):void 0}(e);s&&(a.strokeDasharray=s);const c=[{type:"line",key:`${i}-line`,interactive:!1,points:o.points,curve:"linear",paint:a}],l=mS(t,e,`${i}-label`,t=>dS(n,o,t,"start"===e.labelPosition?"start":"end"));return l&&c.push(l),c}function gS(t,e,n,i){const o=lS(n,e);if(!o)return[];const r=GM(t,t=>e[t]),a={fill:e.fill||r.fontColor,fillOpacity:nS(e.fillOpacity,.08)};e.stroke&&(a.stroke=e.stroke,a.strokeWidth=nS(e.strokeWidth,1),a.strokeOpacity=nS(e.strokeOpacity,.4));const s=[{type:"rect",key:`${i}-band`,interactive:!1,...o.box,paint:a}],c=mS(t,e,`${i}-label`,t=>fS(o.box,o.axis,t,"end"===e.labelPosition?"end":"start"));return c&&s.push(c),s}function yS(t){const e={x:[],y:[],x2:[],y2:[]};return t.forEach(t=>{if(t.shape!==JM&&t.shape!==tS)return;if("plot"===t.ref)return;const n=aS(t);if(!n)return;const i=t[n];t.shape===tS?Array.isArray(i)&&e[n].push(i[0],i[1]):e[n].push(i)}),e}function xS(t,e){if(null==t||""===t)return NaN;if(e){const e=t instanceof Date?t:r.date(t);return e instanceof Date?+e:NaN}return"number"==typeof t||"string"==typeof t?Number(t):NaN}function bS(t,e,n={}){const{time:i=!1,log:o=!1,open:r=[!0,!0]}=n;if(!t||2!==t.length||!e.length)return t;const a=t.map(t=>xS(t,i));if(!a.every(Number.isFinite))return t;const s=e.map(t=>xS(t,i)).filter(t=>Number.isFinite(t)&&(!o||t>0));if(!s.length)return t;const c=a[0]<=a[1],[l,h]=c?[0,1]:[1,0],u=Math.min(...s),d=Math.max(...s),f=t.slice();let m=!1;return r[l]&&u<a[l]&&(f[l]=i?new Date(u):u,m=!0),r[h]&&d>a[h]&&(f[h]=i?new Date(d):d,m=!0),m?f:t}function _S(t){if(!Array.isArray(t))return[!0,!0];const e=t=>null==t;return[e(t[0]),t.length<2||e(t[1])]}const kS=new Set(["Linear","Time"]);function vS(t,e,n,i){const o=yS([...rS(t.schema.referenceBands),...oS(t.schema.referenceLines),...t._annotations||[]]),r={...e};return["x","y","x2","y2"].forEach(a=>{const s=e[a];if(!s||!o[a].length)return;if(!kS.has(n[a].type))return;const c=t[`_${a}Config`]?.domain,l=1===a.length?i[a]??c:t.schema[`${a}Domain`]??c;r[a]=bS(s,o[a],{time:"Time"===n[a].type,log:"log"===n[a].config,open:_S(l)})}),r}const wS=E;function MS(t,e){return e?t.map(t=>void 0===t?t:r.date(t)):t.slice()}function SS(t,e,n,i){const o=t[`_${e}Time`]?"Time":!Qw(t,e)&&(t.schema.discrete===e||t.schema[`${e}Sort`])||t._swarm?.cross===e?"Point":"Linear",r=n[e]?MS(n[e],t[`_${e}Time`]):i[e],a=t.schema[`${e}2Domain`]?MS(t.schema[`${e}2Domain`],t[`_${e}2Time`]):i[`${e}2`];return"Point"!==o&&(r&&void 0===r[0]&&(r[0]=i[e][0]),r&&void 0===r[1]&&(r[1]=i[e][1]),a&&void 0===a[0]&&(a[0]=i[`${e}2`][0]),a&&void 0===a[1]&&(a[1]=i[`${e}2`][1])),[r,o,a,o]}function CS(t,e,n,i){const o=t[`_${n}Config`].scale;if("auto"===o){if(t.schema.discrete===n)return i;const o=e.map(t=>t[n]);return h.deviation(o)/h.mean(o)>3?"log":"linear"}return o||i}const $S=(t,e)=>t.map(t=>t[e]).filter(t=>![NaN,void 0,!1].includes(t));const AS=({viz:t,plotFormattedData:e,plotAxisData:n,plotInitialDomains:i})=>{const o=e||[],r=n||[];let a=i;const s=t.schema.width-t._margin.left-t._margin.right,c=t.schema.height-t._margin.top-t._margin.bottom,l=t.schema.discrete?"x"===t.schema.discrete?"y":"x":void 0,u=t.schema.discrete?"x"===t.schema.discrete?"y2":"x2":void 0,d=[l,u].filter(t=>t),f={x:_g(t,"x",a.x),y:_g(t,"y",a.y)},m={x:$M(f.x,a.x,d.includes("x")?t.schema.baseline:void 0),y:$M(f.y,a.y,d.includes("y")?t.schema.baseline:void 0)},[p,g,y,x]=SS(t,"x",f,a),[b,_,k,v]=SS(t,"y",f,a),w=CS(t,r,"y",_).toLowerCase(),M=CS(t,r,"y2",v).toLowerCase(),S=CS(t,r,"x",g).toLowerCase(),C=CS(t,r,"x2",x).toLowerCase(),$=vS(t,{x:p,y:b,x2:y,y2:k},{x:{type:g,config:S},y:{type:_,config:w},x2:{type:x,config:C},y2:{type:v,config:M}},f);a={x:$.x,x2:$.x2||$.x.slice(),y:$.y,y2:$.y2||$.y.slice()},function(t,e,n,i){Object.keys(e).forEach(o=>{"log"===t[`_${o}ConfigScale`]&&e[o].includes(0)&&(h.min(e[o])<0?e[o][1]=h.max($S(n,o)):e[o][0]=h.min($S(i,o)))})}(t,a,o,r),function(t,e,n,i,o){n.forEach(n=>{if(t[`_${n}Config`].domain&&!ug(t,n)){const i=t[`_${n}Config`].domain.slice();"x"===t.schema.discrete&&i.reverse(),e[n]=i}else if(n&&void 0!==t.schema.baseline&&!wg(t,n,n.startsWith("x")?i.x:i.y,o[n])){const i=t.schema.baseline;e[n]&&e[n][0]>i?e[n][0]=i:e[n]&&e[n][1]<i&&(e[n][1]=i)}})}(t,a,d,{x:S,y:w},f);const A=(e,n,i,o)=>function(t,e,n,i,o){return hm(t,e,wS[`scale${n}`]().domain(i).range(h.range(0,o+1,o/(i.length-1))))}(t,e,n,i,o),z=A("x",g,a.x,s),D=A("x2",x,a.x2,s),L=A("y",_,a.y.slice().reverse(),c),F=A("y2",v,a.y2.slice().reverse(),c);return{plotDomains:a,plotScales:{x:z,y:L,x2:D,y2:F,xScale:g,yScale:_,x2Scale:x,y2Scale:v},plotConfigScales:{xConfigScale:S,yConfigScale:w,x2ConfigScale:C,y2ConfigScale:M},plotOpps:{opp:l,opp2:u,opps:d},plotOpenEnds:m}},zS="::confidence";function DS(t,e,n){const i=e<0?n[0]:n[1],o=e<0?n[1]:n[0];return i+(t-e)*(e?(i-o)/e:1)}function LS(t,e,n){const i=t[e],o={};for(const[e,r]of[["lower",t.lci],["upper",t.hci]])f.finite(r)&&(n&&f.finite(i)&&f.finite(n[0])&&f.finite(n[1])?o[e]=DS(r,i,n):n||(o[e]=r));return o}function FS(t,e,n,i){const o={lower:f.finite(t),upper:f.finite(e)};if(!i)return{lower:t,upper:e,end:n,caps:o};const[r,a]=i,s=(t,e)=>{if(!f.finite(t))return t;const n=f.clamp(t,r,a);return n!==t&&(o[e]=!1),n};return{lower:s(t,"lower"),upper:s(e,"upper"),end:f.clamp(n,r,a),caps:o}}function NS(t){return{capWidth:"50%",stroke:(e,n)=>{const{Bar:o,fill:r}=t.schema.shapeConfig,a=o&&void 0!==o.fill?o.fill:r,s="function"==typeof a?a(e,n):a,c=i.color(s);return c?c.darker(1.5).formatHex():s},strokeWidth:2}}function BS(t,e){return!(!f.finite(e)||!t)&&t.some(t=>e>Math.min(t.start,t.end)&&e<Math.max(t.start,t.end))}function ES(t,e){const{viz:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:r}=t,a="y"===n.schema.discrete?"y":"x",s="x"===a?"y":"x",c="x"===a?t.y:t.x,l=function(t,e,n){const i="y"===e?t.viz._yAxis:t.viz._xAxis,o=i&&!i._d3ScaleNegative&&i._d3Scale?i._d3Scale.domain():[],r=o.length?[o[0],o[o.length-1]].map(t=>n(t)):[];if(2!==r.length||!r.every(f.finite))return t.valueExtent;const a=Math.min(r[0],r[1]),s=Math.max(r[0],r[1]);return t.valueExtent?[Math.max(a,t.valueExtent[0]),Math.min(s,t.valueExtent[1])]:[a,s]}(t,s,c),h=("y"===s?n._yAxis:n._xAxis)?._breaks,u=new Map;for(const t of e){if("rect"!==t.type||"Bar"!==t.shapeType||`${t.key}`.endsWith("::hit"))continue;const e=t.datum;if(!e||u.has(e))continue;const d=n.schema.stacked?i[o.get(e.id)??-1]?.[r.get(e.discrete)??-1]:void 0;if(n.schema.stacked&&!d)continue;const m=LS(e,s,d);if(!f.finite(m.lower)&&!f.finite(m.upper))continue;const p=void 0!==e[`${s}2`]?`${s}2`:void 0,g=t=>f.finite(t)?c(t,p):void 0,y=t.transform??{},x=e[s],b=FS(g(m.lower),g(m.upper),c(d?x<0?d[0]:d[1]:x,p),l);BS(h,m.lower)&&(b.caps.lower=!1),BS(h,m.upper)&&(b.caps.upper=!1),u.set(e,{key:t.key,center:"x"===a?(y.x??0)+t.x+t.width/2:(y.y??0)+t.y+t.height/2,thickness:"x"===a?t.width:t.height,...b})}return u}function RS(t,e){const{viz:n}=t;if(!n._confidence)return[];const i=ES(t,e);if(!i.size)return[];const o=Hm(n,"Bar",{...NS(n),...n._confidenceConfig??{}}),r=o.capWidth;delete o.capWidth,delete o.tooltip;const a="y"===n.schema.discrete?"y":"x",s=t=>i.get(t),c=Rm("Path").renderMode("compute").config(o).config({d:(t,e)=>{const n=s(t),i="function"==typeof r?r(t,e):r;return function(t,e,n,i,o,r,a={}){const s=f.finite(o)?o:i,c=f.finite(r)?r:i,l=n/2,h=(e,n)=>"x"===t?`${n},${e}`:`${e},${n}`;let u=`M${h(s,e)}L${h(c,e)}`;for(const[t,n]of[[o,a.lower],[r,a.upper]])f.finite(t)&&!1!==n&&l>0&&(u+=`M${h(t,e-l)}L${h(t,e+l)}`);return u}(a,n.center,function(t,e){if(f.finite(t))return Math.max(0,t);if("string"==typeof t&&t.trim().endsWith("%")){const n=parseFloat(t);if(f.finite(n))return Math.max(0,e*n/100)}return e/2}(i,n.thickness),n.end,n.lower,n.upper,n.caps)},fill:"none",hitArea:{"stroke-width":10},id:t=>`${s(t).key}${zS}`,label:!1,x:0,y:0}).data(Array.from(i.keys()));return n._wirePlotShapeEvents(c,"Bar",t.events),Im(c).map(t=>({...t,shapeType:"Bar"}))}function PS(t){return t.__d3plusStackOrder=!0,t}function TS(t){let e,n=-1,i=0;const o=t.length;for(;++n<o;)(e=+t[n][1])&&(i+=e);return i}const OS=PS(t=>R.stackOrderAscending(t)),WS=PS(t=>R.stackOrderDescending(t)),HS=PS(t=>{const e=t.map(TS),n=t.map(t=>t.key.split("_")[0]);return R.stackOrderNone(t).sort((t,i)=>n[t].localeCompare(n[i])||e[t]-e[i])}),jS=PS(t=>HS(t).reverse());function IS(t,e="descending"){return PS(n=>{const i=n.map(e=>{let n=0;for(let i=0;i<e.length;i++){const o=(e[i].data||[]).find(t=>t.id===e.key);if(o&&o.data){const e=+t(o.data);isNaN(e)||(n+=e)}}return n});return R.stackOrderNone(n).sort((t,n)=>"ascending"===e?i[t]-i[n]:i[n]-i[t])})}const GS={ascending:OS,descending:WS,key:HS,keyReverse:jS,none:PS(t=>R.stackOrderNone(t)),data:PS(t=>R.stackOrderNone(t)),insideOut:PS(t=>R.stackOrderInsideOut(t)),appearance:PS(t=>R.stackOrderAppearance(t)),reverse:PS(t=>R.stackOrderReverse(t))},qS=Object.keys(GS);function VS(t){if("function"==typeof t)return t.__d3plusStackOrder?t:IS(t);if(Array.isArray(t))return t;if(t&&"object"==typeof t){const{value:i,order:o}=t;return"function"==typeof i?IS(i,o):(e=IS(I(i),o),n=i,G.set(e,n),e)}var e,n;return"string"==typeof t?t in GS?GS[t]:(console.warn(`[d3plus] Unknown stackOrder "${t}". Expected one of: ${qS.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`),WS):WS}function YS(t,e){let n,i,o,r,a,s;if(!((n=t.length)>0))return;const c=t[e[0]].length;for(let l=0;l<c;++l)for(s=a=0,r=0;r<n;++r)(o=(i=t[e[r]][l])[1]-i[0])>=0?(i[0]=s,i[1]=s+=o):o<0?(i[1]=a,i[0]=a+=o):i[0]=s}const KS={diverging:YS,none:R.stackOffsetNone,expand:R.stackOffsetExpand,silhouette:R.stackOffsetSilhouette,wiggle:R.stackOffsetWiggle},US=Object.keys(KS);function XS(t){return"function"==typeof t?t:"string"==typeof t&&t in KS?KS[t]:(console.warn(`[d3plus] Unknown stackOffset "${t}". Expected one of: ${US.join(", ")}; or an offset function. Falling back to "diverging".`),YS)}function ZS(t,e,n){const i=new Map,o=Math.max(0,...t.map(t=>t.length));for(let r=0;r<o;r++){const o=[];t.forEach((t,i)=>{const a=t[r],s=n(`${e[i]}`);if(!a||void 0===s)return;const[c,l]=[+a[0],+a[1]];Number.isFinite(c)&&Number.isFinite(l)&&c!==l&&o.push({series:s,order:t.index??i})}),o.sort((t,e)=>t.order-e.order),o.forEach(({series:t},e)=>{const n=i.get(t)??{total:0,count:0};n.total+=(e+.5)/o.length,n.count+=1,i.set(t,n)})}return i}function QS(t){const e=new Map;for(const n of t)n.forEach(({total:t,count:n},i)=>{const o=e.get(i)??{total:0,count:0};e.set(i,{total:o.total+t,count:o.count+n})});return e}function JS(t){const e=e=>{const{total:n,count:i}=t.get(e);return n/i};return Array.from(t.keys()).sort((t,n)=>e(t)-e(n))}function tC(t,e,n){const i=e.slice(),o=new Set(e);let r;for(const e of t){if(!o.has(e)){if(!n.has(e))continue;const t=void 0===r?0:i.indexOf(r)+1;i.splice(t,0,e),o.add(e)}r=e}return i}function eC(t,e,n){let i=[[]];const o=t._drawDepth??0;for(let r=0;r<=o;r++){const o=t.schema.groupBy?.[r];if("function"!=typeof o)break;const a=o.bind(t)(e,n),s=(Array.isArray(a)?a:[a]).map(t=>`${t}`).filter(Boolean);s.length&&(i=i.flatMap(t=>s.map(e=>[...t,e])))}return i.map(t=>t.join("_"))}function nC(t,e){if(!e?.size)return void(t._stackLegendOrder=void 0);const n=new Set((t._legendData??[]).flatMap((e,n)=>eC(t,e,n)));t._stackLegendOrder=tC(t._stackLegendOrder??[],JS(e),n)}function iC(t,e){let n,i=new Map;const o=e=>{const n=eC(t,e,0).map(t=>i.get(t)).filter(t=>void 0!==t);return n.length?n.reduce((t,e)=>t+e,0)/n.length:1/0};return(r,a)=>{const s=t.schema.stacked?t._stackLegendOrder:void 0;if(s?.length){s!==n&&(n=s,i=new Map(s.map((t,e)=>[t,e])));const t=o(r),e=o(a);if(t!==e)return t<e?-1:1}return e(r,a)}}const oC=[y.timeYear,y.timeMonth,y.timeDay,y.timeHour,y.timeMinute,y.timeSecond];function rC(t){const e=t.slice().sort((t,e)=>t-e),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function aC(t,e){if(!e)return[];const n=function(t){const e=t.some(t=>t instanceof Date);if(t.some(t=>!(t instanceof Date)&&"number"!=typeof t))return null;const n=Array.from(new Set(t.map(Number).filter(Number.isFinite))).sort((t,e)=>t-e);if(n.length<2)return null;const i=n.slice(1).map((t,e)=>t-n[e]);if(!e){const t=rC(i);return(e,n)=>+(e+t*n).toPrecision(12)}const o=n.map(t=>new Date(t)),r=oC.find(t=>o.every(e=>+t.floor(e)===+e));if(r){const t=Math.round(rC(o.slice(1).map((t,e)=>r.count(o[e],t))));if(t>0)return(e,n)=>r.offset(e,t*n)}const a=rC(i);return(t,e)=>new Date(+t+a*e)}(t);if(!n)return[];const i=t.some(t=>t instanceof Date),o=t.reduce((t,e)=>+e>+t?e:t,t[0]);if("number"==typeof e){const t=Math.min(Math.floor(e),1e3);return Array.from({length:Math.max(t,0)},(t,e)=>n(o,e+1))}const a=e.to;if(null==a)return[];const s=i?r.date(a):+a;if(!Number.isFinite(+s))return[];const c=[];for(let t=1;t<=1e3;t++){const e=n(o,t);if(+e>+s)break;c.push(e)}return c}const sC=["linear","exponential","logarithmic","power","polynomial"];function cC(t){return!0===t?"linear":sC.includes(t)?t:null}function lC(t){return"y"===t?"y":"x"}function hC(t,e,n=50){const[i,o]=t;return e?e.filter(t=>t>=i&&t<=o):i===o?[i]:Array.from({length:n},(t,e)=>i+(o-i)*e/(n-1))}function uC(t,e,n){const[i,o]=t,r=Math.max(...e);if(!(r>o))return[];if(n)return[o,...n.filter(t=>t>o&&t<=r)];const a=o>i?Math.round(50*(r-o)/(o-i)):50,s=hC([o,r],null,Math.min(Math.max(a,2),50)+1);return Array.from(new Set([...s,...e.filter(t=>t>o)])).sort((t,e)=>t-e)}function dC(t,e,n,i=[]){const o=cC(t._trendLine);if(!o||!e.length)return[];const r=t._trendLineConfig||{},a=lC(t.schema.discrete),s="x"===a?"y":"x",{toNumber:c,fromNumber:l}=function(t){const e=t.map(t=>`${t}`),n=t.some(t=>!(t instanceof Date)&&"number"!=typeof t),i=t.some(t=>t instanceof Date);return{toNumber:t=>{if(t instanceof Date)return+t;if(!n&&"number"==typeof t)return t;const i=e.indexOf(`${t}`);return i<0?NaN:i},fromNumber:e=>n?t[Math.round(e)]:i?new Date(e):e}}(n.concat(i)),u=function(t,e){return!t[`_${e}Time`]&&(t.schema.discrete===e&&!Qw(t,e)||!!t.schema[`${e}Sort`])}(t,a)?n.concat(i).map(c).filter(Number.isFinite):null,d=i.length?n.concat(i).map(c).filter(Number.isFinite):[],m="log"===`${t[`_${s}Config`]?.scale}`.toLowerCase(),p=t.schema.shapeConfig.fill,g=[];for(const[n,i,y,x]of function(t,e,n,i){const o="x"===n?"y":"x",r=t=>[i(t[n]),+t[o]];if(t.schema.stacked)return[["all",h.groups(e,t=>i(t[n])).map(([t,e])=>[t,e.reduce((t,e)=>t+(+e[o]||0),0)]),void 0,-1]];const a=[["all",e.map(r),void 0,-1]];if("all"===t._trendLineConfig?.group)return a;const s=n=>h.groups(e,e=>function(t,e,n){return t._ids(e.data,e.i).slice(0,n+1).join("_")}(t,e,n)).map(([t,e])=>[t,e.map(r),e[0],n]),c=t._drawDepth,l=s(c);return l.some(([,t])=>t.length>1)?l:c>0?s(c-1):a}(t,e,a,c)){const e=f.regression(i,o,{order:r.order});if(!e)continue;const c=r.confidence&&"linear"===o,h=r.confidenceLevel,b=c?f.linearConfidence(i,h):null,_=c?f.linearPrediction(i,h):null,k=[],v=(t,n)=>{const i=e.predict(t);if(!Number.isFinite(i)||m&&i<=0)return;const o={[a]:l(t),[s]:i},r=n?_:b;r&&([o.lci,o.hci]=r(t)),n&&(o.projected=!0),n&&t>e.extent[1]&&d.includes(t)&&(o.step=!0),k.push(o)};if(hC(e.extent,u).forEach(t=>v(t,!1)),uC(e.extent,d,u).forEach(t=>v(t,!0)),k.length<2)continue;const w=y?y.data:void 0,M=r.stroke?r.stroke:w?"function"==typeof p?p(w,y.i):p:"#444",S=w?t._drawLabel(w,y.i,x):t.schema.translate("Trend Line");g.push({id:n,label:S,color:M,axis:a,fit:e,samples:k,row:w})}return g}function fC(t){const e=[];for(const{axis:n,samples:i}of t){const t="x"===n?"y":"x";for(const n of i)e.push(n[t]),void 0!==n.lci&&e.push(n.lci,n.hci)}return e.filter(Number.isFinite)}const mC=({viz:t,plotFormattedData:e,xData:n,yData:i})=>{const o=lC(t.schema.discrete),r=("x"===o?n:i)||[],a=cC(t._trendLine)?aC(r,t._trendLineConfig?.projection):[],s=t._trendFits=t._swarm?[]:dC(t,e||[],r,a);if(!s.length)return{};const c=fC(s),l="x"===o?{yData:(i||[]).concat(c)}:{xData:(n||[]).concat(c)};return s.some(t=>t.samples.some(t=>t.projected))?{...l,[`${o}Data`]:r.concat(a)}:l};function pC(t,e){const{data:n,axisData:i,xData:o,yData:r,opp:a,stackGroup:s}=e;!function(t,e,n){const i=e.filter(t=>["Area","Bar"].includes(t.shape)),o=h.groups(i,t=>t.group).reduce((t,[e,i])=>(t[e]||(t[e]=0),t[e]+=h.sum(i,t=>t[n]),t),{});e.sort((e,i)=>{if(t.schema[`${t.schema.discrete}Sort`])return t.schema[`${t.schema.discrete}Sort`](e.data,i.data);const r=e[t.schema.discrete],a=i[t.schema.discrete];return r-a!==0?r-a:e.group!==i.group?o[i.group]-o[e.group]:i[n]-e[n]})}(t,i,a);const c=Array.from(new Set(i.map(t=>t.discrete))),l=Array.from(new Set(i.map(t=>t.id))),u=h.groups(i,t=>t.discrete).map(([,t])=>t);!1!==t._stackShares&&function(t,e){const n=t.filter(t=>["Area","Bar"].includes(t.shape)),i=new Map;for(const t of n)i.set(t.discrete,(i.get(t.discrete)||0)+Math.abs(+t[e]||0));for(const t of n){const n=i.get(t.discrete),o=n?Math.abs(+t[e]||0)/n:0;gl(t,o),t.data&&gl(t.data,o)}}(n,a),function(t,e){const{axisData:n,data:i,stackData:o,stackKeys:r,stackGroup:a,opp:s}=e;o.forEach(e=>{const o=Array.from(new Set(e.map(t=>t.id)));o.length<r.length&&r.forEach(r=>{if(!o.includes(r)){const o=n.filter(t=>t.id===r)[0],c=o.shape;if("Area"===c){const n=a(o.data,o.i),l={__d3plus__:!0,data:o.data,discrete:"Bar"===o.shape?`${e[0][t.schema.discrete]}_${n}`:`${e[0][t.schema.discrete]}`,group:n,id:o.id,ids:r,shape:c,[t.schema.discrete]:e[0][t.schema.discrete],[s]:0};i.push(l)}}})})}(t,{axisData:i,data:n,stackData:u,stackKeys:l,stackGroup:s,opp:a}),t.schema[`${t.schema.discrete}Sort`]?n.sort((e,n)=>t.schema[`${t.schema.discrete}Sort`](e.data,n.data)):n.sort((e,n)=>e[t.schema.discrete]-n[t.schema.discrete]);const d=new Set(i.filter(t=>t.data?._isAggregation).map(t=>t.id)),m=function(t,e,n,i,o){const r=t._stackOrder;Array.isArray(r)&&e.sort((t,e)=>r.indexOf(t)-r.indexOf(e));const a=Array.isArray(r)?R.stackOrderNone:r;return R.stack().keys(e).offset(t._stackOffset).order(o.size?function(t,e){return n=>{const i=t(n),o=t=>e.has(n[t].key);return i.filter(t=>!o(t)).concat(i.filter(o))}}(a,o):a).value((t,e)=>{const n=t.filter(t=>t.id===e);return n.length?n[0][i]:0})(n)}(t,l,u,a,d),p="x"===t.schema.discrete?o:r,g=fC(t._trendFits||[]);!t._confidence||"x"!==a&&"y"!==a||g.push(...function(t,e,n,i,o){const r=[];for(const a of t){if("Bar"!==a.shape)continue;const t=n[i.indexOf(a.id)],s=t&&t[o.indexOf(a.discrete)];if(!s)continue;const{lower:c,upper:l}=LS(a,e,s);f.finite(c)&&r.push(c),f.finite(l)&&r.push(l)}return r}(i,a,m,l,c));const y="x"===t.schema.discrete?t._xTime:t._yTime;return{plotInitialDomains:{[t.schema.discrete]:t._discreteExtent?tM(t,i):y?h.extent(p):p,[a]:[h.min([...m.map(t=>h.min(t.map(t=>t[0]))),...g]),h.max([...m.map(t=>h.max(t.map(t=>t[1]))),...g])]},plotDiscreteKeys:c,plotStackData:m,plotStackKeys:l,plotStackPositions:gC(t,i,m,l)}}function gC(t,e,n,i){const o=new Map;for(const n of e){const e=`${n.id}`;if(o.has(e)||!n.data)continue;const i=eC(t,n.data,n.i);i.length&&o.set(e,i[0])}return ZS(n,i,t=>o.get(t))}const yC=({viz:t,plotFormattedData:e,plotAxisData:n,xData:i,x2Data:o,yData:r,y2Data:a,plotStackGroup:s})=>{const c=e||[],l=n||[],u=s,d=t.schema.discrete?"x"===t.schema.discrete?"y":"x":void 0,f=t.schema.stacked?pC(t,{data:c,axisData:l,xData:i||[],yData:r||[],opp:d,stackGroup:u}):function(t,e){const{axisData:n,xData:i,x2Data:o,yData:r,y2Data:a}=e,s=t._xTime,c=t._x2Time,l=t._yTime,u=t._y2Time,d=t.schema.discrete||"x";return t.schema[`${t.schema.discrete}Sort`]?n.sort((e,n)=>t.schema[`${t.schema.discrete}Sort`](e.data,n.data)):n.sort((t,e)=>t[d]-e[d]),{plotInitialDomains:{x:Qw(t,"x")?tM(t,n):!s&&"x"===t.schema.discrete||t.schema.xSort||"x"===t._swarm?.cross?i:h.extent(i),x2:Qw(t,"x")?tM(t,n):!c&&"x"===t.schema.discrete||t.schema.x2Sort?o:h.extent(o),y:Qw(t,"y")?tM(t,n):!l&&"y"===t.schema.discrete||t.schema.ySort||"y"===t._swarm?.cross?r:h.extent(r),y2:Qw(t,"y")?tM(t,n):!u&&"y"===t.schema.discrete||t.schema.y2Sort?a:h.extent(a)},plotDiscreteKeys:[],plotStackData:[],plotStackKeys:[]}}(t,{axisData:l,xData:i||[],x2Data:o||[],yData:r||[],y2Data:a||[]}),m=t._plotFacetScales?.domains;return m&&f.plotInitialDomains&&(f.plotInitialDomains={...f.plotInitialDomains,...m}),f};function xC(t){return!!t._confidence&&!1!==t._confidenceConfig?.tooltip}function bC(t,e,n){const i={},o=t._confidence;if(!o||!e)return i;const[r,a]=o,s=r?r(e,n):void 0,c=a?a(e,n):void 0;return f.finite(s)&&(i.lower=s),f.finite(c)&&(i.upper=c),i}function _C(t,e,n,i){if(!xC(t))return[];if(aM(t).length>1)return kC(t,e,n,i);const{lower:o,upper:r}=bC(t,e,n),a=[];return f.finite(o)&&a.push([t.schema.translate("Lower Bound"),i(o)]),f.finite(r)&&a.push([t.schema.translate("Upper Bound"),i(r)]),a}function kC(t,e,n,i){return sM(t,e,n).map(({label:t,lower:e,upper:n})=>[t,wC(e,n,i)]).filter(([,t])=>t)}function vC(t,e,n){const i=wC(t,e,n);return i?` (${i})`:""}function wC(t,e,n){const i=f.finite(t),o=f.finite(e);return i&&o?`${n(t)} – ${n(e)}`:i?`≥ ${n(t)}`:o?`≤ ${n(e)}`:""}const MC=t=>"x"===t?"y":"x";function SC(t,e){const n=t[`_${e}Config`];if(n&&"string"==typeof n.title)return n.title;const i=t[`_${e}Key`];return"string"==typeof i?i:""}function CC(t,e,n){const i=t[`_${e}Config`];if(i&&"function"==typeof i.tickFormat)return i.tickFormat(n);const o=function(t,e,n){if(!t[`_${e}Time`])return;const i=ki(n);if(!i)return;const o=t[`_${e}Axis`];return o&&"time"===o.schema.scale?$i(o,i):d.formatDateFull(i,[i])}(t,e,n);if(void 0!==o)return o;if(Di(n)){const i=t[`_${e}Axis`];return i?$i(i,n):d.formatDateFull(n,[n])}if("number"==typeof n&&e!==t.schema.discrete){const i=t[`_${e}Axis`];return i&&ji(i)?Ii(n,t.schema.locale):d.formatAbbreviate(n,t.schema.locale)}return String(n)}function $C(t,e,n){const i=n.rows[0],o=t[`_${e}`],r=o&&!i.projected?o(i.datum,i.index):n.value;return[SC(t,e),CC(t,e,r)]}function AC(t,e,n){const i=n.nativeEvent,o=i&&i.touches&&i.touches.length?[i.touches[0].clientX,i.touches[0].clientY]:i?[i.clientX,i.clientY]:n.point,r=t._zoomTransform,a=t._chartTransform,s=e.axis,c=(e.px+(a?.[s]??0))*(r?.scale??1)+(r?.[s]??0),l="x"===s?0:1,h=[o[0],o[1]];return h[l]=o[l]-n.point[l]+c,h}function zC(t){const e=t._tooltipClass;t._sharedTooltipSaved||(t._sharedTooltipSaved={arrow:e.arrow(),thead:e.thead(),tbody:e.tbody()});const n=t._sharedTooltipSaved;return e.thead(n.thead).tbody(n.tbody).titleSwatch(!0)}function DC(t,e,n){const i=n=>CC(t,e,n),o=n.projected;return o?void 0===o.lci||void 0===o.hci?"":vC(o.lci,o.hci,i):function(t,e,n,i){if(!xC(t))return"";const{lower:o,upper:r}=bC(t,e,n);return vC(o,r,i)}(t,n.datum,n.index,i)}function LC(t,e,n){const i=MC(e.axis),{header:o,names:r}=function(t,e){const n=` (${t.schema.translate("Projected")})`,i=$C(t,e.axis,e),o=e.rows.every(t=>t.projected);return{header:o?[i[0],`${i[1]}${n}`]:i,names:e.rows.map(t=>t.projected&&!o?`${t.name}${n}`:t.name)}}(t,e);zC(t).data([e.rows[0].datum]).config(Qt.bind(t)(t.schema.tooltipConfig)).title(()=>SC(t,i)).thead(o).tbody(e.rows.flatMap((e,n)=>[[Dl(zl(e.color,e.shape),r[n]),`${CC(t,i,e.value)}${DC(t,i,e)}`],...Sl(t,e.datum,5)])).footer(!1).arrow(!1).position(AC(t,e,n)).render()}function FC(t,e,n,i){if(i(void 0===e?t:Dg(t,e))<=n)return void 0===e?{name:t}:{name:t,value:e};if(void 0!==e&&i(t)<=n)return{name:t};const o=e=>`${t.slice(0,e).trimEnd()}…`;let r=1,a=t.length-1,s=0;for(;r<=a;){const t=r+a>>1;i(o(t))<=n?(s=t,r=t+1):a=t-1}return s?{name:o(s)}:null}function NC(t,e=0){return Math.max(0,t-e)/4}function BC(t){let e,n=t;for(;n.__d3plus__&&n.data;)n=n.data,e=n.i;return{d:n,i:e}}function EC([t,e],n,i="end"){const{labelFunction:o,fontColorAccessor:a,fontSizeAccessor:s,fontWeightAccessor:c,fontFamilyAccessor:l,paddingAccessor:u,xEstimate:d,yEstimate:f}=n,m="end"===i,{d:p,i:g}=BC(e[m?e.length-1:0]),y="function"==typeof o?o(p,g):o,x="function"==typeof a?a(p,g):a,b="function"==typeof s?s(p,g):s,_="function"==typeof c?c(p,g):c;let k="function"==typeof l?l(p,g):l;Array.isArray(k)&&(k=k.map(t=>`'${t}'`).join(", "));const v="function"==typeof u?u(p,g):u,w=e.map(t=>[d(t.x),f(t.y)]),M=e.map(t=>d(t.x)),S=m?h.max(M):h.min(M),C=e.find(t=>d(t.x)===S),$=C.y;let A=n.valueText($,C);const z={"font-size":b,"font-family":k,"font-weight":_};let D,L=r.textWidth(void 0===A?y:Dg(y,A),z);if(void 0!==n.maxSpace&&L+4*v>n.maxSpace){const t=FC(`${y}`,A,n.maxSpace-4*v,t=>r.textWidth(t,z));if(!t)return null;D=t.name,A=t.value,L=r.textWidth(void 0===A?D:Dg(D,A),z)}return{id:t,side:i,name:D,valueText:A,labelWidth:L+2*v,spaceNeeded:L+4*v,value:$,yEstimate:f($),padding:v,fontSize:b,fontColor:x,edgeX:S,xValue:C.x,coords:w}}function RC(t,e){const{fontSize:n,id:i,labelWidth:o,edgeX:r,side:a,yEstimate:s}=t,c="start"===a?-1:1;return 0!==e.filter(t=>t.id!==i&&t.coords.some(e=>((e[0]-r)*c>0||e[0]===r&&t.edgeX!==r)&&(r+o*c-e[0])*c>=0&&e[1]<=s+.75*n&&e[1]>=s-.75*n)).length}function PC(t,e,n){const i=Hm(t,"Line");e.config(i);const o=e.labelConfig(),r=void 0!==o.fontColor?o.fontColor:n.fontColor(),a=void 0!==o.fontSize?o.fontSize:n.fontSize(),s=void 0!==o.fontWeight?o.fontWeight:n.fontWeight(),c=void 0!==o.fontFamily?o.fontFamily:n.fontFamily(),l=void 0!==o.padding?o.padding:n.padding();return{labelFunction:i.label||t._drawLabel,fontColorAccessor:r,fontSizeAccessor:a,fontWeightAccessor:s,fontFamilyAccessor:c,paddingAccessor:l}}function TC(t,e,n){return i=>("log"===e&&0===i&&(i=t._givenDomain()[n[0]<0?1:0]),t._getPosition.bind(t)(i))}function OC(t,e,n,i){return t.map(t=>EC(t,e,n)).filter(t=>null!==t).sort((t,e)=>i[1]>i[0]?t.value-e.value:e.value-t.value).filter((t,e,n)=>!RC(t,n))}function WC(t,e,n){const i=h.max(t.filter(t=>t.edgeX===e),t=>t.spaceNeeded);return i?h.min([i,n]):0}const HC=({viz:t,plotFormattedData:e,plotScales:n,plotConfigScales:i,plotTestAxes:o,plotLineLabelTest:r,y2Exists:a})=>{const s=e||[],c=t.schema.lineLabels;if(!c||a)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0,plotStartLabelSpace:0};const l=t=>Ag(c,t.data,t.i),u=s.filter(t=>"Line"===t.shape&&l(t).length>0),d=h.groups(u,t=>t.id);if(!d.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0,plotStartLabelSpace:0};const{testLineShape:f,testTextBox:m}=r,{xTest:p,yTest:g}=o,y=n.x.domain(),x=n.y.domain(),b=i.xConfigScale,_=i.yConfigScale,k=t.schema.width-t._margin.left-t._margin.right,v=t.schema.lineLabelConfig,w={...PC(t,f,m),xEstimate:TC(p,b,y),yEstimate:TC(g,_,x),valueText:(e,n)=>{const{d:i,i:o}=BC(n);return zg(v,e,i,o,e=>CC(t,"y",e))}},M=t=>d.filter(([,e])=>{const n="end"===t?e[e.length-1]:e[0];return l(n).includes(t)}),[S,C]=[M("start"),M("end")],$=g.outerBounds(),A=NC(k,$.width?$.width+g.padding():0),z={...w,maxSpace:A},D=OC(S,z,"start",x),L=OC(C,z,"end",x),[F,N]=p._getRange.bind(p)(),B=WC(L,h.max(L,t=>t.edgeX),A),E=WC(D,h.min(D,t=>t.edgeX),A);return{plotLabelWidths:[...D,...L],plotLargestLabel:h.max(L.map(t=>t.labelWidth)),plotXRangeMax:B&&h.max(L,t=>t.edgeX)===N?k-B:void 0,plotStartLabelSpace:E&&h.min(D,t=>t.edgeX)===F?E:0}};function jC(t,e){const n=()=>Ws(t);return r.assign({barConfig:{stroke:n},baselineBreakConfig:{stroke:n},breakConfig:{stroke:n},shapeConfig:{fill:n,labelConfig:{fontColor:n},stroke:n},titleConfig:{fontColor:n}},e)}function IC(t){return mg(t,"x")||t._discreteExtent&&"x"===t.schema.discrete?"none":"outside"}function GC(t,e){const{xData:n,xScalePadding:i}=e;return jC(t,{data:n,locale:t.schema.locale,rounding:gg(t,"x",IC(t)),scalePadding:i,...vg(t,"x")})}const qC=({viz:t,plotAxisData:e,plotScales:i,x2Exists:o,y2Exists:r,x2Data:a,y2Data:s,yData:c})=>{const l=e||[],{x:h,y:u,x2:d,y2:f,xScale:m,yScale:p,x2Scale:g,y2Scale:y}=i,x=h.domain(),b=d.domain(),_=u.domain(),k=f.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},w=mg(t,"y")||Qw(t,"y")?"none":"outside",M={...o?{data:a}:v,...rg(t,"x2"),baselineBreak:!1,rounding:yg(t,"x2",IC(t))},S={...r?{data:s}:v,...rg(t,"y2"),baselineBreak:!1,rounding:yg(t,"y2",w)},{showX:C,showY:$}=function(t){return{showX:"x"===t.schema.discrete?t.schema.width>t._discreteCutoff&&t.schema.width>t.schema.xCutoff:t.schema.width>t.schema.xCutoff&&!wM(t,"x"),showY:"y"===t.schema.discrete?t.schema.height>t._discreteCutoff&&t.schema.height>t.schema.yCutoff:t.schema.height>t.schema.yCutoff&&!wM(t,"y")}}(t),A=function(t,e,n,i,o){const r={data:n,locale:t.schema.locale,rounding:gg(t,"y",i),scalePadding:e.padding?e.padding():0,scaleAlign:e.align?e.align():.5,...vg(t,"y")};return o.showX||!o.showY||t._swarm||(r.barConfig={stroke:"transparent"},r.tickSize=0,r.shapeConfig={labelBounds:(e,n)=>{const{width:i,y:o}=e.labelBounds,r=t.schema.height/2;return{x:n?-r:0,y:o,width:i,height:r}},labelConfig:{padding:0,rotate:0},labelRotation:!1}),r}(t,u,c,w,{showX:C,showY:$}),z=function(t,e){const n=Hm(t,"Bar"),i=void 0!==n.label?"function"==typeof n.label?n.label:()=>n.label:t._drawLabel,o=[],r=[];for(const t of e){if("Box"===t.shape)continue;const e=i(t.data,t.i);("number"==typeof e||e)&&(o.push(String(e)),r.push(t))}return{labels:o,rows:r}}(t,l),D=z.labels;let L;const F=(e,i)=>{if(Qw(t,e))return function(t,e){const n=new Set;return e.filter(t=>t.data).forEach(e=>Jw(t,e).forEach(t=>n.add(t))),Array.from(n).sort((t,e)=>t-e)}(t,l);if("Point"!==i)return null;return n.unique(l.map(t=>t[e])).every(t=>D.includes(`${t}`))?("x"!==e&&"y"!==e||e===t.schema.discrete&&("x"===e?C:$)&&(L={axis:e,...z}),[]):null},N=F("x",m),B=F("x2",g),E=F("y",p),R=F("y2",y);return{plotDefaultConfig:v,plotDefaultX2Config:jC(t,M),plotDefaultY2Config:jC(t,S),plotShowX:C,plotShowY:$,plotYC:jC(t,A),plotBarLabels:D,plotBarLabelCheck:L,plotXTicks:N,plotX2Ticks:B,plotYTicks:E,plotY2Ticks:R,plotXDomain:x,plotX2Domain:b,plotYDomain:_,plotY2Domain:k}},VC=t=>null===t||"number"==typeof t&&!Number.isFinite(t)||Array.isArray(t)&&0===t.length,YC=t=>!(VC(t.x)||VC(t.y)||void 0!==t.x2&&VC(t.x2)||void 0!==t.y2&&VC(t.y2));function KC(t,e,n){const i="y"===t.schema.discrete?"y":"x";return e.filter(e=>"Line"===e.shape&&!YC(e)&&void 0!==e[i]&&!VC(e[i])&&(!n||n.has(e[t.schema.discrete])))}function UC(t,e){const n=h.extent(e),{sizeMax:i,sizeMin:o,sizeScale:r,sizeZero:a}=t.schema,s=wS[`scale${r.charAt(0).toUpperCase()}${r.slice(1)}`],c=a?XC(s,n,i):NaN;return s().domain(n).range([n[0]===n[1]?i:Number.isFinite(c)?c:h.min([i/2,o]),i])}function XC(t,[e,n],i){if(!(e>=0&&n>0))return NaN;const o=t().domain([0,n]).range([0,i])(e);return Number.isFinite(o)?o:NaN}const ZC=(t,e)=>(t._plotCircleShapes??["Circle"]).includes(e);function QC(t,e){const{xTime:n,x2Time:i,yTime:o,y2Time:a}=e,s=n||i||o||a,c=(e,n)=>`${!s&&t.schema.time?t.schema.time(e,n):"time"}_${t.schema.stacked?((e,n)=>t._stackGroup?t._stackGroup(e,n):t.schema.groupBy.length>1?t._ids(e,n).slice(0,-1).join("_"):"group")(e,n):`${t._ids(e,n).join("_")}`}`;return{prepData:(e,s)=>{const l={__d3plus__:!0,data:e,group:c(e,s),i:s,hci:t._confidence&&t._confidence[1]&&t._confidence[1](e,s),id:t._ids(e,s).slice(0,t._drawDepth+1).join("_"),lci:t._confidence&&t._confidence[0]&&t._confidence[0](e,s),shape:t.schema.shape(e,s),x:n?r.date(t._x(e,s)):t._x(e,s),x2:i?r.date(t._x2(e,s)):t._x2(e,s),y:o?r.date(t._y(e,s)):t._y(e,s),y2:a?r.date(t._y2(e,s)):t._y2(e,s)};return l.discrete="Bar"===l.shape?`${l[t.schema.discrete]}_${l.group}`:`${l[t.schema.discrete]}`,l.id="Bar"===l.shape?`${l.id}_${l[t.schema.discrete]}`:l.id,l},stackGroup:c}}const JC=({viz:t})=>{if(!t._filteredData||!t._filteredData.length)return t._sizeLegendFinal=null,t._swarm=null,{plotFormattedData:[],plotAxisData:[],plotMissingRows:[],x2Exists:!1,y2Exists:!1};const{prepData:e,stackGroup:n}=QC(t,function(t){const e=t._filteredData[0],n=!!t.schema.time&&t.schema.time(e,0),i=i=>{const o=t[`_${i}`](e,0);return Boolean(n&&o===n)||am(t,i,o)},o=t._x2Time=i("x2"),r=t._xTime=i("x"),a=t._y2Time=i("y2");return{xTime:r,x2Time:o,yTime:t._yTime=i("y"),y2Time:a}}(t)),i=function(t){const e=t.schema.discrete;if(!e||Qw(t,e))return null;if("x"===e?t._xTime:t._yTime)return null;const n=("x"===e?t._xConfig:t._yConfig)?.domain,i=Array.isArray(n)?n:t.schema[`${e}Domain`];return Array.isArray(i)&&i.length?new h.InternSet(i):null}(t),o=e=>YC(e)&&(!i||i.has(e[t.schema.discrete])),r=t._filteredData.map(e),a=lm(t,r.filter(o)),[s,c]=Jp(t,a,t._axisPersist?lm(t,t._data.map(e).filter(o)):a);t._formattedData=s;const l=t._swarm=kM(t.schema.swarm,c);l&&(vM(s,l),c!==s&&vM(c,l)),function(t,e){t._sizeScaleD3=t._size?t._plotFacetScales?.size??UC(t,e.map(e=>t._size(e.data))):()=>t.schema.sizeMin,t._sizeLegendFinal=t._size&&e.some(e=>ZC(t,e.shape))?t._sizeScaleD3:null}(t,c);const u=og(t),d="x2"===u||c.some(t=>void 0!==t.x2),f="y2"===u||c.some(t=>void 0!==t.y2);return{plotFormattedData:s,plotAxisData:c,x2Exists:d,y2Exists:f,plotStackGroup:n,plotMissingRows:KC(t,r,i)}},t$=({viz:t,plotFormattedData:e,plotAxisData:i})=>{const o=e||[],a=i||[];function s(e){const i=t[`_${e}Time`],s=i?o:a,c=t._plotAxisRows?t._plotAxisRows(s,e):s,l=c.filter(t=>![NaN,void 0,!1].includes(t[e])),u=t._plotAxisValues?t._plotAxisValues(c,e):[];if(!l.length)return u;const d="number"==typeof l[0][e];let f=t.schema.discrete===e?h.rollups(l,e=>1===e.length?e[0].data:n.merge(e.map(t=>t.data),t.schema.aggs),t=>t[e]).sort((n,o)=>{if(t.schema[`${e}Sort`])return t.schema[`${e}Sort`](n[1],o[1]);return(i||d?parseFloat(n[0]):n[0])-(i||d?parseFloat(o[0]):o[0])}).map(([t])=>i?r.date(t):d?parseFloat(t):t):Zw(l,e,t.schema[`${e}Sort`]?(n,i)=>t.schema[`${e}Sort`](n.data,i.data):void 0);return t.schema.discrete!==e.charAt(0)&&t._confidence&&(t._confidence[0]&&(f=f.concat(c.map(t=>t.lci))),t._confidence[1]&&(f=f.concat(c.map(t=>t.hci))),f=f.concat(uM(t,c))),u.length?f.concat(u):f}return{xData:s("x"),x2Data:s("x2"),yData:s("y"),y2Data:s("y2")}},e$=({viz:t,plotFormattedData:e,plotAxisData:n,plotScales:i,plotConfigScales:o})=>{const r=e||[],a=n||[];let{x:s,y:c,x2:l,y2:u}=i;const{xConfigScale:d,yConfigScale:f,x2ConfigScale:m,y2ConfigScale:p}=o,g=i.xScale,y=i.yScale;if("Point"!==("x"===t.schema.discrete||"y"===t._swarm?.axis?y:g)){h.groups(a,t=>t.shape).forEach(([e,n])=>{if(["Bar","Box"].includes(e)&&!t._discreteExtent&&kw("x"===t.schema.discrete?s:c,r,t.schema.discrete),t._buffer[e]){const i=t._buffer[e].bind(t)({data:n,x:s,y:c,yScale:f,xScale:d,config:t.schema.shapeConfig[e]});s=i[0],c=i[1];const o=t._buffer[e].bind(t)({data:n,x:l,y:u,yScale:p,xScale:m,x2:!0,y2:!0,config:t.schema.shapeConfig[e]});l=o[0],u=o[1]}})}return{plotScales:CM(t,{...i,x:s,y:c,x2:l,y2:u})}},n$={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:H("Circle"),tooltipShared:!0,trendLine:!1}};function i$(t){return this._sizeScaleD3(this._size?this._size(t):null)}function o$(t,e,n,i){const o=("y"===e?t._y:t._x)(n,i),r="y"===e?t._yAxis:t._xAxis;return o<0!==Boolean(r?.schema?.reverse)}function r$(t,e){if(this.schema.stacked)return!1;const n=this.schema.labelPosition(t,e);if("outside"===n)return!0;if("inside"===n)return!1;const i="x"===this.schema.discrete.charAt(0)?"y":"x",o=this.schema.discrete.replace(this.schema.discrete.charAt(0),i),r="y"===o?this._yAxis:this._xAxis,a="y"===o?this._y:this._x,s=r._d3Scale.range(),c=a(t,e),l=o$(this,o,t,e),h=r._getPosition(0),u="y"===o?l?s[1]-h:h-s[0]:l?h-s[0]:s[1]-h,d=r._getPosition(c);return Math.abs(l?h-d:d-h)<u/2}function a$(t){return{label:(e,n)=>!!t.schema.stacked&&t._drawLabel(e,n),labelBounds:(e,n,i)=>{const o=Mg(t,i.points);let r=f.largestRect(o,{angle:h.range(-20,20,5)});if((!r||r.height<20||r.width<50)&&(r=f.largestRect(o,{angle:h.range(-80,80,5)})),!r)return null;const a=h.min(i.points,t=>t[0]),s=h.max(i.points.filter(t=>t[0]===a),t=>t[1]);return{angle:r.angle,width:r.width,height:r.height,x:r.cx-r.width/2-a,y:r.cy-r.height/2-s}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}function s$(t){const e=(e,n)=>Di(n)?CC(t,e,n):n;return(n,i)=>{let o;return n.nested?o=`${t._drawLabel(n.data,n.i)}`:(o=`${t._drawLabel(n,i)}`,void 0!==t._x(n,i)&&(o+=`, x: ${e("x",t._x(n,i))}`),void 0!==t._y(n,i)&&(o+=`, y: ${e("y",t._y(n,i))}`),void 0!==t._x2(n,i)&&(o+=`, x2: ${e("x",t._x2(n,i))}`),void 0!==t._y2(n,i)&&(o+=`, y2: ${e("y",t._y2(n,i))}`)),`${o}.`}}function c$(t){return{curve:()=>t.schema.discrete?`monotone${t.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:H("none"),labelConfig:{fontColor:(e,n)=>{const i="function"==typeof t.schema.shapeConfig.Line.stroke?t.schema.shapeConfig.Line.stroke(e,n):t.schema.shapeConfig.Line.stroke;return null==i?J(t._theme,t=>t.text,"rgb(0, 0, 0)"):po(i,Boolean(t._theme?.dark))},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:H(2)}}function l$(){return{Area:a$(this),ariaLabel:s$(this),Bar:{labelBounds(t,e,n){const i="y"===this.schema.discrete?"width":"height",o="y"===this.schema.discrete?"height":"width",r="x"===this.schema.discrete.charAt(0)?"y":"x",a="y"===r,s=this.schema.discrete.replace(this.schema.discrete.charAt(0),r),c=("y"===s?this._yAxis:this._xAxis)._d3Scale.range(),l=Math.abs(c[1]-c[0]),h=o$(this,s,t,e);return r$.bind(this)(t,e)?{[i]:l-n[i],[o]:n[o],x:a?-n.width/2:h?-l:n.width+1,y:a?h?n.height+1:-l:-n.height/2+1}:{[i]:n[i],[o]:n[o],x:a?-n.width/2:h?(this.schema.stacked,1-n.width):-1,y:a?h?(this.schema.stacked,1):1-n.height:-n.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(t,n){if(r$.bind(this)(t,n)){const t="transparent"===this._backgroundConfig.fill?Os(this):this._backgroundConfig.fill;return e.colorContrast(t,this.schema.colorDefaults)}return e.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(t,n):this.schema.shapeConfig.fill,this.schema.colorDefaults)},fontStroke(t,n){if(r$.bind(this)(t,n)){const t="transparent"===this._backgroundConfig.fill?Os(this):this._backgroundConfig.fill;return e.colorContrast(t,this.schema.colorDefaults)}return"transparent"},fontStrokeWidth(t,e){return r$.bind(this)(t,e)?.1:0},padding:3,textAnchor(t,e){const n="x"===this.schema.discrete.charAt(0)?"y":"x",i="y"===n,o=o$(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),n),t,e),a=i?"middle":r$.bind(this)(t,e)?o?"end":"start":o?"start":"end";return r.rtl()?"start"===a?"end":"end"===a?"start":a:a},verticalAlign(t,e){const n="x"===this.schema.discrete.charAt(0)?"y":"x",i="y"===n,o=o$(this,this.schema.discrete.replace(this.schema.discrete.charAt(0),n),t,e);return i?r$.bind(this)(t,e)?o?"top":"bottom":o?"bottom":"top":"middle"}}},Circle:{r:i$.bind(this),trail:!0},Line:c$(this),Rect:{height:t=>2*i$.bind(this)(t),width:t=>2*i$.bind(this)(t),trail:!0}}}const h$=[{key:"axisHover",coerce:"identity",default:!0},{key:"axisHoverConfig",merge:!0,factory:function(){return{guideConfig:{strokeDasharray:"4 3",strokeWidth:1},badgeConfig:{fontSize:12,fontWeight:400,padding:4,rx:2}}}},{key:"barPadding",coerce:"identity"},{key:"connectGaps",coerce:"identity",default:!0},{key:"baselineBreak",coerce:"identity"},{key:"fillBetween",coerce:"identity",default:!1},{key:"fillBetweenConfig",merge:!0,factory:Bw},{key:"forecast",coerce:"identity"},{key:"forecastConfig",merge:!0,factory:Iw},{key:"lineLabels",coerce:"identity"},{key:"lineLabelConfig",merge:!0,factory:()=>({value:!1})},{key:"referenceBands",coerce:"identity",factory:()=>[]},{key:"referenceLines",coerce:"identity",factory:()=>[]},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"sizeZero",coerce:"identity",default:!1},{key:"stacked",coerce:"identity"},{key:"swarm",coerce:"identity",default:"auto"},{key:"swarmConfig",merge:!0,factory:()=>({padding:1,overflow:"shrink"})},{key:"tooltipShared",coerce:"identity"},{key:"xBreak",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yBreak",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}];function u$(t){const n=n$.defaults;t._axisPersist=n.axisPersist,t._annotations=n.annotations,t._backgroundConfig={duration:0,fill:"transparent"},t.schema.barPadding=n.barPadding,t._buffer=r.assign({},Mw,{Bar:!1,Line:!1}),t._confidence=!1,t._confidenceConfig={fill:(e,n)=>{const{Line:i,stroke:o}=t.schema.shapeConfig,r=i&&void 0!==i.stroke?i.stroke:o;return"function"==typeof r?r(e,n):r},fillOpacity:H(.5)},t._crosshairConfig={stroke:()=>J(t._theme,t=>t.textMuted,e.colorGray[500]),strokeDasharray:"4 3",strokeWidth:1},t._discreteCutoff=n.discreteCutoff,t._groupPadding=n.groupPadding,t._labelConnectorConfig={strokeDasharray:"1 1"},t._lineMarkerConfig={fill:(n,i)=>e.colorAssign(t._id(n,i),Re(t)),r:H(3)},t._lineMarkers=n.lineMarkers,t._previousAnnotations={back:[],front:[]},t._previousShapes=[],t.schema.shape=n.shape,t.schema.shapeConfig=r.assign(t.schema.shapeConfig,l$.call(t)),t._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],t.schema.shapeSort=(e,n)=>t._shapeOrder.indexOf(e)-t._shapeOrder.indexOf(n),t.schema.tooltipShared=n.tooltipShared,t.schema.sizeMax=20,t.schema.sizeMin=5,t.schema.sizeScale="sqrt",t._stackOffset=YS,t._stackOrder=WS,t.schema.legendSort=iC(t,t.schema.legendSort),t.schema.threshold=H(0),t._thresholdMemberFormat=e=>CC(t,"y"===t.schema.discrete?"x":"y",e),t.schema.timelineConfig=r.assign(t.schema.timelineConfig,{brushMin:()=>t._xTime||t._yTime||t._x2Time||t._y2Time?2:1})}const d$=["ellipsis","fontFamily","fontMax","fontMin","fontResize","fontSize","fontWeight","lineHeight","maxLines","overflow","padding","split"];function f$(t,e,n,i){if(!t.length)return!0;const o=function(t,e){const n=new Ir;for(const i of d$){const o=t[i];if(void 0!==o)if("split"===i||"function"!=typeof o)n[i](o);else{const t=o;n[i]((n,i)=>t(e[i].data,e[i].i))}}return n}(i,e);return t.every((t,e)=>{const i=Fr(o,{text:t,width:n.width,height:n.height},e);return!!i&&!i.truncated&&""!==i.lines.join("")})}function m$(t,e,n,i,o){const r="y"===t.schema.discrete?"y":"x",a=new Map;for(const t of e){const e=String(t[r]);a.set(e,(a.get(e)??0)+1)}const s=t.schema.stacked?1:h.max(Array.from(a.values()))??1,c=function(t,e,n,i,o){const r="x"===t?e.width:e.height,a=("x"===t?e.height:e.width)/2;let s=r/Math.max(1,n);return o.group<s&&(s-=o.group),i>1&&(s=(s-o.bar*i-1)/i),s=Math.max(0,s),"x"===t?{width:s,height:a}:{width:a,height:s}}(r,i,a.size,s,{group:t._groupPadding??0,bar:t.schema.barPadding??0});return f$(n,e,c,o)}function p$(t,e,n){const i=Hm(t,"Bar").labelConfig||{};return!m$(t,e.rows,e.labels,n,i)}function g$(t,e,n){const{xTest:i,x2Test:o,showX:r,x2Exists:a,width:s}=t,c=t.xRangeMax||void 0;r&&i.range([e,c]).measure(),a&&o.range([e,c]).measure();const l=i._getRange()[1],u=o._getRange()[1];return h.max([0,n,s-l,s-u])}function y$(t,e,n){const{yDomain:i,y2Domain:o,yConfigScale:r,y2ConfigScale:a}=e,{defaultY2Config:s,showY:c,y2Exists:l,yC:u}=e,{yTicks:d,x2TestRange:f,xTestRange:m,height:p,width:g}=e,{yTest:y,y2Test:x}=e;let{xOffsetRight:b}=e;c&&y.domain(i).height(p).maxSize(g/2).range(n).ticks(d).width(g).config(u).config(kg(t,"y")).scale(r).measure();const _=y.outerBounds(),k=_.width?_.width+y.padding():void 0,{startLabelSpace:v}=e,w=h.max([0,k,m[0],f[0],t._plotMinLeft?.(),v&&(k??0)+v]);l&&x.config(u).domain(o).gridSize(0).height(p).range(n).width(g-h.max([0,b-e.y2Width])).title(!1).config(t._y2Config).config(s).scale(a).measure();const M=x.outerBounds(),S=M.width?M.width+x.padding():void 0;return b=g$(e,w,S),{yBounds:_,yWidth:k,y2Bounds:M,y2Width:S,xOffsetLeft:w,xOffsetRight:b}}function x$(t,e){const{xTest:n,showX:i,xLabelMode:o}=t;if(i&&(!o||"axis"===o))return n.range(e).measure(),n.outerBounds().height+n.padding()}function b$(t,e,n){const{x2Height:i,topOffset:o,height:r,horizontalMargin:a,verticalMargin:s}=e,c=(e,a=0)=>{const c=r-(e+o+s),l=n?.insetBottom??Math.max(0,t._plotInsetBottom?.(c-i)??0)+a;return{yBottom:c,insetBottom:l,yRange:[i,c-l]}};let l=c(e.xHeight),h=n||y$(t,e,l.yRange);for(let i=0;!n&&i<3;i++){const n=x$(e,[h.xOffsetLeft,e.width-(h.xOffsetRight+a)]);if(void 0===n||n===e.xHeight)break;t._padding.bottom+=n-e.xHeight,e={...e,xHeight:n},l=c(n),h=y$(t,e,l.yRange)}const u=n?0:function(t,e){const n=[t.yTest,...t.y2Exists?[t.y2Test]:[]],i=Math.max(0,...n.map(t=>t._labelOverflow?.[1]??0));return Math.max(0,Math.ceil(i-(t.xHeight+e)))}(e,l.insetBottom);return u&&(l=c(e.xHeight,u),h=y$(t,e,l.yRange)),{pCtx:e,...l,solved:h}}const _$={labels:[]},k$=(t,e,n)=>"function"==typeof t?t(e,n):t;function v$(t,e,n){const i=!(n||wM(t,"y")&&t.schema.height>t.schema.yCutoff);return e&&i&&void 0===t._xConfig?.labels}function w$(t){const e=t._getDomain();if(!e.length)return[];const n="time"===t.schema.scale,[i,o]=[e[0],e[e.length-1]].map(t=>n?+t:t);return i===o||i instanceof Date&&o instanceof Date&&+i===+o?[i]:[i,o]}function M$(t){const e=t.schema.shapeConfig,n=e.labelConfig||{},i=t._labelFormat||(t=>`${t}`);let o=0,a=0;const c=w$(t).map((t,c)=>{const l=k$(n.fontSize??12,t,c),h=e.lineHeight?e.lineHeight(t,c):1.4*l,u=`${i(t)??""}`,d=s.textWrap().fontFamily(r.fontExists(k$(n.fontFamily??s.fontFamily,t,c))).fontSize(l).fontWeight(k$(n.fontWeight??400,t,c)).lineHeight(h).width(Number.MAX_SAFE_INTEGER).height(h)(u),f=d.lines.filter(t=>""!==t);return o=Math.max(o,Math.ceil(f.length*h)),a=Math.max(a,k$(n.padding??0,t,c)),{value:t,text:u,width:f.length?Math.ceil(Math.max(...d.widths)):0}});return{labels:c,padding:a,height:o}}function S$(t,e){const n=t.height?t.padding+t.height:0;return e-n>=n?n:0}function C$(t,e,n,i){const o=Math.max(0,n-i);if(t+e<=o)return[o-e,o-t];const r=o/2;return t<=r?[t,o-t]:e<=r?[o-e,e]:[r,r]}function $$(t,e,n,i=!1){const{labels:o,padding:r,height:a}=t;if(!o.length||!a)return[];const[s,c]=[e[0],e[e.length-1]],l=n+r;if(1===o.length){const[{value:t,text:e}]=o;return[{value:t,text:e,x:s,y:l,width:c-s,height:a,textAnchor:"middle"}]}const[h,u]=o,d=C$(h.width,u.width,c-s,r);return[{value:h.value,text:h.text,x:s,y:l,width:d[0],height:a,textAnchor:i?"end":"start"},{value:u.value,text:u.text,x:c-d[1],y:l,width:d[1],height:a,textAnchor:i?"start":"end"}]}function A$(t,e,n){return $$(M$(t),e,n,r.rtl())}function z$(t,e){t.measure();const n=t._outerBounds.y+t._margin.top;t.height(t.height()+e-n)}function D$(t,e){if(!e.length)return null;const n=t.schema.shapeConfig.labelConfig||{},i=(new Ir).renderMode("compute").config(n).config({fontResize:!1,padding:0,rotate:0,textAnchor:t=>t.textAnchor,verticalAlign:"top"}).data(e.map((t,n)=>({...t,id:1===e.length?"middle":n?"end":"start",i:n,data:{id:t.value,text:t.text}}))),{children:o}=i.toScene();return o.length?{type:"group",key:"plot-x-end-labels",children:o}:null}function L$(t,e,n,i,o,r,a){const{xTest:s,x2Test:c,yTest:l,showX:u,showY:d,x2Exists:f,height:m,width:p}=e,{labelWidths:g,largestLabel:y,xRangeMax:x,startLabelSpace:b=0}=function(t,e,n,i,o){const{xTest:r,x2Test:a,xDomain:s,x2Domain:c,xTicks:l,x2Ticks:h,xConfigScale:u,x2ConfigScale:d,defaultX2Config:f,showX:m,x2Exists:p,height:g,width:y}=e;let x;const b=o?_$:{};m&&r.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(kg(t,"x")).config(b).scale(u).measure();const{labelWidths:_,largestLabel:k,xRangeMax:v,startLabelSpace:w=0}=i();return void 0!==v&&(x=v),m&&x&&r.domain(s).height(g).maxSize(g/2).range([void 0,x]).ticks(l).width(y).config(n).config(kg(t,"x")).config(b).scale(u).measure(),p&&a.domain(c).height(g).range([void 0,x]).ticks(h).width(y).config(n).tickSize(0).config(f).config(t._x2Config).scale(d).measure(),{labelWidths:_,largestLabel:k,xRangeMax:x,startLabelSpace:w}}(t,e,n,r,a),_=s._getRange(),k=c._getRange(),v=c.outerBounds(),w=f?v.height+c.padding():0,M=h.max([0,i,_[0],k[0],t._plotMinLeft?.(),b&&(i??0)+b]),S=l.shapeConfig().labelConfig,C=(d?S.fontSize()/2:0)+(t._plotInsetTop??0),$=g$({xTest:s,x2Test:c,showX:u,x2Exists:f,xRangeMax:x,width:p},M,o),A=s.outerBounds(),z=a?S$(M$(s),m-w):0;return{xRangeMax:x,labelWidths:g,largestLabel:y,startLabelSpace:b,xTestRange:_,x2TestRange:k,x2Height:w,xOffsetLeft:M,xOffsetRight:$,topOffset:C,xHeight:a?z:A.height+(d||u?s.padding():0),xLabelMode:a?z?"ends":"none":"axis"}}function F$(t,e,n){let i=e;const o=i.barLabelCheck,r="y"===o?.axis&&p$(t,o,N$(t,i,0,function(t,e){if(!e.showX)return 0;const n=(new Do).align("end").gridSize(0);return n.domain(e.xDomain).height(e.height).maxSize(e.height/2).range([void 0,void 0]).ticks(e.xTicks).width(e.width).config(GC(t,e)).config(kg(t,"x")).scale(e.xConfigScale).measure(),n.outerBounds().height+n.padding()}(t,i)+function(t,e){const{yTest:n,yC:i,showY:o}=e;o&&n.config(i).config(kg(t,"y"));const r=n.shapeConfig().labelConfig;return(o?r.fontSize()/2:0)+(t._plotInsetTop??0)}(t,i)));r&&(i={...i,yTicks:null});const{yBounds:a,yWidth:s,y2Bounds:c,y2Width:l}=function(t,e){const{yTest:n,y2Test:i,yDomain:o,y2Domain:r,yTicks:a,y2Ticks:s,yConfigScale:c,y2ConfigScale:l,defaultY2Config:h,yC:u,showY:d,y2Exists:f,height:m,width:p}=e;d&&n.domain(o).height(m).maxSize(p/2).range([void 0,void 0]).ticks(a).width(p).config(u).config(kg(t,"y")).scale(c).measure();const g=n.outerBounds(),y=g.width?g.width+n.padding():void 0;f&&i.domain(r).height(m).range([void 0,void 0]).ticks(s).width(p).config(u).config(h).config(t._y2Config).scale(l).measure();const x=i.outerBounds();return{yBounds:g,yWidth:y,y2Bounds:x,y2Width:x.width?x.width+i.padding():void 0}}(t,i),h="x"===o?.axis&&p$(t,o,N$(t,i,(s??0)+(l??0),0));h&&(i={...i,xTicks:null});const u=v$(t,i.showX,i.showY),d=GC(t,i),f=L$(t,i,d,s,l,n,u);return t._padding.left+=f.xOffsetLeft,t._padding.right+=f.xOffsetRight,t._padding.bottom+=f.xHeight,t._padding.top+=f.x2Height+f.topOffset,{yBounds:a,y2Bounds:c,yWidth:s,y2Width:l,xC:d,...f,barLabelsOnAxis:r||h,xTicks:i.xTicks,yTicks:i.yTicks}}function N$(t,e,n,i){const o="panel"===t._facetStep?0:ap(t);return{width:e.width-n,height:e.height-i-o}}const B$=new rs,E$=new Ir,R$=(t,e)=>cx.prototype._draw.call(t,e);function P$(t,e){if(t._axisHoverState=null,"chrome"===t._facetStep||!t._filteredData.length&&!t._annotations?.length)return R$(t,e),t;const n={xTest:(new Do).align("end").gridSize(0),x2Test:(new No).align("start").gridSize(0),yTest:(new Lo).align("start").gridSize(0),y2Test:(new Lo).align("end").gridSize(0)},i=function(t){const e=_t({viz:t},[JC,t$,mC]);return{data:e.plotFormattedData,axisData:e.plotAxisData,x2Exists:e.x2Exists,y2Exists:e.y2Exists,xData:e.xData,x2Data:e.x2Data,yData:e.yData,y2Data:e.y2Data,stackGroup:e.plotStackGroup,missingRows:e.plotMissingRows??[]}}(t),{data:o,axisData:r,x2Exists:a,y2Exists:s,xData:c,x2Data:l,yData:u,y2Data:d}=i,f=t.schema.height-t._margin.top-t._margin.bottom,m=t.schema.discrete?"x"===t.schema.discrete?"y":"x":void 0,p=t.schema.width-t._margin.left-t._margin.right,g=function(t,e,n,i,o){const{xData:r,x2Data:a,yData:s,y2Data:c}=o,l=_t({viz:t,plotFormattedData:e,plotAxisData:n,xData:r,x2Data:a,yData:s,y2Data:c,plotStackGroup:i},[yC,AS]);return"panel"!==t._facetStep&&nC(t,l.plotStackPositions),{plotInitialDomains:l.plotInitialDomains,plotDiscreteKeys:l.plotDiscreteKeys,plotStackData:l.plotStackData,plotStackKeys:l.plotStackKeys,plotDomains:l.plotDomains,plotScales:l.plotScales,plotConfigScales:l.plotConfigScales,plotOpps:l.plotOpps,plotOpenEnds:l.plotOpenEnds}}(t,o,r,i.stackGroup,{xData:c,x2Data:l,yData:u,y2Data:d}),{x:y,y:x,x2:b,y2:_,xScale:k,yScale:v}=g.plotScales,w=h.groups(o,t=>t.shape).sort(([e],[n])=>t.schema.shapeSort(e,n)),M=function(t,e,n,i,o){const r=_t({viz:t,plotFormattedData:e,plotAxisData:n,plotScales:{...i.plotScales,...o},plotConfigScales:i.plotConfigScales,plotOpenEnds:i.plotOpenEnds},[e$,DM]).plotScales;return{x:r.x,y:r.y,x2:r.x2,y2:r.y2}}(t,o,r,g,{x:y,y:x,x2:b,y2:_}),S=function(t,e,n,i,o,r){const{x2Exists:a,y2Exists:s}=o,{x2Data:c,y2Data:l,yData:h}=r,u=_t({viz:t,plotAxisData:e,plotScales:{...n.plotScales,...i},x2Exists:a,y2Exists:s,x2Data:c,y2Data:l,yData:h},[qC]);return{xDomain:u.plotXDomain,x2Domain:u.plotX2Domain,yDomain:u.plotYDomain,y2Domain:u.plotY2Domain,defaultConfig:u.plotDefaultConfig,defaultX2Config:u.plotDefaultX2Config,defaultY2Config:u.plotDefaultY2Config,showX:u.plotShowX,showY:u.plotShowY,yC:u.plotYC,xTicks:u.plotXTicks,x2Ticks:u.plotX2Ticks,yTicks:u.plotYTicks,y2Ticks:u.plotY2Ticks,barLabels:u.plotBarLabels,barLabelCheck:u.plotBarLabelCheck}}(t,r,g,M,{x2Exists:a,y2Exists:s},{x2Data:l,y2Data:d,yData:u}),C=t.schema.lineLabels&&!s,$=function(t,e,n,i,o){const{xTest:r,yTest:a}=o;return()=>{const o=_t({viz:t,plotFormattedData:e,plotScales:n.plotScales,plotConfigScales:n.plotConfigScales,plotTestAxes:{xTest:r,yTest:a},plotLineLabelTest:{testLineShape:B$,testTextBox:E$},y2Exists:i},[HC]);return{labelWidths:o.plotLabelWidths,largestLabel:o.plotLargestLabel,xRangeMax:o.plotXRangeMax,startLabelSpace:o.plotStartLabelSpace??0}}}(t,o,g,s,n),A=F$(t,function(t,e,n,i){const{x2Exists:o,y2Exists:r,height:a,width:s,xData:c,x:l}=i;return{...t,xDomain:e.xDomain,x2Domain:e.x2Domain,yDomain:e.yDomain,y2Domain:e.y2Domain,xTicks:e.xTicks,x2Ticks:e.x2Ticks,yTicks:e.yTicks,y2Ticks:e.y2Ticks,xConfigScale:n.xConfigScale,x2ConfigScale:n.x2ConfigScale,yConfigScale:n.yConfigScale,y2ConfigScale:n.y2ConfigScale,defaultX2Config:e.defaultX2Config,defaultY2Config:e.defaultY2Config,yC:e.yC,showX:e.showX,showY:e.showY,x2Exists:o,y2Exists:r,height:a,width:s,xData:c,xScalePadding:l.padding?l.padding():0,barLabelCheck:e.barLabelCheck}}(n,S,g.plotConfigScales,{x2Exists:a,y2Exists:s,height:f,width:p,xData:c,x:M.x}),$),z={...t._margin};R$(t,e);const D=t._margin.left+t._margin.right-z.left-z.right,L=t._margin.top+t._margin.bottom-z.top-z.bottom,F={...i,domains:g.plotDomains,shapeData:w,discreteKeys:g.plotDiscreteKeys,stackData:g.plotStackData,stackKeys:g.plotStackKeys,...M,xScale:k,yScale:v,...g.plotConfigScales,...S,...A,...n,height:f,width:p,opp:m,showLineLabels:C,horizontalMargin:D,verticalMargin:L};return t._paint(F)}function T$(t){const e=Object.create(t);return e._d3Scale=t._d3Scale?t._d3Scale.copy():null,e._d3ScaleNegative=t._d3ScaleNegative?t._d3ScaleNegative.copy():null,e.schema={...t.schema},e}function O$(t,e,n){const i=t.length;if(!i)return[];const o=[0];for(let t=1;t<i;t++)o.push(o[t-1]+(e[t-1]+e[t])/2);const r=(t,e)=>o[e]-o[t.start],a=e=>{let n=0;for(let i=e.start;i<=e.end;i++)n+=t[i]-r(e,i);return n/(e.end-e.start+1)},s=[];for(let n=0;n<i;n++){let i={start:n,end:n,top:t[n]};for(;;){const t=s[s.length-1];if(!t)break;const n=t.top+r(t,t.end),o=(e[t.end]+e[i.start])/2;if(i.top>=n+o)break;s.pop(),i={start:t.start,end:i.end,top:0},i.top=a(i)}s.push(i)}const c=[];for(const t of s)for(let e=t.start;e<=t.end;e++)c.push(t.top+r(t,e));const[l,h]=[Math.min(...n),Math.max(...n)];c[0]=Math.max(c[0],l);for(let t=1;t<i;t++)c[t]=Math.max(c[t],c[t-1]+(e[t-1]+e[t])/2);c[i-1]=Math.min(c[i-1],h);for(let t=i-2;t>=0;t--)c[t]=Math.min(c[t],c[t+1]-(e[t]+e[t+1])/2);c[0]=Math.max(c[0],l);for(let t=1;t<i;t++)c[t]=Math.max(c[t],c[t-1]+(e[t-1]+e[t])/2);return c}function W$(t,e,n){return e?(h.groups(e,t=>t.side??"end",t=>t.xValue).forEach(([,e])=>e.forEach(([,e])=>function(t,e,n){const i=e.map(e=>(e.defaultY||(e.defaultY=t._yAxis._getPosition(e.value)),e)).sort((t,e)=>t.defaultY-e.defaultY),o=O$(i.map(t=>t.defaultY),i.map(t=>1.2*t.fontSize),n),r=Math.max(...n)+.5,a=o.filter(t=>t<=r).length;i.forEach((t,e)=>{if(a<i.length&&e>=a-1){if(e!==a-1)return void(t.hidden=!0);t.collapsed=i.length-e}Math.abs(o[e]-t.defaultY)>.5&&(t.newY=o[e])})}(t,e,n))),e.reduce((t,e)=>(e.newY&&(t[Lg(e.side,e.id)]=e.newY),t),{})):{}}function H$(t,e){const n=e.filter(t=>void 0!==t.newY&&!t.hidden);if(!n.length)return[];const i=n.map(e=>r.assign({x:t._xAxis._getPosition.bind(t._xAxis)(e.xValue),y:e.defaultY},e)).concat(n.map(e=>r.assign({x:"start"===e.side?t._xAxis._getPosition.bind(t._xAxis)(e.xValue)-e.padding+1:t._xAxis._getPosition.bind(t._xAxis)(e.xValue)+e.padding-1,y:e.newY||e.defaultY},e))),o=Rm("Line").config({data:i,id:t=>"start"===t.side?Lg("start",t.id):t.id,stroke:t=>t.fontColor,x:t=>t.x,y:t=>t.y}).config(t._labelConnectorConfig).renderMode("compute");return o.render(),Im(o)}const j$={domainTicks:!0,fixedSize:void 0};const I$=t=>!!t._labelRotation&&t._labelAngle;const G$=([t,e])=>[t,Math.max(t,e)];function q$(t,e,n){const{labelWidths:i}=e,o=b$(t,e,n);e=o.pCtx;const{x2Height:r,horizontalMargin:a}=e;let s=o.yRange;const{insetBottom:c,yBottom:l}=o,{yBounds:u,yWidth:d,y2Bounds:f,y2Width:m,xOffsetLeft:p,xOffsetRight:g}=o.solved,y=n?.xRange??G$([p,e.width-(g+a)]),x=function(t,e,n,i){const{x2Height:o,topOffset:r}=e,a={x:t._margin.left,y:t._margin.top+o+r};t._chartTransform=a;const s=i,c=Math.max(0,n-s-(e.startLabelSpace??0))||0,l={x:{x:t._margin.left,y:t._margin.top+o+r},x2:{x:t._margin.left,y:t._margin.top+r},y:{x:t._margin.left+c,y:t._margin.top+r},y2:{x:t._margin.left-e.horizontalMargin,y:t._margin.top+r}};return t=>({x:l[t].x-a.x,y:l[t].y-a.y})}(t,e,p,d),b=[],_=(n?.yRange??s)[1]+c-r,k=function(t,e,n,i,o,r){const{xDomain:a,x2Domain:s,xConfigScale:c,x2ConfigScale:l}=e,{defaultX2Config:h,showX:u,x2Exists:d,xC:f}=e,{xTicks:m,x2Ticks:p,x2Height:g,topOffset:y,height:x,width:b,verticalMargin:_}=e,k=t._xAxis,v=t._x2Axis;k.renderMode("compute").select(null).domain(a).height(x-(g+y+_)).maxSize(x/2).range(n).ticks(m).width(b).labelRotation(I$(e.xTest)).config({...j$,...f}).config(kg(t,"x")).config(e.zoomAxes?.x??{}).scale(c);const w=Boolean(e.xLabelMode&&"axis"!==e.xLabelMode);w&&z$(k,r),k.render(),u&&o.push({key:"plot-x-axis",transform:i("x"),axis:k,gridOnly:w}),d&&(v.renderMode("compute").select(null).domain(s).height(x-(e.xHeight+y+_)).range(n).ticks(p).width(b).labelRotation(I$(e.x2Test)).config({...j$,...f}).config(h).config(t._x2Config).config(e.zoomAxes?.x2??{}).scale(l).render(),o.push({key:"plot-x2-axis",transform:i("x2"),axis:v}));const M=T$(k),S=T$(v),C=(t,e)=>"x2"===e?("log"===l&&0===t&&(t=S._givenDomain()[s[0]<0?1:0]),S._getPosition(t)):("log"===c&&0===t&&(t=M._givenDomain()[a[0]<0?1:0]),M._getPosition(t));return t._xFunc=C,C}(t,e,y,x,b,_),v="ends"===e.xLabelMode?A$(t._xAxis,y,_):[];s=n?.yRange??G$([t._xAxis.outerBounds().y+r,l-c]);const w=function(t,e,n,i,o,r,a,s){const{yDomain:c,y2Domain:l,yConfigScale:u,y2ConfigScale:d}=e,{defaultY2Config:f,showY:m,y2Exists:p,yC:g}=e,{yTicks:y,x2Height:x,height:b,width:_}=e,k=t._yAxis,v=t._y2Axis;k.renderMode("compute").select(null).domain(c).height(b).maxSize(_/2).range(i).ticks(y).width(n[n.length-1]).config({...j$,...g}).config(kg(t,"y")).config(e.zoomAxes?.y??{}).scale(u).render(),m&&s.push({key:"plot-y-axis",transform:a("y"),axis:k}),p&&(v.renderMode("compute").select(null).config({...j$,...g}).domain(p?l:c).gridSize(0).height(b).range(i).width(_-h.max([0,o-r])).title(!1).config(t._y2Config).config(f).config(e.zoomAxes?.y2??{}).scale(d).render(),s.push({key:"plot-y2-axis",transform:a("y2"),axis:v}));const w=T$(k),M=T$(v),S=(t,e)=>"y2"===e?("log"===d&&0===t&&(t=l[1]<0?M._givenDomain(!0)[0]:M._givenDomain()[1]),M._getPosition(t)-x):("log"===u&&0===t&&(t=c[1]<0?w._givenDomain(!0)[0]:w._givenDomain()[1]),w._getPosition(t)-x);return t._yFunc=S,S}(t,e,y,s,g,m,x,b),M=W$(t,i,s);let S=t._xAxis.barConfig()["stroke-width"];return S&&(S/=2),{x:k,y:w,xRange:y,yRange:s,xOffsetLeft:p,xOffsetRight:g,yWidth:d,y2Width:m,yBounds:u,y2Bounds:f,axisSceneQueue:b,yOffset:S||0,labelPositions:M,xEndLabels:v,insetBottom:c}}const V$=t=>"text"===t.type||"htmlOverlay"===t.type,Y$="plot-break-mask";function K$(t,e){return["y","x"].flatMap(n=>{const i=t[`_${n}Axis`];if(!i||!i._breaks||!i._breaks.length)return[];const o="y"===n,r=o?e.x2Height:0,a=(o?e.xRange:e.yRange.map(t=>t-e.x2Height)).slice(0,2).sort((t,e)=>t-e);return i._breaks.map(t=>({axis:i,brk:t,vertical:o,gap:Jn(i,t).map(t=>t-r),extent:a}))})}const U$=t=>t.baseline?"baselineBreakConfig":"breakConfig";function X$(t,e){return{..._o(t,t.schema.barConfig),..._o(t,(t.schema[U$(e)]||{}).lineConfig||{})}}function Z$(t,e){return K$(t,e).flatMap(({axis:t,brk:e,vertical:n,gap:i,extent:o},r)=>{if(!Yn(t,U$(e)).lines)return[];const a=X$(t,e),s=`break-line-${n?"y":"x"}-${r}`;return i.map((t,e)=>({type:"line",key:`${s}-${e}`,points:n?[[o[0],t],[o[1],t]]:[[t,o[0]],[t,o[1]]],paint:a,interactive:!1,interactionGroup:"axis"}))})}const Q$=t=>t.reduce((e,[n,i],o)=>{const[r,a]=t[(o+1)%t.length];return e+n*a-r*i},0)/2;function J$(t,e){const n=Math.sign(Q$(t));return[t,...e.map(t=>Math.sign(Q$(t))===n?t.slice().reverse():t)].map(t=>`M${t.map(([t,e])=>`${t},${e}`).join("L")}Z`).join("")}function tA(t,e,n,i=0){const o=t[0]+i,r=t[1]-i,[a,s]=e;return n?[[a,o],[s,o],[s,r],[a,r]]:[[o,a],[r,a],[r,s],[o,s]]}function eA(t,e,n){const i=[[-1e6,-1e6],[1e6,-1e6],[1e6,1e6],[-1e6,1e6]],o=K$(t,n),r=[!0,!1].flatMap(t=>{const e=o.filter(e=>e.vertical===t&&e.brk.mask).map(({axis:e,brk:n,gap:i,extent:o})=>{const r=Yn(e,U$(n)).lines?(X$(e,n).strokeWidth??1)/2:0;return tA(i,o,t,r)});return e.length?[{axis:t?"y":"x",d:J$(i,e)}]:[]});if(!r.length)return e;const a=[];let s=[],c=0;const l=()=>{if(!s.length)return;const t=c++?"-"+(c-1):"",e=r.reduce((e,{axis:n,d:i})=>[{type:"group",key:`${Y$}-${n}${t}`,clip:{type:"path",d:i},children:e}],s);a.push(...e),s=[]};for(const t of e)V$(t)?(l(),a.push(t)):s.push(t);return l(),a}const nA=t=>"group"===t.type&&String(t.key).startsWith(Y$);function iA(t){return t.some(nA)?t.flatMap(t=>nA(t)?iA(t.children):[t]):t}const oA="plot-domain-clip",rA=t=>String(t.key).endsWith("::hit"),aA=t=>"text"===t.type||"htmlOverlay"===t.type||"axis"===t.interactionGroup,sA=t=>"circle"===t.type;function cA(t){const e=t.paint;if(!e||!e.stroke||"none"===e.stroke||"transparent"===e.stroke)return 0;const n=Number(e.strokeWidth??1);return Number.isFinite(n)&&n>0?n/2:0}function lA(t){return t.reduce((t,e)=>Math.max(t,function(t){if(rA(t))return 0;if("group"===t.type)return lA(t.children);const e=Math.abs(t.transform?.scale??1);return("circle"===t.type?t.r+cA(t):cA(t))*e}(e)),0)}function hA(t,e,n=[]){if(rA(t))return!1;const i=t.transform?[t.transform,...n]:n;return"group"===t.type?t.children.some(t=>hA(t,e,i)):function(t){switch(t.type){case"circle":return[[t.cx,t.cy]];case"rect":case"image":return[[t.x,t.y],[t.x+t.width,t.y+t.height]];case"path":{const e=f.pathBounds(t.d);return[[e.x,e.y],[e.x+e.width,e.y+e.height]]}case"line":return t.points;case"area":return[...t.topline,...t.baseline];default:return[]}}(t).some(t=>{const[n,o]=i.reduce((t,e)=>cc(t,e),t);return Number.isFinite(n)&&Number.isFinite(o)&&(n<e.x0||n>e.x1||o<e.y0||o>e.y1)})}const uA=(t,e,n=0)=>({x0:t.x0-e,y0:t.y0-e-n,x1:t.x1+e,y1:t.y1+e+n});function dA(t,e){const n=function(t){const e=t.xRange.slice(0,2).map(Number),n=t.yRange.slice(0,2).map(e=>Number(e)-t.x2Height);return{x0:Math.min(...e),y0:Math.min(...n),x1:Math.max(...e),y1:Math.max(...n)}}(e);if(![n.x0,n.y0,n.x1,n.y1].every(Number.isFinite))return t;const i=uA(n,1,e.yOffset??0),o=[];let r=[],a=0,s=!1;const c=()=>{if(!r.length)return;const t=`${oA}-${a++}`;if(r.some(t=>hA(t,i))){const e=uA(n,lA(r)),i=r.map(t=>t.z).filter(t=>"number"==typeof t);o.push({type:"group",key:t,clip:{type:"rect",x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0},children:r,...i.length?{z:Math.min(...i)}:{}}),s=!0}else o.push(...r);r=[]};for(const e of t)aA(e)?(c(),o.push(e)):(r.length&&sA(r[0])!==sA(e)&&c(),r.push(e));return c(),s?o:t}const fA=new RegExp(`(^|/)${oA}-\\d+$`),mA=t=>"group"===t.type&&fA.test(String(t.key));function pA(t){return t.some(mA)?t.flatMap(t=>"group"===t.type&&mA(t)?t.children:[t]):t}function gA(t,e,n,i){return{x:t[0]+n-e.width/2,y:t[1]+i-e.height/2,width:e.width,height:e.height}}const yA=(t,e,n,i)=>Math.max(n,Math.min(t,i-e));function xA(t,e){return{...t,x:yA(t.x,t.width,e.x0,e.x1),y:yA(t.y,t.height,e.y0,e.y1)}}function bA(t,e,n=0){const i=t.x+t.width/2,o=t.y+t.height/2,r=e[0]-i,a=e[1]-o,s=r?t.width/2/Math.abs(r):1/0,c=a?t.height/2/Math.abs(a):1/0,l=Math.min(s,c);if(!(l<1))return null;const h=[i+r*l,o+a*l],u=Math.hypot(e[0]-h[0],e[1]-h[1]),d=Math.min(Math.max(n,0),u),f=u?d/u:0,m=[e[0]-(e[0]-h[0])*f,e[1]-(e[1]-h[1])*f];return Math.hypot(m[0]-h[0],m[1]-h[1])<1?null:{from:h,to:m}}function _A(t,e,n){const i=Math.hypot(e[0]-t[0],e[1]-t[1])||1,o=(e[0]-t[0])/i,r=(e[1]-t[1])/i,a=e[0]-o*n,s=e[1]-r*n,c=n/2;return[e,[a-r*c,s+o*c],[a+r*c,s-o*c]]}function kA(t,e,n){const i=Math.hypot(e[0]-t[0],e[1]-t[1]);if(!i)return e;const o=Math.min(n,i)/i;return[e[0]-(e[0]-t[0])*o,e[1]-(e[1]-t[1])*o]}const vA=(t,[e,n])=>e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height;function wA(t,e,[n,i],o,r=!0){const a=gA(t,e,n,i);if(!r)return a;const s=xA(a,o);if(!vA(s,t)||vA(a,t))return s;const c=xA(gA(t,e,-n,-i),o);return vA(c,t)?s:c}const MA=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e,SA=t=>!1===t||"none"===t;function CA(t,e,n){return i=>{const o=t[i];return"function"==typeof o?o(e,n):void 0!==e[i]?e[i]:o}}function $A(t,e,n,i){const o=CA(e,i.d,i.i),r=OM(n,i.d,e.xRef,e.yRef);if(!r.every(Number.isFinite)||!TM(r,n.plot))return[];const a=o("label");if(null==a||!1===a||""===a)return[];const s=GM(t,o),c=qM(`${a}`,s);if(!c.lines.length)return[];const l=Math.max(0,MA(o("padding"),6)),h=wA(r,{width:c.width+2*l,height:c.height+2*l},[MA(o("dx"),0),MA(o("dy"),-40)],n.plot,!1!==o("clamp")),u=o("textAlign")||"middle",d="start"===u?h.x+l:"end"===u?h.x+h.width-l:h.x+h.width/2,f=s.fontColor,m=function(t,e,n,i,o){if(!1===t("connector"))return[];const r=bA(e,n,MA(t("standoff"),0));if(!r)return[];const a=t("connectorStroke")||o,s=MA(t("connectorStrokeOpacity"),1),c=t("marker")??"arrow",l=Math.max(0,MA(t("markerSize"),6)),h=MA(t("connectorStrokeWidth"),1),u=[],d="arrow"===c&&l?kA(r.from,r.to,l):r.to,f={fill:"none",stroke:a,strokeWidth:h,strokeOpacity:s},m=$a(t("connectorStrokeDasharray"));if(m&&(f.strokeDasharray=m),u.push({type:"line",key:`${i}-connector`,interactive:!1,points:[r.from,d],curve:"linear",paint:f}),"arrow"===c&&l){const[t,e,n]=_A(r.from,r.to,l);u.push({type:"path",key:`${i}-marker`,interactive:!1,d:`M${t[0]},${t[1]}L${e[0]},${e[1]}L${n[0]},${n[1]}Z`,paint:{fill:a,opacity:s}})}else"dot"===c&&l&&u.push({type:"circle",key:`${i}-marker`,interactive:!1,cx:r.to[0],cy:r.to[1],r:l/2,paint:{fill:a,opacity:s}});return u}(o,h,r,i.key,f),p=function(t,e,n,i,o){const r=e("fill"),a=e("stroke");if(SA(r)&&SA(a))return null;const s=SA(r)?{fill:"none"}:{fill:r||Os(t),fillOpacity:MA(e("fillOpacity"),1)};return SA(a)||(s.stroke=a||o,s.strokeWidth=MA(e("strokeWidth"),1),s.strokeOpacity=MA(e("strokeOpacity"),.25)),{type:"rect",key:i,interactive:!1,...n,rx:MA(e("rx"),3),paint:s}}(t,o,h,`${i.key}-box`,f);return p&&m.push(p),m.push(VM(c,s,{key:`${i.key}-label`,x:d,y:h.y+l,align:u})),m}function AA(t,e,n,i){return(Array.isArray(e.data)?e.data:[]).flatMap((o,r)=>$A(t,e,n,{d:o,i:r,key:`${i}-${r}`}))}function zA(t){const e=t=>{t.interactive=!1;const n=t.children;if(n)for(const t of n)e(t)};return t.forEach(e),t}function DA(t,e){const n=[];try{const e=t.toScene();e&&Array.isArray(e.children)&&e.children.length&&n.push(e);const i=t._labelClass;if(i&&"function"==typeof i.toScene){const t=i.toScene();t&&Array.isArray(t.children)&&t.children.length&&n.push(t)}}catch{return null}if(!n.length)return null;const i={type:"group",key:e,children:n};return zA([i]),i}function LA(t,e,n,i,o,r){const a=Object.assign({},e);delete a.shape,delete a.layer;const s=Rm(e.shape).renderMode("compute").duration(Zt(t)).config(a).config(Lt({x:t=>t.x2?n(t.x2,"x2"):n(t.x),x0:"x"===t.schema.discrete?t=>t.x2?n(t.x2,"x2"):n(t.x):n(o.x[0]),x1:"x"===t.schema.discrete?null:t=>t.x2?n(t.x2,"x2"):n(t.x),y:t=>t.y2?i(t.y2,"y2"):i(t.y),y0:"y"===t.schema.discrete?t=>t.y2?i(t.y2,"y2"):i(t.y):i(o.y[1])-r,y1:"y"===t.schema.discrete?null:t=>t.y2?i(t.y2,"y2"):i(t.y)-r}));return s.render(),s}const FA={Callout:AA,[tS]:gS,[JM]:pS};function NA(t){return t.layer||("Callout"===t.shape?"front":"back")}function BA(t){const e=t._annotations||[];return[...rS(t.schema.referenceBands),...oS(t.schema.referenceLines),...e.filter(t=>!!t&&"string"==typeof t.shape)]}function EA(t,e,n,i,o){const{x:r,y:a,frame:s}=n,c=[],l=BA(t);return Object.keys(t._previousAnnotations).forEach(n=>{const h=l.filter(t=>NA(t)===n);h.forEach((l,h)=>{const u=`annotation-${n}-${h}`,d=FA[l.shape];if(!d){const s=DA(LA(t,l,r,a,i,o),u);return void(s&&("front"===n?c:e).push(s))}const f=d(t,l,s,u),m="back"===n&&"Callout"!==l.shape,p=RA(m?f.filter(t=>"text"!==t.type):f,u);p&&("front"===n?c:e).push(p);const g=m&&RA(f.filter(t=>"text"===t.type),`${u}-labels`);g&&c.push(g)});const u=h.map(t=>t.shape).filter(t=>!FA[t]);t._previousAnnotations[n].filter(t=>!u.includes(t)).forEach(t=>{Rm(t).renderMode("compute").data([]).render()}),t._previousAnnotations[n]=u}),c}function RA(t,e){if(!t.length)return null;const n={type:"group",key:e,children:t};return zA([n]),n}const PA=(t,e,n)=>"function"==typeof t?t(e,n):t;function TA(t,e,n){if(n.labelBounds)return null;const{viz:i,values:o}=t,r=e.schema,a=r.labelConfig,s=o.map((t,e)=>{const n=t,i=Number(r.r(t,e));return{key:t,datum:n.data??t,index:"number"==typeof n.i?n.i:e,x:Number(r.x(t,e)),y:Number(r.y(t,e)),r:i,text:r.label(t,e),inside:{width:2*i,height:2*i,shape:"circle",padding:PA(a.padding,t,e),font:{family:PA(a.fontFamily,t,e),weight:PA(a.fontWeight,t,e)}}}}),c=M_(i,s,function(t){const e=t.xRange.slice(0,2).map(Number),n=t.yRange.slice(0,2).map(e=>Number(e)-(t.x2Height??0)),i=Math.min(...e),o=Math.min(...n);return{x:i,y:o,width:Math.max(...e)-i,height:Math.max(...n)-o}}(t));if(!c.size)return null;const l=r.labelBounds,h=a.fontMin;r.labelBounds=function(t,e,n){const i=c.get(t);return i&&"inside"!==i.position?null:l.call(this,t,e,n)},e.config({labelConfig:{fontMin:(t,e)=>A_(i,c.get(t.data),PA(h,t,e)??8)}});const u=new Map(o.map((t,e)=>[t,e])),d=$_(c,t=>({id:`${PA(r.id,t,u.get(t)??0)}`,datum:t}));return()=>C_(i,d,{fontOpacity:a.fontOpacity})}function OA(t){let e=-1/0;for(const n of t)"number"==typeof n.z&&(e=Math.max(e,n.z));return e===-1/0?t:t.map(t=>"text"===t.type?{...t,z:e+1}:t)}const WA=["bandOpacity","capWidth","tooltip"];function HA(t){const{viz:e,x:n,y:i,values:o}=t,a=aM(e);if(!a.length)return[];const s=e.schema.discrete||"x",c="x"===s?"y":"x",l="x"===s?i:n,h=Object.assign({},e.schema.shapeConfig,e._confidenceConfig),u=r.assign(Hm(e,"Line",h),Hm(e,"Area",h));WA.forEach(t=>delete u[t]);const d=a.length>1,f=d?lM(cM(e._confidenceConfig?.bandOpacity,a.length)):[],m=[];return a.forEach((e,n)=>{const i=(t,e,n)=>l(t?hM(t(e.data,e.i),n):n),r=Lt(Object.assign({},t.shapeConfig));r[`${c}0`]=t=>i(e.lower,t,t[c]),r[`${c}1`]=t=>i(e.upper,t,t[c]),n&&(r.id=t=>`${t.id}::band-${n}`);const a=Rm("Area").renderMode("compute").config(r).data(o);a.config(u),d&&a.config({fillOpacity:f[n]}),a.render(),m.push(...Im(a))}),m}function jA(t,e,n,i){const{viz:o}=t;if(e.hidden)return!1;if(e.collapsed)return`+${d.formatAbbreviate(e.collapsed,o.schema.locale)} ${o.schema.translate("more")}`;const r=void 0!==e.name?e.name:void 0===t.name||null===t.name?o._drawLabel(n,i):"function"==typeof t.name?t.name(n,i):t.name;return void 0===e.valueText?r:Dg(r,e.valueText)}function IA(t,e,n){const{viz:i,labelWidths:o}=t;if(!Ag(i.schema.lineLabels,e.data,e.i).length)return[];const r=[];for(const i of["start","end"]){const a=o.find(t=>t.id===e.id&&(t.side??"end")===i);if(!a)continue;const s=jA(t,a,e,n);!1!==s&&r.push({side:i,text:s,measure:a})}return r}function GA(t,e,n,i,o){const[r,a]=t[0],[s,c]=t.reduce((t,n)=>"end"===e?n[0]>=t[0]?n:t:n[0]<t[0]?n:t),l=i/4;return{x:s-r-("start"===e?n:0),y:c-a-l/2-(o?c-o:0),width:n,height:l}}function qA(t){const{viz:e,labelWidths:n,largestLabel:i,labelPositions:o}=t,r=h.max(n.filter(t=>"start"===t.side),t=>t.labelWidth)??0,a=new Map,s=t=>1===t.length?t[0]:t;return{label:(e,n)=>{const i=IA(t,e,n);return a.set(e.id,i.map(t=>t.side)),!!i.length&&s(i.map(t=>t.text))},labelBounds:(n,a,c)=>s(IA(t,n,a).map(({side:t})=>GA(c.points,t,"start"===t?r:i,e.schema.height,o[Lg(t,n.id)]))),textAnchor:t=>(e,n)=>{const i=void 0===e.l?e.data:e,o=i?.data?.id;return"start"===a.get(o)?.[i?.l]?"end":"function"==typeof t?t(e,n):t}}}const VA=[2,4];function YA(t){if(!1===t)return{bridge:null};if("dashed"===t)return{bridge:{strokeDasharray:VA,opacity:1}};if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,n=void 0===e.strokeDasharray?VA:!1===e.strokeDasharray?void 0:$a(Array.isArray(e.strokeDasharray)?e.strokeDasharray.join(" "):e.strokeDasharray),i={opacity:"number"==typeof e.opacity&&Number.isFinite(e.opacity)?e.opacity:1};return n&&n.some(t=>t>0)&&(i.strokeDasharray=n),"string"==typeof e.stroke&&e.stroke&&(i.stroke=e.stroke),"number"==typeof e.strokeWidth&&(i.strokeWidth=e.strokeWidth),{bridge:i}}function KA(t,e){const n=Array.from(new Set(e.filter(Number.isFinite))).sort((t,e)=>t-e),i=[];for(let e=0;e<t.length-1;e++){const o=Math.min(t[e],t[e+1]),r=Math.max(t[e],t[e+1]);if(!Number.isFinite(o)||!Number.isFinite(r))continue;let a=0,s=n.length;for(;a<s;){const t=a+s>>1;n[t]<=o?a=t+1:s=t}a<n.length&&n[a]<r&&i.push(e)}return i}function UA(t,e,n){const i=[0];for(let e=1;e<t.length;e++)i.push(i[e-1]+Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]));const o=i[i.length-1]??0;let r=0;return{at:n.map(n=>{for(;r<t.length-1;r++){const o=t[r][e],a=t[r+1][e];if(o===n)return i[r];if((o-n)*(a-n)<0){const t=(n-o)/(a-o);return i[r]+t*(i[r+1]-i[r])}}return o}),total:o}}function XA(t,e,n){if(!(n>e))return[];const i=t&&t.length%2?t.concat(t):t,o=i?i.reduce((t,e)=>t+e,0):0;if(!(i&&o>0&&i.some((t,e)=>!(e%2)&&t>0)))return[[e,n]];const r=[];let a=e;for(let t=0;a<n;t=(t+1)%i.length){const e=Math.min(n,a+i[t]);!(t%2)&&e>a&&r.push([a,e]),a=e}return r}function ZA(t,e){const n=[];let i=0,o=0;for(;i<t.length&&o<e.length;){const r=Math.max(t[i][0],e[o][0]),a=Math.min(t[i][1],e[o][1]);a>r&&n.push([r,a]),t[i][1]<e[o][1]?i++:o++}return n}function QA(t,e){const n=[];let i=0;return t.forEach(([t,e])=>{t>i&&n.push([i,t]),i=Math.max(i,e)}),e>i&&n.push([i,e]),n}function JA(t,e){const n=t=>+Math.max(0,t).toFixed(2),i=[];let o=0;return t.forEach(([t,e],r)=>{r?i.push(n(t-o)):n(t)>0&&i.push(0,n(t)),i.push(n(e-t)),o=e}),i.length?(i.push(n(e-o)+n(e)+1),i):[0,n(e)+1]}function tz(t,e,n,i,o=3){const r=new Set(e),a=[[]];t.forEach((e,n)=>{a[a.length-1].push(e),r.has(n)&&n<t.length-1&&a.push([])});const s=x.line().curve(Dw(n));return a.map(t=>{if(t.length>1)return s(t)||"";const[e,n]=t[0];return i?`M${e},${n-o}L${e},${n+o}`:`M${e-o},${n}L${e+o},${n}`}).join("")}function ez(t,e){if(!t)return[];const n=[];let i=0;return[...e].sort((t,e)=>t-e).forEach(e=>{e<i||e>=t-1||(n.push([i,e]),i=e+1)}),n.push([i,t-1]),n}function nz(t,e,n=16){const i=[];let o=0,r=0;const a=(t,e)=>{i.push([t,e]),o=t,r=e},s={moveTo:a,lineTo:a,closePath:()=>{},bezierCurveTo(t,e,a,s,c,l){const h=o,u=r;for(let o=1;o<=n;o++){const r=o/n,d=1-r,f=d*d*d,m=3*d*d*r,p=3*d*r*r,g=r*r*r;i.push([f*h+m*t+p*a+g*c,f*u+m*e+p*s+g*l])}o=c,r=l},quadraticCurveTo(t,e,a,s){const c=o,l=r;for(let o=1;o<=n;o++){const r=o/n,h=1-r;i.push([h*h*c+2*h*r*t+r*r*a,h*h*l+2*h*r*e+r*r*s])}o=a,r=s}};return x.line().curve(Dw(e)).context(s)(t),i}function iz(t,e,n){let i,o=0;if(t.length){const o=Math.sign(t[t.length-1][e]-t[0][e])||1;(t[0][e]-n)*o>=0&&(i=0)}for(let r=1;r<t.length;r++){const a=t[r-1],s=t[r],c=Math.hypot(s[0]-a[0],s[1]-a[1]);void 0===i&&(a[e]-n)*(s[e]-n)<=0&&s[e]!==a[e]&&(i=o+c*((n-a[e])/(s[e]-a[e]))),o+=c}return[i??o,o]}function oz(t,e,n){const i=n.length%2?n.concat(n):n,o=i.reduce((t,e)=>t+e,0);if(!(o>0)||t>=e)return;const r=[+t.toFixed(2),0];for(let n=0;n<e-t;n+=o)r.push(...i);return r}const rz=1e5;function az(t){const{viz:e,values:n}=t,i=YA(e.schema.connectGaps);if(!i||!n.length)return null;const o=n,r=t.missingRows??[],a="y"===e.schema.discrete?"y":"x",s="y"===a?1:0,c=qw([...o.map(t=>t[a]),...r.map(t=>t[a])]),l=o.map(t=>c(t[a])),h=new Map;r.forEach(t=>{const e=`${t.id}`;h.has(e)||h.set(e,[]),h.get(e).push(c(t[a]))});const u=new Map;o.forEach(t=>{const e=`${t.id}`;u.has(e)||u.set(e,[]),u.get(e).push(t)});const d=t.shapeConfig.x,f=t.shapeConfig.y,m=Lw(e,o[0]),p=new Map;return u.forEach((t,e)=>{const n=KA(t.map(t=>c(t[a])),l.concat(h.get(e)??[]));if(!n.length)return;const i=t.map(t=>[d(t),f(t)]),{at:o,total:r}=UA(nz(i,m),s,i.map(t=>t[s])),u=n.map(t=>[o[t],o[t+1]]);p.set(e,{points:i,gaps:n,gapIntervals:u,total:r})}),p.size?{series:p,bridge:i.bridge,curve:m,axis:s}:null}function sz(t){const e=t.interactionPoints?.[0]?.datum;return e?`${e.id}`:void 0}function cz(t,e){const n=QA(e.gapIntervals,e.total);return JA(ZA(XA(t,0,e.total),n),e.total)}function lz(t,e,n){const i=t.paint??{},o=JA(e.gapIntervals.flatMap(([t,e])=>XA(n.strokeDasharray,t,e)),e.total);return{...t,key:`${t.key}::gap`,interactive:!1,interactionPoints:void 0,aria:{hidden:!0},paint:{...i,stroke:n.stroke??i.stroke,strokeWidth:n.strokeWidth??i.strokeWidth,strokeDasharray:o,opacity:(i.opacity??1)*n.opacity}}}function hz(t,e){return t.flatMap(t=>{if("path"!==t.type||"Line"!==t.shapeType)return[t];const n=sz(t),i=void 0===n?void 0:e.series.get(n);if(!i)return[t];const o=t.transform?.x??0,r=t.transform?.y??0;if(String(t.key).endsWith("::hit")){const n=i.points.map(([t,e])=>[t-o,e-r]);return[{...t,d:tz(n,i.gaps,e.curve,e.axis)}]}const a=$a(t.paint?.strokeDasharray),s={...t,paint:{...t.paint,strokeDasharray:cz(a,i)}};return e.bridge?[s,lz(t,i,e.bridge)]:[s]})}function uz(t,e){const{points:n}=t,i=ez(n.length,t.gaps),o=n[n.length-1][e]>=n[0][e];return i.map(([t,r],a)=>{const s=n[t][e],c=n[r][e];let l=Math.min(s,c),h=Math.max(s,c);return!a&&o&&(l=-rz),a||o||(h=rz),a===i.length-1&&o&&(h=rz),a!==i.length-1||o||(l=-rz),e?`M-100000,${l}H100000V${h}H-100000Z`:`M${l},-100000H${h}V100000H${l}Z`}).join("")}function dz(t,e){return t.map(t=>{const n=sz(t),i=void 0===n?void 0:e.series.get(n);if(!i||"Area"!==t.shapeType)return t;return{type:"group",key:`${t.key}::gaps`,clip:{type:"path",d:uz(i,e.axis)},children:[t]}})}function fz(t,e,n,i){const o=t/2;if(e<2)return[-o,o];const r=2*i/(e-1),a=n*r-i;return[(n<=0?-o:a-r/2)-a,(n>=e-1?o:a+r/2)-a]}const mz=t=>"Bar"===t.shapeType&&String(t.key).endsWith("::hit");function pz(t,e){const n=t=>yl(t),i=e.label(),o=e.labelBounds(),r=e.labelConfig(),a="number"==typeof r.padding?r.padding:0,s=r.verticalAlign;if("function"!=typeof o)return;const c=new WeakSet,l=(t,e)=>{const o=i(t,e);return!(!1===o||null==o||Array.isArray(o)||!Number.isFinite(n(t)))&&o};e.label((e,o)=>{const r=l(e,o);return!1===r?i(e,o):[r,`${d.formatAbbreviate(100*n(e),t.schema.locale)}%`]}),e.labelBounds((t,e,n)=>{const i=o(t,e,n);if(!i||Array.isArray(i)||!1===l(t,e))return i;const r=function(t,e){const n=Math.min(14,.4*(t.height-2*e));if(n<8)return null;const i=t.height-e-n;return[{...t,height:i+e},{...t,height:n+2*e,y:t.y+i-e}]}(i,a);return r?(c.add((t=>t.__d3plusShape__?t.data:t)(t)),r):[i,{...i,height:0,width:0}]}),e.labelConfig({verticalAlign:(t,e)=>!!t&&c.has(t.data)?1===t.l?"top":"bottom":"function"==typeof s?s(t,e):s})}function gz(t,e){return{start:a.cubicInOut(t/e),end:a.cubicInOut((t+1)/e)}}function yz(t,e){const{viz:n}=t;if(!n.schema.stacked||function(t){const e=t=>"rect"===t.type&&"Bar"===t.shapeType||"group"===t.type&&t.children.some(e);return!!t&&e(t.root)}(n._paintedScene))return e;const{levels:i,depth:o}=function(t,e){const{opp:n,stackData:i,stackKeyIndex:o,discreteKeyIndex:r}=e,a=new Map;for(const e of t){const t=Number(e[n??"y"]),s=i[o.get(e.id)??-1],c=r.get(e.discrete);if(!t||!Number.isFinite(t)||!s||void 0===c)continue;const l=s.index??o.get(e.id),h=`${c}|${e.group}|${t<0?"-":"+"}`;a.has(h)||a.set(h,[]),a.get(h).push({row:e,order:l})}const s=new Map;let c=0;for(const t of a.values())t.sort((t,e)=>t.order-e.order),t.forEach(({row:t},e)=>s.set(t,e)),c=Math.max(c,t.length);return{levels:s,depth:c}}(t.values,t);if(o<2)return e;const r=new Map;for(const t of e){const e="Bar"===t.shapeType?i.get(t.datum):void 0;void 0!==e&&r.set(t.datum,gz(e,o))}return e.map(t=>{const e=t.datum,n=r.get(e)??r.get(e?.data);return n?{...t,enterWindow:n}:t})}const xz="plot-forecast",bz=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function _z(t,e,n){return"x"===(t.schema.discrete||"x")?e.x(n):e.y(n)}function kz(t,e,n){const i=t.schema.discrete||"x",o=qw(n.map(t=>t[i])),r=n.map(n=>({at:o(n[i]),px:_z(t,e,n[i])})).filter(t=>Number.isFinite(t.px)).sort((t,e)=>t.at-e.at);return r.length<2?1:r[r.length-1].px<r[0].px?-1:1}function vz(t,e,n,i,o){if(void 0===i.next)return NaN;const r=_z(t,e,i.next);if(!Number.isFinite(r))return NaN;const a=_z(t,e,i.value);if(Number.isFinite(a)&&Math.abs(a-r)>=.5)return(a+r)/2;const s=t.schema.discrete||"x",c=n.map(n=>_z(t,e,n[s])).filter(t=>Number.isFinite(t)),l=t=>c.filter(e=>(e-r)*o*t>.5).reduce((t,e)=>void 0===t||Math.abs(e-r)<Math.abs(t-r)?e:t,void 0),h=l(-1);if(void 0!==h)return(h+r)/2;const u=l(1);return void 0!==u?r-(u-r)/2:r}function wz(t,e,n,i=!1){const o=Xw(t,e);if(!o||!e.length)return[];const a="x"===(t.schema.discrete||"x"),s=kz(t,n,e),c=i?vz(t,n,e,o,s):_z(t,n,o.value);if(!Number.isFinite(c))return[];const l=a?n.xRange:[0,n.yRange[1]-n.yRange[0]],h=a?[0,n.yRange[1]-n.yRange[0]]:n.xRange,u=Math.min(l[0],l[1]),d=Math.max(l[0],l[1]),f=s>0?d:u,m=Math.min(Math.max(c,u),d);if(Math.abs(f-m)<1)return[];const p=c>=u-.5&&c<=d+.5,g=t.schema.forecastConfig,y=function(t){return Ws(t)}(t),x=Math.min(m,f),b=Math.abs(f-m),_={type:"rect",key:`${xz}-region`,x:a?x:h[0],y:a?h[0]:x,width:a?b:h[1]-h[0],height:a?h[1]-h[0]:b,paint:{fill:g.fill||y,fillOpacity:bz(g.fillOpacity,.05)},interactive:!1},k=[];if(!1!==g.fill&&"none"!==g.fill&&k.push(_),k.push(...Mz(g,_,y)),p&&!1!==g.stroke&&"none"!==g.stroke){const t={fill:"none",stroke:g.stroke||y,strokeWidth:bz(g.strokeWidth,1),strokeOpacity:bz(g.strokeOpacity,.4)},e=$a(g.strokeDasharray);e&&(t.strokeDasharray=e),k.push({type:"line",key:`${xz}-rule`,points:a?[[m,h[0]],[m,h[1]]]:[[h[0],m],[h[1],m]],curve:"linear",paint:t,interactive:!1})}const v=p?function(t,e){const n=e.label;return!1===n||null===n||""===n?"":"function"==typeof n?`${n(t.schema.locale)}`:"string"==typeof n?n:t.schema.translate("Forecast")}(t,g):"";return v&&k.push(function(t,e,n,i){const o=bz(e.fontSize,12),a=e.fontFamily||`${t.schema.fontFamily}`,s=r.textWidth(n,{"font-family":a,"font-size":o}),c=5,l=i.dir>=0,h=i.horizontal?i.from+(l?c:-c):i.cross[0]+c,u=i.horizontal?i.cross[0]+c+o/2:i.from+(l?c+o/2:-c-o/2);return{type:"text",key:`${xz}-label`,interactive:!1,x:0,y:0,transform:{x:h,y:u},lines:[{text:n,x:0,y:0,width:s}],font:{family:a,size:o,weight:e.fontWeight??400,anchor:i.horizontal&&!l?"end":"start",baseline:"middle"},paint:{fill:e.fontColor||i.ink,opacity:bz(e.fontOpacity,.7)}}}(t,g,v,{from:m,dir:Math.sign(f-m),horizontal:a,cross:h,ink:y})),k.length?[{type:"group",key:xz,interactive:!1,children:k}]:[]}function Mz(t,e,n){const i=[],o="string"==typeof t.fill&&"none"!==t.fill?t.fill:n,r=xa(t.texture,()=>"transparent",()=>o,t.textureDefault||void 0);r&&i.push({...e,key:`${xz}-texture`,paint:{fill:`pattern:${r}`,opacity:bz(t.textureOpacity,.3)}});const a=t.backgroundImage,s="string"==typeof a&&Jv({backgroundImage:a,backgroundImageFit:t.backgroundImageFit},{...e,paint:{}},void 0,0);return s&&i.push(s),i}function Sz(t,e,n,i){const o=$a(t.schema.forecastConfig.lineDasharray);if(!o||!o.some(t=>t>0))return null;const r=Xw(t,e);if(!r||r.series&&!r.series.size)return null;const a="x"===(t.schema.discrete||"x")?0:1,s=n.x,c=n.y,l=Lw(t,e[0]),h=new Map;return(n,u)=>{const d=`${e[u]?.id}`;if(!h.has(d)){const n=(e=>{const n=r.series?r.series.get(e):r.value;return void 0===n?NaN:_z(t,i,n)})(d);if(Number.isFinite(n)){const t=e.filter(t=>`${t.id}`===d).map(t=>[s(t),c(t)]),[i,r]=iz(nz(t,l),a,n);h.set(d,oz(i,r,o))}else h.set(d,void 0)}return h.get(d)}}function Cz(t,e){return(n,i)=>{const o=t(n,i);return o||("function"==typeof e?e(n,i):e)}}function $z(t){const e=t.map(([t])=>t),n=t.flatMap(([,t])=>t);return{rows:n,slots:e.includes("Bar")&&!e.includes("Line")&&!e.includes("Area")}}function Az(t,e){const{viz:n,opp:i,x:o,y:r,stackData:a,domains:s,stackKeyIndex:c,discreteKeyIndex:l}=t,h=Lt(Object.assign({},t.shapeConfig));if("Circle"===e&&n._size){const t=n._size;h.sort=(e,n)=>(Number(t(n))||0)-(Number(t(e))||0)}if("Box"===e&&(h.id=t=>t.discrete),n.schema.stacked&&["Area","Bar"].includes(e)){const t="x"===i?o:r;h[`${i}`]=h[`${i}0`]=e=>{const n=c.get(e.id)??-1,o=l.get(e.discrete)??-1,r=e[i]<0?1:0;return t(n>=0?a[n][o][r]:s[i]["x"===i?0:1])},h[`${i}1`]=e=>{const n=c.get(e.id)??-1,o=l.get(e.discrete)??-1,r=e[i]<0?0:1;return t(n>=0?a[n][o][r]:s[i]["x"===i?0:1])}}return h}function zz(t,e,n,i){const{viz:o,events:r}=t;o._wirePlotShapeEvents(n,e,r);const a=Hm(o,e);void 0===o.schema.shapeConfig.duration&&delete a.duration,n.config(a),i&&n.config(i(a)),"Bar"===e&&t.barLabelsOnAxis&&n.label(!1),"Area"===e&&o.schema.stacked&&n.label(Jg(o,n.label())),o.schema.stacked&&"Bar"===e&&pz(o,n);const s="Circle"===e?TA(t,n,a):null;n.render();const c=Im(n);if("Circle"===e)return OA([...c,...s?.()??[]]);if("Bar"!==e)return c;const l=RS(t,c);if(!l.length)return yz(t,c);let h=-1;return c.forEach((t,e)=>{"Bar"===t.shapeType&&(h=e)}),yz(t,[...c.slice(0,h+1),...l,...c.slice(h+1)])}const Dz=(t,e)=>zz(t,e,Rm(e).renderMode("compute").config(Az(t,e)).data(t.values));function Lz(t){const{viz:e,values:n}=t,i=e.schema.discrete;if("Time"!==("x"===i?t.xScale:t.yScale))return n;const o=t.zoomRanges?.[i];if(o){const e="x"===i?t.x:t.y,[r,a]=h.extent(o);return n.filter(t=>{const n=e(t[i]);return n>=r-.5&&n<=a+.5})}const[r,a]=h.extent(("x"===i?t.xDomain:t.yDomain).map(Number));return n.filter(t=>{const e=+t[i];return e>=r&&e<=a})}function Fz(t,e,n){const{viz:i}=t;i.schema.stacked||function(t,e,n,i){n&&t.config({hitArea:(o,r)=>function(t,e,n,i){const[o,r]=e,[a,s]=n;return"x"===t?{x:o,y:a-(i.y??0),width:r-o,height:s-a}:{x:a-(i.x??0),y:o,width:s-a,height:r-o}}(e,i(o,r),n,t._sceneTransform(o,r))})}(e,"y"===i.schema.discrete?"y":"x",t.valueExtent,n)}const Nz={Bar:t=>{const e={...t,values:Lz(t)},{viz:n,x:i,y:o,xScale:r,yScale:a,xDomain:s,yDomain:c,xRange:l,yRange:u,values:d,zoomRanges:f}=e,m=Rm("Bar").renderMode("compute").config(Cg(Az(e,"Bar"),lg(n),e.valueExtent)).data(d),p="x"===n.schema.discrete?i:o;if(n._discreteExtent)return function(t,e,n){const{viz:i,values:o}=t,r=t=>{const[e,o]=Jw(i,t);return Math.max(1,Math.abs(n(o)-n(e))-i._groupPadding)},a=t=>{const[e,o]=Jw(i,t);return Math.abs(n(o)-n(e))},s=i.schema.discrete,c=i._barSpans?function(t,e){const n=new Map,i=new Set;let o=!1;for(const r of t){const t=Kp(r[e]),a=n.get(t)??new Set;a.add(r.group),n.set(t,a),i.add(r.group),a.size>1&&(o=!0)}return o?Array.from(i):[]}(o,s):[];if(c.length<2)return e.width(r),e.height(r),Fz(t,e,t=>fz(a(t),1,0,0)),zz(t,"Bar",e);const l=t=>function(t,e,n,i){const o=Math.max(1,(t-i*e-1)/e);if(e<2)return{size:o,offset:0};const r=Math.max(0,t-o)/2;return{size:o,offset:n*r*2/(e-1)-r}}(r(t),c.length,c.indexOf(t.group),i.schema.barPadding),h=t.shapeConfig[s];return e[s]((t,e)=>h(t,e)+l(t).offset),e.width(t=>l(t).size),e.height(t=>l(t).size),Fz(t,e,t=>fz(a(t),c.length,c.indexOf(t.group),Math.max(0,r(t)-l(t).size)/2)),zz(t,"Bar",e)}(e,m,p);let g;const y="x"===n.schema.discrete?r:a,x="x"===n.schema.discrete?s:c,b="x"===n.schema.discrete?l:u,_=f?.[n.schema.discrete];if("Point"!==y&&2===x.length){const t=Array.from(new Set(d.map(t=>p(t[n.schema.discrete]))));t[0]>t[t.length-1]&&t.reverse();const e=t[0],i=t[t.length-1];t.unshift(_?2*_[0]-e:b[0]-e-b[0]),t.push(_?2*_[1]-i:b[1]+b[1]-i),g=t.reduce((t,e,n,i)=>{if(n){const o=Math.abs(e-i[n-1]);o<t&&(t=o)}return t},1/0)}else g=x.length>1?Math.abs(p(x[1])-p(x[0])):b[b.length-1]-b[0];const k=g;n._groupPadding<g&&(g-=n._groupPadding);let v=g||1;const w=h.groups(d,t=>t[n.schema.discrete],t=>t.group),M=h.merge(w.map(([,t])=>t.map(([t])=>t))),S=Array.from(new Set(M)),C=n.schema.discrete,$=e.shapeConfig[C];let A=()=>fz(k,1,0,0);if(1===h.max(w.map(([,t])=>t.length)))m[C]((t,e)=>$(t,e));else{v=(v-n.schema.barPadding*S.length-1)/S.length;const t=g/2-v/2,e=E.scaleLinear().domain([0,S.length-1]).range([-t,t]);m[C]((t,n)=>$(t,n)+e(S.indexOf(t.group))),A=e=>fz(k,S.length,S.indexOf(e.group),t)}return m.width(v),m.height(v),Fz(e,m,A),zz(e,"Bar",m)},Circle:(t,e)=>{if(!t.viz._swarm)return Dz(t,e);const{viz:n,values:i,x:o,y:r,xRange:a,yRange:s}=t,c=Rm("Circle").renderMode("compute").config(Az(t,"Circle")).data(i);return zz(t,"Circle",c,e=>{const c=e.r,l=MM(n,{values:i,x:o,y:r,xRange:a,yRange:s,lanes:"x"===n._swarm.cross?t.xDomain:t.yDomain,r:"function"==typeof c?c:()=>c}),h=t=>l.get(t);return{x:t=>h(t).x,y:t=>h(t).y,r:t=>h(t).r}})},Line:t=>{const{viz:e,values:n,width:i,showLineLabels:o,labelWidths:r,largestLabel:a,labelPositions:s}=t,c=[],l=Rm("Line").renderMode("compute").config(Az(t,"Line")).data(n);e.schema.fillBetween&&c.push(...Tw(t)),l.duration(1.5*i);const h=az(t);if(e._confidence){const e=HA(t);c.push(...h?dz(e,h):e)}const u={viz:e,labelWidths:r,largestLabel:a,labelPositions:s},d=o?qA(u):void 0;l.config({discrete:t.shapeConfig.discrete||"x",label:!!d&&d.label,labelBounds:!!d&&d.labelBounds});const f=Sz(e,n,t.shapeConfig,t),m=d&&r.some(t=>"start"===t.side||t.valueText||void 0!==t.name)?t=>{const e=qA({...u,name:t.label});return{label:e.label,labelBounds:e.labelBounds,labelConfig:{textAnchor:e.textAnchor(l.labelConfig().textAnchor)}}}:void 0,p=zz(t,"Line",l,f||m?t=>({...f&&{strokeDasharray:Cz(f,t.strokeDasharray)},...m?.(t)}):void 0);c.push(...h?hz(p,h):p);const g=Rm("Circle").renderMode("compute").data(e._lineMarkers?n:[]).config(t.shapeConfig).config(e._lineMarkerConfig).id(t=>`${t.id}_${t.discrete}`);return e._wirePlotShapeEvents(g,"Circle",t.events),g.render(),c.push(...Im(g)),c}};const Bz=["group","order","confidence","confidenceLevel","confidenceConfig","projection","projectionConfig","tooltip","stroke","label","labelConfig"];function Ez(t,e,n){const i=t;return i.interactive=n,i.interactionGroup="trend",n&&(i.trendFit=e),i.datum=e.row,i.children&&i.children.forEach(t=>Ez(t,e,n)),t}function Rz(t,e,n){return(t._trendFits||[]).map(i=>function(t,e,n,i){const o=t._trendLineConfig||{},r=[],a=()=>`trend-${e.id}`;if(void 0!==e.samples[0].lci){const s=Rm("Area").renderMode("compute").duration(Zt(t)).data(e.samples).config({id:a,label:!1,fill:e.color,stroke:"none",strokeWidth:0}).config(o.confidenceConfig||{}).config(function(t,e,n){const i=i=>"x"===t.axis?e(i.x):n(i.y),o=i=>"x"===t.axis?n(i.lci):e(i.lci),r=i=>"x"===t.axis?n(i.hci):e(i.hci);return"x"===t.axis?{x:i,x0:i,x1:null,y:o,y0:o,y1:r}:{y:i,y0:i,y1:null,x:o,x0:o,x1:r}}(e,n,i));r.push(...Im(s).map(t=>Ez(t,e,!1)))}const s=Object.fromEntries(Object.entries(o).filter(([t])=>!Bz.includes(t))),c=(a,c,l)=>{if(a.length<2)return;const h=Rm("Line").renderMode("compute").duration(Zt(t)).data(a).config({...s,id:c,label:!1,stroke:e.color}).config(l).config({x:t=>n(t.x),y:t=>i(t.y)});r.push(...Im(h).map(t=>Ez(t,e,!1!==o.tooltip)))};return c(e.samples.filter(t=>!t.projected),a,{}),c(e.samples.filter(t=>t.projected),()=>`trend-${e.id}-projection`,o.projectionConfig||{}),r.length?{type:"group",key:`plot-trend-${e.id}`,children:r}:null}(t,i,e,n)).filter(t=>null!==t)}const Pz={2:"²",3:"³"},Tz={exponential:"Exponential",linear:"Linear",logarithmic:"Logarithmic",polynomial:"Polynomial",power:"Power"};function Oz(t,e){const n=t.filter(([t])=>0!==t);return n.length?n.map(([t,n],i)=>{const o=`${e(Math.abs(t))}${n}`;return 0===i?t<0?`−${o}`:o:t<0?` − ${o}`:` + ${o}`}).join(""):e(0)}function Wz(t,e=String,n="x"){const i=n,o="x"===n?"y":"x",r=t.coefficients;let a;if("exponential"===t.type)a=`${e(r[0])}e^(${e(r[1])}${i})`;else if("power"===t.type)a=`${e(r[0])}${i}^${e(r[1])}`;else if("logarithmic"===t.type)a=Oz([[r[1],`ln(${i})`],[r[0],""]],e);else{a=Oz(r.map((t,e)=>[t,0===e?"":1===e?i:`${i}${Pz[e]||`^${e}`}`]).reverse(),e)}return`${o} = ${a}`}function Hz(t){return e=>0!==e&&Math.abs(e)<.001?e.toPrecision(3):d.formatAbbreviate(e,t)}function jz(t,e,n,i){const o=n.nativeEvent,r=o&&o.touches&&o.touches.length?[o.touches[0].clientX,o.touches[0].clientY]:o?[o.clientX,o.clientY]:n.point;jl(zC(t).data([e.row||{}]).config(Qt.bind(t)(t.schema.tooltipConfig)).title(()=>e.label),zl(e.color,"Line")).thead([]).tbody(function(t,e,n){const{fit:i,axis:o}=e,r=e=>t.schema.translate(e),a=[];if(n&&n.projected){const e="x"===o?"y":"x",i=n=>CC(t,e,n),s=void 0!==n.lci?` (${i(n.lci)} – ${i(n.hci)})`:"";a.push([SC(t,o),`${CC(t,o,n[o])} (${r("Projected")})`],[SC(t,e),`${i(n[e])}${s}`])}return a.push([r("Trend Line"),r(Tz[i.type])]),t[`_${o}Time`]||a.push([r("Equation"),Wz(i,Hz(t.schema.locale),o)]),a.push(["R²",i.r2.toFixed(3)],[r("Observations"),`${i.n}`]),a}(t,e,i?function(t,e,n){const i="x"===e.axis?t._xFunc:t._yFunc;if(!i)return;const o="x"===e.axis?n[0]:n[1],r=t=>{let n,r=1/0;for(const a of t){const t=Math.abs(i(a[e.axis])-o);t<r&&([n,r]=[a,t])}return n},a=r(e.samples);return a&&a.projected?r(e.samples.filter(t=>t.step)):void 0}(t,e,i):void 0)).footer(!1).position(r).render()}function Iz(t,e,n){if(!n)return null;if("function"==typeof n){const t=n(e);return!1===t||null==t||""===t?null:`${t}`}return"equation"===n?function(t,e,n=!1){const i=`R² = ${t.fit.r2.toFixed(2)}`;return n?i:`${Wz(t.fit,Hz(e),t.axis)}, ${i}`}(e,t.schema.locale,Boolean(t[`_${e.axis}Time`])):e.row?e.label:t.schema.translate("Trend")}function Gz(t,e,n){return a.pathTextBoxes({type:"text",key:"",x:0,y:0,font:{size:n,anchor:"start"},lines:[{text:" ",x:0,y:0,width:e}],path:{d:t}})}const qz=(t,e)=>{const n={...t,width:t.width+12,height:t.height+4};return e.some(t=>P_(n,t))};function Vz(t,e,n){const{fontSize:i,lift:o,width:r,obstacles:a}=n,s=Op(function(t,e){const n=([t,n])=>t>=e.x0-.5&&t<=e.x1+.5&&n>=e.y0-.5&&n<=e.y1+.5;let i=[],o=[];for(const e of t)Number.isFinite(e[0])&&Number.isFinite(e[1])&&n(e)?o.push(e):o=[],Tp(o)>Tp(i)&&(i=o.slice());return i}(t,e)),c=Tp(s)-6;if(c<4*i)return null;const l=Math.min(r,c),h=i/2;for(const t of[o,-(o+.75*i)])for(let e=c;e-l>=-1e-9;e-=h){const n=Ip(Wp(Hp(s,Math.max(0,e-l),e),t)),o=Gz(n,l,i);if(!o.some(t=>qz(t,a)))return{d:n,boxes:o};if(l>=c)break}return null}function Yz(t,e,n,i,o=[]){const a=t._trendLineConfig||{},c=a.label,l=t._trendFits||[];if(!c||!l.length)return[];const h=a.labelConfig||{},u="number"==typeof h.fontSize?h.fontSize:11,d="number"==typeof a.strokeWidth?a.strokeWidth:2,f={"font-family":r.fontExists(h.fontFamily??s.fontFamily),"font-size":u,"font-weight":h.fontWeight??600},m=function(t){const e=[],n=(t,i,o)=>{const r=i+(t.transform?.x??0),a=o+(t.transform?.y??0);if("group"===t.type&&t.children.forEach(t=>n(t,r,a)),"text"!==t.type)return;const s=t.datum;if(/^(line-label-along|contour-label)-/.test(`${t.key}`)||"Line"===s?.data?.shape)for(const n of ak([t]))e.push({...n,x:n.x+i,y:n.y+o})};return t.forEach(t=>n(t,0,0)),e}(o),p=l.flatMap(o=>{const a=Iz(t,o,c);if(!a)return[];const s=Vz(o.samples.filter(t=>!t.projected).map(t=>[e(t.x),n(t.y)]),i,{fontSize:u,lift:d/2+2,width:r.textWidth(a,f)+2,obstacles:m});return s?(m.push(...s.boxes),[{key:`trend-label-${o.id}`,text:a,d:s.d,color:o.color,anchor:"end"}]):[]});return qp(t,p,h)}function Kz(t,e,n,i,o){const{shapeData:r,domains:a,discreteKeys:s,stackData:c,stackKeys:l,xDomain:h,yDomain:u}=n,{xScale:d,yScale:f}=n,{labelWidths:m,largestLabel:p}=n,{width:g}=n,{opp:y,showLineLabels:x}=n,{x:b,y:_,xRange:k,yRange:v,labelPositions:w,yOffset:M}=i,S=Object.keys(t.schema.on),C=new Map;for(let t=0;t<l.length;t++)C.set(l[t],t);const $=new Map;for(let t=0;t<s.length;t++)$.set(s[t],t);const A={viz:t,shapeConfig:o,events:S,x:b,y:_,xScale:d,yScale:f,xDomain:h,yDomain:u,xRange:k,yRange:v,opp:y,domains:a,stackData:c,stackKeyIndex:C,discreteKeyIndex:$,showLineLabels:x,labelWidths:m,largestLabel:p,labelPositions:w,width:g,values:[],valueExtent:Sg(t,{x2Height:n.x2Height,yOffset:M}),barLabelsOnAxis:n.barLabelsOnAxis,insetBottom:i.insetBottom??0,x2Height:n.x2Height,zoomRanges:n.zoomRanges,missingRows:n.missingRows};var z;e.push(...(z=r.flatMap(([t,e])=>function(t,e){return(t.viz._plotShapeEmitters?.[e]??Nz[e]??Dz)(t,e)}({...A,values:e},t)),z.some(mz)?[...z.filter(mz),...z.filter(t=>!mz(t))]:z))}const Uz=t=>"string"==typeof t.key&&t.key.startsWith("grid-"),Xz=t=>{t.interactionGroup="axis";const e=t.children;if(e)for(const t of e)Xz(t)};function Zz(t,e,n,i){const o=[],{shapeData:r,domains:a}=e,{labelWidths:s}=e,{x:c,y:l,xRange:h,yRange:u,yOffset:d,axisSceneQueue:f}=n,m=function(t){const e=[],n=[];return t.forEach(({key:t,transform:i,axis:o,gridOnly:r})=>{if(!o||"function"!=typeof o.toScene)return;const a=o.toScene();if(!a)return;const s=a.children||[],c=s.filter(Uz),l=s.filter(t=>!Uz(t));if(c.length){const n={type:"group",key:`${t}-grid`,transform:i,children:c};Xz(n),e.push(n)}if(l.length&&!r){const e={type:"group",key:t,transform:i,children:l};Xz(e),n.push(e)}}),{grid:e,rest:n}}(f);!function(t,e,n,i){const o=t._backgroundConfig;if(o&&o.fill&&"transparent"!==o.fill){const t=Rm("Rect").renderMode("compute").data([{}]).x(n[0]+(n[1]-n[0])/2).width(n[1]-n[0]).y((i[1]-i[0])/2).height(i[1]-i[0]).config(o);t.render();const r=Im(t);e.unshift(...r)}}(t,o,h,u),o.push(...m.grid),o.push(...Z$(t,{xRange:h,yRange:u,x2Height:e.x2Height})),o.push(...H$(t,s));const p=$z(r),g=jM(t,{x:c,y:l,xRange:h,yRange:u,x2Height:e.x2Height,x2Exists:e.x2Exists,y2Exists:e.y2Exists,slots:p.slots}),y=EA(t,o,{x:c,y:l,frame:g},a,d);o.push(...wz(t,p.rows,{x:c,y:l,xRange:h,yRange:u},p.slots));const x=Rz(t,c,l),b=function(t,e,n,i,o){const r=t.schema.discrete||"x";return Lt({discrete:t.schema.discrete,duration:Zt(t),label:e=>t._drawLabel(e.data,e.i),x:t=>void 0!==t.x2?e(t.x2,"x2"):e(t.x),x0:"x"===r?t=>t.x2?e(t.x2,"x2"):e(t.x):e("number"==typeof t.schema.baseline?t.schema.baseline:i.x[0]),x1:"x"===r?null:t=>t.x2?e(t.x2,"x2"):e(t.x),y:t=>void 0!==t.y2?n(t.y2,"y2"):n(t.y),y0:"y"===r?t=>t.y2?n(t.y2,"y2"):n(t.y):n("number"==typeof t.schema.baseline?t.schema.baseline:i.y[1])-o,y1:"y"===r?null:t=>t.y2?n(t.y2,"y2"):n(t.y)-o})}(t,c,l,a,d),_=x.length;Kz(t,x,e,n,b);const k=function(t,e){const n=[];for(let i=t.length-1;i>=e;i--)"axis"===t[i].interactionGroup&&n.unshift(...t.splice(i,1));return n}(x,_);t._plotUnderlay&&x.splice(_,0,...t._plotUnderlay(x.slice(_),c,l));const v=function(t,e,n=0){const i=t.slice(0,2).map(Number),o=e.slice(0,2).map(t=>Number(t)-n);return{x0:Math.min(...i),y0:Math.min(...o),x1:Math.max(...i),y1:Math.max(...o)}}(h,u,e.x2Height);x.push(...jg(t,x,v)),x.push(...Qg(t,x,v)),x.push(...Yz(t,c,l,v,x));const w=[u[0],u[1]+(n.insetBottom??0)];o.push(...i?x:dA(x,{xRange:h,yRange:w,x2Height:e.x2Height,yOffset:d})),function(t,e,n){const i=e.map(([t])=>t);i.includes("Line")&&(t._confidence&&i.push("Area"),t._lineMarkers&&i.push("Circle")),t._previousShapes.filter(e=>!i.includes(e)&&!t._plotShapeEmitters?.[e]).forEach(t=>{const e=Rm(t);"function"==typeof e.renderMode&&e.renderMode("compute"),"function"==typeof e.select&&e.select(null),e.config(n).data([]).render()}),t._previousShapes=i}(t,r,b),o.push(...QM(y,fc(x,void 0,Qz,!0),g.plot));const M=eA(t,o,{xRange:h,yRange:u,x2Height:e.x2Height}),S=t.schema.zoom?[{type:"group",key:Jz,...i?{clip:i}:{},children:M}]:M,C=D$(t._xAxis,n.xEndLabels??[]);return C&&Xz(C),[...S,...k,...m.rest,...C?[C]:[]]}const Qz=t=>"group"!==t.type&&"text"!==t.type;const Jz="plot-zoom-content";function tD(t,e,n,i){const o=q$(t,e,n),{xRange:r,yRange:a}=o;return t._bodyRect={x:r[0],y:a[0],width:r[1]-r[0],height:a[1]-a[0]},t._plotAxisDomains={x:t._xAxis?._d3Scale?.domain()??[],y:t._yAxis?._d3Scale?.domain()??[]},t._plotArea={x:r[0],y:0,width:r[1]-r[0],height:a[1]-a[0]+(o.insetBottom??0)},{nodes:Zz(t,e,o,i),layout:o}}const eD=(t,e)=>"time"===e||"Linear"===t&&["linear","pow","sqrt"].includes(e);function nD(t,e,n){const{nodes:i,layout:o}=tD(t,e);if(clearTimeout(t._plotUnclipTimer),t._plotZoomBase=void 0,t._zoomShapes=void 0,!t.schema.zoom)return i;const r={},a={},s={},c={};for(const n of function(t){const e=[];return eD(t.xScale,t.xConfigScale)&&e.push("x"),t.x2Exists&&eD(t.xScale,t.x2ConfigScale)&&e.push("x2"),eD(t.yScale,t.yConfigScale)&&e.push("y"),t.y2Exists&&eD(t.yScale,t.y2ConfigScale)&&e.push("y2"),e}(e)){const e=t[`_${n}Axis`],i=e?._d3Scale;i&&"function"==typeof i.invert&&(r[n]=i.copy(),a[n]=e?._labelSpace,s[n]=Boolean(e?._baselineBreak),c[n]=Boolean(e?.schema.reverse))}if(t._zoomShapes=function(t){const e=t.find(t=>t.key===Jz);return e&&"group"===e.type?pA(iA(e.children)):void 0}(i),!Object.keys(r).length)return i;const{x:l=0,y:h=0}=t._chartTransform||{};if(t._plotZoomBase={pCtx:e,layout:o,chartTransform:{x:l,y:h},scales:r,labelSpace:a,breaks:s,reversed:c},n&&(1!==n.k||n.x||n.y)){const e=iD(t,n);if(e)return e}return i}function iD(t,e,n=!1){const i=t._plotZoomBase;if(!i)return;const{pCtx:o,layout:r}=i,a=1===e.k&&!e.x&&!e.y,s=a?{}:function(t,e){const{pCtx:n,layout:i,chartTransform:o,scales:r}=t,a=i=>{const a=r[i],s="y"===i[0],c=s?o.y:o.x,l=s?e.y:e.x,h=s?-n.x2Height:0,u=a.range().map(t=>a.invert((t+h+c-l)/e.k-c-h)),[d,f]=a.domain();return(+f-+d)*(+u[1]-+u[0])<0!==Boolean(t.reversed[i])?u.reverse():u},s={};for(const t of Object.keys(r))s[`${t}Domain`]=a(t);s.zoomAxes={};for(const e of Object.keys(r))s.zoomAxes[e]={rounding:"none",domainTicks:!1,fixedSize:t.labelSpace[e],domain:s[`${e}Domain`],...t.breaks[e]?{}:{baselineBreak:!1}};const c=(t,i)=>{const r=i?o.y:o.x,a=i?-n.x2Height:0;return(t+a+r)*e.k+(i?e.y:e.x)-r-a};return s.zoomRanges={},r.x&&(s.zoomRanges.x=i.xRange.map(t=>c(t,!1))),r.y&&(s.zoomRanges.y=i.yRange.map(t=>c(t,!0))),s}(i,e),c=a&&!n?void 0:{type:"rect",x:r.xRange[0],y:r.yRange[0]-o.x2Height,width:r.xRange[1]-r.xRange[0],height:r.yRange[1]-r.yRange[0]+(r.insetBottom??0)};return tD(t,{...o,...s},r,c).nodes}function oD(t,e){const n=t._zoomTransform,i=n&&n.scale?n.scale:1,o=t._chartTransform;return[(e[0]-(n?.x??0))/i-(o?.x??0),(e[1]-(n?.y??0))/i-(o?.y??0)]}const rD=t=>t instanceof Date?String(t.getTime()):String(t);function aD(t,e){return!(!e.shapeType||!e.datum||"Box"===e.shapeType)&&("Bar"!==e.shapeType||!!t.schema.stacked)}function sD(t,e,n){const i=new Map,o="x"===e?t._xFunc:t._yFunc,r=(t,o,r,a)=>{if(!t||!Number.isFinite(o))return null;const s=rD(t[e]);let c=i.get(s);if(c||(c={px:o,value:t[e],members:new Map,bars:new Set,markers:[]},i.set(s,c)),"Bar"===a){const e=t.data||t;c.bars.add(e),n.bars.add(e)}const l=String(t.id),h=c.members.get(l);return h?h.color||(h.color=r):c.members.set(l,{wrapped:t,color:r,shape:a}),c},a=new Set,s=i=>{if(i.interactionGroup||!1===i.interactive)return;if(i.children&&i.children.forEach(t=>s(t)),"Box"===i.shapeType&&(n.box=!0),!aD(t,i))return;const c=i.paint||{},l=Ll(c.stroke)??Ll(c.fill);if("Area"===i.shapeType&&(n.area=!0),i.interactionPoints)for(const t of i.interactionPoints){const n=r(t.datum,t[e],l,i.shapeType);n&&"Line"===i.shapeType&&!a.has(t.datum)&&(a.add(t.datum),n.markers.push({datum:t.datum,x:t.x,y:t.y}))}else if(o&&!i.datum.__d3plusShape__){const t=i.datum;r(t,o(t[e]),l,i.shapeType)}};return(t._chartScene||[]).forEach(t=>s(t)),o&&function(t,e,n,i){for(const o of t._trendFits||[])if(o.axis===e&&!1!==t._trendLineConfig?.tooltip)for(const t of o.samples){if(!t.step)continue;const r=t[e],a=i(r);if(!Number.isFinite(a))continue;const s=rD(r);let c=n.get(s);c||(c={px:a,value:r,members:new Map,bars:new Set,markers:[]},n.set(s,c));const l=o.row||{};c.members.set(`${o.id}::projected`,{wrapped:l,color:o.color,shape:"Line",trend:{fit:o,sample:t}})}}(t,e,i,o),i}function cD(t,e,n,i){if(i.trend){const{fit:t,sample:o}=i.trend,r=Number(o["x"===e?"y":"x"]);if(!Number.isFinite(r))return null;const a=String(t.label),s=t.row||{};return{id:n,name:a,value:r,color:i.color,shape:"Line",datum:s,index:0,projected:{lci:o.lci,hci:o.hci}}}const o="x"===e?t._y:t._x,r=i.wrapped.data||i.wrapped,a="number"==typeof i.wrapped.i?i.wrapped.i:0,s=o?Number(o(r,a)):NaN;if(!Number.isFinite(s)||!t.schema.tooltip(r,a))return null;return{id:n,name:String(t._drawLabel(r,a)),value:s,color:i.color,shape:i.shape,datum:r,index:a}}function lD(t,e,n){let i=null;for(const o of t.values())(void 0===n||o.members.has(n))&&(!i||Math.abs(o.px-e)<Math.abs(i.px-e))&&(i=o);return i}const hD=t=>!(!t||!t.shapeType||!t.datum||t.interactionGroup||!1===t.interactive);function uD(t,e){const n=e?.datum?.data;if(!n||hD(e))return;let i;const o=t=>{i||(hD(t)&&t.datum===n?i=t:t.children&&t.children.forEach(t=>o(t)))};return(t._chartScene||[]).forEach(t=>o(t)),i}function dD(t,e,n,i){const o=t.schema.discrete;if("x"!==o&&"y"!==o)return null;const r=o,a="x"===r?n[0]:n[1],s={bars:new Set,area:!1,box:!1},c=sD(t,r,s);if(s.box)return null;const l=s.area?"front":"back",h=e.pick?e.pick.node:void 0,u=uD(t,h)??h,d=hD(u)&&"Box"!==u.shapeType,f=(e,n,i,o)=>{const a=e?.members.get(n)??(o?{wrapped:o,color:El(t,u),shape:u?.shapeType}:void 0),s=a?cD(t,r,n,a):null;if(!s||!Number.isFinite(i))return null;const c=e?e.markers.filter(t=>String(t.datum.id)===n):[],h=e?e.value:a.wrapped[r];return{mode:"single",axis:r,px:i,value:h,rows:[s],markers:c,layer:l}};if(i&&t.schema.tooltipShared){const e=lD(c,a);if(e){const n=[];if(e.members.forEach((e,i)=>{const o=cD(t,r,i,e);o&&n.push(o)}),n.length>=2||n.some(t=>t.projected)){!function(t,e,n){const i="x"===e?t._yFunc:t._xFunc,o=t=>{const n=i?i(t):NaN;return Number.isFinite(n)?"x"===e?n:-n:-t};n.sort((t,e)=>o(t.value)-o(e.value))}(t,r,n);const i=e.bars.size?{rows:e.bars,bars:s.bars}:void 0;return{mode:"shared",axis:r,px:e.px,value:e.value,rows:n,markers:e.markers,layer:l,stack:i}}if(1===n.length&&!d)return f(e,n[0].id,e.px)}}if(!d)return null;const m=u.datum,p=String(m.id);if(u.interactionPoints){const t=lD(c,a,p);return t?f(t,p,t.px):null}return f(null,p,function(t,e){const n=t,i=n.transform?.[e]??0;return"rect"===n.type?i+(n[e]??0)+(("x"===e?n.width:n.height)??0)/2:"circle"===n.type?i+(("x"===e?n.cx:n.cy)??0):NaN}(Bl(t,u)??u,r),m)}function fD(t,e){let n=null;const i=t._plotArea;if("mousemove"===e.type||"mouseenter"===e.type){if(t._transitionEndsAt&&Date.now()<t._transitionEndsAt)return;const o=e.pick&&e.pick.node;if(o&&o.trendFit)return void function(t,e,n){const i=t._sharedHoverState;t._sharedHoverActive=!0,t._sharedHoverState=null;const o=Array.isArray(n.point)?oD(t,n.point):void 0;jz(t,e,n,o),i&&("shared"===i.mode&&"function"==typeof t._hover&&t.hover(!1),t._scheduleSceneRepaint())}(t,o.trendFit,e);if(i&&Array.isArray(e.point)&&(!o||"legend"!==o.interactionGroup)){const[o,r]=oD(t,e.point);n=dD(t,e,[o,r],o>=i.x&&o<=i.x+i.width&&r>=i.y&&r<=i.y+i.height)}}else if("mouseleave"!==e.type||e.nativeEvent&&"mouseleave"!==e.nativeEvent.type)return;const o=t._sharedHoverState;if(n){t._sharedHoverActive=!0;const{mode:i,axis:r,px:a,value:s,markers:c,layer:l}=n,h=Xl(t,e.point)?.key;t._sharedHoverState={mode:i,axis:r,px:a,value:s,markers:c,layer:l,panel:h},"shared"===i?LC(t,n,e):function(t,e,n){const i=e.rows[0],o=t._drawDepth<t.schema.groupBy.length-1,r=zC(t).data([i.datum]).title(()=>t._drawLabel(i.datum,i.index)).footer(!(!o||!t.schema.on["click.shape"])&&t.schema.translate("Click to Expand")).config(Qt.bind(t)(t.schema.tooltipConfig)),a=r.tbody(),s="function"==typeof a?a(i.datum,i.index):a;jl(r,zl(i.color,i.shape)).tbody([...!1===t._tooltipAxisRows?[]:[$C(t,"x",e),$C(t,"y",e)],...i.projected?[]:_C(t,i.datum,i.index,n=>CC(t,MC(e.axis),n)),...Array.isArray(s)?s:[],...Sl(t,i.datum)]).arrow(!1).position(AC(t,e,n)).render()}(t,n,e),o&&o.px===a&&o.mode===i&&o.panel===h||(!function(t,e,n){const i=e.stack,o=()=>{"function"==typeof t._hover&&t.hover(!1)},r=t._plotColumnHighlight;if(r&&1===t.schema.shapeConfig.hoverOpacity)o();else if(r){const n=new Set(e.rows.map(t=>t.datum));We(t,t=>n.has(t)),t.hover(r(n))}else"single"===e.mode?"shared"===n&&o():i?(We(t,t=>i.rows.has(t)),t.hover(t=>i.rows.has(t)||!i.bars.has(t))):o()}(t,n,o?.mode),t._scheduleSceneRepaint())}else t._sharedHoverActive&&(t._sharedHoverActive=!1,t._sharedHoverState=null,t._tooltipClass.data([]).render(),function(t){const e=t._sharedTooltipSaved;e&&t._tooltipClass.arrow(e.arrow).thead(e.thead).tbody(e.tbody),t._sharedTooltipSaved=void 0}(t),"function"==typeof t._hover&&t.hover(!1),t._scheduleSceneRepaint())}const mD=/::(hit|stem|confidence)$/;function pD(t,e){return Math.abs(t)>=Math.abs(t+e)?t:t+e}function gD(t,e,n){return Number.isFinite(e)?{...t,[n]:e,span:[t[n],e]}:t}function yD(t,e,n){const i=t,o=i.datum;if(!o||"string"==typeof i.key&&mD.test(i.key))return[];const r=i.shapeType;if(i.interactionPoints)return i.interactionPoints.map(t=>({x:t.x,y:t.y,datum:t.datum,color:n,shape:r}));const a=i.transform?.x??0,s=i.transform?.y??0;if("circle"===i.type)return[{x:a+(i.cx??0),y:s+(i.cy??0),datum:o,color:n,shape:r}];if("rect"!==i.type)return[];const c=i.x??0,l=i.y??0,h=i.width??0,u=i.height??0;if("Bar"!==r)return[{x:a+c+h/2,y:s+l+u/2,datum:o,color:n,shape:r}];if("x"===e){const t=a+pD(c,h);return[{x:t,y:s+l+u/2,datum:o,color:n,shape:r,span:[a,t]}]}const d=s+pD(l,u);return[{x:a+c+h/2,y:d,datum:o,color:n,shape:r,span:[s,d]}]}function xD(t){return!(!t||!t.shapeType||!t.datum||"Box"===t.shapeType||t.interactionGroup||!1===t.interactive||t.datum.__d3plusShape__)}function bD(t,e,n){let i=null,o=1/0;for(const r of t){const t=r.span,a=t&&n>=Math.min(t[0],t[1])&&n<=Math.max(t[0],t[1])?0:Math.abs(r[e]-n);a<o&&(o=a,i=r)}return i}const _D=(t,e,n)=>t(e,n);function kD(t,e,n,i){return Number.isFinite(e)&&Math.abs(e-n)<=1?t:i?i(n):t}function vD(t,e){if(null==e)return"";if("number"==typeof e&&!Number.isFinite(e))return"";return`${(t?t(e):`${e}`)??""}`.replace(/<[^>]*>/g,"").trim()}function wD(t,e,n,i){const o=t[`_${e}Axis`]?._d3Scale;if(!o||"function"!=typeof o.invert)return;const r=_D(n,i,e)-o(i);return Number.isFinite(r)?t=>o.invert(t-r):void 0}function MD(t,e,n){if("Area"!==e.shape)return e;const i=void 0!==e.datum[`${n}2`]?`${n}2`:n,o="x"===n?t._xFunc:t._yFunc,r=Number(e.datum[i]);if(!o||!Number.isFinite(r))return e;if(!t.schema.stacked)return gD(e,_D(o,r,i),n);const a=wD(t,i,o,r),s=a?Number(a(e[n])):NaN;return Number.isFinite(s)?gD(e,_D(o,s+r,i),n):e}function SD(t){const e=t.schema.discrete;return"x"===e||"y"===e?e:void 0}function CD(t,e,n){const i=SD(t),o=e.pick?e.pick.node:void 0,r=Bl(t,uD(t,o)??o),a=xD(r);if(i){const e=t._sharedHoverState;if(!e)return a?function(t,e,n,i){const o="x"===n?"y":"x",r=yD(e,o,El(t,e));return r.length&&void 0!==r[0].datum[`${o}2`]?bD(r.map(e=>MD(t,e,o)),n,i["x"===n?0:1]):null}(t,r,i,n):null;const o="single"===e.mode&&a?String(r.datum.id):void 0,s="x"===i?"y":"x",c=function(t){const e="y"===t.schema.discrete?"x":"y",n=[],i=o=>{o.interactionGroup||!1===o.interactive||(o.children&&o.children.forEach(t=>i(t)),xD(o)&&n.push(...yD(o,e,El(t,o))))};return(t._chartScene||[]).forEach(t=>i(t)),n}(t).map(e=>MD(t,e,s)).filter(t=>Math.abs(t[i]-e.px)<=1&&(void 0===o||String(t.datum.id)===o)),l="x"===i?"y":"x";return bD(c,l,n["x"===l?0:1])}if(!a)return null;return function(t,e){let n=null,i=1/0;for(const o of t){const t=Math.hypot(o.x-e[0],o.y-e[1]);t<i&&(i=t,n=o)}return n}(yD(r,"y",El(t,r)).map(e=>MD(t,e,"y")),n)}const $D=t=>t?JSON.stringify([t.point,t.color,t.panel,t.badges]):"";function AD(t,e){let n=null;if("mousemove"===e.type||"mouseenter"===e.type){if(t._transitionEndsAt&&Date.now()<t._transitionEndsAt)return;const i=e.pick?.node;if(!1!==t.schema.axisHover&&t._plotArea&&Array.isArray(e.point)&&(!i||"legend"!==i.interactionGroup)&&(n=function(t,e,n){const i=CD(t,e,n);if(!i||!function(t,e){const n=t._plotArea;return!!n&&e.x>=n.x-1&&e.x<=n.x+n.width+1&&e.y>=n.y-1&&e.y<=n.y+n.height+1}(t,i))return null;const o=SD(t),r=o?t._sharedHoverState:null,a=t.schema.axisHover,s=function(t,e){const n=[];for(const i of["x","y"])e.bar&&i===(e.discrete??"x")||e.cross!==i&&(e.only&&e.only!==i||n.push(void 0!==t[`${i}2`]?`${i}2`:i));return n}(i.datum,{discrete:o,bar:"Bar"===i.shape,cross:t._swarm?.cross,only:"x"===a||"y"===a?a:void 0}),c=[];for(const e of s){const n=e.charAt(0),a=!!r&&n===o,s=a?r.px:i[n],l="x"===n?t._xFunc:t._yFunc,h=a?r.value:i.datum[e],u=vD(n=>CC(t,e,n),a||!l?h:kD(h,_D(l,h,e),s,wD(t,e,l,h)));u&&c.push({axis:e,at:s,text:u,guide:!a})}if(!c.length)return null;const l=i.datum.data||i.datum;return{point:{x:i.x,y:i.y},color:i.color,datum:l,index:"number"==typeof i.datum.i?i.datum.i:0,badges:c}}(t,e,oD(t,e.point)),n)){const i=Xl(t,e.point)?.key;void 0!==i&&(n.panel=i)}}else if("mouseleave"!==e.type)return;const i=t._axisHoverState;$D(i)!==$D(n)&&(t._axisHoverState=n,t._scheduleSceneRepaint())}function zD(t){const e=t;return e.interactive=!1,e.interactionGroup="axis",e.children&&e.children.forEach(zD),t}const DD=t=>{const e=t,n=e.datum;return!!e.shapeType&&!e.interactionGroup&&!1!==e.interactive&&!!n&&void 0!==n.id};function LD(t,e,n,i){const o=[...t];if(e.length){const t=o.findIndex(t=>DD(t)||mA(t)&&t.children.some(DD));"back"===i&&t>=0?o.splice(t,0,...e):o.push(...e)}return o.push(...n),o}function FD(t,e,n,i){const o=t._plotArea;if(!o)return e;const{state:r,axis:a}=n,s="x"===t.schema.discrete||"y"===t.schema.discrete,c=s&&t.schema.tooltipShared&&function(t){const e=n=>!n.interactionGroup&&!1!==n.interactive&&(!!aD(t,n)||!!n.children&&n.children.some(t=>e(t)));return(t._chartScene||[]).some(t=>e(t))}(t)?[{type:"rect",key:i("plot-hover-surface"),...o,interactionGroup:"axis",paint:{fill:"transparent"}}]:[];let l=e;const h=r&&s?function(t,e){const n=()=>e.px,i="x"===e.axis?n:t._xFunc,o="y"===e.axis?n:t._yFunc,r=t._plotAxisDomains?.x,a=t._plotAxisDomains?.y;if(!(i&&o&&r?.length&&a?.length))return null;const s="x"===e.axis?a:r,c=DA(LA(t,{shape:"Line",data:[s[0],s[s.length-1]].map(t=>"x"===e.axis?{x:e.value,y:t}:{x:t,y:e.value}),id:()=>"crosshair",...t._crosshairConfig},i,o,{x:r,y:a},0),"plot-crosshair");return c?zD(c):null}(t,r):null,u=a?zw(t,a):null,d=fy([...h?[h]:[],...u?u.guides:[]],i),f=fy(r&&s?function(t,e){if(t._lineMarkers||!e.markers.length)return[];const n=new Map(e.markers.map(t=>[t.datum,t])),i=Rm("Circle").renderMode("compute").data(e.markers.map(t=>t.datum)).config(t._lineMarkerConfig).x(t=>n.get(t).x).y(t=>n.get(t).y).id(t=>`${t.id}_shared`);return i.render(),[{type:"group",key:"plot-shared-markers",children:Im(i)}].map(zD)}(t,r):[],i);if(d.length||f.length){const t=r?r.layer:"back",e=l.findIndex(t=>t.key===i(Jz));if(e>=0){const n=l[e];l=[...l],l[e]={...n,children:LD(n.children||[],d,f,t)}}else l=LD(l,d,f,t)}const m=u?fy(u.badges,i):[];return[...c,...l,...m]}function ND(t,e){const n=t.schema.discrete;if("x"!==n&&"y"!==n&&!t._axisHoverState)return;const i=e.root.children.find(t=>"viz-chart-cells"===t.key),o=i&&i.children&&i.children[0],r=o&&o.children&&o.children[0];if(!r||!r.children)return;const a=t._facetPanels;r.children=a?r.children.map(e=>{const n=a.find(t=>t.key===e.key);return n?function(t,e,n){const i=e.children||[],o=i.findIndex(t=>t.key===`${n.key}/cells`),r=i[o],a=r&&r.children&&r.children[0];if(!r||!a||!a.children)return e;const s=t._sharedHoverState,c=t._axisHoverState,l=Zl(t,n,()=>FD(t,a.children,{state:s&&s.panel===n.key?s:null,axis:c&&c.panel===n.key?c:null},t=>`${n.key}/${t}`)),h=[...i];return h[o]={...r,children:[{...a,children:l},...r.children.slice(1)]},{...e,children:h}}(t,e,n):e}):FD(t,r.children,{state:t._sharedHoverState,axis:t._axisHoverState},t=>t)}const BD=/^plot-(x|x2|y|y2)-axis$/;function ED(t,e){if(t.schema[`${e}Sort`])return!0;if(Qw(t,e))return!1;const n=t[`_${e}Time`];return t.schema.discrete===e.charAt(0)&&!n}function RD(t){let e,n;for(const i of t)for(const t of i)null==t||Number.isNaN(+t)||((void 0===e||+t<+e)&&(e=t),(void 0===n||+t>+n)&&(n=t));return void 0===e||void 0===n?void 0:[e,n]}function PD(t,e){t._filteredData=e;const n=_t({viz:t},[JC,t$,mC,yC]);return{formatted:n.plotFormattedData||[],domains:n.plotInitialDomains||{},positions:n.plotStackPositions}}function TD(t,e){if(!t.schema.stacked)return nC(t,void 0);const n=e.filter(t=>t.length).map(e=>PD(t,e).positions).filter(t=>void 0!==t);nC(t,QS(n))}function OD(t,e){const n=e.filter(t=>t.length).map(e=>PD(t,e)),i=n.flatMap(t=>t.formatted),o=_t({viz:t,plotFormattedData:i,plotAxisData:i},[t$]),r={};for(const e of SM)if(n.some(t=>t.domains[e]))if(ED(t,e)){const t=o[`${e}Data`];t&&t.length&&(r[e]=t)}else{const t=RD(n.map(t=>t.domains[e]||[]));t&&(r[e]=t)}const a=t._size?i.map(e=>t._size(e.data)):[],s=a.length?UC(t,a):void 0;return{domains:r,size:s,padded:WD(t,i,r,s)}}function WD(t,e,n,i){const o=t._sizeScaleD3;i&&(t._sizeScaleD3=i);const r=_t({viz:t,plotFormattedData:e,plotAxisData:e,plotInitialDomains:{...n}},[AS,e$]);t._sizeScaleD3=o;const a={},s=r.plotScales;if(!s)return a;for(const t of SM){const e=s[t];e&&"function"==typeof e.invert&&(a[t]=e.domain())}return a}function HD(t,e){const n=t||{};return{...n,labels:e?n.labels:[],title:!!e&&n.title}}function jD(t,e){t&&t.config({labels:e?.labels,title:e?.title})}function ID(t,e){const n={scales:t._plotFacetScales,x:t._xConfig,y:t._yConfig};return t._plotFacetScales=e.shared?e.scales:void 0,t._xConfig=HD(n.x,e.labels.x),t._yConfig=HD(n.y,e.labels.y),()=>{t._plotFacetScales=n.scales,t._xConfig=n.x,t._yConfig=n.y,jD(t._xAxis,n.x),jD(t._yAxis,n.y)}}function GD(t){const e=t._plotArea,n=t._chartTransform;if(!e||!n)return{top:0,right:0,bottom:0,left:0};const i=e.x+(n.x??0),o=e.y+(n.y??0);return{top:o-t._margin.top,right:t.schema.width-t._margin.right-(i+e.width),bottom:t.schema.height-t._margin.bottom-(o+e.height),left:i-t._margin.left}}const qD={aspect:4/3,chrome:TD,share:OD,panel:ID,insets:GD,capture:t=>({_plotArea:t._plotArea,_plotAxisDomains:t._plotAxisDomains,_xFunc:t._xFunc,_yFunc:t._yFunc,_trendFits:t._trendFits,_barSpans:t._barSpans})},VD=t=>Array.isArray(t)?t.map(VD).join(""):t instanceof Date?+t:t;function YD(t,e){const{aggs:i,id:o,position:r,threshold:a,value:s}=e,c=Math.min(1,Math.max(0,+a(t)));if(!(c>0))return null;const l=new Map,h=new Map;let u=0;if(t.forEach((t,e)=>{const n=`${o(t,e)}`,i=Math.abs(+s(t,e))||0;l.set(n,(l.get(n)??0)+i);const r=h.get(n);r?r.push(t):h.set(n,[t]),u+=i}),!(u>0))return null;const d=new Set;if(l.forEach((t,e)=>{t<c*u&&d.add(e)}),d.size<2)return null;const f=function(t,e,i){const o=new Set;t.forEach(t=>t.forEach(t=>Object.keys(t).forEach(t=>o.add(t))));const r=Array.from(o).filter(n=>t.every(t=>{let i;return t.every((t,o)=>{const r=t[n];if("number"==typeof r)return!1;const a=VD(r);return!e.some(e=>VD(e(t,o))===a)&&(0===o&&(i=a),a===i)})})),a=t.filter(t=>t.length).map(t=>{const e={};for(const n of r)e[n]=t[0][n];return e});return n.merge(a,i)}(Array.from(d,t=>h.get(t)),r,i);return{members:d,percent:c,identity:f}}function KD(t,e,i){const{aggs:o,id:r,position:a}=i,s=i.label??r,c=i.measure??i.value,l=[],h=new Map;if(t.forEach((t,n)=>{if(!e.members.has(`${r(t,n)}`))return void l.push(t);const i=a.map(e=>`${VD(e(t,n))}`).join(""),o=h.get(i);o?o.push(t):h.set(i,[t])}),!h.size)return t;const u=Array.from(h.values(),t=>{const i=n.merge(t,o),l=t[0],h=a.map(t=>VD(t(l,0)));for(const e of Object.keys(l))h.some(n=>t.every(t=>VD(t[e])===n))&&(i[e]=l[e]);return{...i,...e.identity,_isAggregation:!0,_threshold:e.percent,[vl]:wl(t,r,s,c)}});return l.concat(u)}function UD(t){const e="y"===t.schema.discrete?"y":"x",n="x"===e?"y":"x",i=[t[`_${e}`]];return t.schema.time&&i.push(t.schema.time),{aggs:t.schema.aggs,id:t._id,label:t._drawLabel,measure:t[`_${n}`],position:i,threshold:t.schema.threshold,value:t.schema.thresholdKey??t[`_${n}`]}}function XD(t){const e=t?.domain;return Array.isArray(e)?{...t,domain:e.slice().reverse()}:t}class ZD extends cx{_preDraw(){["x","y","x2","y2"].forEach(t=>{if(this[`_${t}Key`]){const e=this[`_${t}Key`];this.schema.aggs[e]||this.schema.discrete!==t||(this.schema.aggs[e]=(t,e)=>{const n=Array.from(new Set(t.map(e)));return 1===n.length?n[0]:n}),e!==t&&this[`_${t}Title`]===this[`_${t}Config`].title&&this.schema.discrete!==t&&(this[`_${t}Title`]=e,this[`_${t}Config`].title=e)}}),super._preDraw()}_thresholdLegend(t){return function(t,e){if(!t.schema.stacked||!e.length)return e;const n=UD(t),i=YD(e,n);return i?KD(e,i,{...n,position:[]}):e}(this,t)}_thresholdFunction(t,e,n){return function(t,e,n=e){if(!t.schema.stacked)return e;const i=UD(t),o=YD(n,i);return o?KD(e,o,i):e}(this,t,n)}toScene(){const t=cx.prototype.toScene.call(this);if(Array.isArray(this._filteredData)&&0===this._filteredData.length&&(!this._annotations||0===this._annotations.length))return t;const e=[];for(const t of["_xAxis","_x2Axis","_yAxis","_y2Axis"]){const n=this[t];n&&"function"==typeof n.toScene&&n._select&&"function"==typeof n._select.node&&n._select.node()&&e.push({type:"group",key:`plot-${t}`,children:[n.toScene()]})}return t.root.children.unshift(...e),ND(this,t),t}_wirePlotShapeEvents(t,e,n){const i=n.filter(t=>t.includes(`.${e}`)),o=n.filter(t=>!t.includes(".")),r=n.filter(t=>t.includes(".shape")),a=t=>(e,n,i,o)=>this.schema.on[t](e.data,e.i,i,o);for(const e of o)t.on(e,a(e));for(const e of r)t.on(e,a(e));for(const e of i)t.on(e,a(e))}_interactionDatum(t,e){const n=t.node,i=n&&n.interactionPoints;if(n&&"legend"!==n.interactionGroup&&Array.isArray(i)&&i.length&&e&&Array.isArray(e.point)){const t=this._nearestInteractionPoint(i,e.point);if(t){const e=t.datum;return{d:e&&e.data?e.data:e,i:"number"==typeof e.i?e.i:t.index,x:e}}}return super._interactionDatum(t,e)}_pointMark(t){return ih(t)}_nearestInteractionPoint(t,e){const[n,i]=oD(this,e),o="y"===this.schema.discrete?"y":"x",r="y"===o?i:n;let a=null,s=1/0;for(const e of t){const t=Math.abs(e[o]-r);t<s&&(s=t,a=e)}return a}_sharedHover(t){fD(this,t),AD(this,t)}_draw(t){return P$(this,t)}_facetHooks(){return qD}_sizeLegendScale(){return function(t){if(!t._size)return null;const e=t._axisPersist?t._data:t._filteredData||[],n=[];let i=!1;return e.forEach((e,o)=>{VC(t._x(e,o))||VC(t._y(e,o))||(n.push(t._size(e,o)),ZC(t,t.schema.shape(e,o))&&(i=!0))}),i?UC(t,n):null}(this)}_insetRegion(){return function(t){const e=t._plotArea,n=t._chartTransform;return e&&n?Cp(t,{x:e.x+(n.x??0),y:e.y+(n.y??0),width:e.width,height:e.height},t=>BD.test(String(t.key))):null}(this)}_paint(t){const e=this,n=e._zoomEventTarget||e._container;return this._chartScene=nD(e,t,n&&n.node()?_.zoomTransform(n.node()):void 0),this}_zoomRescale(t,e=0){if(this._facetPanels)return!1;const n=function(t,e,n){clearTimeout(t._plotUnclipTimer);const i=t._chartScene?.find(t=>t.key===Jz),o="group"===i?.type&&!!i.clip&&n>0&&1===e.k&&!e.x&&!e.y,r=iD(t,e,o);return r&&o&&(t._plotUnclipTimer=setTimeout(()=>{const n=iD(t,e);n&&(t._chartScene=n,t._drawSceneToTarget(0))},n)),r}(this,t,e);return!!n&&(this._chartScene=n,!0)}annotations(t){return arguments.length?(this._annotations=t instanceof Array?t:[t],this):this._annotations}axisPersist(t){return arguments.length?(this._axisPersist=t,this):this._axisPersist}baseline(t){return arguments.length?(function(t,e){t._userBaseline=e===it||void 0===e?void 0:e}(this,t),this):(e=this)._userBaseline??e.schema.baseline;var e}backgroundConfig(t){return arguments.length?(this._backgroundConfig=ut(this,"backgroundConfig",t,this._backgroundConfig),this):this._backgroundConfig}buffer(t){if(arguments.length){if(t)if(!0===t)this._buffer=Mw;else{this._buffer=r.assign({},this._buffer,t);for(const t in this._buffer){const e=this._buffer;!0===e[t]&&(e[t]=Mw[t])}}else this._buffer={};return this}return this._buffer}confidence(t){if(!arguments.length)return this._confidenceBands&&this._confidenceBands.length>1?this._confidenceBands:this._confidence;const e=this._confidenceBands=rM(t);return this._confidence=!!e.length&&[e[0].lower,e[0].upper],this}confidenceConfig(t){return arguments.length?(e=It(this),(n=t)&&"object"==typeof n&&Object.getPrototypeOf(n)===Object.prototype&&bs(e,n,eM),this._confidenceConfig=ut(this,"confidenceConfig",t,this._confidenceConfig),this):this._confidenceConfig;var e,n}discreteCutoff(t){return arguments.length?(this._discreteCutoff=t,this):this._discreteCutoff}groupPadding(t){return arguments.length?(this._groupPadding=t,this):this._groupPadding}labelConnectorConfig(t){return arguments.length?(this._labelConnectorConfig=ut(this,"labelConnectorConfig",t,this._labelConnectorConfig),this):this._labelConnectorConfig}crosshairConfig(t){return arguments.length?(this._crosshairConfig=ut(this,"crosshairConfig",t,this._crosshairConfig),this):this._crosshairConfig}trendLine(t){return arguments.length?(this._trendLine=t,this):this._trendLine}trendLineConfig(t){return arguments.length?(this._trendLineConfig=ut(this,"trendLineConfig",t,this._trendLineConfig),this):this._trendLineConfig}lineMarkerConfig(t){return arguments.length?(this._lineMarkerConfig=ut(this,"lineMarkerConfig",t,this._lineMarkerConfig),this):this._lineMarkerConfig}lineMarkers(t){return arguments.length?(this._lineMarkers=t,this):this._lineMarkers}size(t){return arguments.length?(this._size="function"!=typeof t&&t?q(t):t,this._sizeKey="string"==typeof t?t:void 0,this):this._size}stackOffset(t){return arguments.length?(this._stackOffset=XS(t),this):this._stackOffset}stackOrder(t){return arguments.length?(this._stackOrder=VS(t),this):this._stackOrder}x(t){return arguments.length?("function"==typeof t?this._x=t:(this._x=q(t),this._xKey=t),this):this._x}x2(t){return arguments.length?("function"==typeof t?this._x2=t:(this._x2=q(t),this._x2Key=t),this):this._x2}xConfig(t){return arguments.length?(this._xConfig=ut(this,"xConfig",t,this._xConfig),this):this._xConfig}x2Config(t){return arguments.length?(this._x2Config=ut(this,"x2Config",t,this._x2Config),this):this._x2Config}y(t){return arguments.length?("function"==typeof t?this._y=t:(this._y=q(t),this._yKey=t),this):this._y}y2(t){return arguments.length?("function"==typeof t?this._y2=t:(this._y2=q(t),this._y2Key=t),this):this._y2}yConfig(t){return arguments.length?(this._yConfig=ut(this,"yConfig",XD(t),this._yConfig),this):this._yConfig}y2Config(t){return arguments.length?(this._y2Config=ut(this,"y2Config",XD(t),this._y2Config),this):this._y2Config}constructor(){var t;super(),this._trendLine=n$.defaults.trendLine,this._trendLineConfig={confidence:!1,confidenceConfig:{fillOpacity:.15},confidenceLevel:.95,group:"series",label:"equation",order:2,projection:0,projectionConfig:{strokeDasharray:"2 4"},strokeDasharray:"6 4",strokeWidth:2,tooltip:!0},xt(this,h$),u$(this),(t=this)._x=I("x"),t._xKey="x",t._xAxis=(new Do).align("end"),t._xConfig={gridConfig:{stroke:e=>{if("x"===t.schema.discrete?.charAt(0)||"x"===t._swarm?.cross)return"transparent";const n=t._xAxis.range(),i=t._xAxis._getPosition.bind(t._xAxis)(e.id);return n[0]===i?"transparent":Hs(t)}}},t.schema.xCutoff=150,t._x2=I("x2"),t._x2Key="x2",t._x2Axis=(new No).align("start"),t._x2Config={},t._y=I("y"),t._yKey="y",t._yAxis=(new Lo).align("start"),t._yKey="y",t._yConfig={gridConfig:{stroke:e=>{if("y"===t.schema.discrete?.charAt(0)||"y"===t._swarm?.cross)return"transparent";const n=t._yAxis.range(),i=t._yAxis._getPosition.bind(t._yAxis)(e.id);return n[n.length-1]===i?"transparent":Hs(t)}}},t.schema.yCutoff=150,t._y2=I("y2"),t._y2Key="y2",t._y2Axis=(new Fo).align("end"),t._y2Config={}}}ZD._displayName="Plot",dt(ZD.prototype,"backgroundConfig","baseline","confidenceConfig","crosshairConfig","labelConnectorConfig","lineMarkerConfig","trendLineConfig","xConfig","x2Config","yConfig","y2Config");var QD=lx({name:"AreaPlot",paintDriven:!0,ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:H("Area"),coerce:"const"}]},ZD);function JD(t){const e=[()=>t.schema.translate("Share"),(e,n,i)=>{const o=bl(i);let r=yl(o);if(!Number.isFinite(r)){const e=t["_"+("y"===t.schema.discrete?"x":"y")];r=o?_l(o,t._legendData||[],e):NaN}return Number.isFinite(r)?`${d.formatAbbreviate(100*r,t.schema.locale)}%`:""}];return{tbody:()=>t.schema.stacked?[e]:[]}}const tL={name:"BarChart",paintDriven:!0,ctx:{},fields:[{key:"barWidth",coerce:Up},{key:"barWidthShare",default:!1},{key:"barWidthShareFormat"},{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},{key:"shape",default:H("Bar"),coerce:"const"},{key:"tooltipConfig",merge:!0,factory:function(t){const e=JD(t);return{tbody:n=>[...cg(t,n),...e.tbody()]}}},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{if(t._legendCategories)return e.call(t,n,i);return i.map(t.schema.groupBy[t._legendDepth].bind(t)).sort().join()!==t._filteredData.map(t.schema.groupBy[t._legendDepth].bind(t)).sort().join()&&e.call(t,n,i)}}}]};var eL=lx(tL,ZD);const nL={name:"Beeswarm",paintDriven:!0,ctx:{},fields:[{key:"shapeConfig",merge:!0,default:{Circle:{label:!1,trail:!1}}},{key:"swarm",default:!0}]};var iL=lx(nL,ZD);const oL=new WeakMap;function rL(t,e){for(;t.__d3plus__&&t.data;)e=t.i,t=t.data;return[t,e]}function aL(t){const e=t.schema.shapeConfig||{},n=(e.Box||{}).whiskerMode??e.whiskerMode;return void 0===n?["tukey","tukey"]:Wa(n)}function sL(t,e,n){if(!e)return[];const i=e=>void 0===e?"":d.formatAbbreviate(e,t.schema.locale),o=e=>t.schema.translate(e),[r,a]=rL(e,n);if(Xa(t.schema)){const e=es(t.schema,r,a);return e?[[o("Maximum"),i(e.max)],[o("Upper Quartile"),i(e.q3)],[o("Median"),i(e.median)],[o("Lower Quartile"),i(e.q1)],[o("Minimum"),i(e.min)]]:[]}const s=function(t,e){const n=oL.get(e);if(!n)return null;const i="vertical"===n.orient,o=n.values.map(t=>{const e=i?t.y2??t.y:t.x2??t.x;return"number"==typeof e||e instanceof Date?+e:NaN}).filter(Number.isFinite).sort((t,e)=>t-e);return o.length?Ha(o,aL(t)):null}(t,r);if(!s)return[];const c=aL(t);return[["extent"===c[1]?"Maximum":"Upper Whisker",s.upperLimit],["Upper Quartile",s.third],["Median",s.median],["Lower Quartile",s.first],["extent"===c[0]?"Minimum":"Lower Whisker",s.lowerLimit]].filter(([,t])=>void 0!==t).map(([t,e])=>[o(t),i(e)])}const cL=t=>"y"===t.schema.discrete?"x":"y";function lL(t){const e=Hm(t,"Box").outlier;return"function"==typeof e?e:void 0===e||Oa(e)?null:()=>e}const hL=(t,e)=>{const n=t[e];return"number"==typeof n||n instanceof Date?+n:NaN};function uL(t,e,n){if(Xa(t.schema)||n.charAt(0)!==cL(t))return e;const i=lL(t);return i?function(t,e){const n=t.schema.discrete,i="function"==typeof t.schema.facet?t.schema.facet:void 0;return h.groups(e,t=>i?`${t[n]}\0${i(t.data,t.i)}`:`${t[n]}`).map(([,t])=>t)}(t,e).flatMap(e=>function(t,e,n,i){const o=e.map(t=>hL(t,n)).filter(Number.isFinite).sort((t,e)=>t-e);if(!o.length)return e;const{lowerLimit:r,upperLimit:a}=Ha(o,aL(t)),s=e.filter(t=>{const e=hL(t,n);return!(e<r||e>a)||Oa(i(t,t.i))});if(s.length===e.length)return e;const c=e[0][n]instanceof Date,l=[r,a].filter(t=>Number.isFinite(t)).map(t=>({...e[0],[n]:c?new Date(t):t}));return s.concat(l)}(t,e,n,i)):e}const dL=t=>Xa(t.schema);function fL(t){const e=function(t){const e=lL(t);return t=>!e||Oa(e(t,t.i))}(t);return n=>function(t,e,n,i=!0){const o=[];for(const i of Ka){const r=t[i],a="function"==typeof r?Ja(r(e,n)):NaN;Qa(a)&&o.push(a)}return i?o.concat(ts(t,e,n)):o}(t.schema,n.data,n.i,e(n))}function mL(t){const e=_w,n=this,i=cL(this);if(!dL(this)){const o=uL(this,t.data,t.x2?`${i}2`:i);return e.call(n,{...t,data:o})}if(t.x2)return e.call(n,t);const o=fL(this),r=t.data.flatMap(t=>o(t).map(e=>({...t,[i]:e})));return e.call(n,{...t,data:r})}function pL(t,e){const n=t=>"number"==typeof t||t instanceof Date?e(t):NaN;return e=>{const i=t(e.data,e.i);return Array.isArray(i)?i.map(n):n(i)}}const gL=(t,e)=>{const{viz:n}=t;if(!dL(n))return function(t){const e=t=>{for(const n of t){"group"===n.type&&e(n.children);for(const t of n.owners||[])"Box"===t.shapeType&&t.datum&&oL.set(rL(t.datum,t.index)[0],t.datum)}};return e(t),t}(Dz(t,e));const i="y"===cL(n)?t.y:t.x,o={};for(const t of[...Ka,"boxOutliers"]){const e=n.schema[t];"function"==typeof e&&(o[t]=pL(e,i))}return Dz({...t,shapeConfig:{...t.shapeConfig,...o}},e)};var yL=lx({name:"BoxWhisker",paintDriven:!0,setup:t=>{t._buffer={...t._buffer,Box:mL},t._plotShapeEmitters={Box:gL},t._plotAxisValues=(e,n)=>function(t,e,n){return dL(t)&&n===cL(t)?e.flatMap(fL(t)):[]}(t,e,n),t._plotAxisRows=(e,n)=>uL(t,e,n)},ctx:{},fields:[{key:"boxMax",coerce:Ua},{key:"boxMedian",coerce:Ua},{key:"boxMin",coerce:Ua},{key:"boxOutliers",coerce:Ua},{key:"boxQ1",coerce:Ua},{key:"boxQ3",coerce:Ua},{key:"discrete",default:"x"},{key:"shape",default:H("Box"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>{const e=()=>J(t._theme,t=>t.text,"black");return{Box:{whiskerConfig:{lineConfig:{stroke:e},endpointConfig:{fill:e}}}}}},{key:"tooltipShared",default:!1},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>{if(!e)return"";for(;e.__d3plus__&&e.data;)n=(e=e.data).i;const i=t.schema.label;if(i)return i(e,n);const o=t._drawDepth+(dL(t)?1:0),r=t._ids(e,n).slice(0,o);return r[r.length-1]},tbody:(e,n)=>sL(t,e,n)})}]},ZD);const xL={name:"Scatter",paintDriven:!0,ctx:{},fields:[{key:"shape",default:H("Circle"),coerce:"const"}]};var bL=lx(xL,ZD);const _L=t=>String(t.key).split("::")[0];function kL(t){const e=new Map;for(const n of t)"circle"===n.type&&e.set(String(n.key),n.r);const n=[];t.forEach((t,i)=>{e.has(_L(t))&&n.push(i)});const i=n.map(n=>({node:t[n],r:e.get(_L(t[n]))})).sort((t,e)=>t.r===e.r?0:t.r<e.r?1:-1),o=t.slice();return n.forEach((t,e)=>o[t]=i[e].node),o}const vL=(t,e)=>kL(Nz.Circle(t,e)),wL={name:"BubbleChart",paintDriven:!0,setup:t=>{t._plotShapeEmitters={...t._plotShapeEmitters,Circle:vL}},ctx:{},fields:[{key:"sizeMax",default:40},{key:"sizeScale",default:"sqrt"},{key:"sizeZero",default:!0},{key:"shapeConfig",merge:!0,factory:t=>({Circle:{stroke:()=>Os(t),strokeWidth:H(1)}})}]};var ML=lx(wL,bL);const SL=t=>t*Math.PI/180,CL=t=>180*t/Math.PI;function $L(t,e,n,i){const[o,r]=e,a=r-o,s=Number.isFinite(t)&&a?(t-o)/a:0;return n+Math.max(0,Math.min(1,s))*(i-n)}function AL(t,e=[],n=void 0,i=10){const o=[0,...t,...e.flatMap(t=>[t.min,t.max])].filter(t=>"number"==typeof t&&Number.isFinite(t)),[r,a]=n??[],s=Number.isFinite(r)?r:Math.min(...o);let l=Number.isFinite(a)?a:Math.max(...o);l>s||(l=s+1);const[h,u]=c.scaleLinear().domain([s,l]).nice(i).domain();return[Number.isFinite(r)?s:h,Number.isFinite(a)?l:u]}function zL(t,e){return Math.max(2,Math.round(Math.abs(CL(e-t))/45))}function DL(t,e,n,i){const[o,r]=t,a=r-o;if(!1===e)return{major:[],minor:[]};const s=c.scaleLinear().domain(t),l="number"==typeof e?Math.max(1,e):i;let h;if(Array.isArray(e))h=e.filter(t=>Number.isFinite(t)&&t>=o&&t<=r).sort((t,e)=>t-e);else{const t=s.ticks(l),e=t.length>1?t[1]-t[0]:a;h=[o,...t.filter(t=>t-o>=e/2&&r-t>=e/2),r]}const u=n?s.ticks(Math.max(1,5*(h.length-1||l))).filter(t=>t>o&&t<r&&!h.some(e=>((t,e,n)=>Math.abs(t-e)<=1e-9*n)(e,t,a))):[];return{major:h,minor:u}}function LL(t,e,n){const[i,o]=e,r=[];let a=i;for(const e of t??[]){if(!e)continue;const t=f.clamp(Number.isFinite(e.min)?e.min:a,i,o),s=f.clamp(Number.isFinite(e.max)?e.max:o,i,o);a=s,s>t&&r.push({min:t,max:s,color:e.color??n})}return r}function FL(t,e){const n=Math.min(t,e),i=Math.max(t,e),o=[n,i],r=Math.PI/2;for(let t=Math.ceil(n/r);t*r<=i;t++)o.push(t*r);const a=[0,...o.map(t=>Math.sin(t))],s=[0,...o.map(t=>-Math.cos(t))];return{x0:Math.min(...a),x1:Math.max(...a),y0:Math.min(...s),y1:Math.max(...s)}}function NL(t,e){return{x0:Math.min(t.x0,e.x0),x1:Math.max(t.x1,e.x1),y0:Math.min(t.y0,e.y0),y1:Math.max(t.y1,e.y1)}}function BL(t,e,n){const i=n.x1-n.x0||1,o=n.y1-n.y0||1,r=Math.max(0,Math.min(t/i,e/o));return{cx:t/2-(n.x0+n.x1)/2*r,cy:e/2-(n.y0+n.y1)/2*r,radius:r}}function EL(t,e,n){const i=.2*e,o=.7*e;return`M${-e},0L${-i},${-t}L${i},${-t}L${e},0L${o},${n}L${-o},${n}Z`}function RL(t,e){const{indicator:n,hasBands:i,hasValue:o,extent:r}=e,a=e.hasName&&o,s="progress"!==n,c=function(t,e,n,i){const o=i?Math.max(1,n):1,r=o>1?Math.max(2,.02*t):0;let a=t*e;return o>1&&o*a+(o-1)*r>.5*t&&(a=Math.max(1,(.5*t-(o-1)*r)/o)),Array.from({length:o},(e,n)=>{const i=t-n*(a+r);return{inner:Math.max(0,i-a),outer:i}})}(t,f.clamp(e.thickness,.02,1),e.rows,!s),l=t,h=c[c.length-1].inner,u=s?l:h-.025*t,d=s?h:u-Math.max(2,.035*t),m=(s||!i?h:d)-.03*t,p=.07*t,g=e.tickFontSize??f.clamp(.075*t,8,16),y=m-p-.03*t-.8*g,x=Math.max(3,.055*t),b=o?f.clamp(t*(s?.2:.3),10,72):0,_=a?f.clamp(.085*t,9,20):0,k=.03*t,v=b+(a?k+_:0);let w;w=s?x+.06*t:r.y1>=.3?-v/2:-v-k;const M=w+b/2;return{outer:l,inner:h,rings:c,bandOuter:u,bandInner:d,tickOuter:m,majorLength:p,minorLength:p/2,tickLabelRadius:y,tickFontSize:g,hubRadius:x,needleLength:(h+l)/2,needleHalfWidth:Math.max(2,.03*t),needleTail:.12*t,valueY:M,valueFontSize:b,valueMaxWidth:Math.max(0,y)*(s?1.3:1.6),nameY:M+b/2+k+_/2,nameFontSize:_,nameMaxWidth:1.2*t}}function PL(t,e,n){if(t.schema.label)return!0;return(t.schema.groupBy??[]).some(t=>void 0!==t(e,n))}function TL(t){const e=t.schema.axisConfig??{},n=e.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?n:void 0}const OL=({viz:t})=>{const{width:e,height:n}=kt(t),i=t._filteredData??[],o=t.schema.value,r=i.map((t,e)=>Number(o(t,e))),a=Array.isArray(t.schema.bands)?t.schema.bands:[],s=SL(Number(t.schema.startAngle)||0),c=SL(Number(t.schema.endAngle)||0),l=t.schema.ticks,h="number"==typeof l?l:zL(s,c),u=AL(r,a,t.schema.domain,h),d=LL(a,u,t.schema.colorDefaults?.missing??"#ced4da"),f=DL(u,l,!1!==t.schema.minorTicks,h),m=1===i.length,p={indicator:"progress"===t.schema.indicator?"progress":"needle",thickness:Number(t.schema.thickness)||.2,hasBands:d.length>0,rows:i.length,hasValue:m,hasName:m&&PL(t,i[0],0),extent:FL(s,c),tickFontSize:TL(t)},g=BL(Math.max(0,e-4),Math.max(0,n-4),function(t){const e=100,n=RL(e,t);if(!n.valueFontSize){const i="progress"===t.indicator?0:n.needleTail/e;return NL(t.extent,{x0:0,x1:0,y0:0,y1:i})}const i=(n.nameFontSize?n.nameY+n.nameFontSize/2:n.valueY+n.valueFontSize/2)/e,o=(n.valueY-n.valueFontSize/2)/e,r="progress"===t.indicator?0:n.needleTail/e;return NL(t.extent,{x0:-.5,x1:.5,y0:Math.min(o,0),y1:Math.max(i,r)})}(p)),y=i.map((t,e)=>({__d3plus__:!0,data:t,i:e,value:r[e],angle:$L(r[e],u,s,c)}));return t.ctx.gauge={cx:g.cx+2,cy:g.cy+2,radius:g.radius,domain:u,start:s,end:c,ticks:f,bands:d,dial:p},{shapeData:y}};function WL(t){if(!Array.isArray(t))return[];const e=[];let n=!1;for(const i of t)"number"==typeof i?Number.isFinite(i)&&(e.push({max:i}),n=!0):i&&"object"==typeof i&&e.push({...i});const i=e[e.length-1];return n&&i&&void 0!==i.max&&e.push({}),e}function HL(t,e,n){const i=[...t,...e.flatMap(t=>[t.min,t.max])].filter(t=>"number"==typeof t&&Number.isFinite(t));return{extent:i.length?[Math.min(...i),Math.max(...i)]:[],input:n}}function jL(t,e=5){return AL(t.extent,[],t.input,e)}function IL(t,e,n,i,o){const r=e[1]-e[0]||1;return t.every((e,a)=>{if(!a)return!0;return(e-t[a-1])/r*n>=(i(e)+i(t[a-1]))/2+o})}function GL(t,e,n,i,o=70,r=8){if(!1===e)return{domain:jL(t),ticks:[]};if(Array.isArray(e)){const n=jL(t);return{domain:n,ticks:DL(n,e,!1,5).major}}if("number"==typeof e){const n=Math.max(1,e),i=jL(t,n);return{domain:i,ticks:DL(i,n,!1,n).major}}const a=Math.max(1,Math.floor(Math.max(0,n)/o));let s={domain:jL(t,1),ticks:[]};for(let e=a;e>=1;e--){const o=jL(t,e),a=DL(o,e,!1,e).major;if(s={domain:o,ticks:a},IL(a,o,n,i,r))return s}return{domain:s.domain,ticks:s.domain.slice()}}function qL(t,e){const n=function(t,e){const[n,i]=e,o=i-n;return Number.isFinite(t)&&o?Math.max(0,Math.min(1,(t-n)/o)):0}(e,t.domain),{band:i}=t;return"vertical"===t.orient?i.y+i.height*(1-n):i.x+i.width*n}function VL(t){const[e,n]=t;return Math.max(e,Math.min(n,0))}function YL(t,e,n,i){const{band:o}=t,r=qL(t,e),a=qL(t,n),s=Math.min(r,a),c=Math.abs(a-r),l=Math.max(0,Math.min(1,i));if("vertical"===t.orient){const t=o.width*l;return{x:o.x+(o.width-t)/2,y:s,width:t,height:c}}const h=o.height*l;return{x:s,y:o.y+(o.height-h)/2,width:c,height:h}}function KL(t,e,n){const i=qL(t,e);return"vertical"===t.orient?{...n,y:i,height:0}:{...n,x:i,width:0}}function UL(t,e,n){const{band:i}=t,o=qL(t,e),r=Math.max(0,Math.min(1,n));if("vertical"===t.orient){const t=i.width*(1-r)/2;return[[i.x+t,o],[i.x+i.width-t,o]]}const a=i.height*(1-r)/2;return[[o,i.y+a],[o,i.y+i.height-a]]}function XL(t){return t.axis?"vertical"===t.orient?7+t.tickLabelWidth:7+t.tickFontSize:0}function ZL(t){return t.count>0&&t.width>0&&t.height>0?"vertical"===t.orient?function(t){const{width:e,height:n,count:i,labelHeight:o}=t,r=XL(t),a="row"===t.axis?r:0,s="shared"===t.axis?r:0,c=o?o+12:0,l=t.axis?t.tickFontSize/2:0,h=2+c+l,u=Math.max(0,n-h-Math.max(2,l)-2),d=Math.max(0,e-s-4),m=d/i,p=Math.min(Math.max(0,m-a),f.clamp(.45*(m-a),4,t.bulletSize)),g=a+p,y=Math.min(m,Math.max(g+Math.max(16,p),t.labelWidth+12)),x=2+s+(d-y*i)/2;return Array.from({length:i},(e,n)=>{const i=x+n*y,o=i+(y-p)/2+a/2;return{band:{x:o,y:h,width:p,height:u},label:{x:o+p/2,y:2,anchor:"middle",maxWidth:Math.max(0,y-8)},axis:"row"===t.axis||"shared"===t.axis&&0===n,hit:{x:i,y:2,width:y,height:h+u-2}}})}(t):function(t){const{width:e,height:n,count:i,labelHeight:o}=t,r=XL(t),a="row"===t.axis?r:0,s="shared"===t.axis?r:0,c=Math.min(t.labelWidth,.35*e),[l,h]=t.axis?t.tickOverhang:[0,0],u=c?2+c+Math.max(12,l):2+l,d=Math.max(0,e-u-2-h),m=Math.max(0,n-s-4),p=m/i,g=Math.min(Math.max(0,p-a),f.clamp(.62*(p-a),4,t.bulletSize)),y=g+a,x=Math.max(12,.6*g),b=Math.min(p,Math.max(y,o)+x),_=Math.max(0,(o-g)/2),k=b*(i-1)+y,v=2+Math.max(_,(m-k)/2);return Array.from({length:i},(e,n)=>{const r=v+n*b,a={x:u,y:r,width:d,height:g},s=Math.min(r,r+g/2-o/2);return{band:a,label:{x:2+c,y:r+g/2,anchor:"end",maxWidth:c},axis:"row"===t.axis||"shared"===t.axis&&n===i-1,hit:{x:0,y:s,width:u+d,height:Math.max(r+y,r+g/2+o/2)-s}}})}(t):[]}function QL(t,e){const n=function(t,e=.36,n=.12){if(t<=0)return[];if(1===t)return[(e+n)/2];const i=(e-n)/(t-1);return Array.from({length:t},(t,n)=>e-n*i)}(t.length);return t.map((t,i)=>t.color?t:{...t,color:e(n[i])})}function JL(t,e,n){if("function"!=typeof t)return NaN;const i=t(e,n);return null==i||""===i?NaN:Number(i)}function tF(t,e,n){return t._ids(e,n).join("-")}function eF(t,e,n){const i=t.schema.bands;return WL("function"==typeof i?i(e,n):i)}function nF(t,e,n){return[JL(t.schema.value,e,n),JL(t.schema.target,e,n),JL(t.schema.forecast,e,n)]}function iF(t,e){const n=!!t.schema.sharedDomain,i=new Map;return e.forEach((e,o)=>{const r=n?"*":tF(t,e,o),a=HL(nF(t,e,o),eF(t,e,o),function(t,e,n){const i=t.schema.domain,o="function"==typeof i?i(e,n):i;return Array.isArray(o)?o:void 0}(t,e,o)),s=i.get(r);var c,l;i.set(r,s?(l=a,HL([...(c=s).extent,...l.extent],[],c.input)):a)}),i}const oF=(t,e,n,i=400)=>t?r.textWidth(t,{"font-family":e,"font-size":n,"font-weight":i}):0;function rF(t,e,n,i){const o=t.ctx.bulletFacet,r=t.schema.sharedDomain?"*":tF(t,n,i);return o?.get(r)??e.get(r)??{extent:[],input:void 0}}function aF(t,e){const n=t.some(t=>t.name),i=t.some(t=>t.subLabel);return{labelWidth:Math.max(0,...t.map(t=>oF(t.name,e,13,600)),...t.map(t=>oF(t.subLabel,e,11))),labelHeight:(n?13:0)+(i?11+(n?2:0):0)}}const sF=({viz:t})=>{const{width:n,height:i}=kt(t),o=t._filteredData??[],r="vertical"===t.schema.orient?"vertical":"horizontal",a=function(t,n,i){const o=(t.schema.axisConfig??{}).shapeConfig??{},r=o.labelConfig??{},a=Os(t),c=e.colorContrast(a,t.schema.colorDefaults),l=b.interpolateRgb(a,c),h=Pm(r.fontColor,n,i)??c,u=Pm(r.fontFamily,n,i)??t.schema.fontFamily,d=Pm(r.fontSize,n,i),f=t.schema.tickFormat;return{background:a,mix:l,trackFill:Pm(o.fill,n,i)??l(.08),tickStroke:Pm(o.stroke,n,i)??l(.55),tickStrokeWidth:Pm(o.strokeWidth,n,i)??1,fontColor:h,mutedColor:b.interpolateRgb(a,h)(.68),fontFamily:s.fontFamilyStringify(u),tickFontSize:"number"==typeof d&&d>0?d:10,tickFormat:t=>`${f(t)}`}}(t,o[0]??{},0),c=a.fontFamily,l=function(t,e){const n=t.schema.subLabel,i=iF(t,e);return e.map((e,o)=>{const r="function"==typeof n?n(e,o):void 0,[a,s,c]=nF(t,e,o);return{d:e,i:o,value:a,target:s,forecast:c,name:PL(t,e,o)?`${t._drawLabel(e,o)??""}`:"",subLabel:null==r?"":`${r}`,extent:rF(t,i,e,o)}})}(t,o),h=t.schema.ticks,u=t=>oF(a.tickFormat(t),c,a.tickFontSize),d=l.map(t=>jL(t.extent,10)),f=ZL({orient:r,width:n,height:i,count:l.length,bulletSize:Math.max(1,Number(t.schema.bulletSize)||1),...aF(l,c),axis:!1!==h&&(t.schema.sharedDomain?"shared":"row"),tickFontSize:a.tickFontSize,tickLabelWidth:Math.max(0,...d.flatMap(t=>DL(t,10,!1,10).major.map(u))),tickOverhang:[Math.max(0,...d.map(t=>u(t[0])/2)),Math.max(0,...d.map(t=>u(t[1])/2))]}),m="vertical"===r,p=f.map((e,n)=>{const i=l[n],o=GL(i.extent,h,m?e.band.height:e.band.width,m?()=>1.2*a.tickFontSize:u,m?45:70);return{__d3plus__:!0,data:i.d,i:i.i,key:tF(t,i.d,i.i),value:i.value,target:i.target,forecast:i.forecast,name:i.name,subLabel:i.subLabel,track:{orient:r,band:e.band,domain:o.domain},bands:LL(QL(eF(t,i.d,i.i),a.mix),o.domain,a.mix(.2)),ticks:e.axis?o.ticks:[],axis:e.axis,label:e.label,hit:e.hit}});return t.ctx.bullet={orient:r,style:a,nameFontSize:13,subFontSize:11},{shapeData:p}};function cF(t,e,n){return{type:"path",key:t,interactive:!1,d:a.arcPath(e),arc:e,paint:{fill:n}}}function lF(t,e,n,i,o=8,a=400){const s=(t,n)=>r.textWidth(t,{"font-family":e,"font-size":n,"font-weight":a});let c=s(t,n);c>i&&c>0&&(c=s(t,n=Math.max(o,n*i/c)));let l=t;for(;c>i&&l.length>1;)if(l=l.slice(0,-1),c=s(`${l.trimEnd()}…`,n),c<=i)return{text:`${l.trimEnd()}…`,size:n,width:c};return{text:l,size:n,width:c}}function hF(t,e,n,i,o){return{type:"text",key:t,interactive:!1,x:0,y:0,transform:{x:n,y:i},lines:[{text:e,x:0,y:0,width:o.width??r.textWidth(e,{"font-family":o.family,"font-size":o.size})}],font:{family:o.family,size:o.size,weight:o.weight??400,anchor:"middle",baseline:"middle"},paint:{fill:o.color}}}function uF(t,e,n){return t.map(t=>{const i=Math.sin(t),o=Math.cos(t);return`M${e*i},${-e*o}L${n*i},${-n*o}`}).join("")}function dF(t,e,n,i){const{domain:o,start:r,end:a,ticks:s,bands:c}=n,l=t=>$L(t,o,r,a),h=e.rings.map((e,n)=>cF(`${t}-track-${n}`,{innerRadius:e.inner,outerRadius:e.outer,startAngle:r,endAngle:a},i.trackFill));c.forEach((n,i)=>h.push(cF(`${t}-band-${i}`,{innerRadius:e.bandInner,outerRadius:e.bandOuter,startAngle:l(n.min),endAngle:l(n.max)},n.color)));const u={fill:"none",stroke:i.tickStroke,strokeLinecap:"round"};return s.minor.length&&h.push({type:"path",key:`${t}-minor-ticks`,interactive:!1,d:uF(s.minor.map(l),e.tickOuter,e.tickOuter-e.minorLength),paint:{...u,strokeWidth:i.tickStrokeWidth/2,strokeOpacity:.75}}),s.major.length&&h.push({type:"path",key:`${t}-major-ticks`,interactive:!1,d:uF(s.major.map(l),e.tickOuter,e.tickOuter-e.majorLength),paint:{...u,strokeWidth:i.tickStrokeWidth}}),e.tickLabelRadius>0&&s.major.forEach((n,o)=>{const r=l(n),a=e.tickLabelRadius;h.push(hF(`${t}-tick-${o}`,i.tickFormat(n),a*Math.sin(r),-a*Math.cos(r),{size:e.tickFontSize,family:i.fontFamily,color:i.fontColor}))}),h}function fF(t,e,n,i,o){const r=[];if(i){const o=lF(i,n.fontFamily,e.valueFontSize,e.valueMaxWidth,8,600);r.push(hF(`${t}-value`,o.text,0,e.valueY,{size:o.size,family:n.fontFamily,color:n.fontColor,weight:600,width:o.width}))}if(o&&e.nameFontSize){const i=lF(o,n.fontFamily,e.nameFontSize,e.nameMaxWidth);r.push(hF(`${t}-name`,i.text,0,e.nameY,{size:i.size,family:n.fontFamily,color:n.fontColor,width:i.width}))}return r}function mF(t,e,n,i,o){return{type:"text",key:t,x:0,y:0,transform:{x:n,y:i},lines:[{text:e,x:0,y:0,width:o.width}],font:{family:o.family,size:o.size,weight:o.weight??400,anchor:o.anchor,baseline:"middle"},paint:{fill:o.color}}}function pF(t,e,n){const{track:i}=t,[o,r]=i.domain,a=VL(i.domain),s=(t,e,n,o)=>{const r=YL(i,e,n,1);return((t,e,n,i)=>({type:"rect",key:t,interactive:!1,...e,enterRect:i,paint:{fill:n}}))(t,r,o,KL(i,a,r))},c=[s(`${e}-track`,o,r,n.trackFill)];if(t.bands.forEach((t,n)=>c.push(s(`${e}-band-${n}`,t.min,t.max,t.color))),!t.ticks.length)return c;const l="vertical"===i.orient,{band:h}=i,u=l?h.x:h.y+h.height,d=t.ticks.map(t=>{const e=qL(i,t);return l?`M${u-4},${e}L${u},${e}`:`M${e},${u}L${e},${u+4}`}).join("");c.push({type:"path",key:`${e}-ticks`,interactive:!1,d:d,paint:{fill:"none",stroke:n.tickStroke,strokeWidth:n.tickStrokeWidth}});return t.ticks.forEach((t,o)=>{const r=qL(i,t),a=lF(n.tickFormat(t),n.fontFamily,n.tickFontSize,1/0);c.push({...mF(`${e}-tick-${o}`,a.text,l?u-7:r,l?r:u+7+n.tickFontSize/2,{size:n.tickFontSize,family:n.fontFamily,color:n.fontColor,anchor:l?"end":"middle",width:a.width}),interactive:!1})}),c}function gF(t,e,n){const{style:i,nameFontSize:o,subFontSize:r}=n,{label:a}=t,s=[];if(t.name&&s.push({text:t.name,size:o,weight:600,color:i.fontColor,kind:"name"}),t.subLabel&&s.push({text:t.subLabel,size:r,weight:400,color:i.mutedColor,kind:"sub"}),!(s.length&&a.maxWidth>0))return[];const c=s.reduce((t,e)=>t+e.size,0)+2*(s.length-1);let l="vertical"===n.orient?a.y:a.y-c/2;return s.map(n=>{const o=lF(n.text,i.fontFamily,n.size,a.maxWidth,8,n.weight),r=mF(`${e}-${n.kind}`,o.text,a.x,l+n.size/2,{size:o.size,family:i.fontFamily,color:n.color,anchor:a.anchor,width:o.width,weight:n.weight});return l+=n.size+2,{...r,datum:t.data,index:t.i}})}function yF(t,e,n,i){const{track:o,data:r,i:a}=e,s=[],c=VL(o.domain),l=Hm(t,"Rect"),h=Om(l,r,a),u=t.schema.valueFormat,d=[e.name,Number.isFinite(e.value)?u(e.value,r):""];Number.isFinite(e.target)&&d.push(`${t.schema.translate("Target")} ${u(e.target,r)}`);const f={datum:r,index:a,aria:{label:`${d.filter(Boolean).join(", ")}.`}},m=t.schema.forecastConfig??{};if(Number.isFinite(e.forecast)){const t=Pm(m.size,r,a)??.6,i=Pm(m.fill,r,a)??Pm(l.fill,r,a),h=YL(o,c,e.forecast,t),u={type:"rect",key:`${n}-forecast`,...h,enterRect:KL(o,c,h),shapeType:"Rect",paint:{fill:Tm({...l,...m},r,a,i),opacity:Pm(m.opacity,r,a)??.35},...f};s.push(u);const d=Jv(m,u,r,a);d&&s.push(d)}if(Number.isFinite(e.value)){const i=Number(t.schema.measureSize),u=YL(o,c,e.value,Number.isFinite(i)?i:.35),d={type:"rect",key:`${n}-measure`,...u,enterRect:KL(o,c,u),shapeType:"Rect",paint:h,...f};s.push(d);const m=Jv(l,d,r,a);m&&s.push(m)}const p=t.schema.targetConfig??{};if(Number.isFinite(e.target)){const t=Pm(p.size,r,a)??.75;s.push({type:"line",key:`${n}-target`,points:UL(o,e.target,t),shapeType:"Line",paint:{fill:"none",stroke:Pm(p.stroke,r,a)??i.style.fontColor,strokeWidth:Pm(p.strokeWidth,r,a)??3},...f})}return s}function xF(t){return"function"==typeof t?t:"string"==typeof t?q(t):"number"==typeof t&&H(t)}const bF={name:"Bullet",layoutStage:sF,emit:({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.bullet;if(!n.length||!i)return[];const o=new Map;return n.map(e=>{const n=o.get(e.key)??0;o.set(e.key,n+1);const r=`bullet-${e.key}${n?`-${n}`:""}`,a={type:"rect",key:`${r}::hit`,...e.hit,datum:e.data,index:e.i,paint:{fill:"transparent"}};return{type:"group",key:r,children:[{type:"group",key:`${r}-static`,interactive:!1,aria:{hidden:!0},children:pF(e,r,i.style)},a,...gF(e,r,i),...yF(t,e,r,i)]}})},facet:{aspect:2,share:(t,e)=>iF(t,e.flat()),panel:(t,e)=>(e.shared&&e.scales instanceof Map&&(t.ctx.bulletFacet=e.scales),()=>{t.ctx.bulletFacet=void 0})},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"bulletSize",default:40},{key:"domain"},{key:"forecast",default:I("forecast"),coerce:xF},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{const o=t._filteredData??[],r=new Set(o.map((e,n)=>tF(t,e,n)));return!(i.length>=r.size)&&e.call(t,n,i)}}},{key:"measureSize",default:.35},{key:"orient",default:"horizontal"},{key:"sharedDomain",default:!1},{key:"subLabel",default:!1,coerce:xF},{key:"target",default:I("target"),coerce:xF},{key:"tickFormat",factory:t=>e=>d.formatAbbreviate(e,t.schema.locale)},{key:"ticks"},{key:"value",default:I("value"),coerce:t=>xF(t)||I("value")},{key:"valueFormat",factory:t=>e=>d.formatAbbreviate(e,t.schema.locale)},{key:"zoom",default:!1},{key:"forecastConfig",merge:!0,default:{opacity:.35,size:.6}},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Os(t),strokeWidth:1})},{key:"targetConfig",merge:!0,default:{size:.75,strokeWidth:3}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>function(t,e,n){const i=t.schema.valueFormat,o=[];for(const[r,a]of[["value","Value"],["target","Target"],["forecast","Forecast"]]){const s=JL(t.schema[r],e,n);Number.isFinite(s)&&o.push([t.schema.translate(a),`${i(s,e)}`])}return o}(t,e,n)})}]};var _F=lx(bF);const kF={name:"BumpChart",paintDriven:!0,setup:t=>{const e=t;e.y2((e,n)=>t._y(e,n)),e.yConfig({tickFormat:e=>{const n=t._formattedData??[],i=n[0].x instanceof Date?n[0].x.getTime():n[0].x,o=n.filter(t=>(t.x instanceof Date?t.x.getTime():t.x)===i),r=o.find(t=>t.y===e);return r?t._drawLabel(r,r.i):""}}),e.y2Config({tickFormat:e=>{const n=t._formattedData??[],i=n[n.length-1].x instanceof Date?n[n.length-1].x.getTime():n[n.length-1].x,o=n.filter(t=>(t.x instanceof Date?t.x.getTime():t.x)===i),r=o.find(t=>t.y===e);return r?t._drawLabel(r,r.i):""}}),e.ySort((e,n)=>t._y(n)-t._y(e)),e.y2Sort((e,n)=>t._y(n)-t._y(e))},facet:{axes:"all"},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"discrete",default:"x"},{key:"shape",default:H("Line"),coerce:"const"}]};var vF=lx(kF,ZD);const wF=/^(\d{4})-(\d{2})-(\d{2})$/;function MF(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function SF(t){if(Array.isArray(t))return t.length?SF(t[0]):null;if(t instanceof Date)return isNaN(+t)?null:MF(t);if("number"==typeof t)return Number.isFinite(t)?MF(new Date(t)):null;if("string"!=typeof t||!t.trim())return null;const e=wF.exec(t.trim());if(e){const[t,n,i]=[+e[1],+e[2]-1,+e[3]],o=new Date(t,n,i);return o.setFullYear(t),o.getMonth()===n&&o.getDate()===i?o:null}const n=new Date(t);return isNaN(+n)?null:MF(n)}function CF(t){return`${`${t.getFullYear()}`.padStart(4,"0")}-${`${t.getMonth()+1}`.padStart(2,"0")}-${`${t.getDate()}`.padStart(2,"0")}`}function $F(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),i=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.round((i-n)/864e5)}function AF(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e)}function zF(t,e){return((t.getDay()-e)%7+7)%7}function DF(t,e,n){return Math.floor(($F(e,t)+zF(e,n))/7)}const LF=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function FF(t,e){if("number"==typeof t&&Number.isFinite(t))return(Math.round(t)%7+7)%7;if("string"==typeof t&&t.length>=2){const e=t.toLowerCase(),n=LF.findIndex(t=>t.startsWith(e));if(n>=0)return n}return l.findWeekStart("string"==typeof e?e:"")}function NF(t){if(!t.length)return null;let e=t[0],n=t[0];for(const i of t)+i<+e&&(e=i),+i>+n&&(n=i);return[e,n]}function BF(t,e,n){const i=[];if(+e<+t)return i;if("month"===n){let n=t.getFullYear(),o=t.getMonth();const r=12*e.getFullYear()+e.getMonth();for(;12*n+o<=r;)i.push({key:`${CF(new Date(n,o,1)).slice(0,7)}`,start:new Date(n,o,1),end:new Date(n,o+1,0)}),o+=1,o>11&&([n,o]=[n+1,0]);return i}for(let n=t.getFullYear();n<=e.getFullYear();n++)i.push({key:`${n}`,start:new Date(n,0,1),end:new Date(n,11,31)});return i}function EF(t,e){return DF(t.end,t.start,e)+1}function RF(t,e){const n=$F(t.start,t.end)+1,i=zF(t.start,e),o=[];for(let e=0;e<n;e++){const n=AF(t.start,e);o.push({date:n,key:CF(n),week:Math.floor((e+i)/7),day:(e+i)%7})}return o}function PF(t){return BF(t.start,t.end,"month")}function TF(t){return"string"==typeof t&&l.locale[t]||l.locale["en-US"]}function OF(t,e,n){const i=void 0===t?n:t;if("function"==typeof i){const t=i;return e=>`${t(e)??""}`}return"string"==typeof i&&i?g.timeFormatLocale(e).format(i):null}function WF(t){const e=t.dateTime.replace(/[,.]?\s*%X/g,"").replace(/[\s,.]+$/,"").replace(/%e/g,"%-d").trim()||t.date;return/%[aA]/.test(e)?e:`%A, ${e}`}function HF(t,e){const[n=""]=Array.from(t.trim());try{return n.toLocaleUpperCase(e)}catch{return n.toUpperCase()}}function jF(t){const{count:e,gridColumns:n,gridRows:i,insetTop:o,insetLeft:r,gap:a,width:s,height:c}=t,l=Math.max(1,e),h=t.columns?[Math.min(l,Math.max(1,Math.round(t.columns)))]:Array.from({length:l},(t,e)=>e+1);let u;for(const t of h){const e=Math.ceil(l/t),h=(s-t*r-(t-1)*a)/(t*n),d=(c-e*o-(e-1)*a)/(e*i),f=Math.max(0,Math.min(h,d));(!u||f>u.cell+1e-9)&&(u={cell:f,columns:t,rows:e})}const{cell:d,columns:f,rows:m}=u,p=r+n*d,g=o+i*d;return{cell:d,columns:f,rows:m,blockWidth:p,blockHeight:g,width:f*p+(f-1)*a,height:m*g+(m-1)*a}}function IF(t,e,n){return"vertical"===n?[e,t]:[t,e]}function GF(t,e){return"vertical"===e?{columns:7,rows:t}:{columns:t,rows:7}}function qF(t,e,n,i){const{week:o,day:r}=t,{week:a,day:s}=e,c=t=>Math.round(100*t)/100;return`${[[o+1,r],[o,r],[o,7],[a,7],[a,s+1],[a+1,s+1],[a+1,0],[o+1,0]].map(([t,e],o)=>{const[r,a]=IF(t,e,i);return`${o?"L":"M"}${c(r*n)},${c(a*n)}`}).join("")}Z`}function VF(t){return 0===t.day?t.week:t.week+1}function YF(t,e){return t>=e?[0,1,2,3,4,5,6]:[1,3,5]}function KF(t,e){return t>0&&e>0?Math.min(t,e/3):0}const UF=new Date(2023,0,1);function XF(t){return Math.max(3,Math.round(.4*t))}function ZF(t,e){return Array.from({length:7},(n,i)=>t(AF(UF,(e+i)%7)))}function QF(t,e,n,i,o){const r=n.fontSize,a=XF(r),s=1.15*r+a,c=r+a,l=n.weekday?i+a:0;if("month"===t){return{top:(n.title.length?s:0)+("vertical"===e&&n.weekday?c:0),left:"horizontal"===e?l:0}}return"vertical"===e?{top:(n.year?s:0)+(n.weekday?c:0),left:n.month?o+a:0}:{top:n.month?c:0,left:l+(n.year?s:0)}}function JF(t,e,n){const i=t=>Math.round(100*t)/100;return t.replace(/(-?[\d.]+),(-?[\d.]+)/g,(t,o,r)=>`${i(+o+e)},${i(+r+n)}`)}function tN(t){const{start:e,end:n,period:i,orient:o,weekStart:r,width:a,height:s,labels:c}=t,l=BF(e,n,i),h=Math.max(1,...l.map(t=>EF(t,r))),u=c.weekday?ZF(c.weekday,r):[],d=c.month?Math.max(0,...Array.from({length:12},(t,e)=>c.measure(c.month(new Date(2023,e,1))))):0,f=Math.max(0,...u.map(c.measure)),m=QF(i,o,c,f,d),p=GF(h,o),g="month"===i?1.5*c.fontSize:c.fontSize,y=jF({count:l.length,gridColumns:p.columns,gridRows:p.rows,insetTop:m.top,insetLeft:m.left,gap:g,width:a,height:s,columns:"month"===i?void 0:"vertical"===o?l.length:1}),{cell:x}=y,b=Math.max(0,(a-y.width)/2),_=Math.max(0,(s-y.height)/2),k=[],v=[],w=[];return l.forEach((e,n)=>{const a=b+n%y.columns*(y.blockWidth+g),s=_+Math.floor(n/y.columns)*(y.blockHeight+g),l={block:e,left:a,top:s,x:a+m.left,y:s+m.top};for(const t of RF(e,r)){const[n,i]=IF(t.week,t.day,o);k.push({...t,block:e.key,x:l.x+n*x,y:l.y+i*x,size:x})}c.weekday&&v.push(...function(t,e,n,i){const{labels:o,orient:r}=n,a=o.fontSize,s=XF(a),c="vertical"===r;let l=e,h=YF(i,1.25*a);if(c){const t=(t,e)=>Math.max(...t.map(o.measure))<=e,n=e.map(o.narrow);t(e,i-2)?h=[0,1,2,3,4,5,6]:t(n,i)?[l,h]=[n,[0,1,2,3,4,5,6]]:t(n,2*i-2)?[l,h]=[n,[0,2,4,6]]:h=[]}return h.map(e=>({key:`${t.block.key}-weekday-${e}`,kind:"weekday",text:l[e],x:c?t.x+(e+.5)*i:t.x-s,y:c?t.y-s-a/2:t.y+(e+.5)*i,anchor:c?"middle":"end"}))}(l,u,t,x)),"year"===i&&c.month&&v.push(...function(t,e,n,i){const{labels:o,orient:r,weekStart:a}=e,s=o.month,c=o.fontSize,l=XF(c),h=[];let u=-1/0;for(const e of PF(t.block)){const d=VF({week:DF(e.start,t.block.start,a),day:zF(e.start,a)});if(d>=i)continue;const f=s(e.start),m=d*n,p="vertical"===r?c:o.measure(f);m<u||m+("vertical"===r?0:p)>i*n+l||(u=m+p+l,h.push({key:`${t.block.key}-month-${e.key}`,kind:"month",text:f,x:"vertical"===r?t.x-l:t.x+m,y:"vertical"===r?t.y+m+n/2:t.y-l-c/2,anchor:"vertical"===r?"end":"start"}))}return h}(l,t,x,EF(e,r)));const h=function(t,e,n,i){const{labels:o,orient:r,period:a}=e,s=o.fontSize,c=`${t.block.key}-${"month"===a?"title":"year"}`;if("month"===a){const e=o.title.map(e=>e(t.block.start)).find((t,e,i)=>e===i.length-1||1.1*o.measure(t)<=n.blockWidth);return void 0===e?null:{key:c,kind:"title",text:e,x:t.left,y:t.top+.6*s,anchor:"start"}}if(!o.year)return null;const l=o.year(t.block.start);return"vertical"===r?{key:c,kind:"year",text:l,x:t.x+i/2,y:t.top+.6*s,anchor:"middle"}:{key:c,kind:"year",text:l,x:t.left+.6*s,y:t.y+7*n.cell/2,anchor:"middle",rotate:-90}}(l,t,y,p.columns*x);h&&v.push(h),"year"===i&&w.push(...function(t,e,n,i){return PF(t.block).map(o=>{const r=n=>({week:DF(n,t.block.start,e),day:zF(n,e)}),a=qF(r(o.start),r(o.end),n,i);return{key:`${t.block.key}-outline-${o.key}`,d:JF(a,t.x,t.y)}})}(l,r,x,o))}),{blocks:l,fit:y,cells:k,labels:v,outlines:w}}function eN(t,e,n){const i=t.schema.date;return SF("function"==typeof i?i(e,n):void 0)}function nN(t,e){const n=[];return e.forEach((e,i)=>{const o=eN(t,e,i);o&&n.push(o)}),NF(n)}function iN(t){return"month"===t.schema.period?"month":"year"}function oN(t){const e=t.schema.orient;return"horizontal"===e||"vertical"===e?e:"month"===iN(t)?"vertical":"horizontal"}function rN(t){const e=t.schema.calendarLabelConfig??{},n=e.fontFamily??t.schema.fontFamily;return{fontColor:"string"==typeof e.fontColor?e.fontColor:void 0,fontFamily:s.fontFamilyStringify(n),fontSize:"number"==typeof e.fontSize?e.fontSize:11,fontWeight:e.fontWeight??400}}function aN(t){const e=TF(t.schema.locale);return OF(WF(e),e,!1)}function sN(t,e,n){const i=TF(t.schema.locale),o=[];if("month"===e){const e=OF(t.schema.monthFormat,i,!1);if(e)o.push(e);else if(!1!==t.schema.monthFormat)for(const t of["%B %Y","%b %Y","%b"])o.push(OF(t,i,!1))}return{fontSize:n.fontSize,measure:t=>r.textWidth(t,{"font-family":n.fontFamily,"font-size":n.fontSize,"font-weight":n.fontWeight}),weekday:OF(t.schema.weekdayFormat,i,"%a"),month:"year"===e?OF(t.schema.monthFormat,i,"%b"):null,year:"year"===e?OF(t.schema.yearFormat,i,"%Y"):null,title:o,narrow:e=>HF(e,t.schema.locale)}}const cN=({viz:t})=>{const e=t._filteredData??[],n=new Map;e.forEach((e,i)=>{const o=eN(t,e,i);if(!o)return;const r=CF(o);n.has(r)||n.set(r,{datum:e,i:i})});const i=t.ctx.calendarSharedExtent??nN(t,e);if(t.ctx.calendarLayout=void 0,!i)return{shapeData:[]};const{width:o,height:r}=kt(t),a=iN(t),s=rN(t),c=tN({start:i[0],end:i[1],period:a,orient:oN(t),weekStart:FF(t.schema.weekStart,t.schema.locale),width:o,height:r,labels:sN(t,a,s)});t.ctx.calendarLayout=c,t.ctx.calendarDateFormat=aN(t),t.ctx.calendarLabelStyle=s;return{shapeData:c.cells.map(t=>{const e=n.get(t.key);return e?{...t,datum:e.datum,i:e.i}:t})}};function lN(t,e){const n=b.interpolateRgb(t,e);return{empty:n(.09),outline:n(.45),text:n(.75)}}function hN(t,e,n){const i=t.schema.colorScale;if("function"!=typeof i)return;const o=i(e,n);return null!=o&&""!==o&&"boolean"!=typeof o&&Number.isFinite(+o)?+o:void 0}function uN(t,e,n){return"function"!=typeof t.schema.colorScale||void 0!==hN(t,e,n)}function dN(t,e,n){if(!t.schema.monthOutline)return[];const i=t.schema.monthOutlineConfig??{},o=i.strokeDasharray;return e.outlines.map(t=>({type:"path",key:`calendar-${t.key}`,d:t.d,interactive:!1,paint:{fill:"none",stroke:i.stroke??n,strokeWidth:i.strokeWidth??1,...o?{strokeDasharray:o}:{}}}))}const fN=({viz:t,shapeData:n})=>{const i=n??[],o=t.ctx.calendarLayout;if(!i.length||!o)return[];const a=t.ctx.calendarLabelStyle,s=Os(t),c=lN(s,e.colorContrast(s,t.schema.colorDefaults)),l=Hm(t,"Rect"),h=o.fit.cell,u=Math.min(Math.max(0,Number(t.schema.cellPadding)||0),h/2),d=Math.max(0,h-u),f={viz:t,sc:l,emptyFill:t.schema.emptyFill??t._theme?.colorScale.missing??c.empty,padding:u,side:d,radius:KF(Number(t.schema.cellRadius)||0,d),noData:t.schema.translate("No Data"),dateFormat:t.ctx.calendarDateFormat},m=i.map(t=>function(t,e){const{viz:n,sc:i,emptyFill:o,noData:r}=e,a={type:"rect",key:`calendar-${t.key}`,x:t.x+e.padding/2,y:t.y+e.padding/2,width:e.side,height:e.side,...e.radius?{rx:e.radius,ry:e.radius}:{}},{datum:s,i:c}=t;if(!s){const n=e.dateFormat?e.dateFormat(t.date):t.key;return{...a,interactive:!1,paint:{fill:o},aria:{label:`${n}, ${r}.`}}}const l=hN(n,s,c??0),h=uN(n,s,c??0),u=h?Pm(i.fill,s,c):o,d=Pm(i.ariaLabel,s,c)??t.key,f=h?l:r;return{...a,datum:s,index:c,shapeType:"Rect",paint:{fill:h?Tm(i,s,c,u):u,stroke:Pm(i.stroke,s,c),strokeWidth:Pm(i.strokeWidth,s,c),opacity:Pm(i.opacity,s,c)??1},aria:{label:`${void 0===f?d:`${d}, ${f}`}.`}}}(t,f)),p=i.filter(t=>t.datum),g=m.filter(t=>t.datum),y=t=>r.textWidth(t,{"font-family":a.fontFamily,"font-size":a.fontSize,"font-weight":a.fontWeight}),x=o.labels.map(t=>function(t,e,n,i){const o="year"===t.kind||"title"===t.kind;return{type:"text",key:`calendar-label-${t.key}`,interactive:!1,x:0,y:0,transform:{x:t.x,y:t.y,...t.rotate?{rotate:t.rotate}:{}},lines:[{text:t.text,x:0,y:0,width:i(t.text)}],font:{family:e.fontFamily,size:e.fontSize,weight:o?600:e.fontWeight,anchor:t.anchor,baseline:"middle"},paint:{fill:n}}}(t,a,a.fontColor??c.text,y));return[...m,...tw(l,g,t=>[p[t].datum,p[t].i]),...dN(t,o,c.outline),...x]},mN=t=>void 0!==t.date?t.date:t.time,pN={name:"Calendar",layoutStage:cN,emit:fN,insetRegion:function(t){const{width:e,height:n}=kt(t);return{bounds:{x:t._margin.left,y:t._margin.top,width:e,height:n},obstacles:fc(t._chartScene||[],t._chartTransform,void 0,!0)}},defaults:{hoverOutline:!0},facet:{aspect:3,share:(t,e)=>NF(e.flatMap(e=>nN(t,e)??[])),panel:(t,{shared:e,scales:n})=>(t.ctx.calendarSharedExtent=e&&n?n:void 0,()=>{t.ctx.calendarSharedExtent=void 0})},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellRadius",default:2},{key:"date",default:mN,coerce:t=>"function"==typeof t?t:q(t)},{key:"emptyFill"},{key:"monthFormat"},{key:"monthOutline",default:!0},{key:"orient"},{key:"period",default:"year"},{key:"weekStart"},{key:"weekdayFormat"},{key:"yearFormat"},{key:"zoom",default:!1},{key:"colorScale",default:I("value"),coerce:Jc},{key:"groupBy",factory:t=>[(e,n)=>{const i=eN(t,e,n);return i?CF(i):e.id}]},{key:"label",coerce:"const",factory:t=>(e,n)=>{const i=eN(t,e,n);return i?aN(t)(i):""}},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>!!t._legendCategories&&e.call(t,n,i)}},{key:"calendarLabelConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,default:{hoverOpacity:1}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[[()=>t.schema.translate("Value"),(e,n)=>{const i=hN(t,e,n);return void 0===i?"":d.formatAbbreviate(i,t.schema.locale)}]]})},{key:"monthOutlineConfig",merge:!0,default:{}}]};var gN=lx(pN);function yN(t){const e=(e,n)=>{const i=t._id(e,n);return Array.isArray(i)?i:[i]};return n=>{const i=new Set;(t._facetPanels?t._facetPanels.map(t=>t.scene):[t._chartScene||[]]).forEach(t=>Ae(t,t=>i.add(t)));const o=new Set;return n.forEach(t=>e(t,0).forEach(t=>o.add(t))),(t,r)=>!t.__d3plus__&&(i.has(t)?n.has(t):e(t,r).some(t=>o.has(t)))}}function xN(t){if(null==t||""===t||"boolean"==typeof t)return;const e="number"==typeof t?t:Number(t);return Number.isFinite(e)?e:void 0}function bN(t,e,n){const i=xN(n.close(t,e));if(void 0===i)return;const o=xN(n.open(t,e))??i,r=xN(n.high(t,e)),a=xN(n.low(t,e));return{open:o,high:Math.max(r??-1/0,o,i),low:Math.min(a??1/0,o,i),close:i}}function _N(t,e){return e>=t?"up":"down"}function kN(t,e){if(Number.isFinite(t)&&Number.isFinite(e)&&0!==t)return(e-t)/Math.abs(t)}function vN(t,e){let n=1/0,i=-1/0;for(const{d:o,i:r}of t){const t=bN(o,r,e);t&&(t.low<n&&(n=t.low),t.high>i&&(i=t.high))}return n<=i?[n,i]:void 0}function wN(t,e){const n=Array.from(new Set(t.filter(Number.isFinite))).sort((t,e)=>t-e);let i=1/0;for(let t=1;t<n.length;t++)i=Math.min(i,n[t]-n[t-1]);return Number.isFinite(i)&&i>0?i:e}function MN(t,e){const n=Number.isFinite(e)?Math.min(1,Math.max(0,e)):.7;return Math.max(1,t*n)}const SN=t=>Math.round(t-.5)+.5;function CN(t,e,n){const i=Math.min(n.open,n.close),o=Math.max(n.open,n.close),r=Math.min(n.high,i),a=Math.max(n.low,o),s=e/2;let c="";return r<i&&(c+=`M${t},${r}V${i}`),a>o&&(c+=`M${t},${o}V${a}`),c+=`M${t-s},${i}H${t+s}V${o}H${t-s}Z`,c}function $N(t,e,n){const i=e/2;return`M${t},${n.high}V${n.low}M${t-i},${n.open}H${t}M${t},${n.close}H${t+i}`}const AN=["open","high","low","close","volume"],zN=new WeakMap;function DN(t){if("function"==typeof t)return t;if("string"!=typeof t)return H(t);const e=q(t);return zN.set(e,t),e}function LN(t){const e=I(t);return zN.set(e,t),e}function FN(t){return"function"==typeof t?zN.get(t):void 0}const NN=(t,e)=>t.map(e).map(xN).filter(t=>void 0!==t),BN=(t,e)=>NN(t,e)[0],EN=(t,e)=>NN(t,e).at(-1),RN=(t,e)=>{const n=NN(t,e);return n.length?Math.max(...n):void 0},PN=(t,e)=>{const n=NN(t,e);return n.length?Math.min(...n):void 0},TN=(t,e)=>{const n=NN(t,e);return n.length?n.reduce((t,e)=>t+e,0):void 0},ON={open:BN,high:RN,low:PN,close:EN,volume:TN},WN=new Set(Object.values(ON)),HN=t=>WN.has(t);function jN(t,e){const n=new Map;for(const t of AN){const i=FN(e[t]);void 0!==i&&n.set(i,ON[t])}for(const e of Object.keys(t))HN(t[e])&&!n.has(e)&&delete t[e];n.forEach((e,n)=>{t[n]&&!HN(t[n])||(t[n]=e)})}function IN(t,e,n){let i;for(const o of AN){const r=e[o];if("function"!=typeof r||void 0!==FN(r))continue;const a=n[o],s="function"!=typeof a||HN(a)?ON[o]:a;(i??(i={}))[o]=s(t,e=>r(e,t.indexOf(e)))}return i}const GN=t=>Object.fromEntries(AN.map(e=>[e,t.schema[e]])),qN=new WeakMap;function VN(t,e){return(n,i)=>{const o=qN.get(t)?.get(n);return o&&e in o?o[e]:t.schema[e](n,i)}}function YN(t){return{open:VN(t,"open"),high:VN(t,"high"),low:VN(t,"low"),close:VN(t,"close")}}function KN(t,e,n,i=4){let[o,r]=t;const a=n.invert,s=(t,e)=>{const i=n(t);if(!a||!Number.isFinite(i))return t;const o=Number(a(i+e));return Number.isFinite(o)?o:t},c=s(e[1],-i),l=s(e[0],i);return c>r&&(r=c),l<o&&(o=l),[o,r]}function UN({data:t,x:e,y:n,x2:i}){if(i)return[e,n];!function(t,e){if(t.padding)return void t.padding(1);const n=Array.from(new Set(e.filter(Number.isFinite))).sort((t,e)=>t-e);let i=1/0;for(let e=1;e<n.length;e++)i=Math.min(i,yi(t,n[e-1],n[e]));if(!Number.isFinite(i))return;const[o,r]=t.domain().map(Number);t.domain([xi(t,o,-i),xi(t,r,i)])}(e,t.map(t=>+t.x));const o=vN(t.map(t=>({d:t.data,i:t.i})),YN(this));if(!o)return[e,n];const r=KN(n.domain().slice().reverse(),o,n);return n.domain(r.slice().reverse()),[e,n]}const XN=["day","week","month","quarter","year"],ZN=[2,5,10,20,50,100,200,500,1e3];function QN(t){if(t instanceof Date)return t;if("string"!=typeof t&&"number"!=typeof t)return t;const e=r.date(t);return e instanceof Date&&!isNaN(+e)?e:t}function JN(t){const e=!t.getHours()&&!t.getMinutes()&&!t.getSeconds();return g.timeFormat(e?"%b %-d, %Y":"%b %-d, %Y %-I:%M %p")(t)}function tB(t,e){const n=t.getFullYear(),i=t.getMonth();switch(e){case"day":return 31*(12*n+i)+t.getDate();case"week":return+y.timeMonday.floor(t);case"month":return 12*n+i;case"quarter":return 4*n+Math.floor(i/3);default:return n}}function eB(t,e){if(!t.length)return[];const n=Math.max(1,Math.floor(e)),i=XN.map(e=>function(t,e){const n=[];for(let i=1;i<t.length;i++)tB(t[i],e)!==tB(t[i-1],e)&&n.push(t[i]);return n}(t,e)),o=i[i.length-1],r=i.concat(ZN.map(t=>o.filter(e=>e.getFullYear()%t===0))).filter((t,e,n)=>{return t.length&&!(e&&(i=t,o=n[e-1],i.length===o.length&&i.every((t,e)=>+t===+o[e])));var i,o}),a=r.filter(t=>t.length<=n),s=a.length?a:r.slice(-1);return s.length?s.flatMap(e=>e.length>1?[[t[0],...e],e]:[[t[0],...e]]):[[t[0]]]}function nB(t){const e=new Map(t.map((t,e)=>[+t,e])),n=(n,i)=>{const o=e.get(+n);return Boolean(o)&&tB(t[o],i)!==tB(t[o-1],i)},i=new WeakMap;return function(t){if(!(t instanceof Date))return String(t);const e=this?Fi(this):void 0;if(!e?.length)return JN(t);let o,r=i.get(e);r||i.set(e,r=function(t,e){return XN.slice().reverse().find(n=>t.slice(1).every(t=>e(t,n)))??"day"}(e,n));for(const n of e)+n<+t&&(o=n);return function(t,e,n){const i=!e||e.getFullYear()!==t.getFullYear();return"year"===n?g.timeFormat("%Y")(t):"day"===n||"week"===n?g.timeFormat(i?"%b %-d, %Y":"%b %-d")(t):e?g.timeFormat(i?"%Y":"%b")(t):g.timeFormat("%b %Y")(t)}(t,o,r)}}function iB(t){const e=function(t){const e=t._filteredData||[],n=new Map;return e.forEach((e,i)=>{const o=t._x?t._x(e,i):void 0;o instanceof Date&&!isNaN(+o)&&!n.has(+o)&&n.set(+o,o)}),Array.from(n.values()).sort((t,e)=>+t-+e)}(t);return{labels:eB(e,(t.schema.width-t._margin.left-t._margin.right-60)/72),tickFormat:nB(e)}}const oB={height:.2,gap:16,axisConfig:{},shapeConfig:{fillOpacity:.5}};function rB(t){return null==t||!1===t?void 0:DN(t)}const aB=t=>"function"==typeof t.schema.volume;function sB(t){const e=t.schema.volumeConfig??{};return{...oB,...e}}function cB(t,e,n){return aB(t)?xN(VN(t,"volume")(e,n)):void 0}function lB(t,e){if(!(e>0))return{height:0,gap:0};const n=Number(t.height),i=Number.isFinite(n)&&n>0?n:oB.height,o=Math.min(i<=1?i*e:i,.5*e),r=Math.max(0,Number.isFinite(Number(t.gap))?Number(t.gap):oB.gap);return{height:Math.round(o),gap:r}}function hB(t){const e=c.scaleLinear().domain([0,t>0?t:1]).nice(2);return{domain:e.domain(),ticks:e.ticks(2)}}function uB(t,e){return h.max(e,(e,n)=>cB(t,e,n))??0}const dB=new WeakMap;function fB(t){return"panel"===t._facetStep&&t._plotFacetScales?dB.get(t)??0:uB(t,t._filteredData||[])}function mB(t){const e=t._yConfig?.labels;return!(Array.isArray(e)&&!e.length)}function pB(t,e){return d.formatAbbreviate(e,t.schema.locale)}function gB(t,e){const{domain:n,ticks:i}=hB(fB(t)),o=mB(t);return(new Lo).renderMode("compute").select(null).config(jC(t,{locale:t.schema.locale,scale:"linear",domain:[n[1],n[0]],range:e,ticks:i,labels:o?i.filter(t=>t>0):[],tickFormat:e=>pB(t,e),gridSize:0,rounding:"none",title:!1,height:e[1],width:e[1]})).config(sB(t).axisConfig)}function yB(t){t._plotInsetBottom=e=>{if(!aB(t))return 0;const{height:n,gap:i}=lB(sB(t),e);return n?n+i:0},t._plotMinLeft=()=>aB(t)&&mB(t)?function(t){const e=t.outerBounds();return e.width?e.width+t.padding():0}(gB(t,[0,100]).measure()):0}function xB(t){const e=t.insetBottom??0;if(!(e>0))return;const n=t.yRange[1]-(t.x2Height??0),{gap:i}=sB(t.viz);return{top:n+Math.min(i,e),bottom:n+e,left:t.xRange[0],right:t.xRange[t.xRange.length-1]}}const bB=t=>"path"===t.type||String(t.key).endsWith("::hit");function _B(t,e,n,i,o){const{viz:r}=t,a=xB(t);if(!a||!e.size)return[];const{domain:s}=hB(fB(r)),c=a.bottom-a.top,l=new Map;e.forEach(({cx:t,width:e},n)=>{const i=cB(r,n.data,n.i);if(void 0===i||i<0)return;const o=Math.min(c,i/s[1]*c);l.set(n,{cx:t,width:e,top:a.bottom-o})});const h=sB(r),u=Rm("Path").renderMode("compute").config(Hm(r,i)).config(n).config(Qt.bind(r)(h.shapeConfig)).config({d:t=>{const{cx:e,width:n,top:i}=l.get(t),o=n/2;return`M${e-o},${i}H${e+o}V${a.bottom}H${e-o}Z`},hitArea:t=>{const{cx:e,width:n}=l.get(t),i=Math.max(n,6);return{x:e-i/2,y:a.top,width:i,height:c}},id:t=>`${t.id}_${t.discrete}_volume`,label:!1,x:0,y:0}),d=u.schema.fill,f=u.schema.texture;u.config({texture:(t,e)=>o(f(t,e),d(t,e))}).data(Array.from(l.keys())),r._wirePlotShapeEvents(u,i,t.events);const m=Im(u).map(t=>{const n=t.datum,o=n&&bB(t)?{interactionPoints:e.get(n)?.interactionPoints}:{};return{...t,shapeType:i,...o}}),p=gB(r,[a.top,a.bottom]);p.render();const g=p.toScene();return[...m,vB({...g,key:"candlestick-volume-axis",transform:{x:a.left-kB(p,g),y:0}})]}function kB(t,e){const n=(e.children||[]).find(t=>"bar"===t.key&&"line"===t.type),i=n?.points?.[0]?.[0];if(Number.isFinite(i))return i;const o=t.outerBounds();return o.x+o.width}function vB(t){const e=t.children;return{...t,interactionGroup:"axis",...e?{children:e.map(vB)}:{}}}function wB(t,e){if(Math.abs(t)<1)return d.formatAbbreviate(t,e,".3~g");const n=d.formatAbbreviate(1.5,e,".1f").charAt(1),[i,o=""]=d.formatAbbreviate(t,e,",.2f").split(n);return`${i}${n}${o.padEnd(2,"0")}`}function MB(t,e){return`${t>0?"+":""}${d.formatAbbreviate(100*t,e,".2f")}%`}function SB(t,e,n){const i=t._x?t._x(e,n):void 0,o=t._xConfig?.tickFormat,r=QN(i);return"function"==typeof o?String(o(r)):r instanceof Date?JN(r):String(i??"")}function CB(t,e,n){const i=bN(e,n,YN(t));if(!i)return[];const o=e=>t.schema.translate(e),r=function(t){const e=t._yConfig?.tickFormat;return"function"==typeof e?t=>String(e(t)):e=>wB(e,t.schema.locale)}(t),a=[[SC(t,"x"),SB(t,e,n)],[o("Open"),r(i.open)],[o("High"),r(i.high)],[o("Low"),r(i.low)],[o("Close"),r(i.close)]],s=kN(i.open,i.close);void 0!==s&&a.push([o("Change"),MB(s,t.schema.locale)]);const c=cB(t,e,n);return void 0!==c&&a.push([o("Volume"),pB(t,c)]),a}function $B(t,e,n){const[i,...o]=CB(t,e,n);return`${zB(t,e,n,i?.[1])}: ${o.map(([t,e])=>`${t} ${e}`).join(", ")}.`}function AB(t,e,n){const i=cB(t,e,n),o=void 0===i?"":` ${pB(t,i)}`;return`${zB(t,e,n,SB(t,e,n))}: ${t.schema.translate("Volume")}${o}.`}function zB(t,e,n,i){return[t._drawLabel(e,n),i].filter(t=>void 0!==t&&""!==t).join(", ")}const DB="Candlestick",LB=(t,e)=>"function"==typeof t?t(e.data,e.i):t;function FB(t,e,n,i,o){const r=YN(t),a=t.schema.variant,s=Math.min(Math.abs(o[o.length-1]-o[0]),40),c=e.map(t=>n(t.x)),l=MN(wN(c,s),Number(t.schema.bodyWidth)),h=l>=2?2*Math.round(l/2):l,u=new Map;return e.forEach((t,e)=>{const n=bN(t.data,t.i,r);if(!n||!Number.isFinite(c[e]))return;const o={open:SN(i(n.open)),high:SN(i(n.high)),low:SN(i(n.low)),close:SN(i(n.close))};if(![o.open,o.high,o.low,o.close].every(Number.isFinite))return;const s=SN(c[e]);u.set(t,{cx:s,width:h,px:o,direction:_N(n.open,n.close),d:"ohlc"===a?$N(s,h,o):CN(s,h,o)})}),u}function NB(t,e){if(!t)return t;const n="string"==typeof e?i.color(e):null;if(!n)return t;const o="object"==typeof t?{...t}:{texture:t};return o.stroke||(o.stroke=n.darker(1).formatHex()),o}const BB=t=>{const{viz:e,x:n,y:i,xRange:o}=t,r=t.values,a=FB(e,r,n,i,o);if(!a.size)return[];const s=t=>a.get(t),c=e.schema.shapeConfig[DB],l=Rm("Path").renderMode("compute").config(Hm(e,DB)).config(function(t,e){const n=n=>LB("up"===e(n).direction?t.schema.upColor:t.schema.downColor,n);return{fill:i=>{const{direction:o}=e(i);return"ohlc"===t.schema.variant||"up"===o&&t.schema.hollow?"none":n(i)},stroke:n,strokeWidth:1,strokeLinecap:"butt"}}(e,s)).config(c?Qt.bind(e)(c):{}).config({ariaLabel:t=>$B(e,t.data,t.i),d:t=>s(t).d,hitArea:t=>{const{cx:e,width:n,px:i}=s(t),o=Math.max(n,6);return{x:e-o/2,y:i.high-2,width:o,height:i.low-i.high+4}},id:t=>`${t.id}_${t.discrete}`,label:!1,x:0,y:0}),h=l.schema.fill,u=l.schema.backgroundImage,d=l.schema.texture;l.config({backgroundImage:(t,e)=>"none"!==h(t,e)&&u(t,e),texture:(t,e)=>NB(d(t,e),h(t,e))}).data(Array.from(a.keys())),e._wirePlotShapeEvents(l,DB,t.events);const f=(t,e)=>[{x:e.cx,y:e.px.close,datum:t,index:t.i}],m=Im(l).map(t=>{const e=t.datum,n=e&&a.get(e),i=n&&bB(t)?{interactionPoints:f(e,n)}:{};return{...t,shapeType:DB,...i}});if(!aB(e)||!xB(t))return m;const p=new Map;a.forEach((t,e)=>p.set(e,{cx:t.cx,width:t.width,interactionPoints:f(e,t)}));const g=_B(t,p,function(t,e){return{ariaLabel:e=>AB(t,e.data,e.i),fill:n=>LB("up"===e(n).direction?t.schema.upColor:t.schema.downColor,n),stroke:"none",strokeWidth:0}}(e,s),DB,NB),y=t.yRange[0]-(t.x2Height??0);return[{type:"group",key:"candlestick-price",clip:{type:"rect",x:o[0],y:y,width:o[o.length-1]-o[0],height:t.yRange[1]-t.yRange[0]},children:m},...g]};const EB=t=>t.ctx.candlestick;function RB(t){const e=EB(t),n=VN(t,"close");Object.defineProperty(t,"_x",{configurable:!0,enumerable:!0,get:()=>t.schema.skipGaps?e.xDate:e.x,set:t=>{t!==e.xDate&&t!==e.x&&(e.x=t)}}),Object.defineProperty(t,"_y",{configurable:!0,enumerable:!0,get:()=>n,set:e=>{e!==n&&(t.schema.close=e)}}),Object.defineProperty(t,"_yKey",{configurable:!0,enumerable:!0,get:()=>e.yKey??t.schema.translate("Close"),set:n=>{e.yKey="y"===n?void 0:n,void 0!==e.yKey&&"function"==typeof t.schema.close&&function(t,e){zN.set(t,e)}(t.schema.close,n)}})}const PB={name:"Candlestick",paintDriven:!0,facet:{aspect:16/9},setup:t=>{const e=I("date");t.ctx.candlestick={x:e,xDate:(e,n)=>QN(EB(t).x(e,n))},t._xKey="date",RB(t),function(t){const e=new WeakMap;qN.set(t,e),t._mergeRows=i=>{const o=n.merge(i,t.schema.aggs);if(i.length>1){const n=IN(i,GN(t),t.schema.aggs);n&&e.set(o,n)}return o}}(t),yB(t),t._buffer={...t._buffer,[DB]:UN},t._plotShapeEmitters={[DB]:BB},t._plotColumnHighlight=yN(t),t._tooltipAxisRows=!1,t._yTitle=null;const i=t._preDraw.bind(t);t._preDraw=()=>{!function(t){const e=EB(t),n=t.schema.time;void 0!==n&&n!==e.time||(e.time=t.schema.skipGaps?void 0:(e,n)=>t._x(e,n),t.schema.time=e.time)}(t),function(t){jN(t.schema.aggs,GN(t))}(t),i()};const o=t._draw.bind(t);t._draw=e=>(t._plotAxisDefaults=t.schema.skipGaps?{x:iB(t)}:void 0,"chrome"===t._facetStep&&function(t){dB.set(t,uB(t,t._filteredData||[]))}(t),o(e))},ctx:{},fields:[{key:"open",coerce:DN,factory:()=>LN("open")},{key:"high",coerce:DN,factory:()=>LN("high")},{key:"low",coerce:DN,factory:()=>LN("low")},{key:"close",coerce:DN,factory:()=>LN("close")},{key:"volume",coerce:rB},{key:"volumeConfig",merge:!0,default:oB},{key:"variant",default:"candlestick"},{key:"upColor",default:"#2f9e44"},{key:"downColor",default:"#e03131"},{key:"hollow",default:!0},{key:"bodyWidth",default:.7},{key:"skipGaps",default:!0},{key:"discrete",default:"x"},{key:"legend",default:!1,coerce:"const"},{key:"shape",default:H(DB),coerce:"const"},{key:"timeline",default:!1},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>CB(t,e,n)})}]};var TB=lx(PB,ZD);const OB={out:.06,in:.06};function WB(t){const e={},{fontFamily:n,fontWeight:i}=t;return("string"==typeof n||Array.isArray(n))&&(e.fontFamily=n),"number"!=typeof i&&"string"!=typeof i||(e.fontWeight=i),e}function HB(t,e){const n={"font-family":r.fontExists(e.fontFamily??s.fontFamily),"font-size":100,"font-weight":e.fontWeight??400},i=r.textWidth(t,n);return t=>i*t/100}const jB=t=>"text"===t.type&&t.lines.some(t=>t.text.replace(/(\.\.\.|…)$/,"").trim().length>0);function IB(t,e,n={}){if(!e.length)return[];const i=new Map(e.map(t=>[t.key,t.fit.fontSize]));return qp(t,e.map(t=>({key:t.key,text:t.text,d:t.fit.d,color:t.color,anchor:"middle",datum:t.datum,index:t.index})),{fontWeight:400,...n,fontColor:t=>t.color,fontSize:t=>i.get(t.key)??10},{halo:!1}).filter(jB).map(t=>({...t,fadeSwap:OB}))}function GB(t,e=[]){const n=e.slice();return t.filter(t=>{const e=ak([t]);return!e.some(t=>n.some(e=>P_(t,e)))&&(n.push(...e),!0)})}const qB=1e-6;function VB(t={}){return{fontMin:8,fontMax:24,padding:2,lineHeight:1.2,maxLines:3,...t}}function YB(t){const e=[];let n=!1;for(const i of s.textSplit(t))n?e[e.length-1]+=i.replace("­",""):e.push(i.replace("­","")),n=i.endsWith("­");return e}function KB(t,e){const n=YB(t).map(t=>t.trim()).filter(Boolean);if(!n.length)return{words:[],space:0};const[i,...o]=e([" ",...n]);return{words:o,space:i}}function UB(t,e,n){return("function"==typeof t?t(e,0):t)??n}function XB(t,e,n){const i={"font-family":r.fontExists(UB(n.fontFamily,e,s.fontFamily)),"font-size":100,"font-weight":UB(n.fontWeight,e,400)};return KB(t,t=>r.textWidth(t,i).map(t=>t/100))}function ZB(t,e,n){let i=1,o=0;for(const r of t.words){const a=r*e;if(a>n+qB)return 1/0;const s=o?o+t.space*e+a:a;s>n+qB?(i++,o=a):o=s}return i}function QB(t,e,n){if(!t(e))return null;let i=e,o=Math.max(e,n);for(;i<o;){const e=Math.ceil((i+o)/2);t(e)?i=e:o=e-1}return i}const JB=2*Math.PI,tE=1e-6,eE=5;function nE(t,e){return Math.max(t,.3*e)}function iE(t,e){return[t*Math.sin(e),-t*Math.cos(e)]}function oE(t,e){const n=[iE(1,t),iE(1,e)];return Op(n)===n}function rE(t,e,n,i){const o=t=>Math.round(100*t)/100,[r,a]=i?[e,n]:[n,e],[s,c]=iE(t,r),[l,h]=iE(t,a),u=n-e>Math.PI?1:0,d=o(t);return`M${o(s)},${o(c)}A${d},${d} 0 ${u} ${i?1:0} ${o(l)},${o(h)}`}function aE(t,e,n,i){const o=t.innerRadius+n+e/2,r=t.outerRadius-n-e/2;return r<o-tE?null:"outer"===i?r:"inner"===i?o:(t.innerRadius+t.outerRadius)/2}function sE(t,e,n={}){const{fontMin:i=8,fontMax:o=24,padding:r=eE,endPadding:a=r,align:s="middle",minRadius:c=2.5,maxTurn:l=Math.PI,truncate:h=!0}=n,u=Math.min(t.startAngle,t.endAngle),d=Math.min(JB,Math.abs(t.endAngle-t.startAngle));if(!(d>0&&t.outerRadius>t.innerRadius&&i>0))return null;if(t.innerRadius<=0&&d>=JB-tE)return null;const f=u+d/2,m=oE(f-.01,f+.01),p=Math.sqrt(t.innerRadius**2+t.outerRadius**2),g=(t.padAngle??0)*p,y=e=>{const n=aE(t,e,r,s);if(null===n)return null;const i=n+(m?-.3:.3)*e;if(i<c*e)return null;const o=n-e/2;if(!(o>0))return null;const h=Math.min(l,d-(g+2*nE(a,e))/o,JB-tE);return h>0?{radius:i,turn:h}:null};let x=QB(t=>{const n=y(t);return Boolean(n&&e(t)<=n.radius*n.turn+tE)},i,Math.max(i,o));const b=null===x;if(b){if(!h)return null;x=i}const _=y(x);if(!_)return null;const k=_.radius*_.turn;return b&&k<3*x?null:{d:rE(_.radius,f-_.turn/2,f+_.turn/2,m),fontSize:x,radius:_.radius,clockwise:m,length:k,truncated:b}}function cE(t,e,n,i={}){const{fontMin:o=8,fontMax:r=24,padding:a=eE,align:s="middle"}=i,c=Math.abs(t.endAngle-t.startAngle),l=Math.min(t.startAngle,t.endAngle)+c/2,h=oE(l-.01,l+.01)?1:-1,u=r=>{const c=Math.max(o,Math.round(.75*r)),l=r+1.3*c,u=aE(t,l,a,s);if(null===u)return null;const d=(e,n,o)=>sE({...t,innerRadius:e-n/2,outerRadius:e+n/2},o,{...i,fontMin:n,fontMax:n,padding:0,endPadding:i.endPadding??a,align:"middle",truncate:!1}),f=d(u+h*(l-r)/2,r,e),m=d(u-h*(l-c)/2,c,n);return f&&m?[f,m]:null},d=QB(t=>Boolean(u(t)),o,Math.max(o,r));return null===d?null:u(d)}function lE(t,e,n,i="straight"){if("inside"===t||"outside"===t)return e?"straight":null;if("along"===t)return n?"curved":null;return!n||n.truncated||e&&!e.truncated&&(o=n.fontSize,r=e.fontSize,!("curved"===i?o>=r:o>r))?e?"straight":n?"curved":null:"curved";var o,r}function hE(t,e,n){const i=t.schema.labelPosition;return"function"==typeof i?i(e,n):i}function uE(t,e){const n=t=>t.split(/\s+/).filter(Boolean),i=t.flatMap(n),o=n(e);return i.length!==o.length||i.some((t,e)=>t!==o[e])}function dE(t){const e=jm(t,"Path").fontSize;return"number"==typeof e&&e>0?e:11}function fE(t,e,n){const i=dE(t),o=WB(jm(t,"Path"));return e.map(e=>{const r=e.group;if(!r)return null;const a=hE(t,e.data,e.i);if("inside"===a||"outside"===a)return null;const s=`${t._drawLabel(e.data,e.i)??""}`;return s?sE({innerRadius:n,outerRadius:n+i+8,startAngle:r.startAngle,endAngle:r.endAngle},HB(s,o),{fontMin:i,fontMax:i,padding:4,align:"inner",minRadius:0,truncate:"along"===a}):null})}function mE(t,e,n){return e.every((e,i)=>!(e.group&&!n[i])||!`${t._drawLabel(e.data,e.i)??""}`)}function pE(t,e,n,i=11){const o=1.5*i;t.forEach(t=>{const i=t.group;if(!i)return;const r=(i.startAngle+i.endAngle)/2,a=r-Math.PI/2;t.labelX=Math.cos(a)*e,t.labelY=Math.sin(a)*e;let s=180*r/Math.PI-90;r>Math.PI?(s+=180,t.labelBounds={x:-(n+4),y:-o/2,width:n,height:o},t.labelAnchor="end"):(t.labelBounds={x:4,y:-o/2,width:n,height:o},t.labelAnchor="start"),t.labelRotate=s})}function gE(t,e,n,i){const o=Math.max(0,i),r=Math.min(t.schema.arcThickness,o),a=Math.max(0,o-r),s=null!=t.schema.padAngle?t.schema.padAngle:t.schema.padPixel/(o||1),c=(t.schema.directed?w.chordDirected():w.chord()).padAngle(s).sortSubgroups(h.descending)(n);c.groups.forEach(t=>{const n=e[t.index];n&&(n.group=t)});const l=x.arc().innerRadius(a).outerRadius(o),u=t.schema.arrows,d="function"==typeof u||!!u&&"source"!==u,f="number"==typeof t.schema.arrowSize?t.schema.arrowSize:void 0;let m;if(d){const t=w.ribbonArrow().radius(a).headRadius(f??Math.max(10,.75*r));m=e=>t(e)??""}else{const t=w.ribbon().radius(a);m=e=>t(e)??""}return{outer:o,chords:c,arcFn:t=>l(t)??"",ribbonFn:m}}const yE=({viz:t})=>{const e=t,{width:n,height:i}=kt(e),o=Array.isArray(e.schema.nodes)&&e.schema.nodes.length>0,r=Array.isArray(e.schema.links)&&e.schema.links.length>0;if(!o&&!r)return e.ctx.nodeLookup={},e.ctx.adjacency={},{viz:t};const a=(o?e.schema.nodes:function(t,e,n){const i=new Set,o=[];for(const r of t){const t=r[e];i.has(t)||(i.add(t),o.push(t));const a=r[n];i.has(a)||(i.add(a),o.push(a))}return o.map(t=>({id:t}))}(e.schema.links,e.schema.linksSource,e.schema.linksTarget)).map((t,n)=>({__d3plus__:!0,data:t,node:t,i:n,id:e.schema.nodeId(t,n),shape:"Path"})),s={};a.forEach((t,e)=>{s[String(t.id)]=e}),e.ctx.nodeLookup=s;const c=a.length,l=Array.from({length:c},()=>new Array(c).fill(0)),h={},u=(t,e)=>{var n,i;((n=h)[i=String(t)]??(n[i]=[])).push(e)};e.schema.links.forEach((t,n)=>{const i=s[String(t[e.schema.linksSource])],o=s[String(t[e.schema.linksTarget])];null!=i&&null!=o&&(l[i][o]+=e.schema.value(t,n)||0,u(a[i].id,a[o].id),u(a[o].id,a[i].id))}),e.ctx.adjacency=h;const d=Math.min(n,i)/2,f=Math.min(.28*d,90),m=dE(e)+8;let p=gE(e,a,l,d-m),g=fE(e,a,p.outer);mE(e,a,g)||(p=gE(e,a,l,d-f),g=fE(e,a,p.outer));const{chords:y,arcFn:x,ribbonFn:b}=p;return pE(a,p.outer,f,dE(e)),a.forEach((t,e)=>{t.labelCurve=g[e]??void 0}),e.ctx.chordCtx={nodes:a,chords:y,arcFn:x,ribbonFn:b},e.ctx.chordWidth=n,e.ctx.chordHeight=i,{shapeData:a}};const xE={name:"Chord",layoutStage:yE,emit:({viz:t})=>{const e=t.ctx.chordCtx;if(!e)return[];const n=[],i=Hm(t,"Path"),o=t.schema.chordOpacity??.6;n.push(...function(t,e,n,i){const o=[],r=[];for(let a=0;a<e.chords.length;a++){const s=e.chords[a],c=e.nodes[s.source.index],l=e.nodes[s.target.index];if(!c||!l)continue;const h=Pm(n.fill,c.data,c.i),u="string"==typeof h?h:void 0,d=Pm(n.opacity,c.data,c.i),f={type:"path",shapeType:"Chord",key:`chord-ribbon-${c.id}-${l.id}`,d:e.ribbonFn(s),datum:{source:{id:c.id},target:{id:l.id},value:s.source.value},index:a,paint:{fill:Tm(n,c.data,c.i,h),fillOpacity:i,stroke:u,strokeOpacity:1,opacity:"number"==typeof d?d:1},aria:{label:`${t._drawLabel(c.data,c.i)} to ${t._drawLabel(l.data,l.i)}, ${s.source.value}.`}};o.push(f);const m=Jv(n,{...f,paint:{...f.paint,opacity:(f.paint?.opacity??1)*i}},c.data,c.i);m&&r.push(m)}return[...o,...r]}(t,e,i,o));const r=[],a=e.nodes.filter(t=>Boolean(t.group));for(const n of a){const o=Om(i,n.data,n.i);r.push({type:"path",key:`chord-arc-${n.id}`,d:e.arcFn(n.group),datum:n.data,index:n.i,paint:o,aria:{label:`${t._drawLabel(n.data,n.i)}, ${n.group.value}.`}})}return n.push(...r,...tw(i,r,t=>[a[t].data,a[t].i])),a.length&&n.push(...function(t,e){const n=jm(t,"Path"),i=n.fontColor,o=Ws(t),r=t=>{const e=Pm(i,t.data,t.i);return"string"==typeof e?e:o},a=IB(t,e.filter(t=>t.labelCurve).map(e=>({key:`chord-label-curved-${e.id}`,text:`${t._drawLabel(e.data,e.i)}`,fit:e.labelCurve,color:r(e),datum:e.data,index:e.i})),WB(n)),s=e.filter(e=>!e.labelCurve&&"along"!==hE(t,e.data,e.i)),c=s.length?Kx({data:s,label:e=>{const n=e;return t._drawLabel(n.data,n.i)},x:t=>t.labelX??0,y:t=>t.labelY??0,aes:()=>({}),rotate:t=>t.labelRotate??0,id:t=>`chord-label-${t.id}`,labelBounds:t=>t.labelBounds??!1,labelConfig:{fontColor:t=>r(t.data??t),...n,fontResize:!1,fontSize:dE(t),padding:0,textAnchor:t=>(t.data??t).labelAnchor??"start",verticalAlign:"middle"}}):[];return[...a,...GB(c,ak(a))]}(t,a)),n},chartTransform:t=>vt(t,t.ctx.chordWidth,t.ctx.chordHeight),chartBodyRect:t=>{const e=t.ctx.chordWidth??0,n=t.ctx.chordHeight??0;return{x:-e/2,y:-n/2,width:e,height:n}},setup:t=>{const e=t;t.schema.color=(e,n)=>t.schema.groupBy[0](e,n)??t.schema.nodeId(e,n),t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{if(n(i,o,r,a),t._focus&&t._focus===i.id)return e.hover(!1),t.schema.on.mouseenter.bind(t)(i,o,r,a),void(t._focus=void 0);const s=i;if(s.source&&s.target){const n=s.source.id,i=s.target.id;return void e.hover((e,o)=>{if(e.source&&e.target)return e.source.id===n&&e.target.id===i;const r=t.schema.nodeId(e,o);return r===n||r===i})}const c=t.schema.nodeId(i,o),l=t.ctx.adjacency[String(c)]??[],h=[c,...l];e.hover((e,n)=>e.source&&e.target?e.source.id===c||e.target.id===c:h.includes(t.schema.nodeId(e,n)))},e.links=function(){return arguments.length?(dn(this,"links",arguments),this):this.schema.links},e.nodes=function(){return arguments.length?(dn(this,"nodes",arguments),this):this.schema.nodes},e.nodeId=function(t){return arguments.length?(this.schema.nodeId="function"==typeof t?t:q(t),this):this.schema.nodeId},e.value=function(t){return arguments.length?(this.schema.value="function"==typeof t?t:q(t),this):this.schema.value},e.hover=hx},facet:{aspect:1},ctx:{},fields:[...pn("links","nodes"),{key:"arcThickness",default:20},{key:"arrows",default:!1},{key:"arrowSize"},{key:"chordOpacity",default:.6},{key:"directed",default:!0},{key:"links",default:I("links")},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:I("nodes")},{key:"nodeId",default:I("id")},{key:"padAngle"},{key:"padPixel",default:2},{key:"value",default:H(1)},{key:"shape",default:H("Path"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>({Path:{label:!1}})},{key:"tooltipConfig",merge:!0,factory:t=>({title:e=>e&&e.source&&e.target?`${e.source.id} → ${e.target.id}`:t._drawLabel(e,"number"==typeof e.i?e.i:0)})}]};var bE=lx(xE);function _E(t,e){return[()=>t.schema.translate("Share"),(n,i,o)=>{const r=e=>`${d.formatAbbreviate(100*e,t.schema.locale)}%`;if(o._isColorScaleBucket){const n=Ds(t,o.color,t.schema[e]);return null==n?"":r(n)}const a=xl(o);return Number.isFinite(a)?r(a):""}]}function kE(t,e=()=>!0){const n=t.schema.legend;return(i,o)=>(o.length!==t._filteredData.length||!e(t))&&n.call(t,i,o)}function vE(t,e){return(n,i)=>{const o=t.schema[e];return o(i)-o(n)}}const wE=2*Math.PI,ME=1e-9;function SE(t,e){const n=t=>"number"==typeof t&&Number.isFinite(t),i=n(t)?t*Math.PI/180:0,o=n(e)?e*Math.PI/180:i+wE;return{start:i,end:i+Math.max(-wE,Math.min(wE,o-i))}}function CE(t,e){return Math.abs(e-t)>=wE-ME}function $E(t,e){const n=e.end-e.start;if(!n)return 0;let i=(t-e.start)*Math.sign(n)%wE;return i<0&&(i+=wE),i/Math.abs(n)}const AE=t=>Math.abs(t)<ME?0:t;function zE(t,e,n=0){if(CE(t,e))return{x0:-1,x1:1,y0:-1,y1:1};const i=Math.min(t,e),o=Math.max(t,e),r=Math.max(0,Math.min(1,n)),a=[],s=[],c=(t,e)=>{a.push(AE(e*Math.sin(t))),s.push(AE(-e*Math.cos(t)))};c(i,1),c(o,1);const l=Math.PI/2;for(let t=Math.ceil(i/l-ME);t*l<=o+ME;t++)c(t*l,1);return c(i,r),c(o,r),{x0:Math.min(...a),x1:Math.max(...a),y0:Math.min(...s),y1:Math.max(...s)}}function DE(t,e,n,i){const o=zE(t,e,n>0?i/n:0);return{x0:o.x0*n,x1:o.x1*n,y0:o.y0*n,y1:o.y1*n}}function LE(t,e,n){const i=n.x1-n.x0,o=n.y1-n.y0;return Math.max(0,Math.min(i>0?t/i:1/0,o>0?e/o:1/0))}function FE(t,e,n,i,o=0,r=0){if(CE(n,i)){const n=Math.max(0,Math.min(t,e)/2-r);return{cx:t/2,cy:e/2,radius:n,box:{x0:-n,x1:n,y0:-n,y1:n}}}const a=Math.max(0,t-2*r),s=Math.max(0,e-2*r),c=Math.max(0,o);let l=LE(a,s,zE(n,i,0));if(c>0&&Number.isFinite(l)){let t=LE(a,s,zE(n,i,1));Number.isFinite(t)||(t=l);const e=t=>{const e=DE(n,i,t,c);return e.x1-e.x0<=a+ME&&e.y1-e.y0<=s+ME};for(let n=0;n<40&&t-l>1e-6;n++){const n=(l+t)/2;e(n)?l=n:t=n}}const h=Number.isFinite(l)?l:0,u=DE(n,i,h,c),d=u.x1-u.x0,f=u.y1-u.y0;return{cx:r+(a-d)/2-u.x0,cy:r+(s-f)/2-u.y0,radius:h,box:u}}function NE(t,e,n,i=0){const o=CE(e,n)?{x0:-1,x1:1,y0:-1,y1:1}:zE(e,n,0);return{width:t*(o.x1-o.x0)+2*i,height:t*(o.y1-o.y0)+2*i}}function BE(t){return{fontSize:t,lineHeight:Math.ceil(1.3*t),elbow:10,tail:8,gap:4}}function EE(t){return Math.sin(t)>=-1e-9?1:-1}function RE(t,e){return t+e.elbow+e.tail}function PE(t,e){const n={left:0,right:0},i=e.elbow+e.tail+e.gap;for(const{angle:e,width:o}of t){const t=1===EE(e)?"right":"left";n[t]=Math.max(n[t],o+i)}return n}function TE(t,e,n=()=>!0){const i=t.map(()=>null),o=Math.min(...e),r=Math.max(...e);let a=t.map((t,e)=>({...t,i:e})).filter(t=>t.size<=r-o).sort((t,e)=>t.y-e.y||t.i-e.i);for(;a.length;){const t=a[0].size/2,e=a[a.length-1].size/2,s=O$(a.map(t=>t.y),a.map(t=>t.size),[o+t,r-e]);if(s.every((t,e)=>t+a[e].size/2<=r+.5&&n(a[e].i,t))){a.forEach((t,e)=>i[t.i]=s[e]);break}const c=a.reduce((t,e)=>e.weight<t.weight||e.weight===t.weight&&e.i>t.i?e:t);a=a.filter(t=>t!==c)}return i}function OE(t,e){const n=e[0]-t[0],i=e[1]-t[1],o=n*n+i*i,r=o?Math.max(0,Math.min(1,-(t[0]*n+t[1]*i)/o)):0;return Math.hypot(t[0]+r*n,t[1]+r*i)}function WE(t,e,n,i){const o=EE(t),r=RE(e,i),a=Math.sin(t),s=Math.cos(t),c=[e*a,-e*s],l=[o*r,n],h=[o*(r-i.tail),n],u=[(e+i.elbow)*a,-(e+i.elbow)*s],d=[];OE(u,h)>=e+i.elbow/2-1e-9&&d.push([c,u,h,l]);let f=Math.abs(u[0]);const m=e*e-c[1]*n,p=Math.abs(c[0]);if(f*p<m&&(f=p<1e-9?1/0:m/p),f<=r-i.tail/2+1e-9){const t=[o*f,n];d.push([c,[(c[0]+t[0])/2,(c[1]+t[1])/2],t,l])}return d}function HE(t,e,n=2){for(let i=1;i<t.length;i++)for(let o=1;o<e.length;o++){const[r,a,s,c]=[t[i-1],t[i],e[o-1],e[o]],l=[a[0]-r[0],a[1]-r[1]],h=[c[0]-s[0],c[1]-s[1]],u=l[0]*h[1]-l[1]*h[0];if(Math.abs(u)<1e-12)continue;const d=[s[0]-r[0],s[1]-r[1]],f=(d[0]*h[1]-d[1]*h[0])/u,m=(d[0]*l[1]-d[1]*l[0])/u,p=Math.hypot(...l),g=Math.hypot(...h),y=(t,e)=>t*e>n&&(1-t)*e>n;if(y(f,p)&&y(m,g))return!0}return!1}function jE(t,e,n){return-(e+n.elbow)*Math.cos(t)}const IE=t=>"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0,GE=t=>t.datum?.data;function qE(t){const e=IE(t.fontSize),n=e??IE(t.fontMax)??24;return{fontMin:Math.min(n,e??IE(t.fontMin)??8),fontMax:n}}function VE(t,e){const n=t=>t.replace(/[\s\u00ad\u2010-]/g,""),i=n(e);return i.length>0&&n(t.join(""))===i}function YE(t){const{viz:n,slices:i,arcOf:o,nameOf:r,shareOf:a,fillOf:s,labelConfig:c}=t,l=new Map;for(const e of t.straight){const t=GE(e);if(!t)continue;const n=l.get(t);n?n.push(e):l.set(t,[e])}const h=WB(c),u=qE(c),d=[],f=[],m=new Set,p=new Map;i.forEach((t,i)=>{const g=t.i??i,y=r(t),x=l.get(t)??[],b=x[0],_=b?{fontSize:b.font?.size??0,truncated:uE(b.lines.map(t=>t.text),y)}:null,k=void 0!==b&&VE(b.lines.map(t=>t.text),y),v=o(t);if(!(v.innerRadius>0))return d.push(...x),void(k&&m.add(t));const w={...u,align:v.innerRadius>=.3*v.outerRadius?"middle":"outer"},M=HB(y,h),S=y?sE(v,M,w):null,C=lE(hE(n,t.data,g),_,S);if("straight"===C&&(d.push(...x),k&&m.add(t)),"curved"!==C||!S)return;const $=Pm(c.fontColor,t.data,g),A=s(t),z="string"==typeof $?$:e.colorContrast("string"==typeof A?A:"rgb(255, 255, 255)",n.schema.colorDefaults),D=a(t),L=S.truncated?null:cE(v,M,HB(D,h),w),F={color:z,datum:t.data,index:g},N=`pie-label-curved-${n._ids(t.data,g).join("-")}`;S.truncated||p.set(N,t),L?f.push({...F,key:N,text:y,fit:L[0]},{...F,key:`${N}-share`,text:D,fit:L[1]}):f.push({...F,key:N,text:y,fit:S})});const g=GB(IB(n,f,h),ak(d));for(const t of g){const e=p.get(String(t.key));e&&m.add(e)}return{straight:d,curved:g,whole:m}}const KE=2*Math.PI,UE=1e-9,XE=t=>[Math.sin(t),-Math.cos(t)];function ZE(t,e=0){let n=Math.min(t.startAngle,t.endAngle),i=Math.max(t.startAngle,t.endAngle);const o=t.innerRadius>0?t.innerRadius+e:0,r=t.outerRadius-e;if(!(i-n>UE&&r>o))return null;if(i-n>=KE-1e-6)return{mid:0,dir:XE(0),span:KE,inner:o,outer:r,sides:[]};const a=(t.padAngle??0)/2;let s=0;a>0&&t.innerRadius>0?s=Math.hypot(t.innerRadius,t.outerRadius)*Math.sin(a):a>0&&(n+=a,i-=a);const c=i-n;if(!(c>UE))return null;const l=(n+i)/2,h=s+e,u=[{normal:[Math.cos(n),Math.sin(n)],offset:h,ray:XE(n)},{normal:[-Math.cos(i),-Math.sin(i)],offset:h,ray:XE(i)}];return{mid:l,dir:XE(l),span:c,inner:o,outer:r,sides:u}}function QE(t,e,n,i){const[o,r]=t.normal,a=o*e[0]+r*e[1],s=t.offset+n*Math.abs(o)+i*Math.abs(r);return a>UE?s/a:1/0}function JE(t,e,n){const i=e/2,o=n/2,{dir:r,inner:a,outer:s,sides:c,span:l}=t,h=Math.abs(r[0]),u=Math.abs(r[1]),d=i*h+o*u,f=d*d-(i*i+o*o-s*s);if(i*i+o*o>s*s||f<0)return null;const m=-d+Math.sqrt(f);if(!(c.length||a>0))return{lo:-m,hi:m};let p=Math.max(0,function(t,e,n,i){if(!(i>0))return-1/0;const o=Math.abs(t[0]),r=Math.abs(t[1]),a=[];if(o>UE){const t=(e+i)/o;t*r<=n+UE&&a.push(t)}if(r>UE){const t=(n+i)/r;t*o<=e+UE&&a.push(t)}const s=e*o+n*r,c=s*s-(e*e+n*n-i*i);if(c>=0){const t=s+Math.sqrt(c);t*o>=e-UE&&t*r>=n-UE&&a.push(t)}return a.length?Math.min(...a):1/0}(r,i,o,a));return c.length&&(p=Math.max(p,l>Math.PI?function(t,e,n){const{dir:i,sides:o,span:r}=t;let a=Math.min(...o.map(t=>QE(t,i,e,n)));const s=o[0].offset/Math.sin(r/2),c=[[1,0],[-1,0],[0,1],[0,-1]];for(const t of c){const r=e=>t[0]*e[0]+t[1]*e[1];if(r(o[0].ray)<-1e-9||r(o[1].ray)<-1e-9)continue;const c=e*Math.abs(t[0])+n*Math.abs(t[1]),l=r(i),h=s*l;l<-1e-9?a=Math.min(a,(c-h)/-l):c<=h+UE&&(a=-1/0)}return a}(t,i,o):Math.max(...c.map(t=>QE(t,r,i,o))))),p<=m+UE?{lo:p,hi:Math.max(p,m)}:null}function tR(t,e,n,i){return{x:e*t.dir[0]-n/2,y:e*t.dir[1]-i/2,width:n,height:i}}function eR(t,e,n){const i=JE(t,e,n);return i?tR(t,(i.lo+i.hi)/2,e,n):null}function nR(t,e,n=40){const i=n=>null!==JE(t,...e(n));let o=0,r=2*t.outer;if(!i(o))return null;for(let t=0;t<n;t++){const t=(o+r)/2;i(t)?o=t:r=t}return o>0?eR(t,...e(o)):null}const iR={fontMin:10,fontMax:32,padding:5,lineHeight:1.2,shareRatio:.7,shareKeep:.75,shareFont:16,margin:.2,maxLines:4},oR=t=>"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0;function rR(t){const e=oR(t.fontSize),n=e??oR(t.fontMax)??iR.fontMax,i=Math.min(n,e??oR(t.fontMin)??iR.fontMin),o="number"==typeof t.padding&&t.padding>=0?t.padding:iR.padding;return{...iR,fontMin:i,fontMax:n,padding:o}}function aR(t,e,n){const i=t.split(/\s+/).filter(Boolean),o=i.length;if(!o)return[];const r=new Map,a=(t,n)=>{const o=`${t},${n}`;let a=r.get(o);return void 0===a&&(a=e(i.slice(t,n).join(" ")),r.set(o,a)),a};let s=Array.from({length:o+1},(t,e)=>e?a(0,e):0);const c=[s[o]];for(let t=2;t<=Math.min(n,o);t++){const e=s.map(()=>1/0);for(let n=t;n<=o;n++)for(let i=t-1;i<n;i++)e[n]=Math.min(e[n],Math.max(s[i],a(i,n)));s=e,c.push(s[o])}return c}function sR(t,e,n,i=iR){const{fontMin:o,fontMax:r,padding:a,lineHeight:s}=i;if(!e.length)return null;const c=(t,r,c)=>{const l=c?Math.max(o,Math.round(r*i.shareRatio)):null,h=t*s*r+1;return{width:1.02*Math.max(e[t-1]*r,l?n*l:0)+2,height:h+(l?a+s*l+1:0),nameHeight:h,shareSize:l,margin:Math.max(a,r*i.margin)}},l=e=>null!==JE(t,e.width+2*e.margin,e.height+2*e.margin),h=t=>{let n={lines:0,size:0};return e.forEach((e,i)=>{const a=((t,e)=>{let n=Math.ceil(o),i=Math.floor(r);if(i<n&&(i=n=o),!l(c(t,n,e)))return 0;for(;n<i;){const o=Math.ceil((n+i)/2);l(c(t,o,e))?n=o:i=o-1}return n})(i+1,t);a>n.size&&(n={lines:i+1,size:a})}),n},u=h(!1),d=null!==n?h(!0):{lines:0,size:0},f=Math.min(u.size*i.shareKeep,i.shareFont),m=d.size>0&&d.size>=f?{...d,share:!0}:{...u,share:!1};if(!m.size)return function(t,e){const{fontMin:n,padding:i,lineHeight:o}=e,r=o*n+2*i+1,a=nR(t,t=>[t,r]);return!a||a.width-2*i<2*n?null:{fontSize:n,lines:1,shareSize:null,name:a,share:null,center:[a.x+a.width/2,a.y+a.height/2],truncated:!0}}(t,i);const p=c(m.lines,m.size,m.share),g=eR(t,p.width+2*p.margin,p.height+2*p.margin),y=[g.x+g.width/2,g.y+g.height/2],x=y[0]-p.width/2-a,b=y[1]-p.height/2;return{fontSize:m.size,lines:m.lines,shareSize:p.shareSize,name:{x:x,y:b-a,width:p.width+2*a,height:p.nameHeight+2*a},share:p.shareSize?{x:x,y:b+p.nameHeight,width:p.width+2*a,height:s*p.shareSize+2*a+1}:null,center:y,truncated:!1}}function cR(t,e){const n=ak(t);if(!n.length)return;const i=e-(Math.min(...n.map(t=>t.y-t.height/2))+Math.max(...n.map(t=>t.y+t.height/2)))/2,o=new Set;for(const e of t){const t=e.transform;t&&!o.has(t)&&(o.add(t),t.y=(t.y??0)+i)}}const lR=t=>t.datum?.data;function hR(t){const{viz:n,slices:i,arcOf:o,sc:r,sharePct:a,labelConfig:s}=t,c=rR(s),l=WB(s),h=t=>HB(t,l)(1),u=new Map;i.forEach((t,e)=>{const i=n._drawLabel(t.data,t.i??e),r=i?ZE(o(t)):null;if(!r)return;const s=sR(r,aR(String(i),h,c.maxLines),h(a(t)),c);s&&u.set(t,s)});const d=Kx({data:i,label:(t,e)=>{const o=n._drawLabel(i[e].data,i[e].i??e);return u.get(i[e])?.share?[o,a(i[e])]:[o]},x:()=>0,y:()=>0,aes:()=>({}),rotate:H(0),id:(t,e)=>`pie-label-${e}`,labelBounds:(t,e)=>{const n=u.get(i[e]);if(!n)return!1;return(n.share?[n.name,n.share]:[n.name]).map(t=>({...t,angle:0}))},labelConfig:{fontColor:t=>{const i=t.data??t,o=Pm(r.fill,i.data,i.i??0);return e.colorContrast("string"==typeof o?o:"rgb(255, 255, 255)",n.schema.colorDefaults)},textAnchor:"middle",verticalAlign:"middle",...s,fontResize:!1,fontSize:t=>{const e=t.data?u.get(t.data):void 0;return e?1===t.l&&e.shareSize?e.shareSize:e.fontSize:c.fontMin}}});if(void 0===s.verticalAlign){const t=new Map;for(const e of d){const n=lR(e);n&&t.set(n,[...t.get(n)??[],e])}t.forEach((t,e)=>{const n=u.get(e);n&&cR(t,n.center[1])})}return d}function uR(t,e){const n=t.split(/\s+/).filter(Boolean);let i=e(n.join(" "));for(let t=1;t<n.length;t++)i=Math.min(i,Math.max(e(n.slice(0,t).join(" ")),e(n.slice(t).join(" "))));return i}function dR(t){const e=t.schema.locale;return t=>`${d.formatAbbreviate(100*(t.share??0),e)}%`}function fR(t){const e=t.fontSize;return"number"==typeof e&&e>0?e:12}function mR(t,e){return"outside"===t||"inside"!==t&&"along"!==t&&!e}function pR(t,e){return e.some((e,n)=>{const i=hE(t,e.data,e.i??n);return"inside"!==i&&"along"!==i})}function gR(t,e){const n=t.ctx.arcData,i=t.ctx.pieLabelPlan;if(i&&i.arc===n&&i.slices===e)return i.plan;const o=n.innerRadius(),r=n.outerRadius(),a=Hm(t,"Path"),s=jm(t,"Path"),c=dR(t),l=e=>t._drawLabel(e.data,e.i??0),h=t=>({innerRadius:o(t,t.i??0),outerRadius:r(t,t.i??0),startAngle:t.startAngle,endAngle:t.endAngle,padAngle:t.padAngle}),u=YE({viz:t,slices:e,arcOf:h,nameOf:l,shareOf:c,fillOf:t=>Pm(a.fill,t.data,t.i??0),straight:hR({viz:t,slices:e,arcOf:h,sc:a,sharePct:c,labelConfig:s}),labelConfig:s}),d=[];if(pR(t,e)){const n=WB(s),i=fR(s);e.forEach((e,o)=>{const r=e.i??o,a=l(e),s=hE(t,e.data,r);if(!a||!mR(s,u.whole.has(e)))return;const h=`${a} ${c(e)}`,f=t=>HB(t,n)(i);d.push({slice:e,index:r,angle:(e.startAngle+e.endAngle)/2,text:h,width:f(h),wrapWidth:uR(h,f),weight:e.value})})}const f={straight:u.straight,curved:u.curved,outside:d};return t.ctx.pieLabelPlan={arc:n,slices:e,plan:f},f}const yR={start:.5,end:1};function xR(t,e){const n=RE(t.radius,e)+e.gap;return{left:t.cx-n,right:t.width-t.cx-n}}function bR(t,e,n){const{radius:i,cy:o,height:r}=e,a=t.map(()=>null),s=(e,o)=>WE(t[e].angle,i,o,n);for(const e of[1,-1]){let c=t.map((t,n)=>EE(t.angle)===e?n:-1).filter(t=>t>=0);for(;c.length;){const e=TE(c.map(e=>({y:jE(t[e].angle,i,n),size:t[e].lines*n.lineHeight,weight:t[e].weight})),[-o,r-o],(t,e)=>s(c[t],e).length>0),l=c.map((t,n)=>({k:t,y:e[n]})).filter(t=>null!==t.y).sort((t,e)=>t.y-e.y),h=[];let u=!1;for(const{k:t,y:e}of l){const n=s(t,e).find(t=>h.every(e=>!HE(t,e.leader)));if(!n){u=!0;break}h.push({k:t,y:e,leader:n})}if(!u){for(const{k:t,y:e,leader:n}of h)a[t]={y:e,leader:n};break}const d=c.reduce((e,n)=>t[n].weight<t[e].weight?n:e);c=c.filter(t=>t!==d)}}return a}const _R=t=>t.match(/\S+\s*/g)??[],kR=t=>t.replace(/[\s\u00ad\u2010-]/g,"");function vR(t,e,n){const i=new Set,o=[],r=BE(fR(jm(t,"Path"))),a=function(t,e,n,i){const o=jm(t,"Path"),r=xR(n,i),a=RE(n.radius,i)+i.gap,s=t=>1===EE(t.angle),c=t=>s(t)?r.right:r.left,l=e.filter(t=>c(t)>=3*i.fontSize);if(!l.length)return[];const h=Ws(t),u=(new Ir).renderMode("compute").locale(t.schema.locale).data(l.map((t,e)=>({id:`${e}`,c:t}))).config({fontWeight:400,...WB(o),fontSize:i.fontSize,lineHeight:1.2*i.fontSize,fontColor:({c:t})=>{const e=Pm(o.fontColor,t.slice.data,t.index);return"string"==typeof e?e:h},text:({c:t})=>t.text,split:_R,textAnchor:({c:t})=>s(t)?"start":"end",maxLines:2,ellipsis:t=>t,padding:0,x:({c:t})=>s(t)?a:-a-r.left,y:0,width:({c:t})=>c(t),height:2*i.lineHeight});return u.toScene().children.flatMap(e=>{const n=e.datum?.c;if(!n||"text"!==e.type||!e.lines.length)return[];const i=kR(t._drawLabel(n.slice.data,n.index)),o=c(n)+.5;return kR(e.lines.map(t=>t.text).join("")).startsWith(i)&&e.lines.every(t=>t.width<=o)?[{c:n,node:e}]:[]})}(t,e,n,r);if(!a.length)return{nodes:[],named:i,crowded:o};const s=bR(a.map(({c:t,node:e})=>({angle:t.angle,weight:t.weight,lines:e.lines.length})),n,r),c=Ws(t),l=1.2*r.fontSize,h=[],u=[];return a.forEach(({c:e,node:n},a)=>{const d=s[a];if(!d)return void o.push({angle:e.angle,size:n.lines.length*r.lineHeight});i.add(e.slice);const f=`pie-outside-${t._ids(e.slice.data,e.index).join("-")}`,m={interactive:!1,datum:e.slice.data,index:e.index,aria:{hidden:!0},enterWindow:yR},p=n.transform??{};h.push({...n,...m,key:f,transform:{...p,y:(p.y??0)+d.y-n.lines.length*l/2},paint:{...n.paint,opacity:1}}),u.push({type:"line",key:`${f}-leader`,...m,points:d.leader,curve:"linear",paint:{fill:"none",stroke:c,strokeWidth:1,strokeOpacity:.5,opacity:1}})}),{nodes:[...u,...h],named:i,crowded:o}}const wR=new WeakMap;function MR(t,e){const n=gR(t,e),i=wR.get(n);if(i)return i;const o=t.ctx.arcData,r=t.ctx.pieCenter,{width:a,height:s}=kt(t),c=e.length?vR(t,n.outside,{radius:o.outerRadius()(e[0],e[0].i??0),cx:r?.x??a/2,cy:r?.y??s/2,width:a,height:s}):{nodes:[],named:new Set,crowded:[]};return wR.set(n,c),c}const SR={left:0,right:0,top:0,bottom:0};function CR(t,e,n,i){const o=t+e,r=Math.max(0,n-i);if(o<=r)return[t,e];const a=o>0?r/o:0;return[t*a,e*a]}function $R(t,e,n){return t<=n?t:e<=n?e:0}function AR(t,e,n,i){if(!pR(t,e))return n;const{outside:o}=gR(t,e);if(!o.length)return n;const{width:r}=kt(t),a=BE(fR(jm(t,"Path"))),s=.3*r,c=PE(o.map(t=>({angle:t.angle,width:$R(t.width,t.wrapWidth,s)})).filter(t=>t.width>0),a),[l,h]=CR(Math.max(n.left,Math.ceil(c.left)),Math.max(n.right,Math.ceil(c.right)),r,i);return{...n,left:l,right:h}}function zR(t,e,n,i){let o=t.top,r=t.bottom;for(const{angle:t,size:n}of e)Math.cos(t)>=0?o+=n:r+=n;return[o,r]=CR(o,r,n,i),{...t,top:o,bottom:r}}function DR(t,e){return{...t,left:e.left?t.left:0,right:e.right?t.right:0}}const LR=(t,e)=>t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom;function FR(t,e,n){let i=SR,o=e(i);for(let r=0;r<2;r++){const r=AR(t,o,i,n.width);if(LR(r,i))break;i=r,o=e(i)}if(!i.left&&!i.right)return o;const{crowded:r}=MR(t,o);if(r.length){const a=zR(i,r,kt(t).height,n.height);LR(a,i)||(i=a,o=e(i))}const a={left:!1,right:!1};for(const e of MR(t,o).named){a[1===EE((e.startAngle+e.endAngle)/2)?"right":"left"]=!0}const s=DR(i,a);return LR(s,i)?o:e(s)}function NR(t){return SE(t.schema.startAngle,t.schema.endAngle)}function BR(t){const{width:e,height:n}=kt(t),{start:i,end:o}=NR(t);return FE(e,n,i,o).radius}function ER(t){const{start:e,end:n}=NR(t),i=zE(e,n),o=i.y1-i.y0;return o>0?(i.x1-i.x0)/o:1}function RR(t){const e=t.schema.shapeConfig??{};return 3*("number"==typeof e.strokeWidth?e.strokeWidth:2)/2}function PR(t,e=SR){const{width:n,height:i}=kt(t),o=Math.max(0,n-e.left-e.right),r=Math.max(0,i-e.top-e.bottom),a=RR(t),s=NR(t),c=t.ctx.pie,l=t.schema.padAngle??0,h=t.schema.padPixel??0,u=t.schema.sort,d=t.schema.value,f=e=>c.startAngle(s.start).endAngle(s.end).padAngle(l||h/e).sort(u).value(d)(t._filteredData),m=FE(o,r,s.start,s.end,0,a),p=o<n||r<i?FE(n,i,s.start,s.end,0,a).radius:m.radius,g=p>0?m.radius/p:1,y=t.schema.innerRadius,x="function"==typeof y?y:()=>y,b=(t,e)=>x(t,e)*g;let _=f(m.radius);const k=_.reduce((t,e,n)=>Math.min(t,Number(b(e,n))||0),1/0),v=Number.isFinite(k)&&k>0?FE(o,r,s.start,s.end,k,a):m;v.radius!==m.radius&&(_=f(v.radius));const w=v.radius,M=_.reduce((t,e)=>t+e.value,0);return _.forEach((t,e)=>{t.__d3plus__=!0,t.i=e;const n=M?t.value/M:0;t.share=n,gl(t.data,n)}),t.ctx.arcData=R.arc().innerRadius(b).outerRadius(w),t.ctx.pieData=_,t.ctx.pieSweep=s,t.ctx.pieCenter={x:e.left+v.cx,y:e.top+v.cy},t.ctx.pieBox=v.box,_}const TR=({viz:t})=>{const e=PR(t),n=NR(t),i=NE(.6*t.ctx.arcData.outerRadius()(e[0]),n.start,n.end,RR(t));return{shapeData:FR(t,e=>PR(t,e),i)}};const OR={name:"Pie",layoutStage:TR,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=t.ctx.arcData,o=i.innerRadius(),r=i.outerRadius(),s=Hm(t,"Path"),c=t._pendingEnterOrigin,l=c?.parentStartAngle,h=c?.parentEndAngle,u=void 0!==l&&void 0!==h?{start:l,span:h-l}:void 0,d=Boolean(t._pendingExitReunion),f=t.ctx.pieSweep??{start:0,end:a.FULL_TURN},m={viz:t,arcMaker:t=>i(t)??"",resolveInnerRadius:o,resolveOuterRadius:r,sc:s,value:t.schema.value,sharePct:dR(t),flipSource:u,isReunionDraw:d,sweep:f},p=n.map((t,e)=>function(t,e,n){const{viz:i,arcMaker:o,resolveInnerRadius:r,resolveOuterRadius:s,sc:c,value:l,sharePct:h,flipSource:u,isReunionDraw:d,sweep:f}=n,m=Pm(c.fill,t.data,t.i??0),p=Pm(c.stroke,t.data,t.i??0),g=Pm(c.strokeWidth,t.data,t.i??0),y={innerRadius:r(t,t.i??0),outerRadius:s(t,t.i??0),startAngle:t.startAngle,endAngle:t.endAngle,padAngle:t.padAngle},x=f.end-f.start||a.FULL_TURN,b=(t,e)=>e.start+(t-f.start)/x*e.span,_=u?{...y,startAngle:b(t.startAngle,u),endAngle:b(t.endAngle,u)}:void 0,k=d?{...y,startAngle:f.start,endAngle:f.end}:void 0;return{type:"path",key:`pie-${i._ids(t.data,t.i??0).join("-")}`,d:o(t),arc:y,flipFromArc:_,reunionFromArc:k,...(v=f,0===v.start&&v.end===a.FULL_TURN?{}:{sweep:{startAngle:f.start,endAngle:f.end}}),shapeType:"Pie",transform:{x:0,y:0},startAngle:t.startAngle,endAngle:t.endAngle,datum:t.data,paint:{fill:Tm(c,t.data,t.i??0,m),stroke:p,strokeWidth:g,opacity:1},aria:{label:`${e+1}. ${i._drawLabel(t.data,t.i??0)}, ${l(t.data,t.i??0)}, ${h(t)}.`}};var v}(t,e,m)),g=gR(t,n),y=MR(t,n),x=new Set(Array.from(y.named,t=>t.data)),b=g.straight.filter(t=>{const e=t.datum?.data;return!e||!y.named.has(e)}),_=g.curved.filter(t=>!x.has(t.datum));!function(t,e,n){for(const i of t){const t=i;if(t.shapeType="Label",!e)continue;const o=t.transform??{},r=o.x??0,a=o.y??0,s=Math.hypot(r,a),c=Math.atan2(r,-a),l=e.start+$E(c,n)*e.span;t.flipFromTransform={x:s*Math.sin(l),y:-s*Math.cos(l)}}}(b,u,f);const k=tw(s,p,t=>[n[t].data,n[t].i??0]);return[...p,...k,...b,..._,...y.nodes]},insetRegion:Cp,chartTransform:t=>{const e=t.ctx.pieCenter;if(!e){const{width:e,height:n}=kt(t);return vt(t,e,n)}return{x:t._margin.left+e.x,y:t._margin.top+e.y}},chartBodyRect:t=>{const e=t.ctx.pieBox;return e?{x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0}:{x:0,y:0,width:0,height:0}},facet:{aspect:ER},ctx:{pie:x.pie()},fields:[{key:"innerRadius",default:0},{key:"startAngle",default:0},{key:"endAngle"},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:I("value"),coerce:t=>"function"==typeof t?t:q(t)},{key:"sort",factory:t=>{const e=t.schema.value;return(t,n)=>e(n)-e(t)}},{key:"legendSort",factory:t=>vE(t,"value")},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t.ctx.pieData;return i?`${++i[n].index}. ${t._drawLabel(e,n)}, ${t.schema.value(e,n)}.`:""},Path:{labelConfig:{fontResize:!0}},stroke:()=>Os(t),strokeWidth:2})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[_E(t,"value")]})},{key:"legend",coerce:"const",factory:kE}]};var WR=lx(OR);var HR=lx({name:"Donut",emit:OR.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:t=>()=>BR(t)/2}]},WR);const jR="::connector";function IR(t,e){const n="x"===e?"y":"x",i=new Map;for(const o of t){const t=`${o[e]}`;let r=i.get(t);r||i.set(t,r={});const a=o[n];f.finite(a)&&((!r.lo||a<r.lo[n])&&(r.lo=o),(!r.hi||a>r.hi[n])&&(r.hi=o))}const o=[];return i.forEach(({lo:t,hi:e},i)=>{t&&e&&t!==e&&t[n]!==e[n]&&o.push({category:i,lo:t,hi:e})}),o}function GR(t){const e={...t,interactive:!1};return delete e.datum,e}function qR(t){const{viz:e}=t,n="x"===e.schema.discrete?"x":"y",i=IR(t.values,n);if(!i.length)return[];const o=i.flatMap(({category:t,lo:e,hi:n})=>[{__d3plus__:!0,data:e,i:e.i,category:t},{__d3plus__:!0,data:n,i:n.i,category:t}]),r=e=>{const n=t.shapeConfig[e];return t=>n(t.data,t.data.i)},a=Rm("Line").renderMode("compute").config(t.shapeConfig).data(o),s=Hm(e,"Line");return void 0===e.schema.shapeConfig.duration&&delete s.duration,a.config(s).config({curve:"linear",hitArea:!1,id:t=>`${t.category}${jR}`,label:!1,x:r("x"),y:r("y")}),Im(a).map(GR)}const VR=(t,e)=>{const n=Lt({...t.shapeConfig,id:t=>`${t.id}_${t.discrete}`});return[...qR(t),...Nz.Circle({...t,shapeConfig:n},e)]};function YR(t,e,n){const i=new Map;t.forEach((t,o)=>{const r=`${e(t,o)}`,a=n(t,o),s=i.get(r);f.finite(a)?s&&f.finite(s[0])?i.set(r,[Math.min(s[0],a),Math.max(s[1],a)]):i.set(r,[a,a]):s||i.set(r,[NaN,NaN])});const o=new Map;return i.forEach(([t,e],n)=>o.set(n,f.finite(t)?e-t:0)),o}function KR(t,e,n){const i=e=>t().get(`${n(e)}`)??0;return(t,n)=>"ascending"===e?i(t)-i(n):i(n)-i(t)}function UR(t,e){e.axis&&e.sort&&t.schema[`${e.axis}Sort`]===e.sort&&(t.schema[`${e.axis}Sort`]=void 0),e.axis=e.sort=void 0;const n=t.schema.gapSort;if("ascending"!==n&&"descending"!==n)return;const i="x"===t.schema.discrete?"x":"y";if(t.schema[`${i}Sort`])return;const o=t[`_${i}`],r=t["_"+("x"===i?"y":"x")],a=new WeakMap,s="y"===i?"ascending"===n?"descending":"ascending":n;e.axis=i,e.sort=t.schema[`${i}Sort`]=KR(()=>{const e=t._filteredData||[];let n=a.get(e);return n||a.set(e,n=YR(e,o,r)),n},s,t=>o(t,0))}function XR(t){return e.colorContrast(Os(t),t.schema.colorDefaults)===t.schema.colorDefaults.dark?e.colorGray[500]:e.colorGray[700]}const ZR={name:"Dumbbell",paintDriven:!0,setup:t=>{const e={};t.ctx.dumbbell=e,t._plotShapeEmitters={Circle:VR},t._plotColumnHighlight=yN(t);const n=t._preDraw.bind(t);t._preDraw=()=>{UR(t,e),n()}},ctx:{},fields:[{key:"discrete",default:"y"},{key:"gapSort",default:!1},{key:"shapeConfig",merge:!0,factory:t=>({Circle:{label:!1,trail:!1},Line:{label:!1,stroke:()=>XR(t),strokeWidth:3}})}]};var QR=lx(ZR,ZD);var JR=lx({name:"LinePlot",paintDriven:!0,ctx:{},fields:[{key:"discrete",default:"x"},{key:"lineLabels",default:"along"},{key:"shape",default:H("Line"),coerce:"const"}]},ZD);const tP={name:"FanChart",paintDriven:!0,ctx:{},fields:[{key:"forecast",default:"auto"}]};var eP=lx(tP,JR);function nP(t,e,n){if(t<=0||!(e>0))return[];const i=t>1?Math.min(.95,Math.max(0,n||0)):0,o=e/(t-i),r=o*(1-i);return Array.from({length:t},(t,e)=>({start:e*o,end:e*o+r}))}function iP(t){return Number.isFinite(t)&&t>0?t:0}function oP(t){return t.reduce((t,e)=>Math.max(t,iP(e)),0)}function rP(t,e,n=0){const i=Math.max(oP(t),iP(n));return t.map(t=>i>0?iP(t)/i*e:0)}function aP(t){const e=t.length;if(e<2)return t.map(()=>0);const n=[];for(let i=0;i<e-1;i++){const e=t[i+1].s-t[i].s;n.push(e>0?(t[i+1].w-t[i].w)/e:0)}const i=t.map((t,i)=>{if(0===i)return n[0];if(i===e-1)return n[e-2];const o=n[i-1],r=n[i];return o*r<=0?0:(o+r)/2});for(let t=0;t<e-1;t++){const e=n[t];if(0===e){i[t]=0,i[t+1]=0;continue}const o=i[t]/e,r=i[t+1]/e,a=o*o+r*r;if(a>9){const n=3/Math.sqrt(a);i[t]=n*o*e,i[t+1]=n*r*e}}return i}function sP(t,e,n){if(!t.length)return[];if(!n)return t.flatMap((t,n)=>[{s:t.start,w:e[n],m:0},{s:t.end,w:e[n],m:0}]);const i=t.length-1,o=t.map((t,n)=>({s:t.start,w:e[n]}));o.push({s:t[i].end,w:e[i]});const r=aP(o);return o.map((t,e)=>({...t,m:r[e]}))}function cP(t,e,n,i){const o=e.s-t.s;if(!(o>0))return t.w;const r=Math.min(1,Math.max(0,(n-t.s)/o));if("smooth"!==i)return t.w+(e.w-t.w)*r;const a=r*r,s=a*r;return(2*s-3*a+1)*t.w+(s-2*a+r)*o*t.m+(-2*s+3*a)*e.w+(s-a)*o*e.m}function lP(t,e){return t.w===e.w&&0===t.m&&0===e.m}function hP(t,e,n,i,o=12){const r=[];if(!(n>e))return r;for(let a=0;a<t.length-1;a++){const s=t[a],c=t[a+1],l=Math.max(e,s.s),h=Math.min(n,c.s);if(!(h>l&&c.s>s.s))continue;const u="smooth"!==i||lP(s,c)?1:Math.max(1,Math.ceil(o*(h-l)/(c.s-s.s)));for(let t=0;t<=u;t++){const e=l+(h-l)*t/u,n=cP(s,c,e,i),o=r[r.length-1];o&&o[0]===e&&o[1]===n||r.push([e,n])}}return r}const uP=t=>Math.round(100*t)/100;function dP(t,e,n){if(t.length<2)return"";const i=(t,e)=>"horizontal"===n?`${uP(t)},${uP(e)}`:`${uP(e)},${uP(t)}`,o=t.map(([t,n])=>i(t,e-n/2)),r=t.slice().reverse().map(([t,n])=>i(t,e+n/2));return`M${o.join("L")}L${r.join("L")}Z`}function fP(t){if(!t.length)return{min:0,max:0};const e=t.map(t=>t[1]);return{min:Math.min(...e),max:Math.max(...e)}}function mP(t){const e=(t,e)=>Number.isFinite(t)&&Number.isFinite(e)&&0!==e?t/e:NaN;return{first:t.map(n=>e(n,t[0])),previous:t.map((n,i)=>i?e(n,t[i-1]):NaN)}}function pP(t){var e;return(e=t.ctx).funnelRates??(e.funnelRates=new WeakMap)}function gP(t,e){const n=t.schema.sort;return"function"==typeof n?e.slice().sort(n):e}function yP(t){const e=Number(t.ctx.funnelScaleMax);return Number.isFinite(e)&&e>0?e:0}function xP(t){return"horizontal"===t.schema.orient?"horizontal":"vertical"}function bP(t){return"smooth"===t.schema.curve?"smooth":"linear"}function _P(t,e,{width:n,height:i},o){const r=xP(t),a=bP(t),s=t.schema.value,c=e.map((t,e)=>Number(s(t,e))),l="vertical"===r,h=Math.max(0,(l?i:n)-4),u=Math.max(0,(l?n:i)-4),d=nP(e.length,h,Number(t.schema.stagePadding)).map(t=>({start:t.start+2,end:t.end+2})),f=rP(c,u,o),m=sP(d,f,!!t.schema.taper),p=mP(c),g=e.map((t,e)=>{const n=d[e],i=hP(m,n.start,n.end,a),o=e?hP(m,d[e-1].end,n.start,a):[];return{__d3plus__:!0,data:t,i:e,value:c[e],first:p.first[e],previous:p.previous[e],start:n.start,end:n.end,points:i,neck:o,...fP(i)}});return{stages:g,shared:{orient:r,curve:a,center:(l?n:i)/2,breadth:u,offset:2}}}const kP=({viz:t})=>{const e=gP(t,t._filteredData??[]),{stages:n,shared:i}=_P(t,e,kt(t),yP(t)),o=pP(t);for(const t of n)o.set(t.data,{first:t.first,previous:t.previous});return t.ctx.funnel=i,{shapeData:n}};function vP(t){return!0===t||"both"===t?["first","previous"]:"first"===t||"previous"===t?[t]:Array.isArray(t)?["first","previous"].filter(e=>t.includes(e)):[]}function wP(t,e,n,i){const{fontMax:o,padding:r,lineHeight:a}=i,s=e.width-2*r,c=e.height-2*r;if(!(t.length&&s>0&&c>0))return 0;const l=Math.max(...t.map(t=>n(t,o))),h=c/(t.length*a),u=l>0?s/l*o:o,d=Math.min(o,h,u);return Math.floor(2*d)/2}function MP(t,e,n,i,o){for(let r=t.length;r>0;r--){const a=t.slice(0,r),s=wP(a,e,i,o),c=n?wP(a,n,i,o):0;if(s>=o.fontMin&&s>=.8*c)return{position:"inside",fontSize:s,lines:a};if(c>=o.fontMin)return{position:"outside",fontSize:c,lines:a}}return null}function SP(t,e,n,i=1/0){const o=t.map(t=>MP(t.lines,t.inside,t.outside,e,t.fixed?{...n,fontMin:t.fixed,fontMax:t.fixed}:n)),r=o.flatMap((e,n)=>e&&!t[n].fixed?[n]:[]);if(!r.length)return{plans:o,fontSize:0};const a=Math.min(i,...r.map(t=>o[t].fontSize));for(const i of r){const r=o[i],s="inside"===r.position||wP(r.lines,t[i].inside,e,n)>=a;o[i]={...r,position:s?"inside":"outside",fontSize:a}}return{plans:o,fontSize:a}}function CP(t,e,n,i){const o=e*n,r="top"===i?t.y:t.y+(t.height-o)/2;return Array.from({length:e},(e,i)=>({x:t.x,y:r+i*n,width:t.width,height:n}))}function $P(t,e){return`${d.formatAbbreviate(100*e,t.schema.locale)}%`}function AP(t,e){const n=t.schema.valueFormat,i=[t._drawLabel(e.data,e.i)];if(Number.isFinite(e.value)&&i.push(`${n(e.value,e.data)}`),!e.i)return i;const o=vP(t.schema.conversion);for(const n of o){const o="first"===n?e.first:e.previous;if(!Number.isFinite(o))continue;const r=t.schema.translate("first"===n?"of first":"of previous");i.push(`${$P(t,o)} ${r}`)}return i}function zP(t,e){const n=t.end-t.start,i=e.center+t.max/2+6,o=Math.max(0,(e.breadth-t.max)/2-6);return"horizontal"===e.orient?{inside:{x:t.start,y:e.center-t.min/2,width:n,height:t.min},outside:{x:t.start,y:i,width:n,height:o}}:{inside:{x:e.center-t.min/2,y:t.start,width:t.min,height:n},outside:{x:i,y:t.start,width:o,height:n}}}function DP(t,e){return{x:t.x+e,y:t.y+e,width:Math.max(0,t.width-2*e),height:Math.max(0,t.height-2*e)}}function LP(t,e,n){const i=(t,i)=>{const o=Pm(t,e,n);return"number"==typeof o&&o>0?o:i};return{fontMin:i(t.fontMin,10),fontMax:i(t.fontMax,16),padding:4,lineHeight:1.2}}function FP(t,e,n,i=1/0){const o=jm(t,"Path"),a=e[0],c=a?LP(o,a.data,a.i):LP({},{},0),l=s.fontFamilyStringify((a?Pm(o.fontFamily,a.data,a.i):void 0)??t.schema.fontFamily),h=e.map(e=>{const{inside:i,outside:r}=zP(e,n),a=Pm(o.fontSize,e.data,e.i);return{lines:AP(t,e),inside:i,outside:r,fixed:"number"==typeof a&&a>0?a:void 0}}),{plans:u,fontSize:d}=SP(h,(t,e)=>Number(r.textWidth(t,{"font-family":l,"font-size":e,"font-weight":600}))||0,c,i),f=new Map;return u.forEach((t,n)=>{t&&f.set(e[n].data,t)}),{plans:f,fontSize:d,sizing:c,user:o}}function NP(t,e,n){return e.length?FP(t,e,n).fontSize:0}function BP(t){const e=Number(t.ctx.funnelLabelSize);return Number.isFinite(e)&&e>0?e:1/0}function EP(t,n,i){const o=Hm(t,"Path"),{plans:r,sizing:a,user:s}=FP(t,n,i,BP(t)),c="horizontal"===i.orient,l=new Map;for(const t of n){const e=r.get(t.data);if(!e)continue;const{inside:n,outside:o}=zP(t,i),a="inside"===e.position?n:o,s="outside"===e.position&&c?"top":"middle",h=CP(DP(a,4),e.lines.length,1.2*e.fontSize,s);l.set(t.data,{stage:t,plan:e,boxes:h})}const h=t=>l.get((t&&t.data)??t);return Kx({data:n.map(t=>t.data),datum:t=>t,label:t=>l.get(t)?.plan.lines??!1,labelBounds:t=>{const e=l.get(t)?.boxes;return!!e&&e.map(t=>({...t,y:t.y-1,height:t.height+2}))},x:()=>0,y:()=>0,aes:()=>({}),rotate:H(0),id:(e,n)=>`funnel-label-${t._ids(e,n).join("-")}`,labelConfig:{fontResize:!1,padding:0,lineHeight:t=>1.2*(h(t)?.plan.fontSize??a.fontMin),fontWeight:t=>t&&0===t.l?600:400,textAnchor:t=>"outside"!==h(t)?.plan.position||c?"middle":"start",verticalAlign:"top",fontColor:n=>{const i=h(n);if(!i||"outside"===i.plan.position)return Ws(t);const r=Pm(o.fill,i.stage.data,i.stage.i);return"string"==typeof r?e.colorContrast(r,t.schema.colorDefaults):Ws(t)},...s,fontSize:t=>h(t)?.plan.fontSize??a.fontMin}})}function RP(t,e={}){return{...e,...t.schema.connectorConfig??{}}}function PP(t,e,n,i={}){const o=t.schema.connectorConfig??{},r=e.data,a=e.i,s=Pm(o.fill,r,a)??n;return{fill:Tm(RP(t,i),r,a,s),opacity:Pm(o.opacity,r,a),stroke:Pm(o.stroke,r,a),strokeWidth:Pm(o.strokeWidth,r,a)}}function TP(t,e){const n=t.schema.valueFormat,i=Number.isFinite(e.value)?`, ${n(e.value,e.data)}`:"";return`${e.i+1}. ${t._drawLabel(e.data,e.i)}${i}.`}const OP=({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.funnel;if(!n.length||!i)return[];const o=Hm(t,"Path"),r=e=>`funnel-${t._ids(e.data,e.i).join("-")}`,a=[],s=[],c=[];for(const e of n){const n=Om(o,e.data,e.i);a.push({type:"path",key:r(e),d:dP(e.points,i.center,i.orient),datum:e.data,index:e.i,shapeType:"Path",paint:n,aria:{label:TP(t,e)}});const l=dP(e.neck,i.center,i.orient);if(!1!==t.schema.connector&&l){const n=Pm(o.fill,e.data,e.i);s.push({type:"path",key:`${r(e)}-neck`,d:l,datum:e.data,index:e.i,interactive:!1,aria:{hidden:!0},paint:PP(t,e,"string"==typeof n?n:void 0,o)}),c.push(e)}}const l=tw(RP(t,o),s,t=>[c[t].data,c[t].i]),h=tw(o,a,t=>[n[t].data,n[t].i]),u=!1===(t.schema.shapeConfig??{}).label?[]:EP(t,n,i);return[...s,...l,...a,...h,...u]};function WP(t,e,n){if(!1===(t.schema.shapeConfig??{}).label)return 0;const i=kt(t),o=e.filter(t=>t.length).map(e=>{const{stages:o,shared:r}=_P(t,gP(t,e),i,n);return NP(t,o,r)}).filter(t=>t>0);return o.length?Math.min(...o):0}function HP(t,e){const n=t.schema.value,i=oP(e.flatMap(t=>t.map((t,e)=>Number(n(t,e)))));return{max:i,fontSize:WP(t,e,i)}}function jP(t,e){const n=t.ctx.funnelScaleMax,i=t.ctx.funnelLabelSize,o=e.shared?e.scales:void 0;return t.ctx.funnelScaleMax=o?o.max:void 0,t.ctx.funnelLabelSize=o&&o.fontSize?o.fontSize:void 0,()=>{t.ctx.funnelScaleMax=n,t.ctx.funnelLabelSize=i}}const IP={scales:"independent",share:HP,panel:jP};function GP(t,e,n){const i=Number(t.schema.value(e,n)),o=t.schema.valueFormat,r=[];Number.isFinite(i)&&r.push([t.schema.translate("Value"),`${o(i,e)}`]);const a=e?pP(t).get(e):void 0,s=a?a.first:NaN,c=a?a.previous:NaN;return Number.isFinite(c)&&(Number.isFinite(s)&&r.push([t.schema.translate("% of First Stage"),$P(t,s)]),r.push([t.schema.translate("% of Previous Stage"),$P(t,c)])),r}const qP={name:"Funnel",layoutStage:kP,emit:OP,insetRegion:Cp,facet:IP,ctx:{},fields:[{key:"connector",default:!0},{key:"conversion",default:!1},{key:"curve",default:"linear"},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{const o=new Set(t._filteredData.map((e,n)=>t._ids(e,n).join("_")));return!(i.length>=o.size)&&e.call(t,n,i)}}},{key:"orient",default:"vertical"},{key:"sort"},{key:"stagePadding",default:.3},{key:"taper",default:!1},{key:"value",default:I("value"),coerce:t=>"function"==typeof t?t:"string"==typeof t?q(t):H(t)},{key:"valueFormat",factory:t=>e=>d.formatAbbreviate(e,t.schema.locale)},{key:"zoom",default:!1},{key:"connectorConfig",merge:!0,default:{opacity:.35}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>GP(t,e,n)})}]};var VP=lx(qP);const YP=t=>"function"==typeof t?t:q(t),KP=t=>(e,n)=>{const i="function"==typeof n?null:n;i&&!e.schema.aggs[i]&&(e.schema.aggs[i]=t)};function UP(){return[{key:"end",default:I("end"),coerce:YP,onSet:KP(h.max)},{key:"start",default:I("start"),coerce:YP,onSet:KP(h.min)}]}function XP(t){t.schema.aggs.start||(t.schema.aggs.start=h.min),t.schema.aggs.end||(t.schema.aggs.end=h.max)}function ZP(t){const e=t.schema.axisConfig;return"time"===e?.scale}function QP(t,e){if(null==t||""===t)return null;if(e){const e=r.date(t);return e instanceof Date&&!isNaN(+e)?e:null}const n=Number(t);return Number.isFinite(n)?n:null}const JP=(t,e,n)=>e.config({domain:n.domain,height:n.height,width:n.width}).config(n.config??{}).config(t.schema.axisConfig);function tT(t,e){const n=t.ctx.axisTest;return JP(t,n,e).measure(),{height:n.outerBounds().height,padding:n.schema.padding}}function eT(t,e,n={}){const i=t.ctx.axis;JP(t,i,e).renderMode("compute").select(void 0).render();const o=i.toScene();var r;o&&((r=t)._chartScene||(r._chartScene=[])).push({type:"group",key:e.key,transform:e.transform,children:o.children??[],...n});return i._d3Scale}function nT(t,e,n,i){return t.schema[e](n,i)}const iT=t=>Math.round(100*t)/100;function oT(t,e,n){return`M${iT(t)},${iT(e-n)}L${iT(t+n)},${iT(e)}L${iT(t)},${iT(e+n)}L${iT(t-n)},${iT(e)}Z`}function rT(t,e,n){const i=e*Math.max(0,Math.min(1,n));return{done:{x:t,width:i},rest:{x:t+i,width:e-i}}}function aT(t,e,n,i){const o=n-i/2,r=n+i/2,a=Math.min(i,Math.max(0,(e-t)/2));return`M${iT(t)},${iT(o)}H${iT(e)}V${iT(r+a)}L${iT(e-a)},${iT(r)}H${iT(t+a)}L${iT(t)},${iT(r+a)}Z`}function sT(t,e,n,i){const[o,r]=t,[a,s]=e;if(r===s&&a>=o)return[t,e];const c=o+n;if(a-o>=2*n)return[t,[c,r],[c,s],e];const l=r+(s>r?1:-1)*i/2,h=a-n;return[t,[c,r],[c,l],[h,l],[h,s],e]}function cT(t,e,n,i){if(!(t>0&&n>0))return 0;const o=n<=1?e*n:n;return Math.max(0,Math.min(Math.ceil(t+2*i),o))}function lT(t){const e=t.schema.taskLabelConfig??{},n=Pm(e.fontSize,{},0),i=Pm(e.fontFamily,{},0)??t.schema.fontFamily,o="number"==typeof n&&n>0?n:12;return{family:s.fontFamilyStringify(i),size:o,color:Pm(e.fontColor,{},0)??Ws(t),lineHeight:Math.round(1.2*o)}}function hT(t,e,n=400){return t?r.textWidth(t,{"font-family":e.family,"font-size":e.size,"font-weight":n}):0}function uT(t,e,n){let i=t.trimEnd();for(;i.length;){const t=`${i}…`;if(n(t)<=e)return t;i=i.slice(0,-1).trimEnd()}return""}function dT(t,e,n,i,o=400){const r=t=>hT(t,i,o);if(!t||e<=0||n<1)return{lines:[],widths:[]};const a=s.textWrap().fontFamily(i.family).fontSize(i.size).fontWeight(o).lineHeight(i.lineHeight).width(e).height(i.lineHeight*n).maxLines(n)(t),c=a.lines.filter(t=>""!==t),l=c.join(" ").replace(/\s+/g," ").trim(),h=t.replace(/\s+/g," ").trim();if(!c.length){const t=uT(h,e,r);return t?{lines:[t],widths:[r(t)]}:{lines:[],widths:[]}}if(a.truncated||l.length<h.length||r(c[c.length-1])>e){const t=c.length-1,n=h.slice(c.slice(0,t).join(" ").length+(t?1:0));c[t]=uT(n,e,r),c[t]||c.pop()}return{lines:c,widths:c.map(r)}}function fT(t,e,n){return null!=n&&""!==n?!!n:+t===+e}function mT(t){let e;if("number"==typeof t)e=t;else if("string"==typeof t&&t.trim().endsWith("%"))e=parseFloat(t)/100;else{if("string"!=typeof t||""===t.trim())return;e=Number(t)}if(Number.isFinite(e))return Math.max(0,Math.min(1,e))}function pT(t){const e=(Array.isArray(t)?t:"string"==typeof t?t.split(","):"number"==typeof t?[t]:[]).filter(t=>null!=t).map(t=>`${t}`.trim()).filter(t=>""!==t);return Array.from(new Set(e))}function gT(t,e){const n=(t,e)=>t.i-e.i;return"function"==typeof e?[...t].sort((t,i)=>e(t.data,i.data)||n(t,i)):"start"===e?[...t].sort((t,e)=>+t.start-+e.start||+t.end-+e.end||n(t,e)):[...t].sort(n)}function yT(t,e){const n=gT(t,e),i=(t,e)=>({kind:"task",key:`task-${t.id}`,task:t,indent:e});if(!n.some(t=>void 0!==t.group))return n.map(t=>i(t,!1));const o=new Map,r=[];for(const t of n){if(void 0===t.group){r.push(t);continue}const e=o.get(t.group);e?e.push(t):(o.set(t.group,[t]),r.push(t.group))}const a=[];for(const t of r){if("string"!=typeof t){a.push(i(t,!1));continue}const e=o.get(t);a.push({kind:"group",key:`group-${t}`,label:t,start:xT(e.map(t=>t.start)),end:bT(e.map(t=>t.end)),tasks:e}),e.forEach(t=>a.push(i(t,!0)))}return a}const xT=t=>t.reduce((t,e)=>+e<+t?e:t),bT=t=>t.reduce((t,e)=>+e>+t?e:t);function _T(t,e){if(!ZP(t))return e=>d.formatAbbreviate(Number(e),t.schema.locale);const n=Array.from(new Set(e.map(Number))).sort((t,e)=>t-e).map(t=>new Date(t)),i=g.timeFormatLocale(TF(t.schema.locale)),o=d.dateFullFormatter(n,i.format);return t=>o(t instanceof Date?t:new Date(t))}function kT(t,e,n){const i=+n-+e;if(!ZP(t))return d.formatAbbreviate(i,t.schema.locale);const o=function(t){const e=t.schema.axisConfig,n=ri(e?.rangeBreaks);return n.some(t=>"object"==typeof t&&"hours"in t)?[]:n}(t),r=o.length?fi(o,+e,+n):i,a=Math.round(r/864e5*10)/10,s=t.schema.translate(`${o.length?"working ":""}${1===a?"day":"days"}`);return`${vT(a,t.schema.locale)} ${s}`}function vT(t,e){try{return new Intl.NumberFormat("string"==typeof e?e:"en-US",{maximumFractionDigits:1}).format(t)}catch{return`${t}`}}const wT=t=>`${Math.round(100*t)}%`;function MT(t,e,n){const i=ZP(t);let o=QP(nT(t,"start",e,n),i),r=QP(nT(t,"end",e,n),i);if(null===o&&null===r)return null;o??(o=r),r??(r=o),+r<+o&&([o,r]=[r,o]);const a=t.schema.milestone,s=t.schema.progress;return{start:o,end:r,milestone:fT(o,r,"function"==typeof a?a(e,n):void 0),progress:mT("function"==typeof s?s(e,n):void 0)}}function ST(t,e){const n=t.ctx.gantt;return n?.format??_T(t,e)}function CT(t,e,n){const i=MT(t,e,n);if(!i)return[];const o=e=>t.schema.translate(e),r=ST(t,[i.start,i.end]),a=i.milestone?[[o("Milestone"),r(i.end)]]:[[o("Start"),r(i.start)],[o("End"),r(i.end)],[o("Duration"),kT(t,i.start,i.end)]];return void 0!==i.progress&&a.push([o("Progress"),wT(i.progress)]),a}function $T(t,e,n){const i=`${t._drawLabel(e,n)??""}`,o=MT(t,e,n);if(!o)return`${i}.`;const r=ST(t,[o.start,o.end]);return`${i}, ${o.milestone?`${t.schema.translate("Milestone")} ${r(o.end)}`:`${r(o.start)} - ${r(o.end)}`}${void 0===o.progress?"":`, ${t.schema.translate("Progress")} ${wT(o.progress)}`}.`}const AT=(t,e,n)=>"function"==typeof t?t(e,n):void 0;function zT(t,e){const n=[];return e.forEach((e,i)=>{const o=MT(t,e,i);if(!o)return;const r=AT(t.schema.group,e,i);n.push({__d3plus__:!0,data:e,i:i,id:`${t._id(e,i)}`,label:`${t._drawLabel(e,i)??""}`,...o,dependencies:pT(AT(t.schema.dependencies,e,i)),group:null==r||""===r?void 0:`${r}`})}),n}function DT(t,e){if(!t.length)return[0,1];let n=Math.min(...t.map(t=>+t.start)),i=Math.max(...t.map(t=>+t.end));return n===i&&(e?(n=+y.timeDay.offset(new Date(n),-1),i=+y.timeDay.offset(new Date(i),1)):(n-=1,i+=1)),[n,i]}function LT(t,e,n,i){const o=n>=2*i.lineHeight+2?2:1;return t.map(t=>{const n="task"===t.kind&&t.indent?12:0,r=e-16-n;return"group"===t.kind?dT(t.label,r,o,i,600):dT(t.task.label,r,o,i)})}const FT=({viz:t})=>{const e=t,n=e._filteredData??[],i=ZP(e),o=zT(e,n),r=yT(o,e.schema.taskSort??"data"),a=lT(e),{width:s,height:l}=kt(e),h=function(t,e,n,i){return cT(Math.max(0,...e.map(t=>"group"===t.kind?hT(t.label,n,600):hT(t.task.label,n)+(t.indent?12:0))),i,Number(t.schema.labelWidth),8)}(e,r,a,s),u="bottom"!==(e.schema.axisConfig??{}).orient,d={domain:DT(o,i),width:Math.max(0,s-h),height:l,config:{orient:u?"top":"bottom",align:u?"start":"end"}},f=tT(e,d),m=Math.max(0,l-f.height-2*f.padding),p=Math.min(m,40*r.length),g=u?f.height+f.padding:f.padding,y=eT(e,{...d,height:p+f.height+2*f.padding,transform:{x:h,y:0},key:"gantt-axis"},{interactive:!1,interactionGroup:"axis"}),x=t=>h+y(t),b=c.scaleBand().domain(r.map((t,e)=>e)).paddingInner(Number(e.schema.paddingInner)||0).paddingOuter(Number(e.schema.paddingOuter)||0).range([g,g+p]),_=b.bandwidth(),k=r.length>1?b.step():p,v=r.map((t,e)=>(b(e)??0)+_/2),w=[];r.forEach((t,e)=>{"task"===t.kind&&w.push({...t.task,row:e,cy:v[e],x0:x(t.task.start),x1:x(t.task.end)})});const M=y.range?.()??[0,d.width];return e.ctx.gantt={rows:r,labels:LT(r,h,k,a),font:a,column:h,x:x,cy:v,step:k,band:_,plot:{x0:h+Math.min(...M),x1:h+Math.max(...M),y0:g,y1:g+p},time:i,format:_T(e,o.flatMap(t=>[t.start,t.end]))},{shapeData:w}},NT=(t,e)=>"number"==typeof t&&Number.isFinite(t)?t:e;function BT(t){const e=t.schema.dependencyConfig??{};return{stroke:e.stroke||Ws(t),strokeWidth:NT(e.strokeWidth,1),strokeOpacity:NT(e.strokeOpacity,.55),arrowSize:Math.max(2,NT(e.arrowSize,6))}}function ET(t,e){const{font:n}=t,i=new Map(e.map(t=>[t.row,t])),o=[];return t.rows.forEach((e,r)=>{const a=t.labels[r];if(!a||!a.lines.length)return;const s="group"===e.kind,c=!s&&e.indent?12:0,l=t.cy[r]-a.lines.length*n.lineHeight/2,h=i.get(r);o.push({type:"text",key:`gantt-label-${e.key}`,interactive:!1,...h?{datum:h.data,index:h.i}:{},x:0,y:0,transform:{x:8+c,y:l},lines:a.lines.map((t,e)=>({text:t,x:0,y:n.lineHeight*(e+.5),width:a.widths[e]})),font:{family:n.family,size:n.size,weight:s?600:400,anchor:"start",baseline:"middle"},paint:{fill:n.color}})}),o}function RT(t,e){const n=Ws(t),i=[];return e.rows.forEach((t,o)=>{if("group"!==t.kind)return;const r=e.x(t.start),a=Math.max(e.x(t.end),r+1);i.push({type:"path",key:`gantt-${t.key}`,interactive:!1,d:aT(r,a,e.cy[o],Math.max(2,.4*e.band)),paint:{fill:n,fillOpacity:.6}})}),i}function PT(t,e){return[t.milestone?t.x1+e:t.x1,t.cy]}function TT(t,e){return[t.milestone?t.x1-e:t.x0,t.cy]}function OT(t,e,n,i){const o=BT(t),r=new Map(n.map(t=>[t.id,t])),a=Math.max(8,o.arrowSize+4),s=[];for(const t of n)for(const n of t.dependencies){const c=r.get(n);if(!c||c===t)continue;const l=PT(c,i),h=TT(t,i),u=sT(l,h,a,e.step).slice();u[u.length-1]=[h[0]-.8*o.arrowSize,h[1]];const d=`gantt-dependency-${c.id}-${t.id}`,f=[{x:l[0],y:l[1],datum:c.data,index:c.i},{x:h[0],y:h[1],datum:t.data,index:t.i}];s.push({type:"line",key:d,interactive:!1,points:u,curve:"linear",interactionPoints:f,paint:{fill:"none",stroke:o.stroke,strokeWidth:o.strokeWidth,strokeOpacity:o.strokeOpacity}});const m=Ck({key:`${d}-arrow`,datum:t.data,x:h[0],y:h[1],angle:0,size:o.arrowSize,fill:o.stroke});s.push({...m,datum:void 0,interactionPoints:f,paint:{...m.paint,fillOpacity:o.strokeOpacity}})}return s}function WT(t,e=()=>new Date){return!0===t?e():!1===t||null==t||""===t?null:t}function HT(t,e){const n=WT(t.schema.today);if(null===n)return[];const i=t.schema.todayConfig??{},o={label:t.schema.translate("Today"),fontSize:11,labelPosition:"end",strokeOpacity:.85,strokeWidth:1.5,...i,shape:"ReferenceLine",x:n};return pS(t,o,{plot:e.plot,axes:{x:{scale:t=>e.x(t),time:e.time}}},"gantt-today")}function jT(t,e){return b.interpolateRgb(t,e)(.6)}const IT=t=>Math.max(3,.6*t);function GT(t,e,n){const i=Pm(e.fill,n.data,n.i),o={fill:Tm(e,n.data,n.i,i),stroke:Pm(e.stroke,n.data,n.i),strokeWidth:Pm(e.strokeWidth,n.data,n.i)},r=Pm(e.opacity,n.data,n.i);"number"==typeof r&&(o.opacity=r);const a="string"!=typeof o.fill||o.fill.startsWith("pattern:")?void 0:o.fill;return{paint:o,color:a}}function qT(t,e,n,i){const{paint:o,color:r}=GT(0,i,n),a=IT(e.band),s=void 0!==n.progress&&n.progress<1&&!!r;return{type:"path",shapeType:"Path",key:`gantt-milestone-${n.id}`,d:oT(0,0,a),transform:{x:n.x1,y:n.cy},datum:n.data,index:n.i,paint:s?{...o,fill:jT(r,Os(t)),stroke:r,strokeWidth:1.5}:o,aria:{label:$T(t,n.data,n.i)}}}const VT=({viz:t,shapeData:e})=>{const n=t,i=n.ctx.gantt,o=e??[];if(!i||!o.length)return[];const r=Hm(n,"Rect"),a=Hm(n,"Path"),s=IT(i.band),c=o.flatMap(t=>t.milestone?[qT(n,i,t,a)]:function(t,e,n,i){const{paint:o,color:r}=GT(0,i,n),a=Math.max(1,n.x1-n.x0),s=void 0!==n.progress&&void 0!==r,c=`gantt-task-${n.id}`,l={type:"rect",transform:{x:n.x0,y:n.cy},y:-e.band/2,height:e.band,datum:n.data,index:n.i},h={...l,shapeType:"Bar",key:c,x:0,width:a,paint:s?{...o,fill:jT(r,Os(t))}:o,aria:{label:$T(t,n.data,n.i)}},u=[h],d=Jv(i,h,n.data,n.i);if(d&&u.push(d),s){const{done:t}=rT(0,a,n.progress);t.width>0&&u.push({...l,key:`${c}-progress`,interactive:!1,x:t.x,width:t.width,paint:{fill:r,..."number"==typeof o.opacity?{opacity:o.opacity}:{}}})}return u}(n,i,t,r));return[...RT(n,i),...OT(n,i,o,s),...c,...ET(i,o),...HT(n,i)]};function YT(t){return"function"==typeof t?t:!("string"!=typeof t||!t)&&q(t)}function KT(t,e){return h.mean(t.map(t=>mT(e(t))).filter(t=>void 0!==t))}const UT={name:"Gantt",layoutStage:FT,emit:VT,setup:t=>{XP(t),t.schema.aggs.progress||(t.schema.aggs.progress=KT)},ctx:{axis:(new zo).align("start").orient("top"),axisTest:(new zo).align("start").gridSize(0).orient("top")},fields:[{key:"axisConfig",merge:!0,default:{scale:"time"}},{key:"dependencies",default:I("dependencies"),coerce:YT},{key:"dependencyConfig",merge:!0,default:{}},...UP(),{key:"group",default:!1,coerce:YT},{key:"labelWidth",default:.3},{key:"legend",coerce:"const",factory:t=>{const e=t.schema.legend;return(n,i)=>{const o=t._filteredData??[];return!(i.length>=o.length)&&e.call(t,n,i)}}},{key:"milestone",default:I("milestone"),coerce:YT},{key:"paddingInner",default:.35},{key:"paddingOuter",default:.2},{key:"progress",default:I("progress"),coerce:YT,onSet:(t,e)=>{const n="string"==typeof e?e:null;n&&!t.schema.aggs[n]&&(t.schema.aggs[n]=KT)}},{key:"taskSort",default:"data"},{key:"taskLabelConfig",merge:!0,default:{}},{key:"today",default:!1},{key:"todayConfig",merge:!0,default:{}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>CT(t,e,n)})},{key:"zoom",default:!1}]};var XT=lx(UT);function ZT(t){const n=Os(t),i=e.colorContrast(n,t.schema.colorDefaults),o=b.interpolateRgb(n,i);return{track:o(.12),tick:o(.6),text:i}}const QT={name:"Gauge",layoutStage:OL,emit:({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.gauge;if(!(n.length&&i&&i.radius>0))return[];const o=1===n.length,r=n[0],c=RL(i.radius,i.dial),l=function(t,e,n){const i=(t.schema.axisConfig??{}).shapeConfig??{},o=i.labelConfig??{},r=ZT(t),a=Pm(o.fontFamily,e,n)??t.schema.fontFamily,c=t.schema.tickFormat;return{trackFill:Pm(i.fill,e,n)??r.track,tickStroke:Pm(i.stroke,e,n)??r.tick,tickStrokeWidth:Pm(i.strokeWidth,e,n)??1,fontColor:Pm(o.fontColor,e,n)??r.text,fontFamily:s.fontFamilyStringify(a),tickFormat:t=>`${c(t)}`}}(t,r.data,r.i),h=t.schema.valueFormat,u=o&&Number.isFinite(r.value)?`${h(r.value,r.data)}`:"",d=i.dial.hasName?t._drawLabel(r.data,r.i):void 0,f={type:"group",key:"gauge-dial",interactive:!1,aria:{hidden:!0},children:[...dF("gauge",c,i,l),...fF("gauge",c,l,u,d)]},m={viz:t,layout:c,shared:i,single:o},p=[f,...n.flatMap(t=>function(t,e){const{viz:n,layout:i,shared:o,single:r}=e,s=`gauge-${n._ids(t.data,t.i).join("-")}`,c=Hm(n,"Path"),l=Om(c,t.data,t.i),h=n.schema.valueFormat,u=`${[PL(n,t.data,t.i)?n._drawLabel(t.data,t.i):"",h(t.value,t.data)].filter(Boolean).join(", ")}.`,d={datum:t.data,index:t.i,shapeType:"Path",aria:{label:u}},f="progress"===o.dial.indicator,m=i.rings[f?t.i:0],p={startAngle:o.start,endAngle:o.end},g={rotate:CL(t.angle)},y={type:"path",key:`${s}-indicator::hit`,d:r?a.arcPath({innerRadius:0,outerRadius:i.outer,...p}):f?a.arcPath({innerRadius:m.inner,outerRadius:m.outer,...p}):EL(i.needleLength,3*i.needleHalfWidth,i.needleTail),transform:r||f?void 0:g,datum:t.data,index:t.i,paint:{fill:"transparent"}};if(!Number.isFinite(t.value))return[y];if(f){const e={innerRadius:m.inner,outerRadius:m.outer,startAngle:o.start,endAngle:t.angle},n={type:"path",key:`${s}-indicator`,d:a.arcPath(e),arc:e,paint:l,...d},i=Jv(c,n,t.data,t.i);return i?[y,n,i]:[y,n]}const x={type:"path",key:`${s}-indicator`,d:EL(i.needleLength,i.needleHalfWidth,i.needleTail),transform:g,paint:l,...d};return r?[y,x,{type:"circle",key:`${s}-hub`,cx:0,cy:0,r:i.hubRadius,paint:l,...d}]:[y,x]}(t,m))];return o||"progress"===i.dial.indicator||p.push({type:"circle",key:"gauge-hub",interactive:!1,cx:0,cy:0,r:c.hubRadius,paint:{fill:l.fontColor,stroke:Os(t),strokeWidth:1.5}}),[{type:"group",key:"gauge",transform:{x:i.cx,y:i.cy},children:p}]},ctx:{},fields:[{key:"axisConfig",merge:!0},{key:"bands",default:[]},{key:"domain"},{key:"endAngle",default:120},{key:"indicator",default:"needle"},{key:"minorTicks",default:!0},{key:"startAngle",default:-120},{key:"thickness",default:.2},{key:"tickFormat",factory:t=>e=>d.formatAbbreviate(e,t.schema.locale)},{key:"ticks"},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Os(t),strokeWidth:()=>"progress"===t.schema.indicator?0:1.5})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[[()=>t.schema.translate("Value"),(e,n)=>{const i=Number(t.schema.value(e,n));return Number.isFinite(i)?`${t.schema.valueFormat(i,e)}`:""}]]})},{key:"value",default:I("value"),coerce:t=>"function"==typeof t?t:"string"==typeof t?q(t):H(t)},{key:"valueFormat",factory:t=>e=>d.formatAbbreviate(e,t.schema.locale)},{key:"zoom",default:!1}]};var JT=lx(QT);const tO=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["tile.openstreetmap.org"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["openstreetmap.fr/hot"],text:"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, tiles by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a>"},{matches:["stadiamaps.com"],text:"© <a href='https://stadiamaps.com/' target='_blank'>Stadia Maps</a> © <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["World_Light_Gray_Base","World_Dark_Gray_Base"],text:"Powered by <a href='https://www.esri.com/' target='_blank'>Esri</a> | Esri, HERE, Garmin, © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, and the GIS user community"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}],eO={light:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",dark:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}"};function nO(t,e){return(t=>"object"==typeof t&&null!==t&&"light"in t&&"dark"in t)(t)?e?t.dark:t.light:t}function iO(t){const e=t.ctx.linkBundleCache;if(e)return e;const n=Sb();return t.ctx.linkBundleCache=n,n}function oO(t,e){return zb(e,t.schema.linkBundleConfig??{},iO(t))}function rO(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&Number.isFinite(t[0])&&Number.isFinite(t[1])&&Math.abs(t[1])<=90}function aO(t){if(!Array.isArray(t)||t.length<2)return null;const e=[Number(t[0]),Number(t[1])];return rO(e)?e:null}function sO(t){const e=t?.geometry;if(!e)return null;let n=e;if("MultiPolygon"===e.type){const t=e.coordinates;let i=-1;for(const e of t){const t={type:"Polygon",coordinates:e},o=cO(t);o>i&&(i=o,n=t)}}let i=S.geoCentroid(n);return S.geoArea(n)>2*Math.PI&&(i=[i[0]>0?i[0]-180:i[0]+180,-i[1]]),rO(i)?i:null}function cO(t){const e=S.geoArea(t);return Math.min(e,4*Math.PI-e)}function lO(t,e,n){const i=S.geoInterpolate(t,e),o=Math.max(1,Math.round(n));return Array.from({length:o+1},(t,e)=>i(e/o))}function hO(t,e){if(!e||t.length<2)return t.slice();const[n,i]=t[0],[o,r]=t[t.length-1],a=Math.hypot(o-n,r-i);if(!a)return t.slice();const s=(r-i)/a,c=-(o-n)/a,l=t.length-1;return t.map(([t,n],i)=>{const o=i/l,r=4*o*(1-o)*e*a;return[t+s*r,n+c*r]})}function uO(t,e,n){if(1!==(t.match(/M/g)??[]).length)return!1;const i=function(t){return(t.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)??[]).map(Number)}(t);if(i.length<4)return!1;const o=(t,e,n)=>Math.abs(t-n[0])<=1&&Math.abs(e-n[1])<=1;return o(i[0],i[1],e)&&o(i[i.length-2],i[i.length-1],n)}function dO(t,e,n,i){const o=i({type:"LineString",coordinates:[t,e]}),r=pO(n(t)),a=pO(n(e));return!(o&&r&&a&&uO(o,r,a))}function fO(t,e,n=0){const i=Math.hypot(e[0]-t[0],e[1]-t[1]),o=Math.min(128,Math.max(16,Math.ceil(i/4))),r=hO(Array.from({length:o+1},(n,i)=>{const r=i/o;return[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r]}),n);return{d:j_(r),points:r}}function mO(t,e,n,i,o=0){if(!S.geoDistance(t,e))return null;const r=i({type:"LineString",coordinates:[t,e]});if(!r)return null;const a=pO(n(t)),s=pO(n(e)),c=!yO(n),l=t=>xO(i,t),h=()=>c&&a&&s&&l(t)&&l(e)?fO(a,s,o):null;if(!a||!s||!uO(r,a,s))return h()??{d:r,points:null};const u=Math.hypot(s[0]-a[0],s[1]-a[1]),d=Math.min(128,Math.max(16,Math.ceil(u/4))),f=[];for(const i of lO(t,e,d)){const t=pO(n(i));if(!t)return h()??{d:r,points:null};f.push(t)}const m=o?hO(f,o):f;return{d:o?j_(m):r,points:m}}function pO(t){return t&&Number.isFinite(t[0])&&Number.isFinite(t[1])?[t[0],t[1]]:null}function gO(t){const e=[];for(const[,n,i]of t.matchAll(/([ML])([^ML]*)/gi)){const t=(i.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)??[]).map(Number);"M"!==n.toUpperCase()&&e.length||e.push([]);const o=e[e.length-1];for(let e=0;e+1<t.length;e+=2)o.push([t[e],t[e+1]])}return e.filter(t=>t.length>1)}function yO(t){const e=t?.clipAngle;if("function"!=typeof e)return!1;const n=e.call(t);return"number"==typeof n&&Number.isFinite(n)&&n>0}function xO(t,e){return!!t({type:"Point",coordinates:e})}function bO(t){if(rO(t))return[t[0],t[1]];if("string"==typeof t)return t;if("number"==typeof t&&Number.isFinite(t))return`${t}`;if(t&&"object"==typeof t&&"id"in t){const e=t.id;if("string"==typeof e||"number"==typeof e)return`${e}`}return null}function _O(t,e){let n;try{const t=new Intl.NumberFormat(e||void 0,{maximumFractionDigits:2});n=e=>t.format(e)}catch{n=t=>""+Math.round(100*t)/100}return`${n(t[0])}, ${n(t[1])}`}function kO(t,e){const n=new Map;e.pointData.forEach((i,o)=>{const r=aO(t.schema.point(i,o));if(!r)return;const a=`${t._id(i,o)}`;if(n.has(a))return;const s=e.pointR(i,o);n.set(a,{data:i,i:o,id:a,coord:r,shape:"Circle",r:Number.isFinite(s)?s:0})});const i=new Map;e.topoData.forEach((t,e)=>{const n=`${t.id}`;i.has(n)||i.set(n,{row:t,i:e})});const o=new Map,r=new Map,a=t.schema.locale;return t=>{const e=bO(t);if(null===e)return null;if("string"!=typeof e){const t=e.join(",");return r.has(t)||r.set(t,{data:{point:e},i:0,id:t,label:_O(e,a),coord:e,r:0}),r.get(t)}const s=n.get(e);if(s)return s;if(!o.has(e)){const t=i.get(e),n=t?sO(t.row.feature):null;o.set(e,t&&n?{data:t.row.data??t.row,i:t.i,id:e,coord:n,shape:"Path",r:0}:null)}return o.get(e)}}function vO(t){if(!Array.isArray(t))return[];const e=[];for(const n of t)if(n&&"object"==typeof n)for(const t of[n.source,n.target])rO(t)&&e.push([t[0],t[1]]);return e}function wO(t,{scale:e,min:n,max:i}){const o=t.map(t=>"number"==typeof t&&Number.isFinite(t)?t:void 0),[r,a]=h.extent(o.filter(t=>void 0!==t));if(void 0===r||void 0===a||r===a)return o.map(t=>t??n);const s=`${e||"sqrt"}`,c=(E[`scale${s.charAt(0).toUpperCase()}${s.slice(1)}`]??E.scaleSqrt)().domain([r,a]).range([n,Math.max(n,i)]);return o.map(t=>void 0===t?n:c(t))}function MO(t){const e=(t.match(/-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi)??[]).map(Number),n=[];for(let t=0;t+1<e.length;t+=2)n.push([e[t],e[t+1]]);return n.length?Y_(n):[[0,0],[0,0]]}function SO(t,e,n,i){if(!t.schema.linkBundle||yO(n))return;const o=e.filter(t=>t.points&&t.sourceAt&&t.targetAt&&!dO(t.source.coord,t.target.coord,n,i));if(!o.length)return;const r=oO(t,o.map(t=>[t.points[0],t.points[t.points.length-1]]));o.forEach((t,e)=>{t.points=r[e],t.d=j_(r[e]),t.box=Y_(r[e])})}function CO(t,e){"panel"!==t._facetStep&&Pb(t);const n=Array.isArray(t.schema.links)?t.schema.links:[],i=kO(t,e),o=t.schema.projection,r=t=>{const n=xO(e.path,t)?o(t):null;return n&&Number.isFinite(n[0])&&Number.isFinite(n[1])?n:null},a=yO(o)?0:Number(t.schema.linkCurve)||0,s=[];n.forEach((t,n)=>{if(!t||"object"!=typeof t)return;const c=i(t.source),l=i(t.target);if(!c||!l)return;const h=mO(c.coord,l.coord,o,e.path,a);h&&s.push({datum:Bb(t,c,l,n),index:n,source:c,target:l,...h,sourceAt:r(c.coord),targetAt:r(l.coord),box:h.points?Y_(h.points):MO(h.d)})}),SO(t,s,o,e.path);const c=t.schema.linkSize,l=wO(s.map(t=>Eb(t.datum,c(t.datum,t.index))),{scale:t.schema.linkSizeScale,min:Number(t.schema.linkSizeMin)||0,max:Number(t.schema.linkSizeMax)||0}),h=s.map((t,e)=>({...t,size:l[e]})),u=new Map;for(const t of h)for(const e of[t.source,t.target])e.shape&&u.set(e.id,e);return Rb(t,h.map(t=>t.datum),[...u.values()]),h}const $O=new WeakMap;function AO(t,e){const n=t.objects,i=e&&n[e]?e:Object.keys(n)[0];let o=$O.get(t);o||$O.set(t,o=new Map);let r=o.get(i);return r||(r=C.feature(t,i),o.set(i,r)),Array.isArray(r.features)?{...r,features:r.features.map(t=>({...t}))}:{...r}}const zO=["scale","translate","rotate","center","angle","reflectX","reflectY","parallels","clipAngle","clipExtent","precision","preclip","postclip"],DO=[[0,0],[-98,39],[-150,61],[-157,21],[-66,18],[12,50],[116,40],[151,-34],[-58,-34],[28,-26]],LO=new WeakMap;let FO=0;function NO(t){if("function"==typeof t){let e=LO.get(t);return void 0===e&&LO.set(t,e=FO++),`f${e}`}return"number"==typeof t?Object.is(t,-0)?"-0":String(t):Array.isArray(t)?`[${t.map(NO).join(",")}]`:null==t?String(t):"boolean"==typeof t||"string"==typeof t?JSON.stringify(t):"?"}function BO(t){try{const e=[];for(const n of zO){const i=t[n];"function"==typeof i&&e.push(`${n}=${NO(i.call(t))}`)}for(const n of DO)e.push(NO(t(n)));return e.join(";")}catch{return null}}function EO(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!EO(t[n],e[n]))return!1;return!0}if(!t||!e||"object"!=typeof t||"object"!=typeof e||Array.isArray(e)||Object.getPrototypeOf(t)!==Object.prototype||Object.getPrototypeOf(e)!==Object.prototype)return!1;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&EO(t[n],e[n]))}const RO=new WeakMap;const PO=new WeakMap;const TO=Math.PI/180,OO=180/Math.PI,WO=t=>Math.max(-1,Math.min(1,t));function HO([t,e,n]){const i=t*TO/2,o=e*TO/2,r=(n??0)*TO/2,a=Math.sin(i),s=Math.cos(i),c=Math.sin(o),l=Math.cos(o),h=Math.sin(r),u=Math.cos(r);return[s*l*u+a*c*h,a*l*u-s*c*h,s*c*u+a*l*h,s*l*h-a*c*u]}function jO(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]**2+t[2]**2))*OO,Math.asin(WO(2*(t[0]*t[2]-t[3]*t[1])))*OO,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]**2+t[3]**2))*OO]}function IO([t,e]){const n=t*TO,i=e*TO,o=Math.cos(i);return[o*Math.cos(n),o*Math.sin(n),Math.sin(i)]}function GO(t,e){const n=[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],i=Math.hypot(...n);if(!i)return[1,0,0,0];const o=Math.acos(WO(t[0]*e[0]+t[1]*e[1]+t[2]*e[2]))/2,r=Math.sin(o);return[Math.cos(o),n[2]/i*r,-n[1]/i*r,n[0]/i*r]}function qO(t,e){return[t[0]*e[0]-t[1]*e[1]-t[2]*e[2]-t[3]*e[3],t[1]*e[0]+t[0]*e[1]+t[2]*e[3]-t[3]*e[2],t[0]*e[2]-t[1]*e[3]+t[2]*e[0]+t[3]*e[1],t[0]*e[3]+t[1]*e[2]-t[2]*e[1]+t[3]*e[0]]}const VO=t=>t&&Number.isFinite(t[0])&&Number.isFinite(t[1])?t:null;function YO(t,e){const n=VO(t.invert?.(e));if(!n)return null;const i=t(n);return i&&Math.hypot(i[0]-e[0],i[1]-e[1])<.5?n:null}function KO(t,e,n,i){const o=t.rotate();t.rotate(e);const r=YO(t,n),a=r?YO(t,i)??VO(t.invert?.(i)):null;t.rotate(o);const[s,c,l=0]=e;if(r&&a)return jO(qO(HO(e),GO(IO(r),IO(a))));const h=OO/(t.scale()||1);return[s+(i[0]-n[0])*h,Math.max(-90,Math.min(90,c-(i[1]-n[1])*h)),l]}function UO(t,e){const n=t.touches,i=n&&n.length?n[0]:void 0!==t.clientX?t:null;if(!i)return null;const o=e.getBoundingClientRect();return[i.clientX-o.left-(e.clientLeft||0),i.clientY-o.top-(e.clientTop||0)]}function XO(t,e,n={}){return[(t[0]-e.x)/e.k-(n.x??0),(t[1]-e.y)/e.k-(n.y??0)]}function ZO(t){return yO(t.schema.projection)&&!!t.schema.zoom&&!t._ssr&&!t._facetPanels&&!t._facetStep}function QO(t){const e=t.schema.projectionRotate;if(Array.isArray(e))return e;const n=t._globeHome;return n&&n.projection===t.schema.projection?n.rotate:void 0}function JO(t,e){let n=null;const i=()=>(t._zoomEventTarget||t._container)?.node()??null,o=()=>{if(!n||!n.to)return;n.frame=void 0;const i=t.schema.projection;i.rotate(KO(i,n.r0,n.p0,n.to)),e(),t._drawSceneToTarget?.(0)},r=()=>{n&&(void 0!==n.frame&&cancelAnimationFrame(n.frame),o(),n=null,t._globeDragging=!1)},a={start(e){n=null;const o=i();if(!o||!ZO(t)||!(t=>!!t&&("mousedown"===t.type||"pointerdown"===t.type||"touchstart"===t.type&&1===(t.touches?.length??0)))(e.sourceEvent))return;const r=UO(e.sourceEvent,o);if(!r)return;const a=t.schema.projection;QO(t)||(t._globeHome={projection:a,rotate:a.rotate()}),n={t0:e.transform,r0:a.rotate(),p0:XO(r,e.transform,t._chartTransform)}},zoom(e){if(!n)return!1;const a=e.sourceEvent,s=i();if(!a||!s||"wheel"===a.type||(a.touches?.length??0)>1)return r(),!1;(t._zoomEventTarget||t._container).property("__zoom",n.t0);const c=UO(a,s);return!c||(t._globeDragging=!0,n.to=XO(c,n.t0,t._chartTransform),"function"!=typeof requestAnimationFrame?o():void 0===n.frame&&(n.frame=requestAnimationFrame(o)),!0)},end(){r()},reset(){if(!ZO(t))return;const n=QO(t);n&&(t.schema.projection.rotate(n),e())}};t._zoomGesture=a}function tW(t){return t._filteredData.filter((e,n)=>t.schema.point(e,n)instanceof Array)}function eW(t,e){const n=`scale${t.schema.pointSizeScale.charAt(0).toUpperCase()}${t.schema.pointSizeScale.slice(1)}`;return E[n]().domain(h.extent(e,(e,n)=>t.schema.pointSize(e,n))).range([t.schema.pointSizeMin,t.schema.pointSizeMax])}function nW(t,e,n){return e.filter((e,i)=>{const o=aO(t.schema.point(e,i));return null!==o&&xO(n,o)})}function iW(t,e,n,i,o,r){e.effectivePadding=void 0;const a=t.schema.fitObject?AO(t.schema.fitObject,t.schema.fitKey):n;e.extentBounds={type:"FeatureCollection",features:t.schema.fitFilter?a.features.filter(t.schema.fitFilter):a.features.slice()},e.extentBounds.features=function(t,e){return t.reduce((t,n)=>{const i=n;if(!i.geometry)return t;const o={type:i.type,id:i.id,geometry:{coordinates:i.geometry.coordinates,type:i.geometry.type}};if("MultiPolygon"===i.geometry.type&&i.geometry.coordinates.length>1){const t=[],n=[];i.geometry.coordinates.forEach(n=>{o.geometry.coordinates=[n],t.push(e.area(o))}),o.geometry.coordinates=[i.geometry.coordinates[t.indexOf(h.max(t))]];const r=e.centroid(o);i.geometry.coordinates.forEach(t=>{o.geometry.coordinates=[t],n.push(f.pointDistance(e.centroid(o),r))});const a=h.quantile(t.reduce((e,i,o)=>(n[o]&&e.push(t[o]/n[o]),e),[]),.9);o.geometry.coordinates=i.geometry.coordinates.filter((e,i)=>{const o=n[i];return 0===o||t[i]/o>=a})}return t.push(o),t},[])}(e.extentBounds.features,i);const s=vO(t.schema.links);e.extentBounds.features.length||!o.length&&!s.length||function(t,e,n,i,o){const r=[[void 0,void 0],[void 0,void 0]];n.map((e,n)=>t.schema.point(e,n)).concat(o).forEach(e=>{const n=t.schema.projection(e);n&&((void 0===r[0][0]||n[0]<r[0][0])&&(r[0][0]=n[0]),(void 0===r[1][0]||n[0]>r[1][0])&&(r[1][0]=n[0]),(void 0===r[0][1]||n[1]<r[0][1])&&(r[0][1]=n[1]),(void 0===r[1][1]||n[1]>r[1][1])&&(r[1][1]=n[1]))}),e.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:r.map(e=>t.schema.projection.invert(e))}}]};const a=h.max(n,(e,n)=>i(t.schema.pointSize(e,n)))??0;e.effectivePadding={top:t.schema.projectionPadding.top+a,right:t.schema.projectionPadding.right+a,bottom:t.schema.projectionPadding.bottom+a,left:t.schema.projectionPadding.left+a}}(t,e,o,r,s)}function oW(t,e,n,i){const o=e.effectivePadding||t.schema.projectionPadding,r=yO(t.schema.projection)?QO(t):void 0,a=r?t.schema.projection.rotate():void 0;r&&t.schema.projection.rotate(r),function(t,e,n){const i=RO.get(t);i&&null!==i.state&&EO(i.extent,e)&&i.state===BO(t)&&EO(i.object,n)||(t.fitExtent(e,n),RO.set(t,{extent:[[...e[0]],[...e[1]]],object:n,state:BO(t)}))}(t.schema.projection,e.extentBounds.features.length?[[o.left,o.top],[n-o.right,i-o.bottom]]:[[0,0],[n,i]],e.extentBounds.features.length?e.extentBounds:{type:"Sphere"}),a&&t.schema.projection.rotate(a)}const rW=({viz:t})=>{const e=t,n=t.ctx,{width:i,height:o}=kt(e),r=e.schema.topojson?AO(e.schema.topojson,e.schema.topojsonKey):{type:"FeatureCollection",features:[]};n.coordData=r,e.schema.topojsonFilter&&(r.features=r.features.filter(e.schema.topojsonFilter));const a=P.geoPath().projection(e.schema.projection);n.path=a;const s=tW(e),c=e._filteredData.filter((t,n)=>!(e.schema.point(t,n)instanceof Array)).reduce((t,n,i)=>(t[e._id(n,i)]=n,t),{}),l=r.features.reduce((t,n)=>{const i=e.schema.topojsonId(n);return t.push({__d3plus__:!0,data:c[i],feature:n,id:i}),t},[]),h=eW(e,s);e._sizeLegendFinal=s.length?h:null,e._zoomSet&&n.extentBounds||iW(e,n,r,a,s,h),e._globeDragging||oW(e,n,i,o),n.geomapWidth=i,n.geomapHeight=o;const u=function(t,e){const n=BO(t);if(null===n)return e;let i=PO.get(t);i?.state!==n&&PO.set(t,i={state:n,byGeometry:new WeakMap});const{byGeometry:o}=i;return t=>{const n=t?.geometry;if(!n||"object"!=typeof n)return e(t);if(o.has(n))return o.get(n);const i=e(t);return o.set(n,i),i}}(e.schema.projection,a),d=(t,n)=>h(e.schema.pointSize(t,n));return n.geomapCtx={flowLinks:CO(e,{pointData:s,topoData:l,pointR:d,path:a}),topoData:l,pathFn:t=>u(t.feature),pointData:nW(e,s,a),pointR:d,pointSort:(t,n)=>e.schema.pointSize(n)-e.schema.pointSize(t),pointX:(t,n)=>e.schema.projection(e.schema.point(t,n))[0],pointY:(t,n)=>e.schema.projection(e.schema.point(t,n))[1]},{shapeData:l}},aW={geoAlbers:S.geoAlbers,geoAlbersUsa:T.geoAlbersUsa??S.geoAlbersUsa,...T.geoAlbersUsaTerritories&&{geoAlbersUsaTerritories:T.geoAlbersUsaTerritories},geoAzimuthalEqualArea:S.geoAzimuthalEqualArea,geoAzimuthalEquidistant:S.geoAzimuthalEquidistant,geoConicConformal:S.geoConicConformal,geoConicEqualArea:S.geoConicEqualArea,geoConicEquidistant:S.geoConicEquidistant,geoEqualEarth:S.geoEqualEarth,geoEquirectangular:S.geoEquirectangular,geoGnomonic:S.geoGnomonic,geoMercator:S.geoMercator,geoMiller:$.geoMiller,geoNaturalEarth1:S.geoNaturalEarth1,geoOrthographic:S.geoOrthographic,geoRobinson:$.geoRobinson,geoStereographic:S.geoStereographic,geoTransverseMercator:S.geoTransverseMercator,geoWinkel3:$.geoWinkel3};function sW(t,e,n,i){const o=e.label;if(!1!==o)return void 0!==o?Pm(o,n,i):t._drawLabel(n,i)}function cW(t,n,i){const o={...i.labelConfig??{},...jm(t,"Circle")},r=n.points.map((e,r)=>{const a=n.pointR(e,r);return{key:e,datum:e,index:r,x:n.pointX(e,r),y:n.pointY(e,r),r:a,text:sW(t,i,e,r),inside:{width:2*a,height:2*a,shape:"circle",padding:Pm(o.padding,e,r)??Yx.padding,font:{family:Pm(o.fontFamily,e,r),weight:Pm(o.fontWeight,e,r)}}}}),{width:a,height:s}=kt(t),c=M_(t,r,{x:0,y:0,width:a,height:s});if(!c.size)return[];const l=new Map(n.points.map((t,e)=>[t,e])),h=e=>`geomap-label-${t._id(e,l.get(e)??0)}`,u=Kx({data:n.points,label:t=>"inside"===c.get(t)?.position&&c.get(t).text,x:(t,e)=>n.pointX(t,e),y:(t,e)=>n.pointY(t,e),aes:(t,e)=>({r:n.pointR(t,e)}),rotate:H(0),id:h,labelBounds:(t,e,n)=>{const i=n.r;return{width:2*i,height:2*i,x:-i,y:-i,shape:"circle"}},labelConfig:{fontColor:n=>{const o=n.data,r=Pm(i.fill,o,l.get(o)??0);return e.colorContrast("string"==typeof r?r:"rgb(255, 255, 255)",t.schema.colorDefaults)},textAnchor:"middle",verticalAlign:"middle",...o,fontMin:(e,n)=>A_(t,c.get(e.data),Pm(o.fontMin,e,n)??Yx.fontMin)}}),d=$_(c,t=>({id:h(t),datum:t}));return[...u,...C_(t,d)]}const lW=t=>`geomap-link-${t.source.id}-${t.target.id}-${t.index}`;function hW(t){return b.interpolateRgb(Os(t),Ws(t))(.5)}function uW(t,e,n,i){return{fill:"none",stroke:n(e.datum,e)??i,strokeWidth:e.size,strokeOpacity:.85,strokeLinecap:"round"}}const dW=(t,e)=>!!t&&!!e&&Math.hypot(t[0][0]-e[0],t[0][1]-e[1])<=1;function fW(t,e,n){const i=bk({arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:e.size,datum:e.datum,i:e.index});if(!i.ends.source&&!i.ends.target)return{d:e.d,arrows:[]};const o=gO(e.d),r=o[o.length-1],a=t=>t?t+1:0,s={source:i.ends.source&&dW(o[0],e.sourceAt),target:i.ends.target&&dW(r?[...r].reverse():void 0,e.targetAt)},{d:c,source:l,target:h}=Fk(o,{...i,ends:s},{source:a(e.source.r),target:a(e.target.r)});return{d:c,arrows:Ek({ends:{source:l,target:h},size:i.size,datum:e.datum,keyPrefix:`${lW(e)}-arrow`,fill:n})}}function mW(t,e){if(!e.length)return[];const n=i_(t),i=hW(t),o=[],r=[],a=[],s=[...e].sort((t,e)=>e.size-t.size||t.index-e.index);for(const e of s){const s=uW(0,e,n,i),c=lW(e),l=fW(t,e,"string"==typeof s.stroke?s.stroke:void 0);l.arrows.length&&(s.strokeLinecap="butt"),o.push({type:"path",key:c,d:l.d,datum:e.datum,index:e.index,paint:s,aria:{label:Vb(t,e.datum)}}),r.push(Jb(c,e.d,e.datum,e.size)),a.push(...l.arrows)}return[...o,...r,...a]}function pW(t,e,n){return sk(t,e.map((t,e)=>({key:lW(t),link:t.datum,i:e,anchor:t.points?V_(t.points):null,path:t.points,priority:t.size})),{circles:n})}function gW(t){return`link:${Fb(t)?.index}`}function yW(t,e){const n=Fb(e),i=t.ctx.nodeLookup;if(!n||!i)return null;const o=[n.source.id,n.target.id].map(t=>i[t]),r=[];for(const t of o){if(!t||"number"!=typeof t.x||"number"!=typeof t.y)return null;const e="number"==typeof t.r?t.r:0;r.push([[t.x-e,t.y-e],[t.x+e,t.y+e]])}return[[Math.min(r[0][0][0],r[1][0][0]),Math.min(r[0][0][1],r[1][0][1])],[Math.max(r[0][1][0],r[1][1][0]),Math.max(r[0][1][1],r[1][1][1])]]}function xW(t){return void 0!==t._focus&&(t.active?.(!1),t._focus=void 0,t._zoomToBounds?.(null),!0)}const bW=new WeakSet;function _W(t){const e=t._select?.node?.();e&&"function"==typeof e.addEventListener&&(bW.has(e)||(bW.add(e),e.addEventListener("click",n=>{if(n.target!==e)return;const i=hh(t),{clientX:o,clientY:r}=n;t._backgroundClick?.([o-i.left,r-i.top])})))}function kW(t,e,{nodeKey:n,box:i}={}){t._tooltipClass?.data([]).render();const o=gW(e);t._focus!==o?(t.hover?.(!1),t.active?.(Yb(t,e,n)),t._focus=o,_W(t),i&&t._zoomToBounds&&rv(t,[i[0][0],i[1][0]],[i[0][1],i[1][1]])):xW(t)}function vW(t){t._backgroundClick=([e,n])=>{const{width:i,height:o}=kt(t),{left:r,top:a}=t._margin;e>=r&&e<=r+i&&n>=a&&n<=a+o&&xW(t)}}function wW(t,e){const n=Fb(e)?.index,i=(t.ctx.geomapCtx?.flowLinks??[]).find(t=>t.index===n);return i?i.box:null}function MW(t,e){const n=(e,n)=>`${t._id(e,n)}`;return Nb(e)?Yb(t,e,n):Ub(t,e,n)}function SW(t){t.links=function(){return arguments.length?(dn(this,"links",arguments),this):this.schema.links},vW(t);const e=t.schema.on;let n=!1;const i=e["mousemove.shape"];e["mousemove.shape"]=(e,o,r,a)=>{i?.(e,o,r,a);const s=MW(t,e);s&&(n=!0,hx.call(t,s))};const o=e["mouseleave.shape"];e["mouseleave.shape"]=(e,i,r,a)=>{o?.(e,i,r,a),n&&(n=!1,hx.call(t,!1))};const r=e["click.shape"];e["click.shape"]=(e,n,i,o)=>Nb(e)?(o?.stopPropagation?.(),void kW(t,e,{nodeKey:(e,n)=>`${t._id(e,n)}`,box:wW(t,e)})):xW(t)?void 0:r?.(e,n,i,o);const a=t._draw.bind(t);t._draw=function(e){const n=a(e);return t._container?.select("rect.d3plus-geomap-ocean").on("click.linkFocus",()=>xW(t)),n}}const CW="Shift+ArrowLeft Shift+ArrowRight Shift+ArrowUp Shift+ArrowDown",$W="Hold Shift and use the arrow keys to rotate the globe.",AW={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]},zW=t=>((t+180)%360+360)%360-180;function DW(t,e,n){const[i=0,o=0,r=0]=t;return[zW(i-e),Math.max(-90,Math.min(90,o-n)),r]}function LW(t,e,n){const[i=0,o=0,r=0]=t,[a=0,s=0,c=0]=e;return[zW(i+zW(a-i)*n),o+(s-o)*n,r+(c-r)*n]}function FW(t){if(!t.shiftKey||t.altKey||t.ctrlKey||t.metaKey)return null;const e=AW[t.key];return e?[10*e[0],10*e[1]]:null}const NW=(t,e)=>t.every((t,n)=>Math.abs(t-(e[n]??0))<1e-6);function BW(t,e){let n=null;const i=()=>t.schema.projection,o=n=>(i().rotate(n),e(),t._drawSceneToTarget?.(0),i().rotate()),r=()=>{void 0!==n?.frame&&cancelAnimationFrame(n.frame),n=null},a=t=>{if(!n)return;if(n.frame=void 0,!NW(i().rotate(),n.last))return r();const e=Math.max(0,Math.min(1,(t-n.start)/n.duration));n.last=o(e<1?LW(n.from,n.to,(t=>1-(1-t)**3)(e)):n.to),e<1?n.frame=requestAnimationFrame(a):n=null},s={keydown(e){const s=FW(e);if(!s||!ZO(t))return!1;const c=i();QO(t)||(t._globeHome={projection:c,rotate:c.rotate()});const l=c.rotate(),h=DW(n&&NW(l,n.last)?n.to:l,...s),u=Math.min(200,Zt(t));return r(),u&&"function"==typeof requestAnimationFrame?(n={from:l,to:h,start:performance.now(),duration:u,last:l},n.frame=requestAnimationFrame(a),!0):(o(h),!0)},keys:()=>ZO(t)?{shortcuts:CW,instructions:t.schema.translate($W)}:null};t._keyboardGesture=s}function EW(){return[{key:"arrows",default:!1},{key:"arrowSize"},...lk(),...uk(),{key:"links",default:[]},{key:"linkCurve",default:.2},{key:"linkSize",default:H(2),coerce:t=>"function"==typeof t?t:H(t)},hk(10),{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"nodeTooltipLinks"},{key:"tooltipConfig",merge:!0,factory:t=>Qb(t)}]}function RW(t){const{width:e,height:n}=kt(t);return[[0,0],[e,n]]}function PW(t){return nO(t.schema.tileUrl,Boolean(t._basemapDark))}function TW(t){const e=!!t.schema.tiles&&function(t){const e=tO.find(e=>e.matches.some(e=>t.includes(e)));return!!e&&e.text}(PW(t)),n=t.schema.attribution;n&&n!==t._tileAttribution||(t.schema.attribution=e||""),t._tileAttribution=e}function OW(t){!function(t){const e=t;e.fitFilter=function(t){if(arguments.length){if(this._zoomSet=!1,"function"==typeof t)return this.schema.fitFilter=t,this;const e=t instanceof Array?t:[t];return this.schema.fitFilter=t=>e.includes(t.id),this}return this.schema.fitFilter},e.fitKey=function(t){return arguments.length?(this.schema.fitKey=t,this._zoomSet=!1,this):this.schema.fitKey},e.fitObject=function(t,e){return arguments.length?(n.addToQueue.bind(this)(t,e,"fitObject"),this._zoomSet=!1,this):this.schema.fitObject},e.point=function(t){return arguments.length?(this.schema.point="function"==typeof t?t:H(t),this):this.schema.point},e.pointSize=function(t){return arguments.length?(this.schema.pointSize="function"==typeof t?t:H(t),this):this.schema.pointSize}}(t),function(t){const e=t;e.projection=function(t){return arguments.length&&"geoMercator"!==t&&e.tiles(!1),arguments.length?(this.schema.projection="string"==typeof t?(n=t,Object.hasOwn(aW,n)?aW[n]():(Bt(`Geomap received unknown projection "${n}"; using geoMercator. Pass the projection itself to use one not built in, e.g. .projection(${n}()).`),S.geoMercator())):t,this):this.schema.projection;var n},e.projectionPadding=function(t){return arguments.length?(this.schema.projectionPadding=r.parseSides(t),this):this.schema.projectionPadding},e.projectionRotate=function(t){return arguments.length?(this.schema.projectionRotate=t,this.schema.projection.rotate(t),e.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}(t),function(t){const e=t;e.tiles=function(t){return arguments.length?(this.schema.tiles=t,TW(this),this):this.schema.tiles},e.tileUrl=function(t){return arguments.length?(this.schema.tileUrl=t,TW(this),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}(t),function(t){const e=t;e.topojson=function(){return arguments.length?(dn(this,"topojson",arguments),this._zoomSet=!1,this):this.schema.topojson},e.topojsonFill=function(t){return arguments.length?(this.schema.topojsonFill="function"==typeof t?t:H(t),this):this.schema.topojsonFill},e.topojsonFilter=function(t){if(arguments.length){if(this._zoomSet=!1,"function"==typeof t)return this.schema.topojsonFilter=t,this;const e=t instanceof Array?t:[t];return this.schema.topojsonFilter=t=>e.includes(t.id),this}return this.schema.topojsonFilter},e.topojsonKey=function(t){return arguments.length?(this.schema.topojsonKey=t,this._zoomSet=!1,this):this.schema.topojsonKey},e.topojsonId=function(t){return arguments.length?(this.schema.topojsonId="function"==typeof t?t:I(t),this):this.schema.topojsonId}}(t)}const WW={name:"Geomap",layoutStage:rW,sizeLegendScale:t=>{const e=tW(t);return e.length?eW(t,e):null},emit:({viz:t})=>{const e=t.ctx.geomapCtx;if(!e)return[];const n=function(t){const e=[],n="panel"===t._facetStep;if(t._ssr||n){const n=nO(t.schema.ocean,Boolean(t._basemapDark));if(n&&"transparent"!==n){const{width:i,height:o}=kt(t);e.push({type:"rect",key:"geomap-ocean",x:0,y:0,width:i,height:o,paint:{fill:n}})}}const i=t._ssrTiles;if((i&&i.size||n&&!t._ssr)&&"function"==typeof t._computeTileList)for(const n of t._computeTileList()){const t=i&&i.size?i.get(n.key):n.url;t&&e.push({type:"image",key:`geomap-tile-${n.key}`,x:n.x,y:n.y,width:n.size,height:n.size,href:t,preserveAspectRatio:"none",interactive:!1})}return e}(t);if(e.topoData&&e.topoData.length){const i=Hm(t,"Path"),o=t.schema.colorScale,r=n.length;for(let r=0;r<e.topoData.length;r++){const a=e.topoData[r],s=a.data??a,c=Om(i,s,r),l=o?`, ${o(s,r)}`:"";n.push({type:"path",key:`geomap-path-${a.id}`,d:e.pathFn(a),datum:s,paint:{...c,vectorEffect:c.vectorEffect??"non-scaling-stroke"},aria:{label:`${t._drawLabel(s,r)}${l}.`}})}n.push(...tw(i,n.slice(r),t=>{const n=e.topoData[t];return[n.data??n,t]}))}const i=e.flowLinks??[];n.push(...mW(t,i));const o=[];if(e.pointData&&e.pointData.length){const i=Hm(t,"Circle"),r=e.pointSort?[...e.pointData].sort(e.pointSort):e.pointData,a=n.length;for(let a=0;a<r.length;a++){const s=r[a],c=Om(i,s,a);o.push({x:e.pointX(s,a),y:e.pointY(s,a),r:e.pointR(s,a)}),n.push({type:"circle",key:`geomap-point-${t._id(s,a)}`,cx:0,cy:0,r:e.pointR(s,a),transform:{x:e.pointX(s,a),y:e.pointY(s,a)},datum:s,paint:{...c,vectorEffect:c.vectorEffect??"non-scaling-stroke"},aria:{label:`${t._drawLabel(s,a)}, ${t.schema.pointSize(s,a)}.`},...i.trail?{trail:!0}:{},...i.trailPersist?{trailPersist:i.trailPersist}:{}})}n.push(...tw(i,n.slice(a),t=>[r[t],t])),n.push(...cW(t,{points:r,pointR:e.pointR,pointX:e.pointX,pointY:e.pointY},i))}return n.push(...pW(t,i,o)),n},insetRegion:Cp,colorScaleShape:(t,e,n)=>t.schema.point(e,n)instanceof Array?t.schema.shape(e,n):"Path",pointMark:(t,e)=>ih(e),chartClip:wt,setup:t=>{const e=t;t._zoomSet=!1,t.schema.tiles=!0,t._tileGen=M.tile(),function(t){t._renderTiles=function(t=Cu(this),e=0){if(this._ssr)return;if(this._facetPanels||this._facetStep)return void this._tileGroup?.selectAll("image.d3plus-geomap-tile").remove();let n=[];this.schema.tiles&&(n=this._tileGen.extent(RW(this)).scale(this.schema.projection.scale()*(2*Math.PI)*t.k).translate(t.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(e).attr("transform",t));const i=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(n,([t,e,n])=>`${t}-${e}-${n}`);i.exit().transition().duration(e).attr("opacity",0).remove();const o=n.scale/t.k,r=i.enter().append("image").attr("class","d3plus-geomap-tile");r.attr("opacity",0).transition().duration(e).attr("opacity",1),i.interrupt(),i.merge(r).attr("width",o).attr("height",o).attr("xlink:href",([t,e,n])=>PW(this).replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${n}`).replace("{x}",`${t}`).replace("{y}",`${e}`)).attr("x",([e])=>e*o+n.translate[0]*o-t.x/t.k).attr("y",([,e])=>e*o+n.translate[1]*o-t.y/t.k)},t._computeTileList=function(){if(!this.schema.tiles)return[];const t=this._tileGen.extent(RW(this)).scale(this.schema.projection.scale()*(2*Math.PI)).translate(this.schema.projection.translate())(),e=t.scale;return t.map(([n,i,o])=>({key:`${n}-${i}-${o}`,url:PW(this).replace("{s}","a").replace("{z}",`${o}`).replace("{x}",`${n}`).replace("{y}",`${i}`),x:n*e+t.translate[0]*e,y:i*e+t.translate[1]*e,size:e}))}}(t),function(t){const e=t._draw.bind(t);t._draw=function(n){t._basemapDark=t._theme?t._theme.dark:ff(t),TW(t);const i=e(n),{width:o,height:r}=kt(t);return tc(t,{kind:"geomap",width:o,height:r,duration:Zt(t),ocean:t._facetStep?"transparent":nO(t.schema.ocean,Boolean(t._basemapDark))}),t._zoomSet=!0,i}}(t),OW(t),SW(t);const n=()=>Mt(t,WW,rW);JO(t,n),BW(t,n),e.tileUrl(eO),t.schema.topojsonFill=()=>t._theme?.colorScale.missing??(t._basemapDark?"#3d3e44":"#f5f5f3")},ctx:{},fields:[...pn("topojson","links"),{key:"fitObject",default:!1},...EW(),{key:"noDataMessage",default:!1},{key:"ocean",default:{light:"#d0cfd4",dark:"#222327"}},{key:"point",default:I("point")},{key:"pointSize",default:H(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:S.geoMercator()},{key:"projectionPadding",default:r.parseSides(20)},{key:"shape",default:H("Circle"),coerce:"const"},{key:"topojson",default:!1},{key:"topojsonFill",default:H("#f5f5f3")},{key:"topojsonFilter",default:t=>!["010"].includes(t.id)},{key:"topojsonId",default:I("id")},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>`${t._drawLabel(e,n)}, ${t.schema.pointSize(e,n)}`,hoverOpacity:1,Path:{ariaLabel:(e,n)=>{const i=t.schema.colorScale,o=i?`, ${i(e,n)}`:"";return`${t._drawLabel(e,n)}${o}.`},fill:(e,n)=>{const i=t.ctx.coordData?.features??[],o=t.schema.colorScale;if(o&&!i.includes(e)){const n=o(e);if(null!=n){if(t._colorScaleClass._colorScale)return t._colorScaleClass._colorScale(n);let e=t._colorScaleClass.color();return e instanceof Array&&(e=e[e.length-1]),e}}return t.schema.topojsonFill(e,n)},on:{mouseenter:(e,n,i,o)=>(t.ctx.coordData?.features??[]).includes(e)?null:t.schema.on.mouseenter.bind(t)(e,n,i,o),"mousemove.shape":(e,n,i,o)=>(t.ctx.coordData?.features??[]).includes(e)?null:t.schema.on["mousemove.shape"].bind(t)(e,n,i,o),mouseleave:(e,n,i,o)=>(t.ctx.coordData?.features??[]).includes(e)?null:t.schema.on.mouseleave.bind(t)(e,n,i,o)},stroke:(e,n)=>{const o=t.schema.shapeConfig.Path,r="function"==typeof o.fill?o.fill(e,n):o.fill,a=i.color(r);return a?a.darker().toString():r},strokeWidth:1},Circle:{trail:!0}})}]};var HW=lx(WW);const jW=Math.sqrt(3),IW=t=>Number.isFinite(t.x)&&Number.isFinite(t.y);function GW(t,e){const{shape:n,size:i}=e,[o,r]=e.origin??[0,0],a=t.filter(IW);if(!(i>0&&a.length))return[];if("square"===n){const t=new Map;for(const e of a){const n=Math.floor((e.x-o)/i),a=Math.floor((e.y-r)/i),s=`s${n}_${a}`;let c=t.get(s);c||(c={key:s,cx:o+(n+.5)*i,cy:r+(a+.5)*i,points:[]},t.set(s,c)),c.points.push(e)}return Array.from(t.values())}const s=i*jW,c=1.5*i;return z.hexbin().radius(i).x(t=>t.x-o).y(t=>t.y-r)(a).map(t=>({key:`h${Math.round(2*t.x/s)}_${Math.round(t.y/c)}`,cx:o+t.x,cy:r+t.y,points:Array.from(t)}))}function qW(t,e,n){const i="square"===e?n/2:n*jW/2,o="square"===e?n/2:n;return{x0:t.cx-i,x1:t.cx+i,y0:t.cy-o,y1:t.cy+o}}function VW(t,e,n){const i=t=>Math.round(100*t)/100;if("square"===e){const{x0:o,x1:r,y0:a,y1:s}=qW(t,e,n);return`M${i(o)},${i(a)}H${i(r)}V${i(s)}H${i(o)}Z`}return`M${[0,1,2,3,4,5].map(e=>{const o=e*Math.PI/3;return`${i(t.cx+Math.sin(o)*n)},${i(t.cy-Math.cos(o)*n)}`}).join("L")}Z`}function YW(t,e){return"square"===t?e*e:3*jW/2*e*e}function KW(t,e){if("count"===e)return t.length;let n=0,i=0;for(const e of t)"number"==typeof e.weight&&Number.isFinite(e.weight)&&(n+=e.weight,i++);return"sum"===e?n:i?n/i:NaN}function UW(t,e){return Array.isArray(e)?e.filter(t=>Number.isFinite(t)&&t>0).sort((t,e)=>t-e):t>0&&e>0?h.ticks(0,t,e).filter(e=>e>0&&e<t):[]}function XW(t,[e,n]=[0,0]){const i=t=>Math.round(100*t)/100;return t.flatMap(t=>t.map(t=>`M${t.map(([t,o])=>`${i(t+e)},${i(o+n)}`).join("L")}Z`)).join("")}function ZW(t,e){const{left:n,top:i,width:o,height:r,bandwidth:a,unit:s}=e,c=t.filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y));if(!(c.length&&o>0&&r>0&&s>0))return[];const l=D.contourDensity().x(t=>t.x-n).y(t=>t.y-i).weight(t=>"number"==typeof t.weight&&Number.isFinite(t.weight)?t.weight:1).size([Math.ceil(o),Math.ceil(r)]).bandwidth(Math.max(a,.5)).contours(c);return UW(l.max*s,e.thresholds).map(t=>({level:t,path:XW(l(t/s).coordinates,[n,i])})).filter(t=>t.path.length)}const QW="Hexbin",JW="__d3plusHexbin",tH={bandwidth:20,thresholds:8,strokeWidth:1.5,fillOpacity:.8,labels:!0,labelConfig:{},labelSpacing:"auto",labelStep:"auto"},eH={r:1.5,fillOpacity:.35};function nH(t){for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function iH(t){const e=t?nH(t):void 0;return e?e[JW]:void 0}function oH(t){const e=iH(t);return e?"bin"===e.kind?e.value:e.level:void 0}function rH(t,e){return{id:t,[JW]:e}}function aH(t,e){if(!t||"count"===t||"object"!=typeof t)return{agg:"count",measure:e("Count")};const{value:n,agg:i,label:o}=t,r="function"==typeof n?n:"string"==typeof n?q(n):void 0;if(!r)return{agg:"count",measure:e("Count")};const a="mean"===i?"mean":"sum",s="string"==typeof n?n:V(r)??void 0,c=e("mean"===a?"Mean":"Total");return{agg:a,weight:r,measure:o??(s?`${c} ${s}`:c)}}function sH(t){const e=t.schema,n="square"===e.binShape?"square":!1!==e.binShape&&"hex",i=Number(e.binSize),o="filled"===e.contours?"filled":(!0===e.contours||"lines"===e.contours)&&"lines";return{shape:n,size:i>0?i:12,...aH(e.binValue,t=>e.translate(t)),contours:o,contourConfig:{...tH,...e.contourConfig},points:Boolean(e.points),pointConfig:{...eH,...e.pointConfig}}}function cH(t){return t.ctx.hexbin}const lH=t=>"number"==typeof t&&Number.isFinite(t);function hH(t){const{xRange:e,yRange:n}=t;return{left:e[0],top:n[0]-(t.x2Height??0),width:e[e.length-1]-e[0],height:n[n.length-1]-n[0]}}function uH(t,e,n){const i=e.shape||"hex",o=[];for(const r of t){const t=KW(r.points,e.agg);if(!Number.isFinite(t))continue;const a=qW(r,i,e.size),[s,c]=[n.x(a.x0),n.x(a.x1)].sort((t,e)=>t-e),[l,h]=[n.y(a.y0),n.y(a.y1)].sort((t,e)=>t-e);o.push(rH(`bin-${r.key}`,{kind:"bin",count:r.points.length,value:t,x0:s,x1:c,y0:l,y1:h,path:VW(r,i,e.size),rows:r.points.map(t=>t.row)}))}return o}function dH(t,e,n){const{bandwidth:i,thresholds:o}=n.contourConfig,r=ZW("sum"===n.agg?t:t.map(t=>({...t,weight:1})),{...e,bandwidth:i,thresholds:o,unit:YW(n.shape||"hex",n.size)});return r.map((t,e)=>rH(`contour-${e}`,{kind:"contour",level:t.level,next:r[e+1]?.level,index:e,levels:r.length,path:t.path}))}function fH(t,e,n){const i=n.shape||"hex";return t.filter(t=>{const o=qW(t,i,n.size);return o.x1>e.left&&o.x0<e.left+e.width&&o.y1>e.top&&o.y0<e.top+e.height})}function mH(t,e){const n=t=>Math.round(10*t)/10;let i="";for(const o of t)lH(o.x)&&lH(o.y)&&(i+=`M${n(o.x-e)},${n(o.y)}a${e},${e} 0 1,0 ${2*e},0a${e},${e} 0 1,0 ${-2*e},0`);return i}function pH(t,e,n,i){const o={x:()=>NaN,y:()=>NaN};return i.shape?uH(fH(GW(t,{shape:i.shape,size:i.size,origin:n}),e,i),i,o):i.contours?dH(t,e,i):[]}function gH(t,e,n,i,o){const{weight:r}=o;return e.map((e,o)=>({x:n(Number(t._x(e,o))),y:i(Number(t._y(e,o))),row:e,weight:r?Number(r(e,o)):void 0}))}function yH(t,e){if(!he(t))return[e];const n=t.schema.facet;return h.groups(e,(t,e)=>Cm($m(n(t,e)))).map(([,t])=>t)}function xH(t){const e=cH(t);e.colorRows=void 0;const n=t._filteredData??[],i=n.map((e,n)=>Number(t._x(e,n))).filter(lH),o=n.map((e,n)=>Number(t._y(e,n))).filter(lH),[r]=h.extent(i),[a]=h.extent(o);e.anchor=void 0!==r&&void 0!==a?[r,a]:void 0,e.panels=he(t)?yH(t,n):void 0}function bH(t,e,n,i,o){const{viz:r}=t,a=cH(r).panels;return"panel"===r._facetStep&&a?a.flatMap(e=>pH(gH(r,e,e=>t.x(e),e=>t.y(e),o),n,i,o)):e}function _H(t){return cH(t).colorRows??vH(t,sH(t))}const kH={width:.8,height:.7};function vH(t,e){const n=t._filteredData??[],i=n.map((e,n)=>Number(t._x(e,n))).filter(lH),o=n.map((e,n)=>Number(t._y(e,n))).filter(lH);if(!i.length||!o.length)return[];const r=yH(t,n),a={left:0,top:0,width:t.schema.width*kH.width/Math.sqrt(r.length),height:t.schema.height*kH.height/Math.sqrt(r.length)},s=c.scaleLinear().domain(h.extent(i)).range([a.left,a.left+a.width]),l=c.scaleLinear().domain(h.extent(o)).range([a.top+a.height,a.top]),u=[a.left,a.top+a.height];return r.flatMap(n=>pH(gH(t,n,s,l,e),a,u,e))}function wH(t,e){cH(t).colorRows=e;const n=t._colorScaleClass;n&&t.schema.colorScale&&n.data(e).render()}function MH(t,e,n,i,o){if(!t.invert)return;const[r,a]=h.extent(n.filter(lH));if(void 0===r||void 0===a)return;let s=t.domain().slice();s=ww(t,e,r,i,s,0,o),ww(t,e,a,i,s,1,o)}function SH({data:t,x:e,y:n,x2:i,y2:o,xScale:r,yScale:a}){if(i||o)return[e,n];const{size:s}=sH(this);return e=e.copy(),n=n.copy(),MH(e,r??"linear",t.map(t=>t.x),s,!1),MH(n,a??"linear",t.map(t=>t.y),s,!0),[e,n]}const CH=(t,e)=>Number.isFinite(e)?d.formatAbbreviate(e,t.schema.locale):"",$H=(t,e,n)=>`${CH(t,e)} – ${CH(t,n)}`;function AH(t,e){const n=t[`_${e}Key`];return"string"==typeof n?n:e}function zH(t,e){const n=t.schema.levelFormat;return"function"==typeof n?`${n(e)}`:CH(t,e)}function DH(t,e,n){const i=e=>zH(t,e);return void 0===n?`≥ ${i(e)}`:`${i(e)} – ${i(n)}`}function LH(t,e){const n=iH(e);if(!n)return"";return"contour"===n.kind?(i="Density",t.schema.translate(i)):`${sH(t).measure}: ${CH(t,n.value)}`;var i}function FH(t,e){const n=iH(e);if(!n)return[];const i=e=>t.schema.translate(e);if("contour"===n.kind)return[[i("Range"),DH(t,n.level,n.next)]];const o=[[AH(t,"x"),$H(t,n.x0,n.x1)],[AH(t,"y"),$H(t,n.y0,n.y1)]];return"count"!==sH(t).agg&&o.push([i("Count"),CH(t,n.count)]),o}function NH(t,e){const n=iH(e);return n?[LH(t,e),`${AH(t,"x")} ${$H(t,n.x0,n.x1)}`,`${AH(t,"y")} ${$H(t,n.y0,n.y1)}`].join(", "):""}function BH(t,e){const n=iH(e);if(!n||"contour"!==n.kind)return"";return`${i="Density",t.schema.translate(i)}: ${DH(t,n.level,n.next)}`;var i}const EH=Math.PI/3;function RH(t){return(t.match(/M[^MZ]*/g)??[]).map(t=>t.slice(1).split("L").map(t=>t.split(",").map(Number)).filter(([t,e])=>Number.isFinite(t)&&Number.isFinite(e))).filter(t=>t.length>2).map(t=>[...t,t[0]])}function PH(t,e){return"number"==typeof t&&Number.isFinite(t)?Math.max(1,Math.round(t)):e>5?2:1}function TH(t,e=PH("auto",t.length)){if(e<=1)return t.map(()=>!0);const n=t[1]-t[0];return n>0&&t.every((e,i)=>!i||Math.abs(e-t[i-1]-n)<1e-9)&&Math.abs(t[0]/n-Math.round(t[0]/n))<1e-9?t.map(t=>Math.round(t/n)%e===0):t.map((t,n)=>(n+1)%e===0)}function OH(t,e,n){return"number"==typeof t&&t>0&&Number.isFinite(t)?t:Math.max(20*e,(n.width+n.height)/4)}function WH(t,e,n){const i=Math.abs(((t-e)%n+n)%n);return Math.min(i,n-i)}function HH(t,e){const n=e.fontSize/2;return[-n,0,n].flatMap(n=>Eg(t,{...e,lift:e.lift+n}))}function jH(t,e,n,i){const o=Tp(t);if(!(o>2*e))return[];const r=Math.max(i,e),a=Hp([...t,...t.slice(1)],0,o+e),s=Math.max(1,Math.floor(o/r)),c=[],l=[];for(;l.length<s;){const t=Og([a],e,n,t=>t<o&&c.every(n=>WH(t+e/2,n,o)>=r));if(!t)break;c.push(t.from+e/2),l.push(t.points),n.grid.add(HH(t.points,n))}return l}function IH(t,e,n,i,o,a=[]){const{labels:c,labelConfig:l,labelSpacing:h,labelStep:u,strokeWidth:d}=o.contourConfig;if(!c||!e.length)return[];const f=e.map(t=>iH(t)).filter(t=>"contour"===t?.kind),m=f.map(t=>RH(t.path)),p="number"==typeof l.fontSize?l.fontSize:10,g={"font-family":r.fontExists(l.fontFamily??s.fontFamily),"font-size":p,"font-weight":l.fontWeight??600},y={x0:i.left,y0:i.top,x1:i.left+i.width,y1:i.top+i.height},x=new Fg(p);for(const t of a)x.add(Ng(t,2));let b=0;const _=m.map(t=>t.map(t=>(x.add(Ng(t,2),b),b++))),k={grid:x,rect:y,fontSize:p,lift:-.3*p,maxTurn:EH,minClearance:Math.max(2,.3*p)},v=OH(h,p,i),w=function(t){const e=new Map;for(const n of t){const t=iH(n.datum);if("contour"!==t?.kind)continue;const i=n.paint??{},o=(i.strokeWidth??0)>0?i.stroke:i.fill;o&&e.set(t.index,o)}return e}(n),M="lines"===o.contours&&d>0,S=TH(f.map(t=>t.level),PH(u,f.length)),C=[],$=[];return f.forEach((e,n)=>{if(!S[n])return;const i=zH(t,e.level);if(!i)return;const o=r.textWidth(i,g)+.8*p;m[n].forEach((r,a)=>{k.ignore=_[n][a],jH(r,o,k,v).forEach((n,o)=>{const r=`contour-label-${e.index}-${a}-${o}`;M&&C.push({type:"path",key:`${r}-pad`,d:Ip(n),interactive:!1,aria:{hidden:!0},paint:{fill:"none",stroke:Os(t),strokeWidth:d+2,strokeLinecap:"butt"}}),$.push({key:r,text:i,d:Ip(Wp(n,k.lift)),color:w.get(e.index)??Ws(t),anchor:"middle"})})})}),[...C,...qp(t,$,{fontSize:p,...l})]}function GH(t,e,n){const i=("x"===e?t._xAxis:t._yAxis)?._d3Scale;return t=>i&&i.invert?Number(i.invert(t+n)):NaN}function qH(t,e){const n=t.values,{weight:i}=e;return n.map(e=>({x:t.x(e.x),y:t.y(e.y),row:e.data,weight:i?Number(i(e.data,e.i)):void 0}))}function VH(t,e,n,i){if(!e.length)return[];const{viz:o}=t,r=Hm(o,QW),a=Rm("Path").renderMode("compute").config(r).config(n(r)).config({ariaLabel:t=>"contour"===iH(t)?.kind?BH(o,t):NH(o,t),d:t=>iH(t)?.path??"",id:t=>t.id,label:!1,x:0,y:0}).data(e);return i&&o._wirePlotShapeEvents(a,QW,t.events),Im(a).map(t=>({...t,shapeType:QW,...i?{}:{interactive:!1}}))}function YH(t,e,n){const i=mH(e,n.pointConfig.r);return i?[{type:"path",key:"hexbin-points",d:i,interactive:!1,aria:{hidden:!0},paint:{fill:n.pointConfig.fill??Ws(t),fillOpacity:n.pointConfig.fillOpacity}}]:[]}function KH(t){return(t.viz._trendFits??[]).map(e=>e.samples.map(e=>[t.x(e.x),t.y(e.y)]).filter(([t,e])=>Number.isFinite(t)&&Number.isFinite(e)))}const UH=t=>{const{viz:e}=t,n=sH(e),i=hH(t),o=qH(t,n),r={x:GH(e,"x",0),y:GH(e,"y",t.x2Height??0)},a=function(t,e){const n=cH(t.viz).anchor,i=n?t.x(n[0]):NaN,o=n?t.y(n[1]):NaN;return[Number.isFinite(i)?i:e.left,Number.isFinite(o)?o:e.top+e.height]}(t,i),s=n.shape?GW(o,{shape:n.shape,size:n.size,origin:a}):[],c=uH(s,n,r),l=n.contours?dH(o,i,n):[],h=new Set(fH(s,i,n).map(t=>`bin-${t.key}`));wH(e,bH(t,n.shape?c.filter(t=>h.has(String(t.id))):l,i,a,n));const u=VH(t,l,t=>function(t,e,n){const{strokeWidth:i,fillOpacity:o}=e.contourConfig,r=Boolean(e.shape);return"filled"===e.contours?{fillOpacity:t=>{const e=iH(t);return e&&"contour"===e.kind?o*(e.index+1)/e.levels:o},stroke:n,strokeWidth:0}:{fillOpacity:0,stroke:r?()=>Ws(t):n,strokeWidth:i}}(e,n,(t=>{const e=t.fill;return(t,n)=>"function"==typeof e?e(t,n):e})(t)),!n.shape);return[...n.points?YH(e,o,n):[],...VH(t,c,()=>({}),!0),...u,...IH(e,l,u,i,n,KH(t))]};function XH(t){const e=cH(t);t._data!==e.rows&&(e.raw=t._data),t._sourceData=e.raw;const n=e.raw.filter((e,n)=>lH(t._x(e,n))&&lH(t._y(e,n)));e.rows=t._data=n.length===e.raw.length?e.raw:n}const ZH={name:"Hexbin",paintDriven:!0,setup:t=>{t.ctx.hexbin={raw:[],rows:[]},t._buffer={...t._buffer,[QW]:SH},t._plotShapeEmitters={[QW]:UH},t._unmergedShapes=[QW],t._colorScaleRows=()=>_H(t),t._tooltipAxisRows=!1,t._sharedHover=()=>{},function(t){const e=t.schema.on.mouseenter;t.schema.on.mouseenter=(n,i,...o)=>{if(!iH(n)||1===t.schema.shapeConfig.hoverOpacity)return e(n,i,...o);const r=nH(n);t._hoverBucket=!1,t.hover(t=>nH(t)===r)}}(t);const e=t._preDraw.bind(t);t._preDraw=()=>{XH(t),e()};const n=t._draw.bind(t);t._draw=e=>("panel"!==t._facetStep&&xH(t),n(e))},ctx:{},fields:[{key:"binShape",default:"hex"},{key:"binSize",default:12},{key:"binValue",default:"count"},{key:"contours",default:!1},{key:"contourConfig",merge:!0,default:tH},{key:"levelFormat"},{key:"points",default:!1},{key:"pointConfig",merge:!0,default:eH},{key:"colorScale",coerce:Jc,default:oH},{key:"colorScaleConfig",merge:!0,default:{scale:"linear"}},{key:"legend",default:!1,coerce:"const"},{key:"shape",default:H(QW),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({[QW]:{stroke:()=>Os(t),strokeWidth:H(.5)}})},{key:"tooltipConfig",merge:!0,factory:t=>({title:e=>LH(t,e),tbody:e=>FH(t,e)})}]};var QH=lx(ZH,ZD);const JH=new WeakMap;function tj(t){const e=I(t);return JH.set(e,t),e}function ej(t){return"function"==typeof t?JH.get(t)??V(t):void 0}function nj(t,e,n){!t||void 0!==t.title&&t.title!==e||(t.title=n)}function ij(t="count",e=!1){return e&&"density"===t?"relative":t}function oj(t,e){if(!e)return t.slice();const n="reverse"===e,i=new Array(t.length);let o=0;for(let e=0;e<t.length;e++){const r=n?t.length-1-e:e;i[r]=o+=t[r]}return i}function rj(t,e){let[n,i]=e.domain??h.extent(t),o=Boolean(e.domain);if(n===i&&([n,i]=[n-.5,i+.5],o=!0),e.width&&e.width>0)return function(t,e,n){const i=Math.floor(t/n)*n,o=Math.max(Math.ceil(e/n)*n,i+n);return h.range(0,Math.round((o-i)/n)+1).map(t=>i+t*n)}(n,i,e.width);let r=h.bin();o&&(r=r.domain([n,i]));const a=e.thresholds??h.thresholdSturges,s=r.thresholds(a)(t);return[s[0].x0,...s.map(t=>t.x1)]}function aj(t,e){const{value:n,panel:i=()=>""}=e,o=t.map((t,e)=>({d:t,i:e,v:Number(n(t,e))})).filter(t=>t.d&&Number.isFinite(t.v));if(!o.length)return[];const r=e.sharedEdges?rj(o.map(t=>t.v),e):void 0;return h.groups(o,t=>i(t.d,t.i)).flatMap(([,t])=>function(t,e,n){const{group:i=()=>"",cumulative:o=!1}=n,r=ij(n.normalize,o),a=h.bin().domain([e[0],e[e.length-1]]).thresholds(e.slice(1,-1)),s=t.length,c=[];for(const[,e]of h.groups(t,t=>i(t.d,t.i))){const t=a(e.map(t=>t.v)),n=e[0].d,i=oj(t.map(t=>t.length),o);t.forEach((t,e)=>{const a=t.x0,l=t.x1,h=t.length,u=i[e],d="density"===r?u/(s*(l-a)):"relative"===r?u/s:u;c.push({...n,x0:a,x1:l,x:(a+l)/2,count:h,...o?{cumulativeCount:u}:{},y:d})})}return c}(t,r??rj(t.map(t=>t.v),e),e))}const sj={count:"Count",density:"Density",relative:"Relative Frequency"},cj={count:"Cumulative Count",density:"Cumulative Relative Frequency",relative:"Cumulative Relative Frequency"};function lj(t="count",e=!1){const n=ij(sj[t]?t:"count",e);return(e?cj:sj)[n]}function hj(t){for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}const uj=t=>Array.isArray(t.x);function dj(t){const e=t.ctx.histogram;t._data!==e.bins&&(e.raw=t._data),t._sourceData=e.raw;const n=function(t,e){if(t.schema.timeFilter)return t.schema.timeFilter;const n=t._data;t._data=e;try{return pm(t)}finally{t._data=n}}(t,e.raw),i=t.schema.filter,o=n?e.raw.filter(n):e.raw,r=i?o.filter(i):o,a=he(t)?t.schema.facet:void 0,s=t.schema.groupBy,c=ej(t.schema.value),l=aj(r,{value:t.schema.value,group:(t,e)=>s.map(n=>`${n(t,e)}`).join("_"),panel:a?(t,e)=>Cm($m(a(t,e))):void 0,sharedEdges:"independent"!==oe(t.schema.facetConfig).scales,thresholds:t.schema.binThresholds,domain:t.schema.binDomain,width:t.schema.binWidth,normalize:t.schema.binNormalize,cumulative:t.schema.cumulative}),h=l.every((t,e)=>s.every(n=>void 0===n(t,e)));l.forEach(e=>{c&&delete e[c],h&&(e.id=c??t.schema.translate("Value"))});const u=n?e.raw.filter((t,e)=>!n(t,e)):[];e.bins=t._data=u.length?[...l,...u]:l,e.binned=new Set(l);const d=t.schema.translate(lj(t.schema.binNormalize,t.schema.cumulative));nj(t._yConfig,e.yTitle,d),e.yTitle=d,nj(t._xConfig,e.xTitle,c),e.xTitle=c}const fj={name:"Histogram",paintDriven:!0,thresholdFunction:(t,e)=>e,defaults:{groupPadding:1},setup:t=>{const e={raw:[],bins:[],binned:new Set};t.ctx.histogram=e,t._filterApplied=t=>e.binned.has(t),t.stackOrder("key"),t.schema.shapeConfig.Bar={...t.schema.shapeConfig.Bar,label:!1},t._discreteExtent=t=>[t.x0,t.x1];const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(e,i,o,r)=>{if(n(e,i,o,r),1===t.schema.shapeConfig.hoverOpacity)return;const a=hj(e),s=`${t._id(a,i)}`;t.hover((e,n)=>{const i=hj(e);return`${t._id(i,n)}`===s&&(uj(i)||i.x0===a.x0)})};const i=t._preDraw.bind(t);t._preDraw=()=>{dj(t),i()}},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"binThresholds"},{key:"binDomain"},{key:"binWidth"},{key:"binNormalize",default:"count"},{key:"cumulative",default:!1},{key:"discrete",default:"x"},{key:"shape",default:H("Bar"),coerce:"const"},{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:t=>{const e=e=>d.formatAbbreviate(e,t.schema.locale),n=t=>{const n=hj(t);return`${e(n.x0)} – ${e(n.x1)}`},i=(e,n)=>t.schema.groupBy.some(t=>void 0!==t(hj(e),n));return{title:(e,o)=>i(e,o)?t._drawLabel(hj(e),o):n(e),tbody:(o,r)=>{const a=hj(o),s=t.schema.translate,c=[];if(uj(a))return[[s("Count"),e(a.count)]];i(o,r)&&c.push([s("Range"),n(o)]),c.push([s("Count"),e(a.count)]);const l=t.schema.cumulative;l&&c.push([s("Cumulative Count"),e(Number(a.cumulativeCount))]);const h=t.schema.binNormalize;return"count"!==ij(h,l)&&c.push([s(lj(h,l)),e(a.y)]),c}}}},{key:"value",default:tj("value"),coerce:t=>"string"==typeof t?q(t):"function"==typeof t?t:H(t)}]};var mj=lx(fj,ZD);function pj(t,e){const{aggs:i,drawDepth:o,groupBy:r,label:a,threshold:s,thresholdKey:c}=e,l=h.sum(t,c);if(!s||!c)return t;return function t(e,u){if(u<o)return[...h.group(e,r[u])].reduce((e,[,n])=>{const i=t(n,u+1)??[];return e.concat(i)},[]);if(u===o){const t=Math.min(1,Math.max(0,s(e)));if(!isFinite(t)||isNaN(t))return null;const o=[],h=[],d=t*l;for(let t=0;t<e.length;t++){const n=e[t];c(n)<d?o.push(n):h.push(n)}if(o.length<2)return e;const f=n.merge(o,i);return f._isAggregation=!0,f._threshold=t,f[vl]=wl(o,(t,e)=>e,a??(t=>r[u](t)),c),h.push(f),h}throw new Error("Depth is higher than the amount of grouping levels.")}(t,0)??t}function gj(t,e,n={}){const{level:i=0,path:o=[],index:r=()=>0}=n;if(!e.length)return{children:[],own:t};const[a,...s]=e,c=[],l=new Map;for(const e of t){const t=a(e,r(e));if(null==t){c.push(e);continue}const n=l.get(t);n?n.push(e):l.set(t,[e])}return{children:[...l].map(([t,e])=>{const n=[...o,t];if(!s.length)return{key:t,path:n,level:i,rows:e,own:e};const a=gj(e,s,{level:i+1,path:n,index:r});return{key:t,path:n,level:i,rows:e,own:a.own,children:a.children.length?a.children:void 0}}),own:c}}function yj(t){const{children:e,rows:n}=t.data;return!e&&1===n.length&&!0===n[0]._isAggregation}function xj(t){return(e,n)=>{const i=yj(e),o=yj(n);return i&&!o?1:!i&&o?-1:t(e,n)}}function bj(t){if(!(fl in t))return t;const e={...t};return e.share===e[fl]&&delete e.share,delete e[fl],e}function _j(t,e){const i=n.merge(t.map(bj),e);return delete i._isAggregation,delete i._threshold,delete i[vl],i}function kj(t,e){const{data:n,keys:i,firstLevel:o,focusPath:r,sum:a,sort:s,aggs:c}=t;if(!n.length)return[];const l=t=>n.indexOf(t),h=gj(n,i,{level:o,path:r,index:l}),u={key:r[r.length-1],path:r,level:o-1,rows:n,own:h.own,children:h.children};let d=L.hierarchy(u,t=>t.children).sum(t=>t.own.reduce((t,e)=>t+(Number(a(e))||0),0));s&&(d=d.sort(s));const f=L.partition().size([t.breadth??1,i.length+1])(d),m=f.value??0,p=[],g=new Map;for(const t of f.descendants()){if(0===t.depth&&!r.length)continue;const n=t.value??0;if(!(n>0)||t.x1-t.x0<=0)continue;const i=t.data,o=!i.children&&1===i.rows.length,a=o?i.rows[0]:_j(i.rows,c),s=t.parent?t.parent.value??0:n,h={id:JSON.stringify(i.path),path:i.path,level:i.level,depth:t.depth,datum:a,i:o?l(a):void 0,value:n,share:m?n/m:0,parentShare:s?n/s:0,x0:t.x0,x1:t.x1,hasChildren:Boolean(t.children&&t.children.length)},u={...h,...e(h),parent:t.parent?g.get(t.parent.data):void 0};g.set(i,u),p.push(u)}return p}function vj(t){const e=[];for(let n=t;n;n=n.parent)e.push(n);return e}function wj(t){const e=be(t._history),n=t._filteredData??[],i=t.schema.groupBy;if(!e||void 0===e.groupDepth||!n.length)return{level:-1,path:[]};const o=Math.min(e.groupDepth,t._drawDepth-1);if(o<0)return{level:-1,path:[]};return{level:o,path:i.slice(0,o+1).map(t=>t(n[0],0))}}function Mj(t,e,n){const i=t.ctx[e];if(i&&i.data===t._filteredData)return i.base;const o=n();return t.ctx[e]={data:t._filteredData,base:o},o}function Sj(t,e){const n=new Set(e.map(t=>t.id));return t.filter(t=>!n.has(t.id))}function Cj(t,e){const n=t.find(t=>0===t.depth);if(!n)return;return e.filter(t=>t.depth>0&&(t=>t.path.length<=n.path.length&&t.path.every((t,e)=>t===n.path[e]))(t)).sort((t,e)=>e.path.length-t.path.length)[0]}function $j(t,e,n){const i=new Map,o=Cj(t,e);if(!o)return i;const r=new Set(t.map(t=>t.id));for(const t of e)r.has(t.id)||i.set(t.id,n(t,o));return i}function Aj(t,e){if(0===e.depth||e.datum._isAggregation)return!1;const n=t.schema.groupBy.length-1;return e.hasChildren||e.level===t._drawDepth&&e.level<n}function zj(t,e){return 0===e.depth?void 0!==be(t._history):Aj(t,e)}function Dj(t){t.hover(!1),t._tooltipClass?.data([]).render()}function Lj(t,e){return`${d.formatAbbreviate(100*e,t.schema.locale)}%`}function Fj(t,e,n){const i=t._tooltipClass,o=t.schema.tooltipConfig;if(void 0===o.title){const n=t._drawLabel(e.datum,e.i??0,e.level);jl(i.title(()=>n),Hl(t,t._lastScenePick))}if(void 0===o.footer){const n=!!zj(t,e)&&t.schema.translate(Aj(t,e)?"Click to Expand":"Click to Zoom Out");i.footer(n)}const r=function(t,e){if(e&&e.parent&&0!==e.parent.depth)return[t.schema.translate("Share of Parent"),Lj(t,e.parentShare)]}(t,e);r&&function(t,e){if(!Array.isArray(t)||1!==t.length||!Array.isArray(t[0]))return!1;const n=t[0];return n.length===e.length&&n.every((t,n)=>t===e[n])}(o.tbody,n)&&i.tbody([...o.tbody,r]),(void 0===o.title||void 0===o.footer||r)&&i.render()}function Nj(t,e,n){const{prefix:i}=n,o=t.schema.on,r=o.mouseenter,a=o["mousemove.shape"],s=e=>function(t,e,n){let i=e;for(;i&&i.__d3plus__&&i.data;)i=i.data;const o=t.ctx[`${n}Nodes`];return i&&o?o.get(i):void 0}(t,e,i),c=e=>{if(t.ctx[`${i}Hovered`]=e,1===t.schema.shapeConfig.hoverOpacity)return;const n=function(t){return new Set(vj(t).map(t=>t.datum))}(e);var o;o=t=>n.has(t),t.hover(o)};return{mouseenter:(e,n,i,o)=>{const a=s(e);a?c(a):r.call(t,e,n,i,o)},"mousemove.shape":(n,o,r,l)=>{a.call(t,n,o,r,l);const h=s(n);if(!h)return;t.ctx[`${i}Hovered`]!==h&&c(h);const u=Boolean(t.schema.on.click);t._select?.style("cursor",u||zj(t,h)?"pointer":"auto"),t._tooltipClass&&t.schema.tooltip(n,o)&&Fj(t,h,e)},"click.shape":(e,i,o,r)=>{r?.stopPropagation?.();const a=s(e);a&&(0===a.depth?function(t){const e=_e(t._history);if(!e)return;Dj(t);const n={depth:e.depth,filter:e.filter};t.config(n).render()}(t):Aj(t,a)&&function(t,e,n){var i;const o=t.schema.groupBy,r=wj(t),a=t.schema.filter,s=o.slice(0,e.level+1),c=e.path;Dj(t);const l={depth:t.schema.depth,filter:a,groupId:c[e.level],groupDepth:e.level};((i=t)._history??(i._history=[])).push(l),t.ctx[`${n.prefix}ZoomOrigin`]=n.origin(e);const h={filter:(t,e)=>(!a||a(t,e))&&s.every((n,i)=>n(t,e)===c[i])};if(void 0!==t.schema.depth){const n=e.level-r.level;h.depth=Math.min(o.length-1,t._drawDepth+n)}t.config(h).render()}(t,a,n))}}}function Bj(t,e){return pj(e,{aggs:t.schema.aggs,drawDepth:t._drawDepth,groupBy:t.schema.groupBy,threshold:t.schema.threshold,thresholdKey:t.schema.thresholdKey,label:(e,n)=>t._drawLabel(e,n)})}const Ej=(t,e)=>(e.value??0)-(t.value??0);function Rj(t,e){return xj(e)}function Pj(t){return"function"==typeof t?t:q(t)}function Tj(t,e){t.schema.thresholdKey=e}function Oj(t){return vE(t,"sum")}function Wj(t,e){const{prefix:n}=e;t.ctx[`${n}DefaultColor`]=t.schema.color,t.ctx[`${n}DefaultFill`]=t.schema.shapeConfig.fill,Object.assign(t.schema.on,Nj(t,(t.schema.tooltipConfig.tbody??[])[0]??[],e))}const Hj={step:.22,max:.6};function jj(t,e={}){const{step:n,max:i}={...Hj,...e};return t<=0?0:Math.max(0,Math.min(i,n*t))}function Ij(t,n,o,r){const a=function(t,e,n="Path"){const i=t.shapeConfig??{},o=i[n]??{};return!1!==t.shade&&!t.colorScale&&!t.colorOrdinal&&t.color===e.color&&i.fill===e.fill&&void 0===o.fill}(t,o,r),s=t.shadeConfig??{};return t=>{const o=Pm(n.fill,t.datum,t.i??0);if("string"==typeof o)return a?function(t,n){return t&&n>0&&i.color(t)?e.colorLighter(t,n):t}(o,jj(t.level,s)):o}}function Gj(t){const{width:e,height:n,orient:i}=t,o=Math.max(0,e),r=Math.max(0,n);return"vertical"===i?{depth:r,breadth:o}:{depth:o,breadth:r}}function qj(t,e,n){const i=Math.max(0,t),o=Math.max(0,e)+(n?1:0);if(o<1)return[[0,0]];const r=i/o,a=n?[]:[[0,0]];for(let t=0;t<o;t++)a.push([t*r,(t+1)*r]);return a}function Vj(t,e,n){const{breadth:i}=Gj(n),o=t.x0*i,r=t.x1*i,[a,s]=e;return"vertical"===n.orient?{x:o,y:a,width:r-o,height:s-a}:{x:a,y:o,width:s-a,height:r-o}}function Yj(t,e,n,i,o){const r=n.x1-n.x0||1,a=t=>Math.min(1,Math.max(0,(t-n.x0)/r)),s=e-n.depth,c=i[i.length-1]?.[1]??0,l=s<0?[0,0]:i[s]??[c,c];return Vj({x0:a(t.x0),x1:a(t.x1)},l,o)}function Kj(t,e){return"vertical"===e?{x:t.x+t.width/2,y:t.y,width:0,height:0}:{x:t.x,y:t.y+t.height/2,width:0,height:0}}function Uj(t,e,n){const i=new Map;for(const n of t){if(!e.has(n.id))continue;const t=n.parent;i.set(n.id,t?(i.get(t.id)??-1)+1:0)}const o=Math.max(0,...i.values())+1,r=new Map,s=new Map;for(const e of t){const t=i.get(e.id);void 0!==t&&(r.set(e.id,Kj(e,n)),s.set(e.id,{start:a.cubicInOut(t/o),end:a.cubicInOut((t+1)/o)}))}return{rects:r,windows:s}}function Xj(t){const{bands:e,frame:n,...i}=t;return kj({...i,breadth:1},t=>Vj(t,e[t.depth]??[0,0],n))}function Zj(t){return"vertical"===t?"vertical":"horizontal"}const Qj=({viz:t})=>{const{width:e,height:n}=kt(t),i={width:Math.max(0,e),height:Math.max(0,n),orient:Zj(t.schema.orient)};t.ctx.icicleWidth=i.width,t.ctx.icicleHeight=i.height,t.ctx.icicleNodes=new Map,t.ctx.icicleGhosts=[];const o=function(t){return Mj(t,"iciclePass",()=>{const e={laid:t.ctx.icicleLaid,bands:t.ctx.icicleBands,frame:t.ctx.icicleFrame,origin:t.ctx.icicleZoomOrigin};return t.ctx.icicleZoomOrigin=void 0,e})}(t),r=t._filteredData??[];if(!r.length)return t.ctx.icicleLaid=[],t.ctx.icicleBands=void 0,t.ctx.icicleFrame=i,t.ctx.icicleEnterRects=new Map,t.ctx.icicleEnterWindows=new Map,{shapeData:[]};const a=wj(t),s=t.schema.groupBy.slice(a.level+1,t._drawDepth+1),c=qj(Gj(i).depth,s.length,a.path.length>0),l=Xj({data:r,keys:s,firstLevel:a.level+1,focusPath:a.path,sum:t.schema.sum,sort:t.schema.sort,aggs:t.schema.aggs,bands:c,frame:i}),{laid:h,bands:u,origin:d}=o;t.ctx.icicleGhosts=d&&h?function(t,e,n,i,o){return Sj(t,e).map(t=>({id:t.id,datum:t.datum,i:t.i,level:t.level,rect:Yj(t,t.depth,n,i,o)}))}(h,l,d,c,i):[];const f=h&&u&&o.frame?function(t,e,n,i){return $j(t,e,(t,e)=>Yj(t,t.depth,{x0:e.x0,x1:e.x1,depth:e.depth},n,i))}(h,l,u,o.frame):new Map,m=Boolean(d)||Boolean(h&&Cj(h,l)),p=new Set((h??[]).map(t=>t.id)),g=m?{rects:f,windows:new Map}:Uj(l,new Set(l.filter(t=>!p.has(t.id)).map(t=>t.id)),i.orient);t.ctx.icicleEnterRects=g.rects,t.ctx.icicleEnterWindows=g.windows,t.ctx.icicleLaid=l,t.ctx.icicleBands=c,t.ctx.icicleFrame=i;const y=t.ctx.icicleNodes;for(const t of l)gl(t.datum,t.share),y.set(t.datum,t);return{shapeData:l}};function Jj(t,e,n={}){const{width:i,height:o}=t;if(!(e.words.length&&i>0&&o>0))return null;const r=VB(n),a=(t,n)=>QB(i=>function(t,e,n,i,o={}){const{padding:r,lineHeight:a,maxLines:s}=VB(o),c=n-2*r;if(c<=0)return!1;for(let n=1;n<=s;n++){if(n*a*e+2*r>i)return!1;if(ZB(t,e,c)<=n)return!0}return!1}(e,i,t,n,r),r.fontMin,r.fontMax),s=a(i,o),c=o>i?a(o,i):null,l=t.x+i/2,h=t.y+o/2;return null!==s&&(null===c||s>=c)?{orientation:"upright",x:l,y:h,width:i,height:o,rotate:0,fontSize:s}:null===c?null:{orientation:"rotated",x:l,y:h,width:o,height:i,rotate:-90,fontSize:c}}function tI(t,e){return t._drawLabel(e.datum,e.i??0,e.level)}function eI(t,e){return(t.ctx.icicleGhosts??[]).map(t=>({type:"rect",key:`icicle-${t.id}`,...t.rect,paint:{fill:e(t),opacity:1}}))}const nI={out:.06,in:.06};function iI(t){let e=t;for(;e&&e.__d3plus__&&e.data;)e=e.data;return e}const oI={prefix:"icicle",origin:function(t){return{x0:t.x0,x1:t.x1,depth:t.depth}}},rI={name:"Icicle",layoutStage:Qj,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=Hm(t,"Rect"),r=t.schema.sum,a=t.schema.locale,s=function(t,e){return Ij(t.schema,e,{color:t.ctx.icicleDefaultColor,fill:t.ctx.icicleDefaultFill},"Rect")}(t,o),c=t.ctx.icicleEnterRects??new Map,l=t.ctx.icicleEnterWindows??new Map,h=i.map(e=>{const n=e.i??0;return{type:"rect",key:`icicle-${e.id}`,x:e.x,y:e.y,width:e.width,height:e.height,enterRect:c.get(e.id),enterWindow:l.get(e.id),datum:e.datum,paint:{fill:Tm(o,e.datum,n,s(e)),stroke:Pm(o.stroke,e.datum,n),strokeWidth:Pm(o.strokeWidth,e.datum,n),opacity:Pm(o.opacity,e.datum,n)??1},aria:{label:`${tI(t,e)}, ${r(e.datum)}, ${d.formatAbbreviate(100*e.share,a)}%`}}}),u=tw(o,h,t=>[i[t].datum,i[t].i??0]),f=jm(t,"Rect")??{},m="number"==typeof f.fontMin?f.fontMin:8,p="number"==typeof f.fontMax?f.fontMax:24,g=function(t,e,n,i){const o=new Map;for(const r of e){const e=Jj(r,XB(tI(t,r),r.datum,n),i);e&&o.set(r,e)}return o}(t,i,f,{fontMin:m,fontMax:p}),y=i.filter(t=>g.has(t)),x=t=>g.get(t),b=t.ctx.icicleNodes,_=Kx({data:y,label:e=>tI(t,e),x:t=>x(t).x,y:t=>x(t).y,rotate:t=>x(t).rotate,aes:()=>({}),id:t=>`icicle-${t.id}`,datum:t=>t.datum,labelBounds:t=>{const{width:e,height:n}=x(t);return{x:-e/2,y:-n/2,width:e,height:n}},labelConfig:{fontMax:p,fontMin:m,split:YB,fontResize:!0,padding:2,textAnchor:"middle",verticalAlign:"middle",fontColor:n=>{const i=b.get(iI(n)),o=i?s(i):void 0;return e.colorContrast(o??"rgb(255, 255, 255)",t.schema.colorDefaults)},...f}});for(const t of _)t.fadeSwap=nI;const k=new Map(i.map(t=>[t.datum,l.get(t.id)]));for(const t of[...u,..._])t.datum&&(t.enterWindow=k.get(iI(t.datum)));return[...eI(t,s),...h,...u,..._]},thresholdFunction:Bj,setup:t=>Wj(t,oI),ctx:{},fields:[{key:"orient",default:"horizontal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...Hj})},{key:"sort",default:Ej,decorate:Rj},{key:"sum",default:I("value"),coerce:Pj,onSet:Tj},{key:"shapeConfig",merge:!0,factory:t=>({Rect:{labelConfig:{fontResize:!0}},stroke:()=>Os(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[_E(t,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:Oj},{key:"legend",coerce:"const",factory:kE}]};var aI=lx(rI);const sI="::stem";function cI(t,e,n){const i=(t.transform?.x??0)+t.x,o=(t.transform?.y??0)+t.y,r=i+t.width,a=o+t.height;if("x"===e){const e=i+t.width/2;return!f.finite(n)||Math.abs(o-n)<=Math.abs(a-n)?{x:e,y:o,x0:e,y0:a}:{x:e,y:a,x0:e,y0:o}}const s=o+t.height/2;return!f.finite(n)||Math.abs(r-n)<=Math.abs(i-n)?{x:r,y:s,x0:i,y0:s}:{x:i,y:s,x0:r,y0:s}}function lI(t){const e=[];for(const n of t)e.push({__d3plus__:!0,data:n,i:n.i,end:!1}),e.push({__d3plus__:!0,data:n,i:n.i,end:!0});return e}function hI(t,e){let n=0;for(const i of t){const t="function"==typeof e?e(i.data,i.i):e;f.finite(t)&&t>n&&(n=t)}return n}function uI(t){const e=this.schema.shapeConfig.Circle,n=hI(t.data,e?.r);return bw.call(this,{...t,buffer:n+2})}function dI(t){const e=t.datum,n={...t,datum:e?.data??t.datum,shapeType:"Circle"};return delete n.interactionPoints,n}function fI(t,e,n){const{viz:i}=t,o=t=>n.get(t.data),r=Rm("Line").renderMode("compute").config(t.shapeConfig).data(lI(e));i._wirePlotShapeEvents(r,"Circle",t.events);const a=Hm(i,"Line");return void 0===i.schema.shapeConfig.duration&&delete a.duration,r.config(a).config({curve:"linear",id:t=>`${t.data.id}${sI}`,label:!1,x:t=>t.end?o(t).x:o(t).x0,y:t=>t.end?o(t).y:o(t).y0}),Im(r).map(dI)}function mI(t,e,n){const i=Lt({...t.shapeConfig,x:t=>n.get(t).x,y:t=>n.get(t).y});return Nz.Circle({...t,shapeConfig:i,values:e},"Circle")}const pI=(t,e)=>{const n=Nz.Bar(t),i=function(t,e){const{viz:n}=t,i="y"===n.schema.discrete?"y":"x",o="x"===i?"y":"x",r="x"===i?t.y:t.x,a=new Map;for(const t of e){if("rect"!==t.type||"Bar"!==t.shapeType||`${t.key}`.endsWith("::hit"))continue;const e=t.datum;if(!e||a.has(e))continue;const n=void 0!==e[`${o}2`],s=n?e[`${o}2`]:e[o];a.set(e,cI(t,i,r(s,n?`${o}2`:void 0)))}return a}(t,n),o=t.values.filter(t=>i.has(t)),r=n.filter(t=>`${t.key}`.endsWith(zS));return[...fI(t,o,i),...r,...mI(t,o,i)]},gI=tL.fields.find(t=>"legend"===t.key),yI=t=>(e,n)=>{const i=t.schema.shapeConfig.fill;return"function"==typeof i?i(e,n):i},xI={name:"Lollipop",paintDriven:!0,setup:t=>{t._buffer={...t._buffer,Bar:uI},t._plotShapeEmitters={Bar:pI},t._plotCircleShapes=["Bar"],t._plotColumnHighlight=yN(t)},ctx:{},fields:[{key:"baseline",default:0},{key:"baselineBreak",default:!0},{key:"discrete",default:"x"},gI,{key:"shape",default:H("Bar"),coerce:"const"},{key:"legendConfig",merge:!0,default:{shape:"Circle"}},{key:"shapeConfig",merge:!0,factory:t=>({Bar:{label:!1},Circle:{label:!1,trail:!1},Line:{label:!1,stroke:yI(t)}})}]};var bI=lx(xI,ZD);function _I(t){const e=e=>{const n=e.map(e=>{const n=function(t){for(let e=0;e<t.length;e++){const n=(t[e].data||[]).find(e=>e.id===t.key);if(n)return n}}(e);return n&&n.data?t(n.data,n.i??0):`${e.key}`}),i=new Map;n.forEach((t,n)=>i.set(t,(i.get(t)??0)+function(t){let e=0;for(let n=0;n<t.length;n++)e+=Math.abs(+t[n][1]||0);return e}(e[n])));const o=Array.from(i.keys()).sort((t,e)=>i.get(e)-i.get(t)),r=new Map(o.map((t,e)=>[t,e]));return e.map((t,e)=>e).sort((t,e)=>r.get(n[t])-r.get(n[e])||t-e)};return e.__d3plusStackOrder=!0,e}function kI(t){return t._stackOffset===XS("expand")}function vI(t,e){return`${d.formatAbbreviate(100*t,e)}%`}function wI(t){return t.schema.stacked&&kI(t)?{[lg(t)]:{rounding:"none",tickFormat:e=>vI(e,t.schema.locale)}}:{}}function MI(t){return"y"===lg(t)?{x:"all",y:"outer"}:{x:"outer",y:"all"}}function SI(t){return t.schema.stacked&&kI(t)?{[lg(t)]:!0}:{}}const CI={name:"Marimekko",paintDriven:!0,defaults:{groupPadding:1},facet:{axes:MI,fixedAxes:SI},setup:t=>{t._stackOffset=XS("expand"),t._stackOrder=_I((e,n)=>t._ids(e,n).slice(0,t._drawDepth+1).join("_"));const e=t._preDraw.bind(t);t._preDraw=()=>{t._plotAxisDefaults=wI(t),e()}},ctx:{},fields:[{key:"barWidth",coerce:Up,factory:function(t){return Xp((e,n)=>{const i="y"===t.schema.discrete?t._x:t._y;return i?i(e,n??0):void 0},"Bar Total")}},{key:"barWidthShare",default:"opposite"},{key:"stacked",default:!0},{key:"tooltipShared",default:!1}]};var $I=lx(CI,eL);function AI(t){const e=this._filteredData,i=(this.schema.rowList||n.unique(e.map(this.schema.row))).sort(this.schema.rowSort),o=(this.schema.columnList||n.unique(e.map(this.schema.column))).sort(this.schema.columnSort);if(!i.length||!o.length)return{rowValues:[],columnValues:[],shapeData:[]};var r,a;return{rowValues:i,columnValues:o,shapeData:(r=i,a=o,[].concat(...r.map(t=>a.map(e=>[t,e])))).map(([t,n])=>{const i={__d3plusTooltip__:!0,__d3plus__:!0,column:n,row:t},o=e.findIndex((e,i)=>this.schema.row(e,i)===t&&this.schema.column(e,i)===n);return o>=0?(i.i=o,i.data=e[o]):i.data={row:t,column:n},i})}}const zI=({viz:t})=>{const e=AI.bind(t)(t._filteredData),{rowValues:n,columnValues:i,shapeData:o}=e;if(!n.length||!i.length)return{shapeData:[]};const{width:r,height:a}=kt(t),s=r/i.length<120||void 0;t._padding={top:0,right:0,bottom:0,left:0};const c=t.ctx.rowAxis,l=t.ctx.columnAxis,h=t.schema.rowConfig,u=t.schema.columnConfig;c.domain(n).height(a-t._padding.bottom-t._padding.top).maxSize(r/4).width(r).config(h).measure();const d=c.outerBounds().width;t._padding.left+=d,l.domain(i).range([t._margin.left+t._padding.left,t._margin.left+r-t._padding.right]).height(a).maxSize(a/4).width(r).labelRotation(s).config(u).measure();const f=l.outerBounds().height;t._padding.top+=f,c.renderMode("compute").select(void 0).height(a-t._padding.bottom).maxSize(d).range([f+l.padding(),void 0]).render();const m=c.toScene();var p;m&&((p=t)._chartScene||(p._chartScene=[])).push({type:"group",key:"matrix-row-axis",transform:{x:t._margin.left,y:0},children:m.children??[]});l.renderMode("compute").select(void 0).range([t._margin.left+t._padding.left+c.padding(),t._margin.left+r-t._padding.right]).maxSize(f).render();const g=l.toScene();var y;g&&((y=t)._chartScene||(y._chartScene=[])).push({type:"group",key:"matrix-column-axis",transform:{x:0,y:0},children:g.children??[]});const x=c._getPosition.bind(c),b=l._getPosition.bind(l),_=n.length>1?x(n[1])-x(n[0]):c.height(),k=i.length>1?b(i[1])-b(i[0]):l.width();return t.ctx.columnScale=b,t.ctx.rowScale=x,t.ctx.cellWidth=k,t.ctx.cellHeight=_,{shapeData:o}},DI={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},LI=(t,e)=>`${t}`.localeCompare(`${e}`),FI={name:"Matrix",layoutStage:zI,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=t.ctx.columnScale,o=t.ctx.rowScale,r=t.ctx.cellWidth,a=t.ctx.cellHeight,s=t.schema.cellPadding??0,c=Hm(t,"Rect"),l=t.schema.colorScale,h=n.map((t,e)=>{const n=Pm(c.fill,t,e),h=Pm(c.stroke,t,e),u=Pm(c.strokeWidth,t,e),d=r-s,f=a-s,m=i(t.column)+r/2-d/2,p=o(t.row)+a/2-f/2,g=l?`, ${l(t.data??t,e)}`:"";return{type:"rect",key:`matrix-${e}`,x:m,y:p,width:d,height:f,datum:t,paint:{fill:Tm(c,t,e,n),stroke:h,strokeWidth:u},aria:{label:`${t.row}, ${t.column}${g}.`}}});return[...h,...tw(c,h,t=>[n[t],t])]},chartTransform:t=>({x:0,y:t._margin.top}),setup:t=>{const e=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(n,i,o,r)=>{if(e(n,i,o,r),Ls(o)||Ls(n))return;const a=Jt.bind(t)("row",n,i),s=Jt.bind(t)("column",n,i),c=t.schema.colorScale;t.hover((e,n)=>!(Jt.bind(t)("row",e,n)!==a&&Jt.bind(t)("column",e,n)!==s||"function"==typeof c&&"number"!=typeof c(e,n)))}},facet:{aspect:1},ctx:{rowAxis:new zo,columnAxis:new zo},fields:[{key:"cellPadding",default:2},{key:"column",default:I("column"),coerce:t=>"function"==typeof t?t:q(t)},{key:"row",default:I("row"),coerce:t=>"function"==typeof t?t:q(t)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:LI},{key:"rowSort",default:LI},{key:"rowConfig",merge:!0,default:{orient:"left",...DI}},{key:"columnConfig",merge:!0,default:{orient:"top",...DI}},{key:"label",coerce:"const",factory:t=>(e,n)=>`${Jt.bind(t)("row",e,n)} / ${Jt.bind(t)("column",e,n)}`}]};var NI=lx(FI);const BI=t=>{const e="number"==typeof t?t:NaN;return Number.isFinite(e)&&e>=0?e:void 0};function EI(t,e,n){const i=BI(t)??1,o=BI(e);if(void 0!==o)return[Math.min(i,o),o];const r=Number.isFinite(n)?.5*Math.max(0,n):0;return[i,Math.max(i,r)]}function RI(t,e){if(!t.schema.linkBundle)return;const n=e.filter(t=>t.source&&t.target&&!t.loop&&!Rk(t)&&Number.isFinite(t.source.x)&&Number.isFinite(t.source.y)&&Number.isFinite(t.target.x)&&Number.isFinite(t.target.y));if(!n.length)return;const i=oO(t,n.map(t=>[[t.source.x,t.source.y],[t.target.x,t.target.y]]));n.forEach((t,e)=>{t.points=i[e]})}function PI(t,e=0,n=0){return{source:K_(t,e+1),target:K_([...t].reverse(),n+1)}}function TI(t,e,n){const i=function(t,e,n,i){return bk({arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:"number"==typeof i?i:void 0,datum:e,i:n})}(t,n.datum,n.i,n.strokeWidth),o=PI(e.points,e.source?.r??0,e.target?.r??0),{d:r,source:a,target:s}=Fk(e.points,i,o);return{d:r,arrows:Ek({ends:{source:a,target:s},size:i.size,datum:n.datum,keyPrefix:n.keyPrefix,fill:n.fill})}}function OI(t){const{source:e,target:n}=PI(t.points,(t.source?.r??0)-1,(t.target?.r??0)-1);return I_(t.points,e,n)}function WI(t){return V_(OI(t))}function HI(t){const e=[];let n=!1;for(const i of t){const t=[i.x??0,i.y??0];Number.isFinite(t[0])&&Number.isFinite(t[1])?e.push({node:i,p:t}):Number.isNaN(t[0])||Number.isNaN(t[1])||(n=!0)}e.sort((t,e)=>t.p[0]-e.p[0]);let i=1/0,o=!1;for(let t=0;t<e.length;t++){const n=e[t];for(let r=t+1;r<e.length;r++){const t=e[r];if(f.pointDistanceSquared([n.p[0],0],[t.p[0],0])>i)break;if(n.node===t.node)continue;const a=f.pointDistanceSquared(n.p,t.p);(!o||a<i)&&(i=a,o=!0)}}return o?Math.sqrt(i):n?function(t){const e=[];for(const n of t)for(const i of t)n!==i&&e.push(f.pointDistance([n.x??0,n.y??0],[i.x??0,i.y??0]));return h.min(e)}(t):void 0}const jI=t=>iv(t),II=ov;function GI(t,e,n){if(!e.some(t=>void 0===t.fx||void 0===t.fy))return;const i=n.filter(t=>t.source&&t.target&&!Rk(t)),o=`${e.map(t=>t.id).join("\0")}|${i.map(t=>`${t.source.id}>${t.target.id}:${t.size}`).join("\0")}`,r=t.ctx.networkForceCache;r&&r.key===o?e.forEach((t,e)=>{t.fx=r.positions[e][0],t.fy=r.positions[e][1]}):(!function(t,e){const n=E.scaleLinear().domain(h.extent(e,t=>t.size)).range([.1,.5]),i=F.forceSimulation().force("link",F.forceLink(e).id(t=>t.id).distance(1).strength(t=>n(t.size)).iterations(4)).force("charge",F.forceManyBody().strength(-1)).stop(),o=1-Math.pow(.001,.01);i.velocityDecay(0),i.alphaMin(.001),i.alphaDecay(o),i.alphaDecay(0),i.nodes(t),i.tick(100).stop();const r=t.map(t=>[t.vx??0,t.vy??0]);let a=0,s=0,c=0;if(2===r.length)a=100;else if(r.length>2){const t=N.polygonHull(r)||[],e=f.largestRect(t,{verbose:!0});a=e.angle,s=e.cx,c=e.cy}t.forEach(t=>{const e=f.pointRotate([t.vx??0,t.vy??0],Math.PI/180*a*-1,[s,c]);t.fx=e[0],t.fy=e[1]})}(e,i),t.ctx.networkForceCache={key:o,positions:e.map(t=>[t.fx,t.fy])})}function qI(t,e,n){const i=h.extent(e,t=>t.size);return i[0]===i[1]?null:E[`scale${t.schema.linkSizeScale.charAt(0).toUpperCase()}${t.schema.linkSizeScale.slice(1)}`]().domain(i).range(EI(t.schema.linkSizeMin,t.schema.linkSizeMax,n))}function VI(t,e,n,i,o=[]){const r=h.extent(e.map(t=>t.fx)),a=h.extent(e.map(t=>t.fy)),s=E.scaleLinear().domain(r).range([0,n]),c=E.scaleLinear().domain(a).range([0,i]),l=(r[1]-r[0])/(a[1]-a[0])||1,u=n/i;if(l>u){const t=i*u/l;c.range([(i-t)/2,i-(i-t)/2])}else{const t=n*l/u;s.range([(n-t)/2,n-(n-t)/2])}e.forEach(t=>{t.x=s(t.fx),t.y=c(t.fy)});const d=h.extent(e.map(t=>t.r));let f=t.schema.sizeMax||h.max([1,HI(e)/2]);const m=E[`scale${t.schema.sizeScale.charAt(0).toUpperCase()}${t.schema.sizeScale.slice(1)}`]().domain(d).range([d[0]===d[1]?f:h.min([f/2,t.schema.sizeMin]),f]),p=s.domain(),g=c.domain(),y=p[1]-p[0],x=g[1]-g[0];for(const[[n,i],[r,a]]of function(t,e,n,i){const o=new Map(e.map(t=>[t.id,{id:t.id,x:t.x??0,y:t.y??0,r:i(t.r)}])),r=[...o.values()].map(t=>[[t.x-t.r,t.y-t.r],[t.x+t.r,t.y+t.r]]),a=qI(t,n,i.range()[0]),s=YI(e,n,t=>o.get(t.id),t=>a?a(t.size):t.size);for(const{box:t}of s.values())r.push(t);return r}(t,e,o,m))p[0]=Math.min(p[0],s.invert(n-3)),p[1]=Math.max(p[1],s.invert(r+3)),g[0]=Math.min(g[0],c.invert(i-3)),g[1]=Math.max(g[1],c.invert(a+3));const b=p[1]-p[0],_=g[1]-g[0];f*=h.min([y/b,x/_]),m.range([d[0]===d[1]?f:h.min([f/2,t.schema.sizeMin]),f]),s.domain(p),c.domain(g);const k=(l>u?n:i)/2;return e.forEach(t=>{t.x=s(t.fx),t.fx=t.x,t.y=c(t.fy),t.fy=t.y,t.r=m(t.r)||k,t.width=2*t.r,t.height=2*t.r}),m}function YI(t,e,n,i){const o=e.filter(t=>t.datum&&Rk(t));if(!o.length)return new Map;const r=new Map;for(const t of e)if(t.source&&t.target&&!Rk(t))for(const[e,i]of[[t.source,t.target],[t.target,t.source]]){r.has(e.id)||r.set(e.id,[]);const t=n(i);r.get(e.id).push([t.x,t.y])}const a=t.map(n),s=[a.reduce((t,e)=>t+e.x,0)/a.length,a.reduce((t,e)=>t+e.y,0)/a.length];return Zk(o,{node:t=>n(t.source),angle:t=>Uk([t.x,t.y],r.get(t.id)??[],Xk([t.x,t.y],s)),reach:t=>Ok(n(t.source).r),strokeWidth:i})}const KI=({viz:t})=>{const e=t,{width:n,height:i}=kt(e);Array.isArray(e._filteredData)||(e._filteredData=[]),Array.isArray(e.schema.nodes)||(e.schema.nodes=[]),Array.isArray(e.schema.links)||(e.schema.links=[]);const o=jI(e),r=II(e,o);Rb(e,r.flatMap(t=>t.datum?[t.datum]:[]),o.map(ev)),GI(e,o,r);const a=VI(e,o,n,i,r);e._sizeLegendFinal=e._size?a:null,function(t,e,n){const i=qI(t,e,n.range()[0]);i&&e.forEach(t=>{t.size=i(t.size)})}(e,r,a),function(t,e){const n=YI(t,e,t=>({id:t.id,x:t.x??NaN,y:t.y??NaN,r:t.r??0}),t=>t.size);for(const[t,e]of n)t.loop=e}(o,r),RI(e,r);const s=Hm(e,"Path",e.schema.shapeConfig,"edge");delete s.on;const c={label:t=>!!(o.length<=e.schema.dataCutoff||e._hover&&e._hover(t)||e._active&&e._active(t))&&e._drawLabel(t.data||t.node,t.i)},l=Array.from(h.groups(o,t=>t.shape));return e.ctx.networkCtx={links:r,linkConfig:s,linkD:t=>t.loop?t.loop.d:t.points?j_(t.points):`M${t.source.x},${t.source.y} ${t.target.x},${t.target.y}`,nodeGroups:l,nodeShapeConfig:c},{shapeData:o}};function UI(t,e){let n=!1;for(const i of t)e<i&&(n=!n);return n}function XI(t){const e=new Map,n=n=>{let i=e.get(n);return i||e.set(n,i=(e=>{const n=[],i=t.length;let[o,r]=t[i-1];for(let a=0;a<i;++a){const[i,s]=t[a];s>e!=r>e&&n.push((o-i)*(e-s)/(r-s)+i),o=i,r=s}return n})(n)),i};return{contains:([t,e])=>UI(n(e),t),row:n}}const ZI={fontMax:16,fontMin:10,padding:4};function QI(t){const e=(t.schema.clusterConfig??{}).labelConfig;if(!1===e)return null;const{fontMax:n,fontMin:i,padding:o,...r}=e??{},a=(t,e)=>"number"==typeof t&&Number.isFinite(t)&&t>=0?t:e,s=a(n,ZI.fontMax);return{fontMax:s,fontMin:Math.min(s,a(i,ZI.fontMin)),padding:a(o,ZI.padding),text:r}}function JI(t,e){const n=e.x-Math.max(t.x,Math.min(e.x,t.x+t.width)),i=e.y-Math.max(t.y,Math.min(e.y,t.y+t.height));return n*n+i*i<e.r*e.r}function tG(t,e){return t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height}function eG(){const t=new Map;let e=0;return{get size(){return e},get:(e,n)=>t.get(e)?.get(n),add(n,i,o){let r=t.get(n);r||t.set(n,r=new Map);const a=r.get(i);a?a.push(o):(r.set(i,[o]),e++)}}}function nG(t,e,n=32){const i=eG(),o=t=>{const e=(t=>"r"in t?{x:t.x-t.r,y:t.y-t.r,width:2*t.r,height:2*t.r}:t)(t);[e.x,e.y,e.width,e.height].every(Number.isFinite)&&((t,e)=>{for(let i=Math.floor(t.x/n);i<=Math.floor((t.x+t.width)/n);i++)for(let o=Math.floor(t.y/n);o<=Math.floor((t.y+t.height)/n);o++)e(i,o)})(e,(e,n)=>i.add(e,n,t))};t.forEach(o),e.forEach(o);return{hits:t=>{const e=Math.floor((t.x+t.width)/n),o=Math.floor((t.y+t.height)/n);for(let r=Math.floor(t.x/n);r<=e;r++)for(let e=Math.floor(t.y/n);e<=o;e++)for(const n of i.get(r,e)??[])if("r"in n?JI(t,n):tG(t,n))return!0;return!1},add:o}}function iG(t,e=32){const n=eG();let i=1/0,o=-1/0,r=1/0,a=-1/0;for(const s of t){if(!Number.isFinite(s.x)||!Number.isFinite(s.y))continue;const t=Math.floor(s.x/e),c=Math.floor(s.y/e);[i,o,r,a]=[Math.min(i,t),Math.max(o,t),Math.min(r,c),Math.max(a,c)],n.add(t,c,s)}return(t,s)=>{if(!n.size)return;const c=Math.floor(t/e),l=Math.floor(s/e),h=Math.max(Math.abs(c-i),Math.abs(c-o),Math.abs(l-r),Math.abs(l-a));let u,d=1/0;for(let i=0;i<=h&&!(u&&(i-1)*e>Math.sqrt(d));i++)for(let e=c-i;e<=c+i;e++)for(let o=l-i;o<=l+i;o++)if(Math.max(Math.abs(e-c),Math.abs(o-l))===i)for(const i of n.get(e,o)??[]){const e=(i.x-t)**2+(i.y-s)**2;e<d&&([u,d]=[i,e])}return u}}const oG=new WeakMap;function rG(t){let e=oG.get(t);return e||oG.set(t,e=XI(t)),e}const aG=new WeakMap;function sG(t,e,n,i,o=0,r=4){const{width:a,height:s}=e,{row:c}=rG(t),{spots:l,rows:h}=function(t,e,n){const i=`${e}|${n}`,o=aG.get(t);if(o?.key===i)return o;const{contains:r}=rG(t),a=t.map(t=>t[0]),s=t.map(t=>t[1]),[c,l]=[Math.min(...a),Math.max(...a)],[h,u]=[Math.min(...s),Math.max(...s)],d=Math.min(120,Math.ceil((l-c)/n)+1),f=Math.min(120,Math.ceil((u-h)/n)+1),m=[],p=[];for(let t=0;t<d;t++)for(let e=0;e<f;e++){const n=[c+(d>1?(l-c)*t/(d-1):0),h+(f>1?(u-h)*e/(f-1):0)];r(n)&&(m.push(n),p.push(e))}const g=m.map(([t,n])=>(t-e[0])**2+(n-e[1])**2),y=m.map((t,e)=>e).sort((t,e)=>g[t]-g[e]),x={key:i,spots:y.map(t=>m[t]),rows:y.map(t=>p[t])};return aG.set(t,x),x}(t,n,r),u=[],d=[];for(let t=0;t<l.length;t++){var f,m,p,g;const[e,n]=l[t],r=e-a/2,y=n-s/2,x=(f=u)[m=h[t]]??(f[m]=c(y));if(!UI(x,r)||!UI(x,r+a))continue;const b=(p=d)[g=h[t]]??(p[g]=c(y+s));if(!UI(b,r+a)||!UI(b,r))continue;if(!i({x:r-o,y:y-o,width:a+2*o,height:s+2*o}))return{x:r,y:y,width:a,height:s}}return null}function cG(t,e){const n=t.flatMap(({x:t,y:n,r:i})=>{const o=i+e;return[[t-o,n],[t+o,n],[t,n-o],[t,n+o],[t-o*Math.SQRT1_2,n-o*Math.SQRT1_2],[t+o*Math.SQRT1_2,n-o*Math.SQRT1_2],[t+o*Math.SQRT1_2,n+o*Math.SQRT1_2],[t-o*Math.SQRT1_2,n+o*Math.SQRT1_2]]}),i=N.polygonHull(n);return!i||t.length<3?null:{hull:i,target:[t.reduce((t,e)=>t+e.x,0)/t.length,t.reduce((t,e)=>t+e.y,0)/t.length]}}function lG(t,e,n){const i=t.ctx.clusterState,o=QI(t);if(!(i?.active&&o&&o.fontMax>0))return[];const r=e.filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y)),a=new Map(r.map(t=>[t.id,t])),s=function(t,e){const n=t=>"Rect"===t.shape;return nG(t.filter(t=>!n(t)).map(t=>({x:t.x,y:t.y,r:t.r})),t.filter(n).map(t=>{const e=t.width??2*t.r,n=t.height??2*t.r;return{x:t.x-e/2,y:t.y-n/2,width:e,height:n}}).concat(e))}(r,n),c=iG(r),{padding:l,fontMax:h,fontMin:u}=o,d=t=>({family:o.text.fontFamily,size:t,weight:o.text.fontWeight??600}),f=[];for(const t of i.clusters){const e=new Set(t.ids),n=cG(t.ids.flatMap(t=>a.get(t)??[]),h);if(!n)continue;const i=t=>[t.x+l,t.x+t.width/2,t.x+t.width-l].every(n=>e.has(c(n,t.y+t.height/2)?.id??"")),o=t=>s.hits(t)||!i(t);for(let e=h;e>=u;e--){const i=sG(n.hull,k_(t.name,d(e)),n.target,o,l);if(!i)continue;const r=t.name;f.push({key:`network-cluster-label-${t.index}`,text:r,fontSize:e,box:i}),s.add({x:i.x-l,y:i.y-l,width:i.width+2*l,height:i.height+2*l});break}}return f}function hG(t,e){const n=QI(t);if(!e.length||!n)return[];const i=new Map(e.map(t=>[`${t.key}_0`,t])),o=t=>i.get(`${t.id}`)?.fontSize??10,r=Kx({data:e,label:t=>t.text,labelBounds:t=>{const{width:e,height:n}=t.box;return{x:-e/2,y:-n/2,width:e,height:n}},x:t=>{const{box:e}=t;return e.x+e.width/2},y:t=>{const{box:e}=t;return e.y+e.height/2},aes:H({}),rotate:H(0),id:t=>t.key,labelConfig:{fontColor:()=>Ws(t),fontWeight:600,...n.text,fontResize:!1,fontSize:o,lineHeight:t=>1.2*o(t),padding:0,pointerEvents:"none",textAnchor:"middle",verticalAlign:"middle"}}).map(t=>{const{datum:e,...n}=t;return{...n,interactive:!1}}),a=Math.max(...e.map(t=>t.fontSize));return Gp(r,Os(t),Math.max(2,a/4))}function uG(t,e,n){const i=lG(t,e,[...n.values()].flatMap(t=>"outside"===t.position&&t.box?[t.box]:[]));return{scene:hG(t,i),boxes:i.map(t=>t.box)}}function dG(t,e,n,i,o,r,a){const s={arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:o,datum:n,i:r,keyPrefix:a,fill:"string"==typeof i?i:void 0};return e.loop?Jk({...s,loop:e.loop}):e.points?TI(t,{...e,points:e.points},s).arrows:Sk({...s,source:e.source,target:e.target})}function fG(t,e,n,i,o,r){const a=bk({arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:"number"==typeof o?o:void 0,datum:n,i:i});return a.source||a.target?e.loop?qk(e.loop,a):e.points?TI(t,{...e,points:e.points},{datum:n,i:i,strokeWidth:o,keyPrefix:""}).d:Mk(e.source,e.target,a):r}const mG=(t,e)=>`network-link-${t.source.id??""}-${t.target.id??""}-${e}`;function pG(t,e,n,i,o){const r=`network-${t}-${e.id}`;if("Circle"===t)return{type:"circle",key:r,cx:e.x,cy:e.y,r:e.r,...i};if("Rect"===t){const t=Number(e.width??Pm(n.width,i.datum,o)??0),a=Number(e.height??Pm(n.height,i.datum,o)??0);return{type:"rect",key:r,x:e.x-t/2,y:e.y-a/2,width:t,height:a,...i}}return null}function gG(t,n,i,o,r,a){const s=n.nodeShapeConfig.label;if(!s)return[];const c="Circle"===i,l=r.labelConfig??{fontResize:!0},h=jm(t,i),u=h.fontMin??l.fontMin,d=Kx({data:o,label:(t,e)=>!!(t=>{const e=a.get(t);return!e||"inside"===e.position})(t)&&s(t,e),x:t=>t.x,y:t=>t.y,aes:t=>{const e=t;return c?{r:e.r,width:2*e.r,height:2*e.r}:{width:e.width??0,height:e.height??0}},rotate:H(0),id:t=>`network-label-${t.id}`,labelBounds:(t,e,n)=>{const i=n;if(c){const t=i.r??0;return{width:1.5*t,height:1.5*t,x:.75*-t,y:.75*-t}}const o=i.width??0,r=i.height??0;return{width:o,height:r,x:-o/2,y:-r/2}},labelConfig:{...l,fontColor:n=>{const i=n.data??n,o=Pm(r.fill,i.data??i,i.i??0);return e.colorContrast("string"==typeof o?o:"rgb(255, 255, 255)",t.schema.colorDefaults)},...h,fontMin:(e,n)=>A_(t,a.get(e.data),Pm(u,e,n)??Yx.fontMin)}});if(!c)return d;const f=$_(new Map(o.filter(t=>a.has(t)).map(t=>[t,a.get(t)])),t=>({id:`network-label-${t.id}`,datum:t}));return[...d,...C_(t,f)]}const yG=nv,xG=t=>t.ctx.networkCtx?.links??[];function bG(t,e){const n=yW(t,e),i=xG(t).find(t=>t.datum===e);return n&&i?.loop?Qk(n,i.loop.box):n&&i?.points?Qk(n,Y_(i.points)):n}function _G(t,e){t.schema.on["click.shape"]=(n,i,o,r)=>{if(t._tooltipClass.data([]).render(),Nb(n))kW(t,n,{nodeKey:(e,n)=>`${t._ids(e,n)[t._drawDepth]}`,box:bG(t,n)});else if(t._drawDepth>=t.schema.groupBy.length-1){const a=yG(t,n,i);if(t._focus&&t._focus===a)e.active(!1),t.schema.on.mouseenter.bind(t)(n,i,o,r),t._focus=void 0,t._zoomToBounds(null);else{e.hover(!1);const n=t.ctx.linkLookup[a]??[],i=t.ctx.nodeLookup[a];if(!i)return;const o=[a],r=[i.x-i.r,i.x+i.r],s=[i.y-i.r,i.y+i.r];n.forEach(t=>{o.push(t.id),t.x-t.r<r[0]&&(r[0]=t.x-t.r),t.x+t.r>r[1]&&(r[1]=t.x+t.r),t.y-t.r<s[0]&&(s[0]=t.y-t.r),t.y+t.r>s[1]&&(s[1]=t.y+t.r)}),function(t,e,n,i){for(const o of xG(t)){if(!o.loop||o.source?.id!==e)continue;const[[t,r],[a,s]]=o.loop.box;n[0]=Math.min(n[0],t),n[1]=Math.max(n[1],a),i[0]=Math.min(i[0],r),i[1]=Math.max(i[1],s)}}(t,a,r,s),e.active((e,n)=>{const i=Fb(e);return i?i.source.id===a||i.target.id===a:o.includes(yG(t,e,n))}),t._focus=a,rv(t,r,s)}}}}function kG(t,e){vW(t),_G(t,e),function(t,e){t.schema.on["click.legend"]=(n,i,o,r)=>{const a=t._ids(n,i),s=a[a.length-1],c=t._id(n,i);if(t._drawDepth>=t.schema.groupBy.length-1){if(t._focus&&t._focus===c)e.active(!1),t._focus=void 0,t._zoomToBounds(null);else{e.hover(!1);const n=(Array.isArray(c)?c:[c]).map(e=>t.ctx.nodeLookup[String(e)]),i=[`${s}`],o=[n[0].x-n[0].r,n[0].x+n[0].r],r=[n[0].y-n[0].r,n[0].y+n[0].r];n.forEach(t=>{i.push(t.id),t.x-t.r<o[0]&&(o[0]=t.x-t.r),t.x+t.r>o[1]&&(o[1]=t.x+t.r),t.y-t.r<r[0]&&(r[0]=t.y-t.r),t.y+t.r>r[1]&&(r[1]=t.y+t.r)}),e.active((e,n)=>{const o=Fb(e);if(o)return i.includes(o.source.id)&&i.includes(o.target.id);const r=t._ids(e,n);return i.includes(`${r[r.length-1]}`)}),t._focus=c,rv(t,o,r)}t.schema.on.mouseenter.bind(t)(n,i,o,r),t.schema.on["mousemove.legend"].bind(t)(n,i,o,r)}}}(t,e),function(t,e){t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{n(i,o,r,a);const s=(e,n)=>`${t._ids(e,n)[t._drawDepth]}`;if(Nb(i))return void e.hover(Yb(t,i,s));const c=yG(t,i,o),l=t.ctx.linkLookup[c]??[],h=t.ctx.nodeLookup[c];if(!h)return;const u=[c],d=[h.x-h.r,h.x+h.r],f=[h.y-h.r,h.y+h.r];l.forEach(t=>{u.push(t.id),t.x-t.r<d[0]&&(d[0]=t.x-t.r),t.x+t.r>d[1]&&(d[1]=t.x+t.r),t.y-t.r<f[0]&&(f[0]=t.y-t.r),t.y+t.r>f[1]&&(f[1]=t.y+t.r)}),e.hover((t,e)=>{const n=Fb(t);return n?n.source.id===c||n.target.id===c:u.includes(s(t,e))})}}(t,e)}const vG={name:"Network",layoutStage:KI,sizeLegendScale:(t,{width:e,height:n})=>function(t,e,n){if(!t._size)return null;if(!Array.isArray(t._filteredData)||!Array.isArray(t.schema.nodes)||!Array.isArray(t.schema.links))return null;const i=jI(t);if(!i.length)return null;const{nodeLookup:o,linkLookup:r}=t.ctx,a=II(t,i);return t.ctx.nodeLookup=o,t.ctx.linkLookup=r,GI(t,i,a),VI(t,i,e,n,a)}(t,e,n),emit:({viz:t})=>{const e=t.ctx.networkCtx;if(!e)return[];const n=[],i=e.nodeGroups?.length?function(t,e){const n=e.nodeShapeConfig.label,i=[];for(const[o,r]of e.nodeGroups){const a="Circle"===o,s={...Hm(t,o),...e.nodeShapeConfig}.labelConfig??{};r.forEach((t,e)=>{const o=t.data??t,r=t.i??e,c=a?t.r:Math.hypot(t.width??0,t.height??0)/2||t.r;i.push({key:t,datum:o,index:r,x:t.x,y:t.y,r:c,text:a&&n?n(t,e):void 0,inside:{width:1.5*t.r,height:1.5*t.r,padding:Pm(s.padding,o,r)??Yx.padding,font:{family:Pm(s.fontFamily,o,r),weight:Pm(s.fontWeight,o,r)}}})})}const{width:o,height:r}=kt(t);return M_(t,i,{x:0,y:0,width:o,height:r})}(t,e):new Map;e.links&&e.links.length&&n.push(...function(t,e){const n=[],i=i_(t);for(const o of e.links){const r=o.datum;if(!r)continue;const a=Fb(r).index,s=Om(e.linkConfig,r,a);"number"==typeof o.size&&(s.strokeWidth=o.size);const c=i(r,o);c&&(s.stroke=c);const l=o.source.id??"",h=o.target.id??"",u=mG(o,a),d=e.linkD(o);n.push({type:"path",key:u,d:fG(t,o,r,a,s.strokeWidth,d),datum:r,index:a,paint:s,aria:{label:Vb(t,r)}}),n.push(Jb(u,d,r,s.strokeWidth)),n.push(...dG(t,o,r,s.stroke,s.strokeWidth,a,`network-arrow-${l}-${h}-${a}`))}return n}(t,e));const o=uG(t,(e.nodeGroups??[]).flatMap(([,t])=>t),i);if(n.push(...o.scene),n.push(...function(t,e,n,i=[]){if(!e.links?.length)return[];const o=[...n.values()].flatMap(t=>"outside"===t.position?[t.box]:[]),r=e.nodeGroups.flatMap(([,t])=>t);return sk(t,e.links.flatMap(t=>{if(!t.datum)return[];const e=Fb(t.datum).index;return[{key:mG(t,e),link:t,i:e,anchor:t.loop?t.loop.apex:t.points?WI({...t,points:t.points}):t.source&&t.target?z_([t.source.x,t.source.y],[t.target.x,t.target.y],t.source.r??0,t.target.r??0):null,path:t.loop?X_(t.loop.d):t.points?OI({...t,points:t.points}):null,priority:t.size}]}),{circles:r.filter(t=>"Rect"!==t.shape).map(t=>({x:t.x,y:t.y,r:t.r})),boxes:r.filter(t=>"Rect"===t.shape).map(t=>{const e=t.width??2*t.r,n=t.height??2*t.r;return{x:t.x-e/2,y:t.y-n/2,width:e,height:n}}).concat(o,i)})}(t,e,i,o.boxes)),e.nodeGroups&&e.nodeGroups.length)for(const[o,r]of e.nodeGroups){if(!r.length)continue;const a={...Hm(t,o),...e.nodeShapeConfig},s=[];for(let e=0;e<r.length;e++){const i=r[e],c=i.data??i,l=Om(a,c,i.i??e);void 0===l.vectorEffect&&(l.vectorEffect="non-scaling-stroke");const h=t._size,u=h?`, ${h(c,i.i??e)}`:"",d=pG(o,i,a,{datum:c,paint:l,aria:{label:`${Wm(t,i,e)}${u}.`}},i.i??e);if(!d)continue;n.push(d);const f=Jv(a,d,c,i.i??e);f&&s.push(f)}n.push(...s),n.push(...gG(t,e,o,r,a,i))}return n},insetRegion:Cp,setup:t=>{const e=t;kG(t,e),function(t){tv(t),t.x=function(t){if(!arguments.length)return this._x;if("function"==typeof t)this._x=t;else{const e=t;this._x=q(e),this.schema.aggs[e]||(this.schema.aggs[e]=h.mean)}return this},t.y=function(t){if(!arguments.length)return this._y;if("function"==typeof t)this._y=t;else{const e=t;this._y=q(e),this.schema.aggs[e]||(this.schema.aggs[e]=h.mean)}return this}}(e),xv(t),t._x=I("x"),t._y=I("y");const n=e._draw.bind(t);e._draw=function(e){const i=n(e),{width:o,height:r}=kt(t);return tc(t,{kind:"network",width:o,height:r,duration:Zt(t)}),i}},facet:{aspect:1},pointMark:(t,e)=>ih(e)||Pk(e),ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"cluster",default:!0,coerce:t=>!1!==t},{key:"clusterConfig",merge:!0,default:{}},...lk(),...uk(),...pn("links","nodes"),{key:"links",default:[]},{key:"linkSize",default:H(1),coerce:t=>"function"==typeof t?t:H(t)},hk(),{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[I("id")]},{key:"nodeTooltipLinks"},{key:"tooltipConfig",merge:!0,factory:t=>Qb(t)},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:H("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t._size,o=i?`, ${i(e,n)}`:"";return`${t._drawLabel(e,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:()=>J(t._theme,t=>t.link,"#adb5bd")}})}]};var wG=lx(vG);const MG=({viz:t})=>{const e=t._filteredData;if(!e||!e.length)return{shapeData:[]};const i=t.schema.height-t._margin.top-t._margin.bottom,o=t.schema.width-t._margin.left-t._margin.right,r=Math.min(i,o),a=n.nestGroups(e,t.schema.groupBy.slice(0,t._drawDepth+1)),s=t.schema.packOpacity,c=t.ctx.pack.padding(t.schema.layoutPadding).size([r,r])(L.hierarchy({key:a.key,values:a},t=>t.values).sum(t.schema.sum).sort(t.schema.sort)).descendants().filter((t,e)=>{const n=t;n.__d3plus__=!0,n.i=e,n.id=n.parent?n.parent.data.key:"root";const i=n.data;return i.__d3plusOpacity__=n.height?s(i,e):1,i.__d3plusTooltip__=!n.height,!n.children||n.children.length>1});return t.ctx.packDiameter=r,t.ctx.packOffsetX=(o-r)/2,t.ctx.packOffsetY=(i-r)/2,{shapeData:c}};function SG(t,e=[]){return t.values?t.values.forEach(t=>{e.push(t),SG(t,e)}):e.push(t),e}const CG=t=>Array.isArray(t)?t:[t],$G={name:"Pack",layoutStage:MG,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=Hm(t,"Circle"),o=(t.schema.shapeConfig.Circle??{}).label,r=n.map((e,n)=>{const o=e.data,r=Pm(i.fill,o,n),a=Pm(i.stroke,o,n),s=Pm(i.strokeWidth,o,n);return{type:"circle",key:`pack-${e.id}-${e.i}`,cx:e.x,cy:e.y,r:e.r,shapeType:"Pack",datum:o,paint:{fill:Tm(i,o,n,r),stroke:a,opacity:o.__d3plusOpacity__,strokeWidth:s},aria:{label:`${t._drawLabel(o,e.i)}, ${e.value}.`}}}),a=Kx({data:n,label:(t,e)=>{const n=t;return!n.children&&(o?o(n.data,e):!!n.parent&&(n.data.id??!1))},x:t=>t.x,y:t=>t.y,datum:t=>t.data,aes:t=>{const e=t.r;return{r:e,width:2*e,height:2*e}},rotate:H(0),id:t=>t.id,labelBounds:(t,e,n)=>{const i=n.r;return{width:1.6*i,height:.8*i,x:.8*-i,y:.4*-i}},labelConfig:{fontResize:!0,...jm(t,"Circle")}}),s=tw(i,r,t=>[n[t].data,t]);return[...r,...s,...a]},insetRegion:Cp,chartTransform:t=>({x:t._margin.left+(t.ctx.packOffsetX??0),y:t._margin.top+(t.ctx.packOffsetY??0)}),chartBodyRect:t=>{const e=t.ctx.packDiameter??0;return{x:0,y:0,width:e,height:e}},setup:t=>{const e=t.hover.bind(t);t.hover=n=>(e(n),t.schema.legend&&t._legendClass.hover(n),t)},facet:{aspect:1},ctx:{pack:L.pack()},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(t,e)=>(e.value??0)-(t.value??0)},{key:"sum",default:I("value"),coerce:t=>"function"==typeof t?t:q(t)},{key:"packOpacity",default:H(.25),coerce:t=>"function"==typeof t?t:H(t)},{key:"shape",default:H("Circle"),coerce:t=>"function"==typeof t?t:H(t)},{key:"shapeConfig",merge:!0,factory:()=>({Circle:{label:t=>{const e=t;return!(!e.parent||e.children)&&e.id},labelConfig:{fontResize:!0},opacity:t=>t.__d3plusOpacity__}})},{key:"legendSort",factory:t=>vE(t,"sum")},{key:"legend",coerce:"const",factory:kE},{key:"on",merge:!0,factory:t=>{const e=t.schema.on["mousemove.legend"],n=t.schema.on["mousemove.shape"],i=e=>t.hover(e);return{mouseenter:()=>{},"mousemove.legend":(n,o,r,a)=>{e(n,o,r,a);const s=t._ids(n,o),c=SG(n);i(t=>(Object.keys(t).filter(t=>"value"!==t&&!t.startsWith("__d3plus")).every(e=>null!=n[e]&&CG(t[e]).every(t=>CG(n[e]).includes(t)))?c.push(t):s.includes(t.key)&&c.push(...SG(t,[t])),c.includes(t)))},"mousemove.shape":(t,e,o,r)=>{t.__d3plusTooltip__&&n(t,e,o,r);const a=SG(t,[t]);i(t=>a.includes(t))}}}}]};var AG=lx($G);function zG(t){return"number"==typeof t&&Number.isFinite(t)}function DG(t){return null==t||""===t||"number"==typeof t&&!Number.isFinite(t)}function LG(t,e=[]){const n=new Set(e),i=[],o=new Map;for(const e of t)for(const t of Object.keys(e)){if(n.has(t)||t.startsWith("_"))continue;const r=e[t];o.has(t)||(o.set(t,!0),i.push(t)),DG(r)||zG(r)||o.set(t,!1)}return i.filter(e=>o.get(e)&&t.some(t=>zG(t[e])))}function FG(t){const e=t.filter(t=>!DG(t));return e.length&&e.every(zG)?"numeric":"categorical"}function NG(t,e,n={}){const i=Array.isArray(n.domain)?n.domain:void 0;if("numeric"===e){const[e,n]=h.extent(t.filter(zG));return[i&&zG(i[0])?i[0]:e??0,i&&zG(i[i.length-1])?i[i.length-1]:n??0]}if(i)return i.map(String);return Array.from(new Set(t.filter(t=>!DG(t)).map(String))).sort((t,e)=>t.localeCompare(e,void 0,{numeric:!0}))}function BG(t,e,n={},i){return t.map(t=>{const o=n[t]??{},r=e.map(e=>e[t]),a="point"===o.scale||"band"===o.scale?"categorical":FG(r),s=i?.[t]??NG(r,a,o);return{key:t,title:"string"==typeof o.title?o.title:t,type:a,domain:s,reverse:Boolean(o.reverse)}})}function EG(t,e,n={}){const i={};for(const o of BG(t,e,n))i[o.key]=o.domain;return i}function RG(t){return t<=50?1:Math.max(.1,Math.round(100*Math.sqrt(50/t))/100)}function PG(t,e,n){if(t<=0)return[];if(1===t)return[(e+n)/2];const i=(n-e)/(t-1);return Array.from({length:t},(t,n)=>e+i*n)}function TG(t,e){const n=t.domain.slice();return("numeric"===t.type?"horizontal"===e!==t.reverse:t.reverse)?n.reverse():n}function OG(t){if(!t)return{};const e={...t};return delete e.domain,delete e.reverse,delete e.title,e}function WG(t,e){const n=t.schema.axisConfig??{};return{fontColor:Ws(t),fontSize:12,textAnchor:"horizontal"===e?"middle":"end",verticalAlign:"horizontal"===e?"bottom":"middle",...n.titleConfig??{}}}function HG(t,e,n){const i=t.schema.dimensionConfig??{},o=(new zo).orient("horizontal"===n?"left":"bottom").align("start");o.renderMode("compute").select(null),o.config(jC(t,{})).config(t.schema.axisConfig??{}).config(OG(i[e.key])),o.gridSize(0).title(!1);const r=o.scale();return"categorical"===e.type&&"point"!==r&&"band"!==r&&o.scale("point"),"numeric"!==e.type||"point"!==r&&"band"!==r||o.scale("linear"),o.domain(TG(e,n)),o}function jG(t,e){let n=0,i=e;for(const o of t){const t=o._d3Scale?.range()??[0,e];n=Math.max(n,Math.min(...t)),i=Math.min(i,Math.max(...t))}return i>n?[n,i]:[0,e]}function IG(t,e,n){const i=t=>{const e=t.children,n={...t,interactionGroup:"axis",interactive:!1};return delete n.datum,e&&(n.children=e.map(i)),n},o=t.toScene();return i({type:"group",key:`pc-axis-${e}`,transform:n,children:o.children})}function GG(t,e,n,i,o){const r=t._d3Scale,a="numeric"===e.type&&r&&"function"==typeof r.invert?t=>Number(r.invert(t-i)):void 0;return{dim:e,offset:n,start:i+o[0],end:i+o[1],position:n=>{const o=t._getPosition((t=>"categorical"===e.type?String(t):t)(n));return"number"==typeof o&&Number.isFinite(o)?i+o:NaN},invert:a}}function qG(t,e,n,i,o){return!e.length||n<=0||i<=0?{axes:[],nodes:[]}:"vertical"===o?function(t,e,n,i){const o=e.length,r=WG(t,"vertical"),a=t.schema.locale,s=Bx(e.map(t=>t.title),r,a),c=Math.min(Math.max(0,...s)+4,.25*n),l=c?c+8:0,h=Math.max(0,n-l),u=Math.max(20,i/o*.5),d=e.map(e=>HG(t,e,"vertical").width(h).height(u).maxSize(u));d.forEach(t=>t.measure());const f=d.map(t=>t.outerBounds().height||0),m=Ex(e.slice(0,1).map(t=>({key:t.key,text:"M",x:0,y:0,width:c||1,height:0})),r,a),p=PG(o,Math.max(4,m/2),i-Math.max(4,f[o-1])),g=o>1?p[1]-p[0]:i,y=jG(d,h),x=[],b=d.map((t,n)=>{t.range(y).render();const i=ko(t),o=i?i.points[0][1]:0;return x.push(IG(t,e[n].key,{x:l,y:p[n]-o})),GG(t,e[n],p[n],l,y)}),_=c?e.map((t,e)=>({key:t.key,text:t.title,x:0,y:p[e]-g/2,width:c,height:g})).filter(t=>t.text):[];return x.push(...Rx(_,r,a)),{axes:b,nodes:x}}(t,e,n,i):function(t,e,n,i){const o=e.length,r=WG(t,"horizontal"),a=t.schema.locale,s=Bx(e.map(t=>t.title),r,a),c=Math.max(30,n/o*.6),l=e.map(e=>HG(t,e,"horizontal").height(i).width(c).maxSize(c));l.forEach(t=>t.measure());const h=l.map(t=>t.outerBounds().width||0);let u=o>1?n/o:n,d=[],f=0,m=0;for(let t=0;t<2;t++)d=s.map(t=>Math.min(t+4,Math.max(u-8,40))),f=Math.max(h[0],d[0]/2,4),m=Math.max(d[o-1]/2,4),u=o>1?(n-f-m)/(o-1):n-f-m;const p=PG(o,f,n-m),g=e.map((t,e)=>({key:t.key,text:t.title,x:p[e]-d[e]/2,y:0,width:d[e],height:0})).filter(t=>t.text),y=Ex(g,r,a),x=y?y+8:0;g.forEach(t=>t.height=y);const b=Math.max(0,i-x);l.forEach(t=>t.height(b).measure());const _=jG(l,b),k=[],v=l.map((t,n)=>{t.range(_).render();const i=ko(t),o=i?i.points[0][0]:h[n];return k.push(IG(t,e[n].key,{x:p[n]-o,y:x})),GG(t,e[n],p[n],x,_)});return k.push(...Rx(g,r,a)),{axes:v,nodes:k}}(t,e,n,i)}function VG(t,e,n="horizontal"){return e.map(e=>{const i=t[e.key];if(DG(i))return null;const o=e.position(i);return"number"==typeof o&&Number.isFinite(o)?"horizontal"===n?[e.offset,o]:[o,e.offset]:null})}function YG(t,e="linear",n="horizontal"){const i="bump"===e?"horizontal"===n?x.curveBumpX:x.curveBumpY:x.curveLinear;return x.line().defined(t=>null!==t).x(t=>t[0]).y(t=>t[1]).curve(i)(t)??""}function KG(t){const e=t.schema.dimensions;if(Array.isArray(e))return e.map(String);const n=t._groupByRaw,i=(Array.isArray(n)?n:[n]).filter(t=>"string"==typeof t);return LG(t._data??[],["id",...i])}function UG(t){return"vertical"===t?"vertical":"horizontal"}function XG(t,e,n,i){const o=t.end-t.start,{dim:r}=t,a={id:`${n.left},${n.top}|${e}|${r.key}`,key:r.key,title:r.title,orient:e,type:r.type,domain:r.domain,position:t.position,invert:t.invert,alongStart:t.start};return"horizontal"===e?{...a,x:n.left+t.offset-i/2,y:n.top+t.start,width:i,height:o}:{...a,x:n.left+t.start,y:n.top+t.offset-i/2,width:o,height:i}}const ZG=({viz:t})=>{var e;const n=(e=t.ctx).brushQueue??(e.brushQueue=[]),i=t._filteredData??[],o=KG(t);if(t.ctx.dimensions=[],t.ctx.axisNodes=[],!i.length||!o.length)return{shapeData:[]};const r=BG(o,i,t.schema.dimensionConfig??{},t.ctx.sharedDomains);t.ctx.dimensions=r;const a=UG(t.schema.orient),s="bump"===t.schema.curve?"bump":"linear",{width:c,height:l}=kt(t),h=qG(t,r,c,l,a);t.ctx.axisNodes=h.nodes;const u=t.schema.brushConfig??{},d="number"==typeof u.width?u.width:20;for(const e of h.axes)n.push(XG(e,a,t._margin,d));const f=h.axes.map(t=>({key:t.dim.key,offset:t.offset,position:t.position})),m=new Map;return{shapeData:i.map((e,n)=>{const i=`${t._id(e,n)}`,o=m.get(i)??0;return m.set(i,o+1),{data:e,i:n,id:o?`${i}-${o}`:i,d:YG(VG(e,f,a),s,a)}})}};function QG(t){return 2===t.length&&t.every(t=>zG(t))}function JG(t,e){if(QG(e)){if(!zG(t))return!1;const[n,i]=e[0]<=e[1]?e:[e[1],e[0]];return t>=n&&t<=i}return null!=t&&e.includes(String(t))}function tq(t,e){if(!e)return!0;for(const n of Object.keys(e))if(!JG(t[n],e[n]))return!1;return!0}function eq(t){return Boolean(t&&Object.keys(t).length)}function nq(t,e){const n=Math.min(t[0],t[1]),i=Math.max(t[0],t[1]);if("numeric"===e.type){if(!e.invert)return null;const t=e.invert(n),o=e.invert(i);return zG(t)&&zG(o)?t<=o?[t,o]:[o,t]:null}const o=e.domain.filter(t=>{const o=e.position(t);return o>=n&&o<=i}).map(String);return o.length?o:null}function iq(t,e,n=6){if(QG(t)){if("numeric"!==e.type)return null;const n=e.position(t[0]),i=e.position(t[1]);return zG(n)&&zG(i)?n<=i?[n,i]:[i,n]:null}const i=new Set(t.map(String)),o=e.domain.filter(t=>i.has(String(t))).map(t=>e.position(t)).filter(zG);return o.length?[Math.min(...o)-n,Math.max(...o)+n]:null}const oq="d3plus-parallel-brushes",rq="d3plus-parallel-brush",aq=new WeakMap;function sq(t){return"horizontal"===t.orient?t.height:t.width}function cq(t,e){if(!t)return null;const n=iq(t,e);if(!n)return null;const i=sq(e),o=Math.max(0,Math.min(i,n[0]-e.alongStart)),r=Math.max(0,Math.min(i,n[1]-e.alongStart));return r>o?[o,r]:null}function lq(t,e){const n=aq.get(t)?.clearLabel,i=o.select(t).attr("tabindex",e?0:null);i.selectAll(":scope > title").remove(),e&&n&&i.insert("title",":first-child").text(n)}function hq(t,e,n,i){const r=aq.get(e);if(!r)return;const a=r.target.key,s={...t.schema.brushes??{}};n?s[a]=n:delete s[a],t.schema.brushes=s;const c=e.parentNode;c&&o.select(c).selectAll(`g.${rq}`).each(function(t){const r=aq.get(this);r&&t.key===a&&(lq(this,Boolean(n)),(this!==e||i)&&o.select(this).call(r.brush.move,cq(n??void 0,r.target)))});const l=t.schema.on?.brush;"function"==typeof l&&l.call(t,s),t._scheduleSceneRepaint()}function uq(t,e){const n=aq.get(e),i=t.schema.brushes??{};return!(!n||!(n.target.key in i))&&(n.active=!1,hq(t,e,null,!0),!0)}function dq(t,e,n){const i=t._select&&"function"==typeof t._select.node?t._select.node():null;if(!i||"function"!=typeof i.querySelector)return;const r=!1!==t.schema.brushing&&!t._ssr&&e.length>0,a=o.select(i).selectAll(`:scope > g.${oq}`).data(r?[0]:[]);if(a.exit().remove(),!r)return;const s=a.enter().append("g").attr("class",`d3plus-viz-brush ${oq}`).merge(a),c=Array.from(new Map(e.map(t=>[t.id,t])).values()),l=s.selectAll(`g.${rq}`).data(c,t=>t.id);l.exit().remove();const h=t.schema.brushes??{},u=e=>t.schema.translate(e);l.enter().append("g").attr("class",rq).merge(l).each(function(e){const i=o.select(this);let r=aq.get(this);if(!r){const n="horizontal"===e.orient?p.brushY():p.brushX();r={brush:n,target:e,signature:"",active:!1,clearLabel:""},aq.set(this,r);const o=this;n.on("start brush end",e=>function(t,e,n){const i=aq.get(e);if(!i||!n.sourceEvent)return;const o=i.target;i.active="end"!==n.type;const r=n.selection;hq(t,e,r&&Math.abs(r[1]-r[0])>=1?nq([r[0]+o.alongStart,r[1]+o.alongStart],o):null,"end"===n.type&&"categorical"===o.type)}(t,o,e)),i.on("dblclick.clear",e=>{e.preventDefault(),e.stopPropagation(),uq(t,o)}).on("keydown.clear",e=>{"Escape"===e.key&&uq(t,o)&&(e.preventDefault(),e.stopPropagation())})}if(r.target=e,r.clearLabel=`${e.title}: ${u("Double-click or Escape to Clear")}`,i.attr("transform",`translate(${e.x},${e.y})`),r.active)return;const a=`${e.width}x${e.height}`;r.signature!==a&&(r.brush.extent([[0,0],[e.width,e.height]]),i.call(r.brush),r.signature=a),function(t,e,n){const i=t.selectAll("rect.selection"),o=[["fill",e.fill],["fill-opacity",e.fillOpacity],["stroke",e.stroke],["stroke-width",e.strokeWidth]];for(const[t,e]of o)null!=e&&i.attr(t,`${e}`);t.selectAll("rect.overlay").attr("aria-label",n)}(i,n,`${e.title}: ${u("Drag to Filter")}`),i.call(r.brush.move,cq(h[e.key],e)),lq(this,e.key in h)})}function fq(t,e,n){if(DG(n))return"";const i=t.schema.dimensionConfig??{},o=i[e]?.tickFormat;return"function"==typeof o?`${o(n)}`:zG(n)?d.formatAbbreviate(n,t.schema.locale):String(n)}function mq(t,e){return(t.ctx.dimensions??[]).map(n=>[n.title,fq(t,n.key,e[n.key])])}const pq="pc-line-",gq="::hit";function yq(t,e){return"number"==typeof t&&Number.isFinite(t)?Math.min(1,Math.max(0,t)):RG(e)}function xq(t,e,n,i){const o=i.map(n=>`${n.title} ${fq(t,n.key,e[n.key])}`).join(", ");return`${t._drawLabel(e,n)}${o?`: ${o}`:""}.`}const bq=({viz:t,shapeData:e})=>{const n=e??[],i=t.ctx.axisNodes??[];if(!n.length)return i;const o=t.ctx.dimensions??[],r=Hm(t,"Line"),a=yq(t.schema.lineOpacity,n.length),s=[];return n.forEach(e=>{if(!e.d)return;const{data:n,i:i}=e,c=`${pq}${e.id}`,l=Pm(r.strokeOpacity,n,i);s.push({type:"path",shapeType:"Line",key:c,d:e.d,datum:n,index:i,paint:{fill:"none",stroke:Pm(r.stroke,n,i),strokeWidth:Pm(r.strokeWidth,n,i),strokeOpacity:"number"==typeof l?l:a,strokeDasharray:Pm(r.strokeDasharray,n,i),opacity:Pm(r.opacity,n,i)},aria:{label:xq(t,n,i,o)}}),s.push({type:"path",shapeType:"Line",key:`${c}${gq}`,d:e.d,datum:n,index:i,paint:{fill:"none",stroke:"transparent",strokeWidth:8},aria:{hidden:!0}})}),[...s,...i]},_q=t=>"string"==typeof t.key&&t.key.includes(pq),kq=t=>"string"==typeof t.key&&t.key.endsWith(gq),vq=t=>"number"==typeof t.z&&t.z>0;function wq(t,e){if(_q(t))return e(t);const n=t.children;return n&&n.length?{...t,children:n.map(t=>wq(t,e))}:t}function Mq(t){if(_q(t))return!kq(t)&&vq(t)?1:0;const e=t.children;return e?e.reduce((t,e)=>t+Mq(e),0):0}function Sq(t,n){const i=eq(n.brushes),o=1===Mq(t);return i||o?wq(t,t=>{const r={...t.paint??{}};if(i&&!tq(t.datum,n.brushes)){if(!kq(t)){const t="number"==typeof r.strokeOpacity?r.strokeOpacity:1;r.strokeOpacity=n.inactiveOpacity??.3*t,"string"==typeof r.stroke&&(r.stroke=e.colorGrayscale(r.stroke))}const i={...t,paint:r,interactive:!1};return delete i.z,i}return o&&vq(t)&&!kq(t)?(r.strokeOpacity=1,{...t,paint:r}):t}):t}function Cq(t){const e={};for(const[n,i]of Object.entries(t))e[n]="function"==typeof i?i():i;return e}const $q={name:"ParallelCoordinates",layoutStage:ZG,emit:bq,decorateScene:function(t,e){const n=Cq(t.schema.brushConfig??{}),i=t.ctx.brushQueue;i&&(t.ctx.brushQueue=void 0,dq(t,i,n));const o=Sq(e.root,{brushes:t.schema.brushes,inactiveOpacity:"number"==typeof n.inactiveOpacity?n.inactiveOpacity:void 0});return o===e.root?e:{...e,root:o}},facet:{aspect:1.5,axes:"all",share:(t,e)=>EG(KG(t),e.flat(),t.schema.dimensionConfig??{}),panel:(t,e)=>{const n=t.ctx.sharedDomains;return t.ctx.sharedDomains=e.shared?e.scales:void 0,()=>{t.ctx.sharedDomains=n}}},ctx:{},fields:[{key:"brushes",default:{}},{key:"brushing",default:!0},{key:"curve",default:"linear"},{key:"dataCutoff",default:2e3},{key:"dimensions"},{key:"lineOpacity",default:"auto"},{key:"orient",default:"horizontal"},{key:"zoom",default:!1},{key:"axisConfig",merge:!0,default:{}},{key:"brushConfig",merge:!0,factory:t=>({fill:()=>Ws(t),fillOpacity:.12,stroke:()=>Ws(t),strokeWidth:1,width:20})},{key:"dimensionConfig",merge:!0,default:{}},{key:"shapeConfig",merge:!0,factory:t=>({Line:{stroke:(e,n)=>{const i=t.schema.shapeConfig.fill;return"function"==typeof i?i(e,n):i},strokeWidth:1.5}})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:e=>mq(t,e)})}]};var Aq=lx($q);function zq(t){return{barConfig:{stroke:()=>Ws(t),strokeWidth:1},gridConfig:{stroke:()=>Hs(t),strokeWidth:1},shapeConfig:{fill:H("none"),labelConfig:{fontColor:()=>Ws(t),fontResize:!1,padding:0,textAnchor:t=>t.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Ws(t),strokeWidth:H(1)}}}function Dq(t){return[()=>t.schema.translate("Value"),(e,n)=>{const i=Number(t.schema.value(e,n));return Number.isFinite(i)?d.formatAbbreviate(i,t.schema.locale):""}]}function Lq(t,e,n,i){const o=Hm(t,"Path"),r=e.filter(t=>t.arc.outerRadius>t.arc.innerRadius&&t.arc.endAngle>t.arc.startAngle),s=r.map(e=>{const r=Om(o,e.data,e.i);return{type:"path",key:`${n}-${t._ids(e.data,e.i).join("-")}-${e.slot}`,d:a.arcPath(e.arc),arc:e.arc,datum:e.data,index:e.i,paint:{...r,opacity:r.opacity??1},aria:{label:i(e)}}}),c=tw(o,s,t=>[r[t].data,r[t].i]);return[...s,...c]}function Fq(t,e,n){const i=e.flatMap(e=>n(t,e)).filter(Number.isFinite);return{extent:i.length?[Math.min(...i),Math.max(...i)]:[]}}function Nq(t,e){const n=t.ctx.polarSharedExtent,i=e.scales;return t.ctx.polarSharedExtent=e.shared&&i?i.extent:void 0,()=>{t.ctx.polarSharedExtent=n}}function Bq(t){const e=t.ctx.polarSharedExtent;return Array.isArray(e)?e:[]}function Eq(t){return{aspect:1,scales:"independent",share:(e,n)=>Fq(e,n,t),panel:Nq}}const Rq=1e-9;function Pq(t,e,n,i,o,r=10){const a=Math.abs(Math.cos(t)),s=Math.abs(Math.sin(t));let c=1/0;return a>Rq&&(c=Math.min(c,(i/2-n/2*s)/a-e-r)),s>Rq&&(c=Math.min(c,(o/2-n/2*a)/s-e-r)),c}function Tq(t){const{labels:e,width:n,height:i,measure:o,wrap:r}=t,a=t.padding??10,s=t.maxLines??2,c=Math.max(0,Math.min(n,i)/2),l=c*(t.minRadiusShare??.5),h=e.map(t=>o(t)),u=function(t,e,n,i=10){let o=Math.min(e,n)/2;for(const r of t){const t=Math.abs(Math.cos(r.angle)),a=Math.abs(Math.sin(r.angle));t>Rq&&(o=Math.min(o,(e/2-r.height/2*a)/t-i-r.width)),a>Rq&&(o=Math.min(o,(n/2-r.height/2*t)/a-i-r.width))}return Math.max(0,o)}(e.map((t,e)=>({angle:t.angle,width:h[e],height:t.lineHeight})),n,i,a);if(u>=l)return{radius:u,labels:e.map((t,e)=>({wrapWidth:h[e]+1,width:h[e],height:t.lineHeight,lines:1,truncated:!1}))};const d=t=>e.map((e,o)=>{if(h[o]<=Pq(e.angle,t,e.lineHeight,n,i,a))return{wrapWidth:h[o]+1,width:h[o],height:e.lineHeight,lines:1,truncated:!1};const c=Pq(e.angle,t,e.lineHeight*s,n,i,a),l=Math.max(0,c),u=r(e,l,s);return{wrapWidth:l,width:Math.max(0,...u.widths),height:Math.max(1,u.lines.length)*e.lineHeight,lines:u.lines.length,truncated:u.truncated}}),f=t=>t.every(t=>!t.truncated);let m=l,p=d(m);if(!f(p))return{radius:l,labels:p};let g=c;for(let t=0;t<16&&g-m>.5;t++){const t=(m+g)/2,e=d(t);f(e)?(m=t,p=e):g=t}return{radius:m,labels:p}}const Oq=t=>t.font.lineHeight??1.2*t.font.fontSize;function Wq(t,e=1){return Math.max(0,...t.map(t=>t.font.fontSize))+(e-1)*Math.max(0,...t.map(Oq))+10}function Hq(t,e,n,i){const o=Math.PI/Math.max(1,i),r=t.angle+Math.PI/2,a=e+n*Oq(t);return{innerRadius:a,outerRadius:a+t.font.fontSize+10,startAngle:r-o,endAngle:r+o}}function jq(t,e,n,i){const o=(e,o)=>sE(Hq(t,n,o,i),HB(e,t.font),{fontMin:t.font.fontSize,fontMax:t.font.fontSize,padding:5,align:"inner",minRadius:0,truncate:!1}),r=o(e[0],0);if(!r)return null;const a=[];for(let t=0;t<e.length;t++){const n=r.clockwise?e.length-1-t:t,i=0===n?r:o(e[t],n);if(!i)return null;a.push({text:e[t],fit:i})}return a.length?{lines:a}:null}function Iq(t,e,n,i){let o=t.width(n)(e).lines;if(i<2)return o;let r=n/2,a=n;for(let n=0;n<8&&a-r>1;n++){const n=(r+a)/2,s=t.width(n)(e);s.truncated||s.lines.length!==i?r=n:(a=n,o=s.lines)}return o}function Gq(t,e,n,i=1){const o=e.length;return e.map((e,a)=>{const c=hE(t,e.data,a);if("inside"===c||"outside"===c||!e.text)return null;const l=jq(e,[e.text],n,o);if(l)return l;const h=i>1?function(t,e,n,i){const{fontSize:o}=t.font,a=Oq(t),c=Hq(t,e,0,n),l=e+5;let h=(c.endAngle-c.startAngle)*l-2*nE(5,o);const u=s.textWrap().fontFamily(r.fontExists(t.font.fontFamily??s.fontFamily)).fontSize(o).fontWeight(t.font.fontWeight??400).lineHeight(a).height(a*i).maxLines(i);for(let i=0;i<6&&h>o;i++){const i=u.width(h)(t.text);if(i.truncated||!i.lines.length)return null;const o=jq(t,Iq(u,t.text,h,i.lines.length),e,n);if(o)return o;h*=.9}return null}(e,n,o,i):null;if(h||"along"!==c)return h;const u=sE(Hq(e,n,0,o),HB(e.text,e.font),{fontMin:e.font.fontSize,fontMax:e.font.fontSize,padding:5,align:"inner",minRadius:0});return u?{lines:[{text:e.text,fit:u}]}:null})}function qq(t,e){return t.every((t,n)=>e[n]||!t.text)}function Vq(t,e){const n=Array.isArray(e)?e.filter(Number.isFinite):[],i=t.filter(Number.isFinite).concat(n),o=Math.min(0,...i),r=Math.max(0,...i);if(Array.isArray(e)){return{domain:[o,r],ticks:Array.from(new Set(n)).sort((t,e)=>t-e)}}const a=Math.max(1,Math.round(e)),s=c.scaleLinear().domain([o,r]).nice(a),[l,h]=s.domain();return{domain:[l,h],ticks:s.ticks(a)}}function Yq(t,e,n){const i=e[1]-e[0];return i?(t-e[0])/i*n:0}const Kq={"stroke-width":"strokeWidth","stroke-opacity":"strokeOpacity","stroke-dasharray":"strokeDasharray"};function Uq(t,e){const n={...t};for(const[t,i]of Object.entries(e??{}))n[Kq[t]??t]=i;return n}const Xq=(t,e,n)=>"function"==typeof t?t(e,n):t;function Zq(t,e,n){const i={fill:"none"},o=Xq(t.stroke,e,n);"string"==typeof o&&(i.stroke=o);const r=Number(Xq(t.strokeWidth,e,n));Number.isFinite(r)&&(i.strokeWidth=r);const a=Number(Xq(t.strokeOpacity,e,n));Number.isFinite(a)&&(i.strokeOpacity=a);const s=Number(Xq(t.opacity,e,n));Number.isFinite(s)&&(i.opacity=s);const c=Xq(t.strokeDasharray,e,n),l=(Array.isArray(c)?c:"string"==typeof c?c.split(/[\s,]+/):[]).map(Number).filter(Number.isFinite);return l.length&&(i.strokeDasharray=l),i}const Qq=2*Math.PI,Jq=(t,e,n,i)=>{const o=t.schema.axisConfig,a=(new Ir).config({...Yx,...o.shapeConfig?.labelConfig??{}}).schema,s={data:n,i:i,text:e},c=Number(a.fontSize(s,i))||10;return{fontFamily:String(r.fontExists(a.fontFamily(s,i))||"sans-serif"),fontSize:c,fontWeight:a.fontWeight(s,i),lineHeight:Number(a.lineHeight(s,i))||1.2*c}};function tV(t,e,i,o){const a=e.length,c=t.schema.aggs,l=t.schema.outerPadding,h=e.map(([e,i],o)=>{const r=n.merge(i,c),s=Jq(t,String(e),r,o);return{key:e,data:r,font:s,text:String(e),angle:Qq/a*o,lineHeight:s.lineHeight}}),u=Math.min(i,o)/2-2;let d,f=0,m=h.map(()=>({wrapWidth:0}));const p="auto"===l?function(t,e,n){if(!e.length)return null;for(let i=1;i<=2;i++){const o=Math.max(0,n-Wq(e,i)),r=Gq(t,e,o,i);if(qq(e,r))return{radius:o,curves:r}}return null}(t,h,u):null;if(p&&({radius:f,curves:d}=p),"number"==typeof l)f=Math.max(0,Math.min(i,o)/2-l),m=h.map(()=>({wrapWidth:l}));else if(!d){const t=Tq({labels:h,width:i-4,height:o-4,measure:({text:t,font:e})=>r.textWidth(t,{"font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":e.fontWeight}),wrap:({text:t,font:e},n,i)=>s.textWrap().fontFamily(e.fontFamily).fontSize(e.fontSize).fontWeight(e.fontWeight).lineHeight(e.lineHeight).width(n).height(e.lineHeight*i).maxLines(i)(t)});f=t.radius,m=t.labels}const g=function(t,e,n){for(let i=2;i>0;i--)if(e+Wq(t,i)<=n)return i;return 0}(h,f,u);d??(d=g?Gq(t,h,f,g):h.map(()=>null));const y=h.map(({key:t,data:e,font:n,angle:i},o)=>{const r=2*n.lineHeight,s=m[o].wrapWidth,c=parseInt(String(360-360/a*o/90),10)%4+1;let l=360/a*o,h="start",u=10;return 2!==c&&3!==c||(u=-s-10,h="end",l+=180),{__d3plus__:!0,data:e,i:o,id:t,key:t,angle:l,textAnchor:h,labelBounds:{x:u,y:-r/2,width:s,height:r},rotateAnchor:[-u,r/2],x:f*Math.cos(i),y:f*Math.sin(i),labelCurve:d[o]??void 0}}).sort((t,e)=>Number(t.key)-Number(e.key));return{radius:f,polarAxis:y}}function eV(t,e){const n=t.schema.axisConfig,i=[],o=function(t,e){const n=t.schema.axisConfig,i=n.shapeConfig?.labelConfig??{},o=e=>{const n=Pm(i.fontColor,e.data,e.i);return"string"==typeof n?n:Ws(t)},r=IB(t,e.flatMap(t=>(t.labelCurve?.lines??[]).map((e,n)=>({key:`radar-axis-label-${t.id}${n?`-${n}`:""}`,text:e.text,fit:e.fit,color:o(t)}))),WB(i)),a=Kx({data:e.filter(e=>!e.labelCurve&&"along"!==hE(t,e.data,e.i)),label:t=>t.id,x:t=>t.x,y:t=>t.y,aes:()=>({}),rotate:t=>t.angle||0,id:t=>t.id,labelBounds:t=>t.labelBounds,labelConfig:i});return[...r,...GB(a,ak(r))]}(t,e);o.length&&i.push({type:"group",key:"radar-axis-labels",children:o});const r=Hm(t,"Path",n.shapeConfig??{}),a=e.map((t,e)=>({type:"path",key:`radar-spoke-${t.id}`,interactive:!1,d:`M0,0 ${t.x},${t.y}`,paint:Om(r,t,e)}));return a.length&&i.push({type:"group",key:"radar-axis-spokes",interactive:!1,children:a}),i}function nV(t,{domain:e,ticks:n},i,o=t=>Yq(t,e,i),r="radar"){const a=t.schema.axisConfig,s=n.map(t=>({value:t,r:o(t)}));return function(t,e,n,i,o,r="radar"){if(!(e>0))return[];const a=t.filter(t=>t.r>0&&t.r<e),s=[...a,{value:n,r:e}].map((t,e)=>({type:"circle",key:e===a.length?`${r}-ring-outer`:`${r}-ring-${t.value}`,interactive:!1,cx:0,cy:0,r:t.r,paint:Zq(e===a.length?o:i,t,e)}));return[{type:"group",key:`${r}-radial-circles`,interactive:!1,children:s}]}(s,i,e[1],Uq({},a.gridConfig),Uq({},a.barConfig),r)}function iV(t,{domain:e,ticks:n},i,o,a="radar"){if(!t.schema.levelLabels)return[];const c=t.schema.levelLabelConfig??{},l=c.fontSize??10,h=c.fontWeight??400,u=s.fontFamilyStringify(c.fontFamily??t.schema.fontFamily??s.fontFamily),f={"font-family":u,"font-size":l,"font-weight":h},m=t.schema.levelFormat,p=function(t){const{ticks:e,domain:n,radius:i,angle:o,format:r,measure:a,fontSize:s}=t,c=t.toRadius??(t=>Yq(t,n,i)),l=o*Math.PI/180,h=Math.sin(l),u=-Math.cos(l),d=-u,f=h,m=d>1e-6?"start":d<-1e-6?"end":"middle",p=(t,e,n,i)=>(Math.abs(n)*t+Math.abs(i)*e)/2,g=e.filter(t=>t>=n[0]&&t<=n[1]).map(t=>{const e=c(t),n=r(t),i=a(n),o=s,l=3+p(i,o,d,f),g=e-2-p(i,o,h,u);return{value:t,text:n,r:e,x:g*h+l*d,y:g*u+l*f,width:i,height:o,anchor:m}}),y=Math.max(0,...g.map(t=>2*p(t.width,t.height,h,u)));let x=1/0;for(let t=1;t<g.length;t++)x=Math.min(x,g[t].r-g[t-1].r);const b=x>0?Math.max(1,Math.ceil((y+2)/x)):g.length;return g.filter((t,e)=>e%b===0)}({ticks:n,domain:e,radius:i,angle:Number(t.schema.levelLabelAngle)||0,format:e=>"function"==typeof m?String(m(e)):d.formatAbbreviate(e,t.schema.locale),measure:t=>r.textWidth(t,f),fontSize:l,toRadius:o});return function(t,e,n="radar"){if(!t.length)return[];const i=[];for(const o of t){const t="start"===o.anchor?-o.width/2:"end"===o.anchor?o.width/2:0;i.push({type:"text",key:`${n}-level-label-${o.value}`,interactive:!1,x:0,y:0,transform:{x:o.x+t,y:o.y},lines:[{text:o.text,x:0,y:.35*e.fontSize,width:o.width}],font:{family:e.fontFamily,size:e.fontSize,weight:e.fontWeight,anchor:o.anchor,baseline:"alphabetic"},paint:{fill:e.fontColor,opacity:e.fontOpacity}})}return[{type:"group",key:`${n}-level-labels`,interactive:!1,children:i}]}(p,{fontColor:c.fontColor??Ws(t),fontFamily:u,fontOpacity:c.fontOpacity??1,fontSize:l,fontWeight:h},a)}const oV=1e-9;function rV(t,e,n,i,o=6){const r=Math.sin(t),a=-Math.cos(t);return{x:(e+o)*r+r*n/2-n/2,y:(e+o)*a+a*i/2-i/2,width:n,height:i}}function aV(t,e,n,i=6){let o=Math.min(e,n)/2;for(const r of t){const t=Math.abs(Math.sin(r.angle)),a=Math.abs(Math.cos(r.angle));t>oV&&(o=Math.min(o,(e/2-r.width/2*(1+t))/t-i)),a>oV&&(o=Math.min(o,(n/2-r.height/2*(1+a))/a-i))}return Math.max(0,o)}function sV(t,e,n,i=6){const o=Math.abs(Math.sin(t));return o<=oV?n:Math.max(0,2*(n/2-(e+i)*o)/(1+o))}const cV=(t,e,n=2)=>t.x<e.x+e.width+n&&e.x<t.x+t.width+n&&t.y<e.y+e.height+n&&e.y<t.y+t.height+n;function lV(t,e,n=6,i=2){if(t.length<2)return!1;const o=t.map(t=>({angle:t.angle,p:rV(t.angle,e,t.width,t.height,n)})).sort((t,e)=>t.angle-e.angle);for(let t=0;t<o.length;t++){const e=o[(t+1)%o.length];if(e!==o[t]&&cV(o[t].p,e.p,i))return!0}return!1}function hV(t){const{angles:e,widths:n,lineHeight:i,width:o,height:r}=t,a=t.padding??6,s=Math.max(0,Math.min(o,r)/2)*(t.minRadiusShare??.5),c=aV(e.map((t,e)=>({angle:t,width:n[e],height:i})),o,r,a);return c>=s?{radius:c,labels:n.map(t=>({width:t,height:i,lines:1}))}:{radius:s,labels:e.map((t,e)=>{const r=sV(t,s,o,a);return n[e]<=r?{width:n[e],height:i,lines:1}:{width:r,height:2*i,lines:2}})}}function uV(t){const e=(180*(t-Math.PI/2)/Math.PI%360+360)%360;return Math.sin(t)<-1e-9?{rotate:e-180,anchor:"end"}:{rotate:e,anchor:"start"}}function dV(t,e,n,i,o=!0){const a=Math.max(0,Math.min(n,i)/2);if(!o||!e.length)return{radius:a,labels:[]};const c=t.schema.outerPadding,l=e.map((e,n)=>Jq(t,e.text,e.data,n)),h=e.map((t,e)=>r.textWidth(t.text,(t=>({"font-family":l[t].fontFamily,"font-size":l[t].fontSize,"font-weight":l[t].fontWeight}))(e))),u=Math.max(...l.map(t=>t.lineHeight)),d=Math.max(0,n-4),f=Math.max(0,i-4),m="number"==typeof c?Math.max(0,a-c):void 0,p=hV({angles:e.map(t=>t.angle),widths:h.map(t=>(t=>Math.max(t+2,12))("number"==typeof c?Math.min(t,c):t)),lineHeight:u+2,width:d,height:f}),g=m??p.radius,y=e.map((t,e)=>({angle:t.angle,width:p.labels[e].width,height:p.labels[e].height}));if(!lV(y,g)){const t=e.map((t,e)=>{const n=y[e],i=rV(t.angle,g,n.width,n.height);return{__d3plus__:!0,data:t.data,id:t.key,text:t.text,x:0,y:0,rotate:0,textAnchor:(r=Math.sin(t.angle),r>.3?"start":r<-.3?"end":"middle"),verticalAlign:(o=-Math.cos(t.angle),o<-.3?"bottom":o>.3?"top":"middle"),labelBounds:i};var o,r});return{radius:g,labels:t}}return function(t,{fonts:e,widths:n,innerW:i,innerH:o,fixed:r,outerPadding:a}){const c=Tq({labels:t.map((t,n)=>({text:t.text,angle:t.angle-Math.PI/2,lineHeight:e[n].lineHeight,i:n})),width:i,height:o,padding:6,measure:t=>n[t.i],wrap:(t,n,i)=>s.textWrap().fontFamily(e[t.i].fontFamily).fontSize(e[t.i].fontSize).fontWeight(e[t.i].fontWeight).lineHeight(e[t.i].lineHeight).width(n).height(e[t.i].lineHeight*i).maxLines(i)(t.text)}),l=r??c.radius,h=t.map((t,n)=>{const{rotate:i,anchor:o}=uV(t.angle),r=Math.max(12,"number"==typeof a?a:c.labels[n].wrapWidth),s=2*e[n].lineHeight,h="start"===o?6:-r-6;return{__d3plus__:!0,data:t.data,id:t.key,text:t.text,x:l*Math.sin(t.angle),y:-l*Math.cos(t.angle),rotate:i,textAnchor:o,verticalAlign:"middle",labelBounds:{x:h,y:-s/2,width:r,height:s},rotateAnchor:[-h,s/2]}});return{radius:l,labels:h}}(e,{fonts:l,widths:h,innerW:d,innerH:f,fixed:m,outerPadding:c})}function fV(t,e,n){if(!e.length)return[];const i=t.schema.axisConfig,o=Kx({data:e,label:t=>t.text,x:t=>t.x,y:t=>t.y,aes:()=>({}),rotate:t=>t.rotate,id:t=>`${n}-label-${t.id}`,labelBounds:t=>t.labelBounds,labelConfig:{...i.shapeConfig?.labelConfig??{},verticalAlign:t=>t.data?.verticalAlign??"middle"}});for(const t of o)t.interactive=!1;return o.length?[{type:"group",key:`${n}-labels`,interactive:!1,children:o}]:[]}function mV(t,e,n,i,o){return{rings:nV(t,e,n,i,o),labels:iV(t,e,n,i,o)}}function pV(t,e,n,i,o="sqrt"){const r=e[1]-e[0],a=Number.isFinite(t)&&r?(t-e[0])/r:0,s=Math.max(0,Math.min(1,a));return"linear"===o?n+s*(i-n):Math.sqrt(n*n+s*(i*i-n*n))}function gV(t,e=0,n=2*Math.PI){const i=Math.max(0,Math.floor(t)),o=i?n/i:0;return Array.from({length:i},(t,n)=>({startAngle:e+n*o,endAngle:e+(n+1)*o,angle:e+(n+.5)*o}))}function yV(t){const e=new Map;return t.map(({slot:t,value:n})=>{const i=e.get(t)??0,o=i+(Number.isFinite(n)&&n>0?n:0);return e.set(t,o),{slot:t,y0:i,y1:o}})}function xV(t,e,n){return t>0?t:e>0&&n>0?e/n:0}function bV(t,e,n=void 0){const i=Vq(t,e),[o,r]=n??[],a="number"==typeof o&&Number.isFinite(o),s="number"==typeof r&&Number.isFinite(r);if(!a&&!s)return i;const l=a?o:i.domain[0],h=s?r:i.domain[1];if(!(h>l))return i;const u=Array.isArray(e)?i.ticks.filter(t=>t>=l&&t<=h):c.scaleLinear().domain([l,h]).ticks(Math.max(1,Math.round(e)));return{domain:[l,h],ticks:u}}function _V(t,e){const n=Number("function"==typeof t?t(e):t);return!Number.isFinite(n)||n<=0?0:Math.min(n,.95*e)}function kV(t,e,n,i){const o=Math.max(0,Math.min(.95,i.inset)),r=t.endAngle-t.startAngle;return{innerRadius:e,outerRadius:n,startAngle:t.startAngle+r*o/2,endAngle:t.endAngle-r*o/2,padAngle:xV(i.padAngle,i.padPixel,Math.hypot(e,n))}}function vV(t,e,n){const i=t.schema.value,o=h.groups(e.map((t,e)=>({d:t,i:e})),t=>n(t.d,t.i)),r=new Map(o.map(([t],e)=>[t,e])),a=e.map((t,e)=>Number(i(t,e))),s=yV(e.map((t,e)=>({slot:r.get(n(t,e)),value:a[e]}))),c=o.map((t,e)=>Math.max(0,...s.filter(t=>t.slot===e).map(t=>t.y1)));return{bySlot:o,values:a,stack:s,tops:c}}function wV(t,e,n){return vV(t,e,n).tops}function MV(t,e){const{width:i,height:o}=kt(t),r=e.rows??t._filteredData??[],s=t.schema.aggs,{bySlot:c,values:l,stack:h,tops:u}=vV(t,r,e.slotOf),d=bV(u.concat(Bq(t)),t.schema.levels,t.schema.domain),f=(t=>(Number(t.schema.startAngle)||0)*Math.PI/180)(t),m=gV(c.length,f,e.sweep).map((t,e)=>({...t,key:c[e][0]})),p=dV(t,m.map((t,i)=>{const o=c[i][1].map(t=>t.d);return{key:t.key,text:e.slotLabel(t.key,o),angle:t.angle,data:1===o.length?o[0]:n.merge(o,s)}}),Math.max(0,i-4),Math.max(0,o-4)),g=Math.max(0,p.radius),y=_V(t.schema.innerRadius,g),x=t=>pV(t,d.domain,y,g,e.scale),b={inset:e.slotPadding,padAngle:Number(t.schema.padAngle)||0,padPixel:Number(t.schema.padPixel)||0},_=r.map((t,e)=>{const n=h[e],i=m[n.slot];return{__d3plus__:!0,data:t,i:e,slot:i.key,value:l[e],y0:n.y0,y1:n.y1,arc:kV(i,x(n.y0),x(n.y1),b)}}),k=m.map(t=>kV(t,y,g,b)),v=mV(t,d,g,x,e.key),w=Array.isArray(t._chartScene)?t._chartScene:t._chartScene=[];e.trackPaint&&w.push(function(t,e,n,i){return{type:"group",key:`${t}-tracks`,interactive:!1,children:n.map((n,o)=>({type:"path",key:`${t}-track-${e[o].key}`,interactive:!1,d:a.arcPath(n),arc:n,paint:i}))}}(e.key,m,k,e.trackPaint)),w.push(...v.rings,...fV(t,p.labels,e.key),...v.labels);const M={inner:y,outer:g,levels:d,scale:e.scale,slots:m,tracks:k};return t.ctx.polar=M,{wedges:_,frame:M}}function SV(t){const e=t.schema.metric;return"function"==typeof e?(t,n)=>`${e(t,n)}`:(e,n)=>t._ids(e,n).join("-")}const CV=(t,e)=>wV(t,e,SV(t)),$V=({viz:t})=>{const e=t.schema.metric,{wedges:n}=MV(t,{key:"polararea",slotOf:SV(t),slotLabel:(n,i)=>"function"!=typeof e&&i.length?t._drawLabel(i[0],0):n,scale:"linear"===t.schema.radialScale?"linear":"sqrt",slotPadding:0,sweep:2*Math.PI});return{shapeData:n}},AV=({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i="function"==typeof t.schema.metric;return Lq(t,n,"polararea",e=>{const n=t._drawLabel(e.data,e.i),o=d.formatAbbreviate(e.value,t.schema.locale);return i?`${n}, ${e.slot}, ${o}.`:`${n}, ${o}.`})},zV={name:"PolarArea",layoutStage:$V,emit:AV,insetRegion:Cp,chartTransform:t=>{const{width:e,height:n}=kt(t);return vt(t,e,n)},chartBodyRect:t=>{const e=t.ctx.polar?.outer??0;return{x:-e,y:-e,width:2*e,height:2*e}},facet:Eq(CV),ctx:{},fields:[{key:"discrete",default:"metric"},{key:"domain"},{key:"innerRadius",default:0},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"metric",coerce:t=>"function"==typeof t?t:"string"==typeof t?q(t):void 0},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"radialScale",default:"sqrt"},{key:"startAngle",default:0},{key:"value",default:I("value"),coerce:t=>"function"==typeof t?t:q(t)},{key:"legend",coerce:"const",factory:kE},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:zq},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Os(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>{const[e,n]=Dq(t);return{tbody:[[(n,i)=>{const o=t.schema.metric;return"function"==typeof o?`${o(n,i)}`:e()},n]]}}},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})}]};var DV=lx(zV);const LV=({viz:t})=>{const e=t._filteredData;if(!e)return{shapeData:[]};const i=t.schema.start,o=t.schema.end,a=t._id,s=t.schema.axisConfig,c="time"===s?.scale,l=e.map((t,e)=>({__d3plus__:!0,data:t,end:c?r.date(o(t,e)):o(t,e),i:e,id:a(t,e),start:c?r.date(i(t,e)):i(t,e)})).filter(t=>Number(t.end)-Number(t.start)>0).sort((t,e)=>Number(t.start)-Number(e.start));let u;if(t.schema.groupBy.length>1&&t._drawDepth>0){const e=[];for(let n=0;n<t._drawDepth;n++)e.push(e=>t.schema.groupBy[n](e.data,e.i));u=n.nestGroups(l,e)}else u=[{values:l}];const d=(t=>{let e=0;return t.forEach(t=>{let n=[];t.values.forEach(t=>{n=n.map(e=>!(!1!==e&&e<=t.start)&&e);const i=n.indexOf(!1);i<0?(t.lane=e+n.length,n.push(t.end)):(n[i]=t.end,t.lane=e+i)}),e+=n.length}),e})(u);return((t,e,n)=>{const i={domain:[h.min(e,t=>Number(t.start))??0,h.max(e,t=>Number(t.end))??0],height:t.schema.height-t._margin.top-t._margin.bottom,width:t.schema.width-t._margin.left-t._margin.right},o=tT(t,i),r=eT(t,{...i,transform:{x:t._margin.left,y:t._margin.top},key:"priestley-axis"}),a=E.scaleBand().domain(h.range(0,n,1).map(String)).paddingInner(t.schema.paddingInner).paddingOuter(t.schema.paddingOuter).rangeRound([t.schema.height-t._margin.bottom-o.height-o.padding,t._margin.top+o.padding]);t.ctx.xScale=r,t.ctx.yScale=a,t.ctx.bandWidth=a.bandwidth()})(t,l,d),{shapeData:l}},FV={name:"Priestley",layoutStage:LV,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=t.ctx.xScale,r=t.ctx.yScale,a=t.ctx.bandWidth,s=Hm(t,"Rect"),c=i.map((e,n)=>{const i=Pm(s.fill,e.data,n),c=Pm(s.stroke,e.data,n),l=Pm(s.strokeWidth,e.data,n),h=`${t._drawLabel(e.data,n)}, ${e.start} - ${e.end}.`,u=Math.abs(o(e.end)-o(e.start)),d=u>2?u-2:u,f=o(e.start)+(o(e.end)-o(e.start))/2-d/2,m=(r(String(e.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${e.id}-${n}`,transform:{x:f,y:m},x:0,y:-a/2,width:d,height:a,datum:e.data,paint:{fill:Tm(s,e.data,n,i),stroke:c,strokeWidth:l},aria:{label:h}}}),l=Kx({data:i,label:(e,n)=>t._drawLabel(i[n].data,n),x:(t,e)=>{const n=i[e];return o(n.start)+(o(n.end)-o(n.start))/2},y:(t,e)=>(r(String(i[e].lane))??0)+a/2,aes:(t,e)=>{const n=i[e],r=Math.abs(o(n.end)-o(n.start));return{width:r>2?r-2:r,height:a}},rotate:H(0),id:(t,e)=>`priestley-label-${i[e].id}-${e}`,labelBounds:(t,e,n)=>{const{width:i,height:o}=n;return{x:-i/2,y:-o/2,width:i,height:o}},labelConfig:{fontColor:n=>{const i=n.data??n,o=Pm(s.fill,i.data,i.i);return e.colorContrast("string"==typeof o?o:"rgb(255, 255, 255)",t.schema.colorDefaults)},fontResize:!1,textAnchor:"start",verticalAlign:"top",...jm(t,"Rect")}}),h=tw(s,c,t=>[i[t].data,t]);return[...c,...h,...l]},chartTransform:()=>{},setup:XP,ctx:{axis:(new zo).align("end").orient("bottom"),axisTest:(new zo).align("end").gridSize(0).orient("bottom")},fields:[{key:"paddingInner",default:.05},{key:"paddingOuter",default:.05},{key:"axisConfig",merge:!0,default:{scale:"time"}},...UP(),{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t.schema.start(e,n),o=t.schema.end(e,n);return`${t._drawLabel(e,n)}, ${i} - ${o}.`}})}]};var NV=lx(FV);function BV(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function EV(t,e,n){const i=Array.isArray(n)?n.map(String):[];return t.forEach((t,n)=>{const o=`${e(t,n)}`;i.includes(o)||i.push(o)}),i}function RV(t,e){return t.length>0&&`${e}`===t[0]?-1:1}function PV(t,e){return t.reduce((t,n,i)=>t+(BV(e(n,i))??0),0)}function TV(t,e,n){const i=new Map;return t.forEach((t,o)=>{const r=`${n(t,o)}`;i.set(r,(i.get(r)??0)+(BV(e(t,o))??0))}),i}function OV(t,e){const{category:n,side:i,value:o,comparison:r,frame:a}=e,s=new Map,c=new Map;return t.forEach((t,e)=>{const l=`${a?a(t,e):""}\0${n(t,e)}\0${i(t,e)}`;s.set(l,(s.get(l)??0)+Math.abs(BV(o(t,e))??0)),r&&c.set(l,(c.get(l)??0)+Math.abs(BV(r(t,e))??0))}),Math.max(0,...s.values(),...c.values())}function WV(t){return t>0?[-t,t]:[-1,1]}function HV(t,e=0){const n=Math.abs(t);return n<=2*e?0:n}function jV(t,e=()=>0){return n=>t("number"==typeof n?HV(n,e()):n)}function IV(t,e,n){const i=t.slice().sort((t,e)=>t.y-e.y);if(!i.length)return[];const o=n/2,r=[[e,i[0].y-o]];for(const t of i)r.push([t.x,t.y-o],[t.x,t.y+o]);return r.push([e,i[i.length-1].y+o]),r}function GV(t,e){const n=Array.from(new Set(t)).sort((t,e)=>t-e);let i=1/0;for(let t=1;t<n.length;t++)i=Math.min(i,n[t]-n[t-1]);return Number.isFinite(i)?i:e}function qV(t){return Array.isArray(t)?t.map(Number):"string"==typeof t&&t.trim()?t.trim().split(/[\s,]+/).map(Number):"number"==typeof t?[t]:void 0}function VV(t,e,n){return"function"==typeof t?t(e,n):t}function YV(t,e){const{left:n,right:i,top:o,height:r}=e,a=[[n,f.clamp(e.inner[0],n,i)],[f.clamp(e.inner[1],n,i),i]];return t.slice(0,2).map((t,e)=>({text:t,x:a[e][0],y:o,width:Math.max(0,a[e][1]-a[e][0]),height:r}))}function KV(t,e,n){const i=t.slice(),o=i.findIndex(t=>t.key===Jz);if(o>=0&&e.length){const t=i[o];"group"===t.type&&(i[o]={...t,children:[...t.children,...e]})}else i.push(...e);return i.push(...n),i}function UV(t,e){const n=t._xFunc,i=t._yFunc,o=t._plotArea;if(!(n&&i&&o&&t._filteredData?.length))return{outlines:[],overlays:[]};const r=e.comparison?function(t){const{sides:e,categories:n,data:i,category:o,side:r,comparison:a,divisor:s,x:c,y:l,fallbackStep:h,config:u}=t,d=t.inset??0,f=GV(n.map(t=>l(t)),h);return e.flatMap((t,h)=>{const m=new Map;if(i.forEach((e,n)=>{if(`${r(e,n)}`!==t)return;const i=BV(a(e,n));if(void 0===i)return;const c=`${o(e,n)}`;m.set(c,(m.get(c)??0)+Math.abs(i)/(s||1))}),!m.size)return[];const p=RV(e,t),g=c(p*d),y=n.map(t=>({y:l(t),x:c(p*((m.get(`${t}`)??0)+d))})),x={fill:"none",stroke:VV(u.stroke,t,h),strokeWidth:VV(u.strokeWidth,t,h),strokeOpacity:VV(u.strokeOpacity,t,h)},b=qV(VV(u.strokeDasharray,t,h));return b&&(x.strokeDasharray=b),[{type:"line",key:`pyramid-comparison-${h}`,points:IV(y,g,f),curve:"linear",paint:x,interactive:!1,interactionGroup:"axis"}]})}({sides:e.sides,categories:t._yAxis?.domain()??[],data:t._filteredData,category:t._y,side:e.side,comparison:e.comparison,divisor:e.divisor,x:n,y:i,fallbackStep:o.height,config:t.schema.comparisonConfig,inset:e.inset}):[],a=[n(-e.inset),n(e.inset)],s=t._plotInsetTop??0,c=e.showTitles&&s>0?function(t,e,n){return t.renderMode("compute").select(void 0).data(e.map((t,e)=>({...t,id:`pyramid-side-${e}`}))).config(n).render(),[{type:"group",key:"pyramid-side-titles",interactionGroup:"axis",children:t.toScene().children??[]}]}(e.titleBox,YV(e.labels,{left:o.x,right:o.x+o.width,inner:a,top:t._margin.top-(t._chartTransform?.y??t._margin.top),height:s}),{...t.schema.fontFamily?{fontFamily:t.schema.fontFamily}:{},...t.schema.sideTitleConfig}):[];return{outlines:r,overlays:[...e.gutter?e.gutter(a):[],...c]}}function XV(t,e,n){const{outlines:i,overlays:o}=UV(t,n);return function(t,e,n){if(!e.length&&!n.length)return t;const i=t.root.children.find(t=>"viz-chart-cells"===t.key),o=i&&"children"in i?i.children.find(t=>"viz-zoom"===t.key):void 0,r=o&&"children"in o?o.children.find(t=>"viz-chart-body"===t.key):void 0;return r&&"group"===r.type?(r.children=KV(r.children,e,n),t):t}(e,i,o)}function ZV(t){return 1e-9*(t>0?t:1)}function QV(t){return(e,n)=>{YS(e,n);const i=t();if(i)for(const t of e)for(const e of t){const t=e[0]<0?-i:i;e[0]+=t,e[1]+=t}}}function JV(t,e,n){const i=i=>{const o=t[i];return"function"==typeof o?o(e,n):o},o=i("fontFamily")??s.fontFamily;return{family:s.fontFamilyStringify(o),size:Number(i("fontSize"))||12,weight:i("fontWeight")??400,padding:Number(i("padding"))||0}}function tY(t,e,n=r.textWidth){let i=0,o=0;return t.forEach((t,r)=>{const a=e[r],s=n(t,{"font-family":a.family,"font-size":a.size,"font-weight":a.weight});i=Math.max(i,s),o=Math.max(o,a.padding)}),Math.ceil(i+2*o)}function eY(t,e){const n=t.map(()=>!1);let i;t.forEach((t,o)=>{(void 0===i||Math.abs(t-i)>=e)&&(n[o]=!0,i=t)});const o=t.length-1;if(o>0&&!n[o]){n[o]=!0;for(let i=o-1;i>=0&&Math.abs(t[o]-t[i])<e;i--)n[i]=!1}return n}function nY(t){return{...t._yAxis?.shapeConfig()?.labelConfig??{},...t._yConfig?.shapeConfig?.labelConfig??{}}}function iY(t,e){const n=t._yConfig?.tickFormat;return"function"==typeof n?`${n(e)}`:`${e}`}const oY=t=>1.2*t.size+2*t.padding;function rY(t,e,n,i,o){if("center"!==t)return{x:{...o.x},y:{...o.y}};return{x:{break:[[-e,e],...Array.isArray(i)?Array.isArray(i[0])?i:[i]:[]],breakConfig:{gap:n,lines:!1,mask:!1,size:0,space:n,stroke:"transparent"}},y:{barConfig:{stroke:"transparent"},tickSize:0,ticks:[]}}}const aY=new WeakMap,sY=t=>t.ctx.pyramid,cY=t=>t.schema.groupBy[0],lY=(t,e)=>`${d.formatAbbreviate(100*e,t.schema.locale)}%`;function hY(t){const e=sY(t),n=function(t){return(e,n)=>{const i=sY(t),o=i.value(e,n),r=BV(o);if(void 0===r)return o;const a=t.schema.percent?i.total?Math.abs(r)/i.total:0:Math.abs(r);return RV(i.sides,cY(t)(e,n))*a}}(t);e.value=t._x,Object.defineProperty(t,"_x",{configurable:!0,enumerable:!0,get:()=>n,set:t=>{t!==n&&(e.value=t)}})}function uY(t,e){const n=t._xConfig,i=n.tickFormat;void 0===i||i===e.tickFormat?(n.tickFormat=e.tickFormat=jV(function(t){return t.schema.percent?e=>lY(t,e):e=>d.formatAbbreviate(e,t.schema.locale)}(t),()=>e.inset),e.wrapped.add(n.tickFormat)):"function"!=typeof i||e.wrapped.has(i)||(n.tickFormat=jV(i,()=>e.inset),e.wrapped.add(n.tickFormat))}function dY(t,e,n){const i=t._xConfig,o=void 0!==i.domain&&(r=i.domain,a=e.domain,Array.isArray(r)&&Array.isArray(a)&&r.length===a.length&&r.every((t,e)=>t===a[e]));var r,a;if(void 0!==i.domain&&!o)return;if(!t.schema.symmetric||mg(t,"x"))return o&&delete i.domain,void(e.domain=void 0);i.domain=e.domain=WV(n+e.inset);const s=t._plotAxisDefaults??{};t._plotAxisDefaults={...s,x:{...s.x,rounding:"outside"}}}function fY(t,e,n){var i;const o=t.schema.categoryPosition;(i=e).restore??(i.restore=function(t){return{y:{barConfig:{...t._yAxis.barConfig()},tickSize:t._yAxis.tickSize()},x:{breakConfig:{...t._xAxis.breakConfig()}}}}(t));const r="center"===o;e.inset=r?ZV(n):0;let a=0;if(r){const e=function(t){const e=t._y;return Array.from(new Set(t._data.map((t,n)=>e(t,n))))}(t),n=nY(t),i=e.map((t,e)=>JV(n,t,e));a=tY(e.map(e=>iY(t,e)),i)}t._plotAxisDefaults=rY(o,e.inset,a,t.schema.xBreak,e.restore)}function mY(t){const e=sY(t);e.sides=EV(t._data,cY(t),t.schema.sides);const n=t._legendData||t._filteredData||[];e.total=PV(n,e.value);const i=t.schema.comparison;e.comparisonTotal=i?PV(n,i):0,uY(t,e);const o=function(t,e){const n=!!t._axisPersist,i=n?t._data:t._filteredData,o=n&&t.schema.time?t.schema.time:void 0,r=(e,n)=>{if(!t.schema.percent)return e;const r=o?TV(i,e,o):void 0;return(t,i)=>{const a=r?r.get(`${o(t,i)}`)??0:n,s=BV(e(t,i));return void 0!==s&&a?s/a:0}},a=t.schema.comparison;return OV(i,{category:t._y,side:cY(t),value:r(e.value,e.total),comparison:a?r(a,e.comparisonTotal):void 0,frame:o})}(t,e);fY(t,e,o),dY(t,e,o),function(t,e){const n=t._xConfig,i=t._xTitle;t.schema.percent?void 0!==n.title&&n.title!==i&&n.title!==e.title||(n.title=e.title=t.schema.translate("Percent of Total")):void 0!==e.title&&(n.title===e.title&&(n.title=i),e.title=void 0)}(t,e),t._plotInsetTop=function(t){if(!t.schema.sideTitles)return 0;const e=t.schema.sideTitleConfig,n="number"==typeof e.fontSize?e.fontSize:14,i="number"==typeof e.padding?e.padding:0;return Math.ceil(1.2*n+2*i)}(t)}function pY(t,e){const n=cY(t);return e.map(e=>{const i=t._data.findIndex((t,i)=>`${n(t,i)}`===e);return i>=0?t._drawLabel(t._data[i],i,0):e})}function gY(t){const e=sY(t);return{sides:e.sides,labels:pY(t,e.sides),side:cY(t),comparison:t.schema.comparison,divisor:t.schema.percent?e.comparisonTotal:1,titleBox:e.titleBox,showTitles:!!t.schema.sideTitles,inset:e.inset,gutter:e.inset?n=>function(t,e,n){const i=t._yFunc,[o,r]=n;if(!(i&&t._yAxis&&r>o))return[];const a=t._yAxis.domain()??[],s=nY(t),c=a.map(t=>i(t)),l=a.map((t,e)=>JV(s,t,e)),h=eY(c,Math.max(0,...l.map(oY))),u=GV(c,t._plotArea?.height??0);return function(t,e,n){return t.renderMode("compute").select(void 0).data(e).config({fontColor:n,fontFamily:t=>t.font.family,fontSize:t=>t.font.size,fontWeight:t=>t.font.weight,textAnchor:"middle",verticalAlign:"middle"}).render(),[{type:"group",key:"pyramid-categories",interactionGroup:"axis",children:t.toScene().children??[]}]}(e,a.flatMap((e,n)=>{if(!h[n])return[];const i=Math.max(u,1.5*l[n].size);return[{id:`pyramid-category-${n}`,text:iY(t,e),x:o,y:c[n]-i/2,width:r-o,height:i,font:l[n]}]}),"string"==typeof s.fontColor?s.fontColor:Ws(t))}(t,e.labelBox,n):void 0}}const yY={name:"Pyramid",paintDriven:!0,thresholdFunction:(t,e)=>e,defaults:{groupPadding:1},setup:t=>{t.ctx.pyramid={value:t._x,sides:[],total:0,comparisonTotal:0,wrapped:new WeakSet,titleBox:new Ir,inset:0,labelBox:new Ir},hY(t),t._stackOffset=QV(()=>sY(t).inset),t._stackGroup=()=>"group",t._stackOrder=_I((e,n)=>t._ids(e,n).slice(1,t._drawDepth+1).join("_")),t.schema.color=(e,n)=>{const i=t.schema.groupBy;return i[Math.max(0,Math.min(t._drawDepth??0,i.length-1))](e,n)},t.schema.shapeConfig.Bar={...t.schema.shapeConfig.Bar,label:!1},t.schema.shapeConfig.ariaLabel=(e,n)=>{const i=t._xConfig.tickFormat;return`${t._drawLabel(e,n)}, ${t._y(e,n)}: ${i(t._x(e,n))}.`};const e=t._preDraw.bind(t);t._preDraw=()=>{e(),mY(t)}},decorateScene:(t,e)=>t._facetPanels?e:XV(t,e,gY(t)),facet:{scene:(t,e)=>function(t,e,n){const{outlines:i,overlays:o}=UV(t,n);return i.length||o.length?KV(e,i,o):e}(t,e,gY(t))},ctx:{},fields:[{key:"baselineBreak",default:!1},{key:"categoryPosition",default:"center"},{key:"comparison",coerce:t=>{if("string"!=typeof t)return t||void 0;const e=q(t);return aY.set(e,t),e}},{key:"comparisonConfig",merge:!0,factory:t=>({stroke:()=>Ws(t),strokeDasharray:"4 3",strokeOpacity:1,strokeWidth:1.5})},{key:"discrete",default:"y"},{key:"percent",default:!1},{key:"sideTitles",default:!0},{key:"sideTitleConfig",merge:!0,factory:t=>({fontColor:()=>Ws(t),fontSize:14,fontWeight:600,padding:2,textAnchor:"middle",verticalAlign:"middle"})},{key:"sides"},{key:"stacked",default:!0},{key:"symmetric",default:!0},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>function(t,e,n){const i=sY(t),o=BV(i.value(e,n));if(void 0===o)return[];const r=[],a=!!t.schema.percent;if(a){const e=t._xKey;r.push(["string"==typeof e?e:t.schema.translate("Value"),d.formatAbbreviate(Math.abs(o),t.schema.locale)])}else i.total&&r.push([t.schema.translate("Percent of Total"),lY(t,Math.abs(o)/i.total)]);const s=t.schema.comparison,c=s?BV(s(e,n)):void 0;if(s&&void 0!==c){const e=aY.get(s)??t.schema.translate("Comparison");r.push([e,a?lY(t,i.comparisonTotal?Math.abs(c)/i.comparisonTotal:0):d.formatAbbreviate(Math.abs(c),t.schema.locale)])}return r}(t,e,n)})}]};var xY=lx(yY,eL);const bY=2*Math.PI,_Y=({viz:t})=>{const{width:e,height:i}=kt(t),r=t.schema.metric,a=t.schema.value,s=t._filteredData,c=h.groups(s,r),l=h.groups(s,t._id,r),u=l.flatMap(([,t])=>t.map(([,t])=>h.sum(t,(t,e)=>a(t,e)))),d=Vq(u,t.schema.levels),{domain:f}=d;if(!u.length||f[0]===f[1])return t.ctx.groupData=[],t.ctx.pathConfig={},{shapeData:[]};const{radius:m,polarAxis:p}=tV(t,c,e,i);(Array.isArray(t._chartScene)?t._chartScene:t._chartScene=[]).push(...nV(t,d,m),...eV(t,p),...iV(t,d,m));const g=c.length,y=l.map(([e,i])=>{const o=i.map(([,t],e)=>{const n=Yq(h.sum(t,(t,e)=>a(t,e)),f,m),i=bY/g*e;return{x:n*Math.cos(i),y:n*Math.sin(i)}}),r=`M ${o[0].x} ${o[0].y} ${o.map(t=>`L ${t.x} ${t.y}`).join(" ")} L ${o[0].x} ${o[0].y}`,s=t.schema.aggs;return{__d3plus__:!0,arr:i.map(([,t])=>n.merge(t,s)),id:e,points:o,d:r,data:n.merge(i.map(([,t])=>n.merge(t,s)),s)}}),x=((t,e,n)=>{const i=Hm(t,"Path"),r=Object.keys(i.on??{});i.on={};for(const a of r)i.on[a]=(i,r,s,c)=>{const l=i.points.map(t=>t.x+e/2),u=i.points.map(t=>t.y+n/2),d=o.pointer(c,t._select.node()),f=l.map(t=>Math.abs(t-d[0])),m=u.map(t=>Math.abs(t-d[1])),p=f.map((t,e)=>t+m[e]);t.schema.on[a].call(t,i.arr[p.indexOf(h.min(p))],r,s,c)};return i})(t,e,i);return t.ctx.groupData=y,t.ctx.pathConfig=x,{shapeData:y}},kY={name:"Radar",layoutStage:_Y,emit:({viz:t})=>{const e=t.ctx.groupData,n=t.ctx.pathConfig;if(!e||!n||!e.length)return[];const i=[];for(let o=0;o<e.length;o++){const r=e[o],a=r.data??r,s=Om(n,a,o);i.push({type:"path",key:`radar-${r.id}`,d:r.d,datum:a,paint:s,aria:{label:`${t._drawLabel(a,o)}.`}})}const o=tw(n,i,t=>[e[t].data??e[t],t]);return[...i,...o]},chartTransform:t=>{const{width:e,height:n}=kt(t);return vt(t,e,n)},chartBodyRect:t=>{const{width:e,height:n}=kt(t);return{x:-e/2,y:-n/2,width:e,height:n}},facet:{aspect:1},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabelConfig",default:{},merge:!0},{key:"levelLabels",default:!0},{key:"levels",default:6},{key:"metric",default:I("metric"),coerce:t=>"function"==typeof t?t:q(t)},{key:"outerPadding",default:"auto"},{key:"shape",default:H("Path"),coerce:"const"},{key:"value",default:I("value"),coerce:t=>"function"==typeof t?t:q(t)},{key:"axisConfig",merge:!0,factory:t=>({barConfig:{stroke:()=>Ws(t),strokeWidth:1},gridConfig:{stroke:()=>Hs(t),strokeWidth:1},shapeConfig:{fill:H("none"),labelConfig:{fontColor:()=>Ws(t),fontResize:!1,padding:0,textAnchor:t=>t.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>Ws(t),strokeWidth:H(1)}})}]};var vY=lx(kY);function wY(t,e,n,i){const o=Math.max(0,Math.floor(t));if(!(o&&n>e))return[];const r=(n-e)/o,a=Math.max(0,Math.min(.95,i));return Array.from({length:o},(t,e)=>{const i=n-e*r;return{inner:i-r*(1-a),outer:i}})}function MY(t,e,n,i=0){if(!(t>0&&e>0))return 0;let o=e;return n<Math.PI/2&&(o=Math.min(o,t*Math.tan(Math.max(0,n)))),Math.max(0,o-i)}function SY(t,e,n){const i=Math.sin(t),o=-Math.cos(t),r=i-n*Math.cos(t),a=o-n*Math.sin(t);return NL(FL(t,e),{x0:Math.min(i,r),x1:Math.max(i,r),y0:Math.min(o,a),y1:Math.max(o,a)})}const CY=(t,e)=>Pm((t.schema.axisConfig.shapeConfig?.labelConfig??{}).fontColor,e,0)??Ws(t);function $Y(t){const e=Number(t.schema.maxAngle??270)||270;return Math.max(1,Math.min(360,e))*Math.PI/180}const AY=Math.PI/6;function zY(t){return 2*Math.PI-$Y(t)>=AY-1e-9}function DY(t,e){const n=zY(t);return e.map((e,i)=>{const o=hE(t,e,i);return"along"===o||"inside"!==o&&"outside"!==o&&!n})}function LY(t){if("angle"===t.schema.discrete)return!1;const e=t._filteredData??[];return e.length>1&&DY(t,e).every(Boolean)}function FY(t,e){const n=t.schema.axisConfig.shapeConfig?.labelConfig?.fontSize;return"number"==typeof n?Math.min(n,.9*e):Math.max(8,Math.min(14,.6*e))}function NY(t,e,n){const i=FY(t,n);return e.map((e,n)=>{const o=t._drawLabel(e,n),a=Jq(t,o,e,n),s=r.textWidth(o,{"font-family":a.fontFamily,"font-size":i,"font-weight":a.fontWeight});return{d:e,i:n,text:o,font:a,size:i,width:s}})}function BY(t,e){const{width:n,height:i}=kt(t),o=t.schema.value,s=e.map((t,e)=>Number(o(t,e))),c=(Number(t.schema.startAngle)||0)*Math.PI/180,l=c+$Y(t),h=zY(t),u=DY(t,e),d=t.schema.ticks,f="number"==typeof d?d:zL(c,l),m=AL(s.concat(Bq(t)),[],t.schema.domain,f),p=DL(m,d,!1,f).major,g=t=>$L(t,m,c,l),y=function(t,e,n){const i=t.schema.tickFormat,o={},a=e.map((e,a)=>{const s=`${i(e)}`,c=Jq(t,s,o,a),l={"font-family":c.fontFamily,"font-size":c.fontSize,"font-weight":c.fontWeight};return{t:e,text:s,font:c,angle:n(e),width:r.textWidth(s,l)}}),s=CY(t,o);return{margin:a.length?Math.max(...a.map(t=>Math.max(t.width,t.font.fontSize)))+6:0,nodes:t=>{const e=a.map(e=>rV(e.angle,t,e.width,e.font.fontSize)),n=e.length,i=n>1&&cV(e[0],e[n-1])?n-1:n;return a.slice(0,i).map((t,n)=>{const i=e[n];return{type:"text",key:`radialbar-tick-${n}`,interactive:!1,x:0,y:0,transform:{x:i.x+i.width/2,y:i.y+i.height/2},lines:[{text:t.text,x:0,y:0,width:t.width}],font:{family:t.font.fontFamily,size:t.font.fontSize,weight:t.font.fontWeight,anchor:"middle",baseline:"middle"},paint:{fill:s}}})}}}(t,p,g),{outer:x,cx:b,cy:_}=function(t,e,n,i){const{width:o,height:r,margin:a,start:s,end:c}=i,l=Math.max(0,o-2*a),h=Math.max(0,r-2*a),u=Number(t.schema.trackPadding)||0,d=t=>BL(l,h,SY(s,c,t));let f=d(0);const m=e.some((t,e)=>!n[e]);for(let i=0;i<2&&m&&f.radius>0;i++){const i=_V(t.schema.innerRadius,f.radius),o=wY(e.length,i,f.radius,u)[0];f=d((Math.max(0,...NY(t,e,o.outer-o.inner).filter((t,e)=>!n[e]).map(t=>t.width))+6)/f.radius)}return{outer:f.radius,cx:f.cx-l/2,cy:f.cy-h/2}}(t,h?e:[],u,{width:Math.max(0,n-4),height:Math.max(0,i-4),margin:y.margin,start:c,end:l}),k=_V(t.schema.innerRadius,x),v={inner:k,outer:x,domain:m,start:c,end:l,ticks:p,cx:b,cy:_},w=wY(e.length,k,x,Number(t.schema.trackPadding)||0),M=g(Math.max(m[0],Math.min(m[1],0))),S=e.map((e,n)=>{const i=g(s[n]);return{__d3plus__:!0,data:e,i:n,slot:t._ids(e,n).join("-"),value:s[n],y0:0,y1:s[n],arc:{innerRadius:w[n].inner,outerRadius:w[n].outer,startAngle:Math.min(M,i),endAngle:Math.max(M,i)}}}),C=Array.isArray(t._chartScene)?t._chartScene:t._chartScene=[];return!1!==t.schema.track&&C.push(function(t,e,n,i){const o=t.schema.trackConfig??{};return{type:"group",key:"radialbar-tracks",interactive:!1,children:e.map((e,r)=>{const s={innerRadius:n[r].inner,outerRadius:n[r].outer,startAngle:i.start,endAngle:i.end};return{type:"path",key:`radialbar-track-${t._ids(e,r).join("-")}`,interactive:!1,d:a.arcPath(s),arc:s,paint:Om(o,e,r)}})}}(t,e,w,v)),C.push(...function(t,e,n){const i=Uq({},t.schema.axisConfig.gridConfig),o=e.ticks.map((t,o)=>{const r=n(t),[a,s]=[Math.sin(r),-Math.cos(r)];return{type:"path",key:`radialbar-grid-${o}`,interactive:!1,d:`M${e.inner*a},${e.inner*s}L${e.outer*a},${e.outer*s}`,paint:Zq(i,{value:t,r:e.outer},o)}});return o.length?[{type:"group",key:"radialbar-grid",interactive:!1,children:o}]:[]}(t,v,g)),p.length&&C.push({type:"group",key:"radialbar-ticks",interactive:!1,children:y.nodes(x)}),h&&C.push(...function(t,e,n,i,o){const r=2*Math.PI-(n.end-n.start),a=i.length?i[0].outer-i[0].inner:0,s=[];if(NY(t,e,a).forEach(({d:e,i:a,text:c,font:l,size:h})=>{if(o[a])return;const u=i[a],d=(u.inner+u.outer)/2,f=MY(d,n.outer,r,6);if(h<6||f<2*h)return;const m=lF(c,l.fontFamily,h,f,6,l.fontWeight);s.push({type:"text",key:`radialbar-label-${t._ids(e,a).join("-")}`,interactive:!1,x:0,y:0,transform:{x:-6,y:-d},lines:[{text:m.text,x:0,y:0,width:m.width}],font:{family:l.fontFamily,size:m.size,weight:l.fontWeight,anchor:"end",baseline:"middle"},paint:{fill:CY(t,e)}})}),!s.length)return[];const c=180*n.start/Math.PI;return[{type:"group",key:"radialbar-labels",interactive:!1,transform:c?{rotate:c}:void 0,children:s}]}(t,e,v,w,u)),t.ctx.polar=v,{wedges:S,frame:v}}function EY(t){const e=(t._filteredData??[]).slice(),n=t.schema.sort;return"function"==typeof n?e.sort(n):e}const RY=t=>(e,n)=>t._ids(e,n).join("-"),PY=(t,e)=>{if("angle"===t.schema.discrete)return wV(t,e,RY(t));const n=t.schema.value;return e.map((t,e)=>Number(n(t,e)))},TY=({viz:t})=>{const e=EY(t);if("angle"===t.schema.discrete){const n=Number(t.schema.maxAngle??360)||360,i=t.schema.trackConfig??{},{wedges:o}=MV(t,{key:"radialbar",rows:e,slotOf:RY(t),slotLabel:(e,n)=>n.length?t._drawLabel(n[0],0):"",scale:"linear",slotPadding:Number(t.schema.trackPadding)||0,sweep:Math.max(1,Math.min(360,n))*Math.PI/180,trackPaint:!1!==t.schema.track&&e.length?Om(i,e[0],0):void 0});return{shapeData:o}}const{wedges:n}=BY(t,e);return{shapeData:n}};function OY(t,e,n,i){const o=t.outerRadius-t.innerRadius,r=Math.min(3,(o-i)/2);if(r<0)return null;const a=(t.innerRadius+t.outerRadius)/2-i/2;if(!(a>0))return null;const s=(n(i)+2*nE(r,i))/a+1e-6,c=e=>sE({...t,startAngle:e,endAngle:e+s},n,{fontMin:i,fontMax:i,padding:r,minRadius:0,truncate:!1});if(t.endAngle-t.startAngle>=s){const e=c(t.startAngle);if(e)return{fit:e,inBar:!0}}if(t.endAngle+s<=e+1e-9){const e=c(t.endAngle);if(e)return{fit:e,inBar:!1}}return null}function WY(t,n,i){const o=n.map(t=>t.data),r=DY(t,o),a=t._alongStats;if(a&&(a.series+=n.length,a.requested+=r.filter(Boolean).length),!r.some(Boolean))return[];const s=n.length?n[0].arc.outerRadius-n[0].arc.innerRadius:0,c=NY(t,o,s),l=Hm(t,"Path"),h=t.schema.trackConfig??{},u=jm(t,"Path").fontColor,d=[];n.forEach((n,o)=>{const a=c[o];if(!r[o]||!a.text)return;const s={fontFamily:a.font.fontFamily,fontWeight:a.font.fontWeight},f=OY(n.arc,i.end,HB(a.text,s),a.size);if(!f)return;const m=f.inBar?Om(l,n.data,n.i).fill:!1===t.schema.track?void 0:Om(h,n.data,n.i).fill,p=Pm(u,n.data,n.i),g="string"==typeof p?p:"string"==typeof m?e.colorContrast(m,t.schema.colorDefaults):Ws(t);d.push({key:`radialbar-label-curved-${t._ids(n.data,n.i).join("-")}`,text:a.text,fit:f.fit,color:g,datum:n.data,index:n.i})});const f=c[0]?.font,m=IB(t,d,f?{fontFamily:f.fontFamily,fontWeight:f.fontWeight}:{});return a&&(a.placed+=m.length),m}const HY=({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i="angle"===t.schema.discrete,o=t.ctx.polar;return[...n.map((e,n)=>{const r=i?{...o.tracks[n],padAngle:0}:{innerRadius:e.arc.innerRadius,outerRadius:e.arc.outerRadius,startAngle:o.start,endAngle:o.end};return{type:"path",key:`radialbar-${t._ids(e.data,e.i).join("-")}-${e.slot}::hit`,d:a.arcPath(r),datum:e.data,index:e.i,paint:{fill:"transparent"}}}),...Lq(t,n,"radialbar",e=>`${t._drawLabel(e.data,e.i)}, ${d.formatAbbreviate(e.value,t.schema.locale)}.`),...i?[]:WY(t,n,o)]},jY={name:"RadialBar",layoutStage:TY,emit:HY,insetRegion:Cp,setup:t=>{t._defaultLegend=t.schema.legend,t._alongLabelsPossible=LY},chartTransform:t=>{const{width:e,height:n}=kt(t),i=vt(t,e,n),o=t.ctx.polar;return{x:(i.x??0)+(o?.cx??0),y:(i.y??0)+(o?.cy??0)}},chartBodyRect:t=>{const e=t.ctx.polar?.outer??0;return{x:-e,y:-e,width:2*e,height:2*e}},facet:Eq(PY),ctx:{},fields:[{key:"discrete",default:"radius"},{key:"domain"},{key:"innerRadius",default:t=>t/4},{key:"levelFormat"},{key:"levelLabelAngle",default:0},{key:"levelLabels",default:!0},{key:"levels",default:4},{key:"maxAngle"},{key:"outerPadding",default:"auto"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"sort",factory:t=>(e,n)=>{const i=t.schema.value;return i(n)-i(e)}},{key:"startAngle",default:0},{key:"tickFormat",factory:t=>e=>d.formatAbbreviate(e,t.schema.locale)},{key:"ticks"},{key:"track",default:!0},{key:"trackPadding",default:.25},{key:"value",default:I("value"),coerce:t=>"function"==typeof t?t:q(t)},{key:"legend",coerce:"const",factory:t=>kE(t,t=>"angle"===t.schema.discrete||zY(t))},{key:"levelLabelConfig",default:{},merge:!0},{key:"axisConfig",merge:!0,factory:t=>ct(zq(t),{gridConfig:{stroke:()=>!1===t.schema.track?Hs(t):Os(t)}})},{key:"trackConfig",merge:!0,factory:t=>({fill:()=>ZT(t).track})},{key:"shapeConfig",merge:!0,factory:t=>({stroke:()=>Os(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[Dq(t)]})}]};var IY=lx(jY);const GY=2*Math.PI,qY=({viz:t})=>{const{rowValues:e,columnValues:n,shapeData:i}=AI.bind(t)(t._filteredData),{width:o,height:r}=kt(t);if(!e.length||!n.length)return t.ctx.radialMatrixWidth=o,t.ctx.radialMatrixHeight=r,{shapeData:[]};t.ctx.radialMatrixWidth=o,t.ctx.radialMatrixHeight=r;const a=100,s=(h.min([r-100,o-200])??0)/2,c=n.slice().reverse();c.unshift(c.pop());const l=c.length,u=c.map((t,e)=>{const n=e/l*GY,i=Math.round(180*n/Math.PI),o=Math.floor((i+90)/90%4+1),r=[0,180].includes(i)?-50:[2,3].includes(o)?-100:0,a=[90,270].includes(i)?-25:[2,1].includes(o)?-50:0;return{key:t,angle:i,quadrant:o,radians:n,x:s*Math.sin(n+Math.PI)+r,y:s*Math.cos(n+Math.PI)+a}}),d=t.schema.columnConfig;((t,e,n,i,o)=>{const r=t.ctx.columnLabels;r.renderMode("compute").select(void 0).data(e).x(t=>t.x).y(t=>t.y).text(t=>t.key).width(n).height(i).config(o).render();const a=r.toScene();var s;a&&((s=t)._chartScene||(s._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:a.children??[]})})(t,d.labels instanceof Array?u.filter(t=>d.labels.includes(t.key)):u,a,50,d.shapeConfig?.labelConfig);const f=(0,t.schema.innerRadius)(s),m=(s-f)/e.length,p=u.length>1?u[1].radians-u[0].radians:GY,g=e.slice().reverse(),y=new Map;g.forEach((t,e)=>y.set(t,e));const x=new Map;n.forEach((t,e)=>x.set(t,e));const b=t.schema.cellPadding,_=R.arc().padAngle(b/s).innerRadius(t=>f+(y.get(t.row)??0)*m+b/2).outerRadius(t=>f+((y.get(t.row)??0)+1)*m-b/2).startAngle(t=>u[x.get(t.column)??0].radians-p/2).endAngle(t=>u[x.get(t.column)??0].radians+p/2);return t.ctx.arcData=_,{shapeData:i}},VY=(t,e)=>`${t}`.localeCompare(`${e}`),YY={name:"RadialMatrix",layoutStage:qY,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=t.ctx.arcData,o=Hm(t,"Path"),r=t.schema.colorScale,a=n.map((e,n)=>{const a=Pm(o.fill,e,n),s=Pm(o.stroke,e,n),c=Pm(o.strokeWidth,e,n),l=r?`, ${r(e.data??e,n)}`:"";return{type:"path",key:`rm-${t._ids(e,n).join("-")}`,d:i(e),datum:e,paint:{fill:Tm(o,e,n,a),stroke:s,strokeWidth:c},aria:{label:`${e.row}, ${e.column}${l}.`}}});return[...a,...tw(o,a,t=>[n[t],t])]},chartTransform:t=>vt(t,t.ctx.radialMatrixWidth,t.ctx.radialMatrixHeight),chartBodyRect:t=>{const e=t.ctx.radialMatrixWidth??0,n=t.ctx.radialMatrixHeight??0;return{x:-e/2,y:-n/2,width:e,height:n}},setup:t=>{const e=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(n,i,o,r)=>{if(e(n,i,o,r),Ls(o)||Ls(n))return;const a=Jt.bind(t)("row",n,i),s=Jt.bind(t)("column",n,i);t.hover((e,n)=>Jt.bind(t)("row",e,n)===a||Jt.bind(t)("column",e,n)===s)}},facet:{aspect:1},ctx:{columnLabels:new Ir},fields:[{key:"cellPadding",default:2},{key:"column",default:I("column"),coerce:t=>"function"==typeof t?t:q(t)},{key:"row",default:I("row"),coerce:t=>"function"==typeof t?t:q(t)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:VY},{key:"rowSort",default:VY},{key:"innerRadius",default:t=>t/5,coerce:t=>"function"==typeof t?t:H(t)},{key:"columnConfig",merge:!0,factory:t=>({shapeConfig:{labelConfig:{fontColor:()=>Ws(t),padding:5,textAnchor:t=>[0,180].includes(t.angle)?"middle":[2,3].includes(t.quadrant)?"end":"start",verticalAlign:t=>[90,270].includes(t.angle)?"middle":[2,1].includes(t.quadrant)?"bottom":"top"}}})},{key:"label",coerce:"const",factory:t=>(e,n)=>`${Jt.bind(t)("row",e,n)} / ${Jt.bind(t)("column",e,n)}`}]};var KY=lx(YY);function UY(t,e={}){const n=t.filter(t=>Number.isFinite(t)).sort((t,e)=>t-e);if(!n.length)return null;const i=f.kernelDensity(n,e);return{values:n,n:n.length,min:n[0],q1:h.quantileSorted(n,.25),median:h.quantileSorted(n,.5),q3:h.quantileSorted(n,.75),max:n[n.length-1],mean:h.mean(n),curve:i,peak:i.reduce((t,e)=>Math.max(t,e[1]),0)}}function XY(t,e){const n=new Map;t.forEach((t,i)=>{if(!t)return;const o=e.value(t,i),r=null==o||""===o?NaN:Number(o);if(!Number.isFinite(r))return;const a=e.key(t,i);let s=n.get(a);s||n.set(a,s={first:t,rows:[],values:[]}),s.rows.push(t),s.values.push(r)});const i=[];return n.forEach((t,n)=>{const o=UY(t.values,e.density);o&&i.push({key:n,first:t.first,summary:{...o,rows:t.rows,observed:t.values}})}),i}function ZY(t,e="area"){if("width"===e)return t=>t.peak>0?1/t.peak:0;if("count"===e){const e=t.reduce((t,e)=>Math.max(t,e.peak*e.n),0);return t=>e>0?t.n/e:0}const n=t.reduce((t,e)=>Math.max(t,e.peak),0);return()=>n>0?1/n:0}function QY(t,e){const n=t.slice();if("ascending"!==e&&"descending"!==e)return n;const i="ascending"===e?1:-1;return n.map((t,e)=>({g:t,i:e})).sort((t,e)=>i*(t.g.summary.median-e.g.summary.median)||t.i-e.i).map(({g:t})=>t)}function JY(t,e){if(!t.length||e<t[0][0]||e>t[t.length-1][0])return 0;let n=0,i=t.length-1;for(;i-n>1;){const o=n+i>>1;t[o][0]<=e?n=o:i=o}const[o,r]=t[n],[a,s]=t[i];return a===o?Math.max(r,s):r+(s-r)*(e-o)/(a-o)}const tK="__d3plusDensity";function eK(t){for(;t&&t.__d3plus__&&t.data;)t=t.data;return t}function nK(t){const e=eK(t);return e?e[tK]:void 0}function iK(t){return`density-${t.id}`}function oK(t){const e=t.schema.groupBy,n=[t.schema.facet,t.schema.time].filter(Boolean);return(t,i)=>[...e,...n].map(e=>`${e(t,i)}`).join("\0")}function rK(t){const e=t.ctx.density;t._data!==e.rows&&(e.raw=t._data),t._sourceData=e.raw;const n=e.layout.valueAxis(t),i="x"===n?"y":"x",o=t.schema.groupBy,r=ej(t.schema.value),a=XY(e.raw,{value:t.schema.value,key:oK(t),density:t.schema.densityConfig}),s=QY(a,t.schema.medianSort),c=ZY(a.map(t=>t.summary),t.schema.densityScale),l=a.every(t=>o.every(e=>void 0===e(t.first,0))),h=r??t.schema.translate("Value");e.categories=new Map,e.rows=t._data=s.map((t,a)=>{const s={...t.first};r&&delete s[r],l&&(s.id=h);const u=l?h:`${o[0](t.first,0)}`;return e.categories.has(u)||e.categories.set(u,e.categories.size),s[i]=u,s[n]=t.summary.median,s[tK]={summary:t.summary,order:a,scale:c(t.summary)},s});const u={x:t._xConfig,y:t._yConfig};e.titleAxis&&e.titleAxis!==n&&nj(u[e.titleAxis],e.title,void 0),nj(u[n],e.titleAxis===n?e.title:void 0,r),e.title=r,e.titleAxis=n}function aK({data:t,x:e,y:n,x2:i,y2:o}){if(i||o)return[e,n];const r=this.ctx.density,a=r.layout.valueAxis(this),s="x"===a?e:n,c="x"===a?n:e,l=s.domain().slice(),h=l[0]>l[1];h&&l.reverse(),t.forEach(t=>{const e=nK(t)?.summary.curve;e&&e.length&&(l[0]=Math.min(l[0],e[0][0]),l[1]=Math.max(l[1],e[e.length-1][0]))}),h&&l.reverse(),s.domain(l);const[u,d]=r.layout.categoryPadding(this);return c.padding&&c.padding(u),c.align&&c.align(d),[e,n]}function sK(t,e){t.ctx.density={raw:[],rows:[],layout:e,categories:new Map},t._buffer={...t._buffer,Area:aK},t._plotShapeEmitters={...t._plotShapeEmitters,Area:e.emit},t._sharedHover=()=>{};const n=function(t){return(e,n)=>{const i=t.ctx.density,o="x"===i.layout.valueAxis(t)?"y":"x",r=t=>i.categories.get(`${eK(t)?.[o]}`)??0;return i.layout.reverse?r(n)-r(e):r(e)-r(n)}}(t),i=t._preDraw.bind(t);t._preDraw=()=>{rK(t);const o="x"===e.valueAxis(t)?"y":"x",r="x"===o?"y":"x";t.schema[`${r}Sort`]===n&&(t.schema[`${r}Sort`]=void 0),t.schema[`${o}Sort`]||(t.schema[`${o}Sort`]=n),i()}}function cK(t,e,n){const i=e=>d.formatAbbreviate(e,t.schema.locale),o=e=>t.schema.translate(e),r=nK(e);if(!r){const r=Number(t.schema.value(eK(e),n));return Number.isFinite(r)?[[ej(t.schema.value)??o("Value"),i(r)]]:[]}const a=r.summary;return[[o("Observations"),i(a.n)],[o("Maximum"),i(a.max)],[o("Upper Quartile"),i(a.q3)],[o("Median"),i(a.median)],[o("Lower Quartile"),i(a.q1)],[o("Minimum"),i(a.min)]]}function lK(){return[{key:"densityScale",default:"area"},{key:"medianSort",default:!1},{key:"shape",default:H("Area"),coerce:"const"},{key:"tooltipShared",default:!1},{key:"value",default:tj("value"),coerce:t=>"string"==typeof t?q(t):"function"==typeof t?t:H(t)}]}function hK(t){return[{key:"densityConfig",merge:!0,default:{kernel:"gaussian",points:80,cut:t}},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:(e,n)=>cK(t,e,n)})}]}function uK(t,e,n){return n?n.rotate?null:(t-(n[e]??0))/(n.scale??1):t}function dK(t,e,n){const i=(t,o)=>{if("group"===t.type){const n=n=>{const i=o(n);return null===i?null:uK(i,e,t.transform)};return void t.children.forEach(t=>i(t,n))}if("path"!==t.type)return;const r=n.get(`${t.key}`.replace(/::hit$/,""));if(void 0===r)return;const s=o(r),c=null===s?null:uK(s,e,t.transform);null!==c&&Number.isFinite(c)&&(t.enterD=a.flattenPath(t.d,e,c))};t.forEach(t=>i(t,t=>t))}function fK(t,e){t.forEach(t=>{if("group"===t.type)fK(t.children,e);else if("rect"===t.type){const{x:n,y:i,width:o,height:r}=t;t.enterRect="x"===e?{x:n+o/2,y:i,width:0,height:r}:{x:n,y:i+r/2,width:o,height:0}}})}function mK(t,e,n){return Math.abs(t)/Math.max(1,e-1+2*n)}function pK(t,e){const{position:n,step:i,gap:o,split:r}=e,a=Math.max(1,i>o?i-o:i),s=new Map;t.forEach((t,e)=>{s.has(t)||s.set(t,[]),s.get(t).push(e)});const c=new Array(t.length);return s.forEach((t,e)=>{const i=n(e),o=t.length;if(r&&2===o)return c[t[0]]={center:i,half:a/2,side:"start"},void(c[t[1]]={center:i,half:a/2,side:"end"});const s=a/o,l=o>1?Math.min(2,s/4):0;t.forEach((t,e)=>{c[t]={center:i-a/2+s*(e+.5),half:Math.max(.5,(s-l)/2),side:"both"}})}),c}function gK(t,e,n){return t.map(([t,i])=>({value:t,extent:i*e*n}))}function yK(t,e){const{center:n,side:i}=t;return["end"===i?n:n-e,"start"===i?n:n+e]}function xK(t){const e=Number(t.schema.overlap);return Number.isFinite(e)&&e>0?e:0}function bK(t){return t>0?[t/2,1]:[0,.5]}const _K=(t,e)=>{const{viz:n,values:i,x:o,y:r,yRange:a,yDomain:s}=t,c=xK(n),l=s,h=l.map(t=>r(t,"y")).sort((t,e)=>t-e);let u=mK(a[a.length-1]-a[0],l.length,bK(c)[0]);for(let t=1;t<h.length;t++)u=Math.min(u,h[t]-h[t-1]);const d=c*u,f=i.filter(t=>nK(t)).map(t=>({row:t,base:r(t.y,"y")})).sort((t,e)=>t.base-e.base),m=[];f.forEach(({row:t,base:e})=>{const n=nK(t);n.summary.curve.forEach(([i,r])=>{m.push({...t,id:iK(t),__pos:o(i),__base:e,__top:e-r*n.scale*d})})});const p=t=>t.__pos,g=t=>t.__base,y={x:p,x0:p,x1:null,y:g,y0:g,y1:t=>t.__top},x=Dz({...t,values:m,shapeConfig:{...t.shapeConfig,...y}},e);return dK(x,"y",new Map(f.map(({row:t,base:e})=>[iK(t),e]))),x},kK={name:"Ridgeline",paintDriven:!0,setup:t=>sK(t,{valueAxis:()=>"x",categoryPadding:t=>bK(xK(t)),reverse:!0,emit:_K}),ctx:{},fields:[{key:"discrete",default:"y"},{key:"overlap",default:1.5},...lK(),...hK(3),{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var vK=lx(kK,ZD);function wK(t,e){const n=(h.min([e,t])||0)/2/3;return{width:t,height:e,ringWidth:n,primaryRing:n,secondaryRing:2*n}}function MK(t,e){const n=t.schema.sizeMin,i=t.schema.sizeMax;return Math.min(i??1/0,Math.max(n??0,e))}function SK(t,e,n,i,o,r){if(o.forEach(t=>t.ring=1),r.forEach(t=>t.ring=2),t._size){const a=[e,...o,...r];a.forEach(e=>e.size=Number(t._size(e.data,e.i)));const s=a.map(t=>t.size).filter(t=>Number.isFinite(t));if(s.length){const e=function(t,e,n,i){const{ringWidth:o,primaryRing:r,secondaryRing:a}=e,s=Math.sin(Math.PI/Math.max(n,2)),c=Math.max(1,Math.floor(h.min([o/4,r*s-1,a*s-1]))),l=Math.min(t.schema.sizeMax??1/0,c),u=Math.min(l/2,t.schema.sizeMin??3),d=h.extent(i),f=`scale${t.schema.sizeScale.charAt(0).toUpperCase()}${t.schema.sizeScale.slice(1)}`;return E[f]().domain(d).range([d[0]===d[1]?l:u,l])}(t,n,i,s);return a.forEach(n=>n.r=Number.isFinite(n.size)?e(n.size):MK(t,0)),e}}const{ringWidth:a}=n,s=a/2,c=a/4;let l=s/2-4;s/2-4<8&&(l=h.min([s/2,8])||0);let u=c/2-4;return c/2-4<4&&(u=h.min([c/2,4])||0),u>a/10&&(u=a/10),u>l&&u>10&&(u=.75*l),l>1.5*u&&(l=1.5*u),o.forEach(e=>e.r=MK(t,Math.floor(l))),r.forEach(e=>e.r=MK(t,Math.floor(u))),null}const CK=t=>({data:t.data,i:t.i,id:t.id});function $K(t,e,n){if("object"==typeof n)return e[n.id];const i=e[n];if(i)return i;if(!isNaN(n)){const t=e[parseFloat(n)];if(t)return t}if("number"==typeof n){const i=t.schema.nodes&&t.schema.nodes[n];if(null==i)return;return"object"==typeof i&&e[i.id]||e[i]}}const AK=t=>!!t&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.r;function zK(t,e,n,i,o){const r=new Map(e.filter(AK).map(t=>[t.id,t])),a=t.filter(t=>Rk(t)&&r.has(t.source.id));if(!a.length)return[];const s=new Map,c=(t,e)=>{s.has(t)||s.set(t,[]),s.get(t).push(e)};for(const t of n){const e=r.get(t.source.id),n=r.get(t.target.id);e&&n&&e!==n&&(c(e.id,[n.x,n.y]),c(n.id,[e.x,e.y]))}for(const t of r.values())t.id!==i.id&&"number"==typeof t.radians&&c(t.id,[t.x+Math.cos(t.radians)*(t.r+10),t.y+Math.sin(t.radians)*(t.r+10)]);const l=Math.max(8,.6*(o.primaryRing-(i.r??0))),h=Math.max(0,...a.filter(t=>t.source.id===i.id).map(t=>t.size??1)),u=Math.max(0,l-1.5*h),d=Zk(a,{node:t=>r.get(t.source.id),angle:t=>Uk([t.x,t.y],s.get(t.id)??[],-Math.PI/2),strokeWidth:t=>t.size??1,reach:t=>{const e=r.get(t.source.id),n=Ok(e.r);return e.id===i.id?Math.min(n,u):n}});return a.flatMap(t=>{const e=d.get(t),n=r.get(t.source.id);return e?[{...t,source:n,target:n,loop:e}]:[]})}const DK=(t,e)=>t.source.id===e?t.target:t.source;function LK(t,e){const n=new Set;return t.filter(t=>{const i=DK(t,e).id;return!n.has(i)&&(n.add(i),!0)})}const FK=(t,e,n)=>t.filter(t=>DK(t,e).id===n),NK=(t,e)=>Array.from({length:t},(n,i)=>(i-(t-1)/2)*e);function BK(t,e,n,i){const o=e[0]-t.x,r=e[1]-t.y,a=Math.hypot(o,r);if(!a)return e;const s=[n[1],-n[0]],c=.9*a,l=Math.max(-c,Math.min(c,o*n[0]+r*n[1]+i)),h=(o*s[0]+r*s[1]<0?-1:1)*Math.sqrt(a*a-l*l);return[t.x+n[0]*l+s[0]*h,t.y+n[1]*l+s[1]*h]}const EK=(t,e,n)=>(t[0]-e[0])*n[0]+(t[1]-e[1])*n[1];function RK(t,e,n,i){const o=Math.hypot(e.x-t.x,e.y-t.y)||1,r=(e.x-t.x)/o,a=(e.y-t.y)/o,s=t.r??0,c=e.r??0,l=.75*i,h=[t.x+r*s,t.y+a*s],u=[e.x-r*c,e.y-a*c],[d,f]=BK(t,h,n,l),[m,p]=BK(e,u,n,l),g=(i-(EK([d,f],h,n)+EK([m,p],u,n))/2)/.75,y=m-d,x=p-f;return{sourceX:d,sourceY:f,sourceBisectX:d+y/3+n[0]*g,sourceBisectY:f+x/3+n[1]*g,targetBisectX:d+2*y/3+n[0]*g,targetBisectY:f+2*x/3+n[1]*g,targetX:m,targetY:p}}function PK(t,e,n){const i=.75*n,o=[t.sourceX,t.sourceY],r=[t.targetX,t.targetY];[t.sourceX,t.sourceY]=BK(t.source,o,e,i),[t.targetX,t.targetY]=BK(t.target,r,e,i);const a=(n-(EK([t.sourceX,t.sourceY],o,e)+EK([t.targetX,t.targetY],r,e))/8)/.75;t.sourceBisectX+=e[0]*a,t.sourceBisectY+=e[1]*a,t.targetBisectX+=e[0]*a,t.targetBisectY+=e[1]*a}const TK=t=>"number"==typeof t.x&&"number"==typeof t.y;function OK(t){const e=new Map;for(const n of t){if(n.loop||n.source.id===n.target.id)continue;const t=[String(n.source.id),String(n.target.id)].sort(),i=JSON.stringify(t);e.has(i)||e.set(i,[]),e.get(i).push(n)}for(const t of e.values()){if(t.length<2)continue;const e=t[0],[n,i]=String(e.source.id)<String(e.target.id)?[e.source,e.target]:[e.target,e.source];if(!TK(n)||!TK(i))continue;const o=Math.hypot(i.x-n.x,i.y-n.y);if(!o)continue;const r=[-(i.y-n.y)/o,(i.x-n.x)/o],a=Math.max(...t.map(t=>t.size??1)),s=Math.max(8,a+4)+4;NK(t.length,s).forEach((e,n)=>{const i=t[n];i.spline&&null!=i.sourceX&&null!=i.targetX?PK(i,r,e):(Object.assign(i,RK(i.source,i.target,r,e)),i.spline=!0)})}}function WK(t,e,n,i,o){const{width:r,height:a,primaryRing:s,secondaryRing:c}=o;i.x=r/2,i.y=a/2,i.r=t.schema.sizeMin?h.max([t.schema.sizeMin,.65*s]):t.schema.sizeMax?h.min([t.schema.sizeMax,.65*s]):.65*s;const l=[i],u=[];(n[t.schema.center]||[]).forEach(e=>{const i=e.source.id===t.schema.center?e.target:e.source;u.includes(i)||(i.edges=n[i.id].filter(e=>e.source.id!==t.schema.center||e.target.id!==t.schema.center),l.push(i),u.push(i))}),u.sort((t,e)=>t.edges.length-e.edges.length);const d=[];let f=0;u.forEach(t=>{const e=t.id;t.edges=LK(t.edges.filter(t=>!l.includes(t.source)&&t.target.id===e||!l.includes(t.target)&&t.source.id===e),e),f+=t.edges.length||1,t.edges.forEach(t=>{const{source:n,target:i}=t,o=i.id===e?n:i;l.push(o)})});const m=2*Math.PI;let p=0;u.forEach((t,e)=>{const n=t.edges,i=n.length||1,o=m/f*i;0===e&&(p-=o/2);const l=p+o/2-m/4;t.radians=l,t.x=r/2+s*Math.cos(l),t.y=a/2+s*Math.sin(l),p+=o,n.forEach((e,n)=>{const o=e.source.id===t.id?e.target:e.source,s=m/f,h=l-s*i/2+s/2+s*n;o.radians=h,o.x=r/2+c*Math.cos(h),o.y=a/2+c*Math.sin(h),d.push(o)})});const g=SK(t,i,o,f,u,d);return{nodes:[i].concat(u).concat(d),primaries:u,secondaries:d,radius:g}}function HK(t,e,n){const{ringWidth:i}=n;e.forEach(e=>{if(e.id===t.schema.center){const{bounds:i,inside:o}=function(t,e,n,i,o){const{primaryRing:a}=n;if(!t._size)return{bounds:{x:-a/2,y:-a/2,width:a,height:a},inside:!0};const c=e.r??0,l=c*Math.SQRT2;return l>=Math.max(0,...String(i??"").split(/\s+/).map(t=>r.textWidth(t,{"font-family":s.fontFamilyStringify(o),"font-size":9})))&&l>=12.6?{bounds:{x:-l/2,y:-l/2,width:l,height:l},inside:!0}:{bounds:{x:-a/2,y:c+3,width:a,height:a/2},inside:!1}}(t,e,n,t._drawLabel(e.data||e.node,e.i),t.schema.fontFamily);return e.labelBounds=i,void(e.labelInside=o)}const o=t.schema.shapeConfig.labelConfig,a=1.4*(o?.fontSize&&o.fontSize(e)||11),c=2*a,l=i-e.r;let h=e.radians*(180/Math.PI),u=e.r+5,d="start";(h<-90||h>90)&&(u=-e.r-l-5,d="end",h+=180),e.labelBounds={x:u,y:-a/2,width:l,height:c},e.rotate=h,e.textAnchor=d})}function jK(t,n,i,o,r){t.ctx.linkLookup=o.reduce((t,e)=>(e.source===e.target||(t[e.source.id]||(t[e.source.id]=[]),t[e.source.id].push(e.target),t[e.target.id]||(t[e.target.id]=[]),t[e.target.id].push(e.source)),t),{}),function(t,e,n){const i=h.extent(n,t=>t.size);if(i[0]!==i[1]){const o=h.min(e,t=>t.r),r=E[`scale${t.schema.linkSizeScale.charAt(0).toUpperCase()}${t.schema.linkSizeScale.slice(1)}`]().domain(i).range(EI(t.schema.linkSizeMin,t.schema.linkSizeMax,o));n.forEach(t=>{t.size=r(t.size)})}}(t,n,o);const a=Hm(t,"Path",t.schema.shapeConfig,"edge");delete a.on;const s=e=>e.id===t.schema.center&&!1!==i[e.id]?.labelInside,c={label:e=>!!(n.length<=t.schema.dataCutoff||t._hover&&t._hover(e)||t._active&&t._active(e))&&t._drawLabel(e.data||e.node,e.i),labelBounds:t=>t.labelBounds,labelConfig:{fontColor:n=>{const o=n.data??n;if(o.id===t.schema.center&&!1!==i[o.id]?.labelInside){const n=Pm(Hm(t,o.key??o.shape).fill,o.data??o,o.i);return e.colorContrast("string"==typeof n?n:"rgb(255, 255, 255)",t.schema.colorDefaults)}return Ws(t)},fontResize:t=>s(t.data??t),padding:0,textAnchor:e=>{const n=e.data??e;return n.id!==t.schema.center||s(n)?i[n.id]?.textAnchor||Hm(t,n.key??n.shape).labelConfig.textAnchor:"middle"},verticalAlign:t=>s(t.data??t)?"middle":"top"},rotate:t=>i[t.id].rotate||0},l=Array.from(h.groups(n,t=>t.shape));t.ctx.ringsCtx={edges:r,nodeGroups:l,linkConfig:a,linkD:t=>t.loop?t.loop.d:t.spline?`M${t.sourceX},${t.sourceY}C${t.sourceBisectX},${t.sourceBisectY} ${t.targetBisectX},${t.targetBisectY} ${t.targetX},${t.targetY}`:`M${t.source.x},${t.source.y} ${t.target.x},${t.target.y}`,nodeShapeConfig:c}}function IK(t){if(Array.isArray(t._filteredData)||(t._filteredData=[]),Array.isArray(t.schema.nodes)||(t.schema.nodes=[]),Array.isArray(t.schema.links)||(t.schema.links=[]),!t._filteredData.length&&!t.schema.nodes.length&&!t.schema.links.length)return null;const e=t._filteredData.reduce((e,n,i)=>(e[t._id(n,i)]=n,e),{}),n=function(t,e){let n=t.schema.nodes;!n.length&&t.schema.links.length&&(n=Array.from(new Set(t.schema.links.reduce((t,e)=>t.concat([e.source,e.target]),[]))).map(t=>"object"==typeof t?t:{id:t}));const i=n.reduce((e,n,i)=>(e[t.schema.nodeGroupBy?t.schema.nodeGroupBy[t._drawDepth](n,i):t._id(n,i)]=n,e),{}),o=Array.from(new Set(Object.keys(e).concat(Object.keys(i)))).map((n,o)=>{const r=e[n],a=i[n];return void 0!==a&&{__d3plus__:!0,data:r||a,i:o,id:n,node:a,shape:void 0!==r&&void 0!==t.schema.shape(r)?t.schema.shape(r):t.schema.shape(a)}}).filter(t=>!!t),r=o.reduce((t,e)=>(t[e.id]=e,t),{});t.ctx.nodeLookup=r;const a=t.schema.links.flatMap((e,n)=>{const i=$K(t,r,e.source),o=$K(t,r,e.target);if(!i||!o)return[];const a=Bb(e,CK(i),CK(o),n);return[{source:i,target:o,size:Eb(a,t.schema.linkSize(a,n)),datum:a}]}),s=a.reduce((t,e)=>(e.source===e.target||(t[e.source.id]||(t[e.source.id]=[]),t[e.source.id].push(e),t[e.target.id]||(t[e.target.id]=[]),t[e.target.id].push(e)),t),{});return{nodes:o,nodeLookup:r,links:a,linkMap:s}}(t,e);let i=n.nodeLookup[t.schema.center];return i||null==t.schema.center||isNaN(t.schema.center)||(i=n.nodeLookup[parseFloat(t.schema.center)]),i&&(t.schema.center=i.id),{data:e,graph:n,center:i}}const GK=({viz:t})=>{const e=t;e._sizeLegendFinal=null;const n=IK(e);if(!n)return e.ctx.nodeLookup={},e.ctx.linkLookup={},e.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:t};const{graph:{nodes:i,nodeLookup:o,links:r,linkMap:a},center:s}=n;if(Rb(e,r.map(t=>t.datum),i.map(CK)),!s)return e.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:t};const{width:c,height:l}=kt(e),h=[],u=wK(c,l),{nodes:d,primaries:f,secondaries:m,radius:p}=WK(e,0,a,s,u);return e._sizeLegendFinal=p,function(t,e,n,i,o,r,a,s){const{width:c,height:l,ringWidth:h,primaryRing:u,secondaryRing:d}=a;n.forEach(t=>{const a=["source","target"];FK(o[t.id],t.id,r.id).forEach(t=>{a.forEach(n=>{t[n]=e.find(e=>e.id===t[n].id)}),s.includes(t)||s.push(t)}),o[t.id].forEach(o=>{const a=o.source.id===t.id?o.target:o.source;if(a.id===r.id)return;let f=i.find(t=>t.id===a.id);if(f||(f=n.find(t=>t.id===a.id)),!f)return;o.spline=!0;const m=c/2,p=l/2,g=u+.5*(d-u);["source","target"].forEach((n,i)=>{const r=o[n],a=r.radians,s=r.ring,c=r.x,l=r.y,u=r.r,d=2===s?a+Math.PI:a;o[`${n}X`]=c+Math.cos(d)*u,o[`${n}Y`]=l+Math.sin(d)*u,o[`${n}BisectX`]=m+g*Math.cos(a),o[`${n}BisectY`]=p+g*Math.sin(a),o[n]=e.find(t=>t.id===r.id);const y=o[n];void 0===y.edges&&(y.edges={});const x=0===i?o.target.id:o.source.id,b=y.edges;y.id===t.id?b[x]={angle:t.radians+Math.PI,radius:h/2}:b[x]={angle:f.radians,radius:h/2}}),s.includes(o)||s.push(o)})})}(0,d,f,m,a,s,u,h),HK(e,d,u),jK(e,d,o,r,h),OK(h),h.push(...zK(r,d,h,s,u)),{shapeData:d}};function qK(t){const e=new Set,n=new Map;return t.map(t=>{let i=n.get(t)??0,o=i?`${t}-${i}`:t;for(;e.has(o);)o=`${t}-${++i}`;return n.set(t,i+1),e.add(o),o})}function VK(t,e,n,i,o,r){const a=t.schema.arrows,s=`${e.source.id}-${e.target.id}-${r}`,c="string"==typeof i?i:void 0;if(e.loop)return Jk({arrows:a,arrowSize:t.schema.arrowSize,strokeWidth:o,datum:n,i:r,keyPrefix:`rings-arrow-${s}`,fill:c,loop:e.loop});if(!e.spline)return Sk({arrows:a,arrowSize:t.schema.arrowSize,strokeWidth:o,datum:n,i:r,keyPrefix:`rings-arrow-${s}`,fill:c,source:e.source,target:e.target});const l=YK(e);if(!l)return[];const h=KK(t,e,r,o);return h.ends.source||h.ends.target?Ek({ends:Lk(l,h),size:h.size,datum:n,keyPrefix:"rings-arrow",keys:{source:`rings-arrow-s-${s}`,target:`rings-arrow-t-${s}`},fill:c}):[]}function YK(t){return t.spline&&null!=t.sourceX&&null!=t.targetX?[[t.sourceX,t.sourceY],[t.sourceBisectX,t.sourceBisectY],[t.targetBisectX,t.targetBisectY],[t.targetX,t.targetY]]:null}const KK=(t,e,n,i)=>bk({arrows:t.schema.arrows,arrowSize:t.schema.arrowSize,strokeWidth:"number"==typeof i?i:void 0,datum:e.datum,i:n});function UK(t,e,n,i,o){const r=KK(t,e,n,i);if(!r.source&&!r.target)return o;if(e.loop)return qk(e.loop,r);const a=YK(e);return a?Lk(a,r).d:Mk(e.source,e.target,r)}const XK=t=>`rings-link-${t.source.id}-${t.target.id}${t.loop?`-${Fb(t.datum)?.index??0}`:""}`,ZK=t=>qK(t.map(XK));function QK(t){if(t.loop)return t.loop.apex;if(t.spline&&null!=t.sourceX&&null!=t.targetX)return F_([t.sourceX,t.sourceY],[t.sourceBisectX,t.sourceBisectY],[t.targetBisectX,t.targetBisectY],[t.targetX,t.targetY]);const e=t=>"number"==typeof t.r?t.r:0;return z_([t.source.x,t.source.y],[t.target.x,t.target.y],e(t.source),e(t.target))}function JK(t){if(t.loop)return X_(t.loop.d);const e=YK(t);return e?X_(wk(e)):null}function tU(t,e,n,i){const o=e.nodeShapeConfig;if(!i.length||!o.label||!o.labelBounds)return[];const r=o.label,a=o.labelBounds;return Kx({data:i,label:(t,e)=>r(t,e),x:t=>t.x,y:t=>t.y,aes:t=>({r:t.r}),rotate:t=>o.rotate?o.rotate(t):0,id:t=>`rings-label-${t.id}`,labelBounds:(t,e)=>a(t),labelConfig:{...jm(t,n),...o.labelConfig}})}function eU(t,e,n,i,o){const r=`rings-${t}-${e.id}`;if("Circle"===t)return{type:"circle",key:r,cx:0,cy:0,r:e.r,...i};if("Rect"===t){const t=Number(Pm(n.width,i.datum,o)??2*e.r),a=Number(Pm(n.height,i.datum,o)??2*e.r);return{type:"rect",key:r,x:-t/2,y:-a/2,width:t,height:a,...i}}return null}const nU={name:"Rings",layoutStage:GK,sizeLegendScale:(t,{width:e,height:n})=>function(t,e,n){if(!t._size)return null;const{nodeLookup:i}=t.ctx,o=IK(t);if(t.ctx.nodeLookup=i,!o||!o.center)return null;const{graph:r,center:a}=o;return WK(t,r.nodeLookup,r.linkMap,a,wK(e,n)).radius}(t,e,n),emit:({viz:t})=>{const e=t.ctx.ringsCtx;if(!e)return[];const n=[],i=new Map((e.nodeGroups??[]).map(([n,i])=>[n,tU(t,e,n,i)]));if(e.edges&&e.edges.length){const o=i_(t),r=ZK(e.edges);for(const[i,a]of e.edges.entries()){const s=a.datum,c=Fb(s)?.index??0,l=Om(e.linkConfig,s,c);"number"==typeof a.size&&(l.strokeWidth=a.size);const h=o(s,a);h&&(l.stroke=h);const u=r[i],d=e.linkD(a);n.push({type:"path",key:u,d:UK(t,a,c,l.strokeWidth,d),datum:s,index:c,paint:l,aria:{label:Vb(t,s)}}),n.push(Jb(u,d,s,l.strokeWidth)),n.push(...VK(t,a,s,l.stroke,l.strokeWidth,c))}n.push(...function(t,e,n,i){return sk(t,e.edges.map((t,e)=>({key:i[e],link:t,i:e,anchor:QK(t),path:JK(t),priority:t.size})),{circles:e.nodeGroups.flatMap(([,t])=>t.map(t=>({x:t.x,y:t.y,r:t.r}))),labels:ak(n)})}(t,e,[...i.values()].flat(),r))}if(e.nodeGroups&&e.nodeGroups.length){const o=e.nodeShapeConfig;for(const[r,a]of e.nodeGroups){if(!a.length)continue;const s={...Hm(t,r),...e.nodeShapeConfig},c=[];for(let e=0;e<a.length;e++){const i=a[e],l=i.data??i,h=Om(s,l,i.i??e);void 0===h.vectorEffect&&(h.vectorEffect="non-scaling-stroke");const u=o.rotate?o.rotate(i):0,d=u?{x:i.x,y:i.y,rotate:u}:{x:i.x,y:i.y},f=t._size,m=f?`, ${f(l,i.i??e)}`:"",p=eU(r,i,s,{datum:l,paint:h,transform:d,aria:{label:`${Wm(t,i,e)}${m}.`}},i.i??e);if(!p)continue;n.push(p);const g=Jv(s,p,l,i.i??e);g&&c.push(g)}n.push(...c),n.push(...i.get(r)??[])}}return n},insetRegion:Cp,setup:t=>{!function(t){const e=t;e.links=function(){return arguments.length?(dn(this,"links",arguments),this):this.schema.links},e.nodes=function(){return arguments.length?(dn(this,"nodes",arguments),this):this.schema.nodes},e.linkSize=function(t){return arguments.length?(this.schema.linkSize="function"==typeof t?t:H(t),this):this.schema.linkSize},e.nodeGroupBy=function(t){if(!arguments.length)return this.schema.nodeGroupBy;const e=t instanceof Array?t:[t];return this.schema.nodeGroupBy=e.map(t=>"function"==typeof t?t:(this.schema.aggs[t]||(this.schema.aggs[t]=(t,e)=>{const n=Array.from(new Set(t.map(e)));return 1===n.length?n[0]:n}),q(t))),this},e.size=function(t){return arguments.length?(this._size="function"!=typeof t&&t?q(t):t,this._sizeKey="string"==typeof t?t:void 0,this):this._size},e.hover=hx}(t);const e=t;t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{e.hover(!1)};const n=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(i,o,r,a)=>{n(i,o,r,a);const s=(e,n)=>`${t._ids(e,n)[t._drawDepth]}`;if(Nb(i))return void e.hover(Yb(t,i,s));if(t._focus&&t._focus===i.id)return e.hover(!1),t.schema.on.mouseenter.bind(t)(i,o,r,a),void(t._focus=void 0);const c=t.schema.nodeGroupBy&&t.schema.nodeGroupBy[t._drawDepth](i,o)?t.schema.nodeGroupBy[t._drawDepth](i,o):t._id(i,o),l=t.ctx.linkLookup[c]??[],h=t.ctx.nodeLookup[c];if(!h)return;const u=[h.id],d=[h.x-h.r,h.x+h.r],f=[h.y-h.r,h.y+h.r];l.forEach(t=>{u.push(t.id),t.x-t.r<d[0]&&(d[0]=t.x-t.r),t.x+t.r>d[1]&&(d[1]=t.x+t.r),t.y-t.r<f[0]&&(f[0]=t.y-t.r),t.y+t.r>f[1]&&(f[1]=t.y+t.r)}),e.hover((t,e)=>{const n=Fb(t);return n?n.source.id===h.id||n.target.id===h.id:u.includes(s(t,e))})},vW(t),t.schema.on["click.shape"]=e=>{Nb(e)?kW(t,e,{nodeKey:(e,n)=>`${t._ids(e,n)[t._drawDepth]}`}):(xW(t),t.hover?.(!1),t._tooltipClass?.data([]).render(),t.schema.center=e.id,t._margin={bottom:0,left:0,right:0,top:0},t._padding={bottom:0,left:0,right:0,top:0},zy(t),Ry(t),t._sceneRenderer&&t._drawSceneToTarget(Zt(t)))}},facet:{aspect:1},ctx:{},fields:[{key:"arrows",default:!1},{key:"arrowSize"},{key:"center"},{key:"tooltipConfig",merge:!0,factory:t=>Qb(t)},...lk(),...pn("links","nodes"),{key:"links",default:[]},{key:"linkSize",default:H(1)},hk(),{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodes",default:[]},{key:"nodeTooltipLinks"},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:H("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i=t._size,o=i?`, ${i(e,n)}`:"";return`${t._drawLabel(e,n)}${o}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:()=>J(t._theme,t=>t.link,"#adb5bd"),strokeWidth:1}})}]};var iU=lx(nU);const oU=(t,e)=>t.sourceLinks.length||!t.targetLinks.length?t.depth:e-1,rU=(t,e)=>t.y0-e.y0,aU=(t,e)=>rU(t.source,e.source)||t.index-e.index,sU=(t,e)=>rU(t.target,e.target)||t.index-e.index,cU=t=>t.value;function lU(t,e){const n=t.length;let i=new Set(t),o=new Set,r=0;for(;i.size;){for(const t of i)if(t[e]=r,"depth"===e)for(const{target:e}of t.sourceLinks)o.add(e);else for(const{source:e}of t.targetLinks)o.add(e);if(++r>n)throw new Error("circular link");i=o,o=new Set}}function hU(t,e,n,i){for(let o=1,r=e.length;o<r;++o){const r=e[o];for(const e of r){let i=0,o=0;for(const{source:n,value:r}of e.targetLinks){const a=r*(e.layer-n.layer);i+=yU(t,n,e)*a,o+=a}if(!(o>0))continue;const r=(i/o-e.y0)*n;e.y0+=r,e.y1+=r,pU(t,e)}void 0===t.sort&&r.sort(rU),dU(t,r,i)}}function uU(t,e,n,i){for(let o=e.length-2;o>=0;--o){const r=e[o];for(const e of r){let i=0,o=0;for(const{target:n,value:r}of e.sourceLinks){const a=r*(n.layer-e.layer);i+=xU(t,e,n)*a,o+=a}if(!(o>0))continue;const r=(i/o-e.y0)*n;e.y0+=r,e.y1+=r,pU(t,e)}void 0===t.sort&&r.sort(rU),dU(t,r,i)}}function dU(t,e,n){const i=e.length>>1,o=e[i];mU(t,e,o.y0-t.py,i-1,n),fU(t,e,o.y1+t.py,i+1,n),mU(t,e,t.y1,e.length-1,n),fU(t,e,t.y0,0,n)}function fU(t,e,n,i,o){for(;i<e.length;++i){const r=e[i],a=(n-r.y0)*o;a>1e-6&&(r.y0+=a,r.y1+=a),n=r.y1+t.py}}function mU(t,e,n,i,o){for(;i>=0;--i){const r=e[i],a=(r.y1-n)*o;a>1e-6&&(r.y0-=a,r.y1-=a),n=r.y0-t.py}}function pU(t,{sourceLinks:e,targetLinks:n}){if(void 0===t.linkSort){for(const{source:t}of n)t.sourceLinks.sort(sU);for(const{target:t}of e)t.targetLinks.sort(aU)}}function gU(t,e){if(void 0===t.linkSort)for(const{sourceLinks:t,targetLinks:n}of e)t.sort(sU),n.sort(aU)}function yU(t,e,n){let i=e.y0-(e.sourceLinks.length-1)*t.py/2;for(const{target:o,width:r}of e.sourceLinks){if(o===n)break;i+=r+t.py}for(const{source:t,width:o}of n.targetLinks){if(t===e)break;i-=o}return i}function xU(t,e,n){let i=n.y0-(n.targetLinks.length-1)*t.py/2;for(const{source:o,width:r}of n.targetLinks){if(o===e)break;i+=r+t.py}for(const{target:t,width:o}of e.sourceLinks){if(t===n)break;i-=o}return i}const bU=t=>Math.round(100*t)/100,_U=t=>`${bU(t[0])},${bU(t[1])}`;function kU(t){return t.map(t=>t.c1&&t.c2?`C${_U(t.c1)} ${_U(t.c2)} ${_U(t.to)}`:`L${_U(t.to)}`).join("")}function vU(t){return`M${_U(t.start)}${kU(t.steps)}`}function wU(t){const e=[t.start,...t.steps.map(t=>t.to)],n=[];for(let i=t.steps.length-1;i>=0;i--){const o=t.steps[i];n.push(o.c1&&o.c2?{to:e[i],c1:o.c2,c2:o.c1}:{to:e[i]})}return{start:e[e.length-1],steps:n}}function MU(t,e){const n=t=>[t[0],t[1]+e];return{start:n(t.start),steps:t.steps.map(t=>({to:n(t.to),...t.c1&&t.c2?{c1:n(t.c1),c2:n(t.c2)}:{}}))}}function SU(t,e){const n=wU(e);return`${vU(t)}L${_U(n.start)}${kU(n.steps)}Z`}function CU(t,e,n,i,o){const r=(t+n)/2,a={start:[t,e],steps:[{c1:[r,e],c2:[r,i],to:[n,i]}]};return SU(MU(a,-o),MU(a,o))}function $U(t,e,n){const{source:i,target:o}=t;return(i.y0+i.y1+o.y0+o.y1)/4<=(e+n)/2?"top":"bottom"}const AU=t=>Math.abs(t.source.layer-t.target.layer);function zU(t,e){const n="top"===e?1:-1,i=t=>"top"===e?t.y0:t.y1;return t.slice().sort((t,e)=>AU(t)-AU(e)||n*(i(t.source)-i(e.source))||n*(i(t.target)-i(e.target))||e.value-t.value||t.index-e.index)}function DU(t,e){const n={source:new Map,target:new Map},i=(t,e)=>{const i=e[t].layer,o=n[t].get(i)??0;return n[t].set(i,o+e.width),8+o+e.width/2},o=t.map(t=>({depth:0,arcSource:i("source",t),arcTarget:i("target",t)})),r=t.map((t,n)=>{const i=e(t.source.layer)[1]+o[n].arcSource,r=e(t.target.layer)[0]-o[n].arcTarget,a=t.width/2;return[Math.min(r,i)-a,Math.max(r,i)+a]});return t.forEach((e,n)=>{for(let e=0;e<n;e++)r[e][0]<r[n][1]&&r[n][0]<r[e][1]&&(o[n].depth=Math.max(o[n].depth,o[e].depth+t[e].width))}),o}function LU(t,e){const n={top:0,right:0,bottom:0,left:0};for(const{side:i,links:o,lanes:r}of t)o.forEach((t,o)=>{const a=r[o],s=12+a.depth+t.width;n[i]=Math.max(n[i],s),t.source.layer===e&&(n.right=Math.max(n.right,a.arcSource+t.width/2)),0===t.target.layer&&(n.left=Math.max(n.left,a.arcTarget+t.width/2))});return n}function FU(t,e,n,i){const o=i+("top"===n?-1:1)*(12+e.depth+t.width/2),r=t.y0,a=t.y1;return{side:n,xs:t.source.x1,sy:r,xt:t.target.x0,ty:a,laneY:o,xr:t.source.x1+e.arcSource,rs:Math.max(0,Math.min(e.arcSource,Math.abs(r-o)/2)),xl:t.target.x0-e.arcTarget,rt:Math.max(0,Math.min(e.arcTarget,Math.abs(a-o)/2))}}const NU=.5523;function BU(t){const{xs:e,sy:n,xt:i,ty:o,laneY:r,xr:a,rs:s,xl:c,rt:l}=t,h="top"===t.side?-1:1,u=[],d=(t,e,n,i,o)=>{u.push({to:t}),u.push({c1:[t[0]+e[0]*NU*o,t[1]+e[1]*NU*o],c2:[n[0]-i[0]*NU*o,n[1]-i[1]*NU*o],to:n})};return d([a-s,n],[1,0],[a,n+h*s],[0,h],s),d([a,r-h*s],[0,h],[a-s,r],[-1,0],s),d([c+l,r],[-1,0],[c,r-h*l],[0,-h],l),d([c,o+h*l],[0,-h],[c+l,o],[1,0],l),u.push({to:[i,o]}),{start:[e,n],steps:u}}function EU(t){return vU(BU(t))}function RU(t,e){const n="top"===t.side?-1:1;return{...t,sy:t.sy-n*e,ty:t.ty-n*e,laneY:t.laneY+n*e,xr:t.xr+e,xl:t.xl-e,rs:Math.max(0,t.rs+e),rt:Math.max(0,t.rt+e)}}function PU(t,e){return SU(BU(RU(t,e)),BU(RU(t,-e)))}function TU(t){return z_([t.xr-t.rs,t.laneY],[t.xl+t.rt,t.laneY])}function OU(t,e){let n=0,i=0;for(const o of e){const e=Number.isFinite(o.value)?o.value:0;o.source===t&&(n+=e),o.target===t&&(i+=e)}return Math.max(n,i)}function WU(t,e){const n={source:new Map,target:new Map},i={source:new Map,target:new Map};for(const{side:e,links:o}of t){const t="top"===e?n:i;for(const n of o)for(const i of["source","target"]){const o=n[i],r=t[i].get(o)??0;t[i].set(o,r+n.width);const{y0:a,y1:s}=o,c="top"===e?a+r+n.width/2:s-r-n.width/2;"source"===i?n.y0=c:n.y1=c}}for(const t of e)t.y0+=n.source.get(t.source)??0,t.y1+=n.target.get(t.target)??0}function HU(t){const e=t.find(t=>"number"==typeof t.value&&t.value>0);return e?(e.y1-e.y0)/e.value:0}function jU(t,e,n){const i=(t,e,n)=>{const i=t+e>n/2?n/2/(t+e):1;return[t*i,e*i]},[o,r]=i(t.top,t.bottom,n),[a,s]=i(t.left,t.right,e);return{top:o,right:s,bottom:r,left:a}}function IU(t,e,n){const i=new Map;for(const e of t){const t=i.get(e.layer)??{count:0,total:0};t.count++,t.total+="number"==typeof e.value?e.value:0,i.set(e.layer,t)}const o=Math.max(0,...Array.from(i.values(),t=>t.count)),r=Math.min(n,e/(o-1));let a=1/0;for(const{count:t,total:n}of i.values())n>0&&(a=Math.min(a,(e-(t-1)*r)/n));return Number.isFinite(a)?Math.max(0,a):0}function GU(t,e,n,i){let o=0,r=Math.max(0,i);for(let i=0;i<48;i++){const i=(o+r)/2;t(Math.max(0,n-e(i)))>=i?o=i:r=i}return o}function qU(t,e,n,i){const o=n>0?(e-t-i)/n:0;return e=>[t+e*o,t+e*o+i]}function VU(t){const{run:e,nodes:n,links:i,circular:o,width:r,height:a,padding:s}=t;if(e([[0,0],[r,a]]),!o.length||!n.length)return[];const c=t=>o.map(e=>({index:e.i,i:e.i,datum:e.datum,source:n[e.source],target:n[e.target],value:e.value,width:Number.isFinite(e.value)?Math.max(0,e.value)*t:0})),l=Math.max(...n.map(t=>t.depth??t.layer)),h=n[0].x1-n[0].x0,u=c(HU(n)),d=new Map(u.map(t=>[t.i,$U(t,0,a)])),f=new Map(["top","bottom"].flatMap(t=>zU(u.filter(e=>d.get(e.i)===t),t).map((t,e)=>[t.i,e]))),m=(t,e)=>{const n=c(t);return["top","bottom"].map(t=>{const i=n.filter(e=>d.get(e.i)===t).sort((t,e)=>(f.get(t.i)??0)-(f.get(e.i)??0));return{side:t,links:i,lanes:DU(i,e)}})},p=t=>{const e=qU(0,r,l,h),{left:n,right:i}=LU(m(t,e),l),o=qU(n,r-i,l,h);return{...LU(m(t,o),l),left:n,right:i}},g=GU(t=>IU(n,t,s),t=>{const e=p(t);return e.top+e.bottom},a,HU(n)),y=jU(p(g),r,a);e([[y.left,y.top],[r-y.right,a-y.bottom]]);const x=new Map(n.map(t=>[t.layer,[t.x0,t.x1]])),b=m(HU(n),t=>x.get(t)??[0,0]);WU(b,i);const _=function(t,e){const n=Math.min(...e.map(t=>t.y0)),i=Math.max(...e.map(t=>t.y1)),o=new Map;for(const{side:e,links:r,lanes:a}of t)r.forEach((t,r)=>{const s=t;o.set(t.i,{source:t.source,target:t.target,value:t.value,datum:t.datum,width:t.width,y0:s.y0,y1:s.y1,circular:FU(s,a[r],e,"top"===e?n:i)})});return o}(b,n);return o.map(t=>_.get(t.i))}const YU=t=>Number.isFinite(t.value)?t.value:0;function KU(t){let e=0;for(const n of t)e=Math.max(e,n.source+1,n.target+1);const n=Array.from({length:e},()=>[]);for(const e of t)e.source!==e.target&&n[e.source].push(e.target);const i=function(t,e){const n=Array.from({length:t},()=>[]),i=Array.from({length:t},()=>[]),o=new Int32Array(t);let r=0;const a=(t,e,n,i=-1)=>{r++,o[t]=r;const a=[t];for(let t=0;t<a.length;t++)for(const s of e[a[t]]){if(s===i)return null;o[s]!==r&&n(s)&&(o[s]=r,a.push(s))}return a};return(t,o)=>{if(t===o)return!1;const r=e[o],s=e[t];if(r<s){const c=a(o,n,t=>e[t]<=s,t);if(!c)return!1;const l=a(t,i,t=>e[t]>=r),h=(t,n)=>e[t]-e[n];l.sort(h),c.sort(h);const u=l.concat(c),d=u.map(t=>e[t]).sort((t,e)=>t-e);u.forEach((t,n)=>e[t]=d[n])}return n[t].push(o),i[o].push(t),!0}}(e,function(t,e){const n=new Int32Array(t),i=new Uint8Array(t);let o=t;for(let r=0;r<t;r++){if(i[r])continue;i[r]=1;const t=[r],a=[0];for(;t.length;){const r=t.length-1,s=t[r];if(a[r]<e[s].length){const n=e[s][a[r]++];i[n]||(i[n]=1,t.push(n),a.push(0))}else t.pop(),a.pop(),n[s]=--o}}return n}(e,n)),o=t.map((t,e)=>e).sort((e,n)=>YU(t[n])-YU(t[e])||e-n),r=new Uint8Array(t.length);for(const e of o)i(t[e].source,t[e].target)||(r[e]=1);const a=[],s=[];return t.forEach((t,e)=>(r[e]?s:a).push(t)),{kept:a,looped:s}}function UU(t){const e=[],n=[],i=[];for(const o of t)void 0===o.source||void 0===o.target?n.push(o):o.source===o.target?i.push(o):e.push(o);return{drawn:e,unresolved:n,selfLinks:i}}function XU(t,e){const n="number"==typeof t?t:Number(t);if(null!==t&&""!==t&&Number.isFinite(n)&&n>0)return n;const i=e.filter(t=>Number.isFinite(t)&&t>0);return i.length?Math.min(...i):1}function ZU(t){const e=1===t.length?"1 link":`${t.length} links`,n=Array.from(new Set(t.map(([t,e])=>`${t} → ${e}`))),i=n.length-10;return`Sankey can't draw a flow that loops back into a node it left, so it leaves out ${e} (${n.slice(0,10).join(", ")}${i>0?`, and ${i} more`:""}).`}const QU=t=>({data:t.data,i:t.i,id:String(t.id)});const JU=({viz:t})=>{const e=t,{width:n,height:i}=kt(e),o=Array.isArray(e.schema.nodes)&&e.schema.nodes.length>0,r=Array.isArray(e.schema.links)&&e.schema.links.length>0;if(!o&&!r)return e.ctx.nodeLookup={},e.ctx.linkLookup={},{viz:t};const a=o?e.schema.nodes:function(t,e){const n=new Set;for(const i of t)for(const t of e)n.add(i[t]);return Array.from(n,t=>({id:t}))}(e.schema.links,[e.schema.linksSource,e.schema.linksTarget]),s=a.map((t,n)=>({__d3plus__:!0,data:t,i:n,id:e.schema.nodeId(t,n),node:t,shape:"Rect"})),c=s.reduce((t,e,n)=>(t[String(e.id)]=n,t),{});e.ctx.nodeLookup=c;const l=function(t,e,n,i){const o=[t.schema.linksSource,t.schema.linksTarget],{drawn:r,selfLinks:a}=UU(i?t.schema.links.map((t,e)=>({link:t,i:e,source:n[String(t[o[0]])],target:n[String(t[o[1]])]})):[]);return[...r,...a].sort((t,e)=>t.i-e.i).map(({link:n,i:i,source:r,target:a})=>{const s=Bb(n,QU(e[r]),QU(e[a]),i,o);return{source:r,target:a,value:Eb(s,t.schema.value(s,i)),datum:s,i:i}})}(e,s,c,r),{kept:u,looped:d}=KU(l),f=!1!==e.schema.circularLinks;!f&&d.length&&Et(e,"sankeyLoops",ZU(d.map(t=>[s[t.source].id,s[t.target].id])));const m=f?d:[],p=m.length?[...u,...m].sort((t,e)=>t.i-e.i):u;Rb(e,p.map(t=>t.datum),s.map(QU)),function(t,e,n){const i=new Set(n.flatMap(t=>[t.source,t.target])),o=n.map(t=>Number(t.value));e.forEach((e,n)=>{if(i.has(n))return;let r;try{r=t.schema.value(e.data,e.i)}catch{r=void 0}e.fixedValue=XU(r,o)})}(e,s,p);for(const t of new Set(m.flatMap(t=>[t.source,t.target])))s[t].fixedValue=OU(t,p);e.ctx.linkLookup=function(t){return t.reduce((t,e)=>(t[e.source]||(t[e.source]=[]),t[e.source].push(e.target),t[e.target]||(t[e.target]=[]),t[e.target].push(e.source),t),{})}(p);const g=e.ctx.sankey.nodeAlign(e.schema.nodeAlign).nodePadding(e.schema.nodePadding).nodeWidth(e.schema.nodeWidth).nodes(s).nodeSort(e.schema.nodeSort).links(u).linkSort(e.schema.linkSort).iterations(e.schema.iterations),y=VU({run:t=>g.extent(t)(),nodes:s,links:u,circular:m,width:n,height:i,padding:e.schema.nodePadding}),x=Array.from(h.groups(s,t=>t.shape));return e.ctx.sankeyCtx={links:[...u,...y],nodeGroups:x,width:n,height:i},{shapeData:s}};function tX(t){const e="number"==typeof t.width?t.width:0;return Math.max(1,e-2)}function eX(t,e){return t.circular?PU(t.circular,e):CU(t.source.x1,t.y0??0,t.target.x0,t.y1??0,e)}const nX=t=>qK(t.map(t=>`${t.source.id??""}-${t.target.id??""}`));function iX(t){if(t.circular)return TU(t.circular);if("number"!=typeof t.y0||"number"!=typeof t.y1)return null;const e=t.source.x1,n=t.target.x0,i=(e+n)/2;return F_([e,t.y0],[i,t.y0],[i,t.y1],[n,t.y1])}function oX(t){if(t.circular)return X_(EU(t.circular));if("number"!=typeof t.y0||"number"!=typeof t.y1)return null;const e=t.source.x1,n=t.target.x0,i=(e+n)/2;return X_(`M${e},${t.y0}C${i},${t.y0} ${i},${t.y1} ${n},${t.y1}`)}const rX={center:t=>t.targetLinks.length?t.depth:t.sourceLinks.length?h.min(t.sourceLinks,t=>t.target.depth)-1:0,justify:oU,left:t=>t.depth,right:(t,e)=>e-1-t.height};const aX={name:"Sankey",layoutStage:JU,emit:({viz:t})=>{const e=t.ctx.sankeyCtx;if(!e)return[];const n=[],i=t.schema.shapeConfig?.Path??{},o=nX(e.links??[]);if(e.links&&e.links.length){const r=i_(t);for(const[a,s]of e.links.entries()){const e=s.datum,c=Fb(e)?.index??0,l=Om(i,e,c),h=r(e,s);h&&(l.fill=h,l.fillOpacity=Pm(i.fillOpacity,e,c)??.5);const u=tX(s),d=`sankey-link-${o[a]}`;n.push({type:"path",shapeType:"Link",key:d,d:eX(s,u/2),datum:e,index:c,paint:l,aria:{label:Vb(t,e)}}),n.push({...Jb(d,eX(s,u/2),e,0),paint:{fill:"transparent",stroke:"transparent",strokeWidth:8},shapeType:"Link"})}}const r=function(t,e){const n=[],i=[];for(const[o,r]of e.nodeGroups??[]){if(!r.length)continue;const a=Hm(t,o),s=n.length;for(let e=0;e<r.length;e++){const i=r[e],s=i.data??i,c=Om(a,s,i.i??e),l={label:`${Wm(t,i,e)}.`};if("Rect"===o)n.push({type:"rect",key:`sankey-${o}-${i.id}`,x:i.x0,y:i.y0,width:i.x1-i.x0,height:i.y1-i.y0,datum:s,paint:c,aria:l});else if("Circle"===o){const t=Number(Pm(a.r,s,i.i??e)??0);n.push({type:"circle",key:`sankey-${o}-${i.id}`,cx:(i.x0+i.x1)/2,cy:(i.y0+i.y1)/2,r:t,datum:s,paint:c,aria:l})}}n.push(...tw(a,n.slice(s),t=>{const e=r[t];return[e.data??e,e.i??t]}));const c=Ux(t,r,a,e.width,e.height);i.push(...c),n.push(...c)}return{out:n,labels:i}}(t,e);return e.links&&e.links.length&&n.push(...function(t,e,n,i){return sk(t,e.links.map((t,e)=>({key:`sankey-link-${i[e]}`,link:t,i:e,anchor:iX(t),path:oX(t),priority:t.value})),{boxes:e.nodeGroups.flatMap(([,t])=>t.map(t=>({x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0}))),labels:ak(n)})}(t,e,r.labels,o)),n.push(...r.out),n},setup:t=>{const e=t;!function(t){t.schema.on.mouseenter=()=>{},t.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const e=t.schema.on["mousemove.shape"];t.schema.on["mousemove.shape"]=(n,i,o,r)=>{if(e(n,i,o,r),t._focus&&t._focus===n.id)return t.hover(!1),t.schema.on.mouseenter.bind(t)(n,i,o,r),void(t._focus=void 0);const a=(e,n)=>`${t.schema.nodeId(e,n)}`,s=Nb(n)?Yb(t,n,a):Ub(t,n,a);s&&t.hover(s)}}(e),function(t){vW(t);const e=t.schema.on["click.shape"];t.schema.on["click.shape"]=function(n,i,o,r){Nb(n)?kW(t,n,{nodeKey:(e,n)=>`${t.schema.nodeId(e,n)}`}):"function"==typeof e&&e.call(this,n,i,o,r)}}(t),e.links=function(){return arguments.length?(dn(this,"links",arguments),this):this.schema.links},e.nodes=function(){return arguments.length?(dn(this,"nodes",arguments),this):this.schema.nodes},e.nodeAlign=function(t){return arguments.length?(this.schema.nodeAlign="function"==typeof t?t:rX[t],this):this.schema.nodeAlign},e.nodeId=function(t){return arguments.length?(this.schema.nodeId="function"==typeof t?t:q(t),this):this.schema.nodeId},e.value=function(t){return arguments.length?(this.schema.value="function"==typeof t?t:q(t),this):this.schema.value},e.hover=hx},ctx:{sankey:function(){const t={x0:0,y0:0,x1:1,y1:1,dx:24,dy:8,py:8,align:oU,sort:void 0,linkSort:void 0,iterations:6};let e=[],n=[];const i=()=>{const i=e,o=n;!function(t,e,n){for(const[t,n]of e.entries())n.index=t,n.sourceLinks=[],n.targetLinks=[];const i=new Map(e.map((t,e)=>[e,t])),o=t=>{const e=i.get(t);if(!e)throw new Error("missing: "+t);return e};for(const[t,e]of n.entries()){e.index=t;const n=e;"object"!=typeof n.source&&(e.source=o(n.source)),"object"!=typeof n.target&&(e.target=o(n.target)),e.source.sourceLinks.push(e),e.target.targetLinks.push(e)}if(null!=t.linkSort)for(const{sourceLinks:n,targetLinks:i}of e)n.sort(t.linkSort),i.sort(t.linkSort)}(t,i,o);for(const t of i)t.value=void 0===t.fixedValue?Math.max(h.sum(t.sourceLinks,cU),h.sum(t.targetLinks,cU)):t.fixedValue;return lU(i,"depth"),lU(i,"height"),function(t,e){const n=function(t,e){const n=h.max(e,t=>t.depth)+1,i=n>1?(t.x1-t.x0-t.dx)/(n-1):0,o=new Array(n);for(const r of e){const e=Math.max(0,Math.min(n-1,Math.floor(t.align(r,n))));r.layer=e,r.x0=t.x0+e*i,r.x1=r.x0+t.dx,o[e]?o[e].push(r):o[e]=[r]}if(t.sort)for(const e of o)e.sort(t.sort);return o}(t,e);t.py=Math.min(t.dy,(t.y1-t.y0)/(h.max(n,t=>t.length)-1)),function(t,e){const n=h.min(e,e=>(t.y1-t.y0-(e.length-1)*t.py)/h.sum(e,cU));for(const i of e){let e=t.y0;for(const o of i){o.y0=e,o.y1=e+o.value*n,e=o.y1+t.py;for(const t of o.sourceLinks)t.width=t.value*n}e=(t.y1-e+t.py)/(i.length+1);for(let t=0;t<i.length;++t){const n=i[t];n.y0+=e*(t+1),n.y1+=e*(t+1)}gU(t,i)}}(t,n);for(let e=0;e<t.iterations;++e){const i=Math.pow(.99,e),o=Math.max(1-i,(e+1)/t.iterations);uU(t,n,i,o),hU(t,n,i,o)}}(t,i),function(t){for(const e of t){let t=e.y0,n=t;for(const n of e.sourceLinks)n.y0=t+n.width/2,t+=n.width;for(const t of e.targetLinks)t.y1=n+t.width/2,n+=t.width}}(i),{nodes:i,links:o}};return i.nodeAlign=e=>(t.align=e,i),i.nodeSort=e=>(t.sort=e,i),i.nodeWidth=e=>(t.dx=+e,i),i.nodePadding=e=>(t.dy=t.py=+e,i),i.nodes=t=>(e=t,i),i.links=t=>(n=t,i),i.linkSort=e=>(t.linkSort=e,i),i.size=e=>(t.x0=t.y0=0,t.x1=+e[0],t.y1=+e[1],i),i.extent=([[e,n],[o,r]])=>(t.x0=+e,t.y0=+n,t.x1=+o,t.y1=+r,i),i.iterations=e=>(t.iterations=+e,i),i}()},fields:[{key:"circularLinks",default:!0},{key:"iterations",default:6},...lk(),...pn("links","nodes"),{key:"links",default:I("links")},{key:"linkSort"},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:I("nodes")},{key:"nodeAlign",default:oU},{key:"nodeId",default:I("id")},{key:"nodePadding",default:8},{key:"nodeSort"},{key:"nodeTooltipLinks"},{key:"nodeWidth",default:30},{key:"value",default:H(1)},{key:"shape",default:H("Rect"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({Path:{fill:()=>J(t._theme,t=>t.link===K.link?e.colorGray[800]:t.link,"#DBDBDB"),fillOpacity:.5,label:!1},Rect:{}})},{key:"tooltipConfig",merge:!0,factory:t=>Qb(t)}]};var sX=lx(aX);const cX=t=>t instanceof Date?+t:"number"==typeof t&&Number.isFinite(t)?t:void 0;function lX(t){const e=new Map;for(const n of t){if(null==n)continue;const t=n instanceof Date?+n:n;e.has(t)||e.set(t,n)}const n=[...e.values()];return n.every(t=>void 0!==cX(t))?n.sort((t,e)=>cX(t)-cX(e)):n}function hX(t,e){return e>t?"up":e<t?"down":"flat"}function uX(t,e,n,i){const o=lX(t.map((t,e)=>n(t,e))),r=new Map(o.map((t,e)=>[t instanceof Date?+t:t,e])),a=new Map;t.forEach((t,o)=>{const s=n(t,o),c=r.get(s instanceof Date?+s:s),l=Number(i(t,o));if(void 0===c||!Number.isFinite(l))return;const h=`${e(t,o)}`,u=a.get(h);u?(c<u.first[0]&&(u.first=[c,l]),c>=u.last[0]&&(u.last=[c,l])):a.set(h,{first:[c,l],last:[c,l]})});const s=new Map;return a.forEach(({first:t,last:e},n)=>s.set(n,hX(t[1],e[1]))),s}const dX=Object.freeze({up:"#2f9e44",down:"#e03131",flat:"#767676"}),fX=Object.freeze({up:"#51cf66",down:"#ff6b6b",flat:"#adb5bd"});function mX(t,e,n){if(!t)return null;const i={...e?fX:dX,...n?{flat:n}:{}};return!0===t?i:{...i,...t}}const pX={barConfig:{stroke:"transparent"},labels:[],ticks:[]},gX=t=>t instanceof Date?t.toISOString().slice(0,10):`${t}`;function yX(t){const e=t._filteredData,n=t._x,i=lX(e.map((t,e)=>n(t,e)));i.length>2&&Et(t,"slopePeriods",`SlopeChart compares two periods, but its data has ${i.length} (${i.map(gX).join(", ")}). Every period is drawn; filter the data to two periods to compare them.`),t.ctx.slope={directions:uX(e,t._id,n,t._y)}}function xX(t,e,n){const i=mX(t.schema.slopeColor,Boolean(t._theme?.dark),t._theme?.textMuted);if(!i)return;for(;e.__d3plus__&&e.data;)n=(e=e.data).i;const o=(t=>t.ctx.slope)(t)?.directions.get(`${t._id(e,n)}`);return o?i[o]:void 0}const bX={name:"SlopeChart",paintDriven:!0,setup:t=>{t._lineMarkers=!0,t._yConfig=r.assign({},t._yConfig??{},pX),t._yTitle=null;const e=t.schema.shapeConfig.fill;t.schema.shapeConfig.fill=(n,i)=>xX(t,n,i)??("function"==typeof e?e(n,i):e),t._lineMarkerConfig=r.assign({},t._lineMarkerConfig??{},{fill:(e,n)=>{const{shapeConfig:i}=t.schema,o=i.Line?.stroke??i.stroke;return"function"==typeof o?o(e,n):o}});const n=t._preDraw.bind(t);t._preDraw=()=>{n(),yX(t)}},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"legend",default:!1,coerce:"const"},{key:"lineLabels",default:"both"},{key:"lineLabelConfig",merge:!0,default:{value:!0}},{key:"slopeColor",default:!1}]};var _X=lx(bX,JR);var kX=lx({name:"StackedArea",paintDriven:!0,ctx:{},fields:[{key:"stacked",default:!0},{key:"tooltipConfig",merge:!0,factory:JD}]},QD);const vX={labels:[],ticks:[]},wX={name:"Streamgraph",paintDriven:!0,setup:t=>{t._stackOffset=XS("silhouette"),t._stackOrder=VS("insideOut"),t._yConfig=r.assign({},t._yConfig??{},vX)},ctx:{},fields:[{key:"axisHover",default:"x"},{key:"shapeConfig",merge:!0,default:{Area:{curve:"monotoneX"}}}]};var MX=lx(wX,kX);const SX=2*Math.PI;function CX(t,e,n="equal",i){const o=Math.max(0,t);if(e<1)return[[0,o]];const r=e+1,a=void 0!==i&&Number.isFinite(i)?Math.min(Math.max(0,i),o):"area"===n?o*Math.sqrt(1/r):o/r,s=t=>"area"===n?Math.sqrt(a*a+(o*o-a*a)*t/e):a+(o-a)*t/e,c=[[0,a]];for(let t=1;t<=e;t++)c.push([s(t-1),s(t)]);return c}function $X(t,e,n,i){const o=n.endAngle-n.startAngle||1,r=t=>Math.min(SX,Math.max(0,(t-n.startAngle)/o*SX)),a=e-n.depth,s=i[i.length-1]?.[1]??0,[c,l]=a<0?[0,0]:i[a]??[s,s];return{innerRadius:c,outerRadius:l,startAngle:r(t.startAngle),endAngle:r(t.endAngle)}}function AX(t,e,n){if(e)return e;if(!n)return 0;const i=Math.sqrt(t.innerRadius**2+t.outerRadius**2);return i?n/i:0}function zX(t){return t<=180?t-90:t-270}function DX(t){return t>90&&t<270?t-180:t>=270?t-360:t}const LX=2*Math.PI;function FX(t){const{radii:e,...n}=t;return kj({...n,breadth:LX},t=>{const[n,i]=e[t.depth]??[0,0];return{startAngle:t.x0,endAngle:t.x1,innerRadius:n,outerRadius:i}})}const NX=wj;const BX=({viz:t})=>{const{width:e,height:n}=kt(t);t.ctx.sunburstWidth=e,t.ctx.sunburstHeight=n,t.ctx.sunburstNodes=new Map,t.ctx.sunburstGhosts=[];const i=function(t){return Mj(t,"sunburstPass",()=>{const e={laid:t.ctx.sunburstLaid,radii:t.ctx.sunburstRadii,origin:t.ctx.sunburstZoomOrigin};return t.ctx.sunburstZoomOrigin=void 0,e})}(t),o=t._filteredData??[];if(!o.length)return t.ctx.sunburstLaid=[],t.ctx.sunburstRadii=void 0,t.ctx.sunburstEnterArcs=new Map,t.ctx.sunburstOuterRadius=0,{shapeData:[]};const r=t.schema.shapeConfig??{},a="number"==typeof r.strokeWidth?r.strokeWidth:1,s=Math.max(0,Math.min(e,n)/2-3*a/2),c=NX(t),l=t.schema.groupBy.slice(c.level+1,t._drawDepth+1),h=CX(s,l.length,t.schema.ringSize,function(t,e){const n=t.schema.innerRadius,i="function"==typeof n?n(e):n;return"number"==typeof i&&Number.isFinite(i)?i:void 0}(t,s)),u=FX({data:o,keys:l,firstLevel:c.level+1,focusPath:c.path,sum:t.schema.sum,sort:t.schema.sort,aggs:t.schema.aggs,radii:h}),{laid:d,radii:f,origin:m}=i;t.ctx.sunburstGhosts=m&&d?function(t,e,n,i){return Sj(t,e).map(t=>({id:t.id,datum:t.datum,i:t.i,level:t.level,arc:$X(t,t.depth,n,i)}))}(d,u,m,h):[],t.ctx.sunburstEnterArcs=d&&f?function(t,e,n){return $j(t,e,(t,e)=>$X(t,t.depth,{startAngle:e.startAngle,endAngle:e.endAngle,depth:e.depth},n))}(d,u,f):new Map,t.ctx.sunburstLaid=u,t.ctx.sunburstRadii=h;const p=t.ctx.sunburstNodes;for(const t of u)gl(t.datum,t.share),p.set(t.datum,t);return t.ctx.sunburstOuterRadius=s,{shapeData:u}},EX=2*Math.PI,RX=1e-6;function PX(t,e){const n=e.rotate*Math.PI/180,i=Math.cos(n),o=Math.sin(n),r=e.width/2,a=e.height/2,s=(t,n)=>[e.x+t*i-n*o,e.y+t*o+n*i],c=[s(-r,-a),s(r,-a),s(r,a),s(-r,a)];if(c.some(([e,n])=>Math.hypot(e,n)>t.outerRadius+RX))return!1;if(t.innerRadius>0){const n=-e.x*i-e.y*o,s=e.x*o-e.y*i;if(Math.hypot(Math.max(Math.abs(n)-r,0),Math.max(Math.abs(s)-a,0))<t.innerRadius-RX)return!1}const l=t.endAngle-t.startAngle;if(l>=EX-RX)return!0;const h=[...c];if(l>Math.PI)for(let t=1;t<8;t++){const e=t/8;h.push(s(2*r*e-r,-a),s(2*r*e-r,a),s(-r,2*a*e-a),s(r,2*a*e-a))}return h.every(e=>function(t,[e,n]){const i=((Math.atan2(e,-n)-t.startAngle)%EX+EX)%EX;return i<=t.endAngle-t.startAngle+RX||i>=EX-RX}(t,e))}function TX(t,e,n,i,o){const r=r=>PX(t,{x:e,y:n,width:r,height:o,rotate:i});if(!r(RX))return 0;let a=0,s=2*t.outerRadius;for(let t=0;t<16;t++){const t=(a+s)/2;r(t)?a=t:s=t}return a}function OX(t,e,n,i,o,r){const{padding:a,lineHeight:s,maxLines:c}=r;for(let r=1;r<=c;r++){const c=r*s*o+2*a,l=TX(t,e[0],e[1],n,c);if(l<=2*a)return null;if(ZB(i,o,l-2*a)<=r)return{width:l,height:c}}return null}function WX(t,e,n,i,o={}){const r=VB(o),a=QB(o=>Boolean(OX(t,e,n,i,o,r)),r.fontMin,r.fontMax);if(null===a)return null;return{fontSize:a,...OX(t,e,n,i,a,r)}}function HX(t,e,n={}){const i=t.endAngle-t.startAngle;if(!(e.words.length&&i>0&&t.outerRadius>t.innerRadius))return null;const o=VB(n);if(t.innerRadius<=0&&i>=EX-RX){const n=WX(t,[0,0],0,e,o);return n?{orientation:"center",x:0,y:0,rotate:0,...n}:null}const r=(t.startAngle+t.endAngle)/2,a=(t.innerRadius+t.outerRadius)/2,s=[a*Math.sin(r),-a*Math.cos(r)],{tangential:c,radial:l}=(h=function(t){return(180*t/Math.PI%360+360)%360}(r),{tangential:DX(h),radial:zX(h)});var h;const u=WX(t,s,c,e,o),d=WX(t,s,l,e,o),f=(t,e,n)=>({orientation:t,x:s[0],y:s[1],rotate:e,...n});return u&&(!d||u.fontSize>=d.fontSize)?f("tangential",c,u):d?f("radial",l,d):null}function jX(t){const e=t.words.length,n=t.words.reduce((t,e)=>t+e,0)+t.space*Math.max(0,e-1);return t=>n*t}function IX(t,e,n,i){const{fontMin:o,fontMax:r}=i,a=new Map,s=new Map;for(const c of e){const e=XB(i.labelOf(c),c.datum,n);if(!e.words.length)continue;const l=i.arcOf(c),h=hE(t,c.datum,c.i??0),u="along"===h?null:HX(l,e,{fontMin:o,fontMax:r}),d="inside"===h||"outside"===h?null:sE(l,jX(e),{fontMin:o,fontMax:r}),f=lE(h,u?{fontSize:u.fontSize,truncated:!1}:null,d,"radial"===u?.orientation?"straight":"curved");"straight"===f&&u&&a.set(c,u),"curved"===f&&d&&s.set(c,d)}return{boxes:a,curves:s}}function GX(t,e,n,i){return IB(t,[...e].map(([t,e])=>({key:`sunburst-curved-${t.id}`,text:i.labelOf(t),fit:e,color:i.colorOf(t),datum:t.datum,index:t.i??0})),WB(n))}function qX(t,e,n){const i=0===t.depth;return{innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,padAngle:i?0:AX(t,e,n)}}function VX(t,e){return t._drawLabel(e.datum,e.i??0,e.level)}const YX=KB;const KX={out:.06,in:.06};const UX={prefix:"sunburst",origin:t=>({startAngle:t.startAngle,endAngle:t.endAngle,depth:t.depth})},XX={name:"Sunburst",layoutStage:BX,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=Hm(t,"Path"),r=Number(t.schema.padAngle)||0,s=Number(t.schema.padPixel)||0,c=t.schema.sum,l=t.schema.locale,h=function(t,e){return Ij(t.schema,e,{color:t.ctx.sunburstDefaultColor,fill:t.ctx.sunburstDefaultFill},"Path")}(t,o),u=t.ctx.sunburstEnterArcs??new Map,f=i.map(e=>{const n=e.i??0,i=qX(e,r,s),f=h(e);return{type:"path",key:`sunburst-${e.id}`,d:a.arcPath(i),arc:i,enterArc:u.has(e.id)?{...u.get(e.id),padAngle:0}:void 0,datum:e.datum,paint:{fill:Tm(o,e.datum,n,f),stroke:Pm(o.stroke,e.datum,n),strokeWidth:Pm(o.strokeWidth,e.datum,n),opacity:Pm(o.opacity,e.datum,n)??1},aria:{label:`${t._drawLabel(e.datum,n,e.level)}, ${c(e.datum)}, ${d.formatAbbreviate(100*e.share,l)}%`}}}),m=tw(o,f,t=>[i[t].datum,i[t].i??0]),p=function(t,e){return(t.ctx.sunburstGhosts??[]).map(t=>{const n={...t.arc,padAngle:0};return{type:"path",key:`sunburst-${t.id}`,d:a.arcPath(n),arc:n,paint:{fill:e(t),opacity:1}}})}(t,h),g=function(t,n,i,o){const{padAngle:r,padPixel:a}=o,s=jm(t,"Path")??{},c="number"==typeof s.fontMin?s.fontMin:8,l="number"==typeof s.fontMax?s.fontMax:24,h=e=>VX(t,e),{boxes:u,curves:d}=IX(t,n,s,{labelOf:h,arcOf:t=>qX(t,r,a),fontMin:c,fontMax:l}),f=n.filter(t=>u.has(t)),m=n=>e.colorContrast((n&&i(n))??"rgb(255, 255, 255)",t.schema.colorDefaults),p=Kx({data:f,label:e=>VX(t,e),x:t=>u.get(t).x,y:t=>u.get(t).y,rotate:t=>u.get(t).rotate,aes:()=>({}),id:t=>`sunburst-${t.id}`,datum:t=>t.datum,labelBounds:t=>{const{width:e,height:n}=u.get(t);return{x:-e/2,y:-n/2,width:e,height:n}},labelConfig:{fontMax:l,fontMin:c,split:YB,fontResize:!0,padding:0,textAnchor:"middle",verticalAlign:"middle",fontColor:e=>{let n=e;for(;n&&n.__d3plus__&&n.data;)n=n.data;return m(t.ctx.sunburstNodes.get(n))},...s}});for(const t of p)t.fadeSwap=KX;const g=s.fontColor,y=GX(t,d,s,{labelOf:h,colorOf:t=>{const e=Pm(g,t.datum,t.i??0);return"string"==typeof e?e:m(t)}});return[...p,...y]}(t,i,h,{padAngle:r,padPixel:s});return[...p,...f,...m,...g]},insetRegion:Cp,thresholdFunction:Bj,chartTransform:t=>vt(t,t.ctx.sunburstWidth,t.ctx.sunburstHeight),chartBodyRect:t=>{const e=t.ctx.sunburstOuterRadius??0;return{x:-e,y:-e,width:2*e,height:2*e}},setup:t=>Wj(t,UX),facet:{aspect:1},ctx:{},fields:[{key:"innerRadius"},{key:"padAngle",default:0},{key:"padPixel",default:0},{key:"ringSize",default:"equal"},{key:"shade",default:!0},{key:"shadeConfig",merge:!0,factory:()=>({...Hj})},{key:"sort",default:Ej,decorate:Rj},{key:"sum",default:I("value"),coerce:Pj,onSet:Tj},{key:"shapeConfig",merge:!0,factory:t=>({Path:{labelConfig:{fontResize:!0}},stroke:()=>Os(t),strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[_E(t,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:Oj},{key:"legend",coerce:"const",factory:kE}]};var ZX=lx(XX);function QX(t,e){return n.merge(e.values.map(e=>e.key&&e.values?QX(t,e):e),t.schema.aggs)}function JX(t,e,i){const o=t.ctx.tree.separation(t.schema.separation).size([e,i])(L.hierarchy({key:"root",values:n.nest(t._filteredData,t.schema.groupBy.slice(0,t._drawDepth+1))},t=>t.key&&t.values?t.values:null).sort(t.schema.sort)).descendants().filter(e=>(e.depth??0)<=t.schema.groupBy.length&&!!e.parent);return o.forEach((e,n)=>{const i=e.data;i.key&&i.values&&(e.data=QX(t,i)),e.__d3plus__=!0,e.i=n,e.data.depth=e.depth}),o}const tZ=({viz:t})=>{const e=t.schema.orient,i="vertical"===e,o="horizontal"===e,a=i?t.schema.height-t._margin.top-t._margin.bottom:t.schema.width-t._margin.left-t._margin.right,s=o?t.schema.height-t._margin.top-t._margin.bottom:t.schema.width-t._margin.left-t._margin.right,l=i?"left":"top",u=JX(t,s,a),{labelHeight:d,labelWidths:f}=function(t,e,i,o,r,a,s){let l=t.schema.shapeConfig.r;if("function"!=typeof l){const t=l;l=()=>t}const u=h.max(e,t=>1===t.depth?l(t.data,t.i):0),d=h.max(e,t=>t.children?0:l(t.data,t.i)),f=h.extent(e,t=>t.y),m=h.min([i?50:100,(f[1]-u-d)/(t.schema.groupBy.length+1)]);t.ctx.labelHeight=m;const p=n.nest(e,t=>t.depth).map(e=>{const n=e.values;return n.reduce((e,i,o)=>{const a=o<n.length-1?n[o+1].x:r+t._margin[s],c=o?n[o-1].x:t._margin[s];return h.min([e,a-i.x,i.x-c])},r)});t.ctx.labelWidths=p;const g=c.scaleLinear().domain(f).range([u+m,a-d-m]);return e.forEach(t=>{const e=g(t.y);o?(t.y=t.x,t.x=e):t.y=e}),{labelHeight:m,labelWidths:p}}(t,u,i,o,s,a,l);return function(t,e,i,o,a,s){const c=t.schema.shapeConfig,l=e.filter(t=>(t.depth??0)>1).map(t=>r.assign({},t)),h=function(t,e,n,i,o){const r=t.schema.label;return{id:(e,n)=>t._ids(e.data,n)[(e.depth??1)-1],label:(e,n)=>{if(r)return r(e.data,n);const i=t._ids(e.data,n).slice(0,e.depth??1);return i[i.length-1]},labelConfig:{fontResize:!1,textAnchor:e=>{const n=e.data??e;return i?"middle":n.children&&n.depth!==t._drawDepth+1?"end":"start"},verticalAlign:t=>{const e=t.data??t;return i?1===e.depth?"bottom":"top":"middle"}},hitArea:(r,a,s)=>{const c=e,l=s.r??(i?s.height/2:s.width/2),h=n[(r.depth??1)-1];return{width:i?h:2*l+h,height:o?c:2*l+c,x:i?-h/2:r.children&&r.depth!==t.schema.groupBy.length?-(l+h):-l,y:o?-c/2:r.children&&r.depth!==t.schema.groupBy.length?-(l+e):-l}},labelBounds:(o,r,a)=>{const s=e,c=i?"height":"width",l=a.r??(i?a.height/2:a.width/2),h=n[(o.depth??1)-1],u=i?"width":"height",d=i?"x":"y",f=i?"y":"x";return{[u]:h,[c]:s,[d]:-h/2,[f]:o.children&&o.depth!==t.schema.groupBy.length?-(l+s):l}}}}(t,i,o,a,s),u=t.schema.shape,d=n.nest(e,t=>u(t.data)),f=d.map(t=>t.key),m=(t.ctx.previousShapes??[]).filter(t=>!f.includes(t)),p=d.concat(m.map(t=>({key:t,values:[]})));t.ctx.linksData=l,t.ctx.linkD=t=>{let e=c.r;"function"==typeof e&&(e=e(t.data,t.i));const n=(t.parent.x??0)-(t.x??0)+(a?0:e),i=(t.parent.y??0)-(t.y??0)+(a?e:0),o=a?0:-e,r=a?-e:0;return a?`M${o},${r}C${o},${(r+i)/2} ${n},${(r+i)/2} ${n},${i}`:`M${o},${r}C${(o+n)/2},${r} ${(o+n)/2},${i} ${n},${i}`},t.ctx.shapeGroups=p,t.ctx.shapeConfig=h,t.ctx.previousShapes=f}(t,u,d,f,i,o),{shapeData:u}};function eZ(t,e,n){const i=e.data??e,o=e.i??0,r=e.x??0,a=e.y??0;switch(t){case"Circle":{const t=Number(Pm(n.r,i,o)??0);return{geom:{type:"circle",cx:r,cy:a,r:t},aes:{r:t}}}case"Rect":{const t=Number(Pm(n.width,i,o)??0),e=Number(Pm(n.height,i,o)??0);return{geom:{type:"rect",x:r-t/2,y:a-e/2,width:t,height:e},aes:{width:t,height:e}}}case"Path":return{geom:{type:"path",d:String(Pm(n.d,i,o)??"")},aes:{}};default:return null}}const nZ={name:"Tree",layoutStage:tZ,emit:({viz:t})=>{const e=t.ctx.linksData,n=t.ctx.linkD,i=t.ctx.shapeGroups,o=t.ctx.shapeConfig;if(!i||!o)return[];const r=[];if(e&&e.length&&n){const i=Hm(t,"Path");for(let o=0;o<e.length;o++){const a=e[o],s=a.data??a,c=Om(i,s,o),l=t._ids(s,o)[(a.depth??1)-1],h=a.x??0,u=a.y??0;r.push({type:"path",key:`tree-link-${l}`,d:n(a),datum:s,paint:c,transform:{x:h,y:u},aria:{label:`${t._drawLabel(s,a.i??o)}.`}})}}for(const{key:e,values:n}of i){if(!n.length)continue;const i={...Hm(t,e),...o},a=n,s=[];for(let n=0;n<a.length;n++){const c=a[n],l=c.data??c,h=eZ(e,c,i);if(!h)continue;const u=o.id(c,n),d=Om(i,l,n),f={...h.geom,key:`tree-${e}-${u}`,datum:l,paint:d,aria:{label:`${t._drawLabel(l,n)}.`}};r.push(f);const m=Jv(i,f,l,n);m&&s.push(m)}r.push(...s);const c=Kx({data:a,label:(t,e)=>o.label(t,e),x:t=>t.x??0,y:t=>t.y??0,aes:t=>eZ(e,t,i)?.aes??{},rotate:H(0),id:(t,e)=>o.id(t,e),labelBounds:(t,e,n)=>o.labelBounds(t,e,n),labelConfig:{...jm(t,e),...o.labelConfig}});r.push(...c)}return r},insetRegion:Cp,ctx:{tree:L.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(t,e)=>t.parent===e.parent?1:2},{key:"shape",default:H("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>(t.ctx.linksData&&t._chartScene,t._drawLabel(e,n)),labelConfig:{fontColor:()=>Ws(t)},Path:{fill:"none",stroke:()=>t.schema.colorDefaults.missing,strokeWidth:2},r:H(7),width:H(12),height:H(12)})},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>t._drawLabel(e,n,(e.depth??1)-1)})},{key:"legendTooltip",merge:!0,factory:t=>({title:ol.bind(t)})}]};var iZ=lx(nZ);const oZ={fontSize:11,fontWeight:600,padding:3};function rZ(t){if(!1===t.schema.groupLabels)return null;const e=t.schema.groupLabelConfig??{};return{...oZ,fontFamily:t.schema.fontFamily,...e}}function aZ(t){return Math.ceil(1.2*t.fontSize+2*t.padding)}function sZ(t,e){const{drawDepth:n,padding:i,style:o}=t;return t=>{const r=t;if(!o||r.depth<1||r.depth>n||null==r.data.key||!function(t,e,n){return e>=2*aZ(n)&&t>=3*n.fontSize+2*n.padding}(r.x1-r.x0,r.y1-r.y0,o))return i;const a=aZ(o);return e.set(r,a),a+i}}function cZ(t){return t.ancestors().reverse().slice(1).map(t=>`${t.data.key}`).join("/")}const lZ=({viz:t})=>{const e=t._filteredData;if(!e||!e.length)return{shapeData:[]};const{width:i,height:o}=kt(t),r=n.nestGroups(e,t.schema.groupBy.slice(0,t._drawDepth+1)),a=L.hierarchy({values:r},t=>t.values).sum(t.schema.sum).sort(t.schema.sort),s=t.schema.layoutPadding,c=new Map,l=rZ(t),h=t.ctx.treemap.padding(s).paddingTop(sZ({drawDepth:t._drawDepth,padding:s,style:l},c)).size([i,o]).tile(t.schema.tile)(a),u=[];h.children&&function i(o){for(const r of o){if(r.depth<=t._drawDepth){i(r.children??[]);continue}const o=r.data,a=o.values??[],s=1===a.length?e.indexOf(a[0]):void 0,c=r;c.__d3plus__=!0,c.id=o.key,c.i=void 0!==s&&s>-1?s:void 0,c.data=n.merge(a,t.schema.aggs),c.x=r.x0+(r.x1-r.x0)/2,c.y=r.y0+(r.y1-r.y0)/2,u.push(c)}}(h.children);const d=t.schema.sort;u.slice().sort(d).forEach((t,e)=>{t.data.rank=e});const f=h.value;!function(t,e){for(const[i,o]of t){const t=i.leaves().map(t=>t.data),r=n.merge(t,e.aggs);delete r._isAggregation,delete r._threshold,delete r[vl],r[ue]=i.depth-1;const a=e.label?e.label(r,0):void 0;null!=a&&!1!==a&&""!==a&&(r[de]=`${a}`),gl(r,(i.value??0)/e.total),i.groupHeader={__d3plus__:!0,data:r,depth:i.depth-1,id:cZ(i),x0:i.x0,y0:i.y0,x1:i.x1,y1:Math.min(i.y1,i.y0+o)}}}(c,{aggs:t.schema.aggs,label:l?.label,total:f});const m=t.schema.sum;return u.forEach(t=>{const e=m(t.data)/f;t.share=e,gl(t.data,e)}),{shapeData:u}};function hZ(t,n,o){if(!n.length)return[];const r=new Map,a=e=>{let n=r.get(e);return void 0===n&&(n=Pm(o.fill,e.data,0)??function(t,e,n){const o=()=>b.interpolateRgb(Os(t),Ws(t))(.7);if(t.schema.colorScale)return o();const r=Hm(t,"Rect"),a=i.color(`${Pm(r.fill,e,n)}`);return a?a.darker(.8).formatHex():o()}(t,e.data,0),r.set(e,n)),n},s=t.schema.sum,c=e=>t._drawLabel(e.data,0,e.depth),l=n.map(e=>({type:"rect",key:`treemap-group-${e.id}`,x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0,datum:e.data,paint:{fill:a(e)},aria:{label:`${c(e)}, ${s(e.data)}, ${d.formatAbbreviate(100*xl(e.data),t.schema.locale)}%`}})),h=new Map(n.map(t=>[t.data,t])),u=Kx({data:n,label:t=>c(t),x:t=>t.x0,y:t=>t.y0,aes:t=>{const e=t;return{width:e.x1-e.x0,height:e.y1-e.y0}},rotate:H(0),id:t=>`group-${t.id}`,datum:t=>t.data,labelBounds:(t,e,n)=>{const{width:i,height:o}=n;return{x:0,y:0,width:i,height:o}},labelConfig:{fontColor:i=>{const r=h.get(i.data)??n[0];return Pm(o.fontColor,r.data,0)??e.colorContrast(a(r),t.schema.colorDefaults)},...o.fontFamily?{fontFamily:o.fontFamily}:{},fontResize:!1,fontSize:o.fontSize,fontWeight:o.fontWeight,maxLines:1,padding:o.padding,textAnchor:"start",verticalAlign:"middle"}});for(const t of u)t.shapeType="Label";return[...l,...u]}const uZ={treemapBinary:L.treemapBinary,treemapDice:L.treemapDice,treemapResquarify:L.treemapResquarify,treemapSlice:L.treemapSlice,treemapSliceDice:L.treemapSliceDice,treemapSquarify:L.treemapSquarify},dZ=t=>!!t.children&&1===t.children.length&&!0===t.children[0].data._isAggregation,fZ={name:"Treemap",layoutStage:lZ,emit:({viz:t,shapeData:n})=>{const i=n??[];if(!i.length)return[];const o=t.schema.locale,r=t._drawLabel,a=Hm(t,"Rect"),s=i.map(e=>{const n=Pm(a.fill,e.data,e.i),i=Pm(a.stroke,e.data,e.i),s=Pm(a.opacity,e.data,e.i),c=Pm(a.strokeWidth,e.data,e.i);return{type:"rect",key:`treemap-${e.id}`,x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0,datum:e.data,paint:{fill:Tm(a,e.data,e.i,n),stroke:"string"==typeof i||null==i?i:String(i),opacity:s,strokeWidth:c},aria:{label:`${r(e.data,e.i??0)}, ${t.schema.sum(e.data)}, ${d.formatAbbreviate(100*e.share,o)}%`}}}),c=Kx({data:i,label:t=>{const e=t;return[r(e.data,e.i??0),`${d.formatAbbreviate(100*e.share,o)}%`]},x:t=>{const e=t;return e.x0+(e.x1-e.x0)/2},y:t=>{const e=t;return e.y0+(e.y1-e.y0)/2},aes:t=>{const e=t;return{width:e.x1-e.x0,height:e.y1-e.y0}},rotate:H(0),id:t=>t.id,labelBounds:(t,e,n)=>{const{width:i,height:o}=n;let r=Math.min(32,.5*(o-10));return r<8&&(r=0),[{width:i,height:o-r,x:-i/2,y:-o/2},{width:i,height:r+10,x:-i/2,y:o/2-r-10}]},labelConfig:{fontMax:32,textAnchor:t=>t&&0===t.l?"start":"middle",verticalAlign:t=>t&&0===t.l?"top":"bottom",fontColor:n=>{const i=n&&n.data?n.data:n,o=Pm(a.fill,i,i.i);return"string"==typeof o?e.colorContrast(o,t.schema.colorDefaults):void 0},...jm(t,"Rect")}});for(const t of c)t.shapeType="Label";const l=tw(a,s,t=>[i[t].data,i[t].i]),h=rZ(t),u=h?hZ(t,function(t){const e=new Set;for(const n of t){let t=n.parent;for(;t;t=t.parent)t.groupHeader&&e.add(t.groupHeader)}return[...e].sort((t,e)=>t.depth-e.depth)}(i),h):[];return[...s,...l,...c,...u]},thresholdFunction:(t,e)=>pj(e,{aggs:t.schema.aggs,drawDepth:t._drawDepth,groupBy:t.schema.groupBy,threshold:t.schema.threshold,thresholdKey:t.schema.thresholdKey,label:(e,n)=>t._drawLabel(e,n)}),ctx:{treemap:L.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"groupLabels",default:!0},{key:"groupLabelConfig",default:{},merge:!0},{key:"sort",default:(t,e)=>(e.value??0)-(t.value??0),decorate:(t,e)=>{const n=e;return(t,e)=>{const i=dZ(t),o=dZ(e);return i&&!o?1:!i&&o?-1:n(t,e)}}},{key:"sum",default:I("value"),coerce:t=>"function"==typeof t?t:q(t),onSet:(t,e)=>{t.schema.thresholdKey=e}},{key:"tile",default:L.treemapSquarify,coerce:t=>{if("string"!=typeof t)return t;const e=`treemap${t.charAt(0).toUpperCase()}${t.slice(1)}`;return uZ[e]??L.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:t=>({ariaLabel:(e,n)=>{const i="number"==typeof e.rank?`${e.rank+1}. `:"",o=t.schema.sum;return`${i}${t._drawLabel(e,n)}, ${o(e,n)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:[_E(t,"sum")]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:t=>vE(t,"sum")},{key:"legend",coerce:"const",factory:kE}]};var mZ=lx(fZ);function pZ(t){const e=Array.isArray(t)?t:[t];return new Set(e.filter(t=>"box"===t||"quartiles"===t||"points"===t))}function gZ(t){const e=t=>{t.interactive=!1;const n=t.children;n&&n.forEach(e)};return t.forEach(e),t}function yZ(t,e,n){const i=t.value(e);return t.vertical?{x:n,y:i}:{x:i,y:n}}function xZ(t,e,n,i){const{viz:o}=t,r=e.map(t=>t.slot.half*("both"===t.slot.side?.16:.08)),a=Math.max(3,Math.min(10,Math.min(...r))),s=n.vertical,c=Os(o),l=e.map(({row:t,meta:e,slot:r})=>{const l=`density-box-${t.id}`,h="both"===r.side?r.center:r.center+("start"===r.side?-1:1)*Math.min(4,r.half/4),u=e.summary.values.map((t,e)=>({...yZ(n,t,h),id:l,i:e})),d=Rm("Box").renderMode("compute").config({id:t=>t.id,orient:s?"vertical":"horizontal",rectWidth:a,rectConfig:{fill:i,stroke:i,strokeWidth:0},medianConfig:{fill:c},outlierConfig:{Circle:{fill:i,r:1.5,strokeWidth:0}},whiskerConfig:{endpoint:"Rect",endpointConfig:{Rect:{fill:i,height:s?1:a/2,width:s?a/2:1}},lineConfig:{stroke:i,strokeWidth:1}}}).config(o.schema.innerConfig?.box??{}).data(u);return d.render(),{type:"group",key:l,children:Im(d)}});return fK(l,s?"x":"y"),gZ(l)}function bZ(t,e,n,i){const{viz:o}=t,r=o.schema.innerConfig?.quartiles??{},a=(t,o)=>{const a=[],s=new Map;e.forEach(({row:e,meta:i,slot:o})=>{t.forEach(t=>{const r=i.summary[t],c=JY(i.summary.curve,r)*i.scale*o.half,[l,h]=yK(o,c),u=`density-${t}-${e.id}`;s.set(u,o.center),a.push({id:u,...yZ(n,r,l)},{id:u,...yZ(n,r,h)})})});const c=Rm("Line").renderMode("compute").config({stroke:i,strokeWidth:1,strokeDasharray:o,curve:"linear"}).config(r).data(a);c.render();const l=Im(c);return dK(l,n.vertical?"x":"y",s),gZ(l)};return[...a(["q1","q3"],"4 3"),...a(["median"],"0")]}function _Z(t,e,n){const{viz:i,events:o}=t,r=i.schema.innerConfig?.points??{},a="number"==typeof r.r?r.r:2.5,s=yM(e.map(({meta:t})=>t.summary.observed.map(t=>({value:n.value(t),r:a}))),{padding:.5,extent:Math.max(1,Math.min(...e.map(t=>t.slot.half*("both"===t.slot.side?.8:.4)))),overflow:"shrink"}),c=[];e.forEach(({row:t,meta:e,slot:i},o)=>{const r="both"===i.side?0:("start"===i.side?-1:1)*i.half*.45;e.summary.observed.forEach((a,l)=>{const h=e.summary.rows[l];c.push({__d3plus__:!0,data:h,i:l,id:`density-point-${t.id}-${l}`,...yZ(n,a,i.center+r+s.offsets[o][l])})})});const l=Rm("Circle").renderMode("compute").config(Hm(i,"Circle")).config({r:a*s.scale,label:!1,x:t=>t.x,y:t=>t.y}).config(r).data(c);return i._wirePlotShapeEvents(l,"Circle",o),l.render(),Im(l)}function kZ(t,e,n){const i=pZ(t.viz.schema.inner);if(!e.length||!i.size)return[];const o=Ws(t.viz),r=(t,e)=>e.length?[{type:"group",key:`violin-${t}`,children:e}]:[];return[...i.has("points")?r("points",_Z(t,e,n)):[],...i.has("quartiles")?r("quartiles",bZ(t,e,n,o)):[],...i.has("box")?r("box",xZ(t,e,n,o)):[]]}const vZ=(t,e)=>{const{viz:n,values:i,x:o,y:r,xRange:a,yRange:s,xDomain:c,yDomain:l}=t,h="y"!==n.schema.discrete,u=h?o:r,d=h?r:o,f=h?"x":"y",m=h?a:s,p=h?c:l,g=p.map(t=>u(t,f)).sort((t,e)=>t-e);let y=mK(m[m.length-1]-m[0],p.length,.5);for(let t=1;t<g.length;t++)y=Math.min(y,g[t]-g[t-1]);const x=i.filter(t=>nK(t)),b=pK(x.map(t=>`${t[f]}`),{position:t=>u(t,f),step:y,gap:n._groupPadding??0,split:Boolean(n.schema.split)}),_=x.map((t,e)=>({row:t,meta:nK(t),slot:b[e]})),k=[];_.forEach(({row:t,meta:e,slot:n})=>{gK(e.summary.curve,e.scale,n.half).forEach(e=>{const[i,o]=yK(n,e.extent);k.push({...t,id:iK(t),__pos:d(e.value),__low:i,__high:o})})});const v=t=>t.__pos,w=t=>t.__low,M=t=>t.__high,S=h?{x:w,x0:w,x1:M,y:v,y0:v,y1:null}:{x:v,x0:v,x1:null,y:M,y0:M,y1:w},C=Dz({...t,values:k,shapeConfig:{...t.shapeConfig,...S}},e);return dK(C,f,new Map(_.map(({row:t,slot:e})=>[iK(t),e.center]))),C.concat(kZ(t,_,{vertical:h,value:t=>d(t)}))},wZ={name:"Violin",paintDriven:!0,defaults:{groupPadding:16},setup:t=>sK(t,{valueAxis:t=>"y"===t.schema.discrete?"x":"y",categoryPadding:()=>[.5,.5],emit:vZ}),ctx:{},fields:[{key:"discrete",default:"x"},{key:"inner",default:"box"},{key:"split",default:!1},...lK(),...hK(2),{key:"innerConfig",merge:!0,default:{box:{},quartiles:{},points:{}}},{key:"shapeConfig",merge:!0,default:{Area:{fillOpacity:.85,strokeWidth:1},Bar:{label:!1}}}]};var MZ=lx(wZ,ZD);const SZ=t=>Number.isFinite(t)&&t>0?t:0;function CZ(t,e){const n=t.map(SZ),i=n.reduce((t,e)=>t+e,0),o=Math.max(0,Math.round(SZ(e)));if(!i||!o)return n.map(()=>0);const r=n.map(t=>t/i*o),a=r.map(Math.floor);let s=o-a.reduce((t,e)=>t+e,0);const c=r.map((t,e)=>({i:e,r:t-a[e],v:n[e]})).filter(t=>t.v>0).sort((t,e)=>e.r-t.r||e.v-t.v||t.i-e.i);for(let t=0;s>0&&c.length;t=(t+1)%c.length)a[c[t].i]++,s--;return a}function $Z(t,{cells:e,unit:n}){if(void 0!==n&&SZ(n)){const e=t.map(SZ).reduce((t,e)=>t+e,0);return CZ(t,Math.round(e/n))}return CZ(t,e)}function AZ(t,{rows:e,columns:n,fillDirection:i,unit:o}){const r=Math.max(1,Math.round(SZ(e))||1),a=Math.max(1,Math.round(SZ(n))||1);if(void 0===o||!SZ(o))return{rows:r,columns:a};const s=Math.max(1,t);return"column"===i?{rows:r,columns:Math.ceil(s/r)}:{rows:Math.ceil(s/a),columns:a}}function zZ(t,{rows:e,columns:n,fillDirection:i,fillStart:o}){let r="column"===i?t%e:Math.floor(t/n),a="column"===i?Math.floor(t/e):t%n;return o.startsWith("bottom")&&(r=e-1-r),o.endsWith("right")&&(a=n-1-a),{row:r,column:a}}function DZ(t,e,{rows:n,columns:i,padding:o}){const r=SZ(t),a=SZ(e),s=Math.max(1,n),c=Math.max(1,i);let l=SZ(o),h=Math.min((r+l)/c,(a+l)/s);l>.4*h&&(l=.4*Math.min(r/c,a/s),h=Math.min((r+l)/c,(a+l)/s));const u=Math.max(0,h-l);return{size:u,padding:l,x:(r-(c*u+(c-1)*l))/2,y:(a-(s*u+(s-1)*l))/2}}const LZ=["top-left","top-right","bottom-left","bottom-right"];function FZ(t){const e=t.schema.fillStart,n=Number(t.schema.unit);return{fillDirection:"column"===t.schema.fillDirection?"column":"row",fillStart:LZ.includes(e)?e:"top-left",unit:n>0&&Number.isFinite(n)?n:void 0}}const NZ=({viz:t})=>{const e=t._filteredData??[];if(!e.length)return{shapeData:[]};const n=t.schema.sum,i=t.schema.sort,o=e.map((t,e)=>e);"function"==typeof i&&o.sort((t,n)=>i(e[t],e[n])||t-n);const r=o.map(t=>Number(n(e[t],t))),a=r.reduce((t,e)=>t+(Number.isFinite(e)&&e>0?e:0),0),s=r.map(t=>a&&Number.isFinite(t)&&t>0?t/a:0);o.forEach((t,n)=>gl(e[t],s[n]));const{fillDirection:c,fillStart:l,unit:h}=FZ(t),u=AZ(0,{rows:Number(t.schema.rows),columns:Number(t.schema.columns),fillDirection:c}),d=$Z(r,{cells:u.rows*u.columns,unit:h}),f=AZ(d.reduce((t,e)=>t+e,0),{...u,fillDirection:c,unit:h}),{width:m,height:p}=kt(t),g=DZ(m,p,{...f,padding:Number(t.schema.cellPadding)||0}),y=g.size+g.padding,x=[];let b=0;return o.forEach((n,i)=>{const o=e[n],r=t._ids(o,n).join("-"),a=s[i];for(let t=0;t<d[i];t++,b++){const e=zZ(b,{...f,fillDirection:c,fillStart:l});x.push({__d3plus__:!0,data:o,i:n,id:`${r}-${t}`,k:b,n:t,...e,x:g.x+e.column*y,y:g.y+e.row*y,size:g.size,share:a})}}),t.ctx.waffleTotal=a,t.ctx.waffleGrid=f,t.ctx.waffleGeometry=g,{shapeData:x}};function BZ(t,e){const{x:n,y:i,size:o}=t;if("circle"===e)return{type:"circle",cx:n+o/2,cy:i+o/2,r:o/2};const r={type:"rect",x:n,y:i,width:o,height:o};if("rounded"!==e)return r;const a=.25*o;return{...r,rx:a,ry:a}}function EZ(t){return"rounded"===t||"circle"===t?t:"square"}function RZ(t,e){return null!=t&&Number.isFinite(t)?`${d.formatAbbreviate(100*t,e)}%`:""}function PZ(t,e){const n=t.schema.sum;if(e._isColorScaleBucket)return Ds(t,e.color,n);const i=bl(e),o=xl(i);return Number.isFinite(o)?o:_l(i,t._legendData||[],t=>n(t,0))}function TZ(t){const e=()=>t.schema.locale;return[[()=>t.schema.translate("Value"),(n,i,o)=>{if(o&&o._isColorScaleBucket)return"";const r=t.schema.sum,a=Number(r(n,i));return Number.isFinite(a)?d.formatAbbreviate(a,e()):""}],[()=>t.schema.translate("Share"),(n,i,o)=>RZ(PZ(t,o??{}),e())]]}const OZ=t=>!0===t._isAggregation,WZ={name:"Waffle",layoutStage:NZ,emit:({viz:t,shapeData:e})=>{const n=e??[];if(!n.length)return[];const i=EZ(t.schema.cellShape),o=Hm(t,"circle"===i?"Circle":"Rect"),r=t.schema.icon,a=t.schema.sum,s=t.schema.locale,c=(t,e)=>r?Pm(r,t,e):void 0,l=n.map(e=>{const{data:n,i:r}=e,l=c(n,r),h=Pm(o.fill,n,r),u=l?{fill:"transparent"}:{fill:Tm(o,n,r,h),stroke:Pm(o.stroke,n,r),strokeWidth:Pm(o.strokeWidth,n,r)},f=0===e.n?`${t._drawLabel(n,r)}, ${a(n,r)}, ${d.formatAbbreviate(100*e.share,s)}%`:void 0;return{...BZ(e,i),key:`waffle-${e.id}`,index:r,datum:n,paint:{...u,opacity:Pm(o.opacity,n,r)},aria:f?{label:f}:{hidden:!0}}}),h=tw(r?{...o,backgroundImage:(t,e)=>c(t,e)||Pm(o.backgroundImage,t,e),backgroundImageFit:(t,e)=>c(t,e)?"contain":Pm(o.backgroundImageFit,t,e)}:o,l,t=>[n[t].data,n[t].i]);return[...l,...h]},insetRegion:Cp,thresholdFunction:(t,e)=>pj(e,{aggs:t.schema.aggs,drawDepth:t._drawDepth,groupBy:t.schema.groupBy,threshold:t.schema.threshold,thresholdKey:t.schema.thresholdKey,label:(e,n)=>t._drawLabel(e,n)}),facet:{aspect:1},ctx:{},fields:[{key:"cellPadding",default:2},{key:"cellShape",default:"square"},{key:"columns",default:10},{key:"fillDirection",default:"row"},{key:"fillStart",default:"top-left"},{key:"icon"},{key:"rows",default:10},{key:"sort",factory:t=>(t=>(e,n)=>{const i=t.schema.sum;return i(n)-i(e)})(t),decorate:(t,e)=>{const n=e;return(t,e)=>{const i=OZ(t),o=OZ(e);return i&&!o?1:!i&&o?-1:n(t,e)}}},{key:"sum",default:I("value"),coerce:t=>"function"==typeof t?t:q(t),onSet:(t,e)=>{t.schema.thresholdKey=e}},{key:"unit"},{key:"zoom",default:!1},{key:"tooltipConfig",merge:!0,factory:t=>({tbody:TZ(t)})},{key:"legendTooltip",merge:!0,factory:t=>({tbody:TZ(t)})},{key:"legendSort",factory:t=>(t=>(e,n)=>{const i=t.schema.sort;return"function"==typeof i?i(e,n):0})(t)}]};var HZ=lx(WZ);const jZ={increase:"Increase",decrease:"Decrease",total:"Total"};function IZ(t,n,i){const o=n[`${t}Color`];if("string"==typeof o&&o)return o;const r={...e.colorDefaults,...i};return"increase"===t?r.on:"decrease"===t?r.off:r.sequential}function GZ(t,e){return"total"===t.kind?e(t.end):t.change>0?`+${e(t.change)}`:e(t.change)}const qZ=t=>"total"===t.kind?t.end>=0:t.change>=0,VZ={height:20,width:56,minWidth:64,gap:2};function YZ(t,e,n){const i=qZ(t),{gap:o}=VZ;if(n){const t=Math.max(e.width,VZ.minWidth),n=VZ.height;return{x:-t/2,y:i?-e.height-n-o:e.height+o,width:t,height:n}}const r=VZ.width;return{x:i?e.width+o:-e.width-r-o,y:-e.height/2,width:r,height:e.height}}function KZ(t,e){const n=qZ(t);return e?{textAnchor:"middle",verticalAlign:n?"bottom":"top"}:{textAnchor:n?"start":"end",verticalAlign:"middle"}}function UZ(t,e,n){return t&&"total"!==t.kind?[[n("Running Total"),e(t.end)]]:[]}function XZ(t,e){return({data:n,x:i,y:o,x2:r})=>{if(r||!e.labels())return[i,o];const a=e.vertical(),s=a?o:i,c=n.map(e=>e.data?t(e.data):void 0).filter(t=>!!t),l=s.range(),h=Math.abs(l[l.length-1]-l[0]);if(!c.length||!h)return[i,o];const u=s.domain().slice();a&&u.reverse();const d=a?VZ.height+VZ.gap:VZ.width+VZ.gap,f=function(t,e,n){let[i,o]=t;const r=Math.min(Math.max(n,0),.45);if(!r||!e.length)return[i,o];let a=-1/0,s=1/0;for(const t of e)qZ(t)?a=Math.max(a,t.end):s=Math.min(s,t.end);for(let t=0;t<8;t++){const t=o-i;Number.isFinite(a)&&(o=Math.max(o,a+r*t)),Number.isFinite(s)&&(i=Math.min(i,s-r*t))}return[i,o]}([u[0],u[1]],c,d/h);return a&&f.reverse(),s.domain(f),[i,o]}}function ZZ(t,e,n){const i=[],o=t=>{if("rect"===t.type&&"Bar"===t.shapeType&&t.datum?.data){const o=t.datum.data,r=e(o),a=n?(t.transform?.x??0)+(t.x??0):(t.transform?.y??0)+(t.y??0),s=(n?t.width:t.height)??0;r&&Number.isFinite(a)&&Number.isFinite(s)&&i.push({step:r,datum:o,lo:a,hi:a+s})}t.children?.forEach(o)};return t.forEach(o),i}function QZ(t,e,n){const i=new Map;for(const e of t){let t=i.get(e.step.series);t||i.set(e.step.series,t=new Map),t.has(e.step.index)||t.set(e.step.index,e)}const o=[];return i.forEach(t=>{t.forEach(i=>{const r=t.get(i.step.index-1);if(!r||!i.step.joins)return;const a=e(r.step.end);if(!Number.isFinite(a))return;const s=i.lo+i.hi>=r.lo+r.hi,c=s?r.hi:r.lo,l=s?i.lo:i.hi;o.push(n?{from:r,x1:c,y1:a,x2:l,y2:a}:{from:r,x1:a,y1:c,x2:a,y2:l})})}),o}function JZ(t,e,n){return"function"==typeof t?t(e,n):t}function tQ(t,e){return t.map((t,n)=>{const i=t.from.datum,o={fill:"none",stroke:JZ(e.stroke,i,n),strokeWidth:JZ(e.strokeWidth,i,n),strokeOpacity:JZ(e.strokeOpacity,i,n)},r=qV(JZ(e.strokeDasharray,i,n));return r&&(o.strokeDasharray=r),{type:"line",key:`waterfall-connector-${t.from.step.series}-${t.from.step.index}`,points:[[t.x1,t.y1],[t.x2,t.y2]],curve:"linear",paint:o,interactive:!1,interactionGroup:"axis"}})}const eQ=["increase","decrease","total"],nQ=t=>"number"==typeof t&&Number.isFinite(t)?t:void 0;function iQ(t,e){const n=Number(t instanceof Date?+t:t)-Number(e instanceof Date?+e:e);return Number.isNaN(n)?0:n}function oQ(t,e,n){const i=t.values.filter(t=>void 0!==t),o=i.reduce((t,e)=>t+e,0),{series:r,index:a}=n;if(t.subtotal){const n=i.length?o:e;return{series:r,index:a,category:t.category,kind:"total",start:0,end:n,change:n-e,joins:a>0&&(s=n,c=e,Math.abs(s-c)<=1e-9*Math.max(1,Math.abs(s),Math.abs(c)))}}var s,c;if(i.length)return{series:r,index:a,category:t.category,kind:o<0?"decrease":"increase",start:e,end:e+o,change:o,joins:a>0}}function rQ(t,e){const{category:n,series:i,value:o,subtotal:r,sort:a}=e,s=new Map;t.forEach((t,e)=>{const o=`${i(t,e)}`,r=n(t,e),a=r instanceof Date?""+ +r:`${r}`;let c=s.get(o);c||s.set(o,c=new Map);const l=c.get(a);l?l.rows.push([t,e]):c.set(a,{category:r,rows:[[t,e]]})});const c=new Map;return s.forEach((t,e)=>{const n=Array.from(t.values());!function(t,e){e?t.sort((t,n)=>e(t.rows[0][0],n.rows[0][0])):t.sort((t,e)=>iQ(t.category,e.category))}(n,a);let i=0,s=0;for(const t of n){const n=oQ({category:t.category,values:t.rows.map(([t,e])=>nQ(o(t,e))),subtotal:!!r&&t.rows.some(([t,e])=>!!r(t,e))},i,{series:e,index:s});n&&(i=n.end,s++,t.rows.forEach(([t])=>c.set(t,n)))}}),c}function aQ(t){const e=new Set;for(const n of t)n&&e.add(n.kind);return eQ.filter(t=>e.has(t))}function sQ(t,e){return void 0===nQ(t)&&e&&"total"===e.kind?e.end:t}function cQ(t){return e=>{for(const n of e){const e=n.key;for(const i of n){const n=(i.data??[]).find(t=>t.id===e),o=n&&n.data?t(n.data):void 0;o&&(i[0]=Math.min(o.start,o.end),i[1]=Math.max(o.start,o.end))}}}}const lQ="__d3plusWaterfallKind",hQ=t=>t.ctx.waterfall,uQ=t=>"y"===t.schema.discrete?"y":"x",dQ=t=>"x"===uQ(t)?"y":"x";function fQ(t){for(;t&&(t.__d3plus__||t.__d3plusShape__)&&t.data;)t=t.data;return t}function mQ(t,e,n){const i="function"==typeof t.schema.facet?t.schema.facet:void 0,o=n&&"function"==typeof t.schema.time?t.schema.time:void 0,r=hQ(t).accessors[uQ(t)],a=o&&e.length&&o(e[0],0)!==r(e[0],0)?o:void 0;return(e,n)=>{const o=[t._ids(e,n).slice(0,(t._drawDepth??0)+1).join("_")];return i&&o.unshift(`${i(e,n)}`),a&&o.unshift(`${a(e,n)}`),o.join("|")}}function pQ(t){const e=t.schema[`${uQ(t)}Sort`];return"function"==typeof e&&e!==hQ(t).ySort?e:void 0}const gQ=t=>t instanceof Date?""+ +t:`${t}`;function yQ(t){const e=hQ(t),n=t.schema.ySort;void 0===n||n===e.ySort?"y"===uQ(t)?t.schema.ySort=e.ySort=function(t,e){const n=n=>t.get(gQ(e(n,0)))??-1;return(t,e)=>n(e)-n(t)}(function(t,e){const n=new Map;t.forEach((t,i)=>{const o=e(t,i),r=gQ(o);n.has(r)||n.set(r,o)});const i=Array.from(n.entries()).sort((t,e)=>iQ(t[1],e[1]));return new Map(i.map(([t],e)=>[t,e]))}(t._data||[],e.accessors.y),e.accessors.y):e.ySort&&(t.schema.ySort=e.ySort=void 0):e.ySort=void 0}function xQ(t,e,n){const i=hQ(t);if(!e||!e.length||i.laidOut.has(e))return;i.laidOut.add(e);rQ(e,{category:i.accessors[uQ(t)],series:mQ(t,e,n),value:i.accessors[dQ(t)],subtotal:t.schema.subtotal,sort:pQ(t)}).forEach((t,e)=>i.steps.set(e,t))}function bQ(t,e){const n=fQ(e);if(n)return xQ(t,t._filteredData,!1),t._axisPersist&&xQ(t,t._data,!0),hQ(t).steps.get(n)}function _Q(t,e){const n=fQ(e);if(!n)return;const i=n[lQ];return"string"==typeof i?i:bQ(t,n)?.kind}function kQ(t){const e=fQ(t)?.[lQ];return"string"==typeof e?e:void 0}function vQ(t){const e=t[`_${dQ(t)}Config`];return e&&"function"==typeof e.tickFormat?e.tickFormat:e=>d.formatAbbreviate(e,t.schema.locale)}const wQ=new WeakSet;const MQ=(t,e)=>{const n=_Q(t,e);return n?t.schema.translate(jZ[n]):void 0},SQ=t=>"x"===uQ(t);const CQ={name:"Waterfall",paintDriven:!0,thresholdFunction:(t,e)=>e,setup:t=>{t.ctx.waterfall={accessors:{x:t._x,y:t._y},steps:new WeakMap,laidOut:new WeakSet},function(t){const e=hQ(t);["x","y"].forEach(n=>{const i=`_${n}`,o=t[i];wQ.has(o)||(e.accessors[n]=o);const r=(i,o)=>{const r=e.accessors[n](i,o);return dQ(t)!==n||void 0!==nQ(r)?r:sQ(r,bQ(t,i))};wQ.add(r),Object.defineProperty(t,i,{configurable:!0,enumerable:!0,get:()=>r,set:t=>{wQ.has(t)||(e.accessors[n]=t)}})})}(t),t._stackOffset=cQ(e=>bQ(t,e)),t._stackGroup=(e,n)=>t._ids(e,n).slice(0,t._drawDepth+1).join("_"),t._stackShares=!1,t.schema.color=e=>_Q(t,e),function(t){const e=t.schema.shapeConfig.fill;t.schema.shapeConfig.fill=(n,i)=>{const o=_Q(t,n);return o?IZ(o,t.schema,t.schema.colorDefaults):e(n,i)};const n=(e,n,i)=>{const o=bQ(t,e);return o?KZ(o,SQ(t))[n]:i},i=t.schema.shapeConfig.Bar??{};t.schema.shapeConfig.Bar={...i,ariaLabel:(e,n)=>{const i=bQ(t,e);return i?`${i.category}, ${MQ(t,e)}: ${GZ(i,vQ(t))}.`:t._drawLabel(fQ(e),n)},label:e=>{const n=bQ(t,e);return!!n&&GZ(n,vQ(t))},labelBounds:(e,n,i)=>{const o=bQ(t,e);return!!o&&YZ(o,i,SQ(t))},labelConfig:{...i.labelConfig??{},fontColor:()=>Ws(t),fontResize:!1,fontSize:12,fontStroke:"transparent",fontStrokeWidth:0,padding:0,textAnchor:t=>n(t,"textAnchor","middle"),verticalAlign:t=>n(t,"verticalAlign","middle")}}}(t),function(t){const e=(e,n)=>MQ(t,e)??t._drawLabel(e,n),n=t.schema.legendConfig;t.schema.legendConfig={...n,label:e,shapeConfig:{...n.shapeConfig??{},ariaLabel:e}},t.schema.legendSort=(e,n)=>eQ.indexOf(_Q(t,e))-eQ.indexOf(_Q(t,n)),delete t.schema.on["click.legend"];const i=t.schema.on.mouseenter;t.schema.on.mouseenter=function(e,n,o,r){const a=kQ(e);if(!a)return i.call(this,e,n,o,r);1!==t.schema.shapeConfig.hoverOpacity&&t.hover(e=>_Q(t,e)===a)}}(t),t._buffer={...t._buffer,Bar:XZ(e=>bQ(t,e),{vertical:()=>SQ(t),labels:()=>!1!==t.schema.shapeConfig.Bar?.label})},t._plotUnderlay=(e,n,i)=>{if(!t.schema.connectors)return[];const o=SQ(t);return tQ(QZ(ZZ(e,e=>bQ(t,e),o),o?t=>i(t):t=>n(t),o),t.schema.connectorConfig)};const e=t._preDraw.bind(t);t._preDraw=()=>{!function(t){const e=hQ(t);e.steps=new WeakMap,e.laidOut=new WeakSet}(t),yQ(t),e();const n=t._filteredData||[];t._legendData=aQ(n.map(e=>bQ(t,e))).map(t=>({[lQ]:t}))}},ctx:{},fields:[{key:"connectors",default:!0},{key:"decreaseColor"},{key:"increaseColor"},{key:"legend",coerce:"const",factory:()=>(t,e)=>e.length>1},{key:"stacked",default:!0},{key:"subtotal",coerce:t=>"string"==typeof t?q(t):"function"==typeof t?t:void 0},{key:"totalColor"},{key:"connectorConfig",merge:!0,factory:t=>({stroke:()=>Ws(t),strokeDasharray:"",strokeOpacity:.6,strokeWidth:1})},{key:"tooltipConfig",merge:!0,factory:t=>({title:(e,n)=>function(t,e,n){const i=fQ(e);if(kQ(i))return MQ(t,i)??"";const o=t._drawLabel(i,n);return"undefined"===o?MQ(t,i)??o:o}(t,e,n),tbody:e=>UZ(bQ(t,e),vQ(t),t.schema.translate)})}]};var $Q=lx(CQ,eL);Object.defineProperty(t,"CanvasRenderer",{enumerable:!0,get:function(){return a.CanvasRenderer}}),Object.defineProperty(t,"SvgRenderer",{enumerable:!0,get:function(){return a.SvgRenderer}}),t.ALLUVIAL_TITLE_GAP=8,t.AREA_LABEL_FONT_MAX=16,t.AREA_LABEL_FONT_MIN=8,t.AREA_LABEL_FONT_WEIGHT=400,t.AREA_LABEL_PADDING=4,t.Alluvial=rb,t.ArcDiagram=yw,t.Area=La,t.AreaPlot=QD,t.Axis=zo,t.AxisBottom=Do,t.AxisLeft=Lo,t.AxisRight=Fo,t.AxisTop=No,t.BIN_SIZE=12,t.BOTTOM_RIGHT_CONTRIBUTORS=Fy,t.Bar=Na,t.BarChart=eL,t.BaseClass=Kt,t.Beeswarm=iL,t.Box=ds,t.BoxWhisker=yL,t.BubbleChart=ML,t.Bullet=_F,t.BumpChart=vF,t.CANDLESTICK_SHAPE=DB,t.CHORD_LABEL_FONT_SIZE=11,t.CHORD_LABEL_PADDING=4,t.CIRCULAR_CLEARANCE=12,t.CIRCULAR_RADIUS=8,t.CLUSTER_LABEL_DEFAULTS=ZI,t.CLUSTER_MAX=12,t.CONNECTOR_KEY_SUFFIX=jR,t.CONTOUR_DEFAULTS=tH,t.CONTOUR_LABEL_FONT_SIZE=10,t.CONTOUR_LABEL_MAX_LEVELS=5,t.Calendar=gN,t.Candlestick=TB,t.Chord=bE,t.Circle=Pa,t.ColorScale=dr,t.DEFAULT_AGGS=ON,t.DEFAULT_BAND_OPACITY=nM,t.DENSITY=tK,t.DOMAIN_CLIP_KEY=oA,t.Donut=HR,t.Dumbbell=QR,t.EDGE_BUNDLE_DEFAULTS=hb,t.END_LABEL_AXIS_CONFIG=_$,t.FACET_ASPECT=ne,t.FACET_PADDING=20,t.FACET_TITLE_DEFAULTS=ee,t.FORMAT_KEYS=sn,t.FanChart=eP,t.Funnel=VP,t.GAP_DASH=VA,t.GLOBE_KEY_DURATION=200,t.GLOBE_KEY_INSTRUCTIONS=$W,t.GLOBE_KEY_SHORTCUTS=CW,t.GLOBE_KEY_STEP=10,t.Gantt=XT,t.Gauge=JT,t.Geomap=HW,t.HEXBIN_META=JW,t.HEXBIN_SHAPE=QW,t.Hexbin=QH,t.Histogram=mj,t.INSET_PRIORITY=js,t.Icicle=aI,t.Image=ms,t.KEYBOARD_NAV_INSTRUCTIONS=Cc,t.LABEL_COMBOS=ry,t.LABEL_FONT_SIZE=12,t.LABEL_INDENT=12,t.LABEL_PADDING=8,t.LEADER_OPACITY=.5,t.LINK_HIT_WIDTH=8,t.LINK_LABEL_DEFAULTS=ik,t.LINK_LABEL_MAX_TURN=U_,t.LINK_LABEL_MIN_RADIUS=2,t.LINK_LABEL_STRAIGHT_TURN=.03,t.LINK_SIZE_SHARE=.5,t.LOOP_ARROW="↻",t.Legend=To,t.Line=rs,t.LinePlot=JR,t.Lollipop=bI,t.MARK_TYPES=$e,t.MAX_ROW_STEP=40,t.Marimekko=$I,t.Matrix=NI,t.Message=kr,t.NO_ROOM=SR,t.NO_SIDES=oy,t.Network=wG,t.OUTSIDE_ENTER=yR,t.OUTSIDE_LABEL_FONT_SIZE=12,t.OUTSIDE_MAX_SHARE=.3,t.PIE_MIN_SCALE=.6,t.POINT_DEFAULTS=eH,t.Pack=AG,t.ParallelCoordinates=Aq,t.Path=gs,t.Pie=WR,t.Plot=ZD,t.PolarArea=DV,t.Priestley=NV,t.Pyramid=xY,t.RADIAL_BAR_MIN_LABEL_GAP=AY,t.REFERENCE_BAND=tS,t.REFERENCE_LINE=JM,t.REMAINING_MIX=.6,t.RESET=it,t.RESOLVES_RESET=rt,t.RING_LABEL_FADE=OB,t.Radar=vY,t.RadialBar=IY,t.RadialMatrix=KY,t.Rect=Ea,t.Ridgeline=vK,t.Rings=iU,t.STEM_KEY_SUFFIX=sI,t.STRAIGHT_LABEL_DEFAULTS=iR,t.Sankey=sX,t.Scatter=bL,t.Shape=za,t.SizeLegend=_r,t.SlopeChart=_X,t.StackedArea=kX,t.Streamgraph=MX,t.Sunburst=ZX,t.TOP_LEFT_CONTRIBUTORS=em,t.TextBox=Ir,t.Timeline=oa,t.Tooltip=ma,t.Tree=iZ,t.Treemap=mZ,t.VIOLIN_PADDING=.5,t.VOLUME_DEFAULTS=oB,t.Violin=MZ,t.Viz=cx,t.Waffle=HZ,t.Waterfall=$Q,t.Whisker=cs,t.absoluteFormat=jV,t.accessor=I,t.addDays=AF,t.aggregateAlluvial=gx,t.aggregateFunctionFields=IN,t.alignAxisLine=z$,t.alignInsets=hy,t.allotEndLabelWidths=C$,t.alluvialColumns=vx,t.alluvialDef=ob,t.alluvialDimensions=Dx,t.alluvialEmit=Zx,t.alluvialGroupBy=Lx,t.alluvialHighlight=Jx,t.alluvialMeta=Cx,t.alluvialNodeId=Ix,t.alluvialPathRows=Gx,t.alluvialPathText=yx,t.alluvialRibbon=Mx,t.alluvialTitleBoxes=Px,t.alluvialTitleNodes=Wx,t.alluvialTitleStyle=Tx,t.alluvialTooltipRows=nb,t.alluvialTooltipTitle=eb,t.alluvialValue=ib,t.alluvialValueTitle=jx,t.anchorPoint=OM,t.angleCompatibility=fb,t.annotationLayer=NA,t.annotationTextNode=VM,t.annotationTextStyle=GM,t.appendFocusRing=Qc,t.applyAlluvialLayout=Vx,t.applyArcDiagramLayout=Qv,t.applyAxisBreaks=Zn,t.applyAxisRangeBreaks=Ri,t.applyBarWidths=Jp,t.applyBulletLayout=sF,t.applyCalendarLayout=cN,t.applyChordLabelGeometry=pE,t.applyChordLayout=yE,t.applyFunnelLayout=kP,t.applyGanttLayout=FT,t.applyGaugeLayout=OL,t.applyGeomapLayout=rW,t.applyIcicleLayout=Qj,t.applyLineStates=Sq,t.applyMatrixLayout=zI,t.applyNetworkLayout=KI,t.applyOverlayColorScheme=kf,t.applyPackLayout=MG,t.applyPaddedDomains=CM,t.applyParallelLayout=ZG,t.applyPieLayout=TR,t.applyPolarAreaLayout=$V,t.applyPriestleyLayout=LV,t.applyRadarLayout=_Y,t.applyRadialBarLayout=TY,t.applyRadialMatrixLayout=qY,t.applyRingsLayout=GK,t.applySankeyLayout=JU,t.applySunburstLayout=BX,t.applySwarmLanes=vM,t.applyTreeLayout=tZ,t.applyTreemapLayout=lZ,t.applyVizTheme=yf,t.applyWaffleLayout=NZ,t.arcApex=Av,t.arcArrowEdge=Lv,t.arcBox=Fv,t.arcDiagramDef=gw,t.arcDiagramEmit=hw,t.arcEndTip=zv,t.arcFocus=uw,t.arcLabelAnchor=ew,t.arcLabelPath=nw,t.arcLoopReach=Hv,t.arcLoopRoom=Gv,t.arcNodeGroup=Yv,t.arcPathD=$v,t.arcPoint=Cv,t.arcPointAlong=Dv,t.arcRadiusScale=Vv,t.arcScale=Mv,t.arcSideOf=wv,t.arcSizeLegendScale=Zv,t.arcTableData=pw,t.arcVisibleD=aw,t.arrowAlongChord=Dk,t.arrowTrim=xk,t.arrowheadPoints=_A,t.autoForecastStart=function(t){const e=Vw(Array.from(Yw(t).values()));return e?e.value:null},t.autoLineOpacity=RG,t.awayFromAngle=Xk,t.axisBarNodes=ti,t.axisDomain=TG,t.axisPixel=NM,t.axisPositions=PG,t.axisSpan=RM,t.backContribution=Iu,t.backdropDecor=Mz,t.backgroundImageNode=Jv,t.backgroundImageNodes=tw,t.backgroundInk=Ws,t.bandAxisDefaults=iB,t.bandColor=Zg,t.bandFontWeight=Ug,t.bandOpacityTargets=cM,t.bandPolygon=tA,t.bandRibbonD=CU,t.bandRows=kC,t.bandSections=Gg,t.bandStep=GV,t.barKey=Kp,t.barSpanAxisConfig=ag,t.barWidthAccessor=Up,t.barWidthLabel=sg,t.barWidthTooltipRows=cg,t.baselineBreakAxisConfig=vg,t.baselineBreakStyle=Un,t.baselineDomainAxis=fg,t.beeswarmDef=nL,t.betweenPoints=Rw,t.binAccumulate=oj,t.binArea=YW,t.binAriaLabel=NH,t.binBounds=qW,t.binCumulativeNormalize=ij,t.binData=aj,t.binMeasure=KW,t.binPath=VW,t.binPoints=GW,t.binRows=uH,t.bindSvgBackgroundClick=_W,t.binsInView=fH,t.blockDays=RF,t.blockGrid=GF,t.blockMonths=PF,t.blockWeeks=EF,t.bottomRightClearance=pu,t.bottomRightControlsBox=uu,t.bottomRightControlsDrop=mu,t.bottomRightControlsFeature=By,t.bottomRightControlsInset=fu,t.bottomRightControlsShortfall=gu,t.boundOrValue=hM,t.bowedEdge=RK,t.boxCoverage=f_,t.boxHitsCircle=m_,t.boxLabelsOnly=Jg,t.boxesOverlap=p_,t.bracketPath=aT,t.breakGap=Jn,t.breakLineNodes=Z$,t.breakLinePaint=X$,t.breakLines=hz,t.breakStyle=Yn,t.breakStyleOf=Kn,t.breakTickValues=Qn,t.broadcastLegend=qe,t.broadcastLink=je,t.brokenBarScene=ei,t.brokenScale=Gn,t.brokenScaleTicks=qn,t.brokenTimeScale=_i,t.brushFromPixels=nq,t.brushTarget=XG,t.bsplinePolyline=sb,t.bubbleChartDef=wL,t.bubbleEmit=vL,t.bulletAxis=GL,t.bulletBands=WL,t.bulletDef=bF,t.bulletExtents=iF,t.bulletStack=ZL,t.bumpLineLabels=W$,t.bundleEdges=zb,t.bundleFlowLinks=SO,t.bundleLinkPaths=oO,t.bundleNetworkLinks=RI,t.bundledLinkAnchor=WI,t.bundledLinkEdge=TI,t.bundledLinkPath=OI,t.bundledTipBack=PI,t.calendarBlocks=BF,t.calendarDateFormat=aN,t.calendarDateSpecifier=WF,t.calendarDayKey=CF,t.calendarDef=pN,t.calendarEmit=fN,t.calendarFormatter=OF,t.calendarInsets=QF,t.calendarLabelStyle=rN,t.calendarLayout=tN,t.calendarOrient=oN,t.calendarPalette=lN,t.calendarPeriod=iN,t.calendarTimeLocale=TF,t.calloutNodes=AA,t.calloutPicker=CA,t.calloutRowNodes=$A,t.candleAriaLabel=$B,t.candleChange=kN,t.candleDirection=_N,t.candlePath=CN,t.candleTexture=NB,t.candleTooltipRows=CB,t.candleWidth=MN,t.candlestickBuffer=UN,t.candlestickDef=PB,t.canvasTooCoarse=Wd,t.capClusters=uv,t.capReserve=jU,t.cartesian=IO,t.cascadeTheme=yo,t.categoryGaps=YR,t.categoryHalfStep=EM,t.categoryStep=mK,t.cellCornerRadius=KF,t.centerLabelLines=cR,t.centeredSectorBox=eR,t.chartBackground=Os,t.chartGridline=Hs,t.chartName=zc,t.chooseRingLabel=lE,t.chordAllCurved=mE,t.chordAngle=zk,t.chordArrowNodes=Ek,t.chordCurves=fE,t.chordDef=xE,t.chordEndsPathD=Bk,t.chordLabelFontSize=dE,t.circularLanes=DU,t.circularLinkAnchor=TU,t.circularLinkD=EU,t.circularLinkEdge=BU,t.circularLinkOrder=zU,t.circularLinkShape=FU,t.circularLinkSide=$U,t.circularReserve=LU,t.circularRibbonD=PU,t.clampBarConfig=Cg,t.clampBox=xA,t.clampSides=CR,t.classTimelineMode=ea,t.clearGraphFocus=Qs,t.clearLinkFocus=xW,t.clearPanelSlots=Ql,t.clearRingLabels=GB,t.clearStrip=uq,t.clientAnchor=uh,t.clientPoint=Gl,t.clipBands=dz,t.clipSpan=PM,t.clipToPlotArea=dA,t.clipsToCircle=yO,t.closestFreeOffset=dM,t.clusterAutoActive=sv,t.clusterFields=av,t.clusterHubs=dv,t.clusterLabelObstacles=nG,t.clusterLabelSettings=QI,t.clusterLegendRows=mv,t.clusterLegendSort=yv,t.clusterName=fv,t.clusterOf=gv,t.clusterRegion=cG,t.clustersMeaningful=lv,t.coerceFacet=ie,t.coerceLinkColor=t_,t.collectAnnotationGroup=DA,t.colorRows=pH,t.colorScaleColor=As,t.colorScaleFeature=Xm,t.colorScaleRows=_H,t.colorScaleValue=$s,t.colorValue=hN,t.columnEdges=qU,t.columnHighlight=yN,t.columnScale=IU,t.compareCategories=iQ,t.compareFacetValues=Am,t.comparisonOutline=IV,t.compatibilityGraph=kb,t.complementIntervals=QA,t.computeAxisLayout=function(t){return no(t),{bounds:t._outerBounds,d3Scale:t._d3Scale,d3ScaleNegative:t._d3ScaleNegative,getPosition:e=>t._getPosition(e),availableTicks:t._availableTicks,visibleTicks:t._visibleTicks,margin:t._margin}},t.computeFilteredData=gm,t.computeSizeLegend=gr,t.computeTimeFilter=pm,t.confidenceBands=aM,t.configOpenDomain=ug,t.configPrep=Qt,t.configWarnings=function(t){if(!arguments.length)return Dt;Dt=!!t},t.connectorBars=ZZ,t.connectorEndpoints=bA,t.connectorNodes=tQ,t.connectorSegments=QZ,t.connectorStroke=XR,t.constant=H,t.contourAriaLabel=BH,t.contourLabelSpacing=OH,t.contourLabelStep=PH,t.contourLevelText=zH,t.contourLevels=UW,t.contourPath=XW,t.contourRings=RH,t.contourRows=dH,t.conversionModes=vP,t.conversionRates=mP,t.coordinateLabel=_O,t.coordinateVisible=xO,t.cornerControlsHeight=ap,t.cornerPlacements=sp,t.countRows=Hx,t.createKeyboardNavHost=Dc,t.crossLayout=Nv,t.crowdedRoom=zR,t.cubicAngle=L_,t.cubicArrowEdge=Lk,t.cubicMidpoint=F_,t.cubicPathD=wk,t.cubicPoint=D_,t.cubicPolyline=Ak,t.curveFactory=Dw,t.curvePoints=X_,t.curvePolyline=nz,t.curvedLabelPad=nk,t.curvedLabelSpot=ek,t.dashArray=qV,t.dateExtent=NF,t.dayCount=vT,t.daysBetween=$F,t.defaultArrowSize=gk,t.defaultCalendarDate=mN,t.defaultSizeLegendValues=pr,t.densify=Vg,t.densityAt=JY,t.densityContours=ZW,t.densityGroups=XY,t.densityMeta=nK,t.densityShapeId=iK,t.densityStats=UY,t.densityTooltipRows=cK,t.densityWidthScale=ZY,t.dependencyIds=pT,t.dependencyNodes=OT,t.dependencyStyle=BT,t.detectDimensions=LG,t.diamondPath=oT,t.dimensionAxisConfig=OG,t.dimensionDomain=NG,t.dimensionTitleStyle=WG,t.dimensionTooltipRows=mq,t.dimensionType=FG,t.discreteDirection=kz,t.discreteOrder=Gw,t.discreteRank=qw,t.distanceAlong=Q_,t.domainEnds=w$,t.dragRotation=KO,t.drawChart=zy,t.drawFacets=Ay,t.drawWithInset=Pp,t.dropHiddenRows=lm,t.dropLegendHistory=Ce,t.dumbbellDef=ZR,t.dumbbellEmit=VR,t.dumbbellSpans=IR,t.edgeArrowTrims=bk,t.edgeBundleCache=Sb,t.edgeBundleKey=$b,t.edgeBundleOptions=Cb,t.edgeCompatibility=function(t,e){return fb(t,e)*mb(t,e)*pb(t,e)*yb(t,e)},t.edgeD=vU,t.edgesBetween=FK,t.effectiveDuration=Zt,t.elbowRoute=sT,t.ellipsize=uT,t.emitAnnotations=EA,t.emitArcLabels=Ov,t.emitAreaLabels=Qg,t.emitCandlesticks=BB,t.emitClusterLabels=hG,t.emitContourLabels=IH,t.emitEndLabels=D$,t.emitFillBetween=Tw,t.emitFlowLabels=pW,t.emitFlowLinks=mW,t.emitForecast=wz,t.emitInner=kZ,t.emitLineBands=HA,t.emitLineLabelConnectors=H$,t.emitLinkLabels=sk,t.emitOutsideLabels=C_,t.emitVolume=_B,t.endLabelSpace=S$,t.estimatedColorRows=vH,t.expandArea=uy,t.expandReferenceBands=rS,t.expandReferenceLines=oS,t.extraBandValues=uM,t.facetActive=he,t.facetAreaMargin=by,t.facetBodyNode=yy,t.facetDimensions=ny,t.facetFilteredData=Fm,t.facetGrid=iy,t.facetGroups=Lm,t.facetKey=Cm,t.facetOuterAxes=ce,t.facetPanelAt=Xl,t.facetPanelNode=xy,t.facetScalesShared=le,t.facetTimeFilter=Nm,t.facetTitleBand=My,t.facetTitleNodes=gy,t.facetTitleStyle=vy,t.facetTitleTexts=wy,t.fanChartDef=tP,t.fanOrder=Kk,t.fanParallelEdges=OK,t.featureAnchor=sO,t.fillBetweenDefaults=Bw,t.fillBetweenPairs=Ew,t.findClusters=cv,t.finiteValue=xN,t.firstPerNeighbor=LK,t.firstValue=BN,t.fitCalendar=jF,t.fitFontSize=wP,t.fitInset=Np,t.fitLabel=dT,t.fitLabels=Ev,t.fitLineLabelText=FC,t.fitRing=FE,t.fitSwarms=yM,t.fittedArea=ey,t.flowArc=mO,t.flowArrowEdge=fW,t.flowEndResolver=kO,t.flowHoverPredicate=MW,t.flowLinkBox=wW,t.flowLinkCoordinates=vO,t.flowLinkGray=hW,t.flowLinkKey=lW,t.flowLinkWidths=wO,t.focusLink=kW,t.focusRingNode=sc,t.focusRingStyle=Wc,t.focusTargets=wc,t.forEachSceneRow=Ae,t.forecastDashOr=Cz,t.forecastDefaults=Iw,t.forecastLineDash=Sz,t.forecastRow=Kw,t.forecastRows=$z,t.forecastStart=Xw,t.forgetLinkNodes=Pb,t.formatAlluvialValue=Xx,t.formatChange=MB,t.formatDimensionValue=fq,t.formatFacetValue=Bm,t.formatPayload=hn,t.formatPrice=wB,t.formatShare=RZ,t.formatterFor=ln,t.frameTotals=TV,t.frozenAxis=T$,t.funnelCurve=bP,t.funnelDef=qP,t.funnelEmit=OP,t.funnelFacetHooks=IP,t.funnelFacetPanel=jP,t.funnelLabelNodes=EP,t.funnelOrder=gP,t.funnelOrient=xP,t.funnelStages=_P,t.funnelTooltipRows=GP,t.ganttAriaLabel=$T,t.ganttDef=UT,t.ganttDomain=DT,t.ganttDuration=kT,t.ganttEmit=VT,t.ganttLabelFont=lT,t.ganttRows=yT,t.ganttTasks=zT,t.ganttTooltipRows=CT,t.gapComparator=KR,t.gapIndex=hi,t.gapsAfter=KA,t.gaugeDef=QT,t.geomapDef=WW,t.geomapFlowLinks=CO,t.geomapLinkFields=EW,t.geomapPointLabels=cW,t.gestureHolds=Vl,t.gestureHoverEnd=Ul,t.gestureHoverMove=Kl,t.gestureHoverStart=Yl,t.gestureMoves=ql,t.getTopLeftContributions=nm,t.globeHome=QO,t.globeKeyStep=FW,t.globeRotates=ZO,t.goBack=Hu,t.graphLinkEnd=ev,t.graphNodeId=nv,t.greatCircle=lO,t.greatCircleCut=dO,t.gridStroke=ho,t.groupFacets=Dm,t.groupNodes=RT,t.growFromLine=dK,t.growRectsFromCenter=fK,t.gutterAxisDefaults=rY,t.gutterInset=ZV,t.gutterStackOffset=QV,t.gutterWidth=tY,t.hasBrushes=eq,t.hasColorValue=uN,t.hasFullConfigDomain=pg,t.hasOpenUserEnd=xg,t.hasUserDomain=mg,t.hexbinBuffer=SH,t.hexbinDef=ZH,t.hexbinEmit=UH,t.hexbinMeta=iH,t.hexbinRow=rH,t.hexbinSettings=sH,t.hexbinState=cH,t.hexbinTooltipRows=FH,t.hexbinTooltipTitle=LH,t.hexbinValue=oH,t.hidesAllTime=mi,t.histogramDef=fj,t.histogramHeightLabel=lj,t.hoverReach=rh,t.icicleBands=qj,t.icicleCollapse=Yj,t.icicleDef=rI,t.icicleLabelBox=Jj,t.icicleLayout=Xj,t.icicleRect=Vj,t.icicleRootEdge=Kj,t.icicleStagger=Uj,t.inPlot=TM,t.incomingBarycenters=_x,t.inheritedFillStyle=Hw,t.inkAxis=fo,t.inkBackground=lo,t.inkGrid=mo,t.inkText=uo,t.innerSet=pZ,t.insetBackground=Ks,t.insetComponentOffset=Xs,t.insetFrame=Ys,t.insetOrient=Vs,t.insetPlacementFor=qs,t.insetStyle=Is,t.insideFontMin=A_,t.installAlluvialHover=tb,t.installClusters=xv,t.installDensity=sK,t.installFluent=xt,t.installFocusBackgroundClick=vW,t.installGlobeKeys=BW,t.installGlobeRotation=JO,t.installGraphFluent=tv,t.installVolumeStrip=yB,t.intersectIntervals=ZA,t.intervalsDash=JA,t.isAggregatedBranch=yj,t.isBrokenScale=Hn,t.isBrokenTimeScale=gi,t.isDarkColor=U,t.isDomainClip=mA,t.isExpandOffset=kI,t.isFluentAccessor=gt,t.isFormatKey=cn,t.isFullTurn=CE,t.isHiddenTime=di,t.isInsetPending=Gs,t.isLegendEntry=xe,t.isLinkDatum=Nb,t.isLonLat=rO,t.isMilestone=fT,t.isMissing=DG,t.isMissingCategory=fx,t.isNumeric=zG,t.isNumericRange=QG,t.isOneSided=hg,t.isPointShape=ih,t.isRangeBreakRule=oi,t.isScaleValue=Ms,t.isSelfLoop=Rk,t.isSelfLoopMark=Pk,t.isTimeAxis=ZP,t.isVertical=LM,t.keepNumericRows=XH,t.keyedAccessor=DN,t.kindColor=IZ,t.labelAlign=KZ,t.labelBarWidth=Xp,t.labelBox=YZ,t.labelColumnWidth=cT,t.labelCorners=B_,t.labelExpansions=sy,t.labelFitsInside=__,t.labelGoesOutside=mR,t.labelGutter=cy,t.labelHitsBox=O_,t.labelHitsCircle=T_,t.labelKey=ay,t.labelMetrics=KB,t.labelNodes=ET,t.labelOverhang=dy,t.labelOverlapsLine=RC,t.labelPadding=XF,t.labelPositionOf=w_,t.labelReach=Rv,t.labelSizeCap=BP,t.labelSizes=Yg,t.labelSpotBox=UM,t.labelStretch=tk,t.labelWidth=hT,t.labelWidthLimit=Pv,t.labelledLevels=TH,t.labelsAlongBand=Ig,t.labelsOverCircles=OA,t.labelsOverlap=P_,t.labelsXEnds=v$,t.largestFirst=kL,t.largestRadius=hI,t.largestRemainder=CZ,t.largestSectorBox=nR,t.largestValue=oP,t.lastValue=EN,t.latestDrillEntry=be,t.layOutCircular=VU,t.layerOpacities=lM,t.layoutAlluvial=wx,t.layoutAxes=qG,t.layoutBarSpans=Qp,t.layoutCandles=FB,t.layoutCircleLabels=M_,t.layoutClusterLabels=lG,t.layoutEndLabels=$$,t.layoutSelfLoops=Zk,t.layoutWithLabelRoom=FR,t.leaderPoints=function(t,e,n,i){return WE(t,e,n,i)[0]??null},t.leaderRoutes=WE,t.legendFeature=Sm,t.legendLabelsWhole=km,t.legendLargestFirst=vE;t.legendSnapshot=ve,t.legibleOn=po,t.liftPolyline=hO,t.lineAriaLabel=xq,t.lineBoxes=CP,t.lineCurve=Lw,t.lineGaps=az,t.lineLabelBox=GA,t.lineLabelCap=NC,t.lineLabelConfig=qA,t.lineLabelKey=Lg,t.lineLabelSides=$g,t.lineLabelSpace=WC,t.lineLabelText=Dg,t.lineLabelValue=zg,t.linePoints=VG,t.lineRows=function(t){const e=t.find(([t])=>"Line"===t);return e?e[1]:[]},t.linkAriaLabel=Vb,t.linkArrows=Hb,t.linkAs=We,t.linkBundleCache=iO,t.linkBundleFields=uk,t.linkCellText=Gb,t.linkColorResolver=i_,t.linkColorScaleRows=Cs,t.linkEndLabel=jb,t.linkEndRef=bO,t.linkEndsBox=yW,t.linkFocusId=gW,t.linkHighlight=Yb,t.linkHitPath=Jb,t.linkKeys=Pe,t.linkLabelSettings=ok,t.linkLabelText=rk,t.linkMembers=function(t){return Array.from(ze.get(t)??[])},t.linkMeta=Fb,t.linkNodeOf=Tb,t.linkPredicate=Oe,t.linkRow=e_,t.linkSizeMaxField=hk,t.linkStyleFields=lk,t.linkTooltipConfig=Qb,t.linkTooltipRows=qb,t.linkTooltipTitle=Ib,t.linkValueColor=n_,t.linkValues=Te,t.linkWidthRange=EI,t.linkedColorDefaults=Re,t.listAxis=ED,t.loaderFormatFields=pn,t.lollipopBuffer=uI,t.lollipopDef=xI,t.lollipopEmit=pI,t.loopAngle=jv,t.loopSide=Wv,t.makeLinkDatum=Bb,t.mapBox=dc,t.mapper=uc,t.marimekkoAxisDefaults=wI,t.marimekkoDef=CI,t.marimekkoFacetAxes=MI,t.marimekkoFixedAxes=SI,t.marimekkoPercentText=vI,t.markBoxes=fc,t.maskBreaks=eA,t.maskPath=J$,t.matrixDef=FI,t.maxLengthRatio=xb,t.maxValue=RN,t.measureAxis=no,t.measureBars=Zp,t.measureEndLabels=M$,t.measureFacetTitles=py,t.measureLabel=k_,t.measureLineLabel=EC,t.measurePlotLineLabels=HC,t.measureTimeAxis=tT,t.measureTrackLabels=NY,t.mergeBranch=_j,t.mergeConfig=ct,t.mergeConfigBag=ut,t.mergeStackOrder=tC,t.metricsWidth=jX,t.milestoneRadius=IT,t.minValue=PN,t.monotoneSlopes=aP,t.monthLabelWeek=VF,t.monthOutlinePath=qF,t.motionReduced=Xt,t.narrowName=HF,t.naturalCompare=_v,t.nearestHoverSurface=ax,t.nearestPick=ch,t.nearestPoint=iG,t.neckConfig=RP,t.neckPaint=PP,t.nestPartition=gj,t.nestSunburst=gj,t.networkClusterLabels=uG,t.networkDef=vG,t.nextTarget=Sc,t.nodeConnectionRows=Zb,t.nodeConnections=Kb,t.nodeDegrees=bv,t.nodeHighlight=Ub,t.nodeTooltipLinkLimit=Xb,t.normalizeBreaks=jn,t.normalizeProgress=mT,t.normalizeRangeBreaks=ri,t.noteDrawRows=xH,t.noteLinkValue=Ss,t.offsetBox=gA,t.offsetCircularShape=RU,t.offsetVisible=pi,t.ohlcAccessors=YN,t.ohlcBarPath=$N,t.ohlcExtent=vN,t.openDomainEnds=_S,t.openEnd=$M,t.openEndAxisConfig=bg,t.outsideBaselineBreak=Mg,t.outsideClaim=$R,t.outsideColumn=RE,t.outsideFontSize=fR,t.outsideIdealY=jE,t.outsideLabels=$_,t.outsideMetrics=BE,t.outsideRoom=PE,t.outsideSide=EE,t.outsideSpace=xR,t.ownBoxes=hc,t.packDef=$G,t.paddedBand=HH,t.pageIsDark=ff,t.pageTheme=df,t.panelAxisConfig=HD,t.panelBase=ly,t.panelLabels=_y,t.panelTitle=Cy,t.parallelCoordinatesDef=$q,t.parallelDimensionKeys=KG,t.parallelEmit=bq,t.parallelOffsets=NK,t.parallelOrient=UG,t.parallelPath=YG,t.parseCalendarDate=SF,t.parseTime=QP,t.partitionFocus=wj,t.partitionLayout=kj,t.partitionLineage=vj,t.partitionShadeAmount=jj,t.partitionSort=xj,t.partitionSplit=YB,t.pathPointBack=$k,t.pathRuns=gO,t.patternIntervals=XA,t.percent=wT,t.percentText=$P,t.periodDate=QN,t.periodSpacing=wN,t.pickLabelSpot=XM,t.pieAspect=ER,t.pieBaseRadius=BR,t.pieDef=OR,t.pieLabelPlan=gR,t.pieLabelRoom=AR,t.pieMayLabelOutside=pR,t.pieOutsideLabels=MR,t.pieOutsideNodes=vR,t.pieRingLayout=PR,t.pieSharePct=dR,t.pieSliceLabels=YE,t.pieStraightLabels=hR,t.pieSweep=SE,t.pieSweepOf=NR,t.pixelCenter=SN,t.pixelPoints=qH,t.pixelsFromBrush=iq,t.placeArcLabel=Tv,t.placeBandLabel=Xg,t.placeCalloutBox=wA,t.placeCircleLabels=x_,t.placeClusterLabel=sG,t.placeEndLabels=A$,t.placeLinkLabels=W_,t.placeLoops=Iv,t.placeOutsideLabels=bR,t.placeReferenceLabels=QM,t.plainText=Ac,t.planFunnelLabels=SP,t.planLabel=MP,t.planStageLabels=FP,t.plotAnnotationFrame=jM,t.plotAnnotationList=BA,t.plotAxisConfig=kg,t.plotAxisRounding=gg,t.plotCircleLabels=TA,t.plotEmit=Zz,t.plotFacetChrome=TD,t.plotFacetHooks=qD,t.plotFacetInsets=GD,t.plotFacetPanel=ID,t.plotFrame=hH,t.plotPaint=function(t,e){return tD(t,e).nodes},t.plotRangeBreaks=rm,t.plotSeriesIds=eC,t.plotTimeScale=hm,t.pointLabelSettings=v_,t.pointLengths=UA,t.pointMarkTargets=oh,t.pointPath=mH,t.pointTarget=sh,t.pointTooltipAnchor=dh,t.pointVoronoi=eh,t.polarAreaDef=zV,t.polarAreaDomainValues=CV,t.polarAreaEmit=AV,t.polarAreaSlotOf=SV,t.polarAxisConfig=zq,t.polarBoxesOverlap=cV,t.polarCategoryLayout=dV,t.polarCategoryNodes=fV,t.polarFacetHooks=Eq,t.polarFacetPanel=Nq,t.polarHorizontalLayout=hV,t.polarInnerRadius=_V,t.polarLabelFitRadius=aV,t.polarLabelPlacement=rV,t.polarLabelRoom=sV,t.polarLabelsCollide=lV,t.polarLevelNodes=mV,t.polarLevels=bV,t.polarPadAngle=xV,t.polarRadius=pV,t.polarSharedExtent=Bq,t.polarSlotArc=kV,t.polarSlotTops=wV,t.polarSlots=gV,t.polarSpokeRotation=uV,t.polarStack=yV,t.polarValueRow=Dq,t.polarWedgeLayout=MV,t.polarWedgeNodes=Lq,t.polygonDistance=th,t.polylineArrowEdge=Fk,t.polylineAt=q_,t.polylineBox=Y_,t.polylineLength=G_,t.polylineMidpoint=V_,t.polylinePath=j_,t.polylineReach=K_,t.polylinesCross=HE,t.poolStackPositions=QS,t.positionCompatibility=pb,t.prefersReducedMotion=Ut,t.prefixKeys=fy,t.prepareClusters=pv,t.prepareSlope=yX,t.priestleyDef=FV,t.profileKnots=sP,t.profileSlice=hP,t.progressAgg=KT,t.progressSplit=rT,t.publishLinkGraph=Rb,t.pullBack=kA,t.pyramidDef=yY,t.pyramidExtent=OV,t.pyramidSides=EV,t.pyramidStackOrder=_I,t.pyramidTotal=PV,t.queuedFormatter=mn,t.radarDef=kY,t.radialBarCurvedLabels=WY,t.radialBarCurvedRows=DY,t.radialBarDef=jY,t.radialBarDomainValues=PY,t.radialBarEmit=HY,t.radialBarFootprint=SY,t.radialBarLabelRoom=MY,t.radialBarLabelSpot=OY,t.radialBarRows=EY,t.radialBarSweep=$Y,t.radialBarTrackLabels=zY,t.radialBarTrackLayout=BY,t.radialBarTracks=wY,t.radialMatrixDef=YY,t.rangeBreakGaps=li,t.rangeBreakTest=ui,t.rangeBreakTime=ii,t.rangeBreaksTimeAxis=am,t.rangeText=wC,t.readOhlc=bN,t.readingOrder=vc,t.recordLegendChange=we,t.recordStackLegendOrder=nC,t.referenceAxis=aS,t.referenceBandLabelAt=function(t,e="start"){return"end"===e?{x:t.x+t.width-4,y:t.y+4,align:"end"}:{x:t.x+4,y:t.y+4,align:"start"}},t.referenceBandLabelSpots=fS,t.referenceBandNodes=gS,t.referenceBandRect=lS,t.referenceDomainValues=yS,t.referenceLineLabelAt=hS,t.referenceLineLabelSpots=dS,t.referenceLineNodes=pS,t.referenceLinePoints=cS,t.refreshColorScale=wH,t.registerLabelSpots=KM,t.registerLink=Be,t.remainingShade=jT,t.removeLatestDrillEntry=_e,t.renderAxes=q$,t.renderPlotAnnotation=LA,t.renderTimeAxis=eT,t.reserveBottomRight=Ny,t.resolveAlluvialDimensions=dx,t.resolveBaselineBreak=Xn,t.resolveBinValue=aH,t.resolveBrushStyle=Cq,t.resolveColorBy=mx,t.resolveConfidenceBands=rM,t.resolveConnectGaps=YA,t.resolveDimensions=BG,t.resolveFacetAxes=ae,t.resolveFacetConfig=oe,t.resolveGraphLinks=ov,t.resolveGraphNodes=iv,t.resolveLineOpacity=yq,t.resolveLink=Ne,t.resolveSaveConfig=Ed,t.resolveSpec=ym,t.resolveSwarm=kM,t.resolveTheme=Q,t.resolveWeekStart=FF,t.resolvesReset=dt,t.restoreLegendEntry=Me,t.reverseEdge=wU,t.ribbonD=SU,t.ridgeOverlap=xK,t.ridgelineDef=kK,t.ridgelineEmit=_K,t.ridgelinePadding=bK,t.ringCentroid=c_,t.ringDistance=WH,t.ringExtent=zE,t.ringFontRange=qE,t.ringLabelFit=sE,t.ringLabelFont=WB,t.ringLabelNodes=IB,t.ringLabelPair=cE,t.ringLabelPosition=hE,t.ringLabelStretches=jH,t.ringPoint=iE,t.ringReadsClockwise=oE,t.ringSizeFor=NE,t.ringTextPath=rE,t.ringTextWidth=HB,t.ringsDef=nU,t.ringsEdgeAnchor=QK,t.ringsEdgePath=JK,t.ringsLinkKeys=ZK,t.ringsLoops=zK,t.ringsVisibleD=UK,t.rotateByStep=DW,t.rotationBetween=LW,t.roundOpenEnd=AM,t.roundPlotOpenEnds=DM,t.roundedDomain=Xi,t.routePointerEvent=lh,t.rowBands=sM,t.rowDate=eN,t.rowLegend=kE,t.rowLineLabelSides=Ag,t.rowPasses=tq,t.rowTime=nT,t.rowsExtent=nN,t.rtlLocale=Wb,t.ruleMarker=ai,t.runIndices=ez,t.runLayout=ep,t.runPath=tz,t.runPostDrawFeatures=Ry,t.runStages=_t,t.runVizPipeline=Ey,t.sameLegendIds=ke,t.sankeyAcyclicLinks=KU,t.sankeyBandThickness=tX,t.sankeyDef=aX,t.sankeyDrawableLinks=UU,t.sankeyLinkAnchor=iX,t.sankeyLinkIds=nX,t.sankeyLinkPath=oX,t.sankeyLoopWarning=ZU,t.sankeyNodeValue=OU,t.sankeyRibbonD=eX,t.sankeyScale=HU,t.saveChart=Hd,t.saveContribution=lf,t.saveFilename=Fd,t.saveFormats=Ld,t.savePixelRatio=Od,t.scaleCompatibility=mb,t.scatterDef=xL,t.sceneInsetRegion=Cp,t.screenArc=fO,t.searchContribution=Xf,t.secondaryAxisRounding=yg,t.sectorBoxAt=tR,t.sectorBoxRange=JE,t.sectorEdges=ZE,t.seedTimeAggs=XP,t.segmentDistance=OE,t.segmentMidpoint=z_,t.segmentWidth=cP,t.selfLoopAngles=Yk,t.selfLoopArrows=Jk,t.selfLoopD=qk,t.selfLoopExtent=Wk,t.selfLoopGeometry=Ik,t.selfLoopOpening=Hk,t.selfLoopReach=Ok,t.selfLoopSpread=Vk,t.seriesForecastStarts=Yw,t.setAlluvialMeta=$x,t.setLinkValue=Eb,t.setLoaderValue=dn,t.setupArcEvents=mw,t.setupGeomapLinks=SW,t.shareFunnelLabelSize=WP,t.shareFunnelScale=HP,t.sharePlotScales=OD,t.sharePolarScale=Fq,t.shareRow=_E,t.sharedColorRows=bH,t.sharedDomains=EG,t.sharedScaleMax=yP,t.sharpestTurn=J_,t.shiftEdge=MU,t.sideAnchor=S_,t.sideBox=a_,t.sideClip=Pw,t.sideControlsDrop=rp,t.sideOrder=l_,t.sideSign=RV,t.sideTitleBoxes=YV,t.simplifyPolyline=cb,t.sizeAlluvialTitles=Ox,t.sizeLegendContribution=Ly,t.sliceExtent=fP,t.slicePath=dP,t.slideOnRim=BK,t.slideSteps=ZM,t.slopeChartDef=bX,t.slopeColors=mX,t.slopeColorsDark=fX,t.slopeColorsLight=dX,t.slopeDirection=hX,t.slopeDirections=uX,t.slopeFill=xX,t.slopePeriods=lX,t.slopeValueAxis=pX,t.slotEdge=vz,t.slotPosition=IF,t.slotPositions=vv,t.smoothBundle=lb,t.snapMagnitude=HV,t.solveScale=GU,t.sortAlluvialColumns=kx,t.sortArcNodes=kv,t.sortByMedian=QY,t.sortFacetValues=zm,t.sortTasks=gT,t.sourceRows=Ax,t.splitDash=oz,t.splitLength=iz,t.spreadLabelPositions=O$,t.stackCircularEnds=WU,t.stackLegendSort=iC,t.stackOutsideLabels=TE,t.stackPositions=ZS,t.stackReadingOrder=JS,t.stageAria=TP,t.stageBoxes=zP,t.stageLabelSize=NP,t.stageLines=AP,t.stageSpans=nP,t.stageWidths=rP,t.startOfDay=MF,t.startingSelection=mm,t.stemFromBar=cI,t.stemPoints=lI,t.stepLabel=GZ,t.stepValue=sQ,t.storePayload=un,t.straightEdgeD=Mk,t.straightLabelLayout=sR,t.straightLabelOptions=rR,t.straightenPolyline=ab,t.streamValueAxis=vX,t.streamgraphDef=wX,t.stripLength=sq,t.stripSelection=cq,t.stripSize=lB,t.subdividePolyline=vb,t.subtitleFeature=hp,t.sumValue=TN,t.summarizeBeforePreDraw=rK,t.sunburstCurvedNodes=GX,t.sunburstDef=XX,t.sunburstFocus=NX,t.sunburstLabelBox=HX,t.sunburstLabelMetrics=YX,t.sunburstLabelPlacements=IX,t.sunburstLayout=FX,t.sunburstPadAngle=AX,t.sunburstRadii=CX,t.sunburstSplit=YB,t.surfaceOrigin=hh,t.surfaceToMap=XO,t.svgForSave=Td,t.swarmExtent=mM,t.swarmFitScale=gM,t.swarmHidesAxis=wM,t.swarmLayout=fM,t.swarmPlacements=MM,t.sweepFraction=$E,t.symmetricDomain=WV,t.syncBrushDom=dq,t.syncDefaultAggs=jN,t.syncGapSort=UR,t.syncKeyboardNav=Zc,t.syncLoaderFormats=fn,t.tableViewContribution=zd,t.takeLegendState=Se,t.targetLabel=Oc,t.taskAccessor=YT,t.taskEnd=PT,t.taskStart=TT,t.taskTimes=MT,t.teardownKeyboardNav=Uc,t.textBroken=uE,t.textHalo=Gp,t.textLineBoxes=ak,t.textShownWhole=VE,t.themeBackground=bf,t.themeBackgroundNode=xf,t.themeColorScheme=_f,t.themeDark=K,t.themeLight=Y,t.themeOverlayStyle=vf,t.themeRamp=et,t.themeScaleColor=tt,t.themeStyle=nt,t.themed=J,t.thickRuns=qg,t.thinBands=eY,t.timeFields=UP,t.timeFormatter=_T,t.timelineFeature=up,t.timelineModeClass=ta,t.timelineRangeBreaks=sm,t.titleFeature=lp,t.titleHeight=Ex,t.titleNodes=Rx,t.titleWidths=Bx,t.toFacetValue=$m,t.toLonLat=aO,t.todayNodes=HT,t.todayValue=WT,t.topLeftControlsFeature=im,t.totalFeature=dp,t.trackFontSize=FY,t.treeDef=nZ,t.treemapDef=fZ,t.trendForecastStart=Uw,t.trimCubic=vk,t.trimPolyline=I_,t.trimSegment=_k,t.trimToNodes=Z_,t.twoLineWidth=uR,t.unbrokenPath=uO,t.unionBox=Qk,t.unionExtent=RD,t.uniqueLinkKeys=qK,t.unlinkedNodeValue=XU,t.unregisterLink=Ee,t.unwatchPageTheme=gf,t.unwrapBreakMasks=iA,t.unwrapDomainClips=pA,t.unwrapHexbinRow=nH,t.unwrapRow=eK,t.updateKeyboardNavHost=Lc,t.uprightAngle=N_,t.usedRoom=DR,t.userAxisDomain=_g,t.userDomainBreaksBaseline=wg,t.valueAxis=lg,t.valueAxisExtent=Sg,t.valueDirection=Ow,t.valuePasses=JG,t.versor=HO,t.versorDelta=GO,t.versorMultiply=qO,t.versorRotation=jO,t.violinDef=wZ,t.violinEdges=yK,t.violinEmit=vZ,t.violinOutline=gK,t.violinSlots=pK,t.visibilityCompatibility=yb,t.visibleBetween=fi,t.visiblePointData=nW,t.visibleTimeValues=Pi,t.vizDraw=Uy,t.vizPostThresholdCtx=ox,t.vizPreDraw=rx,t.volumeAccessor=rB,t.volumeAriaLabel=AB,t.volumeScale=hB,t.volumeStripRect=xB,t.waffleCellGeometry=DZ,t.waffleCellGeometryNode=BZ,t.waffleCellPosition=zZ,t.waffleCellShape=EZ,t.waffleCounts=$Z,t.waffleDef=WZ,t.waffleFillOptions=FZ,t.waffleGrid=AZ,t.waffleShare=PZ,t.waffleTooltipRows=TZ,t.watchPage=mf,t.watchPageTheme=pf,t.waterfallDef=CQ,t.waterfallKinds=aQ,t.waterfallStackOffset=cQ,t.waterfallStep=oQ,t.waterfallSteps=rQ,t.waterfallTooltipRows=UZ,t.weekIndex=DF,t.weekdayLabelSlots=YF,t.weekdayNames=ZF,t.weekdaySlot=zF,t.widenDomain=KN,t.widenReferenceDomains=vS,t.widenToValues=bS,t.widestGapAngle=Uk,t.withFacetPanel=Zl,t.withOpacity=X,t.withinArea=Js,t.wrapAnnotationText=qM,t.wrapLineCount=ZB,t.wrapWidths=aR,t.xAxisRounding=IC,t.zeroAnchoredRadius=XC,t.zoomSizeLegendScale=yr,t.zoomToNodeBounds=rv});