semiotic 3.7.5 → 3.8.1

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 (575) hide show
  1. package/CLAUDE.md +63 -18
  2. package/README.md +121 -27
  3. package/agent-skill/semiotic-charts/SKILL.md +146 -0
  4. package/ai/cli.js +133 -45
  5. package/ai/componentMetadata.cjs +6 -1
  6. package/ai/dist/mcp-server.js +1741 -163
  7. package/ai/examples.md +174 -0
  8. package/ai/schema.json +2733 -536
  9. package/ai/surface-manifest.json +201 -0
  10. package/ai/system-prompt.md +20 -4
  11. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
  12. package/dist/components/AccessibleNavTree.d.ts +7 -1
  13. package/dist/components/CategoryColors.d.ts +1 -1
  14. package/dist/components/ChartContainer.d.ts +91 -0
  15. package/dist/components/ChartGrid.d.ts +11 -1
  16. package/dist/components/CircularBrush.d.ts +61 -0
  17. package/dist/components/ContextLayout.d.ts +5 -1
  18. package/dist/components/DirectManipulationControl.d.ts +63 -0
  19. package/dist/components/LinkedCharts.d.ts +3 -1
  20. package/dist/components/MobileAnnotationCalloutList.d.ts +13 -0
  21. package/dist/components/MobileChartContainer.d.ts +51 -0
  22. package/dist/components/MobileStandardControls.d.ts +68 -0
  23. package/dist/components/SmallMultipleChart.d.ts +84 -0
  24. package/dist/components/Tooltip/FlippingTooltip.d.ts +21 -0
  25. package/dist/components/ai/ChartRecipe.d.ts +16 -0
  26. package/dist/components/ai/IntentMark.d.ts +15 -0
  27. package/dist/components/ai/chartCapabilities.d.ts +8 -1
  28. package/dist/components/ai/chartCapabilityTypes.d.ts +26 -1
  29. package/dist/components/ai/chartClinic.d.ts +91 -0
  30. package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
  31. package/dist/components/ai/chartRecipeRegistry.d.ts +14 -0
  32. package/dist/components/ai/chartRecipes.d.ts +278 -0
  33. package/dist/components/ai/dataPitfallsBridge.d.ts +102 -0
  34. package/dist/components/ai/describeChart.d.ts +7 -0
  35. package/dist/components/ai/describeRecipeChart.d.ts +16 -0
  36. package/dist/components/ai/generativeChart.d.ts +28 -3
  37. package/dist/components/ai/intentManifest.d.ts +62 -0
  38. package/dist/components/ai/navigationTree.d.ts +3 -0
  39. package/dist/components/ai/observedSceneAudit.d.ts +72 -0
  40. package/dist/components/ai/readerGrounding.d.ts +83 -0
  41. package/dist/components/ai/recipeCapability.d.ts +8 -0
  42. package/dist/components/ai/recipeNavigation.d.ts +13 -0
  43. package/dist/components/ai/recipeSemantics.d.ts +11 -0
  44. package/dist/components/ai/repairChartConfig.d.ts +9 -0
  45. package/dist/components/ai/suggestCharts.d.ts +11 -1
  46. package/dist/components/ai/useNavigationSync.d.ts +17 -2
  47. package/dist/components/chartContainerMobile.d.ts +9 -0
  48. package/dist/components/charts/custom/GeoCustomChart.d.ts +48 -0
  49. package/dist/components/charts/custom/NetworkCustomChart.d.ts +8 -2
  50. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +8 -2
  51. package/dist/components/charts/custom/XYCustomChart.d.ts +11 -2
  52. package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
  53. package/dist/components/charts/geo/DistanceCartogram.d.ts +15 -3
  54. package/dist/components/charts/geo/FlowMap.d.ts +11 -7
  55. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +15 -3
  56. package/dist/components/charts/geo/index.d.ts +2 -0
  57. package/dist/components/charts/index.d.ts +35 -1
  58. package/dist/components/charts/network/ChordDiagram.d.ts +10 -2
  59. package/dist/components/charts/network/CirclePack.d.ts +1 -1
  60. package/dist/components/charts/network/ForceDirectedGraph.d.ts +26 -5
  61. package/dist/components/charts/network/OrbitDiagram.d.ts +1 -1
  62. package/dist/components/charts/network/ProcessSankey.d.ts +1 -1
  63. package/dist/components/charts/network/SankeyDiagram.d.ts +10 -2
  64. package/dist/components/charts/network/TreeDiagram.d.ts +1 -1
  65. package/dist/components/charts/network/Treemap.d.ts +1 -1
  66. package/dist/components/charts/network/useForceLayout.d.ts +17 -0
  67. package/dist/components/charts/ordinal/BarChart.d.ts +22 -1
  68. package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -1
  69. package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
  70. package/dist/components/charts/ordinal/DotPlot.d.ts +1 -1
  71. package/dist/components/charts/ordinal/FunnelChart.d.ts +1 -1
  72. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +12 -1
  73. package/dist/components/charts/ordinal/Histogram.d.ts +1 -1
  74. package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
  75. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -1
  76. package/dist/components/charts/ordinal/StackedBarChart.d.ts +12 -1
  77. package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -1
  78. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +1 -1
  79. package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -1
  80. package/dist/components/charts/physics/ChainReactionChart.d.ts +9 -0
  81. package/dist/components/charts/physics/CollisionSwarmChart.capability.d.ts +2 -0
  82. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +54 -0
  83. package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
  84. package/dist/components/charts/physics/EventDropChart.d.ts +60 -0
  85. package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
  86. package/dist/components/charts/physics/GaltonBoardChart.d.ts +74 -0
  87. package/dist/components/charts/physics/GauntletChart.capability.d.ts +2 -0
  88. package/dist/components/charts/physics/GauntletChart.d.ts +73 -0
  89. package/dist/components/charts/physics/PhysicalFlowChart.capability.d.ts +2 -0
  90. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +63 -0
  91. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +99 -0
  92. package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
  93. package/dist/components/charts/physics/PhysicsPileChart.d.ts +60 -0
  94. package/dist/components/charts/physics/ProcessFlowChart.capability.d.ts +2 -0
  95. package/dist/components/charts/physics/ProcessFlowChart.d.ts +96 -0
  96. package/dist/components/charts/physics/chainReactionOverlay.d.ts +22 -0
  97. package/dist/components/charts/physics/chainReactionRuntime.d.ts +37 -0
  98. package/dist/components/charts/physics/chainReactionTypes.d.ts +97 -0
  99. package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +27 -0
  100. package/dist/components/charts/physics/dependencyMachine.d.ts +188 -0
  101. package/dist/components/charts/physics/eventDropPhysics.d.ts +64 -0
  102. package/dist/components/charts/physics/galtonBoardPhysics.d.ts +28 -0
  103. package/dist/components/charts/physics/gauntletChartProps.d.ts +67 -0
  104. package/dist/components/charts/physics/gauntletChrome.d.ts +33 -0
  105. package/dist/components/charts/physics/gauntletController.d.ts +73 -0
  106. package/dist/components/charts/physics/gauntletEffects.d.ts +36 -0
  107. package/dist/components/charts/physics/gauntletPhysics.d.ts +71 -0
  108. package/dist/components/charts/physics/gauntletRuntime.d.ts +42 -0
  109. package/dist/components/charts/physics/gauntletTypes.d.ts +213 -0
  110. package/dist/components/charts/physics/physicalFlowPhysics.d.ts +57 -0
  111. package/dist/components/charts/physics/physicsChartShared.d.ts +57 -0
  112. package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -0
  113. package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
  114. package/dist/components/charts/physics/physicsEncoding.d.ts +142 -0
  115. package/dist/components/charts/physics/physicsHocHandle.d.ts +53 -0
  116. package/dist/components/charts/physics/physicsHocUtils.d.ts +128 -0
  117. package/dist/components/charts/physics/physicsPilePhysics.d.ts +41 -0
  118. package/dist/components/charts/physics/physicsProcessPrimitives.d.ts +38 -0
  119. package/dist/components/charts/physics/processFlowPhysics.d.ts +97 -0
  120. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -1
  121. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +9 -1
  122. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -1
  123. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +16 -2
  124. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -1
  125. package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
  126. package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
  127. package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
  128. package/dist/components/charts/shared/annotationRules.d.ts +2 -1
  129. package/dist/components/charts/shared/auditMobileVisualization.d.ts +91 -0
  130. package/dist/components/charts/shared/chartDefinitionPilot.d.ts +145 -0
  131. package/dist/components/charts/shared/chartFamilySets.d.ts +20 -0
  132. package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
  133. package/dist/components/charts/shared/chartSpecCore.d.ts +165 -0
  134. package/dist/components/charts/shared/chartSpecs.d.ts +8 -127
  135. package/dist/components/charts/shared/chartSpecsGeo.d.ts +2 -0
  136. package/dist/components/charts/shared/chartSpecsNetwork.d.ts +2 -0
  137. package/dist/components/charts/shared/chartSpecsOrdinal.d.ts +2 -0
  138. package/dist/components/charts/shared/chartSpecsPhysics.d.ts +2 -0
  139. package/dist/components/charts/shared/chartSpecsRealtime.d.ts +2 -0
  140. package/dist/components/charts/shared/chartSpecsValue.d.ts +2 -0
  141. package/dist/components/charts/shared/chartSpecsXY.d.ts +2 -0
  142. package/dist/components/charts/shared/colorContrast.d.ts +3 -0
  143. package/dist/components/charts/shared/colorUtils.d.ts +16 -1
  144. package/dist/components/charts/shared/datumTypes.d.ts +2 -0
  145. package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +6 -0
  146. package/dist/components/charts/shared/diagnoseConfig.d.ts +9 -14
  147. package/dist/components/charts/shared/diagnoseMisleadingChecks.d.ts +9 -0
  148. package/dist/components/charts/shared/diagnosePhysicsChecks.d.ts +3 -0
  149. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  150. package/dist/components/charts/shared/formatUtils.d.ts +3 -3
  151. package/dist/components/charts/shared/hatchFill.d.ts +87 -0
  152. package/dist/components/charts/shared/hooks.d.ts +34 -10
  153. package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
  154. package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
  155. package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
  156. package/dist/components/charts/shared/motionEncoding.d.ts +145 -0
  157. package/dist/components/charts/shared/responsiveRules.d.ts +56 -0
  158. package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
  159. package/dist/components/charts/shared/sparseArray.d.ts +1 -1
  160. package/dist/components/charts/shared/streamPropsHelpers.d.ts +17 -5
  161. package/dist/components/charts/shared/styleRules.d.ts +205 -0
  162. package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
  163. package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
  164. package/dist/components/charts/shared/types.d.ts +58 -7
  165. package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
  166. package/dist/components/charts/shared/useChartSetup.d.ts +11 -4
  167. package/dist/components/charts/shared/useCustomChartSetup.d.ts +17 -5
  168. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
  169. package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
  170. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
  171. package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
  172. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +25 -2
  173. package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
  174. package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
  175. package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
  176. package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
  177. package/dist/components/charts/shared/validateChartData.d.ts +7 -5
  178. package/dist/components/charts/shared/validationMap.d.ts +7 -9
  179. package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
  180. package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
  181. package/dist/components/charts/value/targetPresentation.d.ts +22 -0
  182. package/dist/components/charts/value/types.d.ts +5 -6
  183. package/dist/components/charts/xy/AreaChart.d.ts +9 -1
  184. package/dist/components/charts/xy/BubbleChart.d.ts +10 -1
  185. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
  186. package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
  187. package/dist/components/charts/xy/Heatmap.d.ts +2 -2
  188. package/dist/components/charts/xy/LineChart.d.ts +12 -1
  189. package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
  190. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +2 -2
  191. package/dist/components/charts/xy/QuadrantChart.d.ts +8 -1
  192. package/dist/components/charts/xy/Scatterplot.d.ts +11 -1
  193. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
  194. package/dist/components/charts/xy/StackedAreaChart.d.ts +16 -4
  195. package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
  196. package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
  197. package/dist/components/controls/SentenceFilter.d.ts +97 -0
  198. package/dist/components/controls/controlAudit.d.ts +24 -0
  199. package/dist/components/controls/controlContract.d.ts +57 -0
  200. package/dist/components/data/fromFlintChart.d.ts +74 -0
  201. package/dist/components/data/fromVegaLite.d.ts +46 -9
  202. package/dist/components/data/portability/index.d.ts +6 -3
  203. package/dist/components/data/portability/result.d.ts +52 -0
  204. package/dist/components/data/portability/spec.d.ts +31 -0
  205. package/dist/components/data/portability/vegaLite.d.ts +24 -6
  206. package/dist/components/export/chartConfig.d.ts +11 -0
  207. package/dist/components/realtime/types.d.ts +11 -0
  208. package/dist/components/recipes/annotationLayout.d.ts +29 -0
  209. package/dist/components/recipes/axisFixedForce.d.ts +119 -0
  210. package/dist/components/recipes/{gofishBoba.d.ts → boba.d.ts} +2 -2
  211. package/dist/components/recipes/cyclical.d.ts +39 -0
  212. package/dist/components/recipes/edgeRouter.d.ts +103 -0
  213. package/dist/components/recipes/forceLayout.d.ts +48 -0
  214. package/dist/components/recipes/forceLayoutAsync.d.ts +17 -0
  215. package/dist/components/recipes/gofishBobaHandwritten.d.ts +3 -0
  216. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +37 -0
  217. package/dist/components/recipes/gofishIR.d.ts +178 -132
  218. package/dist/components/recipes/gofishIRExamples.d.ts +30 -81
  219. package/dist/components/recipes/intervalLanes.d.ts +87 -0
  220. package/dist/components/recipes/intervals.d.ts +80 -0
  221. package/dist/components/recipes/isometricLandmarks.d.ts +88 -0
  222. package/dist/components/recipes/isotypeGlyphs.d.ts +17 -0
  223. package/dist/components/recipes/mobileAnnotationStrategy.d.ts +48 -0
  224. package/dist/components/recipes/mobileChartFamilyRecipes.d.ts +59 -0
  225. package/dist/components/recipes/networkAnalysis.d.ts +102 -0
  226. package/dist/components/recipes/networkLayouts.d.ts +83 -0
  227. package/dist/components/recipes/physics.d.ts +122 -0
  228. package/dist/components/recipes/physicsReference.d.ts +102 -0
  229. package/dist/components/recipes/processAggregates.d.ts +32 -0
  230. package/dist/components/recipes/processChrome.d.ts +67 -0
  231. package/dist/components/recipes/processJourney.d.ts +54 -0
  232. package/dist/components/recipes/processPhysics.d.ts +300 -0
  233. package/dist/components/recipes/processVolumeGeometry.d.ts +28 -0
  234. package/dist/components/recipes/radialCoords.d.ts +69 -0
  235. package/dist/components/recipes/random.d.ts +2 -0
  236. package/dist/components/recipes/recipeChrome.d.ts +91 -0
  237. package/dist/components/recipes/recipeGlyph.d.ts +42 -0
  238. package/dist/components/recipes/recipeLegend.d.ts +53 -1
  239. package/dist/components/recipes/recipeUtils.d.ts +52 -0
  240. package/dist/components/recipes/runs.d.ts +59 -0
  241. package/dist/components/recipes/tokenEncoding.d.ts +157 -0
  242. package/dist/components/recipes/tokenLayer.d.ts +79 -0
  243. package/dist/components/recipes/unitize.d.ts +108 -0
  244. package/dist/components/recipes/vector.d.ts +28 -0
  245. package/dist/components/recipes/waffle.d.ts +43 -0
  246. package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
  247. package/dist/components/semiotic-ai-core.d.ts +47 -0
  248. package/dist/components/semiotic-ai.d.ts +53 -9
  249. package/dist/components/semiotic-controls.d.ts +20 -0
  250. package/dist/components/semiotic-experimental.d.ts +38 -9
  251. package/dist/components/semiotic-geo.d.ts +15 -0
  252. package/dist/components/semiotic-network.d.ts +15 -0
  253. package/dist/components/semiotic-ordinal.d.ts +14 -0
  254. package/dist/components/semiotic-physics-matter.d.ts +10 -0
  255. package/dist/components/semiotic-physics-rapier.d.ts +9 -0
  256. package/dist/components/semiotic-physics.d.ts +60 -0
  257. package/dist/components/semiotic-realtime-core.d.ts +34 -0
  258. package/dist/components/semiotic-realtime-react.d.ts +10 -0
  259. package/dist/components/semiotic-realtime.d.ts +4 -30
  260. package/dist/components/semiotic-recipes-core.d.ts +92 -0
  261. package/dist/components/semiotic-recipes-react.d.ts +7 -0
  262. package/dist/components/semiotic-recipes.d.ts +4 -43
  263. package/dist/components/semiotic-rough.d.ts +4 -0
  264. package/dist/components/semiotic-server-edge.d.ts +8 -0
  265. package/dist/components/semiotic-server-node.d.ts +5 -0
  266. package/dist/components/semiotic-server.d.ts +2 -2
  267. package/dist/components/semiotic-themes-core.d.ts +53 -0
  268. package/dist/components/semiotic-themes-react.d.ts +4 -0
  269. package/dist/components/semiotic-themes.d.ts +6 -76
  270. package/dist/components/semiotic-utils-core.d.ts +50 -0
  271. package/dist/components/semiotic-utils-react.d.ts +5 -0
  272. package/dist/components/semiotic-utils.d.ts +3 -39
  273. package/dist/components/semiotic-xy.d.ts +12 -0
  274. package/dist/components/semiotic.d.ts +44 -8
  275. package/dist/components/server/animatedGif.d.ts +36 -0
  276. package/dist/components/server/optionalImageTypes.d.ts +37 -0
  277. package/dist/components/server/renderEvidence.d.ts +1 -1
  278. package/dist/components/server/renderToStaticSVG.d.ts +3 -35
  279. package/dist/components/server/serverChartConfigShared.d.ts +21 -0
  280. package/dist/components/server/serverChartConfigs.d.ts +22 -12
  281. package/dist/components/server/serverChartConfigsCustom.d.ts +5 -0
  282. package/dist/components/server/serverChartConfigsGeo.d.ts +9 -0
  283. package/dist/components/server/serverChartConfigsNetwork.d.ts +8 -0
  284. package/dist/components/server/serverChartConfigsOrdinal.d.ts +16 -0
  285. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  286. package/dist/components/server/serverChartConfigsXY.d.ts +11 -0
  287. package/dist/components/server/staticAnnotations.d.ts +6 -3
  288. package/dist/components/server/staticGeo.d.ts +4 -0
  289. package/dist/components/server/staticLegend.d.ts +2 -2
  290. package/dist/components/server/staticNetwork.d.ts +8 -0
  291. package/dist/components/server/staticOrdinal.d.ts +11 -0
  292. package/dist/components/server/staticPhysics.d.ts +3 -0
  293. package/dist/components/server/staticSVGChrome.d.ts +110 -0
  294. package/dist/components/server/staticXY.d.ts +4 -0
  295. package/dist/components/store/ObservationStore.d.ts +23 -2
  296. package/dist/components/store/themeSerialization.d.ts +32 -0
  297. package/dist/components/store/useChartInterrogation.d.ts +9 -0
  298. package/dist/components/stream/AccessibleDataTable.d.ts +7 -23
  299. package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
  300. package/dist/components/stream/CanvasHitTester.d.ts +4 -4
  301. package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
  302. package/dist/components/stream/FocusRing.d.ts +4 -2
  303. package/dist/components/stream/FrameRuntime.d.ts +57 -0
  304. package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
  305. package/dist/components/stream/GeoParticlePool.d.ts +1 -1
  306. package/dist/components/stream/GeoPipelineStore.d.ts +62 -3
  307. package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
  308. package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
  309. package/dist/components/stream/NetworkPipelineStore.d.ts +44 -36
  310. package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
  311. package/dist/components/stream/NetworkSVGOverlay.d.ts +10 -1
  312. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
  313. package/dist/components/stream/OrdinalPipelineStore.d.ts +55 -11
  314. package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
  315. package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
  316. package/dist/components/stream/ParticlePool.d.ts +1 -1
  317. package/dist/components/stream/PipelineStore.d.ts +81 -174
  318. package/dist/components/stream/SVGOverlay.d.ts +6 -0
  319. package/dist/components/stream/SceneGraph.d.ts +12 -4
  320. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  321. package/dist/components/stream/StreamNetworkFrame.d.ts +1 -1
  322. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  323. package/dist/components/stream/StreamXYFrame.d.ts +2 -18
  324. package/dist/components/stream/accessibleDataRows.d.ts +33 -0
  325. package/dist/components/stream/accessorUtils.d.ts +25 -12
  326. package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
  327. package/dist/components/stream/brushAccessibility.d.ts +25 -0
  328. package/dist/components/stream/canvasBackground.d.ts +24 -0
  329. package/dist/components/stream/canvasSetup.d.ts +4 -1
  330. package/dist/components/stream/customLayoutFailure.d.ts +33 -0
  331. package/dist/components/stream/customLayoutPalette.d.ts +19 -9
  332. package/dist/components/stream/frameGraphics.d.ts +4 -0
  333. package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
  334. package/dist/components/stream/frameThemeColors.d.ts +24 -0
  335. package/dist/components/stream/geoAnnotationAnchors.d.ts +14 -0
  336. package/dist/components/stream/geoCartogram.d.ts +17 -0
  337. package/dist/components/stream/geoCustomLayout.d.ts +59 -0
  338. package/dist/components/stream/geoDefaultTooltip.d.ts +11 -0
  339. package/dist/components/stream/geoFrameHelpers.d.ts +34 -0
  340. package/dist/components/stream/geoPipelineHelpers.d.ts +46 -0
  341. package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
  342. package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
  343. package/dist/components/stream/geoTypes.d.ts +97 -15
  344. package/dist/components/stream/glyphDef.d.ts +98 -0
  345. package/dist/components/stream/hitTarget.d.ts +170 -0
  346. package/dist/components/stream/hitTestUtils.d.ts +2 -2
  347. package/dist/components/stream/hoverUtils.d.ts +7 -2
  348. package/dist/components/stream/keyboardNav.d.ts +4 -1
  349. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +9 -1
  350. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +58 -0
  351. package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
  352. package/dist/components/stream/networkBezier.d.ts +10 -0
  353. package/dist/components/stream/networkColorAccessors.d.ts +49 -0
  354. package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
  355. package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
  356. package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
  357. package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
  358. package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
  359. package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
  360. package/dist/components/stream/networkFrameObservations.d.ts +15 -0
  361. package/dist/components/stream/networkFramePaint.d.ts +52 -0
  362. package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
  363. package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
  364. package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
  365. package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
  366. package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
  367. package/dist/components/stream/networkTypes.d.ts +103 -51
  368. package/dist/components/stream/ordinalCanvasRenderers.d.ts +7 -0
  369. package/dist/components/stream/ordinalDataIndex.d.ts +5 -0
  370. package/dist/components/stream/ordinalDefaultTooltip.d.ts +10 -0
  371. package/dist/components/stream/ordinalDomain.d.ts +38 -0
  372. package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +31 -0
  373. package/dist/components/stream/ordinalPulse.d.ts +10 -0
  374. package/dist/components/stream/ordinalPulseResources.d.ts +3 -0
  375. package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +5 -0
  376. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
  377. package/dist/components/stream/ordinalSpatialIndex.d.ts +9 -0
  378. package/dist/components/stream/ordinalTypes.d.ts +68 -9
  379. package/dist/components/stream/paintNeeds.d.ts +31 -0
  380. package/dist/components/stream/physics/CapacityQueueController.d.ts +5 -0
  381. package/dist/components/stream/physics/CapacityQueueTypes.d.ts +134 -0
  382. package/dist/components/stream/physics/MatterPhysicsEngineAdapter.d.ts +42 -0
  383. package/dist/components/stream/physics/PhysicsAccessibility.d.ts +48 -0
  384. package/dist/components/stream/physics/PhysicsAnnotations.d.ts +58 -0
  385. package/dist/components/stream/physics/PhysicsBodyBudget.d.ts +26 -0
  386. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +10 -0
  387. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +26 -0
  388. package/dist/components/stream/physics/PhysicsControllers.d.ts +75 -0
  389. package/dist/components/stream/physics/PhysicsEngineAdapter.d.ts +59 -0
  390. package/dist/components/stream/physics/PhysicsEngineConformance.d.ts +23 -0
  391. package/dist/components/stream/physics/PhysicsEvidence.d.ts +25 -0
  392. package/dist/components/stream/physics/PhysicsKernel.d.ts +207 -0
  393. package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +12 -0
  394. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +86 -0
  395. package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
  396. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +78 -0
  397. package/dist/components/stream/physics/PhysicsSediment.d.ts +69 -0
  398. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +18 -0
  399. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +21 -0
  400. package/dist/components/stream/physics/PhysicsWorkerClient.d.ts +24 -0
  401. package/dist/components/stream/physics/PhysicsWorkerProtocol.d.ts +101 -0
  402. package/dist/components/stream/physics/PhysicsWorkerRuntime.d.ts +5 -0
  403. package/dist/components/stream/physics/RapierPhysicsEngineAdapter.d.ts +18 -0
  404. package/dist/components/stream/physics/ServiceOperationsControllers.d.ts +27 -0
  405. package/dist/components/stream/physics/ServiceOperationsTypes.d.ts +89 -0
  406. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +6 -0
  407. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +317 -0
  408. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -0
  409. package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
  410. package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
  411. package/dist/components/stream/physics/physicsPipelineControls.d.ts +4 -0
  412. package/dist/components/stream/physics/physicsPipelineHelpers.d.ts +41 -0
  413. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +14 -0
  414. package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +27 -0
  415. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +54 -0
  416. package/dist/components/stream/physics/physicsSemanticUI.d.ts +20 -0
  417. package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +18 -0
  418. package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
  419. package/dist/components/stream/pipelineConfig.d.ts +179 -0
  420. package/dist/components/stream/pipelineDecay.d.ts +21 -3
  421. package/dist/components/stream/pipelineDomainResolution.d.ts +62 -0
  422. package/dist/components/stream/pipelineIdentityOps.d.ts +26 -0
  423. package/dist/components/stream/pipelinePulse.d.ts +17 -3
  424. package/dist/components/stream/pipelineRibbons.d.ts +41 -0
  425. package/dist/components/stream/pipelineSpatialIndex.d.ts +12 -0
  426. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +33 -0
  427. package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
  428. package/dist/components/stream/pipelineTransitions.d.ts +3 -1
  429. package/dist/components/stream/pipelineUpdateContract.d.ts +69 -0
  430. package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
  431. package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
  432. package/dist/components/stream/renderBackend.d.ts +27 -0
  433. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
  434. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
  435. package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
  436. package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
  437. package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
  438. package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
  439. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +45 -0
  440. package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
  441. package/dist/components/stream/streamStoreSync.d.ts +37 -0
  442. package/dist/components/stream/streamThemeTypes.d.ts +14 -0
  443. package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
  444. package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
  445. package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
  446. package/dist/components/stream/titleLayout.d.ts +31 -0
  447. package/dist/components/stream/types.d.ts +165 -72
  448. package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
  449. package/dist/components/stream/useFrame.d.ts +44 -2
  450. package/dist/components/stream/useHydration.d.ts +6 -0
  451. package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -0
  452. package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
  453. package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
  454. package/dist/components/stream/workerModuleUrl.d.ts +10 -0
  455. package/dist/components/stream/xyAnnotationAnchors.d.ts +13 -0
  456. package/dist/components/stream/xyCanvasRenderers.d.ts +7 -0
  457. package/dist/components/stream/xyCrosshair.d.ts +11 -0
  458. package/dist/components/stream/xyDateTicks.d.ts +9 -0
  459. package/dist/components/stream/xyDefaultTooltip.d.ts +10 -0
  460. package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
  461. package/dist/components/stream/xySceneBuilders/types.d.ts +10 -9
  462. package/dist/controls.min.js +2 -0
  463. package/dist/controls.module.min.js +2 -0
  464. package/dist/forceLayoutWorker.js +1 -0
  465. package/dist/geo.min.js +1 -1
  466. package/dist/geo.module.min.js +1 -1
  467. package/dist/network.min.js +1 -1
  468. package/dist/network.module.min.js +1 -1
  469. package/dist/ordinal.min.js +1 -1
  470. package/dist/ordinal.module.min.js +1 -1
  471. package/dist/physics-matter.min.js +1 -0
  472. package/dist/physics-matter.module.min.js +1 -0
  473. package/dist/physics-rapier.min.js +1 -0
  474. package/dist/physics-rapier.module.min.js +1 -0
  475. package/dist/physics.min.js +2 -0
  476. package/dist/physics.module.min.js +2 -0
  477. package/dist/physicsWorker.js +1 -0
  478. package/dist/realtime.min.js +1 -1
  479. package/dist/realtime.module.min.js +1 -1
  480. package/dist/rough.min.js +1 -0
  481. package/dist/rough.module.min.js +1 -0
  482. package/dist/semiotic-ai-chunk-OG7BQUUW.module.min.js +2 -0
  483. package/dist/semiotic-ai-core.d.ts +47 -0
  484. package/dist/semiotic-ai-core.min.js +1 -0
  485. package/dist/semiotic-ai-core.module.min.js +1 -0
  486. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +2 -0
  487. package/dist/semiotic-ai.d.ts +53 -9
  488. package/dist/semiotic-ai.min.js +1 -1
  489. package/dist/semiotic-ai.module.min.js +1 -1
  490. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +2 -0
  491. package/dist/semiotic-controls.d.ts +20 -0
  492. package/dist/semiotic-data.min.js +1 -1
  493. package/dist/semiotic-data.module.min.js +1 -1
  494. package/dist/semiotic-experimental.d.ts +38 -9
  495. package/dist/semiotic-experimental.min.js +1 -1
  496. package/dist/semiotic-experimental.module.min.js +1 -1
  497. package/dist/semiotic-geo.d.ts +15 -0
  498. package/dist/semiotic-network.d.ts +15 -0
  499. package/dist/semiotic-ordinal.d.ts +14 -0
  500. package/dist/semiotic-physics-matter.d.ts +10 -0
  501. package/dist/semiotic-physics-rapier.d.ts +9 -0
  502. package/dist/semiotic-physics.d.ts +60 -0
  503. package/dist/semiotic-realtime-core.d.ts +34 -0
  504. package/dist/semiotic-realtime-core.min.js +1 -0
  505. package/dist/semiotic-realtime-core.module.min.js +1 -0
  506. package/dist/semiotic-realtime-react.d.ts +10 -0
  507. package/dist/semiotic-realtime-react.min.js +2 -0
  508. package/dist/semiotic-realtime-react.module.min.js +2 -0
  509. package/dist/semiotic-realtime.d.ts +4 -30
  510. package/dist/semiotic-recipes-core.d.ts +92 -0
  511. package/dist/semiotic-recipes-core.min.js +1 -0
  512. package/dist/semiotic-recipes-core.module.min.js +1 -0
  513. package/dist/semiotic-recipes-react.d.ts +7 -0
  514. package/dist/semiotic-recipes-react.min.js +2 -0
  515. package/dist/semiotic-recipes-react.module.min.js +2 -0
  516. package/dist/semiotic-recipes.d.ts +4 -43
  517. package/dist/semiotic-recipes.min.js +1 -1
  518. package/dist/semiotic-recipes.module.min.js +1 -1
  519. package/dist/semiotic-rough.d.ts +4 -0
  520. package/dist/semiotic-server-edge.d.ts +8 -0
  521. package/dist/semiotic-server-edge.min.js +1 -0
  522. package/dist/semiotic-server-edge.module.min.js +1 -0
  523. package/dist/semiotic-server-node.d.ts +5 -0
  524. package/dist/semiotic-server-node.min.js +1 -0
  525. package/dist/semiotic-server-node.module.min.js +1 -0
  526. package/dist/semiotic-server.d.ts +2 -2
  527. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +2 -0
  528. package/dist/semiotic-themes-core.d.ts +53 -0
  529. package/dist/semiotic-themes-core.min.js +1 -0
  530. package/dist/semiotic-themes-core.module.min.js +1 -0
  531. package/dist/semiotic-themes-react.d.ts +4 -0
  532. package/dist/semiotic-themes-react.min.js +2 -0
  533. package/dist/semiotic-themes-react.module.min.js +2 -0
  534. package/dist/semiotic-themes.d.ts +6 -76
  535. package/dist/semiotic-themes.min.js +1 -2
  536. package/dist/semiotic-themes.module.min.js +1 -2
  537. package/dist/semiotic-utils-core.d.ts +50 -0
  538. package/dist/semiotic-utils-core.min.js +1 -0
  539. package/dist/semiotic-utils-core.module.min.js +1 -0
  540. package/dist/semiotic-utils-react.d.ts +5 -0
  541. package/dist/semiotic-utils-react.min.js +2 -0
  542. package/dist/semiotic-utils-react.module.min.js +2 -0
  543. package/dist/semiotic-utils.d.ts +3 -39
  544. package/dist/semiotic-utils.min.js +1 -2
  545. package/dist/semiotic-utils.module.min.js +1 -2
  546. package/dist/semiotic-value.min.js +1 -1
  547. package/dist/semiotic-value.module.min.js +1 -1
  548. package/dist/semiotic-xy.d.ts +12 -0
  549. package/dist/semiotic.d.ts +44 -8
  550. package/dist/semiotic.min.js +1 -1
  551. package/dist/semiotic.module.min.js +1 -1
  552. package/dist/server.min.js +1 -1
  553. package/dist/server.module.min.js +1 -1
  554. package/dist/test-utils/capturedFrameProps.d.ts +67 -0
  555. package/dist/test-utils/frameMock.d.ts +12 -9
  556. package/dist/xy-chunk-IWD6IB6V.module.min.js +2 -0
  557. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +2 -0
  558. package/dist/xy.min.js +1 -1
  559. package/dist/xy.module.min.js +1 -1
  560. package/package.json +259 -88
  561. package/spec/README.md +152 -0
  562. package/spec/bindings/README.md +35 -0
  563. package/spec/bindings/vega-lite.mjs +112 -0
  564. package/spec/v0.1/annotation-provenance.schema.json +127 -0
  565. package/spec/v0.1/audience-profile.schema.json +67 -0
  566. package/spec/v0.1/chart-capability.schema.json +186 -0
  567. package/dist/components/recipes/gofish.d.ts +0 -207
  568. package/dist/components/recipes/gofishInterpreter.d.ts +0 -52
  569. package/dist/components/recipes/gofishLambdas.d.ts +0 -145
  570. package/dist/semiotic-ai-semiotic-ai-u954ylUn.js +0 -2
  571. package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +0 -1
  572. package/dist/semiotic-semiotic-BmrYbi99.js +0 -2
  573. package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +0 -1
  574. package/dist/xy-semiotic-xy-Dufu3D0-.js +0 -2
  575. package/dist/xy-statisticalOverlays-3Ni9bRph.js +0 -1
@@ -1 +1 @@
1
- "use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("react-dom/server"),o=require("d3-scale"),i=require("d3-quadtree"),r=require("d3-shape"),s=require("d3-array"),a=require("d3-interpolate"),l=require("d3-force"),c=require("d3-chord"),u=require("d3-hierarchy"),d=require("d3-geo"),h=require("d3-selection"),f=require("d3-brush"),g=require("regression");function y(t){return t&&t.__esModule?t:{default:t}}function p(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const m=p(e),v=p(n),x=y(g);function b(t,e,n,o){return new(n||(n=Promise))(function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}l((o=o.apply(t,e||[])).next())})}function k(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function w(t){return"object"==typeof t&&null!==t&&"gradient"in t}"function"==typeof SuppressedError&&SuppressedError;class A{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(o=>{t(o)?n.push(o):e.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class S{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function j(t,e,n,o,i){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const t=i(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function M(t,e,n,o,i,r){const s=[];for(const i of t){const t=n(i),r=o(i);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:i})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function _(t,e,n,o,i,r,s,a){const l=[];for(const r of t){const t=n(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):i;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function P(t,e,n,o){var i,r,s;const a=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;a.set(o,-t/2)}else if("wiggle"===o){t.length>0&&a.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let l=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;l+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(i=a.get(r))&&void 0!==i?i:0;a.set(s,d-(c>0?l/(2*c):0))}if(t.length>0){let o=0;for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;o+=(null!==(r=a.get(i))&&void 0!==r?r:0)+t/2}const i=o/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-i)}}else for(const e of t)a.set(e,0);return a}function O(t,e,n,o,i,r,s){const a=n(t),l=o(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:i,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function T(t,e,n,o,i,r,s,a){const l=n(t),c=o(t);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(l),y:e.y(c),size:i,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function $(t,e,n,o,i,r,s){return{type:"rect",x:t,y:e,w:n,h:o,style:i,datum:r,group:s}}function L(t,e,n,o,i,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:o,fill:i,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function C(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function E(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function R(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function z(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function D(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function N(t,e,n){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function F(t){const e=t.map(D),n=e.length-1;return t=>{if(0>=t){const[t,n,o]=e[0];return N(t,n,o)}if(t>=1){const[t,o,i]=e[n];return N(t,o,i)}const o=t*n,i=Math.floor(o),r=o-i,[s,a,l]=e[i],[c,u,d]=e[i+1];return N(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const W=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],B=F(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),I=F(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Y=F(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),G=F(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),H=F(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),q=F(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),X=F(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),V=F(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),U=F(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Z=F(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Q=F(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),K=F(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),J={blues:B,reds:I,greens:Y,viridis:X,oranges:G,purples:H,greys:q,plasma:V,inferno:U,magma:Z,cividis:Q,turbo:K};F(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),F(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),F(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),F(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),F(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),F(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),F(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const tt=Object.assign({category10:W,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]},J),et=W,nt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],ot=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function it(t,e,n){if("function"==typeof e){const o=e(t);return n&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||ot.has(e)}(o)?n(o):o}const o=(null==t?void 0:t[e])+"";return n?n(o):et[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o))%et.length]}function rt(t,e,n="category10"){const i=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),r=i.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const s=tt[n]||tt.category10;if(r&&"function"==typeof s){let t=-1/0;for(const e of i){const n=Number(e);n>t&&(t=n)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:et;return o.scaleOrdinal().domain(i).range(t).unknown("#999")}}function st(t,e,n){var o,i,r;if(1>=n)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=n-1-e;switch(t.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const e=null!==(i=t.halfLife)&&void 0!==i?i:n/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function at(t,e,n){var o;const i=null!==(o=t.duration)&&void 0!==o?o:500,r=n-e;return i>r?1-r/i:0}function lt(t,e){var n;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&i>o-r}function ct(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ut(t,e){return Math.min((t-e.startTime)/e.duration,1)}function dt(t,e,n){return t+(e-t)*n}function ht(){return"undefined"!=typeof performance?performance.now():Date.now()}function ft(t,e,n){var o,i,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(i=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==i?i:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function gt(t,e,n,o){return"function"==typeof e.style?e.style(o||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,o)}function yt(t,e,n,o){if(!t.scales)return null;const i=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:gt(t,o,n,e[0]),datum:e,group:n,interactive:o.interactive}}function pt(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const o of t)o.perSeries?e.push(o):n.push(o);return{perSeries:e,aggregate:n}}function mt(t,e,n){const o=[];for(const i of n){const n=yt(t,e,"__ribbon_aggregate",i);n&&o.push(n)}return o}function vt(t,e,n,o){const i=[];for(const r of o){const o=yt(t,e,n,r);o&&i.push(o)}return i}function xt(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const o of e){if("band"!==o.kind)continue;const e=o.getTop(t),i=o.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&n.push({y0:i,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function bt(t,e,n,o){var i;if(!t.config.pointStyle)return;const r=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(i=o.r)&&void 0!==i?i:3,l=t.getPointId?t.getPointId(s)+"":void 0,c=O(s,t.scales,t.getX,r,a,o,l);c&&n.push(c)}}}const kt={topOpacity:.8,bottomOpacity:.05};function wt(t){var e,n;if(t)return!0===t?kt:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:kt.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:kt.bottomOpacity}}const At={circle:r.symbolCircle,square:r.symbolSquare,triangle:r.symbolTriangle,diamond:r.symbolDiamond,star:r.symbolStar,cross:r.symbolCross,wye:r.symbolWye},St=["circle","triangle","diamond","star","square","chevron","cross","wye"];function jt(t,e,n){var o,i;if(n)return n;const s=null!=t?t:"circle";if("chevron"===s)return function(t){const e=1.5*Mt(t),n=.92*e;return`M0,${-e}L${n},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-n},${(.78*e).toFixed(3)}Z`}(e);const a=null!==(o=At[s])&&void 0!==o?o:r.symbolCircle;return null!==(i=r.symbol(a,Math.max(1,e))())&&void 0!==i?i:""}function Mt(t){return Math.sqrt(Math.max(1,t)/Math.PI)}const _t=new Map;function Pt(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var o,i,r;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(i=t.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=E(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,y=(f-h||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let n=0;e.length>n;n++){const o=e[n],i=t.getX(o),r=t.getY(o);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/g),s-1),d=Math.min(Math.floor((r-h)/y),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const p=c(o);v[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(l){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/s,A=n.height/a,S=t.config.showValues,j=t.config.heatmapValueFormat,M=[];for(let t=0;a>t;t++){const e=t*s;for(let n=0;s>n;n++){const o=e+n;if(0===m[o])continue;let i;switch(l){case"sum":i=v[o];break;case"mean":i=v[o]/m[o];break;default:i=m[o]}const r=(i-x)/k;M.push(L(n*w,(a-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:i,count:m[o],sum:v[o],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*y,agg:l},S?{value:i,showValues:!0,valueFormat:j}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const o=E(t.config.valueAccessor,"value"),i=R(t.config.xAccessor,"x"),r=R(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],o=i(n),u=r(n);l[t]=o,c[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),m=new Float64Array(e.length),v=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],i=s.get(l[t]),r=a.get(c[t]);if(void 0===i||void 0===r)continue;const d=o(n),h=r*u+i,f=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),p[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in J?t:"blues";let n=_t.get(e);if(n)return n;n=Array(256);const o=(i=e)&&J[i]||B;var i;for(let t=0;256>t;t++)n[t]=o(t/255);return _t.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),j=n.width/u,M=n.height/d,_=t.config.showValues,P=t.config.heatmapValueFormat,O=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const n=p[t],o=n%u;O.push(L(o*j,(d-1-(n-o)/u)*M,j,M,A[Math.min((e-k)*S+.5|0,255)],v[t],_?{value:e,showValues:!0,valueFormat:P}:void 0))}return O}function Ot(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:o,warned:i}=t;Tt(o)&&0===n.length&&$t(i,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(t=>null==t.datum)&&$t(i,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Tt(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Tt))}function $t(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function Lt(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Ct(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=Lt(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=E(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e+i:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e-i:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:Lt(t.y1Accessor,"y1"),getBottom:Lt(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class Et{constructor(t){if(this.xExtent=new S,this.yExtent=new S,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new A(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=E(t.timeAccessor||t.xAccessor,"time"),this.getY=E(t.valueAccessor||t.yAccessor,"value")):(this.getX=E(t.xAccessor,"x"),this.getY=E(t.yAccessor,"y")),this.getGroup=z(t.groupAccessor),this.getCategory=z(t.categoryAccessor),this.getSize=t.sizeAccessor?E(t.sizeAccessor,"size"):void 0,this.getColor=z(t.colorAccessor),this.getSymbol=z(t.symbolAccessor),this.getY0=t.y0Accessor?E(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Ct(t),this.getPointId=z(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?E(t.openAccessor,"open"):void 0,this.getHigh=E(t.highAccessor,"high"),this.getLow=E(t.lowAccessor,"low"),this.getClose=n?E(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new A(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?E(this.config.timeAccessor||this.config.xAccessor,"time"):E(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(e):e[n||"x"],i=o instanceof Date,r="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=i||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)if(this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);if(this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}if(null!=t)if(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t));else{this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}}return!0}computeScene(t){var e,n,i,r,s,a,l,c,u,d,h,f,g,y;const{config:p,buffer:m}=this;if(!this.needsFullRebuild&&!p.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),x=this.xExtent.extent,b=this.yExtent.extent;let k=p.xExtent?[null!==(n=p.xExtent[0])&&void 0!==n?n:x[0],null!==(i=p.xExtent[1])&&void 0!==i?i:x[1]]:x,w=p.yExtent?[null!==(r=p.yExtent[0])&&void 0!==r?r:b[0],null!==(s=p.yExtent[1])&&void 0!==s?s:b[1]]:b;const A=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1],S="exact"===p.axisExtent;if("stackedarea"===p.chartType&&!A&&m.size>0)if(p.normalize)w=[0,S?1:1+p.extentPadding];else{const t=`${m.size}:${this._ingestVersion}:${null!==(a=p.baseline)&&void 0!==a?a:"zero"}:${null!==(l=p.stackOrder)&&void 0!==l?l:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)w=this._stackExtentCache.yDomain;else{const e=this.groupData(v),n=new Map,o=new Set;let i=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let a=0;for(const n of t.data){const t=this.getX(n),s=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),o.add(t),a+=s;const l=(r.get(t)||0)+s;r.set(t,l),l>i&&(i=l)}n.set(t.key,e),s.set(t.key,a)}const a=null!==(c=p.stackOrder)&&void 0!==c?c:"key",l=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===a){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:l(t,e)}),n=[],o=[];let i=0,r=0;for(const e of t)r>i?(n.push(e),i+=null!==(u=s.get(e))&&void 0!==u?u:0):(o.push(e),r+=null!==(d=s.get(e))&&void 0!==d?d:0);g=[...o.reverse(),...n]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==i?i:l(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:l(t,e)}):e.map(t=>t.key).sort(l);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=P(t,g,(t,e)=>{var o;return(null===(o=n.get(t))||void 0===o?void 0:o.get(e))||0},p.baseline);let i=1/0,s=-1/0;for(const n of t){const t=null!==(h=e.get(n))&&void 0!==h?h:0,o=null!==(f=r.get(n))&&void 0!==f?f:0;i>t&&(i=t),t+o>s&&(s=t+o)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=S?0:a>0?a*p.extentPadding:1;w=[i-l,s+l]}else w=[0,i+(S?0:i>0?i*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:w}}}else if("bar"===p.chartType&&p.binSize&&!A&&m.size>0){const[,t]=function(t,e,n,o,i){const r=j(t,e,n,o,i);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(m,this.getX,this.getY,p.binSize,this.getCategory);w=[0,S?t:t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!A&&m.size>0){const[t,e]=function(t,e){let n=0,o=0,i=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(m,this.getY),n=e-t,o=S?0:n>0?n*p.extentPadding:1;w=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!A&&w[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of v)for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&(w[0]>n&&(w[0]=n),n>w[1]&&(w[1]=n)),Number.isFinite(o)&&(w[0]>o&&(w[0]=o),o>w[1]&&(w[1]=o))}const t=w[1]-w[0],e=S?0:t>0?t*p.extentPadding:1,n=null===(g=p.yExtent)||void 0===g?void 0:g[0],o=null===(y=p.yExtent)||void 0===y?void 0:y[1];w=[null!=n?w[0]:w[0]-e,null!=o?w[1]:w[1]+e],"log"!==p.yScaleType||w[0]>0||0>=b[0]||S||(w[0]=null!=n?w[0]:b[0]/(1+p.extentPadding))}if(p.yExtent&&!A){const t=p.yExtent[0],e=p.yExtent[1];null==t&&null==e||(w=[null!=t?t:w[0],null!=e?e:w[1]])}if(k[0]===1/0||k[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();k=[t-864e5,t]}else k=[0,1];w[0]!==1/0&&w[1]!==-1/0||(w=[0,1]);const M="streaming"===p.runtimeMode,_=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(M)if("x"==("up"===(O=p.arrowOfTime)||"down"===O?"y":"x")){const e="right"===p.arrowOfTime?[_,t.width-_]:[t.width-_,_];this.scales={x:o.scaleLinear().domain(k).range(e),y:o.scaleLinear().domain(w).range([t.height-_,_])}}else{const e="down"===p.arrowOfTime?[_,t.height-_]:[t.height-_,_];this.scales={x:o.scaleLinear().domain(w).range([_,t.width-_]),y:o.scaleLinear().domain(k).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)};this.scales={x:e(p.xScaleType,k,[_,t.width-_]),y:e(p.yScaleType,w,[t.height-_,_])}}var O;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,Et.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=i.quadtree().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=n;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=n;for(const o of t.bottomPath)o[0]*=e,o[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:l(this.config.yScaleType,r,u?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,o,i,r,s,a,l,c,u;const{config:d,scales:h}=this;if(!h)return[];if(d.customLayout){const u=null!==(n=d.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},f={data:e,scales:h,dimensions:{width:t.width,height:t.height,margin:u,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(o=d.themeSemantic)&&void 0!==o?o:{},categorical:null!==(i=d.themeCategorical)&&void 0!==i?i:nt},resolveColor:(t,e)=>{var n,o;const i=this.resolveGroupColor(t);if(i)return i;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(o=null===(n=d.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==o?o:"#4e79a7"},config:null!==(r=d.layoutConfig)&&void 0!==r?r:{},selection:null!==(s=d.layoutSelection)&&void 0!==s?s:null};let g;try{g=d.customLayout(f)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,[]}this.customLayoutOverlays=null!==(a=g.overlays)&&void 0!==a?a:null;const y=null!==(l=g.nodes)&&void 0!==l?l:[];if(this._customRestyle=g.restyle,this.hasCustomRestyle=!!g.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of y)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(y,null!==(c=d.layoutSelection)&&void 0!==c?c:null)}return Ot({label:"customLayout",nodes:y,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),y}if(this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const f={scales:h,config:d,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(d.chartType){case"line":return function(t,e){var n;const o=t.groupData(e),i=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=pt(t.ribbons);if(r.length>0&&i.push(...mt(t,e,r)),n.length>0)for(const e of o)i.push(...vt(t,e.data,e.key,n))}for(const e of o){const n=t.resolveLineStyle(e.key,e.data[0]),o=M(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(o.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return bt(t,o,i),i}(f,e);case"area":return function(t,e){const n=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=pt(t.ribbons);if(r.length>0&&o.push(...mt(t,e,r)),i.length>0)for(const e of n)o.push(...vt(t,e.data,e.key,i))}const i=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=_(e.data,t.scales,t.getX,t.getY,i,n,e.key,r),a=wt(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return bt(t,n,o),o}(f,e);case"mixed":return function(t,e){const n=t.groupData(e),o=[],i=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=pt(t.ribbons);if(r.length>0&&o.push(...mt(t,e,r)),i.length>0)for(const e of n)o.push(...vt(t,e.data,e.key,i))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(i.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),i=_(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=wt(t.config.gradientFill);a&&(i.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}else{const n=t.resolveLineStyle(e.key,e.data[0]),i=M(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return bt(t,n,o),o}(f,e);case"stackedarea":return function(t,e){var n,o,i,r;const s=t.groupData(e),a=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",l=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const n of s){let o=0;for(const e of n.data){const n=t.getX(e),i=t.getY(e);Number.isFinite(n)&&Number.isFinite(i)&&(o+=i)}e.set(n.key,o)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(t.key))&&void 0!==i?i:0)-(null!==(r=e.get(o.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else if("desc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else{const t=[...s].sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)}),r=[],a=[];let l=0,c=0;for(const n of t)c>l?(r.push(n),l+=null!==(o=e.get(n.key))&&void 0!==o?o:0):(a.push(n),c+=null!==(i=e.get(n.key))&&void 0!==i?i:0);s.length=0,s.push(...a.reverse(),...r)}}else l();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,o,i,r,s,a="zero"){var l,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=n(i),r=o(i);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const o of t)n+=(null===(l=h.get(o.key))||void 0===l?void 0:l.get(e))||0;f.set(e,n||1)}}const g=P(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},a),y=[],p=new Map,m=new Map;for(const t of d)m.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),o=[],a=[],l=new Map;for(const n of d){let i=t.get(n)||0;const s=m.get(n);r&&(i/=f.get(n));const c=s+i,u=e.x(n);a.push([u,e.y(s)]),o.push([u,e.y(c)]),m.set(n,c),l.set(n,c)}p.set(n.key,l);const c={type:"area",topPath:o,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),y.push(c)}return{nodes:y,stackedTops:p}}(s,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of s){const o=h.get(n.key);if(o)for(const i of n.data){const n=t.getX(i),r=t.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||e.set(i,o.get(n))}}const n=n=>{var o;return null!==(o=e.get(n))&&void 0!==o?o:t.getY(n)};bt(t,s,f,n)}return f}(f,e);case"scatter":case"bubble":return function(t,e){var n;const o=[],i="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const o of n)t>o&&(t=o),o>e&&(e=o);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const a=t.getColor?t.resolveColorMap(e):null,l=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",c=t.getSymbol,u=t.config.symbolMap,d=new Map;let h=0;const f=t=>{const e=null==u?void 0:u[t];if(e)return e;let n=d.get(t);return n||(n=St[h%St.length],h++,d.set(t,n)),n};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:l,opacity:.8},r=e.r||i;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(n);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const i=f(c(n)+""),s=T(n,t.scales,t.getX,t.getY,Math.PI*r*r,i,e,u);s&&o.push(s)}else{const i=O(n,t.scales,t.getX,t.getY,r,e,u);i&&o.push(i)}}return o}(f,e);case"heatmap":return Pt(f,e,t);case"bar":{const t=function(t,e){var n,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=j(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(n),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=n.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:l,order:r})}const s=[],a=t.scales,[l,c]=a.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of i.values()){const n=Math.max(e.start,l),i=Math.min(e.end,c);if(n>=i)continue;const h=a.x(n),y=a.x(i),p=Math.abs(y-h),m=p>f+1?f:0,v=Math.min(h,y)+m/2,x=Math.max(p-m,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const i of r){const r=e.categories.get(i)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(o=t.config.barColors)||void 0===o?void 0:o[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push($(v,Math.min(l,c),x,Math.abs(l-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:i,categoryValue:r},i)),n+=r}}else{const t=a.y(0),n=a.y(e.total);s.push($(v,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of i.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(f,e);return this._barCategoryCache=null!==(u=f.barCategoryCache)&&void 0!==u?u:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,o,i,r,s,a;const l=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(o=c.fill)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),o=t.getY(n);if(null==o||Number.isNaN(o))continue;const i=t.scales.x(e),r=t.scales.y(o);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),l.push(c)}return l}(f,e);case"waterfall":return function(t,e,n){var o,i,r,s,a,l,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),o=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(r=null!==(o=null==h?void 0:h.positiveColor)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",y=null!==(l=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==l?l:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,m=null==h?void 0:h.stroke,v=null==h?void 0:h.strokeWidth,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],i=t.getX(o),r=t.getY(o),s=b+r;let a;a=f.length-1>e?t.getX(f[e+1])-i:e>0?i-t.getX(f[e-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+n.width/10,k=Math.min(l,c)+p/2,w=Math.max(l,c)-p/2-k;if(0>=w){b=s;continue}const A=d.y(b),S=d.y(s),j=Math.min(A,S),M=Math.abs(A-S),_={fill:0>r?y:g,stroke:m,strokeWidth:v};null!=x&&(_.opacity=x),u.push($(k,j,w,M,_,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=s}return u}(f,e,t);case"candlestick":return function(t,e){var n,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const i=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=i?a:s.upColor||"#28a745",c=i?a:s.downColor||"#dc3545",u=i?a:s.wickColor||"#333",d=s.wickWidth||(i?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(n),s=t.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=i?o:t.getOpen(n),h=i?s:t.getClose(n);if(!i&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};i&&(y.isRange=!0),r.push(y)}return r}(f,e);default:return[]}}resolveBoundsStyle(t,e){var n;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?st(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var o,i;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const o=Array(e.length);let i=!1;for(let n=0;e.length>n;n++){const a=s.get(e[n]);null!=a?(o[n]=st(t,a,r),1>o[n]&&(i=!0)):o[n]=1}i&&(n._decayOpacities=o);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:e.length;if(2>o)continue;if(e.length===o){const i=Array(o);let a=!1;for(let n=0;e.length>n;n++){const o=s.get(e[n]);null!=o?(i[n]=st(t,o,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of e){const e=s.get(n);if(null!=e){const n=st(t,e,r);i>n&&(i=n)}}if(1>i){const t=Array(o);t.fill(i),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const a=st(t,e,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(i=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,o){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=t.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let i=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=o.get(e);if(null==r)continue;const a=at(t,r,s);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const i=o.get(e);if(null==i)continue;const r=at(t,i,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&lt(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,o){var i,r,s,a;n.clear(),o.clear();for(let l=0;e.length>l;l++){const c=e[l],u=ft(t,c,l);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(i=c.style)||void 0===i?void 0:i.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?o.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&o.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=ft(this.transitionContext,e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(i,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(i,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(i,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,o,i){var r,s,a,l,c,u,d,h,f,g,y,p,m,v,x,b,k,w,A,S,j,M,_,P,O,T,$,L,C,E,R,z,D,N,F,W,B,I,Y,G,H;if(0===o.size&&0===i.size)return n;const q=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let X=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],T=ft(t,r,e);if(!T)continue;if(r._transitionKey=T,"line"===r.type||"area"===r.type){const t=i.get(T);if(t){if(U.add(T),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];X=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];X=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=t.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;continue}const $=o.get(T);if("point"===r.type)if($){V.add(T);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,$.x===t.x&&$.y===t.y&&$.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=$.x,r.y=$.y,r.r=null!==(d=$.r)&&void 0!==d?d:r.r,X=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("rect"===r.type)if($){V.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,$.x===t.x&&$.y===t.y&&$.w===t.w&&$.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=$.x,r.y=$.y,r.w=null!==(g=$.w)&&void 0!==g?g:r.w,r.h=null!==(y=$.h)&&void 0!==y?y:r.h,X=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("heatcell"===r.type)if($){V.add(T);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(v=null===(m=r.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,$.x===t.x&&$.y===t.y&&$.w===t.w&&$.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=$.x,r.y=$.y,r.w=null!==(x=$.w)&&void 0!==x?x:r.w,r.h=null!==(b=$.h)&&void 0!==b?b:r.h,X=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0;else if("candlestick"===r.type)if($&&null!=$.openY){V.add(T);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,($.x!==t.x||$.openY!==t.openY||$.closeY!==t.closeY||$.highY!==t.highY||$.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=$.x,r.openY=$.openY,r.closeY=null!==(j=$.closeY)&&void 0!==j?j:r.closeY,r.highY=null!==(M=$.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(_=$.lowY)&&void 0!==_?_:r.lowY,X=!0)}else r._targetOpacity=null!==(O=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==O?O:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0}for(const[t,e]of i)if(!U.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),X=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),X=!0}for(const[t,e]of o)if(!V.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(L=e.r)&&void 0!==L?L:3,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(R=e.h)&&void 0!==R?R:0,style:{opacity:null!==(z=e.opacity)&&void 0!==z?z:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(W=e.openY)&&void 0!==W?W:e.y,i={type:"candlestick",x:e.x,openY:o,closeY:null!==(B=e.closeY)&&void 0!==B?B:o,highY:null!==(I=e.highY)&&void 0!==I?I:o,lowY:null!==(Y=e.lowY)&&void 0!==Y?Y:o,bodyWidth:null!==(G=e.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(H=e.opacity)&&void 0!==H?H:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}X=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),X&&(n.activeTransition={startTime:ht(),duration:q}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,o){var i,r,s,a,l,c;if(!n.activeTransition)return!1;const u=ut(t,n.activeTransition),d=ct(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=dt(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),t.y=dt(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=dt(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=dt(i,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),t.y=dt(n.y,t._targetY,d),void 0!==n.w&&(t.w=dt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=dt(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:dt(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),t.y=dt(n.y,t._targetY,d),void 0!==n.w&&(t.w=dt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=dt(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:dt(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=dt(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=dt(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=dt(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=dt(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:dt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=dt(e[o][0],n[o][0],d),t.path[o][1]=dt(e[o][1],n[o][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:dt(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,o=t._targetTopPath,i=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=dt(e[n][0],o[n][0],d),t.topPath[n][1]=dt(e[n][1],o[n][1],d);if(n&&i&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=dt(n[e][0],i[e][0],d),t.bottomPath[e][1]=dt(n[e][1],i[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(this._groupDataCache&&this._groupDataCache.version===this._ingestVersion&&this._groupDataCache.group===this.getGroup&&this._groupDataCache.data===t)return this._groupDataCache.result;let e;if(this.getGroup){const n=new Map;for(const e of t){const t=this.getGroup(e);n.has(t)||n.set(t,[]),n.get(t).push(e)}e=Array.from(n.entries()).map(([t,e])=>({key:t,data:e}))}else e=[{key:"_default",data:t}];return this._groupDataCache={version:this._ingestVersion,group:this.getGroup,data:t,result:e},e}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||nt,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],i[t%i.length]);return this._colorMapCache={key:o,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const i=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,o;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||nt;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>Et.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,o=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{i.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){var n,o;const i=this._customRestyle;if(i)for(const r of t){const t=null!==(o=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==o?o:{},s=i(r,e);r.style=s?Object.assign(Object.assign({},t),s):t}}restyleScene(t){this._customRestyle&&this.applyCustomRestyle(this.scene,t)}updateConfig(t){var e,n,o,i;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=l||!C(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!C(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=E(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=E(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=E(this.config.xAccessor,"x"),this.getY=E(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Ct(this.config)),s=!0,a=!0)}if("groupAccessor"in t&&!C(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?z(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!C(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?z(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!C(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?E(this.config.sizeAccessor,"size"):void 0,s=!0),"symbolAccessor"in t&&!C(t.symbolAccessor,r.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?z(this.config.symbolAccessor):void 0,s=!0),"colorAccessor"in t&&!C(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?z(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!C(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?E(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in t&&!C(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Ct(this.config),s=!0,a=!0),"pointIdAccessor"in t&&!C(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?z(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!C(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!C(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!C(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!C(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?E(this.config.openAccessor,"open"):void 0,this.getHigh=E(this.config.highAccessor,"high"),this.getLow=E(this.config.lowAccessor,"low"),this.getClose=e?E(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,a=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Rt(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function zt(t,e){var n,o=[],i=[],r=[],s={},a=[];function l(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&l(e)})}function c(t){var e,o,d=!1;for(i.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===n?(u(n,i),d=!0):r[o]||(d=c(o));if(d)l(t);else for(e=0;a[t].length>e;e++){var h=s[o=a[t][e]];h||(s[o]=h={}),h[o]=!0}return i.pop(),d}function u(t,e){var n=[].concat(e).concat(t);o.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,o=function(t){for(var e=t.length,n=Array(e),o=Array(e),i=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,o[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(e){var l=[e],c=[e];for(n[e]=o[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=o[y]=u,i[y]=!0,u+=1,l.push(y),c.push(y);break}i[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=g}else{if(o[e]===n[e]){var p=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var x=l[g];if(i[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,s[x]=d.length,x===e){l.length=g;break}}d.push(p);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];h.push(b)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[l]=c}}return{components:d,adjacencyList:h}}(t),i=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],n=s);var l=i[n];if(!l)return!1;var c=t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return o}function Dt(t){return t.y0-t.y1>0?"up":"down"}function Nt(t,e){return e(t.source)==e(t.target)}function Ft(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function Wt(t){return t.target.x0-t.source.x1}function Bt(t,e){var n=Yt(t),o=Wt(e)/Math.tan(n);return"up"==Dt(t)?t.y1-o:t.y1+o}function It(t,e){var n=Yt(t),o=Wt(e)/Math.tan(n);return"up"==Dt(t)?t.y1+o:t.y1-o}function Yt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Gt(t,e){return e(t)}function Ht(t){return Xt(t.source)}function qt(t){return Xt(t.target)}function Xt(t){return(t.y0+t.y1)/2}function Vt(t){return t.virtual?0:t.value}function Ut(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Nt(t,e)?n+1:n});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Nt(t,e)?o+1:o}),n+o}function Zt(t){return t.target.depth}function Qt(t,e){return t.sourceLinks.length?t.depth:e-1}function Kt(t,e){return t.y0-e.y0}function Jt(t,e){return e.y0-t.y0}function te(t,e){return t.y1-e.y1}function ee(t,e){return e.y1-t.y1}function ne(t,e){return ie(t.source,e.source)||t.index-e.index}function oe(t,e){return ie(t.target,e.target)||t.index-e.index}function ie(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function re(t,e){return se(t)==se(e)?"bottom"==t.circularLinkType?Jt(t,e):Kt(t,e):se(e)-se(t)}function se(t){return t.target.column-t.source.column}function ae(t,e){return le(t)==le(e)}function le(t){return t.y0-t.y1>0?"up":"down"}function ce(t,e,n,o,i){let r=t;var a=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var l=s.min(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),ue(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),ue(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Nt(t,e)&&Ft(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,a=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?Jt:Kt);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?ee:te),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=l-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,o=t.target.x0,i=t.y1,r=(e+o)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+i+" "+o+","+i}(t)}),r}function ue(t,e,n){t.sort(re);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Nt(t,e)&&Ft(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&de(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function de(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function he(t){return function(){return t}}function fe(t){return t.index}function ge(t){return t.nodes}function ye(t){return t.links}function pe(t,e,n){var o=s.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(i,r){var s=i.length;if(e)i.sort(e);else if(r>0){var a=new Map;i.forEach(function(t,e){var n,o,i,r=(o=0,i=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Xt(t.source)*e,o+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Xt(t.target)*e,o+=e}}),o>0?i/o:NaN);a.set(t,{bc:r,idx:e})}),i.sort(function(t,e){var n=a.get(t),o=a.get(e),i=n.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?n.idx-o.idx:1:-1:i-r})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ut(e,n)-Ut(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Ut(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+i,e.y1=e.y0+e.value*t.ky)})})}function me(t,e,n,o,i,r){var a=s.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var l=1,c=r;c>0;--c)u(l*=.99,n),d();function u(e,n){var o=a.length;a.forEach(function(i){var r=i.length,a=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ut(i,n)>0){var c=s.mean(i.sourceLinks,qt),u=s.mean(i.targetLinks,Ht),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Xt(i))*e*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==r)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(a==o-1&&1==r)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var f=s.mean(i.sourceLinks,qt),g=s.mean(i.targetLinks,Ht),y=((f&&g?(f+g)/2:f||g)-Xt(i))*e;i.y0+=y,i.y1+=y}})})}function d(){a.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||ie),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+o;if((s=l-o-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function ve(t){t.nodes.forEach(function(t){t.sourceLinks.sort(oe),t.targetLinks.sort(ne)}),t.nodes.forEach(function(t){var e=t.y0,n=e,o=t.y1,i=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function xe(){var t=0,e=0,n=1,o=1,i=24,r=8,a=null,l=fe,c=Qt,u=void 0,d=32,h=2,f=ge,g=ye;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=o,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return s.group(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,i=t.target;"object"!=typeof o&&(o=t.source=Rt(n,o)),"object"!=typeof i&&(i=t.target=Rt(n,i)),o.sourceLinks.push(t),i.targetLinks.push(t)})}(f,l),function(t,e){var n=0;if(null==e){for(var o=[],i=0;t.links.length>i;i++){var r=t.links[i],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=zt(o);l.sort(function(t,e){return t.length-e.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||c[o]&&c[o][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(f,u),function(t,e){var n=0,o=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:o>n?"top":"bottom","top"==i.circularLinkType?n++:o++,t.nodes.forEach(function(t){Gt(t,e)!=Gt(i.source,e)&&Gt(t,e)!=Gt(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Nt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,l),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(s.sum(t.sourceLinks,Vt),s.sum(t.targetLinks,Vt)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,n){var o,i,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(f,u,c);var g=r;if(null!==a){var y=s.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=s.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(o-e)*a/(p-1)))}(function(t,e,n){var o=s.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var i=s.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/s.sum(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var r=s.max(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,g,i),pe(f,u,l),me(f,u,l,g,g,d),ve(f),ce(f,l,h,10,8),pe(f,u,l),me(f,u,l,g,g,d),ve(f),ce(f,l,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var o=n.links.filter(function(n){return Gt(n.source,e)==Gt(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ae(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Bt(e,t);return t.y1-n}if(e.target.column>t.target.column)return Bt(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(f,l),function(t,e){let n=t;n.nodes.forEach(function(t){var o=n.links.filter(function(n){return Gt(n.target,e)==Gt(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ae(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=It(e,t);return t.y0-n}if(e.source.column>t.source.column)return It(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(f,l),function(t){var e=t.nodes,n=t.links,o=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==o||0==i){var r=s.min(e,function(t){return t.y0}),a=s.max(e,function(t){return t.y1}),l=(t.y1-t.y0)/(a-r);function c(e){return(e-r)/(a-r)*(t.y1-t.y0)+t.y0}1>l?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*l})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(f),ce(f,l,h,10,8)}(y),y}return y.update=function(t){return ve(t),ce(t,l,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(i=+t,y):i},y.nodePadding=function(t){return arguments.length?(r=+t,y):r},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:he(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:he(t),y):g},y.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:he(t),y):l},y.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:he(t),y):c},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(d=+t,y):d},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],o=+i[1][1],y):[[t,e],[n,o]]},y.size=function(i){return arguments.length?(t=e=0,n=+i[0],o=+i[1],y):[n-t,o-e]},y}function be(t){const{sx:e,sTop:n,sBot:o,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+o)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(o-n)/2}}}Et.GROUP_COLOR_MAP_CAP=1e3,Et.QUADTREE_THRESHOLD=500;const ke=t=>{let e,n,o,i,r,s,l,c,u;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,l=a.interpolateNumber(r,s),c=l(.5),u=l(.5),`M${e},${r}C${e},${c} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${c} ${i},${r}Z`;const d=t.sankeyWidth/2,h=a.interpolateNumber(t.source.x1,t.target.x0),{pathD:f}=be({sx:t.source.x1,sTop:t.y0-d,sBot:t.y0+d,tx:t.target.x0,tTop:t.y1-d,tBot:t.y1+d,cp1X:h(.5),cp2X:h(.5)});return f};function we(t){var e;const n=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const e=i.sourceX,o=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${e},${o-n}L${e+a},${o-n}L${e+a},${o+n}L${e},${o+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}Z`}const r=i.sourceX,s=i.sourceY,a=i.targetX,l=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+o},${s-h*n+h*f}L${c+o},${d+h*o-h*f}L${c+o-f},${d+h*o}L${u-o+f},${d+h*o}L${u-o},${d+h*o-h*f}L${u-o},${l-h*n+h*f}L${u-o+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${s+h*n}L${r},${s+h*n}Z`}const Ae=new Set,Se=new WeakMap;function je(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Se.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Se.set(t,n);const o=new Proxy(t,{get(t,n,o){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Ae.has(t)||(Ae.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,o)}});return n.set(e,o),o}const Me={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Zt))-1:0},justify:Qt};function _e(t){return"string"==typeof t?t:t.id}const Pe={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r,s,a,l,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const x=xe().extent(v).links(m).nodes(p).nodeAlign(Me[h]||Qt).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),n>o.y0&&(n=o.y0),o.y1>i&&(i=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(null!==(l=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==l?l:0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=e-t,s=i-n,u=o[0],d=o[1];if(r>0&&s>0&&(0>t||0>n||e>u||i>d)){const e=Math.min(u/r,d/s),o=-t*e+(u-r*e)/2,i=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of m)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+o,n.targetX=n.targetX*e+o,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+o,n.leftFullExtent=n.leftFullExtent*e+o,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+o,n.leftInnerExtent=n.leftInnerExtent*e+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=_e(t.source),n=_e(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=d;const i=b.get(e),r=b.get(n);i&&(o.source=i),r&&(o.target=r)}}},buildScene(t,e,n,o){var i,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:W,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],v=[],x=[],b=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const o=d?d(je(e,"nodeStyle")):{},i={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.set(e.id,("string"==typeof i.fill?i.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:i,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof g?g(t)||i:"target"===g?b.get(o.id)||p.get(o.id)||i:b.get(e.id)||p.get(e.id)||i;const u=h?h(je(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||i;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?we(t):ke(t),!d)continue;const y={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const r=e?e(n):n.id;if(!r)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(o[0]/2>n.x0+t/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+i/2),x.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:x}}};function Oe(t){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);return[e,n]}function Te(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}const $e={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r;if(0===t.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,a=o[0]/2,c=o[1]/2,u=n.__previousPositions;let d=0;const h=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==u?void 0:u.get(e.id);t?d++:n?(e.x=n.x,e.y=n.y,d++):h.push(e)}const f=d>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const o=Le(t.id,e,n);if(o.length>0){let e=0,n=0;for(const t of o)e+=t.x,n+=t.y;const i=Ce(t.id),r=i%360*(Math.PI/180),s=10+i%20;t.x=e/o.length+s*Math.cos(r),t.y=n/o.length+s*Math.sin(r)}else{const e=Ce(t.id),n=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(n),t.y=c+o*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const o=t[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(n+.5),i=n*e;o.x=a+t*Math.cos(i),o.y=c+t*Math.sin(i)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:f?40:g,p=Ee(n.nodeSize,n.nodeSizeRange,t),m=t=>p(t);if(y>0){const n=l.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=l.forceSimulation().force("charge",l.forceManyBody().strength(t=>-25*m(t))).force("center",l.forceCenter(a,c).strength(.8)).force("x",l.forceX(a).strength(.15)).force("y",l.forceY(c).strength(.15));if(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));n.links(t),o.force("link",n)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;y>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Ee(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:W,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=d?d(je(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),o="object"==typeof t.target?t.target:x.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const i=h?h(je(t,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=i.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=i.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const o=f(je(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Le(t,e,n){const o=[];for(const i of e){const e="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Ce(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Ee(t,e,n){var i;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],s=[];for(const e of n){const n=null===(i=e.data)||void 0===i?void 0:i[t];"number"==typeof n&&s.push(n)}if(0===s.length)return()=>r[0];const[a,l]=Oe(s);if(a===l)return()=>(r[0]+r[1])/2;const c=o.scaleLinear().domain([a,l]).range(r).clamp(!0);return e=>{var n;const o=null===(n=e.data)||void 0===n?void 0:n[t];return null==o||"number"!=typeof o?r[0]:c(o)}}const Re=W,ze={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const{padAngle:i=.01,groupWidth:s=20,sortGroups:a}=n,l=Math.min(o[0],o[1])/2,u=l-s,d=o[0]/2,h=o[1]/2,f=(g=n.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=y.get("string"==typeof t.source?t.source:t.source.id),o=y.get(e);if(void 0===n||void 0===o)continue;const i=f(t);m[n][o]=i}const v=c.chord().padAngle(i);a&&v.sortGroups(a);const x=v(m),b=x.groups,k=r.arc().innerRadius(u).outerRadius(l);for(const e of b){const n=t[e.index],o=k.centroid({innerRadius:u,outerRadius:l,startAngle:e.startAngle,endAngle:e.endAngle});n.x=o[0]+d,n.y=o[1]+h,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),o=w.get(e);n&&(t.source=n),o&&(t.target=o)}const A=new Map;for(const t of e)A.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,o=t[e.target.index].id,i=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);i&&(i.__chordData=e)}},buildScene(t,e,n,o){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:u=.5}=n,d=Math.min(o[0],o[1])/2,h=d-l,f=o[0]/2,g=o[1]/2,y=n.nodeStyle,p=n.edgeStyle,m=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Re,x=new Map;t.forEach((t,e)=>{x.set(t.id,v[e%v.length])});const b=c.ribbon().radius(h),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],o=n.__arcData;if(!o)continue;let r;r=y?y(je(n,"nodeStyle")).fill||x.get(n.id)||v[e%v.length]:x.get(n.id)||v[e%v.length];const s=y?y(je(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:d,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=b(e);if(!o)continue;const i=De(o,f,g);let l=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)l=p(je(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===m&&n?l=x.get(n.id)||l:e&&(l=x.get(e.id)||l)}const c=p?p(je(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=c.fillOpacity)&&void 0!==a?a:u,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:t})}if(!1!==n.showLabels){const e=(S=n.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=d+12;for(const n of t){const t=n.__arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;A.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:w,labels:A}}};function De(t,e,n){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const i=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("C"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("Q"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("A"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&(i.push(Number(o[r])+e+""),r++),o.length>r&&(i.push(Number(o[r])+n+""),r++);else"Z"===t||"z"===t?(i.push(t),r++):(i.push(o[r]),r++)}return i.join(" ")}const Ne=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Fe(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>150?"#222":"#fff"}function We(t,e,n){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Be(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>{var n;return e(null!==(n=t.data)&&void 0!==n?n:t)}}return e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}}function Ie(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Ne}function Ye(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Ge(t,e,n,o,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${o} ${n},${o}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+o)/2} T ${n},${o}`}{const i=(e+o)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${o}`}}const He={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,o){var i;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),l=n.hierarchySum,c="function"==typeof l?l:"string"==typeof l?t=>Number(t[l])||0:t=>Number(t.value)||0,d=u.hierarchy(r,a);d.sum(c),d.sort((t,e)=>{var n,o;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[h,f]=o;switch(s){case"tree":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=u.tree();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=u.cluster();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(d,n,h,f);break;case"treemap":!function(t,e,n,o){var i,r;const s=null!==(i=e.padding)&&void 0!==i?i:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=u.treemap().size([n,o]).tile(u.treemapBinary).padding(s);a>0&&l.paddingTop(a),l(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,o){var i;const r=null!==(i=e.padding)&&void 0!==i?i:4;u.pack().size([n,o]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,o){var i;u.partition().size([n,o]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(d,n,h,f)}const g=d.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const o=g[e],r={id:We(o,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=o.value)&&void 0!==i?i:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?qe(r,o,n):"treemap"===s||"partition"===s?Xe(r,o):"circlepack"===s&&Ve(r,o),r.__hierarchyNode=o,t.push(r),y.set(o,r)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const n=y.get(t.parent),o=y.get(t);n&&o&&e.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,o){const i=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=[],y=[],p=[],m=n.treeOrientation||"vertical",v="radial"===m,x=o[0]/2,b=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,o=e.y;v&&(t+=x,o+=b);const r=i(je(e,"nodeStyle"));let l=r.fill||Ye(n);if(n.colorByDepth&&void 0!==e.depth){const t=Ie(n);l=t[e.depth%t.length]}const c={fill:l,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=e.x,s=e.y,a=o.x,l=o.y;v&&(i+=x,s+=b,a+=x,l+=b);const f=Ge(i,s,a,l,m),g=r(je(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=Be(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let o,i,r,s=n.x,a=n.y;if(v&&(s+=x,a+=b),v){const t=s-x,e=a-b,n=Math.sqrt(t*t+e*e);n>0?(o=s+t/n*10,i=a+e/n*10,r=0>t?"end":"start"):(o=s,i=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=s-k-6,r="end"):(o=s+k+6,r="start"),i=a):(o=s,i=a+k+14,r="middle");p.push({x:o,y:i,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,o,i,r);case"treemap":case"partition":return function(t,e,n,o){var i,r,s,a,l;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const a=o(je(n,"nodeStyle"));let l=a.fill||Ye(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ie(e);l=t[n.depth%t.length]}const u={fill:l,stroke:a.stroke||(null===(i=e.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Be(e.nodeLabel),i=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===i&&!h)continue;if("parent"===i&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=o(je(c,"nodeStyle")).fill||Ye(e);if(e.colorByDepth&&void 0!==c.depth){const t=Ie(e);g=t[c.depth%t.length]}const y="string"==typeof g?Fe(g):null!==(l=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);case"circlepack":return function(t,e,n,o){var i,r,s,a,l,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=o(je(n,"nodeStyle"));let c=l.fill||Ye(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ie(e);c=t[n.depth%t.length]}const u={fill:c,stroke:l.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Be(e.nodeLabel);for(const i of t){const t=null!==(l=i.__radius)&&void 0!==l?l:5,r=n?n(i):i.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=o(je(i,"nodeStyle")).fill||Ye(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ie(e);a=t[i.depth%t.length]}if(s){const n="string"==typeof a?Fe(a):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:i.x,y:i.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:i.x,y:i.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function qe(t,e,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=e.x,o=e.y;t.x=o*Math.cos(n-Math.PI/2),t.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Xe(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Ve(t,e){var n;const o=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function Ue(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const Ze={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,o){const i=n.__hierarchyRoot;i&&function(t,e,n,o,i){var s,a;const l=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(s=n.orbitSize)&&void 0!==s?s:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=Ue(n);y.metaMap.clear(),o.length=0,i.length=0;const p=new Map;function m(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));o.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,s,a,d,h,p){const v=l(e);if(!(null==v?void 0:v.length))return;const x=v.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const S=(x+1)/b,j={id:n,depth:h,data:e,parentId:n},M=p?d/f(j)*S:d*S,_=r.pie().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(w),O=g(j);for(let e=0;w.length>e;e++){const r=(P[e].startAngle+P[e].endAngle)/2,l=w[e],u=m(c(l)),d=s+M*Math.sin(r),f=a+M*Math.cos(r)*O;o.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:l}),y.metaMap.set(u,{ring:M,angle:r,depth:h,parentId:n,eccentricity:O}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(l,u,d,f,M,h+1,!0)}A+=k}}(t,k,v,x,b,1,!1)}(i,o,n,t,e)},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=Ue(n),o=new Map;for(const e of t)o.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;i.has(n)||i.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:o}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,l=(i+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*o,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(je(e,"nodeSize")),o=d?d(je(e,"nodeStyle")):{},c={fill:o.fill||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),n="object"==typeof t.target?t.target:m.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(je(n,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,o,i)=>!1!==n.orbitAnimated&&(function(t,e){var n,o;const i=Ue(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const o=t.angle+a*l*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(o),e.y=n.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Qe={sankey:Pe,force:$e,chord:ze,tree:He,cluster:He,treemap:He,circlepack:He,partition:He,orbit:Ze};function Ke(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=tt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function Je(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(o)%t.length])&&void 0!==n?n:"#4e79a7"}}function tn(t){const e=t.getSymbol;if(!e)return null;const n=t.config.symbolMap,o=new Map;let i=0;return t=>{const r=e(t)+"",s=null==n?void 0:n[r];if(s)return s;let a=o.get(r);return a||(a=St[i%St.length],i++,o.set(r,a)),a}}function en(t,e,n,o,i,r,s){t.push(e?{type:"symbol",x:o,y:i,size:Math.PI*r*r,symbolType:e(n),style:s,datum:n}:{type:"point",x:o,y:i,r:r,style:s,datum:n})}function nn(t,e){var n;const{columns:o,config:i,resolvePieceStyle:r}=t,s=[],a=Math.min(e.width,e.height)/2-4,l="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,u=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,d=null!=i.sweepAngle&&360>i.sweepAngle,h=Object.values(o),f=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),g=d&&!f&&h.length>1&&(null!==(n=i.cornerRadius)&&void 0!==n?n:0)>0;for(let t=0;h.length>t;t++){const e=h[t],n=e.pieceData[0],o="number"==typeof(null==n?void 0:n._pctStart)?n._pctStart:e.pctStart,d=c+o*u,f=c+(o+("number"==typeof(null==n?void 0:n._pct)?n._pct:e.pct))*u,y=r(e.pieceData[0],e.name),p=0===t,m=t===h.length-1,v=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:d,endAngle:f},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:y,datum:(null==n?void 0:n._nonInteractive)?null:e.pieceData,category:e.name});(null==n?void 0:n._roundedEnds)?v.roundedEnds=n._roundedEnds:g&&(v.roundedEnds={start:p,end:m}),(null==n?void 0:n._gradientBand)&&(v._gradientBand=n._gradientBand),s.push(v)}return s}function on(t){var e,n,o;const i=t.length,r=t[0],a=t[i-1];return{n:i,min:r,q1:null!==(e=s.quantile(t,.25))&&void 0!==e?e:r,median:null!==(n=s.quantile(t,.5))&&void 0!==n?n:(r+a)/2,q3:null!==(o=s.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/i}}const rn={bar:function(t,e){var n,o,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,y="horizontal"===h,p=a.normalize,m=[];if(c){const t=new Set;for(const e of Object.values(s))for(const n of e.pieceData){const e=c(n);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=l(n),o.pieces.push(n)}let n=0;if(p)for(const t of e.values())n+=Math.abs(t.total);let o=0,i=0;for(const r of m){const s=e.get(r);if(!s)continue;let a=s.total;p&&n>0&&(a/=n);const l=u(s.pieces[0],c?r:t.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=d(0>a?i:o+a),n=0>a?d(i+a)-d(i):d(o)-d(o+a);f.push($(t.x,e,t.width,Math.abs(n),l,h,r)),0>a?i+=a:o+=a}else if(y){const e=d(0>a?i+a:o),n=0>a?d(i)-d(i+a):d(o+a)-d(o);f.push($(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?i+=a:o+=a}}}const v="vertical"===h,x=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(n=t.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(x>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const n=(null===(i=e.datum)||void 0===i?void 0:i.category)||"";t.has(n)||t.set(n,[]),t.get(n).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,n;return(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)>=0}),n=e.filter(t=>{var e,n;return 0>(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=x),n.length>0&&(n.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=x)}}return f},clusterbar:function(t,e){const{scales:n,columns:o,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const g=h.length||1;for(const t of Object.values(o)){const e=t.width/g,n=.2*e,o=e-n,i=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),f=a(i,h[s]);if(d){const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push($(r,Math.min(a,d),o,Math.abs(a-d),f,i,h[s]))}else{const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push($(Math.min(a,d),r,Math.abs(d-a),o,f,i,h[s]))}}}}const y=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",i.gradientFill&&(t.fillGradient=i.gradientFill)}return u},point:function(t,e){var n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=t,{r:c,projection:u}=i,d=[],h="vertical"===u,f="radial"===u,g=a.length>0,y=tn(t),p=2*Math.PI,m=-Math.PI/2;for(const t of Object.values(r))for(const e of t.pieceData){const i=null!==(n=e.__rIndex)&&void 0!==n?n:0,r=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[i]||c,v=l(e,t.name),x=v.r||5;let b,k;if(f){const e=m+(t.pctStart+t.pct/2)*p,n=u(r);b=Math.cos(e)*n,k=Math.sin(e)*n}else h?(b=t.middle,k=u(r)):(b=u(r),k=t.middle);en(d,y,e,b,k,x,v)}return d},swarm:function(t,e){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a,u=tn(t);for(const t of Object.values(o)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const o=t.pieceData[n],a=i(o),d=r(o,t.name),h=d.r||4,f=(7919*n%100/100-.5)*e*.8;en(l,u,o,c?t.middle+f:s(a),c?s(a):t.middle+f,h,d)}}return l},pie:nn,donut:nn,boxplot:function(t,e){var n,o,i,r,a,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:f}=t,{r:g,projection:y}=c,p=[],m="vertical"===y,v=!1!==d.showOutliers;for(const e of Object.values(u)){const c=e.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===c.length)continue;const u=c[0],d=c[c.length-1],y=null!==(n=s.quantile(c,.25))&&void 0!==n?n:u,x=null!==(o=s.quantile(c,.5))&&void 0!==o?o:(u+d)/2,b=null!==(i=s.quantile(c,.75))&&void 0!==i?i:d,k=b-y,w=y-1.5*k,A=b+1.5*k,S=null!==(r=c.find(t=>t>=w))&&void 0!==r?r:u,j=null!==(a=[...c].reverse().find(t=>A>=t))&&void 0!==a?a:d,M=f(e.pieceData[0],e.name),_=[];if(v)for(const t of e.pieceData){const n=h(t);if(w>n||n>A){const o=m?e.middle:g(n),i=m?g(n):e.middle;_.push({px:o,py:i,value:n,datum:t})}}if(p.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(y),medianPos:g(x),q3Pos:g(b),maxPos:g(j),stats:{n:c.length,min:S,q1:y,median:x,q3:b,max:j,mean:c.reduce((t,e)=>t+e,0)/c.length},style:M,datum:e.pieceData,category:e.name,outliers:_}),v)for(const e of _)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:M.fill||(null===(l=t.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var n,o,i;const{scales:r,columns:a,config:l,getR:c,resolveSummaryStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,y=l.bins||20,p=!1!==l.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],a=e[e.length-1],l=(a-r)/y||1,h=Array(y).fill(0);for(const t of e)h[Math.min(Math.floor((t-r)/l),y-1)]++;const m=Te(h,1),v=t.width/2*.9;let x="";if(g){x=`M ${t.middle} ${d(r)}`;for(let e=0;y>e;e++){const n=d(r+(e+.5)*l);x+=` L ${t.middle+h[e]/m*v} ${n}`}x+=` L ${t.middle} ${d(a)}`;for(let e=y-1;e>=0;e--){const n=d(r+(e+.5)*l);x+=` L ${t.middle-h[e]/m*v} ${n}`}x+=" Z"}else{x=`M ${d(r)} ${t.middle}`;for(let e=0;y>e;e++)x+=` L ${d(r+(e+.5)*l)} ${t.middle-h[e]/m*v}`;x+=` L ${d(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)x+=` L ${d(r+(e+.5)*l)} ${t.middle+h[e]/m*v}`;x+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const l=null!==(n=s.quantile(e,.25))&&void 0!==n?n:r,c=null!==(o=s.quantile(e,.5))&&void 0!==o?o:(r+a)/2,u=null!==(i=s.quantile(e,.75))&&void 0!==i?i:a;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:t.middle,isVertical:g}}const w=g?{x:t.x,y:Math.min(d(a),d(r)),width:t.width,height:Math.abs(d(a)-d(r))}:{x:Math.min(d(r),d(a)),y:t.x,width:Math.abs(d(a)-d(r)),height:t.width};f.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:on(e),style:b,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l}=o,c=[],u=r.bins||25,d=r.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),f=h?+h[0]:void 0,g=h?+h[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[n,o]=Oe(e),i=null!=f&&isFinite(f)?f:n,r=null!=g&&isFinite(g)?g:o,h=(r-i)/u||1,y=Array(u).fill(0);for(const t of e)i>t||t>r||y[Math.min(Math.floor((t-i)/h),u-1)]++;const p=e.length,m=Te(y,1),v=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===y[e])continue;const n=(d?y[e]/p:y[e]/m)*t.width*.9,o=l(i+e*h),r=l(i+(e+1)*h);c.push($(Math.min(o,r),t.x+t.width-n,Math.abs(r-o),n,v,{bin:e,count:y[e],range:[i+e*h,i+(e+1)*h],category:t.name},t.name))}}return c},ridgeline:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l,projection:c}=o,u=[],d=r.bins||20,h="horizontal"===c,f=r.amplitude||1.5;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],r=(i-o)/d||1,c=Array(d).fill(0);for(const t of e)o>t||t>i||c[Math.min(Math.floor((t-o)/r),d-1)]++;const g=Te(c,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(h){const e=t.x+t.width;m=`M ${l(o)} ${e}`;for(let t=0;d>t;t++)m+=` L ${l(o+(t+.5)*r)} ${e-c[t]/g*p}`;m+=` L ${l(i)} ${e} Z`}else{const e=t.x;m=`M ${e} ${l(o)}`;for(let t=0;d>t;t++){const n=l(o+(t+.5)*r);m+=` L ${e+c[t]/g*p} ${n}`}m+=` L ${e} ${l(i)} Z`}const v=h?{x:Math.min(l(o),l(i)),y:t.x,width:Math.abs(l(i)-l(o)),height:t.width}:{x:t.x,y:Math.min(l(i),l(o)),width:t.width,height:Math.abs(l(i)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:on(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const n=i(e);if(!n)continue;const[o,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push($(n,t.x,i-n,t.width,u,e,t.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push($(t.x,n,t.width,i-n,u,e,t.name))}}return l},funnel:function(t,e){var n,i,r,s,a,l,c,u;const{columns:d,getR:h,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,v=t.scales.o.domain().map(t=>d[t]).filter(Boolean);if(0===v.length)return y;const x=[],b=new Set;for(const t of v)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),x.push(t))}const k=x.length>1&&"_default"!==x[0],w=[];let A=0;for(const t of v){const e=new Map;let n=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=h(o);i.total+=r,i.pieces.push(o),n+=r}w.push({col:t,groups:e,stepTotal:n}),k||n>A&&(A=n)}if(k)for(const t of w){let e=0,n=0;for(let o=0;x.length>o;o++){const i=t.groups.get(x[o]);i&&(o%2==0?e+=i.total:n+=i.total)}const o=Math.max(e,n);o>A&&(A=o)}if(0===A)return y;const S=new Map;for(const t of x){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const j=w[0].stepTotal,M=k?.95*p:.9*e.width,_=o.scaleLinear().domain([0,A]).range([0,M]),P=null!==(i=t.config.connectorOpacity)&&void 0!==i?i:.3;let O=new Map;for(let e=0;w.length>e;e++){const n=w[e],o=n.col,i=0===e,d=o.width,h=.55*d,f=o.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of x){const o=n.groups.get(e);o&&(t+=_(o.total))}let e=p,r=p;for(let s=0;x.length>s;s++){const l=x[s],c=n.groups.get(l);if(!c)continue;const u=_(c.total),d=s%2==0,b=d?e:r-u;d?e+=u:r-=u;const k=g(c.pieces[0],l),w=null!==(a=S.get(l))&&void 0!==a?a:c.total,A=w>0?c.total/w*100:0,j=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:A,__funnelStep:o.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});m&&(0===s&&(j.__funnelStepLabel=o.name,j.__funnelStepLabelX=p,j.__funnelStepLabelY=f,j.__funnelRowWidth=t),j.__funnelValueLabelX=b+u/2,j.__funnelValueLabelY=f,j.__funnelBarW=u),y.push($(b,f,u,h,k,j,l)),v.set(l,{x:b,y:f,w:u,h:h})}}else{const t=n.stepTotal,e=_(t),a=p-e/2,l=x[0],c="_default"!==l,u=null!==(s=null===(r=n.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],d=c?l:o.name,b=g(u,d),k=j>0?t/j*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:i,category:c?l:o.name});m&&(w.__funnelStepLabel=o.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=f,w.__funnelRowWidth=e,w.__funnelValueLabelX=p,w.__funnelValueLabelY=f,w.__funnelBarW=e),y.push($(a,f,e,h,b,w,d)),v.set(l,{x:a,y:f,w:e,h:h})}if(e>0&&O.size>0){const e=k?x:[x[0]];for(const i of e){const e=O.get(i),r=v.get(i);if(!e||!r)continue;const s=(()=>{const t=n.groups.get(i);return g(t?t.pieces[0]:o.pieceData[0],"_default"===i?o.name:i)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(l=t.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:P},datum:null!==(u=null===(c=n.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===i?o.name:i};y.push(a)}}O=v}return y},"bar-funnel":function(t,e){var n,o,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=t,d=[],h=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===h.length)return d;const f=[],g=new Set;for(const t of h)for(const e of t.pieceData){const t=l?l(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of h){const e=new Map;let n=0;for(const o of t.pieceData){const t=l?l(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=a(o);i.total+=r,i.pieces.push(o),n+=r}p.push({col:t,groups:e,stepTotal:n})}const m=new Map;for(const t of f){const e=null===(n=p[0])||void 0===n?void 0:n.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const v=u.r,x=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],n=e.col,o=0===t,s=t>0?p[t-1]:null,a=n.width/x,l=a*b,u=a-l;for(let t=0;f.length>t;t++){const h=f[t],g=e.groups.get(h);if(!g)continue;const p=g.total,x=null!==(i=m.get(h))&&void 0!==i?i:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:p,A=o?0:Math.max(0,w-p),S=n.x+t*a+l/2,j=v(p),M=v(0)-j,_=c(g.pieces[0],y?h:n.name),P=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:y?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(p+A)});if(d.push($(S,j,u,M,_,P,y?h:n.name)),A>0){const t=v(p+A),e=j-t,o=Object.assign({},_),i=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:x>0?A/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:y?h:n.name});d.push($(S,t,u,e,o,i,y?h:n.name))}}}return d},swimlane:function(t,e){var n;const{scales:o,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=o,u=[],d="horizontal"===c,h=t.config.gradientFill,f=d?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(n=g.opacity)&&void 0!==n?n:1,[o,r]=l.range(),s=Math.min(o,r),a=Math.abs(r-o);for(const n of Object.values(i)){const o={fill:t,opacity:e},i=d?$(s,n.x,a,n.width,o,null,"__track__"):$(n.x,s,n.width,a,o,null,"__track__");u.push(i)}}const y=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(i)){let e=0;const n=u.length;for(const n of t.pieceData){const o=Math.abs(r(n));if(0===o)continue;const i=s?s(n):t.name,c=a(n,i);let g;if(d){const r=l(e),s=l(e+o);g=$(r,t.x,s-r,t.width,c,n,i)}else{const r=l(e+o),s=l(e);g=$(t.x,r,t.width,s-r,c,n,i)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),e+=o}if(y>0&&u.length>n){const t=u.slice(n),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:y,tr:y,br:y,bl:y}:d?(e.cornerRadii={tl:y,bl:y},o.cornerRadii={tr:y,br:y}):(e.cornerRadii={bl:y,br:y},o.cornerRadii={tl:y,tr:y})}}return u}};class sn{constructor(t){this.rExtent=new S,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new A(t.windowSize),this.getO=z(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>E(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new S)):(this.getR=E(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=z(t.stackBy),this.getGroup=z(t.groupBy),this.getColor=z(t.colorAccessor),this.getSymbol=z(t.symbolAccessor),this.getConnector=z(t.connectorAccessor),this.getDataId=z(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new A(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const n="function"==typeof e?e(t):t[e];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(t){const{config:e,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const i=n.toArray(),r=e.projection||"vertical",s=e.oExtent||this.resolveCategories(i),a=this.computeValueDomain(i,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1));let d,h;if(c){d=o.scaleBand().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,i=e.innerRadius||0;h=o.scaleLinear().domain(a).range([i,n])}else l?(d=o.scaleBand().domain(s).range([0,t.height]).padding(u),h=o.scaleLinear().domain(a).range([0,t.width])):(d=o.scaleBand().domain(s).range([0,t.width]).padding(u),h=o.scaleLinear().domain(a).range([t.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((i,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(n,i);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=e.extentPadding)&&void 0!==s?s:.05,h=u-c,f=h>0?h*d:1;return c-=f,u+=f,c>0&&(c=0),l?o.scaleLinear().domain([c,u]).range([0,t.width]):o.scaleLinear().domain([c,u]).range([t.height,0])}):[];let f=i;this.rAccessors.length>1&&(f=i.flatMap(t=>this.rAccessors.map((e,n)=>Object.assign(Object.assign({},t),{__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(f,s,d,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(e)?e[t]:e;return"string"==typeof n?n:"value"+t}resolveCategories(t){const e=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let i=null;if(n){i=new Set;for(const e of t)i.add(this.getO(e))}const r=i?Array.from(this.categories).filter(t=>i.has(t)):Array.from(this.categories);if(n&&void 0===o){const t=Math.max(50,3*i.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;i.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var n,o,i,r,s;const a=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,n=new Map;for(const o of t){const t=this.getO(o),i=this.getR(o);0>i?n.set(t,(n.get(t)||0)+i):e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t);for(const t of n.values())c>t&&(c=t)}else if("bar"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=this.getR(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),c>t&&(c=t)}else if("swimlane"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=Math.abs(this.getR(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const t=u-c,e=t>0?t*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[c,u]}buildColumns(t,e,n,o,i){var r;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=0;if("radial"===o)for(const e of t)l+=Math.abs(this.getR(e));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let t=0;for(const n of e){const e=a.get(n)||[];let o;o="string"==typeof c?e.reduce((t,e)=>t+(Number(e[c])||0),0):c(e),u.set(n,o),t+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*e.length;if(t>0)for(const[e,n]of u)u.set(e,n/t*r)}let d=0,h=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),i=l>0?o/l:0;let c,f;u?(c=h,f=u.get(t)||n.bandwidth(),h+=f+n.padding()*n.step()):(c=null!==(r=n(t))&&void 0!==r?r:0,f=n.bandwidth()),s[t]={name:t,x:c,y:0,width:f,middle:c+f/2,padding:n.padding()*n.step(),pieceData:e,pct:i,pctStart:d},d+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){var n,o,i;if(!this.scales)return[];if(this.config.customLayout){const r=this.buildLayoutContext(t,e);let s;try{s=this.config.customLayout(r)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,[]}this.customLayoutOverlays=null!==(n=s.overlays)&&void 0!==n?n:null;const a=null!==(o=s.nodes)&&void 0!==o?o:[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of a)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(a,null!==(i=this.config.layoutSelection)&&void 0!==i?i:null)}return Ot({label:"ordinal customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const r=this.getSceneContext(),s=rn[this.config.chartType];let a=s?s(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var n,o;const{scales:i,config:r,getConnector:s,getO:a}=t;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=s(e);if(!n)continue;let o,i;"point"===t.type?(o=t.x,i=t.y):(o=t.x+t.w/2,i=t.y+("vertical"===c?0:t.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:o,y:i,datum:e,category:a(e)})}const d=i.o.domain(),h=r.connectorStyle;for(const[e,i]of u)if(i.length>=2){i.sort((t,e)=>d.indexOf(t.category)-d.indexOf(e.category));for(let r=0;i.length-1>r;r++){const s=i[r],a=i[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:e})}}return l}(r,a);a=[...t,...a]}return a}buildLayoutContext(t,e){var n,o,i,r;const s=this.config,a=null!==(n=s.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},l=Ke(s.colorScheme,s.themeCategorical,nt),c=this.scales;return{data:t,scales:{o:c.o,r:c.r,projection:c.projection},dimensions:{width:e.width,height:e.height,margin:a,plot:"radial"===c.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(o=s.themeSemantic)&&void 0!==o?o:{},categorical:[...l]},resolveColor:Je(l),config:null!==(i=s.layoutConfig)&&void 0!==i?i:{},selection:null!==(r=s.layoutSelection)&&void 0!==r?r:null}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(t,e);return n&&!n.fill&&e?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(e)}):n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||nt,o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?st(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,n="function"==typeof e,o=n?null:e||"category",i=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[o];let l=i.get(a);l||(l=[],i.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:i},i}rebuildPointQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,sn.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const n=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._pointQuadtree=i.quadtree().x(t=>t.x).y(t=>t.y).addAll(n)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var n,o;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const r=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,i),a=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(e);let u=null;for(const n of t){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const t=n.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let i=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const n=r-e;if(s>n){const t=1-n/s;t>i&&(i=t)}}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const i=r-o;s>i&&(n._pulseIntensity=1-i/s,n._pulseColor=a,n._pulseGlowRadius=l)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&n>e-o}synthesizeIntroPositions(){var t,e,n,o,i;this.prevPositionMap.clear();const r=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(n=this.scales)||void 0===n?void 0:n.projection);let l;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeKey(e,r);n&&("rect"===e.type?this.prevPositionMap.set(n,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===l&&(l=e.startAngle),this.prevPositionMap.set(n,{x:e.cx,y:e.cy,startAngle:l,endAngle:l,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var n,o,i;if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(n)||0;return e.set(n,o+1),`${n}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(i=t.category)&&void 0!==i?i:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let n=0;this.scene.length>n;n++){const o=this.scene[n],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,n,o,i,r,s,a,l,c,u,d,h,f,g,y,p,m,v,x,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let w=!1;const A=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const c=this.scene[t],u=this.getNodeKey(c,S);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(e=c.style.opacity)&&void 0!==e?e:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(i=d.w)&&void 0!==i?i:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const t=c.startAngle;c.startAngle=t,c.endAngle=t,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:t,endAngle:t,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!A.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(c=e.r)&&void 0!==c?c:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(d=e.w)&&void 0!==d?d:0,h:null!==(h=e.h)&&void 0!==h?h:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const n=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(x=e.endAngle)&&void 0!==x?x:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:ht(),duration:k})}advanceTransition(t){var e,n,o,i;if(!this.activeTransition)return!1;const r=ut(t,this.activeTransition),s=ct(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;t.style.opacity=dt(i,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=dt(o.x,t._targetX,s),t.y=dt(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=dt(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=dt(i,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=dt(n.x,t._targetX,s),t.y=dt(n.y,t._targetY,s),void 0!==n.w&&(t.w=dt(n.w,t._targetW,s),t.h=dt(n.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:dt(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const n=this.prevPositionMap.get(e);n&&void 0!==n.startAngle&&(t.startAngle=dt(n.startAngle,t._targetStartAngle,s),t.endAngle=dt(n.endAngle,t._targetEndAngle,s))}}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getDataId,o=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),i}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),i.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){var n,o;const i=this._customRestyle;if(i)for(const r of t){const t=null!==(o=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==o?o:{},s=i(r,e);r.style=s?Object.assign(Object.assign({},t),s):t}}restyleScene(t){this._customRestyle&&this.applyCustomRestyle(this.scene,t)}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!C(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!C(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!C(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(C(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=z(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const n=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,i=Array.isArray(n)?n:[n],r=Array.isArray(o)?o:[o];if(i.length!==r.length||i.some((t,e)=>!C(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>E(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new S)):(this.getR=E(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!C(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?z(this.config.stackBy):void 0),"groupBy"in t&&!C(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?z(this.config.groupBy):void 0),"colorAccessor"in t&&!C(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?z(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!C(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?z(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!C(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?z(this.config.connectorAccessor):void 0)}}sn.QUADTREE_THRESHOLD=500;const an={mercator:d.geoMercator,equalEarth:d.geoEqualEarth,albersUsa:d.geoAlbersUsa,orthographic:d.geoOrthographic,naturalEarth:d.geoNaturalEarth1,equirectangular:d.geoEquirectangular};function ln(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function cn(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function un(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function dn(t,e){if(2>t.length)return[t];const n=.4*e,o=[];let i=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>i.length||o.push(i),i=[r]):i.push(r)}return 2>i.length||o.push(i),o}function hn(t,e,n=24){const o=e[0]-t[0],i=e[1]-t[1],r=Math.sqrt(o*o+i*i);if(0===r)return[t,e];const s=-i/r,a=o/r,l=Math.min(.3*r,80),c=(t[0]+e[0])/2+s*l,u=(t[1]+e[1])/2+a*l,d=[];for(let o=0;n>=o;o++){const i=o/n,r=1-i;d.push([r*r*t[0]+2*r*i*c+i*i*e[0],r*r*t[1]+2*r*i*u+i*i*e[1]])}return d}function fn(t,e){if(2>t.length)return t;const n=e/2+1,o=[];for(let e=0;t.length>e;e++){const i=t[e];let r,s;0===e?(r=t[1][0]-i[0],s=t[1][1]-i[1]):e===t.length-1?(r=i[0]-t[e-1][0],s=i[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([i[0]+s/a*n,i[1]+-r/a*n])}return o}function gn(t,e,n,o,i){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const l=s/a,c=-r/a,u=i/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}class yn{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t.slice()}initStreaming(t=500){this.pointBuffer=new A(t),this.timestampBuffer=new A(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const n of t)this.pointBuffer.push(n),this.timestampBuffer.push(e);this.lastIngestTime=e}pushLine(t){null!=t&&"object"==typeof t&&(this.lineData.push(t),this.version++)}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return;const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){for(const t of e)this.lineData.push(t);this.version++}}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),i=[];return this.lineData=this.lineData.filter(t=>!o.has(n(t)+"")||(i.push(t),!1)),i.length>0&&this.version++,i}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(n(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&n.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)n.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(n(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return d.geoEqualEarth();if("string"==typeof t){const e=an[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),d.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=an[t.type],n=e?e():d.geoEqualEarth();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=d.geoPath(this.projection),this.fitProjection(t),this.geoPath=d.geoPath(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null};const o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,n,o,i,r;const s=this.projection,a=this.config,l=[...this.areas],c=ln(a.xAccessor,"lon"),u=ln(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const t=d.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const h=cn(a.lineDataAccessor);for(const t of this.lineData){const e=h(t);if(e&&e.length>0){const t=e.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==l.length){if(a.projectionExtent){const[[e,n],[o,i]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,n],[o,n],[o,i],[e,i],[e,n]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(n=a.fitPadding)&&void 0!==n?n:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,n=t.width*e,i=t.height*e;s.fitExtent([[n,i],[t.width-n,t.height-i]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(r=null===(i=s.rotate)||void 0===i?void 0:i.call(s))&&void 0!==r?r:[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=d.geoPath(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=d.geoPath(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;n&&n.rotate&&(n.rotate(t),this.geoPath=d.geoPath(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,n;return null!==(n=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxPointRadius=t,yn.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const n=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._quadtree=i.quadtree().x(t=>t.x).y(t=>t.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,n,o;const i=[],{config:r}=this,s=this.projection,a=this.geoPath,l=ln(r.xAccessor,"lon"),c=ln(r.yAccessor,"lat"),u=function(t){var e,n;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(n=t.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(r),h=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),f=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(r);if(r.graticule){const e=!0===r.graticule?{}:r.graticule,n=d.geoGraticule();e.step&&n.step(e.step);const o=a(n())||"";o&&i.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const n=a.centroid(t),o=a.bounds(t),s=a.area(t),l=un(r.areaStyle,t,u);i.push({type:"geoarea",pathData:e,centroid:n,bounds:o,screenArea:s,style:l,datum:t,interactive:!0})}const g=cn(r.lineDataAccessor);for(const e of this.lineData){const n=g(e);if(!n||2>n.length)continue;let o=[];if("geo"===r.lineType){const t=Array(n.length);for(let e=0;n.length>e;e++)t[e]=[l(n[e]),c(n[e])];for(let e=0;t.length-1>e;e++){const n=t[e],i=t[e+1],r=d.geoDistance(n,i)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=d.geoInterpolate(n,i);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const n=s(l(t/a));null!=n&&o.push(n)}}}else for(let t=0;n.length>t;t++){const e=n[t],i=s([l(e),c(e)]);null!=i&&o.push(i)}if(2>o.length)continue;const a=un(r.lineStyle,e,h),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==n.length||2>o.length||"arc"!==r.flowStyle?2!==n.length||2>o.length||"offset"!==r.flowStyle||(o="geo"===r.lineType?fn(o,u):gn(o[0],o[o.length-1],0,0,u)):o=hn(o[0],o[o.length-1]);const f=dn(o,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const n={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};i.push(n)}else i.push({type:"line",path:2>o.length&&f[0]||o,style:a,datum:e})}const y=this.getPoints(),p=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,v=m>0?m*Math.PI/180:null,x=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(n=b[0])&&void 0!==n?n:0)-x[0],(null!==(o=b[1])&&void 0!==o?o:0)-x[1]];for(let t=0;y.length>t;t++){const e=y[t],n=l(e),o=c(e);if(null!=v&&d.geoDistance([n,o],k)>v)continue;const a=s([n,o]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},f),h={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};i.push(h)}return i}applyCartogramTransform(t,e){var n,i,r;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(n=t.strength)&&void 0!==n?n:1;if(0===a)return;const l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=s.find(e=>e.datum&&l(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const d=u.x,h=u.y,f=Te(s.map(t=>t.datum?c(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),g=Math.min(e.width,e.height)/2,y=o.scaleLinear().domain([0,f]).range([0,g]);this.cartogramLayout={cx:d,cy:h,maxCost:f,availableRadius:g},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;if(!t.datum)continue;const e=Math.atan2(t.y-h,t.x-d),n=Math.sqrt(Math.pow(t.x-d,2)+Math.pow(t.y-h,2)),o=c(t.datum),i=n+((isFinite(o)?y(o):n)-n)*a;t.x=d+Math.cos(e)*i,t.y=h+Math.sin(e)*i}const p=e.width/2,m=e.height/2,v=p-u.x,x=m-u.y;if(Math.abs(v)>.5||Math.abs(x)>.5)for(const t of s)t.x+=v,t.y+=x;this.cartogramLayout={cx:p,cy:m,maxCost:f,availableRadius:g};const b=this.scene.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const n=null===(i=e.datum)||void 0===i?void 0:i.source,o=null===(r=e.datum)||void 0===r?void 0:r.target;if(n&&o){const i=t.get(n+""),r=t.get(o+"");i&&r&&(e.path=[i,r])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let o=0;n.length>o;o++){const i=st(t,o,e);n[o]._decayOpacity=i,n[o].style=Object.assign(Object.assign({},n[o].style),{opacity:i})}}applyPulse(){var t;const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const n=performance.now(),o=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray();for(let r=0;o.length>r&&i.length>r;r++){const s=at(e,i[r],n);s>0&&(o[r]._pulseIntensity=s,o[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",o[r]._pulseGlowRadius=null!==(t=e.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var t;return lt(null!==(t=this.config.pulse)&&void 0!==t?t:{},this.timestampBuffer)}startTransition(t){var e,n,o,i;const r=null!==(n=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==n?n:300;if(0>=r)return;const s=new Map;for(const e of t)"point"===e.type&&e.pointId&&s.set(e.pointId,[e.x,e.y]);const a=this.scene.filter(t=>"point"===t.type);let l=!1;for(const t of a)if(t.pointId){const e=s.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(l=!0))}for(const t of a)t.pointId&&!s.has(t.pointId)&&(t._targetOpacity=null!==(i=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1,t.style=Object.assign(Object.assign({},t.style),{opacity:0}),l=!0);l&&(this.activeTransition={startTime:performance.now(),duration:r})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=ut(t,this.activeTransition),n=ct(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=dt(t.x,t._targetX,n),t.y=dt(e,t._targetY,n)}null!=t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style),{opacity:t._targetOpacity*n}))}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style),{opacity:t._targetOpacity}),t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}}function pn(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function mn(t){if(!t||2>t.length)return;const e=pn(t[0]),n=pn(t[t.length-1]);return null!==e&&null!==n?[e,n]:void 0}function vn(t){var e;const{count:n,byType:o}=function(t){var e;const n={};for(const o of t){const t="string"==typeof(null==o?void 0:o.type)&&o.type.length>0?o.type:"node";n[t]=(null!==(e=n[t])&&void 0!==e?e:0)+1}return{count:t.length,byType:n}}(t.marks),i=0===n,r=[...null!==(e=t.extraWarnings)&&void 0!==e?e:[]];i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE");const s=Array.isArray(t.annotations)?t.annotations.length:0,a="string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${n} marks`;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({component:"",frameType:t.frameType,status:i?"empty":"ok",empty:i,markCount:n,markCountByType:o,width:t.width,height:t.height},t.xDomain?{xDomain:t.xDomain}:{}),t.yDomain?{yDomain:t.yDomain}:{}),t.categories?{categories:t.categories}:{}),void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{}),void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{}),void 0!==t.legendItems?{legendItems:t.legendItems}:{}),{annotationCount:s,ariaLabel:a,warnings:r})}function xn(t){var e,n,o,i;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(o=t.br)&&void 0!==o?o:0)>0||(null!==(i=t.bl)&&void 0!==i?i:0)>0}function bn(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}yn.QUADTREE_THRESHOLD=500;const kn=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function wn(t){var e,n;const{innerRadius:o,outerRadius:i,startAngle:r,endAngle:s}=t,a=0>=o;if(0>=(null!==(e=t.cornerRadius)&&void 0!==e?e:0)||!t.roundStart&&!t.roundEnd){if(a){const t=kn(i,r),e=kn(i,s);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${s-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=kn(i,r),e=kn(i,s),n=kn(o,s),l=kn(o,r),c=s-r>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${c} 1 ${e.x},${e.y} L${n.x},${n.y} A${o},${o} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=t.cornerRadius)&&void 0!==n?n:0,(i-o)/2));if(0===l)return wn(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,i-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,o+l))),d=s-r,h=t.roundStart&&t.roundEnd?d/2:d,f=!!t.roundStart&&h>c,g=!!t.roundEnd&&h>c;if(!f&&!g)return wn(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const y=r+(f?c:0),p=s-(g?c:0),m=r+(f?u:0),v=s-(g?u:0),x=kn(i,y),b=kn(i,p),k=(i-l)*Math.cos(c),w=kn(k,r),A=kn(k,s),S=a?null:kn(o,v),j=a?null:kn(o,m),M=a?0:(o+l)*Math.cos(u),_=a?null:kn(M,r),P=a?null:kn(M,s),O=p-y>Math.PI?1:0,T=a?0:v-m>Math.PI?1:0;let $="";if(f)$+=`M${w.x},${w.y}`,$+=` A${l},${l} 0 0 1 ${x.x},${x.y}`;else{const t=kn(i,r);$+=`M${t.x},${t.y}`}if(g)$+=` A${i},${i} 0 ${O} 1 ${b.x},${b.y}`,$+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const t=kn(i,s);$+=` A${i},${i} 0 ${O} 1 ${t.x},${t.y}`}if(a)$+=" L0,0";else{if(g)$+=` L${P.x},${P.y}`,$+=` A${l},${l} 0 0 1 ${S.x},${S.y}`;else{const t=kn(o,s);$+=` L${t.x},${t.y}`}if(f)$+=` A${o},${o} 0 ${T} 0 ${j.x},${j.y}`,$+=` A${l},${l} 0 0 1 ${_.x},${_.y}`;else{const t=kn(o,r);$+=` A${o},${o} 0 ${T} 0 ${t.x},${t.y}`}}return $+=" Z",$}const An={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Sn(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function jn(e,n,o){const i=jt(e.symbolType,e.size,e.path);return t.jsx("path",{d:i,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Sn(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${null!=o?o:""}symbol-${n}`)}function Mn(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function _n(e,n,o){var i,r,s,a,l;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const i="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+n)}case"area":{const l=e;if(0===l.topPath.length)return null;const c=`M${l.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...l.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(l.clipRect){const e=`${o?o+"-":""}area-clip-${n}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:l.clipRect.x,y:l.clipRect.y,width:l.clipRect.width,height:l.clipRect.height})})}),t.jsx("path",{d:c,fill:Sn(l.style.fill),fillOpacity:null!==(r=null!==(i=l.style.fillOpacity)&&void 0!==i?i:l.style.opacity)&&void 0!==r?r:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+n)}return t.jsx("path",{d:c,fill:Sn(l.style.fill),fillOpacity:null!==(a=null!==(s=l.style.fillOpacity)&&void 0!==s?s:l.style.opacity)&&void 0!==a?a:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth},"area-"+n)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Sn(o.style.fill),opacity:null!==(l=o.style.opacity)&&void 0!==l?l:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+n)}case"symbol":return jn(e,n);case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Sn(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+n)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[i,r,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+n)}case"candlestick":{const o=e,i=Math.min(o.openY,o.closeY),r=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}function Pn(e,n,o){var i,s,a,l,c,u,d,h,f;const g=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",y=t=>`ord-${e.type}-${g}-${n}-${t}`,p=`ord-${e.type}-${g}-${n}`;switch(e.type){case"rect":{const n=e,o=Mn(p)+"-grad",i=function(e,n){const o=e.fillGradient;if(!o)return null;let i=e.x,r=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,a=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,s=e.x+e.w,a=e.y);const l=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let n=0;e.length>n;n++)l.push(t.jsx("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=Sn(e.style.fill);l.push(t.jsx("stop",{offset:0,stopColor:n,stopOpacity:o.topOpacity},"0")),l.push(t.jsx("stop",{offset:1,stopColor:n,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(n,o),r=i?`url(#${o})`:Sn(n.style.fill);if(n.cornerRadii&&xn(n.cornerRadii)){const e=function(t){const{x:e,y:n,w:o,h:i}=t,{tl:r,tr:s,br:a,bl:l}=bn(t);let c=`M${e+r},${n}`;return c+=` L${e+o-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+o},${n+s}`),c+=` L${e+o},${n+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+o-a},${n+i}`),c+=` L${e+l},${n+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+i-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(n);return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("path",{d:e,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},p)}if(n.roundedTop&&n.roundedTop>0){const e=Math.min(n.roundedTop,n.w/2,n.h/2),{x:o,y:s,w:a,h:l}=n;let c;switch(n.roundedEdge){case"right":c=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+l-e} A${e},${e} 0 0 1 ${o+a-e},${s+l} L${o},${s+l} Z`;break;case"left":c=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+l-e} A${e},${e} 0 0 0 ${o+e},${s+l} L${o+a},${s+l} Z`;break;case"bottom":c=`M${o},${s} L${o+a},${s} L${o+a},${s+l-e} A${e},${e} 0 0 1 ${o+a-e},${s+l} L${o+e},${s+l} A${e},${e} 0 0 1 ${o},${s+l-e} Z`;break;default:c=`M${o},${s+l} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+l} Z`}return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("path",{d:c,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},p)}return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},p)}case"point":{const n=e;return t.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:Sn(n.style.fill),opacity:null!==(i=n.style.opacity)&&void 0!==i?i:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},p)}case"symbol":return jn(e,n,o);case"wedge":{const i=e;if(i._gradientBand&&i._gradientBand.colors.length>0){const e=Mn(`${o?o+"-":""}gauge-grad-${i.category||p}-${n}`),{clipPath:r,slices:u}=function(t){const e=wn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let i=0;o.length>i;i++)n.push({d:wn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+i*e,endAngle:t.endAngle}),color:o[i]})}return{clipPath:e,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:null===(a=null===(s=i.roundedEnds)||void 0===s?void 0:s.start)||void 0===a||a,roundEnd:null===(c=null===(l=i.roundedEnds)||void 0===l?void 0:l.end)||void 0===c||c,colors:i._gradientBand.colors});return t.jsxs("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("path",{d:r})})}),t.jsx("g",{clipPath:`url(#${e})`,children:u.map((e,n)=>t.jsx("path",{d:e.d,fill:Sn(e.color)},n))}),i.style.stroke&&"none"!==i.style.stroke&&t.jsx("path",{d:r,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},p)}let u;if(i.roundedEnds)u=wn({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const t=r.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),u=t(An)||""}return t.jsx("path",{d:u,transform:`translate(${i.cx},${i.cy})`,fill:Sn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},p)}case"boxplot":{const n=e,o=n.columnWidth/2;return t.jsxs("g","vertical"===n.projection?{children:[t.jsx("line",{x1:n.x,y1:n.minPos,x2:n.x,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:n.x-o,y:Math.min(n.q1Pos,n.q3Pos),width:n.columnWidth,height:Math.abs(n.q3Pos-n.q1Pos),fill:Sn(n.style.fill),fillOpacity:null!==(u=n.style.fillOpacity)&&void 0!==u?u:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.x-o,y1:n.medianPos,x2:n.x+o,y2:n.medianPos,stroke:n.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:n.x-.5*o,y1:n.minPos,x2:n.x+.5*o,y2:n.minPos,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.x-.5*o,y1:n.maxPos,x2:n.x+.5*o,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1})]}:{children:[t.jsx("line",{x1:n.minPos,y1:n.y,x2:n.maxPos,y2:n.y,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(n.q1Pos,n.q3Pos),y:n.y-o,width:Math.abs(n.q3Pos-n.q1Pos),height:n.columnWidth,fill:Sn(n.style.fill),fillOpacity:null!==(d=n.style.fillOpacity)&&void 0!==d?d:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.medianPos,y1:n.y-o,x2:n.medianPos,y2:n.y+o,stroke:n.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:n.minPos,y1:n.y-.5*o,x2:n.minPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.maxPos,y1:n.y-.5*o,x2:n.maxPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1})]},p)}case"violin":{const n=e,o=[t.jsx("path",{d:n.pathString,transform:n.translateX||n.translateY?`translate(${n.translateX},${n.translateY})`:void 0,fill:Sn(n.style.fill),fillOpacity:null!==(h=n.style.fillOpacity)&&void 0!==h?h:.6,stroke:n.style.stroke||"#333",strokeWidth:n.style.strokeWidth||1},y("path"))];if(n.iqrLine&&n.bounds){const e=n.bounds,i=e.x+e.width/2,r=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:i,y1:n.iqrLine.q1Pos,x2:i,y2:n.iqrLine.q3Pos,stroke:n.style.stroke||"#333",strokeWidth:2},y("iqr")),t.jsx("circle",{cx:i,cy:n.iqrLine.medianPos,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},y("med"))):o.push(t.jsx("line",{x1:n.iqrLine.q1Pos,y1:r,x2:n.iqrLine.q3Pos,y2:r,stroke:n.style.stroke||"#333",strokeWidth:2},y("iqr")),t.jsx("circle",{cx:n.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},y("med")))}return t.jsx("g",{children:o},p)}case"connector":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(f=e.style.opacity)&&void 0!==f?f:.5},p);case"trapezoid":{const n=e,o=n.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:Sn(n.style.fill,"#999"),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},p)}default:return null}}const On="undefined"==typeof window||"undefined"==typeof document;function Tn(n){let o=null;const i=()=>(o||(o=e.createContext(null)),o),r=$n(n);return[function({children:o,initialState:r}){const s=e.useRef(r),a=e.useMemo(()=>$n(n,s.current),[]),l=i();return t.jsx(l.Provider,{value:a,children:o})},(t,n)=>{var o;const s=i(),a=null!==(o=e.useContext(s))&&void 0!==o?o:r,l=e.useRef(t);l.current=t;const c=e.useRef({hasValue:!1,value:void 0}),u=e.useCallback(()=>{const t=l.current(a.getState()),e=c.current;return e.hasValue&&n&&n(e.value,t)?e.value:(c.current={hasValue:!0,value:t},t)},[a,n]),d=e.useCallback(()=>l.current(a.getState()),[a]);return e.useSyncExternalStore(a.subscribe,u,d)}]}function $n(t,e){const n=new Set;let o=Object.assign(Object.assign({},t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o=Object.assign(Object.assign({},o),e);for(const t of n)t()}})),null!=e?e:{});return{getState:()=>o,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function Ln(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function Cn(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:En})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const En=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Rn={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},zn={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Dn={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:En,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Nn(t,e){if("light"===e)return Rn;if("dark"===e)return zn;if("high-contrast"===e)return Dn;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?zn:Rn;return Cn(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return Cn(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[Fn,Wn]=Tn(t=>({theme:Rn,setTheme(e){t(t=>({theme:Nn(t.theme,e)}))}})),Bn={light:Rn,dark:zn,"high-contrast":Dn,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function In(t){if(!t)return Rn;if("string"==typeof t){if("light"===t)return Rn;if("dark"===t)return zn;if("high-contrast"===t)return Dn;return Bn[t]||Rn}const e="dark"===t.mode?zn:Rn;return Cn(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})}))}function Yn(t){var e,n,o,i;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(n=t.typography.legendSize)&&void 0!==n?n:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(i=t.typography.tickFontFamily)&&void 0!==i?i:t.typography.fontFamily}}function Gn(t){return"left"===t?"start":"right"===t?"end":null!=t?t:"start"}function Hn(t){var e,n;return Number(null!==(n=null!==(e=t.typography.legendSize)&&void 0!==e?e:t.typography.labelSize)&&void 0!==n?n:t.typography.tickSize)||11}function qn(t,e,n,o){const i=Hn(o);return e+n+Math.ceil(t.length*i*.58)}function Xn(t){var e,n,o,i,r;const{categories:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),y=Math.max(0,null!==(o=null==h?void 0:h.itemGap)&&void 0!==o?o:8),p=Math.max(f,null!==(i=null==h?void 0:h.rowHeight)&&void 0!==i?i:20),m=f+g,v=Math.min(2,f/2),x="top"===l||"bottom"===l,b=Math.max(f,c-d.left-d.right),k=Math.max(p,u-d.top-d.bottom),w=s.map(t=>qn(t,f,g,a));if(x){const t=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:b),e=[];let n=0,o=0;w.forEach((i,r)=>{const s=0===o?i:o+y+i;o>0&&s>t?(e.push({start:n,end:r,width:o}),n=r,o=i):o=s}),s.length>0&&e.push({start:n,end:s.length,width:o});const i=Gn(null==h?void 0:h.align),a=[];return e.forEach((e,n)=>{let o="center"===i?Math.max(0,(t-e.width)/2):"end"===i?Math.max(0,t-e.width):0;for(let t=e.start;e.end>t;t++)a.push({category:s[t],width:w[t],x:o,y:n*p}),o+=w[t]+y}),{items:a,width:Math.max(0,...e.map(t=>t.width)),height:e.length*p,swatchSize:f,labelOffset:m,swatchRadius:v}}const A=Math.max(0,...w),S=Math.max(1,Math.floor(k/p)),j=Math.max(1,Math.ceil(s.length/S));return{items:s.map((t,e)=>({category:t,width:w[e],x:Math.floor(e/S)*(A+y),y:e%S*p})),width:j*A+Math.max(0,j-1)*y,height:Math.min(s.length,S)*p,swatchSize:f,labelOffset:m,swatchRadius:v}}function Vn(t){var e,n,o,i,r;const{legendGroups:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),y=Math.max(0,null!==(o=null==h?void 0:h.itemGap)&&void 0!==o?o:8),p=Math.max(f,null!==(i=null==h?void 0:h.rowHeight)&&void 0!==i?i:20),m=f+g,v=Math.min(2,f/2),x=Math.max(12,Hn(a)),b="top"===l||"bottom"===l,k=Math.max(f,c-d.left-d.right),w=Math.max(p,u-d.top-d.bottom);if(b){const e=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:k),n=Gn(null==h?void 0:h.align);let o=0,i=0;const l=[];for(const n of s){const r=n.items.map(t=>t.label),s=Xn(Object.assign(Object.assign({},t),{categories:r,legendLayout:Object.assign(Object.assign({},h),{maxWidth:Math.max(f,e-x-8),align:"start"})})),c=n.label?x:0,u=n.label?qn(n.label,0,0,a):0,d=c>0?c+8:0,g=d+s.width,y=Math.max(s.height,u);l.push({group:n,x:o,y:0,itemOffsetX:d,itemOffsetY:0,width:g,height:y,items:s.items}),o+=g+12,i=Math.max(i,y)}const c=l.length>0?o-12:0,u=c>e?0:"center"===n?Math.max(0,(e-c)/2):"end"===n?Math.max(0,e-c):0;return{groups:l.map(t=>Object.assign(Object.assign({},t),{x:t.x+u})),width:c,height:i,swatchSize:f,labelOffset:m,swatchRadius:v}}let A=0,S=0;const j=[];for(const t of s){const e=t.items.map(t=>t.label).map(t=>qn(t,f,g,a)),n=Math.max(0,...e),o=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(p,w-A)/p)))),i=Math.max(1,Math.ceil(t.items.length/o)),r=t.items.map((t,i)=>({category:t.label,width:e[i],x:Math.floor(i/o)*(n+y),y:i%o*p})),s=i*n+Math.max(0,i-1)*y,l=Math.min(t.items.length,o)*p,c=t.label?qn(t.label,0,0,a):0,u=t.label?x+8:0,d=u+l+12,h=Math.max(s,c);j.push({group:t,x:0,y:A,itemOffsetX:0,itemOffsetY:u,width:h,height:d,items:r}),S=Math.max(S,h),A+=d}return{groups:j,width:S,height:Math.max(0,A),swatchSize:f,labelOffset:m,swatchRadius:v}}function Un(t){var e,n;return"top"===t.position||"bottom"===t.position?{width:Math.min(null!==(n=null===(e=t.legendLayout)||void 0===e?void 0:e.maxWidth)&&void 0!==n?n:Math.max(1,t.totalWidth-t.margin.left-t.margin.right),200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function Zn(e){const{categories:n,colorScheme:i,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=e;if(!n||0===n.length)return null;const d=function(t,e,n){const i=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:W;return o.scaleOrdinal().domain(t).range(i)}(n,i,r),h="top"===s||"bottom"===s,f=Xn(e);let g,y;if("left"===s?(g=Math.max(4,c.left-f.width-10),y=c.top):"top"===s?(g=c.left,y=u?32:8):"bottom"===s?(g=c.left,y=Math.min(l-c.bottom+38,l-f.height-2)):(g=Math.min(a-f.width-4,a-c.right+10),y=c.top),h){const e=f.items.map((e,n)=>t.jsxs("g",{transform:`translate(${e.x},${e.y})`,children:[t.jsx("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(e.category),rx:f.swatchRadius}),t.jsx("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:Hn(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e.category})]},"legend-"+n));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:e})}const p=f.items.map((e,n)=>t.jsxs("g",{transform:`translate(${e.x},${e.y})`,children:[t.jsx("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(e.category),rx:f.swatchRadius}),t.jsx("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:Hn(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e.category})]},"legend-"+n));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Qn(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=n(e);null!=t&&o.add(t+"")}return Array.from(o)}function Kn(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),r=[];let s="";for(const t of i)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function Jn(t,e,n,o){return"curly"===t?o?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function to(e,n,o,i){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,y=s?u?[s]:Kn(s,c):[],p=r?u?[r]:Kn(r,c):[],m="leftRight"===d?"end"===f?-4:4:0;let v=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?(x.push(t.jsx("foreignObject",{className:"annotation-note-html",x:"end"===f?m-c:"middle"===f?m-c/2:m,y:-16,width:c,height:Math.max(g,(y.length+p.length)*g+(s&&r?2:0))+g,style:{overflow:"visible"},children:t.jsxs("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===f?"right":"middle"===f?"center":"left",whiteSpace:u?"nowrap":"normal",wordBreak:"break-word"},children:[s&&t.jsx("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:s}),r&&t.jsx("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")),v=y.length*g):(y.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:y.map((e,n)=>t.jsx("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-title")),v=y.length*g),p.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:v,children:p.map((e,n)=>t.jsx("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-label")));let k=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===d){const e=Math.min(c,120);let n=0,o=e;"end"===f?(n=-e,o=0):"middle"===f&&(n=-e/2,o=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*g+(p.length>0?g:0);let n=0,o=e;"bottom"===h?(n=-e,o=0):"middle"===h&&(n=-e/2,o=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*g;let A=0;return"topBottom"===d?A=0>o?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+g+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>o?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function eo(e,n,o,i,r){var s;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t.jsx("circle",{r:e,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(e>0||i>0)&&a.push(t.jsx("rect",{width:e,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-e;a.push(t.jsx("line",{x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(t.jsx("line",{x1:(n.x1||0)-e,y1:i,x2:(n.x2||0)-e,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t.jsx("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&a.push(t.jsx("path",{d:Jn((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t.jsx("g",{className:"annotation-subject",children:a})}function no(e,n,o,i,r,s){var a;const l=[];let c=0,u=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,o=s.height||0;if(t>0||o>0){const i=t/2,r=o/2,s=e-i,a=n-r;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),l=t/2,d=o/2,h=e*d>n*l?l/e:d/n;c=i+s*h,u=r+a*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(c=t/2,u=n):void 0!==e&&(c=n,u=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const o=Math.atan2(n,e);c=Math.cos(o)*t,u=Math.sin(o)*t}}const d=Math.sqrt(Math.pow(e-c,2)+Math.pow(n-u,2));if(d>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",s="curve"===(null==o?void 0:o.type);let h=Math.atan2(n-u,e-c);if(s){const i=(null!==(a=null==o?void 0:o.curve)&&void 0!==a?a:.25)*d,s=(c+e)/2+-(n-u)/d*i,f=(u+n)/2+(e-c)/d*i;l.push(t.jsx("path",{className:"connector-curve",d:`M${c},${u}Q${s},${f} ${e},${n}`,fill:"none",stroke:r},"connector-line")),h=Math.atan2(f-u,s-c)}else l.push(t.jsx("line",{x1:c,y1:u,x2:e,y2:n,stroke:r},"connector-line"));if("arrow"===(null==o?void 0:o.end)){const e=10,n=16/180*Math.PI;l.push(t.jsx("path",{d:`M${c},${u}L${c+e*Math.cos(h+n)},${u+e*Math.sin(h+n)}L${c+e*Math.cos(h-n)},${u+e*Math.sin(h-n)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return t.jsx("g",{className:"annotation-connector",children:l})}function oo(e){var n,o;const{x:i=0,y:r=0,dx:s,dy:a,nx:l,ny:c,note:u,connector:d,subject:h,type:f,color:g,className:y,disable:p,opacity:m,strokeDasharray:v,events:x={},"data-testid":b}=e,k=Array.isArray(i)?null!==(n=i[0])&&void 0!==n?n:0:i,w=Array.isArray(r)?null!==(o=r[0])&&void 0!==o?o:0:r,A=new Set(Array.isArray(p)?p:[]);let S=s||0,j=a||0;null!=l&&(S=l-k),null!=c&&(j=c-w);const M="string"==typeof f?f:"label";if("bracket"===M&&h&&0===S&&0===j)if(void 0!==h.width){S=h.width/2;const t=h.depth||30;j=t+(0>t?-5:5)}else if(void 0!==h.height){const t=h.depth||30;S=t+(0>t?-5:5),j=h.height/2}return t.jsxs("g",Object.assign({className:("annotation "+(y||"")).trim(),transform:`translate(${k},${w})`,"data-testid":b},null!=m&&{opacity:m},v&&{strokeDasharray:v},x,{children:[!A.has("connector")&&no(S,j,d,g,M,h),!A.has("subject")&&eo(M,h,g,k,w),!A.has("note")&&to(u,S,j,g)]}))}function io(e){var n,o;const{noteData:i}=e,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const e=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t.jsx(oo,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return t.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return t.jsx(oo,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}const ro={secondary:0,primary:3};function so(t){return!0===(null==t?void 0:t._annotationDeferred)}function ao(t){return"blended"===(null==t?void 0:t.cohesion)||"layer"===(null==t?void 0:t.cohesion)?t.cohesion:null}function lo(t){var e;const n=null===(e=null==t?void 0:t.provenance)||void 0===e?void 0:e.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function co(t){return Math.max(.72,.95-.06*t)}function uo(e){const n=e.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:lo(t.annotation),readingOrder:null,rank:1};var n}),o=n.some(t=>null!=t.emphasis||null!=t.confidence),i=e.some(t=>so(t.annotation)),r=e.some(t=>null!=ao(t.annotation)),s=e.some(t=>"layer"===ao(t.annotation));if(!o&&!i&&!r)return e.map(t=>t.node);const a=n.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>{var n,o;return(null!==(n=e.confidence)&&void 0!==n?n:0)-(null!==(o=t.confidence)&&void 0!==o?o:0)||t.i-e.i});a.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,a.length)});for(const t of n)t.emphasis&&(t.rank=ro[t.emphasis]);const l=n.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(e=>{const{p:n,i:o,emphasis:i,readingOrder:r}=e,s=so(n.annotation);let a=n.node;if("primary"===i||"secondary"===i||null!=r){const e=null==i&&null!=r;a=t.jsx("g",Object.assign({className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i},"secondary"===i?{opacity:.6,fontSize:"0.88em"}:{},e?{opacity:co(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+o)}const l=ao(n.annotation);return l&&(a=t.jsx("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+o)),s&&(a=t.jsx("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+o)),a});return i&&l.unshift(t.jsx("style",{children:".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}"},"annotation-disclosure-style")),s&&l.unshift(t.jsx("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),l}function ho(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function fo(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function go(t){return null==t?null:t+""}function yo(t,e,n){var o;return null===(o=e.stickyPositionCache)||void 0===o||o.set(t,n),n}function po(t,e,n){var o,i;const r=t.anchor||(null===(o=t.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId)return yo(e,n,{x:i.x,y:i.y})}const o=function(t){var e,n,o,i,r,s;const a=t.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(o=t.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=t.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[t.xAccessor||"x"],h=l[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return o?yo(e,n,o):null}if("semantic"===r){const o=function(t,e,n){var o,i;const r=function(t){var e,n;return go(null!==(n=null===(e=t.provenance)||void 0===e?void 0:e.stableId)&&void 0!==n?n:t.stableId)}(t);if(!r)return null;const s=null===(o=n.pointNodes)||void 0===o?void 0:o.find(t=>go(t.pointId)===r);if(s)return yo(e,n,{x:s.x,y:s.y});const a=null===(i=n.data)||void 0===i?void 0:i.find(t=>function(t){var e,n,o;return go(null!==(n=null!==(e=t.stableId)&&void 0!==e?e:t.id)&&void 0!==n?n:null===(o=t.provenance)||void 0===o?void 0:o.stableId)}(t)===r);if(!a)return null;const l=ho(a,n),c=fo(a,n);return null==l||null==c?null:yo(e,n,{x:l,y:c})}(t,e,n);if(o)return o}let s=null,a=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,a=e.y)}if(null!=s&&null!=a||(s=ho(t,n),a=fo(t,n)),null!=s&&null!=a)return yo(e,n,{x:s,y:a});if("sticky"===r){const t=null===(i=n.stickyPositionCache)||void 0===i?void 0:i.get(e);if(t)return t}return null}function mo(t,e,n,o=50){return!(-o>t||t>(n.width||0)+o||-o>e||e>(n.height||0)+o)}const vo=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function xo(t){return!!t&&"object"==typeof t&&vo.has(function(t){return"string"==typeof(null==t?void 0:t.type)?t.type:""}(t))}function bo(t){return"primary"===(null==t?void 0:t.emphasis)||!0===(null==t?void 0:t.defensive)}function ko(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function wo(t){var e,n;let o;const i=null==t?void 0:t.emphasis;o="primary"===i?100:"secondary"===i?10:50;const r=null===(e=null==t?void 0:t.provenance)||void 0===e?void 0:e.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(o+=15*function(t){return Math.max(0,Math.min(1,t))}(r)),null===(n=null==t?void 0:t.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}new Set(["label","callout","callout-circle","callout-rect"]);const Ao=32,So=6,jo=4,Mo=8,_o=72;const Po={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Oo(t){return xo(t)}function To(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),i=[];let r="";for(const t of o)r&&r.length+t.length+1>n?(i.push(r),r=t):r=r?`${r} ${t}`:t;return r&&i.push(r),i}function $o(t,e,n,o,i){const r=t+n,s=e+o;return Math.abs(n)>Math.abs(o)?{x:0>n?r-i.width-4:r+4,y:0>o?s-i.height:s,width:i.width,height:i.height}:{x:0>n?r-i.width:r,y:0>o?s-i.height-4:s+4,width:i.width,height:i.height}}function Lo(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Co(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function Eo(t,e,n,o,i,r,s,a){const l=Lo(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,o){const i=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(i+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(n-o)))*t.width}(l,i,r,a);for(const t of n)c+=12*Co(l,t);for(const t of o)c+=4*Co(l,t);return c}function Ro(t){var e;const{annotations:n,context:o,defaultOffset:i=Ao,notePadding:r=So,markPadding:s=jo,edgePadding:a=Mo,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:u=_o,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:y,audience:p}=t,m=o.width||0,v=o.height||0;if(0===n.length||0>=m||0>=v)return n.slice();const x=[],b=function(t,e){return(t.pointNodes||[]).map(t=>{const n=Math.max(1,t.r||1)+e;return{x:t.x-n,y:t.y-n,width:2*n,height:2*n}})}(o,s);let k=!1;const w=n.map((t,e)=>{if(!Oo(t))return t;const n=function(t,e,n){var o,i;if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=null!==(o=t.pointId)&&void 0!==o?o:t.nodeId;if(null!=r&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===r);if(t)return{x:t.x,y:t.y}}const s=t.coordinates,a=null===(i=n.scales)||void 0===i?void 0:i.geoProjection;if(Array.isArray(s)&&s.length>=2&&a){const t=s[0],e=s[1];if("number"==typeof t&&"number"==typeof e){const n=a([t,e]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof t.x||"number"!=typeof t.y?po(t,e,n):{x:t.x,y:t.y}}(t,e,o);if(!n)return t;const s=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,n=[...To("string"==typeof t.title?t.title:void 0,e),...To("string"==typeof t.label?t.label:void 0,e)],o=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*n.length+6)}}(t);if(l&&("number"==typeof(d=t).dx||"number"==typeof d.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return x.push(Lo($o(n.x,n.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,s),r)),t}var d;let h=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(i)){const e=Eo($o(n.x,n.y,t.dx,t.dy,s),t,x,b,m,v,r,a);f>e&&(h=t,f=e)}if(!h)return t;const g=Lo($o(n.x,n.y,h.dx,h.dy,s),r);x.push(g);const y=Math.hypot(h.dx,h.dy),p=c&&y>=u&&"text"!==t.type&&"widget"!==t.type?Object.assign(Object.assign({},t.connector||{end:"arrow"}),{type:"curve"}):t.connector;return k=!0,Object.assign(Object.assign(Object.assign({},t),{dx:h.dx,dy:h.dy}),p?{connector:p}:{})}),A=k?w:n.slice();let S=A;if(f){let t=!1;const e=A.map(e=>{const n=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:Object.assign(Object.assign({},t),{_redundantConnector:!0})}(e);return n!==e&&(t=!0),n});S=t?e:A}{let t=!1;const e=S.map(e=>{if(!0!==(null==e?void 0:e.defensive))return e;const n=function(t){var e;const n=null==t?void 0:t.provenance;if(!n||"object"!=typeof n)return t;const o="string"==typeof n.source?null!==(e=Po[n.source])&&void 0!==e?e:n.source:null,i="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!i)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[o,i].filter(Boolean).join(" · "),s="string"==typeof t.label?t.label:"";return s.includes(`(${r})`)?t:Object.assign(Object.assign({},t),{label:s?`${s} (${r})`:`(${r})`})}(e);return n!==e&&(t=!0),n});S=t?e:S}const j=new Set;if(d){const t="object"==typeof d?d:{},n=function(t){if(!t)return 1;const e=function(t){const e=null==t?void 0:t.familiarity;if(!e)return 3;const n=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===n.length?3:n.reduce((t,e)=>t+e,0)/n.length}(t);return e>2?4>e?1:.6:1.5}(p),o=1===n?t:Object.assign(Object.assign({},t),{maxAnnotations:Math.max(0,Math.round((null!==(e=t.maxAnnotations)&&void 0!==e?e:ko(m,v,t))*n))}),{deferred:i}=function(t){var e;const{annotations:n,width:o,height:i}=t,r=Math.max(0,null!==(e=t.minVisible)&&void 0!==e?e:1),s=ko(o,i,t),a=n.map((t,e)=>{return{annotation:t,index:e,note:(n=t,xo(n))};var n}),l=a.filter(t=>t.note);if(0===l.length||s>=l.length)return{visible:n.slice(),deferred:[],budget:s};const c=l.filter(t=>bo(t.annotation)),u=l.filter(t=>!bo(t.annotation)).sort((t,e)=>wo(e.annotation)-wo(t.annotation)||t.index-e.index),d=Math.min(u.length,Math.max(Math.max(0,s-c.length),Math.max(0,r-c.length))),h=new Set([...c.map(t=>t.index),...u.slice(0,d).map(t=>t.index)]),f=[],g=[];for(const{annotation:t,index:e,note:n}of a)!n||h.has(e)?f.push(t):g.push(t);return{visible:f,deferred:g,budget:s}}(Object.assign({annotations:S,width:m,height:v},o));for(const t of i)j.add(t)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const t of S)Oo(t)&&"secondary"===t.emphasis&&j.add(t);if(j.size>0)for(const t of S)!0===(null==t?void 0:t.defensive)&&j.delete(t);let M;return M=0===j.size?S:h?S.map(t=>j.has(t)?Object.assign(Object.assign({},t),{_annotationDeferred:!0}):t):S.filter(t=>!j.has(t)),y?function(t,e){let n=!1;const o=t.map(t=>Oo(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,Object.assign(Object.assign({},t),{cohesion:e})):t);return n?o:t}(M,y):M}function zo(t,e){return t.color||e.colors.annotation||e.colors.text}function Do(t,e,n){return null!=t.x&&e.x?e.x(t.x):n&&null!=t[n]&&e.x?e.x(t[n]):"number"==typeof t.x?t.x:null}function No(t,e,n){return null!=t.y&&e.y?e.y(t.y):n&&null!=t[n]&&e.y?e.y(t[n]):"number"==typeof t.y?t.y:null}function Fo(e){const{annotations:n}=e;if(!n||0===n.length)return null;const o=e.autoPlaceAnnotations?Ro(Object.assign({annotations:n,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"}},"object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{})):n,i=[];for(let t=0;o.length>t;t++){const n=Wo(o[t],t,e);n&&i.push({node:n,annotation:o[t]})}const r=uo(i);return r.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function Wo(e,n,o){var i,r,s,a,l,c,u;const{scales:d,layout:h,theme:f,xAccessor:g,yAccessor:y}=o;switch(e.type){case"y-threshold":{const r=e.value;if(null==r)return null;const s=zo(e,f),a=e.label,l=e.labelPosition||"right",c=e.strokeDasharray||"6,4",u=null!==(i=e.strokeWidth)&&void 0!==i?i:1.5;if("horizontal"===o.projection&&d.r){const o=d.r(r);return null==o?null:t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:o,y1:0,x2:o,y2:h.height,stroke:s,strokeWidth:u,strokeDasharray:c}),a&&t.jsx("text",{x:o+4,y:12,textAnchor:"start",fontSize:f.typography.tickSize,fill:s,fontFamily:f.typography.fontFamily,children:a})]},"ann-ythresh-"+n)}const g=d.y?d.y(r):d.r?d.r(r):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:h.width,y2:g,stroke:s,strokeWidth:u,strokeDasharray:c}),a&&t.jsx("text",{x:"left"===l?4:"center"===l?h.width/2:h.width-4,y:g-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:f.typography.tickSize,fill:s,fontFamily:f.typography.fontFamily,children:a})]},"ann-ythresh-"+n)}case"x-threshold":{const o=e.value;if(null==o||!d.x)return null;const i=d.x(o);if(null==i)return null;const s=zo(e,f),a=e.label,l=e.labelPosition||"top",c=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:i,y1:0,x2:i,y2:h.height,stroke:s,strokeWidth:c,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:i>.6*h.width?i-4:i+4,y:"bottom"===l?h.height-4:"center"===l?h.height/2:12,textAnchor:i>.6*h.width?"end":"start",fontSize:f.typography.tickSize,fill:s,fontFamily:f.typography.fontFamily,stroke:f.colors.background,strokeWidth:3,paintOrder:"stroke",children:a})]},"ann-xthresh-"+n)}case"band":{const o=null!=e.y0&&d.y?d.y(e.y0):null,i=null!=e.y1&&d.y?d.y(e.y1):null;if(null==o||null==i)return null;const r=Math.min(o,i),a=Math.abs(i-o),l=e.fill||zo(e,f),c=null!==(s=e.fillOpacity)&&void 0!==s?s:.1;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("rect",{x:0,y:r,width:h.width,height:a,fill:l,fillOpacity:c}),e.label&&t.jsx("text",{x:h.width-4,y:Math.max(r,0)+13,textAnchor:"end",fontSize:f.typography.tickSize,fill:e.color||zo(e,f),fontFamily:f.typography.fontFamily,fontWeight:"bold",stroke:f.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-band-"+n)}case"category-highlight":{if(!e.category||!d.o)return null;const i=d.o(e.category);if(null==i)return null;const r=d.o.bandwidth?d.o.bandwidth():40,s=zo(e,f),l=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:i,width:h.width,height:r,fill:s,opacity:l}:{x:i,y:0,width:r,height:h.height,fill:s,opacity:l},"ann-cathighlight-"+n)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:o,y:i}=function(t,e,n,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const n=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:Do(t,e,n),y:No(t,e,o)}}(e,d,g,y);if(null==o||null==i)return null;const r="text"===e.type,s=null!==(l=e.dx)&&void 0!==l?l:r?0:30,a=null!==(c=e.dy)&&void 0!==c?c:r?0:-30,h=e.color||f.colors.text;if(!r){const r="callout"===e.type?"callout-circle":e.type,l="callout-circle"===r?{radius:null!==(u=e.radius)&&void 0!==u?u:12,radiusPadding:e.radiusPadding}:"callout-rect"===r?{width:e.width,height:e.height}:void 0;return t.jsx(io,{noteData:Object.assign(Object.assign({x:o,y:i,dx:s,dy:a,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:r},l?{subject:l}:{}),{connector:e.connector||{end:"arrow"},color:h,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className})},"ann-label-"+n)}return t.jsx("g",{children:t.jsx("text",{x:o+s,y:i+a,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||f.typography.labelSize,fill:h,fontFamily:f.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+n)}default:return null}}function Bo(t){return Math.max(0,Math.min(1,t))}function Io(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const t=[Number(n[1]),Number(n[2]),Number(n[3])];if(t.every(Number.isFinite))return t}return null}function Yo(t,e,n){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function Go(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Bo(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const o=Bo(e);if(n[0].offset>=o)return n[0].color;if(o>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],i=n[t+1];if(e.offset>o||o>i.offset)continue;const r=i.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=Io(e.color),l=Io(i.color);if(!a||!l)return.5>s?e.color:i.color;const[c,u,d]=a,[h,f,g]=l;return Yo(c+(h-c)*s,u+(f-u)*s,d+(g-d)*s)}return n[n.length-1].color}function Ho(t,e,n){return`${t}-${e}`}function qo(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function Xo(t,e,n){const o=e.incoming[t.id],i=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of i)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:n.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>{var n,o;return t.time-e.time||(null!==(n=s[t.kind])&&void 0!==n?n:99)-(null!==(o=s[e.kind])&&void 0!==o?o:99)})},l=r.length?function(t,e=1/0){let n=e;for(const e of t)n>e&&(n=e);return n}(r.map(t=>t.time)):null,c=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),h=new Map;for(let t=1;d.length>t;t++)h.set(d[t],d[t-1]);const f=t=>{const e=h.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const g=[];let y=0,p=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?y:p);if(n>0){const e="top"===t.side?"bot":"top",o=Math.min(n,"top"===e?y:p);if(o>0){const i=f(t.time);g.push({time:i,delta:-o,kind:"transfer-out",side:e}),g.push({time:i,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:p-=o,"top"===t.side?y+=o:p+=o,n-=o}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?y+=n:p+=n)}"top"===t.side?y-=e:p-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:p+=e}r.push(...g),a();let m=0,v=0,x=0,b=0,k=0;const w=[],A=new Map;for(const t of r){if(w.push({t:t.time,topMass:m,botMass:v}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:v;A.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:v+=t.delta,m+v>x&&(x=m+v),m>b&&(b=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let j=0;for(;w.length>j;){let t=j;for(;w.length>t+1&&w[t+1].t===w[j].t;)t++;S.push(w[j]);for(let e=j+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[e])}j=t+1}const M=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let _=null;for(const t of i)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===_||_>t.systemInTime)&&(_=t.systemInTime);let P=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===P||t.systemOutTime>P)&&(P=t.systemOutTime);if(S.length>0){const t=S[S.length-1],e=Math.max(null!=M?M:-1/0,null!=P?P:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&S.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=S[0],o=Math.min(null!=c?c:1/0,null!=_?_:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&S.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:S,peak:x,topPeak:b,botPeak:k,localAttachments:A}}function Vo(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Uo(t,e){return t.map(t=>({t:Vo(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Zo(t,e,n){const o=t.value*n;if("out"===t.kind){const i=t.sideMassBefore*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}const i=t.sideMassAfter*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}function Qo(t,e){let n=0;for(let o=0;e.length>o;o++)for(let i=o+1;e.length>i;i++){const r=e[o],s=e[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&n++)}return n}function Ko(t,e){let n=0;for(const o of e)n+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return n}function Jo(t,e){return 1e3*Qo(t,e)+Ko(t,e)}function ti(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function ei(t,e,n){t.length>8||n.length>40?(function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=ti(t,e),s=Jo(e,n);for(let a=0;o>a;a++){const o=Array(i).fill(0),a=Array(i).fill(0);for(const t of n){const n=e[t.source],i=e[t.target];o[n]+=i*(t.value||1),a[n]+=t.value||1,o[i]+=n*(t.value||1),a[i]+=t.value||1}const l=Array.from({length:i},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),c=l.map(e=>t[e]),u=new Map;l.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e);const d=Jo(e,n);if(s>d)s=d,r=ti(t,e);else if(d===s)break}!function(t,e,n){t.length=0;for(const e of n.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(n.map))e[t]=n.map[t]}(t,e,r)}(t,e,n,6),function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=Jo(e,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;i-1>s;s++){const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Jo(e,n);if(r>a)r=a,o=!0;else{const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,n,6)):function(t,e,n){const o=t.length;if(1>=o)return;const i=Object.assign({},e),r=Object.keys(i),s=Array.from({length:o},(t,e)=>e),a=s.slice(),l=Object.assign({},i);let c=s.slice(),u=1/0;const d=()=>{for(const t of r)l[t]=a[i[t]];const t=Jo(l,n);u>t&&(u=t,c=s.slice())},h=(t,e)=>{const n=s[t],o=s[e];s[t]=o,s[e]=n,a[n]=e,a[o]=t};d();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(e=>t[e]),p=new Map;c.forEach((t,e)=>p.set(t,e));for(const t of Object.keys(e))e[t]=p.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,n)}function ni(t,e,n,o,i){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:m,lifetimeMode:v="full"}=i,x={},b={};for(const e of t)x[e.id]=n[e.id].topPeak||0,b[e.id]=n[e.id].botPeak||0;const k="half"===v,w={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,n=Array.isArray(e.xExtent)?e.xExtent[1]:null;let i=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of o.outgoing[e.id]){i>t.startTime&&(i=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&i>t.systemInTime&&(i=t.systemInTime);const e=k?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=k?(t.startTime+t.endTime)/2:t.startTime;i>e&&(i=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}w[e.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},S=[];if("reuse"===p){const n=new Map;for(const e of t)n.set(e.id,0);const i=new Map;for(const e of t)i.set(e.id,0);for(const t of e)i.set(t.target,(null!==(r=i.get(t.target))&&void 0!==r?r:0)+1);const d=[];for(const e of t)0===(null!==(s=i.get(e.id))&&void 0!==s?s:0)&&d.push(e.id);for(;d.length;){const t=d.shift();for(const e of null!==(a=o.outgoing[t])&&void 0!==a?a:[]){const o=(null!==(l=n.get(t))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(e.target))&&void 0!==c?c:0)&&n.set(e.target,o),i.set(e.target,i.get(e.target)-1),0===i.get(e.target)&&d.push(e.target)}}const h=[...t].filter(t=>null!==w[t.id].start).sort((t,e)=>{var o,i;const r=null!==(o=n.get(t.id))&&void 0!==o?o:0,s=null!==(i=n.get(e.id))&&void 0!==i?i:0;return r!==s?r-s:w[t.id].start-w[e.id].start}),f=t.filter(t=>null===w[t.id].start);for(const t of[...h,...f]){const e=w[t.id];let n=-1;for(let t=0;S.length>t;t++){const o=S[t].occupants[S[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){n=t;break}}-1===n&&(S.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=S.length-1),S[n].occupants.push({id:t.id,end:null!==(u=null==e?void 0:e.end)&&void 0!==u?u:-1/0}),S[n].peak.topPeak=Math.max(S[n].peak.topPeak,x[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,b[t.id]),A[t.id]=n}}else t.forEach((t,e)=>{var n,o;S.push({occupants:[{id:t.id,end:null!==(o=null===(n=w[t.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:x[t.id],botPeak:b[t.id]}}),A[t.id]=e});let j=null,M=null,_=null,P=null;const O=()=>{j=Qo(A,e),_=Ko(A,e)},T=()=>{M=Qo(A,e),P=Ko(A,e)};"crossing-min"===m?(O(),ei(S,A,e),T()):"inside-out"===m?(O(),function(t,e){const n=t.length;if(1>=n)return;const o=t=>t.peak.topPeak+t.peak.botPeak,i=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let t=1;i.length>t;t++)t%2==1&&n>l||0>a?r[l++]=i[t].idx:r[a--]=i[t].idx;const c=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e)}(S,A),T()):"crossing-min+inside-out"===m&&(O(),ei(S,A,e),function(t,e,n){const o=t.length;if(1>=o)return;const i=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=Jo(e,n);for(const{slot:a}of i){const i=t.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=t[i];t.splice(i,1),t.splice(l,0,c);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(l>i){for(let t=i+1;l>=t;t++)u.set(t,t-1);u.set(i,l)}else{for(let t=l;i>t;t++)u.set(t,t+1);u.set(i,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=Jo(e,n);if(d>s){const n=t[l];t.splice(l,1),t.splice(i,0,n);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(i>l){for(let t=l+1;i>=t;t++)r.set(t,t-1);r.set(l,i)}else{for(let t=i;l>t;t++)r.set(t,t+1);r.set(l,i)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(S,A,e),T());const $=S.map(t=>{const e=new Map;for(const o of t.occupants){const t=n[o.id];if(t)for(const n of t.samples){const t=e.get(n.t)||{top:0,bot:0};e.set(n.t,{top:Math.max(t.top,n.topMass),bot:Math.max(t.bot,n.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),L=(t,e)=>{let n={top:0,bot:0};for(const[o,i]of t){if(o>e)break;n=i}return n},C=[];for(let t=0;S.length-1>t;t++){const e=$[t],n=$[t+1],o=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let i=0;for(const t of o){const o=L(e,t),r=L(n,t);o.bot+r.top>i&&(i=o.bot+r.top)}C.push(i)}const E=[];let R=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*y;S.length>0&&E.push(R);for(let t=1;S.length>t;t++)R+=C[t-1]*y+g,E.push(R);if(S.length>0&&(R+=S[S.length-1].peak.botPeak*y+g),R>f){const t=f/R;for(let e=0;E.length>e;e++)E[e]*=t}const z=0===S.length?0:S[0].peak.topPeak+C.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,D={};for(const e of t)D[e.id]=E[A[e.id]];return{effectiveSlotsHeight:z,centerlines:D,laneLifetime:w,slots:S,slotByNode:A,slotCenter:E,crossingsBefore:j,crossingsAfter:M,lengthBefore:_,lengthAfter:P}}function oi(t){const{nodes:e,edges:n,domain:i,plotW:r,plotH:s,ribbonLane:a,edgeOpacity:l,colorOf:c,layoutOpts:u}=t,d=function(t,e,n){const o=[],i=new Set(t.map(t=>t.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)i.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),i.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,n,i),h=o.scaleTime().domain(i).range([0,r]);if(d.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:d,xScale:h};const f=function(t,e,n){var o;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(t,e){const n={},o={};for(const e of t)n[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:o}}(t,e),u=function(t,e,n,o="value"){const i="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const n=new Map;for(const o of t){const t=o[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=n.get(t);i.edges.push(o),i.total+=o.value,i.earliestStart=Math.min(i.earliestStart,o.startTime),i.latestEnd=Math.max(i.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(t,n)=>"target"===e?t.earliestStart-n.earliestStart:t.latestEnd-n.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:i);return s};for(const e of t){const t=n.outgoing[e.id],o=n.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=n});else if(0===t.length)a(o,"source").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=n});else{const e=a(o,"source"),n=a(t,"target"),i=Math.max(e.length,n.length);for(let t=0;i>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=o;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,r);let d={};for(const e of t)d[e.id]=Xo(e,c,u);const h=ni(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),f=new Set;for(const t of e){const e=h.slotByNode[t.source],n=h.slotByNode[t.target];if(void 0===e||void 0===n)continue;const o=u.get(t.id);e!==n?e>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],o=new Set(t.map(t=>u.get(t.id).sourceSide)),i=new Set(n.map(t=>u.get(t.id).targetSide));if(1===o.size&&n.length>0){const t=[...o][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(u.get(e.id).targetSide=t)}if(1===i.size&&t.length>0){const e=[...i][0];for(const n of t)h.slotByNode[n.source]===h.slotByNode[n.target]&&(u.get(n.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],n=c.outgoing[e.id];if(0===t.length||0===n.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===u.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===u.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},i=(t,e)=>{const i=o(),r="top"===t?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===e?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=n.filter(e=>!f.has(e.id)&&u.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=e,!0)};let r=n.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const e of t)d[e.id]=Xo(e,c,u);const g=ni(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),y=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),p=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),m=y>0?Math.max(0,(i-p*(g.slots.length+1))/y):1,v=ni(t,e,d,c,{plotH:i,padding:p,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:p,compressedPadding:12>p,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(e,n,Object.assign({plotH:s},u)),{centerlines:g,nodeData:y,valueScale:p}=f,m=[],v=[];e.forEach((t,e)=>{var o;const r=y[t.id];if(!r||0===r.samples.length)return;const s=function(t,e,n,o,i){if(0===t.length)return null;const r=Uo(t,i),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${o(r[t].t)},${s(t)}`;l+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${o(r[t].t)},${a(t)}`;return l+" Z"}(r.samples,g[t.id],p,h,i);if(!s)return;const a=Uo(r.samples,i),l=a.find(t=>t.topMass+t.botMass>0)||a[0],u=g[t.id]+(l.botMass-l.topMass)*p/2,d=c(t.id,e),v=function(t,e,n,o,i){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=Uo(r.samples,i),c=l.find(t=>t.topMass+t.botMass>0)||l[0],u=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],d=o(c.t),h=o(u.t),f=t=>o(Vo(t,i)),g=[],y=(t,e,n,o)=>`M${t},${e} L${n},${e} L${n},${o} L${t},${o} Z`;for(const n of e){if(n.source===t&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const t=r.localAttachments.get(n.id);if(t&&"out"===t.kind&&n.startTime>n.systemInTime){const e=f(n.systemInTime),o=f(n.startTime),i=e-20,r=Math.max(d,i);if(o>r){const[n,l]=Zo(t,a,s);g.push({pathD:y(r,n,o,l),x0:i,x1:e,from:0,to:1})}}}if(n.target===t&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const t=r.localAttachments.get(n.id);if(t&&"in"===t.kind&&n.systemOutTime>n.endTime){const e=f(n.systemOutTime),o=f(n.endTime),i=e+20,r=Math.min(h,i);if(r>o){const[n,l]=Zo(t,a,s);g.push({pathD:y(o,n,r,l),x0:e,x1:i,from:1,to:0})}}}}return g}(t.id,n,f,h,i);m.push(Object.assign(Object.assign({id:t.id,pathD:s,fill:d,stroke:d,strokeWidth:.5},v.length>0&&{gradientStubs:v}),{rawDatum:null!==(o=t.__raw)&&void 0!==o?o:t,labelX:h(l.t)-4,labelY:u,labelText:t.id}))});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),n.forEach(t=>{var e,n,o,r;const s=null===(e=y[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=y[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!s||!u)return;const d=null!==(o=x.get(t.source))&&void 0!==o?o:0,f=c(t.source,d),m=function(t,e,n,o,i,r,s,a){const l=i,c=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(c(t.time)),d=r(c(n.time)),h=t.value*l,f=n.value*l,g=t.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,v,x;"top"===t.side?(p=e-g,m=p+h):(m=e+g,p=m-h),"top"===n.side?(v=o-y,x=v+f):(x=o+y,v=x-f);const b="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:v,tBot:x,cp1X:b,cp2X:b}}(s,g[t.source],u,g[t.target],p,h,a,i),{pathD:b,bezier:k}=be(m);v.push({id:t.id,pathD:b,fill:f,opacity:l,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:f,layoutConfig:{bands:m,ribbons:v,showLabels:!0},issues:[],xScale:h}}const ii=t=>{var e,n;const{bands:o=[],ribbons:i=[],showLabels:r=!0}=t.config,s=[];for(const t of i)s.push(Object.assign(Object.assign({type:"bezier",pathD:t.pathD},t.bezier&&{bezierCache:t.bezier}),{style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}}));for(const t of o)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const n=t.gradientStubs[e];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of o)s.push({type:"bezier",pathD:t.pathD,style:Object.assign(Object.assign({},t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86}),{stroke:null!==(e=t.stroke)&&void 0!==e?e:t.fill,strokeWidth:null!==(n=t.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:t.rawDatum,id:t.id}});const a=r?o.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:s,labels:a}},ri=Object.freeze([]);function si(t){if(!t)return ri;let e=!1;for(let n=0;t.length>n;n++){const o=t[n];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}function ai(t){return Array.isArray(t)?t[0]:t}function li(t,e,n,o){return Object.assign({data:ai(t),x:e,y:n,__semioticHoverData:!0},o)}const ci={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function ui(t,e){return"function"==typeof e?e(t):t[e]}function di(t,e){if(e)return e(t);if(null==t)return"";if("number"==typeof t){if(!Number.isFinite(t))return t+"";const e=Number.isInteger(t)?t:parseFloat(t.toPrecision(6));return Math.abs(e)>9999?e.toLocaleString():e+""}return t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function hi(e={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(o){const t=ui(e,o);a=di(t,i)}if(n&&n.length>0)n.forEach(t=>{let n,o,r;"string"==typeof t?(n=t,o=t,r=i):(n=t.label,o=t.accessor||t.key||"",r=t.format||i);const s=ui(e,o);l.push({label:n,value:di(s,r)})});else if(!o){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=di(e[n],i);break}if(!a){const t=Object.keys(e).filter(t=>!t.startsWith("_"));t.length>0&&(a=di(e[t[0]],i))}}const c=Object.assign(Object.assign({},ci),r);return t.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&t.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((e,n)=>t.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[e.label&&t.jsxs("span",{children:[e.label,": "]}),e.value]},n))]})}}function fi(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o+1>>1;e[i]>t?o=i-1:n=i}return e[n]}function gi(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i]?n=i+1:o=i}return e[n]}function yi({width:n,height:o,totalWidth:i,totalHeight:r,margin:s,dimension:a,scales:l,onBrush:c,binSize:u,snap:d,binBoundaries:g,snapDuring:y,streaming:p}){const m=e.useRef(null),v=e.useRef(null),x=e.useRef(c);x.current=c;const b=e.useRef(l);b.current=l;const k=e.useMemo(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=e.useRef(k);w.current=k;const A=e.useRef(!1),S=e.useRef(null);return e.useEffect(()=>{if(!m.current)return;const t=h.select(m.current).select(".brush-g"),e="x"===a?f.brushX():"y"===a?f.brushY():f.brush();return e.extent([[0,0],[n,o]]),e.on("brush end",i=>{if(A.current)return;const r=b.current;if(!r)return;if(!i.selection)return S.current=null,void x.current(null);let s,l;if("x"===a){const[t,e]=i.selection;s=[r.x.invert(t),r.x.invert(e)],l=[r.y.invert(o),r.y.invert(0)]}else if("y"===a){const[t,e]=i.selection;s=[r.x.invert(0),r.x.invert(n)],l=[r.y.invert(e),r.y.invert(t)]}else{const[[t,e],[n,o]]=i.selection;s=[r.x.invert(t),r.x.invert(n)],l=[r.y.invert(o),r.y.invert(e)]}if("bin"===d&&"y"!==a&&("end"===i.type||"brush"===i.type&&y)){const n=w.current;n&&n.length>0?s=function(t,e){return 0===e.length?t:[fi(t[0],e),gi(t[1],e)]}(s,n):u&&u>0&&(s=[Math.floor(s[0]/u)*u,Math.ceil(s[1]/u)*u]);const o=r.x(s[0]),l=r.x(s[1]);if(A.current=!0,"x"===a)t.call(e.move,[o,l]);else if("xy"===a){const n=i.selection;t.call(e.move,[[o,n[0][1]],[l,n[1][1]]])}A.current=!1}const c={x:s,y:l};S.current=c,x.current(c)}),t.call(e),v.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),v.current=null}},[n,o,a,d,u,y]),e.useEffect(()=>{if(!(p&&l&&v.current&&S.current))return;if(!m.current)return;if("y"===a)return;const t=S.current,e=l.x.domain()[0],n=h.select(m.current).select(".brush-g");if(e>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void x.current(null);let o=t.x[0],i=!1;if(e>t.x[0]){if(o=e,"bin"===d){const t=w.current;t&&t.length>0?o=gi(e,t):u&&u>0&&(o=Math.ceil(e/u)*u)}if(o>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void x.current(null);i=!0}const r=l.x(o),s=l.x(t.x[1]);if(A.current=!0,"x"===a)n.call(v.current.move,[r,s]);else{const e=l.y(t.y[1]),o=l.y(t.y[0]);n.call(v.current.move,[[r,e],[s,o]])}if(A.current=!1,i){const e={x:[o,t.x[1]],y:t.y};S.current=e,x.current(e)}},[l,p,a,d,u]),t.jsx("svg",{ref:m,width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`})})}class pi{constructor(t,e){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==e?void 0:e.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=si(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=si(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const o=t[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function mi(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:m.createElement(m.Fragment,null,...e)}const vi=m.createContext(null);function xi({value:e,children:n}){return t.jsx(vi.Provider,{value:e,children:n})}function bi(e,n){return null!=e?t.jsx(xi,{value:n,children:e}):e}function ki(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function wi(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Ai(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Si(t,e){const n=Ai(t);if(!n)return!1;const o=Ai(e);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}const ji=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Mi=new WeakMap;let _i=0,Pi=!1,Oi=null,Ti=null,$i=null;function Li(t,e){var n,o;if(!e)return e;const i=ji.exec(e);if(!i)return e;const r=t.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||e;!function(){if(Pi)return;if("undefined"==typeof window||"undefined"==typeof document)return;Pi=!0;const t=()=>{_i++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Oi=new MutationObserver(t),Oi.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Ti=window.matchMedia("(prefers-color-scheme: dark)"),$i=t,"function"==typeof Ti.addEventListener?Ti.addEventListener("change",$i):"function"==typeof Ti.addListener&&Ti.addListener($i)}catch(t){}}();let s=Mi.get(r);s&&s.version===_i||(s={version:_i,map:new Map},Mi.set(r,s));const a=s.map.get(e);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(o=i[2])||void 0===o?void 0:o.trim())||e;return s.map.set(e,l),l}function Ci(t){switch(t){case"monotoneX":return r.curveMonotoneX;case"monotoneY":return r.curveMonotoneY;case"cardinal":return r.curveCardinal;case"catmullRom":return r.curveCatmullRom;case"step":return r.curveStep;case"stepBefore":return r.curveStepBefore;case"stepAfter":return r.curveStepAfter;case"basis":return r.curveBasis;case"natural":return r.curveNatural;default:return null}}function Ei(t,e,n){return null==e?n:"string"!=typeof e?e:Li(t,e)||n}function Ri(t,e,n,o,i,r,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const a=t.createLinearGradient(o,i,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),d=t.createLinearGradient(o,i,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,o="#010203";try{t.fillStyle=o,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const i=t.fillStyle;if(t.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&e.trim().toLowerCase()!==o)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const r=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function zi(t,e,n,o,i,r){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const a=t.createLinearGradient(n,o,i,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}const Di=new WeakMap;function Ni(t,e){const n=Ci(e);if(!n)return t;const o=Di.get(t);if(o)return o;const i=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const o=[];let i=null;const s={moveTo(t,e){i=[t,e],o.push([t,e])},lineTo(t,e){i=[t,e],o.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!i)return i=[a,l],void o.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const d=i/n,h=1-d;o.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){i=[n,r],o.push([n,r])}};return r.line().x(t=>t[0]).y(t=>t[1]).curve(e).context(s)(t),o}(t,n);return Di.set(t,i),i}function Fi(t,e,n,o=30,i,r=0){let s=null;if(i){const t=function(t,e,n,o,i,r=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(o,i+5,12),c=e-l,u=e+l,d=n-l,h=n+l;let f=null,g=1/0;return t.visit((t,i,l,y,p)=>{if(i>u||c>y||l>h||d>p)return!0;if(!t.length){let i=t;do{const t=i.data,l=r(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);wi(a(t),o)>=u&&g>u&&(f=t,g=u),i=i.next}while(i)}return!1}),f?{node:f,distance:g}:null}(i,e,n,o,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(i)break;t=Bi(r,e,n,o);break;case"symbol":t=Ii(r,e,n,o);break;case"line":t=Yi(r,e,n,o);break;case"rect":if(null==r.datum)break;t=Hi(r,e,n);break;case"heatcell":t=qi(r,e,n);break;case"area":if(!1===r.interactive)break;t=Vi(r,e,n);break;case"candlestick":t=Xi(r,e,n)}t&&o>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Wi(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=Ui(t,e);if(0>o)return null;if(Math.abs(t[o][0]-e)>n)return null;let i=o,r=o;o>0&&t[o][0]>=e?(i=o-1,r=o):t.length-1>o&&(i=o,r=o+1);const[s,a]=t[i],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function Bi(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>wi(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Ii(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>wi(Mt(t.size),o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Yi(t,e,n,o=30){var i,r;if(0===t.path.length)return null;const s=Ui(t.path,e);if(0>s)return null;const[a,l]=t.path[s];let c;if(t.path.length>1){let o=1/0;const i=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=i;r>=s;s++){const[i,r]=t.path[s],[a,l]=t.path[s+1],c=Gi(e,n,i,r,a,l);o>c&&(o=c)}c=o}else{const t=e-a,o=n-l;c=Math.sqrt(t*t+o*o)}const u=t.style,d=null!==(r=null!==(i=u.strokeWidth)&&void 0!==i?i:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:a,y:l,distance:c}}function Gi(t,e,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-o,2));let c=((t-n)*s+(e-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function Hi(t,e,n){const o=ki(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function qi(t,e,n){const o=ki(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function Xi(t,e,n){const o=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,r=e-t.x,s=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function Vi(t,e,n){if(0===t.topPath.length)return null;const o=Ui(t.topPath,e);if(0>o)return null;const[i,r]=t.topPath[o],s=e-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:r,distance:l}}function Ui(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i][0]?n=i+1:o=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Zi(t,e,n){const o=t.byGroup.get(e);let i=0,r=Math.abs(o[0].x-n.x);for(let t=1;o.length>t;t++){const e=Math.abs(o[t].x-n.x);r>e&&(r=e,i=t)}return o[i]._flatIndex}function Qi(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const Ki={fresh:1,aging:.7,stale:.45,expired:.25},Ji={alpha:1,band:"fresh",isStale:!1};function tr(t,e){var n,o;if(!t||0>=e)return Ji;const i=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},o=function(t,e,n={}){var o,i,r;if(!Number.isFinite(e)||0>=e)return"fresh";if(Number.isNaN(t))return"fresh";if(t===1/0)return"expired";if(0>t)return"fresh";const s=null!==(o=n.fresh)&&void 0!==o?o:1,a=null!==(i=n.aging)&&void 0!==i?i:1.5,l=null!==(r=n.stale)&&void 0!==r?r:3;return e*s>t?"fresh":e*a>t?"aging":e*l>t?"stale":"expired"}(e,i,t.thresholds);return{alpha:Object.assign(Object.assign({},Ki),null!==(n=t.opacities)&&void 0!==n?n:{})[o],band:o,isStale:"fresh"!==o}}return e>i?{alpha:null!==(o=t.dimOpacity)&&void 0!==o?o:.5,band:"stale",isStale:!0}:Ji}function er({isStale:e,position:n}){return t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===n?{top:4,left:4}:"bottom-left"===n?{bottom:4,left:4}:"bottom-right"===n?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"}),children:e?"STALE":"LIVE"})}const nr={fill:(e,n)=>t.jsx("rect",{style:e,width:n,height:n}),line:(e,n)=>t.jsx("line",{style:e,x1:0,y1:0,x2:n,y2:n})};function or(t,e,n,o,i){let r;return r="function"==typeof n?n(t):(0,nr[n])(o(t,e),i),r}function ir({swatchSize:e}){return t.jsx("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function rr(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const sr=(e,n,o,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[];let p=0;const m=!(!n&&!o),v="isolate"===u||void 0===u&&null!=r,{swatchSize:x,labelGap:b,rowHeight:k}=d;return g.forEach((e,u)=>{const d=or(e,u,h,f,x),w=rr(e,i,r),A=r&&r.size>0&&r.has(e.label);y.push(t.jsxs("g",{transform:`translate(0,${p})`,onClick:n?()=>n(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?l===s&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&v?A||!1:void 0,"aria-current":m&&!v&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:m?t=>{var o;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+g.length)%g.length;c(l,e);const n=null===(o=t.currentTarget.parentElement)||void 0===o?void 0:o.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(l,u),o&&o(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),d,A&&t.jsx(ir,{swatchSize:x}),t.jsx("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),p+=k}),y};function ar({config:e,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:s,format:a}=e,l=a||(t=>Math.round(100*t)/100+""),c="grad-legend-"+m.useId();if("horizontal"===n){const e=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&t.jsx("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:a,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),t.jsx("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&t.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function lr(e){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical",legendLayout:h}=e,f=function(t){var e,n,o,i,r;const s=Math.max(1,null!==(e=null==t?void 0:t.swatchSize)&&void 0!==e?e:16),a=Math.max(s,null!==(n=null==t?void 0:t.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(o=null==t?void 0:t.labelGap)&&void 0!==o?o:6),itemGap:Math.max(0,null!==(i=null==t?void 0:t.itemGap)&&void 0!==i?i:10),rowHeight:a,align:"left"===(null==t?void 0:t.align)?"start":"right"===(null==t?void 0:t.align)?"end":null!==(r=null==t?void 0:t.align)&&void 0!==r?r:"start",maxWidth:null==t?void 0:t.maxWidth}}(h),[g,y]=m.useState(0),[p,v]=m.useState(0),x=m.useCallback((t,e)=>{y(t),v(e)},[]),b="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return e.forEach((e,g)=>{h+=5,f.push(t.jsx("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,e.label&&(h+=16,f.push(t.jsx("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+g)),h+=8),f.push(t.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:sr(e,o,i,r,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:x,legendInteraction:a,metrics:f}):(({legendGroups:e,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d,metrics:h})=>{var f;let g=0;const y=[];e.forEach((e,n)=>{var f;let p=0;e.label&&(p+=16);const m=((e,n,o,i,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=e,p=[],{swatchSize:m,labelGap:v,itemGap:x,rowHeight:b,align:k}=d,w=!(!n&&!o),A="isolate"===u||void 0===u&&null!=r,S=y.map(t=>m+v+7*t.label.length),j=[];let M=0,_=0;S.forEach((t,e)=>{const n=0===_?t:_+x+t;h&&h>0&&_>0&&n>h?(j.push({start:M,end:e,width:_}),M=e,_=t):_=n}),y.length>0&&j.push({start:M,end:y.length,width:_}),j.forEach((e,u)=>{let d="center"===k?Math.max(0,((null!=h?h:e.width)-e.width)/2):"end"===k?Math.max(0,(null!=h?h:e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=y[h],k=or(e,h,f,g,m),j=rr(e,i,r),M=r&&r.size>0&&r.has(e.label);p.push(t.jsxs("g",{transform:`translate(${d},${u*b})`,onClick:n?()=>n(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:w?l===s&&h===a?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&A?M||!1:void 0,"aria-current":w&&!A&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:w?t=>{var o;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(h+("ArrowRight"===t.key?1:-1)+y.length)%y.length;c(l,e);const n=null===(o=t.currentTarget.parentElement)||void 0===o?void 0:o.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:w?t=>{c(l,h),o&&o(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:w?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:j,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+v+2+7*e.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,M&&t.jsx(ir,{swatchSize:m}),t.jsx("text",{y:m/2,x:m+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),d+=S[h]+x}});const P=Math.max(0,...j.map(t=>t.width)),O=j.length;return{items:p,offset:P,totalRows:O,totalHeight:O*b}})(e,i,r,s,a,l,c,n,u,d,h,null!==(f=h.maxWidth)&&void 0!==f?f:o);p+=m.offset+5,y.push(Object.assign(Object.assign({label:e.label},m),{offset:p,totalRows:m.totalRows,totalHeight:m.totalHeight})),g+=p+12});const p=null!==(f=h.maxWidth)&&void 0!==f?f:o;let m=g>p?0:"center"===h.align?Math.max(0,(p-g)/2):"end"===h.align?Math.max(0,p-g):0;const v=[];return y.forEach((o,i)=>{const r=e[i];r.label&&(v.push(t.jsx("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+i)),m+=16),v.push(t.jsx("g",{className:"legend-item",transform:`translate(${m},0)`,children:o.items},"legend-group-"+i)),m+=o.offset+5,e[i+1]&&v.push(t.jsx("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+i)),m+=12}),t.jsx("g",{children:v})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:x,legendInteraction:a,metrics:f}),k=!(!o&&!i);return t.jsxs("g",{role:k?"listbox":void 0,"aria-multiselectable":!(!k||"isolate"!==a&&(void 0!==a||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===d&&t.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),b]})}function cr(e){var n;const{legend:o,totalWidth:i,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=e;if(!o)return null;const y="top"===a||"bottom"===a,p=!!c,m=Math.max(1,y?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,i-s.left-s.right):100);let v,x;return"left"===a?(v=Math.max(4,s.left-m-10),x=s.top):"top"===a?(v=s.left,x=p?32:8):"bottom"===a?(v=s.left,x=r-s.bottom+38):(v=i-s.right+10,x=s.top),t.jsx("g",{transform:`translate(${v}, ${x})`,children:w(o)?t.jsx(ar,{config:o.gradient,orientation:y?"horizontal":"vertical",width:m}):k(o)?t.jsx(lr,{legendGroups:o.legendGroups,title:"",width:m,orientation:y?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}function ur(t){return"string"==typeof t?{type:t}:t}function dr({orient:n,config:o,values:i,scale:r,size:a,length:l}){const c=function(t){var e,n,o,i,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=t.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=t.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(o),u="top"===n||"bottom"===n,d=e.useMemo(()=>{if(0===i.length)return null;const e=r.domain(),o=a-8;if("boxplot"===c.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const o=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(e[0],o-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(i);if(!e)return null;const{q1:s,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*o,20),g=(o-f)/2+4;if(u){const e=r(s),o=r(l),i=r(a),u=r(d),y=r(h),p="top"===n?-1:1,m=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:m+p*(g+f/2),x2:y,y2:m+p*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:m+p*g,x2:u,y2:m+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:y,y1:m+p*g,x2:y,y2:m+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,o),y:"top"===n?m-g-f:m+g,width:Math.abs(o-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:i,y1:"top"===n?m-g-f:m+g,x2:i,y2:"top"===n?m-g:m+g+f,stroke:c.fill,strokeWidth:2})]})}{const e=r(s),o=r(l),i=r(a),u=r(d),y=r(h),p="left"===n?-1:1,m=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:m+p*(g+f/2),y1:u,x2:m+p*(g+f/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:m+p*g,y1:u,x2:m+p*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:m+p*g,y1:y,x2:m+p*(g+f),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?m-g-f:m+g,y:Math.min(e,o),width:f,height:Math.abs(o-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?m-g-f:m+g,y1:i,x2:"left"===n?m-g:m+g+f,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=s.bin().domain(e).thresholds(c.bins)(i);if(0===d.length)return null;const h=Te(d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*o;if(u){const o=r(e.x0),a=r(e.x1)-r(e.x0);return t.jsx("rect",{x:o,y:"top"===n?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const o=r(e.x0),a=r(e.x1)-r(e.x0);return t.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(o,o+a),width:s,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=o/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(o/2),a=r((t.x0+t.x1)/2);i.push(u?`${a},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${a}`)}for(let t=d.length-1;t>=0;t--){const s=d[t];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(o/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,i=null!=d[0].x0?r(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*o,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-i-4:i+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?r(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*o,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;e.push(`L${t},${s}`),e.push("Z")}return t.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:t.jsx("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,r,c,a,l,n,u,4]);return d?t.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}const hr={linear:r.curveLinear,monotoneX:r.curveMonotoneX,monotoneY:r.curveMonotoneY,step:r.curveStep,stepAfter:r.curveStepAfter,stepBefore:r.curveStepBefore,basis:r.curveBasis,cardinal:r.curveCardinal,catmullRom:r.curveCatmullRom};let fr={positions:new Map};const gr=new Set;function yr(){for(const t of gr)t()}function pr(t,e){const n=fr.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const o=new Map(fr.positions);o.delete(t),fr={positions:o},yr()}function mr(t,e){const n=fr.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const o=new Map(fr.positions);o.delete(t),fr={positions:o},yr()}function vr(){return fr}function xr(t){return gr.add(t),()=>gr.delete(t)}const br={positions:new Map};function kr(){return()=>{}}function wr(){return br}function Ar(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),o=n[0],i=n[n.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,a=i instanceof Date?i.getTime():i;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function Sr(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function jr(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Mr(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const o of t)e>o.pixel&&(e=o.pixel),o.pixel>n&&(n=o.pixel);return{min:e,max:n}}function _r(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Pr(t,e,n){if("left"===t||"right"===t){const o="left"===t?n:0,i="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+o;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${o+4*i}`,s+=`L${Math.min(n,e)},${o}`}return s}{const o="bottom"===t?0:e,i="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${o+4*i},${Math.min(8*t+4,n)}`,s+=`L${o},${Math.min(e,n)}`}return s}}function Or(n){const{width:o,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f,axisExtent:g}=n,y=e.useMemo(()=>{var t,e;if(!l)return[];const n=null==u?void 0:u.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||h||Tr,r=Math.max(2,Math.floor(o/70)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(l.x,"exact"===g?Math.max(2,s):Math.min(s,r),g),c=a.map(t=>t.valueOf()),d=a.map((t,e)=>({value:t,pixel:l.x(t),label:i(t,e,c)})),f=d.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return $r(d,Math.max(55,f+8))},[l,u,h,o,g]),p=e.useMemo(()=>{var t,e;if(!l)return[];const n=null==u?void 0:u.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||f||Tr,r=Math.max(2,Math.floor(i/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return $r((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(l.y,"exact"===g?Math.max(2,s):Math.min(s,r),g)).map(t=>({value:t,pixel:l.y(t),label:o(t)})),22)},[l,u,f,i,g]),m=d&&l,v=c&&l;if(!m&&!v)return null;const x=null==u?void 0:u.find(t=>"bottom"===t.orient),b=null==u?void 0:u.find(t=>"left"===t.orient),k=v&&(!x||!1!==x.baseline),w=v&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,S=(null==b?void 0:b.jaggedBase)||!1,j="var(--semiotic-border, #ccc)";return t.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:t.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[m&&(()=>{var e,n;const r=_r(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=_r(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[y.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),p.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t.jsx("line",{x1:0,y1:i,x2:o,y2:i,stroke:j,strokeWidth:1}),A&&t.jsx("path",{d:Pr("bottom",o,i),fill:"none",stroke:j,strokeWidth:1}),w&&!S&&t.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:j,strokeWidth:1}),S&&t.jsx("path",{d:Pr("left",o,i),fill:"none",stroke:j,strokeWidth:1})]})})}function Tr(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function $r(t,e){if(2>=t.length)return t;const n=[t[0]];for(let o=1;t.length-1>o;o++)e>Math.abs(t[o].pixel-n[n.length-1].pixel)||n.push(t[o]);const o=t[t.length-1];return e>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Lr(n){var o,i;const{width:s,height:a,totalWidth:l,totalHeight:c,margin:d,scales:h,showAxes:f,axes:g,xLabel:y,yLabel:p,yLabelRight:v,xFormat:b,yFormat:k,axisExtent:w,showGrid:A,title:S,legend:j,legendHoverBehavior:M,legendClickBehavior:_,legendHighlightedCategory:P,legendIsolatedCategories:O,legendPosition:T="right",legendLayout:$,foregroundGraphics:L,marginalGraphics:C,xValues:E,yValues:R,annotations:z,autoPlaceAnnotations:D,svgAnnotationRules:N,xAccessor:F,yAccessor:W,annotationData:B,pointNodes:I,curve:Y,underlayRendered:G,canvasObscuresUnderlay:H=!0,linkedCrosshairName:q,linkedCrosshairSourceId:X,children:V}=n,U=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||b||Tr,i=Math.max(2,Math.floor(s/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(h.x,"exact"===w?Math.max(2,r):Math.min(r,i),w),l=a.map(t=>t.valueOf()),c=a.map((t,e)=>({value:t,pixel:h.x(t),label:o(t,e,l)})),u=c.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),d=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(u+8,55)):Math.max(55,u+8);let y=$r(c,d);if(y.length>1&&(y=y.filter((t,e)=>0===e||t.label+""!=y[e-1].label+"")),(null==n?void 0:n.includeMax)&&y.length>0&&"exact"!==w&&!(null==n?void 0:n.tickValues)){const t=h.x.domain()[1],e=h.x(t),n=y[y.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t,y.length,l);d>e-n&&y.length>1&&(y=y.slice(0,-1)),y.push({value:t,pixel:e,label:i})}}return y},[f,h,g,b,s,w]),Z=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||k||Tr,i=Math.max(2,Math.floor(a/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=$r((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Ar(h.y,"exact"===w?Math.max(2,r):Math.min(r,i),w)).map(t=>({value:t,pixel:h.y(t),label:o(t)})),22);if(s.length>1&&(s=s.filter((t,e)=>0===e||t.label+""!=s[e-1].label+"")),(null==n?void 0:n.includeMax)&&s.length>0&&"exact"!==w&&!(null==n?void 0:n.tickValues)){const t=h.y.domain()[1],e=h.y(t),n=s[s.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:i})}}return s},[f,h,g,k,a,w]),Q=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"right"===t.orient);if(!n)return[];const o=n.tickFormat||k||Tr,i=Math.max(2,Math.floor(a/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return $r((null!==(e=n.tickValues)&&void 0!==e?e:Ar(h.y,"exact"===w?Math.max(2,r):Math.min(r,i),w)).map(t=>({value:t,pixel:h.y(t),label:o(t)})),22)},[f,h,g,k,a,w]),K=e.useRef(new Map),J=e.useRef(null!==(o=null==z?void 0:z.length)&&void 0!==o?o:0),tt=null!==(i=null==z?void 0:z.length)&&void 0!==i?i:0;J.current!==tt&&(J.current=tt,K.current=new Map);const et=e.useMemo(()=>{if(!z||0===z.length)return null;const e=function(e,n,o){var i,s,a,l,c,d,h,f,g,y,p,v,b,k,w,A,S,j,M,_,P,O,T,$,L,C,E,R,z,D,N,F,W,B,I,Y,G,H,q,X,V,U,Z,Q,K,J,tt,et,nt,ot,it;switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const r=po(e,n,o);if(!r)return null;const{x:l,y:c}=r;if(!mo(l,c,o))return null;const u="callout"===e.type?"callout-circle":e.type,d="callout-circle"===u?{radius:null!==(i=e.radius)&&void 0!==i?i:12,radiusPadding:e.radiusPadding}:"callout-rect"===u?{width:e.width,height:e.height}:void 0;return t.jsx(io,{noteData:Object.assign(Object.assign({x:l,y:c,dx:null!==(s=e.dx)&&void 0!==s?s:30,dy:null!==(a=e.dy)&&void 0!==a?a:-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:u},d?{subject:d}:{}),{connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className})},"ann-"+n)}case"x-threshold":{const i=ho(null!=e.value?Object.assign(Object.assign({},e),{x:e.value}):e,o);if(null==i)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let a;a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12;const l=i>.6*(o.width||0),c=l?i-4:i+4,u=l?"end":"start";return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:c,y:a,textAnchor:u,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"y-threshold":{const i=fo(null!=e.value?Object.assign(Object.assign({},e),{y:e.value}):e,o);if(null==i)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(o.width||0)/2,l="middle"):(a=(o.width||0)-4,l="end"),t.jsxs("g",{opacity:e.opacity,children:[t.jsx("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"enclose":{const i=(e.coordinates||[]).map(t=>({x:ho(Object.assign(Object.assign({},t),{type:"point"}),o),y:fo(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=u.packEnclose(i),s=e.padding||10;return t.jsxs("g",{children:[t.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"rect-enclose":{const i=(e.coordinates||[]).map(t=>({x:ho(Object.assign(Object.assign({},t),{type:"point"}),o),y:fo(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=e.padding||10,s=i.map(t=>t.x),a=i.map(t=>t.y),[l,c]=Oe(s),[u,d]=Oe(a),h=l-r,f=c+r,g=u-r;return t.jsxs("g",{children:[t.jsx("rect",{x:h,y:g,width:f-h,height:d+r-g,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:(h+f)/2,y:g-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const i=o.data||[],r="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,i)=>{const r=ho(n,o),a=fo(n,o);if(null==r||null==a)return null;const l="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||s;return t.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+n)}case"bracket":{const i=ho(e,o),r=fo(e,o);return t.jsx(io,{noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a="ordinal"===o.frameType,u="horizontal"===o.projection,p=a?r:null,m=a?s:null;let v;const b=[],k=new Map;if(a&&p&&m){for(const t of i){const e=t[p];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,b.length),b.push(n))}v=i.map(t=>{const e=t[p],n=t[m];if(null==e||null==n)return null;const o=k.get(e+"");return null!=o?[o,+n]:null}).filter(t=>null!==t)}else v=i.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>v.length)return null;const w=null!==(c=null===(l=o.scales)||void 0===l?void 0:l.x)&&void 0!==c?c:null===(d=o.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value;if(!w||!A)return null;const S=t=>e=>{const n=Math.max(0,Math.floor(e)),o=Math.min(b.length-1,n+1),i=e-n,r=t(b[n]);return r+(t(b[o])-r)*i},j=w,M=A;let _;if(a)if(u){const t=S(M);_=(e,n)=>[j(n),t(e)]}else{const t=S(j);_=(e,n)=>[t(e),M(n)]}else _=(t,e)=>[j(t),M(e)];const P=e.method||"linear";let O;O="loess"===P?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const o=t.slice().sort((t,e)=>t[0]-e[0]),i=o.map(t=>t[0]),r=o.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=i[t],o=i.map(t=>Math.abs(t-e)),l=o.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:o[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*i[t],h+=e*r[t],f+=e*i[t]*i[t],g+=e*i[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([e,h/u]);else{const t=(u*g-d*h)/y;a.push([e,(h-t*d)/u+t*e])}}return a}(v,null!==(y=e.bandwidth)&&void 0!==y?y:.3):("polynomial"===P?x.default.polynomial(v,{order:e.order||2}):x.default.linear(v)).points;const T=O.map(([t,e])=>{const[n,o]=_(t,e);return`${n},${o}`}).join(" "),$=e.color||"#6366f1",L=O[O.length-1],[C,E]=_(L[0],L[1]);return t.jsxs("g",{children:[t.jsx("polyline",{points:T,fill:"none",stroke:$,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:C+4,y:E-4,fill:$,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const i=null!==(v=null===(p=o.scales)||void 0===p?void 0:p.y)&&void 0!==v?v:null===(b=o.scales)||void 0===b?void 0:b.value,r=null!==(k=null==i?void 0:i(e.y0))&&void 0!==k?k:0,s=null!==(w=null==i?void 0:i(e.y1))&&void 0!==w?w:o.height||0;return t.jsxs("g",{opacity:e.opacity,children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(o.width||0)-4,y:Math.max(Math.min(r,s),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+n)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const s=o.xAccessor||"x",a=null!==(S=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==S?S:null===(j=o.scales)||void 0===j?void 0:j.time,l=null!==(_=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==_?_:null===(P=o.scales)||void 0===P?void 0:P.value;if(!a||!l)return null;const c=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=i.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[s]-e[s]);if(2>h.length)return null;const f=hr[o.curve||"linear"]||r.curveLinear,g=r.area().x(t=>a(t[s])).y0(t=>l(t[u])).y1(t=>l(t[c])).curve(f)(h);if(!g)return null;const y=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:g,fill:y,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:a(h[h.length-1][s])+4,y:l(h[h.length-1][c])-4,fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==($=null===(T=o.scales)||void 0===T?void 0:T.x)&&void 0!==$?$:null===(L=o.scales)||void 0===L?void 0:L.time,a=null!==(E=null===(C=o.scales)||void 0===C?void 0:C.y)&&void 0!==E?E:null===(R=o.scales)||void 0===R?void 0:R.value;if(!s||!a)return null;const l=i.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const c=l.reduce((t,e)=>t+e,0)/l.length,u=l.reduce((t,e)=>t+Math.pow(e-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(z=e.threshold)&&void 0!==z?z:2,f=c-h*d,g=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(D=e.fillOpacity)&&void 0!==D?D:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,x=a(c+h*d),b=a(f),k=i.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[g&&t.jsx("rect",{x:0,y:Math.min(x,b),width:o.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,n)=>{const i=ho(e,o),r=fo(e,o);return null==i||null==r?null:t.jsx("circle",{cx:i,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(o.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(W=null===(F=o.scales)||void 0===F?void 0:F.x)&&void 0!==W?W:null===(B=o.scales)||void 0===B?void 0:B.time,l=null!==(Y=null===(I=o.scales)||void 0===I?void 0:I.y)&&void 0!==Y?Y:null===(G=o.scales)||void 0===G?void 0:G.value;if(!a||!l)return null;const c=i.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=x.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const t=c.length;let e=0,n=0,o=0,i=0;for(const[t,r]of c)e+=t,n+=r,o+=t*t,i+=t*r;const r=t*o-e*e;if(1e-12>Math.abs(r))return null;const s=(t*i-e*n)/r,a=(n-s*e)/t;u=t=>a+s*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),g=c.reduce((t,e)=>t+e[0],0)/d,y=c.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),p=null!==(H=e.confidence)&&void 0!==H?H:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(q=e.steps)&&void 0!==q?q:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;v>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=u(t),n=f*Math.sqrt(1+1/d+(y>0?Math.pow(t-g,2)/y:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,j=A.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),M=`${a(b)},${l(u(b))}`,_=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(X=e.fillOpacity)&&void 0!==X?X:.15,stroke:"none"}),t.jsx("polyline",{points:`${M} ${j}`,fill:"none",stroke:_,strokeWidth:null!==(V=e.strokeWidth)&&void 0!==V?V:2,strokeDasharray:null!==(U=e.strokeDasharray)&&void 0!==U?U:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let i=null,r=null;if(null!=e.px&&null!=e.py)i=e.px,r=e.py;else{const t=po(e,n,o);if(!t)return null;i=t.x,r=t.y}if(null==i||null==r)return null;if(!mo(i,r,o))return null;const s=null!==(Z=e.dx)&&void 0!==Z?Z:0,a=null!==(Q=e.dy)&&void 0!==Q?Q:0,l=null!==(K=e.width)&&void 0!==K?K:32,c=null!==(J=e.height)&&void 0!==J?J:32,u=null!==(tt=e.content)&&void 0!==tt?tt:t.jsx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return t.jsx("foreignObject",{x:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const i=po(e,n,o);if(!i)return null;const{x:r,y:s}=i,a=r+(e.dx||0),l=s+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",u=t.jsx("text",{x:a,y:l,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?m.cloneElement(u,{key:"ann-text-"+n}):t.jsxs("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[t.jsx("line",{x1:r,y1:s,x2:a,y2:l,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),m.cloneElement(u,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const i=e.category;if(null==i)return null;const r=t=>"function"==typeof t&&"function"==typeof t.bandwidth,s=null===(et=o.scales)||void 0===et?void 0:et.o,a=null===(nt=o.scales)||void 0===nt?void 0:nt.x,l=null===(ot=o.scales)||void 0===ot?void 0:ot.y,c=r(s)?s:r(a)?a:r(l)?l:null;if(!c)return null;const u=c(i+"");if(null==u)return null;const d=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",f=null!==(it=e.opacity)&&void 0!==it?it:.15,g=e.label;return t.jsxs("g",(o.projection?"vertical"===o.projection:c===a)?{children:[t.jsx("rect",{x:u,y:0,width:d,height:o.height||0,fill:h,fillOpacity:f}),g&&t.jsx("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]}:{children:[t.jsx("rect",{x:0,y:u,width:o.width||0,height:d,fill:h,fillOpacity:f}),g&&t.jsx("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:F,yAccessor:W,width:s,height:a,data:B,frameType:"xy",pointNodes:I,curve:Y,stickyPositionCache:K.current};return function(t,e,n,o){const i=[];return t.forEach((t,r)=>{let s;if(n){const i=n(t,r,o);s=null!=i?i:e(t,r,o)}else s=e(t,r,o);s&&i.push({node:s,annotation:t})}),uo(i)}(D?Ro(Object.assign({annotations:z,context:n},"object"==typeof D?D:{})):z,e,N,n)},[z,D,N,s,a,F,W,B,h,I,Y]),nt=function(t){var n;const o=e.useSyncExternalStore(t?xr:kr,t?vr:wr,t?vr:wr);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}(q);return e.useEffect(()=>{if(!(null==nt?void 0:nt.locked)||!q)return;const t=t=>{"Escape"===t.key&&mr(q)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==nt?void 0:nt.locked,q]),f||S||j||L||C||et&&et.length>0||A||V||nt?t.jsxs("svg",{role:"img",width:l,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof S?S:"XY Chart"}),t.jsx("desc",{children:"string"==typeof S?S+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[A&&h&&(!G||H)&&(()=>{var e,n;const o=_r(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),i=_r(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[U.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:a,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),Z.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:s,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),o=!e||!1!==e.baseline,i=!n||!1!==n.baseline,r=(null==e?void 0:e.jaggedBase)||!1,l=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&U.length>1&&(()=>{const t=s/Math.max(U.length-1,1);return U.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),b={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},w={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=null==n?void 0:n.tickAnchor,S=null==e?void 0:e.tickAnchor,j=Mr(U),M=Mr(Z);return t.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[t.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!G||H)&&i&&!l&&t.jsx("line",{x1:0,y1:a,x2:s,y2:a,stroke:h,strokeWidth:1}),(!G||H)&&l&&t.jsx("path",{d:Pr("bottom",s,a),fill:"none",stroke:h,strokeWidth:1}),U.map((e,n)=>{const o=!!c&&("function"==typeof c?c(e.value,n):Si(e.value,n>0?U[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${a})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:x?10:18,textAnchor:x?"end":Sr(A,e.pixel===j.min,e.pixel===j.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?k:b),transform:x?"rotate(-45)":void 0,children:e.label}):t.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:Object.assign({textAlign:"center",userSelect:"none"},b),children:e.label})})]},"xtick-"+n)}),y&&t.jsx("text",{x:s/2,y:a+40,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:y})]}),t.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!G||H)&&o&&!r&&t.jsx("line",{x1:0,y1:0,x2:0,y2:a,stroke:h,strokeWidth:1}),(!G||H)&&r&&t.jsx("path",{d:Pr("left",s,a),fill:"none",stroke:h,strokeWidth:1}),Z.map((e,n)=>{const o=!!u&&("function"==typeof u?u(e.value,n):Si(e.value,n>0?Z[n-1].value:void 0));return t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:jr(S,e.pixel===M.min,e.pixel===M.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?k:b),children:e.label}):t.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:Object.assign({textAlign:"right",userSelect:"none"},b),children:e.label})})]},"ytick-"+n)}),(()=>{const n=(null==e?void 0:e.label)||p;return n?t.jsx("text",{x:15-d.left,y:a/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-d.left}, ${a/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:n}):null})()]}),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===Q.length)return null;const n=!1!==e.baseline,o=e.landmarkTicks,i=e.label||v,r=e.tickAnchor,l=Mr(Q);return t.jsxs("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[n&&t.jsx("line",{x1:s,y1:0,x2:s,y2:a,stroke:h,strokeWidth:1}),Q.map((e,n)=>{const i=!!o&&("function"==typeof o?o(e.value,n):Si(e.value,n>0?Q[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${s},${e.pixel})`,children:[t.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:8,textAnchor:"start",dominantBaseline:jr(r,e.pixel===l.min,e.pixel===l.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?k:b),children:e.label}):t.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:Object.assign({textAlign:"left",userSelect:"none"},b),children:e.label})})]},"ytick-r-"+n)}),i&&t.jsx("text",{x:s+d.right-15,y:a/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${s+d.right-15}, ${a/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:i})]})})()]})})(),et,C&&h&&E&&R&&t.jsxs(t.Fragment,{children:[C.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(dr,{orient:"top",config:ur(C.top),values:E,scale:h.x,size:d.top,length:s})}),C.bottom&&t.jsx("g",{transform:`translate(0, ${a})`,children:t.jsx(dr,{orient:"bottom",config:ur(C.bottom),values:E,scale:h.x,size:d.bottom,length:s})}),C.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(dr,{orient:"left",config:ur(C.left),values:R,scale:h.y,size:d.left,length:a})}),C.right&&t.jsx("g",{transform:`translate(${s}, 0)`,children:t.jsx(dr,{orient:"right",config:ur(C.right),values:R,scale:h.y,size:d.right,length:a})})]}),L,nt&&nt.sourceId!==X&&(null==h?void 0:h.x)&&(()=>{const e=h.x(nt.xValue);if(null==e||0>e||e>s)return null;const n=nt.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:a,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),V]}),S&&t.jsx("text",{x:l/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof S?S:null}),cr({legend:j,totalWidth:l,totalHeight:c,margin:d,legendPosition:T,title:S,legendLayout:$,legendHoverBehavior:M,legendClickBehavior:_,legendHighlightedCategory:P,legendIsolatedCategories:O})]}):null}const Cr="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Er=()=>()=>{},Rr=()=>!1,zr=()=>!0;function Dr(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;if(!Object.is(t[o],e[o]))return!1}return!0}function Nr(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function Fr(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const Wr=m.createContext(null),Br={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ir(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===(null==e?void 0:e.datum))continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),o=r.indexOf(e);return(-1===n?999:n)-(-1===o?999:o)});for(const t of s)o.push(`${n[t]} ${i[t]||t}`);return`${e}, ${o.join(", ")}`}const Yr=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""};function Gr(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,o]of Object.entries(t))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(e[n]=o):"string"==typeof o?e[n]=o:"boolean"==typeof o?e[n]=o+"":o instanceof Date&&(e[n]=o.toISOString().slice(0,10)));return e}const Hr="semiotic-accessible-data-table",qr=Hr+" semiotic-accessible-data-table-hidden",Xr=Hr+" semiotic-accessible-data-table-visible",Vr={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ur={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Zr={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Qr={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Kr={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Jr={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},ts={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},es={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function ns({scene:e,chartType:n,tableId:o,chartTitle:i}){var r;const[s,a]=m.useState(!1),[l,c]=m.useState(5),u=m.useContext(Wr),d=null!==(r=null==u?void 0:u.visible)&&void 0!==r&&r,h=s||d,f=m.useRef(null),g=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n;m.useEffect(()=>{h||c(5)},[h]);const y=m.useCallback(t=>{t.target===t.currentTarget&&(s||d||a(!0))},[s,d]),p=m.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!1)},[d]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:Br}):null;if(!h)return t.jsx("div",{id:o,className:qr,tabIndex:-1,onFocus:y,style:Br,role:"region","aria-label":g,children:t.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," elements)"]})});const v=function(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g,y,p,m;const v=[];if(!Array.isArray(t))return v;const x=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const b of t)if(b&&"object"==typeof b&&null!==b.datum)try{switch(b.type){case"point":if(x)break;v.push({label:"Point",values:Gr(b.datum)});break;case"line":case"area":{const t=Array.isArray(b.datum)?b.datum:[],e="line"===b.type?"Line point":"Area point";for(const n of t)v.push({label:e,values:Gr(n)});break}case"rect":{const t=null!=b.datum&&"object"==typeof b.datum?b.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:b.group)&&void 0!==n?n:"",s=null!==(i=null!==(o=t.value)&&void 0!==o?o:t.__aggregateValue)&&void 0!==i?i:t.total;v.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":{const t=Gr(b.datum);null==t.value&&"number"==typeof b.value&&Number.isFinite(b.value)&&(t.value=b.value),v.push({label:"Cell",values:t});break}case"wedge":v.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=b.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=b.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=b.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":v.push({label:"Node",values:Gr(b.datum)});break;case"arc":v.push({label:"Arc",values:Gr(b.datum)});break;case"candlestick":v.push({label:"Candlestick",values:Gr(b.datum)});break;case"geoarea":v.push({label:"Region",values:{name:null!==(y=null!==(f=null===(h=null===(d=b.datum)||void 0===d?void 0:d.properties)||void 0===h?void 0:h.name)&&void 0!==f?f:null===(g=b.datum)||void 0===g?void 0:g.name)&&void 0!==y?y:"",value:null!==(m=null===(p=b.datum)||void 0===p?void 0:p.value)&&void 0!==m?m:""}})}}catch(t){}return v}(e),x=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const o of e){const e=[],i=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[o];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&i.add(t+""))}if(e.length>0){let t=e[0],i=e[0],r=0;for(const n of e)t>n&&(t=n),n>i&&(i=n),r+=n;n.push({name:o,count:e.length,numeric:!0,min:t,max:i,mean:r/e.length})}else if(i.size>0){const t=Array.from(i);n.push({name:o,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(v),b=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Yr(t.min)} to ${Yr(t.max)}, mean ${Yr(t.mean)}.`);else{const e=t.uniqueValues,o=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${o}.`)}return n.join(" ")}(v.length,x),k=Math.min(l,v.length),w=v.slice(0,k),A=v.length-k,S=new Set;for(const t of w)for(const e of Object.keys(t.values))S.add(e);const j=Array.from(S);return t.jsxs("div",{ref:f,id:o,className:Xr,tabIndex:-1,onBlur:p,style:Vr,role:"region","aria-label":g,children:[t.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&u&&u.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Zr,children:"×"}),t.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ur,children:b}),t.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+n,style:Qr,children:[t.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:ts,children:A>0?`First ${k} of ${v.length} data points`:`All ${v.length} data points`}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:Kr,children:"type"}),j.map(e=>t.jsx("th",{style:Kr,children:e},e))]})}),t.jsx("tbody",{children:w.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Jr,children:e.label}),j.map(n=>{return t.jsx("td",{style:Jr,children:(o=e.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Yr(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]}),A>0&&t.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(t=>t+25),style:es,children:["Show ",Math.min(25,A)," more"," ",1===A?"row":"rows"," (",A," remaining)"]})]})}function os({summary:e}){return e?t.jsx("div",{role:"note",style:Br,children:e}):null}function is({tableId:e}){return t.jsx("a",{href:"#"+e,style:Br,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Br)},children:"Skip to data table"})}function rs({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Data point: "+t}return t.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:Br,children:n})}const ss="var(--semiotic-focus, #005fcc)";function as({active:e,hoverPoint:n,margin:o,size:i,shape:r="circle",width:s,height:a}){if(!e||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=s&&null!=a){const e=Math.max(s,4),n=Math.max(a,4);u=t.jsx("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:ss,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:ss,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ss,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function ls({x:e,y:n,containerWidth:o,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(e)&&Number.isFinite(n),u=m.useRef(null),[d,h]=m.useState(null);m.useLayoutEffect(()=>{const t=u.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,a,o,i]);let f;f=d?`translate(${d.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const g=function(t){if(!m.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(s),y=g?null:ci;return c?t.jsx("div",{ref:u,className:g?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:r.left+e,top:r.top+n,transform:f,pointerEvents:"none",zIndex:l,width:"max-content"}),children:s}):null}const cs="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function us(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function ds(t){const n=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>n(t.matches))},[]),t}(),o=e.useRef(n);o.current=n;const[i,r]=function(t,n,o){const i=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const t=i.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,o]),[i,[n&&r?r.w:t[0],o&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),s=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),a=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,c=us(t.foregroundGraphics,r,s),u=us(t.backgroundGraphics,r,s),d=Wn(t=>t.theme),{transition:h,introEnabled:f}=function(t,e){var n,o;if(!1===t)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(o=t.duration)&&void 0!==o?o:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(i||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),g="semiotic-table-"+m.useId(),y=e.useRef(0),p=e.useRef(()=>{}),v=e.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>p.current()))},[]);e.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),A=e.useCallback(()=>{w.current=0;const t=k.current;k.current=null,t&&x.current(t)},[]),S=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),j=e.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),b.current()},[]);e.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const M=t.themeDirtyRef;return cs(()=>{M&&(_i++,M.current=!0,v())},[d,v,M]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:y,renderFnRef:p,scheduleRender:v,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:S,onPointerLeave:j}}function hs(t,e,n,o){const i=t.getContext("2d");if(!i)return null;const r=e[0]*o,s=e[1]*o,a=e[0]+"px",l=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==l&&(t.style.height=l),t.width===r&&t.height===s||(t.width=r,t.height=s),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function fs(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}function gs(t,e,n,o,i,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],o=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=o,t.lineCap=r;for(let n=0;e.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const ys=(t,e,n,o)=>{var i,s;const a=e.filter(t=>"line"===t.type);for(const l of a){if(2>l.path.length)continue;const c=l._introClipFraction;void 0!==c&&1>c&&(t.save(),t.beginPath(),t.rect(0,0,o.width*c,o.height),t.clip());const u=l.style.stroke||"#007bff",d=Li(t,u)||u,h=l.style.strokeWidth||2,f=l.colorThresholds,g=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=h,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const v=null!==(i=l.style.opacity)&&void 0!==i?i:1;gs(t,l.path,d,h,v,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const y=Ci(l.curve),p=f&&f.length>0&&g&&g.length===l.path.length,m=l._decayOpacities;if(m&&m.length===l.path.length&&!p){t.strokeStyle=d;const x=null!==(s=l.style.opacity)&&void 0!==s?s:1;for(let b=0;l.path.length-1>b;b++)t.globalAlpha=.5*(m[b]+m[b+1])*x,t.beginPath(),t.moveTo(l.path[b][0],l.path[b][1]),t.lineTo(l.path[b+1][0],l.path[b+1][1]),t.stroke()}else if(p){let k=null,w=null,A=null,S=null,j=!1;function M(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),j=!0}function _(){j&&(t.stroke(),j=!1)}for(let P=0;l.path.length>P;P++){const[O,T]=l.path[P],$=g[P],L=fs($,f,d);if(null!==k&&null!==S&&null!==A){if(L===S)t.lineTo(O,T);else{const C=[];for(const E of f){const R=E.value;(A>R||R>$)&&(R>A||$>R)||A===R||$===R||C.push({t:(R-A)/($-A)})}C.sort((t,e)=>t.t-e.t);for(const z of C){const D=k+(O-k)*z.t,N=w+(T-w)*z.t,F=fs(A+($-A)*Math.min(z.t+1e-4,1),f,d);t.lineTo(D,N),_(),M(F,D,N)}t.lineTo(O,T)}k=O,w=T,A=$,S=L}else M(L,O,T),k=O,w=T,A=$,S=L}_()}else{t.beginPath();const W=l.strokeGradient&&l.path.length>=2?zi(t,l.strokeGradient,l.path[0][0],0,l.path[l.path.length-1][0],0):null;if(t.strokeStyle=W||d,y)r.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[B,I]=l.path[0];t.moveTo(B,I);for(let Y=1;l.path.length>Y;Y++)t.lineTo(l.path[Y][0],l.path[Y][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=Ei(t,l.style.fill,l.style.fill),y&&!p)r.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[H,q]=l.path[0];t.moveTo(H,q);for(let X=1;l.path.length>X;X++)t.lineTo(l.path[X][0],l.path[X][1])}const G=l.path[0][0];t.lineTo(l.path[l.path.length-1][0],o.height),t.lineTo(G,o.height),t.closePath(),t.fill()}void 0!==c&&1>c&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ps(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ms(t,e,n=.3){ps(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function vs(t,e,n=.6){var o,i,r,s,a;if(!ps(e))return;const l=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,c=e.r+l*e._pulseIntensity,u=null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function xs(t,e,n,o=.35){ps(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function bs(t,e){const n=Ci(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const o=r.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),o(e.topPath)}}const ks=(t,e,n,o)=>{var i,s,a;const l=e.filter(t=>"area"===t.type);for(const e of l){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const l=e._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,o.width*l,o.height),t.clip());const c=Ei(t,e.style.fill,"#4e79a7"),u=e._decayOpacities;if(u&&u.length===e.topPath.length){const n=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.fillStyle=c;for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(u[o]+u[o+1])*n,t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.lineTo(e.bottomPath[o+1][0],e.bottomPath[o+1][1]),t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(u[n]+u[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const d=null!==(s=e.style.opacity)&&void 0!==s?s:1;if(bs(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=Ri(t,e.fillGradient,"string"==typeof c?c:"#4e79a7",0,n,0,o);t.fillStyle=i||c,t.globalAlpha=d}else{const n=null!==(a=e.style.fillOpacity)&&void 0!==a?a:.7;t.globalAlpha=n*d,t.fillStyle=c}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(bs(t,e),xs(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=d;const n=e.strokeGradient&&e.topPath.length>=2?zi(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=Ci(e.curve);if(t.beginPath(),o)r.line().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==l&&1>l&&t.restore(),n&&t.restore(),t.globalAlpha=1}},ws=(t,e,n,o)=>{var i,r;const s=e.filter(t=>"point"===t.type);if(0!==s.length){t.save();try{const e=t.globalAlpha;for(const n of s){t.beginPath(),t.arc(n.x,n.y,n.r,0,2*Math.PI);const o=null!==(r=null!==(i=n.style.opacity)&&void 0!==i?i:n.style.fillOpacity)&&void 0!==r?r:1;t.globalAlpha=e*o,t.fillStyle=Ei(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=Ei(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),vs(t,n)}}finally{t.restore()}}},As=new Map;function Ss(t){var e;try{if(t.path)return new Path2D(t.path);const n=`${null!==(e=t.symbolType)&&void 0!==e?e:"circle"}:${Math.round(t.size)}`;let o=As.get(n);return o||(o=new Path2D(jt(t.symbolType,t.size)),As.size>256&&As.clear(),As.set(n,o)),o}catch(t){return null}}const js=(t,e)=>{var n,o,i,r;const s=t.globalAlpha;for(const a of e){if("symbol"!==a.type)continue;const e=a;if(0>=e.size)continue;const l=Ss(e);if(!l)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const c=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*(null!==(o=e._decayOpacity)&&void 0!==o?o:1);e.style.fill&&(t.globalAlpha=s*c*(null!==(i=e.style.fillOpacity)&&void 0!==i?i:1),t.fillStyle=Ei(t,e.style.fill,"#4e79a7"),t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=s*c,t.strokeStyle=Ei(t,e.style.stroke,e.style.stroke),t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.stroke(l)),t.restore()}t.globalAlpha=s};function Ms(t,e){const{x:n,y:o,w:i,h:r}=e,{tl:s,tr:a,br:l,bl:c}=bn(e);t.beginPath(),t.moveTo(n+s,o),t.lineTo(n+i-a,o),a>0&&t.arcTo(n+i,o,n+i,o+a,a),t.lineTo(n+i,o+r-l),l>0&&t.arcTo(n+i,o+r,n+i-l,o+r,l),t.lineTo(n+c,o+r),c>0&&t.arcTo(n,o+r,n,o+r-c,c),t.lineTo(n,o+s),s>0&&t.arcTo(n,o,n+s,o,s),t.closePath()}function _s(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const Ps=(t,e,n,o)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Os(t,e);else if(e.cornerRadii&&xn(e.cornerRadii)){const n=Ei(t,e.style.fill,Li(t,"var(--semiotic-primary, #007bff)")),o=_s(e),i=e.fillGradient&&"string"==typeof n?Ri(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,Ms(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=Ei(t,e.style.fill,Li(t,"var(--semiotic-primary, #007bff)")),o=_s(e),i=e.fillGradient&&"string"==typeof n?Ri(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+c-r),t.arcTo(s,a+c,s+r,a+c,r),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s+r,a+c),t.arcTo(s,a+c,s,a+c-r,r);break;default:t.moveTo(s,a+c),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=Ei(t,e.style.fill,Li(t,"var(--semiotic-primary, #007bff)")),o=_s(e),i=e.fillGradient&&"string"==typeof n?Ri(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Li(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ms(t,e),t.globalAlpha=1}};function Os(t,e){const n=e.style.icon,o=e.style.iconPadding||2,i=Math.min(e.w,e.h)-o;if(0>=i)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=i+o,s=e.x+(e.w-i)/2;for(let o=e.y+e.h-i;o>=e.y-i;o-=r)t.drawImage(n,s,o,i,i)}else{const r=i+o,s=e.y+(e.h-i)/2;for(let o=e.x;e.x+e.w>o;o+=r)t.drawImage(n,o,s,i,i)}t.restore()}function Ts(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>128?"#000":"#fff"}function $s(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Ls=(t,e,n,o)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Li(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ms(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):$s(e.value),o=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=Ts(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,r)}}}finally{t.restore()}},Cs=(t,e,n,o)=>{var i,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const a=(null!==(i=e._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(t.globalAlpha=a);const l=Li(t,e.wickColor)||e.wickColor,c=60>o.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=l,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*o.height));t.fillStyle=l,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor,r=Li(t,i)||i;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1))}c&&d(),t.restore()}};function Es(t,e,n,o){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:{key:void 0,fn:null}}const Rs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function zs(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Rs[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Rs[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Ds={line:[ks,ys,ws],area:[ks,ws],stackedarea:[ks,ws],scatter:[ws,js],bubble:[ws,js],heatmap:[Ls],bar:[Ps],swarm:[ws],waterfall:[(t,e,n,o)=>{var i;Ps(t,e);const r=e.filter(t=>"rect"===t.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){t.save(),t.strokeStyle=Li(t,a)||a,t.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const o=r[e],i=r[e+1],s=o.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=o.x+o.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[Cs],mixed:[ks,ys,ws],custom:[ks,Ps,Ls,ys,ws,js,Cs]},Ns={top:20,right:20,bottom:30,left:40},Fs={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function Ws(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],o=n[2],i=n[3];return`#${t}${t}${o}${o}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const Bs={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Is({hover:e}){var n,o,i;const r=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",s=null!==(n=e.data)&&void 0!==n?n:{},a=null!==(o=s.y)&&void 0!==o?o:s.value,l=null!==(i=s.x)&&void 0!==i?i:s.time;return t.jsxs("div",{className:"semiotic-tooltip",style:Bs,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(a)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:r(l)})]})}Is.ownsChrome=!0;const Ys=e.forwardRef(function(n,o){var i,r,s,a,l,c,u,d,h,f,g,y,p;const{chartType:v,runtimeMode:x,data:b,chunkThreshold:k,chunkSize:w,xAccessor:A,yAccessor:S,colorAccessor:j,sizeAccessor:M,symbolAccessor:_,symbolMap:P,groupAccessor:O,lineDataAccessor:T,curve:$,normalize:L,baseline:C,stackOrder:E,binSize:R,valueAccessor:z,arrowOfTime:D="right",windowMode:N="sliding",windowSize:F=200,timeAccessor:W,xExtent:B,yExtent:I,extentPadding:Y=.1,scalePadding:G,sizeRange:H,size:q=[500,300],responsiveWidth:X,responsiveHeight:V,margin:U,className:Z,background:Q,lineStyle:K,pointStyle:J,areaStyle:tt,barStyle:et,waterfallStyle:nt,swarmStyle:ot,barColors:it,colorScheme:rt,boundsAccessor:st,boundsStyle:at,y0Accessor:lt,band:ct,gradientFill:ut,lineGradient:dt,areaGroups:ht,openAccessor:ft,highAccessor:gt,lowAccessor:yt,closeAccessor:pt,candlestickStyle:mt,showAxes:vt=!0,axes:bt,xLabel:kt,yLabel:wt,yLabelRight:At,xFormat:St,yFormat:jt,axisExtent:Mt,tickFormatTime:_t,tickFormatValue:Pt,hoverAnnotation:Ot,tooltipContent:Tt,customHoverBehavior:$t,customClickBehavior:Lt,enableHover:Ct,hoverRadius:Rt=30,tooltipMode:zt,annotations:Dt,autoPlaceAnnotations:Nt,svgAnnotationRules:Ft,showGrid:Wt,legend:Bt,legendHoverBehavior:It,legendClickBehavior:Yt,legendHighlightedCategory:Gt,legendIsolatedCategories:Ht,legendPosition:qt,legendLayout:Xt,legendCategoryAccessor:Vt,onCategoriesChange:Ut,backgroundGraphics:Zt,foregroundGraphics:Qt,canvasPreRenderers:Kt,svgPreRenderers:Jt,title:te,categoryAccessor:ee,brush:ne,onBrush:oe,decay:ie,pulse:re,transition:se,animate:ae,staleness:le,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,marginalGraphics:ge,pointIdAccessor:ye,xScaleType:pe,yScaleType:me,accessibleTable:ve=!0,description:xe,summary:be,linkedCrosshairName:ke,linkedCrosshairSourceId:we,customLayout:Ae,layoutConfig:Se,layoutSelection:je}=n,Me=e.useId().replace(/:/g,""),_e=e.useRef(!1),Pe=e.useRef({w:-1,h:-1}),Oe=ds({sizeProp:q,responsiveWidth:X,responsiveHeight:V,userMargin:U,marginDefault:Ns,animate:ae,transitionProp:se,themeDirtyRef:_e}),Te=function(){const[t,n]=e.useState(!1);return Cr(()=>{n(!0)},[]),t}(),$e=function(){const t=e.useSyncExternalStore(Er,Rr,zr);return e.useRef(t).current}(),{reducedMotionRef:Le,responsiveRef:Ce,size:Ee,currentTheme:Re,transition:ze,introEnabled:De,tableId:Ne,rafRef:Fe,renderFnRef:We,scheduleRender:Be}=Oe;let Ie=Oe.margin;if(ge){const t=60,e=Object.assign({},Oe.margin);ge.top&&t>e.top&&(e.top=t),ge.bottom&&t>e.bottom&&(e.bottom=t),ge.left&&t>e.left&&(e.left=t),ge.right&&t>e.right&&(e.right=t),Ie=e}const Ye="function"==typeof Qt?Qt({size:Ee,margin:Ie}):Qt,Ge="function"==typeof Zt?Zt({size:Ee,margin:Ie}):Zt,He=Ee[0]-Ie.left-Ie.right,qe=Ee[1]-Ie.top-Ie.bottom,Xe=e.useMemo(()=>si(b),[b]),Ve=null!=Ot?Ot:Ct,Ue=e.useRef(null),Ze=e.useRef(null),[Qe,Ke]=e.useState(0),Je=e.useRef(0),[tn,en]=e.useState(null),nn=e.useRef(null),on=e.useRef(null),[rn,sn]=e.useState(null),an=e.useRef(Fs.primary),ln=e.useRef([]),cn=e.useRef(Vt),un=e.useRef(Ut);cn.current=Vt,un.current=Ut;const[dn,hn]=e.useState(!1),[fn,gn]=e.useState([]),[yn,pn]=e.useState([]),mn="streaming"===x||["bar","swarm","waterfall"].includes(v),vn=e.useMemo(()=>{var t,e,n;return{chartType:v,runtimeMode:mn?"streaming":"bounded",windowSize:F,windowMode:N,arrowOfTime:mn?D:"right",extentPadding:Y,scalePadding:G,axisExtent:Mt,xAccessor:A,yAccessor:S,timeAccessor:mn?W:void 0,valueAccessor:z,colorAccessor:j,sizeAccessor:M,symbolAccessor:_,symbolMap:P,groupAccessor:O||(T?"_lineGroup":void 0),categoryAccessor:ee,lineDataAccessor:T,xScaleType:pe,yScaleType:me,xExtent:B,yExtent:I,sizeRange:H,binSize:R,normalize:L,baseline:C,stackOrder:E,boundsAccessor:st,boundsStyle:at,y0Accessor:lt,band:ct,gradientFill:!0===ut?{topOpacity:.8,bottomOpacity:.05}:!1===ut?void 0:ut,areaGroups:ht?new Set(ht):void 0,lineGradient:dt,openAccessor:ft,highAccessor:gt,lowAccessor:yt,closeAccessor:pt,candlestickStyle:mt,lineStyle:K,pointStyle:J,areaStyle:tt,swarmStyle:ot,waterfallStyle:nt,colorScheme:rt,barColors:it,barStyle:et,annotations:Dt,decay:ie,pulse:re,transition:ze,introAnimation:De,staleness:le,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,pointIdAccessor:ye,curve:$,themeCategorical:null===(t=null==Re?void 0:Re.colors)||void 0===t?void 0:t.categorical,themeSemantic:Ln(Re),themeSequential:null===(e=null==Re?void 0:Re.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Re?void 0:Re.colors)||void 0===n?void 0:n.diverging,customLayout:Ae,layoutConfig:Se,layoutMargin:Ie}},[v,F,N,D,Y,G,Mt,A,S,W,z,pe,me,j,M,_,P,O,ee,T,B,I,H,R,L,C,E,st,at,lt,ct,ut,dt,ht,ft,gt,yt,pt,mt,K,J,tt,ot,nt,et,rt,it,Dt,ie,re,null==ze?void 0:ze.duration,null==ze?void 0:ze.easing,De,le,ce,ue,de,he,fe,mn,ye,$,Re,Ae,Se,Ie]),xn=function(t){const n=e.useRef(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return Nr(t,e);if(!Fr(t)||!Fr(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;const n=t[o],i=e[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!Nr(n,i))return!1}else{if(!Fr(n)||!Fr(i))return!1;if(!Dr(n,i))return!1}}return!0}(n.current,t)||(n.current=t),n.current}(vn),bn=e.useRef(null);bn.current||(bn.current=new Et(xn));const kn=e.useCallback(()=>{var t,e;const n=cn.current,o=un.current;if(!o||!n)return;const i=function(t,e){if(!e)return[];const n=new Set,o=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),o.push(r))}return o}(null!==(e=null===(t=bn.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(i,ln.current)||(ln.current=i,o(i))},[]);e.useEffect(()=>{var t;null===(t=bn.current)||void 0===t||t.updateConfig(xn),_e.current=!0,Be()},[xn,Be]);const wn=e.useRef(null);e.useEffect(()=>{const t=bn.current;if(!t)return;const e=null!=je?je:null;wn.current!==e&&(wn.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):_e.current=!0,Be())},[je,Be]);const An=e.useRef(null);An.current||(An.current=new pi(t=>{const e=bn.current;e&&e.ingest(t)&&(_e.current=!0,Be())},{chunkThreshold:k,chunkSize:w})),e.useEffect(()=>{var t;null===(t=An.current)||void 0===t||t.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const Sn=e.useCallback(t=>{var e;null===(e=An.current)||void 0===e||e.push(t)},[]),jn=e.useCallback(t=>{var e;null===(e=An.current)||void 0===e||e.pushMany(t)},[]),Mn=e.useCallback(()=>{var t,e;null===(t=An.current)||void 0===t||t.clear(),null===(e=bn.current)||void 0===e||e.clear(),_e.current=!0,Be()},[Be]);e.useImperativeHandle(o,()=>({push:Sn,pushMany:jn,remove:t=>{var e,n,o;null===(e=An.current)||void 0===e||e.flush();const i=null!==(o=null===(n=bn.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[];return i.length>0&&(nn.current&&i.some(t=>{var e;return t===(null===(e=nn.current)||void 0===e?void 0:e.data)})&&(nn.current=null,sn(null)),_e.current=!0,Be()),i},update:(t,e)=>{var n,o,i;null===(n=An.current)||void 0===n||n.flush();const r=null!==(i=null===(o=bn.current)||void 0===o?void 0:o.update(t,e))&&void 0!==i?i:[];return r.length>0&&(_e.current=!0,Be()),r},clear:Mn,getData:()=>{var t,e,n;return null===(t=An.current)||void 0===t||t.flush(),null!==(n=null===(e=bn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=bn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=bn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Sn,jn,Mn,Be]),e.useEffect(()=>{var t,e;if(b){if(T&&Xe.length>0&&"object"==typeof Xe[0]&&null!==Xe[0]){const e="string"==typeof T?T:"coordinates";if(Array.isArray(Xe[0][e])){const n=[];for(const t of Xe){const o=t[e];if(Array.isArray(o)){const e=t.label||t.id||t.key;if(null!=e)for(const t of o)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of o)n.push(t)}}return void(null===(t=An.current)||void 0===t||t.setBoundedData(n))}}null===(e=An.current)||void 0===e||e.setBoundedData(Xe)}},[b,Xe,T]);const{hoverHandlerRef:Pn,hoverLeaveRef:Tn,onPointerMove:$n,onPointerLeave:Cn}=Oe;Pn.current=t=>{var e,n,o,i;if(!Ve)return;const r=Ue.current;if(!r)return;const s=r.getBoundingClientRect(),a=t.clientX-s.left-Ie.left,l=t.clientY-s.top-Ie.top;if(0>a||a>He||0>l||l>qe)return void(nn.current&&(nn.current=null,on.current=null,sn(null),$t&&($t(null),_e.current=!0),Be()));const c=bn.current;if(!c||0===c.scene.length)return;const u=Fi(c.scene,a,l,Rt,c.quadtree,c.maxPointRadius),d="multi"===zt,h=()=>{nn.current&&(nn.current=null,on.current=null,sn(null),$t&&$t(null),Be())};if(!u&&!d)return void h();const f=d||!u?a:u.x,g=d||!u?l:u.y,y=(null==u?void 0:u.datum)?xt(u.datum,c.resolvedRibbons):{},p=null===(n=null===(e=c.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,m="function"==typeof p?p(f):void 0;let x=li(y,f,g,null!=m?{xValue:m,xPx:f}:void 0);if(d&&c.scene.length>0&&c.scales){const t=function(t,e,n=30){const o=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const r=Wi(Ni(t.path,t.curve),e,n);if(null===r)continue;const s=Ui(t.path,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=Ni(t.topPath,t.curve),s=Ni(t.bottomPath,t.curve),a=Wi(r,e,n);if(null===a)continue;const l=Wi(s,e,n),c=Ui(t.topPath,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:null!=l?l:void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return o}(c.scene,f,Math.max(Rt,He));if(t.length>0){const e=c.scales.y.invert,n=an.current,o=p?p(f):f;if(u)x.xValue=o,x.xPx=f;else{const t={xValue:o};"string"==typeof A&&(t[A]=o),x=li(t,f,g,{xValue:o,xPx:f})}x.allSeries=t.map(t=>{const o=e?e(t.y):t.y,i=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===v&&null!=i?o-i:o,valuePx:t.y,color:t.color||n,datum:xt(t.datum,c.resolvedRibbons)}})}}u||(null===(o=x.allSeries)||void 0===o?void 0:o.length)?(nn.current=x,on.current=null!==(i=null==u?void 0:u.node)&&void 0!==i?i:null,sn(x),$t&&($t(x),_e.current=!0),Be()):h()},Tn.current=()=>{nn.current&&(nn.current=null,on.current=null,sn(null),$t&&($t(null),_e.current=!0),Be())};const En=e.useRef(()=>{});En.current=t=>{var e,n;if(!Lt)return;const o=Ue.current;if(!o)return;const i=o.getBoundingClientRect(),r=t.clientX-i.left-Ie.left,s=t.clientY-i.top-Ie.top;if(0>r||r>He||0>s||s>qe)return void Lt(null);const a=bn.current;if(!a||0===a.scene.length)return void Lt(null);const l=Fi(a.scene,r,s,Rt,a.quadtree,a.maxPointRadius);if(!l)return void Lt(null);const c=l.datum||{},u=null===(n=null===(e=a.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,d="function"==typeof u?u(l.x):void 0;Lt(li(c,l.x,l.y,null!=d?{xValue:d,xPx:l.x}:void 0))};const Rn=e.useCallback(t=>En.current(t),[]),zn=e.useRef(-1),Dn=e.useRef(null),Nn=e.useRef(null),Fn=e.useCallback(t=>{const e=bn.current;if(!e||0===e.scene.length)return;const n=e.version;let o;if(Nn.current&&Nn.current.version===n)o=Nn.current.graph;else{const t=function(t){var e,n,o;const i=[];for(const r of t)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=r.size)break;i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],o=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)i.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:o});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],o=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)i.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:o});break}case"rect":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(o=r.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;o=function(t){var e,n;const o=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let i=o.get(t);i||(i=[],o.set(t,i)),i.push(n)}for(const t of o.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const i=Array.from(o.keys()).sort((t,e)=>{const n=o.get(t),i=o.get(e);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(o.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:i,byGroup:o,idToIdx:s}}(t),Nn.current={version:n,graph:o}}const i=zn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),zn.current=0;const n=o.flat[0];Dn.current={shape:n.shape,w:n.w,h:n.h};const i=Qi(Object.assign(Object.assign({},n),{datum:xt(n.datum,e.resolvedRibbons)}));return nn.current=i,sn(i),$t&&$t(i),void Be()}const r=function(t,e){var n,o;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[i];return{flatIndex:i,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=r._groupIndex)&&void 0!==o?o:0}}(o,i),s=function(t,e,n){const{group:o,indexInGroup:i}=e,r=n.byGroup.get(o);switch(t){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(o);return n.groups.length-1>t?Zi(n,n.groups[t+1],r[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(o);return t>0?Zi(n,n.groups[t-1],r[i]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(t.key,r,o);if(null===s)return;if(t.preventDefault(),0>s)return zn.current=-1,Dn.current=null,nn.current=null,on.current=null,sn(null),$t&&$t(null),void Be();zn.current=s;const a=o.flat[s];Dn.current={shape:a.shape,w:a.w,h:a.h};const l=Qi(Object.assign(Object.assign({},a),{datum:xt(a.datum,e.resolvedRibbons)}));nn.current=l,sn(l),$t&&$t(l),Be()},[$t,Be]),Wn=e.useCallback(t=>{zn.current=-1,Dn.current=null,$n(t)},[$n]);We.current=()=>{Fe.current=0;const t=Ue.current,e=Ze.current;if(!t||!e)return;const n=bn.current;if(!n)return;const o="undefined"!=typeof performance?performance.now():Date.now(),i=n.advanceTransition(Le.current?o+1e6:o),r=!Le.current&&i,s=Pe.current.w!==He||Pe.current.h!==qe,a=_e.current||i||s;let l=!1;!a||r&&!s||(n.computeScene({width:He,height:qe}),Pe.current={w:He,h:qe},l=!0,kn());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return Fs;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),o=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=o||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=i||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||Fs.axisStroke,tickText:s||Fs.tickText,crosshair:s?Ws(s,"66"):Fs.crosshair,hoverFill:c?Ws(c,"4D"):Fs.hoverFill,hoverStroke:s?Ws(s,"99"):Fs.hoverStroke,pointRing:c||Fs.pointRing,primary:r||Fs.primary}:Fs}(t);an.current=u.primary;const d=tr(le,n.lastIngestTime>0?o-n.lastIngestTime:0),h=le&&d.isStale;if(a){const e=hs(t,Ee,Ie,c);if(e){if(e.clearRect(-Ie.left,-Ie.top,Ee[0],Ee[1]),le&&1>d.alpha&&(e.globalAlpha=d.alpha),"transparent"!==Q&&!Zt){const n=getComputedStyle(t).getPropertyValue("--semiotic-bg").trim(),o=Q||(n&&"transparent"!==n?n:null),i=o?Li(e,o):null;i&&(e.fillStyle=i,e.fillRect(-Ie.left,-Ie.top,Ee[0],Ee[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,He,qe),e.clip()),Kt&&n.scales)for(const t of Kt)e.save(),t(e,n.scene,n.scales,{width:He,height:qe}),e.restore();const o=Ae?Ds.custom:Ds[v];if(o&&n.scales)for(const t of o)t(e,n.scene,n.scales,{width:He,height:qe});e.restore(),le&&1>d.alpha&&(e.globalAlpha=1)}}{const t=hs(e,Ee,Ie,c);if(t&&(t.clearRect(-Ie.left,-Ie.top,Ee[0],Ee[1]),Ve&&nn.current&&n.scales&&function(t,e,n,o,i,r,s){var a;if(!1===i.crosshair)return;const l=e.allSeries,c=l&&l.length>0,u=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,o),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of l)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=i.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,nn.current,He,qe,"object"==typeof Ve?Ve:{},on.current,u),on.current&&Array.isArray(Ot))){const e=Ot.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,o,i){var r;if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||i.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,n.scene,on.current,e,u)}}a&&t&&t.setAttribute("aria-label",Ir(n.scene,v+" chart"));const f=_e.current;if(_e.current=f&&r&&!l,f&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!tn||t(tn.x.domain()[0])!==t(n.scales.x.domain()[0])||t(tn.x.domain()[1])!==t(n.scales.x.domain()[1])||t(tn.y.domain()[0])!==t(n.scales.y.domain()[0])||t(tn.y.domain()[1])!==t(n.scales.y.domain()[1])||tn.x.range()[0]!==n.scales.x.range()[0]||tn.x.range()[1]!==n.scales.x.range()[1]||tn.y.range()[0]!==n.scales.y.range()[0]||tn.y.range()[1]!==n.scales.y.range()[1])&&en(n.scales),ge){const t=n.getData(),e="function"==typeof A?A:t=>t[A||"x"],o="function"==typeof S?S:t=>t[S||"y"];gn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),pn(t.map(t=>o(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Dt&&Dt.length>0||Ae)&&(l||r))||!l&&33>o-Je.current||(Ke(t=>t+1),Je.current=o),(null==le?void 0:le.showBadge)&&hn(!!h),(r||null!=n.activeTransition||n.hasActivePulses)&&(Fe.current=requestAnimationFrame(()=>We.current()))},function(t){const{hydrated:n,wasHydratingFromSSR:o,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=t;Cr(()=>{var t,e;n&&o&&(null===(e=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===e||e.call(t)),r.current=!0,s.current()},[n,o]);const l=e.useRef(a);l.current=a,e.useEffect(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:Te,wasHydratingFromSSR:$e,storeRef:bn,dirtyRef:_e,renderFnRef:We,cleanup:()=>{var t;return null===(t=An.current)||void 0===t?void 0:t.clear()}}),e.useEffect(()=>{_e.current=!0,Be()},[v,He,qe,vt,Q,K,Kt,Be]),function(t,n,o,i,r,s){const a=e.useRef("fresh");e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{const e=n.current;if(!e||0===e.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=tr(t,l-e.lastIngestTime);c.band===a.current&&c.isStale===r||(a.current=c.band,c.isStale!==r&&s(c.isStale),o.current=!0,i())},1e3);return()=>clearInterval(e)},[t,r,i])}(le,bn,_e,Be,dn,hn);const Bn=e.useMemo(()=>{if(St||_t)return;const t=bn.current;return(null==t?void 0:t.xIsDate)&&tn?zs(tn.x.domain()):void 0},[St,_t,tn]),In=St||_t||Bn,Yn=Ve&&rn?Tt?Tt(rn):t.jsx(Is,{hover:rn}):null,Gn=Yn?t.jsx(ls,{x:rn.x,y:rn.y,containerWidth:He,containerHeight:qe,margin:Ie,className:"stream-frame-tooltip",children:Yn}):null,Hn=Dn.current,qn=t.jsx(as,{active:zn.current>=0,hoverPoint:rn,margin:Ie,size:Ee,shape:null==Hn?void 0:Hn.shape,width:null==Hn?void 0:Hn.w,height:null==Hn?void 0:Hn.h}),Xn=Es(A,W,"__semiotic_resolvedX","__semiotic_resolvedTime"),Vn=Es(S,z,"__semiotic_resolvedY","__semiotic_resolvedValue"),Un=Xn.key,Zn=Vn.key,Qn=function(t,e,n){return o=>{if(!o||!n||!t.fn&&!e.fn)return o;let i=!1;const r=o.map(n=>{const o=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!o&&!r)return n;i=!0;const s=Object.assign({},n);return o&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return i?r:o}}(Xn,Vn,Dt&&Dt.length>0||!1);if(On||!Te&&$e){const e=bn.current;e&&b&&(e.ingest({inserts:Xe,bounded:!0}),e.computeScene({width:He,height:qe}));const n=null!==(i=null==e?void 0:e.scene)&&void 0!==i?i:[],o=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,a=In||(()=>{if((null==e?void 0:e.xIsDate)&&o)return zs(o.x.domain())})();return t.jsxs("div",{ref:Ce,className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":xe||("string"==typeof te?te:"XY chart"),style:{position:"relative",width:X?"100%":Ee[0],height:V?"100%":Ee[1]},children:[t.jsx(os,{summary:be}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${Ie.left},${Ie.top})`,children:Ge}),t.jsxs("g",{transform:`translate(${Ie.left},${Ie.top})`,children:[Q&&t.jsx("rect",{x:0,y:0,width:He,height:qe,fill:Q}),Jt&&o&&Jt.map((e,i)=>t.jsx(m.Fragment,{children:e(n,o,{width:He,height:qe})},"svgpre-"+i)),n.map((t,e)=>_n(t,e,Me)).filter(Boolean)]})]}),t.jsx(Lr,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,scales:o,showAxes:vt,axes:bt,xLabel:kt,yLabel:wt,yLabelRight:At,xFormat:a,yFormat:jt||Pt,axisExtent:Mt,showGrid:Wt,title:te,legend:Bt,legendHoverBehavior:It,legendClickBehavior:Yt,legendHighlightedCategory:Gt,legendIsolatedCategories:Ht,legendPosition:qt,legendLayout:Xt,foregroundGraphics:mi(Ye,bi(null===(s=bn.current)||void 0===s?void 0:s.customLayoutOverlays,null!=je?je:null)),marginalGraphics:ge,xValues:[],yValues:[],annotations:Dt,autoPlaceAnnotations:Nt,svgAnnotationRules:Ft,annotationFrame:0,xAccessor:Un,yAccessor:Zn,annotationData:Qn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof $?$:void 0,linkedCrosshairName:ke,linkedCrosshairSourceId:we})]})}return t.jsxs("div",{ref:Ce,className:"stream-xy-frame"+(Z?" "+Z:""),role:"group","aria-label":xe||("string"==typeof te?te:"XY chart"),tabIndex:0,style:{position:"relative",width:X?"100%":Ee[0],height:V?"100%":Ee[1],overflow:"visible"},onKeyDown:Fn,children:[ve&&t.jsx(is,{tableId:Ne}),ve&&t.jsx(ns,{scene:null!==(l=null===(a=bn.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:v+" chart",tableId:Ne,chartTitle:"string"==typeof te?te:void 0}),t.jsx(os,{summary:be}),t.jsx(rs,{hoverPoint:rn}),t.jsxs("div",{role:"img","aria-label":xe||("string"==typeof te?te:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ve?Wn:void 0,onMouseLeave:Ve?Cn:void 0,onClick:Lt?Rn:void 0,children:[Ge&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${Ie.left},${Ie.top})`,children:Ge})}),t.jsx(Or,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,scales:tn,showAxes:vt,axes:bt,showGrid:Wt,xFormat:In,yFormat:jt||Pt,axisExtent:Mt}),t.jsx("canvas",{ref:Ue,"aria-label":Ir(null!==(u=null===(c=bn.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],v+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:Ze,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(Lr,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,scales:tn,showAxes:vt,axes:bt,xLabel:kt,yLabel:wt,yLabelRight:At,xFormat:In,yFormat:jt||Pt,axisExtent:Mt,showGrid:Wt,title:te,legend:Bt,legendHoverBehavior:It,legendClickBehavior:Yt,legendHighlightedCategory:Gt,legendIsolatedCategories:Ht,legendPosition:qt,legendLayout:Xt,foregroundGraphics:mi(Ye,bi(null===(d=bn.current)||void 0===d?void 0:d.customLayoutOverlays,null!=je?je:null)),marginalGraphics:ge,xValues:fn,yValues:yn,annotations:Dt,autoPlaceAnnotations:Nt,svgAnnotationRules:Ft,annotationFrame:Qe,xAccessor:Un,yAccessor:Zn,annotationData:Qn(null===(h=bn.current)||void 0===h?void 0:h.getData()),pointNodes:null===(f=bn.current)||void 0===f?void 0:f.scene.filter(t=>"point"===t.type),curve:"string"==typeof $?$:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==Q&&!Zt,linkedCrosshairName:ke,linkedCrosshairSourceId:we}),(ne||oe)&&t.jsx(yi,{width:He,height:qe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ie,dimension:null!==(g=null==ne?void 0:ne.dimension)&&void 0!==g?g:"xy",scales:tn,onBrush:null!=oe?oe:()=>{},binSize:R,snap:null==ne?void 0:ne.snap,binBoundaries:null!==(y=null==ne?void 0:ne.binBoundaries)&&void 0!==y?y:"bar"===v?null===(p=bn.current)||void 0===p?void 0:p.getBinBoundaries():void 0,snapDuring:null==ne?void 0:ne.snapDuring,streaming:"streaming"===x}),(null==le?void 0:le.showBadge)&&t.jsx(er,{isStale:dn,position:le.badgePosition}),qn,Gn]})]})});Ys.displayName="StreamXYFrame";const Gs=e.createContext(null);function Hs(){return e.useContext(Gs)}function qs(t){const e=[];for(const[n,o]of Object.entries(t.fields))if("point"===o.type)e.push(t=>o.values.has(t[n]));else{const[t,i]=o.range;e.push(e=>{const o=e[n];return o>=t&&i>=o})}return t=>e.every(e=>e(t))}function Xs(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function Vs(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}const[Us,Zs]=Tn(t=>({selections:new Map,setClause(e,n){t(t=>{const o=t.selections.get(e),i=null==o?void 0:o.clauses.get(n.clientId);if(i&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,o]of n){const n=e.fields[t];if(!n||!Vs(o,n))return!1}return!0}(i,n))return{};const r=new Map(t.selections),s=Xs(r,e),a=new Map(s.clauses);return a.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},s),{clauses:a})),{selections:r}})},clearClause(e,n){t(t=>{const o=t.selections.get(e);if(!o||!o.clauses.has(n))return{};const i=new Map(t.selections),r=new Map(o.clauses);return r.delete(n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(e,n){t(t=>{const o=t.selections.get(e);if((null==o?void 0:o.resolution)===n)return{};const i=new Map(t.selections),r=Xs(i,e);return i.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const o=new Map(t.selections);return o.set(e,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[Qs,Ks]=Tn(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Js(t){const n=e.useId(),o=t.clientId||n,{name:i}=t,r=Zs(t=>t.selections.get(i)),s=Zs(t=>t.setClause),a=Zs(t=>t.clearClause),l=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[o,i]of t.clauses)"crossfilter"===t.resolution&&o===e||n.push(qs(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,o):()=>!0,[r,o]),isActive:l,selectPoints:e.useCallback(t=>{const e={};let n=!1;for(const[o,i]of Object.entries(t))e[o]={type:"point",values:new Set(i)},n=!0;n&&s(i,{clientId:o,type:"point",fields:e})},[o,i,s]),selectInterval:e.useCallback(t=>{const e={};let n=!1;for(const[o,i]of Object.entries(t))e[o]={type:"interval",range:i},n=!0;n&&s(i,{clientId:o,type:"interval",fields:e})},[o,i,s]),clear:e.useCallback(()=>{a(i,o)},[a,i,o]),clientId:o}}const ta=e.createContext(!1),ea=e.createContext(null),na="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function oa(t,e,n){var o;const i=null!==(o=t.xValue)&&void 0!==o?o:null==e?void 0:e[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function ia(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function ra(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function sa(){var t;const e=Wn(t=>t.theme),n=null===(t=null==e?void 0:e.colors)||void 0===t?void 0:t.categorical;return n&&n.length>0?n:void 0}function aa({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(n,o),f="series"===(null==h?void 0:h.mode)?[h.seriesField||u||o[0]].filter(t=>!!t):(null==h?void 0:h.fields)||o||[],g=Js({name:(null==t?void 0:t.name)||"__unused__"}),y=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:i,isActive:r,selectPoints:s,clear:a}=Js({name:n}),l=e.useCallback(t=>{if(!t)return void a();const e={};for(const n of o){const o=t[n];void 0!==o&&(e[n]=[o])}(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(e)&&s(e)},[o,s,a,n]);return{onHover:l,predicate:i,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:f}),p=Ks(t=>t.pushObservation),m=t?{isActive:g.isActive,predicate:g.predicate}:null,[v,x]=e.useState(null),b=u||o[0],k=e.useMemo(()=>{if(!c||null==v||!b)return null;const t=v,e=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[e]?n[e]:(null!==(o=n[e])&&void 0!==o?o:"")+"")===t}}},[c,v,b]),w=e.useCallback(t=>{var e,o;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=oa(t,e,h.xField);null!=n&&function(t,e,n){const o=fr.positions.get(t);(null==o?void 0:o.locked)||o&&o.xValue===e&&o.sourceId===n||(fr={positions:new Map(fr.positions).set(t,{xValue:e,sourceId:n})},yr())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&pr(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&b)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[b];x(null!=n?n+"":null)}else x(null);if(r||p){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){const i=ia(t),s=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(t),p&&p(t)}}},[n,y,h,d,r,s,a,p,c,b]),A=e.useCallback(t=>{var e,n,o,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=oa(t,e,h.xField);null!=n&&function(t,e,n){const o=fr.positions.get(t);if(null==o?void 0:o.locked){const e=new Map(fr.positions);return e.delete(t),fr={positions:e},yr(),!1}fr={positions:new Map(fr.positions).set(t,{xValue:e,sourceId:n,locked:!0})},yr()}(h.name||"hover",n,d)}if(t&&l){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(r||p){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){const n=ia(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(o=t.x)&&void 0!==o?o:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),p&&p(t)}}},[l,r,p,s,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{mr(t,d),pr(t,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:w,customClickBehavior:A,crosshairSourceId:d}}function la({data:t,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(ta),u=null!==e.useContext(ea),d=void 0!==i?i:!c&&!!n,h=!!n&&(d||u),f=e.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const e=new Set;for(const o of t){const t="function"==typeof n?n(o):o[n];null!=t&&e.add(t+"")}return Array.from(e)},[l,n,t,h]);!function(t){const n=e.useContext(ea),o=e.useId(),i=function(t){const e=new Set,n=[];for(const o of t)e.has(o)||(e.add(o),n.push(o));return n}(t),r=e.useRef([]);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(r.current,i)||(r.current=i);const s=r.current;na(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),na(()=>{n&&n.registerCategories(o,s)},[n,o,s])}(u&&n?f:[]);const g=e.useMemo(()=>{if(!d||!n)return;const e=function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((i,r)=>{const s=t.find("function"==typeof e?t=>e(t)===i:t=>t[e]===i),a=s?o(s,e,n):n?n(i):nt[r%nt.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:it,categories:f});return 0!==e.legendGroups.reduce((t,e)=>t+e.items.length,0)?e:void 0},[d,n,t,o,f]),y=e.useMemo(()=>{const t="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},e=e=>{const n=t[e];return"number"==typeof n?n:a[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},o=e=>"number"==typeof t[e];return g&&("right"===r&&!o("right")&&110>n.right?n.right=110:"left"===r&&!o("left")&&110>n.left?n.left=110:"top"===r&&!o("top")&&50>n.top?n.top=50:"bottom"===r&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,s,g,r]);return{legend:g,margin:y,legendPosition:r}}m.createContext(void 0);const ca={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function ua(t,e,n){if(!1!==e)return t;const o=Object.assign({},t);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function da({componentName:e,message:n,diagnosticHint:o,width:i,height:r}){return t.jsx("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:t.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&t.jsx("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class ha extends m.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,t,e)}render(){if(this.state.error){const{fallback:e}=this.props,n=this.state.error;return"function"==typeof e?e(n):void 0!==e?e:t.jsx(da,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function fa({componentName:e,width:n,height:o,children:i}){return t.jsx(ha,{fallback:i=>t.jsx(da,{componentName:e,message:i.message,width:n,height:o}),children:i})}"undefined"!=typeof process&&process;const ga={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},ya={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function pa(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("string"==typeof t){if(""===t.trim())return NaN;const e=+t;return Number.isFinite(e)?e:NaN}return NaN}function ma(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,l=null,c=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;i.length>t;t++){const r=i[t],g=e(r),y=n(r),p=o(r);if(!Number.isFinite(g)||!Number.isFinite(y)||!Number.isFinite(p))continue;const m=u(y,p);if(null!==m)if(null!=a){if(l&&l.w!==m){let t,e;if(c.length>0)t=c[0].x,e=c[0].y;else{const n=y-l.a-(p-l.b);if(0!==n){const o=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+o*(g-l.x),e=l.a+o*(y-l.a)}else t=l.x,e=l.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;c.length>t;t++)f(c[t],a)}else for(const t of c)f(t,a);c=[],h({__x:g,__y:p>y?p:y,__y0:p>y?y:p,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:p,__sourceDatum:r}),l={x:g,a:y,b:p,w:m}}else{a=m;for(const t of c)f(t,a);c=[],h({__x:g,__y:p>y?p:y,__y0:p>y?y:p,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:p,__sourceDatum:r}),l={x:g,a:y,b:p,w:m}}else c.push({x:g,y:y,datum:r})}for(const t of c)f(t,null!=a?a:"A");return r}const va=e.forwardRef(function(n,o){const i=e.useRef(null),r=function(t,e){var n,o,i,r,s,a,l;const c=ca[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(n=e.width)&&void 0!==n?n:c.width,height:null!==(o=e.height)&&void 0!==o?o:c.height,showAxes:null!==(i=e.showAxes)&&void 0!==i?i:c.showAxes,showGrid:null!==(r=e.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=e.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:ua(c.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:u}}(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",seriesAAccessor:h="a",seriesBAccessor:f="b",seriesALabel:g="A",seriesBLabel:y="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:m="var(--semiotic-info, #2563eb)",showLines:v=!0,lineWidth:x=1.5,showPoints:b=!1,pointRadius:k=3,curve:w="linear",areaOpacity:A=.6,gradientFill:S,tooltip:j,annotations:M,xExtent:_,yExtent:P,frameProps:O={},selection:T,linkedHover:$,onObservation:L,onClick:C,hoverHighlight:E,chartId:R,loading:z,loadingContent:D,emptyContent:N,legendInteraction:F,legendPosition:W,pointIdAccessor:B,windowSize:I}=n,{width:Y,height:G,enableHover:H,showGrid:q,showLegend:X,title:V,description:U,summary:Z,accessibleTable:Q,xLabel:K,yLabel:J}=r,tt=e.useMemo(()=>"function"==typeof d?t=>pa(d(t)):t=>pa(t[d]),[d]),et=e.useMemo(()=>"function"==typeof h?t=>pa(h(t)):t=>pa(t[h]),[h]),ot=e.useMemo(()=>"function"==typeof f?t=>pa(f(t)):t=>pa(t[f]),[f]),[it,st]=e.useState([]),at=e.useRef([]),lt=null==s,ct=e.useMemo(()=>si(lt?it:s),[lt,it,s]),ut=e.useMemo(()=>ma(ct,tt,et,ot),[ct,tt,et,ot]),dt=e.useMemo(()=>v?function(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of i){const i=e(t),s=n(t),a=o(t);Number.isFinite(s)&&r.push({__x:i,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:i,__y:a,__diffSegment:"line-B"})}return r}(ct,tt,et,ot):[],[v,ct,tt,et,ot]),ht=e.useMemo(()=>[...ut,...dt],[ut,dt]),ft=e.useMemo(()=>{const t=new Set;for(const e of ut)t.add(e.__diffSegment);return Array.from(t)},[ut]);e.useImperativeHandle(o,()=>{const t=t=>{const e=I&&t.length>I?t.slice(t.length-I):t;at.current=e,st(e)},e=B?"function"==typeof B?B:t=>t[B]:null;return{push:e=>t([...at.current,e]),pushMany:e=>t([...at.current,...e]),remove:n=>{if(!e)return[];const o=Array.isArray(n)?n:[n],i=[],r=[];for(const t of at.current)o.includes(e(t))?i.push(t):r.push(t);return t(r),i},update:(n,o)=>{if(!e)return[];const i=Array.isArray(n)?n:[n],r=[],s=at.current.map(t=>{if(i.includes(e(t))){const e=o(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>lt?at.current:ct,getScales:()=>{var t,e;return null!==(e=null===(t=i.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[lt,ct,B,I]);const gt=function(n){const{data:o,rawData:i,colorBy:r,colorScheme:s,legendInteraction:a,legendPosition:l,selection:c,linkedHover:u,fallbackFields:d,unwrapData:h=!1,onObservation:f,chartType:g,chartId:y,showLegend:p,userMargin:m,marginDefaults:v,onClick:x,hoverHighlight:b,loading:k,loadingContent:w,emptyContent:A,width:S,height:j}=n,M=void 0===i,_=e.useMemo(()=>si(o),[o]),[P,O]=e.useState([]),T=e.useCallback(t=>{O(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),$="string"==typeof n.colorBy?n.colorBy:void 0,{activeSelectionHook:L,hoverSelectionHook:C,customHoverBehavior:E,customClickBehavior:R,crosshairSourceId:z}=aa({selection:c,linkedHover:u,fallbackFields:d,unwrapData:h,onObservation:f,chartType:g,chartId:y,onClick:x,hoverHighlight:b,colorByField:$}),D=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(u,z),N=function(t,n,o){const i=Hs(),r=sa();return e.useMemo(()=>{var e;if(!n)return;const s=null!=i?i:void 0,a=null!==(e=null!=o?o:r&&r.length>0?r:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(t=>n(t)+"")));if(s&&ra(s)){const t=rt(e.map(t=>({_cat:t})),"_cat",a);return e=>s[e]||t(e)}return rt(e.map(t=>({_cat:t})),"_cat",a)}if(s&&ra(s)){const e=rt(t,n,a);return t=>s[t]||e(t)}return rt(t,n,a)}if(s&&ra(s)){const t=rt([{_:"a"}],"_",a);return e=>s[e]||t(e)}},[t,n,o,i,r])}(_,r,s),F=e.useMemo(()=>{if(!r)return[];const t=new Set;for(const e of _){const n="function"==typeof r?r(e):e[r];null!=n&&t.add(n+"")}return Array.from(t)},[_,r]),W=e.useMemo(()=>M&&P.length>0?P:F,[M,P,F]),B=function(t,n,o){const[i,r]=e.useState(null),[s,a]=e.useState(new Set),l=e.useMemo(()=>new Set,[]),c=e.useCallback(e=>{"highlight"===t&&r(e?e.label:null)},[t]),u=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),d=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===i}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,i,s]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?s:l,onLegendHover:c,onLegendClick:u,legendSelectionHook:d}}(a,r,W),I=e.useMemo(()=>C||(B.legendSelectionHook?B.legendSelectionHook:L),[C,B.legendSelectionHook,L]),Y=function(t){const n=Wn(t=>t.theme.colors.selectionOpacity);return e.useMemo(()=>{var e,o;if(void 0!==t||void 0!==n)return Object.assign(Object.assign({name:null!==(e=null==t?void 0:t.name)&&void 0!==e?e:""},t),{unselectedOpacity:null!==(o=null==t?void 0:t.unselectedOpacity)&&void 0!==o?o:n})},[t,n])}(c),G=sa(),H=Hs(),q=e.useMemo(()=>{if(N)return N;if(!r||0===W.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:G&&G.length>0?G:nt,e="__streamCat",n=rt(W.map(t=>({[e]:t})),e,t);return t=>(null==H?void 0:H[t])||n(t)||"#999"},[N,r,W,s,G,H]),{legend:X,margin:V,legendPosition:U}=la({data:_,colorBy:r,colorScale:q,showLegend:p,legendPosition:l,userMargin:m,defaults:v,categories:W}),Z=e.useMemo(()=>{const t={};return X&&(t.legend=X,t.legendPosition=U),a&&"none"!==a&&(t.legendHoverBehavior=B.onLegendHover,t.legendClickBehavior=B.onLegendClick,t.legendHighlightedCategory=B.highlightedCategory,t.legendIsolatedCategories=B.isolatedCategories),M&&r&&(t.legendCategoryAccessor=r,t.onCategoriesChange=T),t},[X,U,a,B.onLegendHover,B.onLegendClick,B.highlightedCategory,B.isolatedCategories,M,r,T]),Q=Array.isArray(i)?si(i):i,K=function(e,n,o,i){if(!e)return null;if(!1===i)return null;if(null!=i)return t.jsx("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(o/40)),s=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),l=Math.floor((o-(r*(s+a)-a))/2);return t.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,o)=>t.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ya),{position:"absolute",top:l+o*(s+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:s,opacity:.5+o%2*.2})},o))})}(k,S,j,w),J=K?null:function(e,n,o,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},ga),{width:n,height:o}),children:i||"No data available"}):null}(Q,S,j,A);return{data:_,colorScale:N,allCategories:W,legendState:B,effectiveSelectionHook:I,activeSelectionHook:L,customHoverBehavior:E,customClickBehavior:R,legend:X,margin:V,legendPosition:U,earlyReturn:K||J||null,legendBehaviorProps:Z,crosshairProps:D,resolvedSelection:Y}}({data:ct,rawData:s,colorBy:"__diffWinner",colorScheme:[p,m],legendInteraction:F,legendPosition:W,selection:T,linkedHover:$,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:L,onClick:C,hoverHighlight:E,chartType:"DifferenceChart",chartId:R,showLegend:X,userMargin:a,marginDefaults:r.marginDefaults,loading:z,loadingContent:D,emptyContent:N,width:Y,height:G}),yt=e.useMemo(()=>{if(!1!==X)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:g,color:p},{label:y,color:m}]}]}},[X,g,y,p,m]),pt=e.useCallback(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?p:m,stroke:"none",fillOpacity:A}},[p,m,A]),mt=e.useCallback(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?p:m,strokeWidth:x,fill:"none"}),[p,m,x]),vt=e.useCallback(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?p:m,r:k}),[p,m,k]),xt=e.useCallback(e=>{var n;const o=e.data,i=e.allSeries,r=null!==(n=e.xValue)&&void 0!==n?n:null==o?void 0:o.__x;let s=null==o?void 0:o.__valA,a=null==o?void 0:o.__valB;if(i&&i.length>0){const t=i.find(t=>"line-A"===t.group),e=i.find(t=>"line-B"===t.group);null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(s=t.value),null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(a=e.value)}if(null!=r&&(null==s||null==a)){const t=ct.find(t=>tt(t)===r);t&&(null==s&&(s=et(t)),null==a&&(a=ot(t)))}const l=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",u=c&&null!=r?c(r):null!=r?r+"":"";return t.jsxs("div",{className:"semiotic-tooltip",style:ci,children:[u&&t.jsx("div",{style:{fontWeight:600,marginBottom:4},children:u}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),t.jsxs("span",{children:[g,": ",l(s)]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),t.jsxs("span",{children:[y,": ",l(a)]})]}),null!=s&&null!=a&&Number.isFinite(s)&&Number.isFinite(a)&&t.jsxs("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",l(s-a)]})]})},[ct,tt,et,ot,c,p,m,g,y]),bt="multi"===j,kt=e.useMemo(()=>{if(!1===j)return()=>null;if(bt)return xt;const e=function(e){if(!0!==e){if("function"==typeof e){const n=e;return e=>{var o;let i=ai(!0===(null==e?void 0:e.__semioticHoverData)||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?null!==(o=e.data)&&void 0!==o?o:{}:e);("node"===(null==e?void 0:e.nodeOrEdge)&&"number"==typeof(null==i?void 0:i.x0)&&"number"==typeof(null==i?void 0:i.x1)||"edge"===(null==e?void 0:e.nodeOrEdge)&&"number"==typeof(null==i?void 0:i.sankeyWidth))&&i.data&&"object"==typeof i.data&&(i=i.data);const r=n(i);return null==r?null:t.jsx("div",{className:"semiotic-tooltip",style:ci,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?hi(e):hi())}}(j);return e||xt},[j,bt,xt]);if(gt.earlyReturn)return gt.earlyReturn;const wt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"mixed",data:ht,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:ft,curve:w,areaStyle:pt,lineStyle:mt},b&&{pointStyle:vt}),{size:[Y,G],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:gt.margin,showAxes:r.showAxes,xLabel:K,yLabel:J,xFormat:c,yFormat:u,enableHover:H,showGrid:q}),S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S}),yt&&{legend:yt,legendPosition:gt.legendPosition}),function(t){const{title:e,description:n,summary:o,accessibleTable:i,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:l}=t,c={};return e&&(c.title=e),n&&(c.description=n),o&&(c.summary=o),void 0!==i&&(c.accessibleTable=i),r&&(c.className=r),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}({title:V,description:U,summary:Z,accessibleTable:Q,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),{tooltipContent:kt}),bt&&{tooltipMode:"multi"}),function(t){const{linkedHover:e,onObservation:n,onClick:o,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=t,l={};return(e||n||o||i)&&(l.customHoverBehavior=r),(a?n||o||e:n||o)&&(l.customClickBehavior=s),l}({linkedHover:$,onObservation:L,onClick:C,hoverHighlight:E,customHoverBehavior:gt.customHoverBehavior,customClickBehavior:gt.customClickBehavior})),M&&M.length>0&&{annotations:M}),_&&{xExtent:_}),P&&{yExtent:P}),gt.crosshairProps),O);return t.jsx(fa,{componentName:"DifferenceChart",width:Y,height:G,children:t.jsx(Ys,Object.assign({ref:i},wt))})});function xa(t,e,n){return"function"==typeof t?t(n):n[t||e]}function ba(t){return t instanceof Date?t.getTime():Number(t)}function ka(t,e){return X(1===e?.5:t/(e-1))}"function"==typeof va&&(va.displayName="DifferenceChart");const wa={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=null!==(r=i.min)&&void 0!==r?r:0,u=null!==(s=i.max)&&void 0!==s?s:100,d=null!==(a=i.sweep)&&void 0!==a?a:240,h=null!==(l=i.arcWidth)&&void 0!==l?l:.3,f=180+(360-d)/2,g=i.thresholds||[{value:u,color:i.color||"#4e79a7"}],y=o.gradientFill,p=function(t){const{min:e,max:n,value:o,thresholds:i,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=t,d=n-e||1,h=(Math.max(e,Math.min(n,o))-e)/d;let f=i&&i.length>0?[...i].sort((t,e)=>t.value-e.value):[{value:n,color:r||"#007bff"}];f=f.map(t=>Object.assign(Object.assign({},t),{value:Math.max(e,Math.min(n,t.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const g=!!c&&c.colorStops.length>=2,y=[],p=new Map,m=[];if(g){const t=a?h:1,e=Ho("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),p.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;n>e;e++)o.push(Go(c.colorStops,t*(e+.5)/n));const i=Ho("fill",0);y.push({category:i,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),p.set(i,{fill:o[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const o=f[n],i=(o.value-t)/d,r=(t-e)/d,l=(o.value-e)/d,c=Math.max(0,(a?Math.min(h,l):l)-r),u=a?Math.max(0,i-c):0;if(c>0){const t=Ho("fill",n);y.push({category:t,value:c,_zone:o.label||"Zone "+(n+1),_isFill:!0}),p.set(t,{fill:o.color})}if(u>0){const t=Ho("bg",n);y.push({category:t,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),p.set(t,{fill:s,opacity:.4})}t=o.value}}if(l&&i&&i.length>0)for(const t of i)t.value>e&&n>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>p.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:c,max:u,value:i.value,thresholds:g,fillColor:i.color,backgroundColor:i.backgroundColor||"#e0e0e0",fillZones:!1!==i.fillZones,showScaleLabels:!1!==i.showScaleLabels,gradientFill:y&&"object"==typeof y&&"colorStops"in y?y:void 0}),m=o.margin||{top:20,right:20,bottom:30,left:40},[v,x]=o.size||[300,300];return Object.assign(Object.assign(Object.assign({chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),x-(m.top||0)-(m.bottom||0))/2*(1-h)),sweepAngle:d,startAngle:f,oSort:!1,pieceStyle:p.pieceStyle},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o),{showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:c,gMax:u,sweep:d,arcWidth:h,value:i.value,startAngleDeg:f,thresholds:g}})}},Aa={Sparkline:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"area",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",y0Accessor:i.y0Accessor,groupAccessor:i.areaBy||e,colorAccessor:e,colorScheme:n},o)},DifferenceChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=i.xAccessor||"x",l=i.seriesAAccessor||"a",c=i.seriesBAccessor||"b",u=t=>ba(xa(a,"x",t)),d=t=>ba(xa(l,"a",t)),h=t=>ba(xa(c,"b",t)),f=i.seriesAColor||"var(--semiotic-danger, #dc2626)",g=i.seriesBColor||"var(--semiotic-info, #2563eb)",y=null!==(r=i.areaOpacity)&&void 0!==r?r:.6,p=null!==(s=i.lineWidth)&&void 0!==s?s:1.5,m=!1!==i.showLines,v=ma(Array.isArray(t)?t:[],u,d,h),x=[];if(m&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(u(t))).sort((t,e)=>u(t)-u(e));for(const t of e){const e=u(t),n=d(t),o=h(t);Number.isFinite(n)&&x.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&x.push({__x:e,__y:o,__diffSegment:"line-B"})}}const b=[...v,...x],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:b,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:k,areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?f:g,stroke:"none",fillOpacity:y}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?f:g,strokeWidth:p,fill:"none"}),curve:i.curve||"linear"},o)}},StackedAreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.areaBy,colorAccessor:e||i.areaBy,colorScheme:n,normalize:i.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,colorScheme:n},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"candlestick",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.highAccessor||"high",highAccessor:i.highAccessor||"high",lowAccessor:i.lowAccessor||"low",openAccessor:i.openAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange||[5,40],colorScheme:n},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",o=e.yAccessor||"y",i=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:ba(xa(e.orderAccessor,"order",t))-ba(xa(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=ba(xa(n,"x",t)),i=ba(xa(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&s++}let a=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=ba(xa(n,"x",t)),i=ba(xa(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&r.set(t,{idx:a++,total:s})}return{data:i,orderMap:r}}(t,i),l=null!==(r=i.pointRadius)&&void 0!==r?r:4;return Object.assign({chartType:"line",data:a.data,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle||{stroke:i.stroke||"#6366f1",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:l,opacity:i.opacity},pointStyle:t=>{var e,n;const o=a.orderMap.get(t),i=null!==(e=null==o?void 0:o.idx)&&void 0!==e?e:0,r=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:r>0?ka(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},o)}},QuadrantChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=i.xCenter,l=i.yCenter,c=i.quadrants,u=i.centerlineStyle||{},d=!1!==i.showQuadrantLabels,h=null!==(r=i.quadrantLabelSize)&&void 0!==r?r:12,f=u.stroke||"#999",g=null!==(s=u.strokeWidth)&&void 0!==s?s:1,y=Array.isArray(u.strokeDasharray)?u.strokeDasharray.join(","):u.strokeDasharray,p=m.createElement,v=c?[(t,e,n)=>{if(!(null==e?void 0:e.x)||!(null==e?void 0:e.y))return null;const o=n.width,i=n.height,r=null!=a?e.x(a):o/2,s=null!=l?e.y(l):i/2;if(null!=a&&!Number.isFinite(r))return null;if(null!=l&&!Number.isFinite(s))return null;const u=Math.max(0,Math.min(o,r)),v=Math.max(0,Math.min(i,s)),x=[{c:c.topLeft,x:0,y:0,w:u,h:v},{c:c.topRight,x:u,y:0,w:o-u,h:v},{c:c.bottomLeft,x:0,y:v,w:u,h:i-v},{c:c.bottomRight,x:u,y:v,w:o-u,h:i-v}],b=d?[p("text",{key:"ltl",x:8,y:8+h,fill:c.topLeft.color,fontWeight:600,fontSize:h,opacity:.5},c.topLeft.label),p("text",{key:"ltr",x:o-8,y:8+h,fill:c.topRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},c.topRight.label),p("text",{key:"lbl",x:8,y:i-8,fill:c.bottomLeft.color,fontWeight:600,fontSize:h,opacity:.5},c.bottomLeft.label),p("text",{key:"lbr",x:o-8,y:i-8,fill:c.bottomRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},c.bottomRight.label)]:[];return p(m.Fragment,null,...x.map((t,e)=>{var n;return t.w>0&&t.h>0?p("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:null!==(n=t.c.opacity)&&void 0!==n?n:.08}):null}),p("line",{key:"vc",x1:u,y1:0,x2:u,y2:i,stroke:f,strokeWidth:g,strokeDasharray:y}),p("line",{key:"hc",x1:0,y1:v,x2:o,y2:v,stroke:f,strokeWidth:g,strokeDasharray:y}),...b)}]:void 0;return Object.assign(Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange,colorScheme:n,pointStyle:i.pointStyle},o),v&&{svgPreRenderers:v})}},Heatmap:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"heatmap",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",valueAccessor:i.valueAccessor,colorScheme:n||i.colorScheme||"blues",showValues:i.showValues,cellBorderColor:i.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,colorAccessor:e,colorScheme:n,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.stackBy,colorAccessor:e||i.stackBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",normalize:i.normalize,oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",groupBy:i.groupBy,colorAccessor:e||i.groupBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",innerRadius:i.innerRadius||60,colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"histogram",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal",bins:i.bins,colorAccessor:e,colorScheme:n},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"boxplot",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorScheme:n},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"violin",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,colorScheme:n},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swarm",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o),{showGrid:null===(r=o.showGrid)||void 0===r||r})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swimlane",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.subcategoryAccessor,colorAccessor:e||i.subcategoryAccessor,categoryAccessor:i.categoryAccessor,subcategoryAccessor:i.subcategoryAccessor,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,amplitude:i.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.levelAccessor||"level",colorAccessor:e||i.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===i.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r="vertical"===i.orientation;return Object.assign({chartType:r?"bar-funnel":"funnel",data:t,oAccessor:i.stepAccessor||"step",rAccessor:i.valueAccessor||"value",colorAccessor:e||i.categoryAccessor,categoryAccessor:i.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:n},o)}},GaugeChart:wa,ForceDirectedGraph:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r;const{edgeWidth:s,edgeColor:a,edgeOpacity:l}=i,c=null!==(r=i.edgeStyle)&&void 0!==r?r:void 0!==s||void 0!==a||void 0!==l?t=>{const e=(null==t?void 0:t.data)||t;let n=1;if("number"==typeof s)n=s;else if("function"==typeof s)n=s(e);else if("string"==typeof s){const t=null==e?void 0:e[s],o="number"==typeof t?t:Number(t);n=Number.isFinite(o)&&o>0?o:1}return{stroke:null!=a?a:"#999",strokeWidth:n,opacity:null!=l?l:.6}}:void 0;return Object.assign({chartType:"force",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,colorBy:e,colorScheme:n,iterations:i.iterations,forceStrength:i.forceStrength,showLabels:i.showLabels,nodeLabel:i.nodeLabel,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange,nodeStyle:i.nodeStyle,edgeStyle:c},o)}},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"sankey",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,orientation:i.orientation,nodeAlign:i.nodeAlign,nodeWidth:i.nodeWidth,nodePaddingRatio:i.nodePaddingRatio,showLabels:i.showLabels,nodeLabel:i.nodeLabel,colorBy:e,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,colorScheme:n},o)},ProcessSankey:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),u=i.sourceAccessor||"source",d=i.targetAccessor||"target",h=i.valueAccessor||"value",f=i.nodeIdAccessor||"id",g=i.startTimeAccessor||"startTime",y=i.endTimeAccessor||"endTime",p=i.systemInTimeAccessor,m=i.systemOutTimeAccessor,v=i.xExtentAccessor||"xExtent",x=i.edgeIdAccessor||"id",b=(t,e)=>"function"==typeof t?t(e):e[t],k=Array.isArray(i.edges)?i.edges:[],w=Array.isArray(i.nodes)?i.nodes:[],A=w.length>0?w:function(t,e,n,o){const i=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof o?o(t):t[o];i.add(e),i.add(r)}),Array.from(i).map(t=>({id:t}))}(0,k,u,d),S=[c(null===(r=i.domain)||void 0===r?void 0:r[0]),c(null===(s=i.domain)||void 0===s?void 0:s[1])],j=A.map(t=>{const e=b(f,t)+"",n=b(v,t),o={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=c(n[0]),e=c(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),M=k.map((t,e)=>{const n=b(x,t),o={id:null!=n?n+"":`${b(u,t)}-${b(d,t)}-${e}`,source:b(u,t)+"",target:b(d,t)+"",value:Number(b(h,t)),startTime:c(b(g,t)),endTime:c(b(y,t)),__raw:t};if(p){const e=c(b(p,t));Number.isFinite(e)&&(o.systemInTime=e)}if(m){const e=c(b(m,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[_,P]=null!==(a=o.size)&&void 0!==a?a:[600,400],O=Object.assign({top:20,right:20,bottom:20,left:20},o.margin),T=null!==(l=o.legendPosition)&&void 0!==l?l:"right";o.showLegend&&("right"===T?O.right=Math.max(O.right,100):"left"===T?O.left=Math.max(O.left,100):"bottom"===T?O.bottom=Math.max(O.bottom,70):"top"===T&&(O.top=Math.max(O.top,40)));const $=O,L=_-$.left-$.right,C=P-$.top-$.bottom,E=Array.isArray(n)?n:null,R=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],z="function"==typeof e?e:null,D=z?A.map(t=>({_cat:z(t)})):A,N=z?"_cat":"string"==typeof e?e:void 0,F=N?rt(D,N,n):null,W=new Map;for(const t of j)W.set(t.id,t.__raw);const{layoutConfig:B,issues:I}=oi({nodes:j,edges:M,domain:S,plotW:L,plotH:C,ribbonLane:i.ribbonLane||"both",edgeOpacity:"number"==typeof i.edgeOpacity?i.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&W.has(t)){const n=W.get(t);return z?it({_cat:z(n)},"_cat",null!=F?F:void 0):it(n,e,null!=F?F:void 0)}const o=E||R;return o[n%o.length]},layoutOpts:{pairing:i.pairing||"temporal",packing:i.packing||"reuse",laneOrder:i.laneOrder||"crossing-min",lifetimeMode:i.lifetimeMode||"half"}});if(I.length>0){const t=I.map(qo).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:A,edges:k,customNetworkLayout:ii,layoutConfig:B,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},o),{margin:$})}},ChordDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"chord",nodes:i.nodes,edges:i.edges,valueAccessor:i.valueAccessor,padAngle:i.padAngle,groupWidth:i.groupWidth,showLabels:i.showLabels,colorBy:e,edgeColorBy:i.edgeColorBy,colorScheme:n},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"cluster"===i.layout?"cluster":"tree",data:t,childrenAccessor:i.childrenAccessor,colorBy:e,colorByDepth:i.colorByDepth,orientation:i.orientation,showLabels:i.showLabels,colorScheme:n},o)},Treemap:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,showLabels:i.showLabels,colorScheme:n},o)},CirclePack:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,colorScheme:n},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({areas:i.areas,projection:i.projection||"equalEarth",areaStyle:i.areaStyle,valueAccessor:i.valueAccessor,colorScheme:n||"blues",graticule:i.graticule,fitPadding:i.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({points:t||i.points,xAccessor:i.xAccessor||"lon",yAccessor:i.yAccessor||"lat",areas:i.areas,areaStyle:i.areaStyle,sizeBy:i.sizeBy,colorBy:e,colorScheme:n,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>{var r,s,a,l,c;const u=(Array.isArray(t)?t:null)||i.flows||[],d=i.nodeIdAccessor||"id",h=i.valueAccessor||"value",f=i.xAccessor||"lon",g=i.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(i.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),v=new Map;for(const t of m)v.set(t[d]+"",t);const x=null!==(r=i.edgeColorBy)&&void 0!==r?r:e,b="function"==typeof x,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),n=v.get(t.target+"");return e&&n?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}):null}).filter(Boolean),w="__flowMapEdgeColor",A=x?b?rt(k.map(t=>({[w]:x(t)})),w,n||"category10"):rt(k,x,n||"category10"):null,S=t=>x&&A?it(t,x,A):"#007bff";let j=1/0,M=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(j>e&&(j=e),e>M&&(M=e))}const _=M>j?M-j:0,[P,O]=null!==(a=i.edgeWidthRange)&&void 0!==a?a:[1,8],T=O-P,$=null!==(l=i.edgeOpacity)&&void 0!==l?l:.6,L=null!==(c=i.edgeLinecap)&&void 0!==c?c:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:i.lineType||"geo",flowStyle:i.flowStyle||"basic",areas:i.areas,areaStyle:i.areaStyle,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(null==t?void 0:t[h]),n=P+Math.max(0,Math.min(1,_>0?((Number.isFinite(e)?e:j)-j)/_:0))*T;return{stroke:S(t),strokeWidth:n,strokeLinecap:L,opacity:$,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function Sa(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function ja(t,e){if(0===e.categories.length)return;const n=e.position||"right",o=function(t){const{width:e,height:n,swatchSize:o}=Xn(t);return{width:e,height:n,swatchSize:o}}({categories:e.categories,theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,legendLayout:e.legendLayout});"right"===n?t.right=Math.max(t.right,o.width+14):"left"===n?t.left=Math.max(t.left,o.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4)}function Ma(t,e){const n=e.position||"right",o={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},i=k(e.legend)?function(t){const{width:e,height:n,swatchSize:o}=Vn(t);return{width:e,height:n,swatchSize:o}}(Object.assign(Object.assign({},o),{legendGroups:e.legend.legendGroups})):w(e.legend)?Un(Object.assign(Object.assign({},o),{gradient:e.legend.gradient})):null;i&&("right"===n?t.right=Math.max(t.right,i.width+14):"left"===n?t.left=Math.max(t.left,i.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+i.height+4):t.bottom=Math.max(t.bottom,38+i.height+4))}function _a(e,n){const o={theme:n.theme,position:n.position||"right",totalWidth:n.size[0],totalHeight:n.size[1],margin:n.margin,hasTitle:n.hasTitle,legendLayout:n.legendLayout,idPrefix:n.idPrefix};return k(e)?function(e){if(0===(n=e.legendGroups,n.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var n;const o=Vn(e),i="top"===e.position||"bottom"===e.position,r=e.theme.colors.grid||e.theme.colors.textSecondary;let s,a;"left"===e.position?(s=Math.max(4,e.margin.left-o.width-10),a=e.margin.top):"top"===e.position?(s=e.margin.left,a=e.hasTitle?32:8):"bottom"===e.position?(s=e.margin.left,a=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-o.height-2)):(s=Math.min(e.totalWidth-o.width-4,e.totalWidth-e.margin.right+10),a=e.margin.top);const l=o.groups.flatMap((n,s)=>{var a;const{group:l}=n,c=null!==(a=l.type)&&void 0!==a?a:"fill",u=[];if(l.label&&u.push(t.jsx("text",i?{transform:`translate(${n.x},${n.y}) rotate(90)`,textAnchor:"start",fontSize:Hn(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:l.label}:{x:n.x,y:n.y+Hn(e.theme),fontSize:Hn(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:l.label},"legend-group-label-"+s)),u.push(...n.items.map((i,r)=>{const a=l.items[r],u=l.styleFn(a,r),d="function"==typeof c?c(a):"line"===c?t.jsx("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:u}):t.jsx("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:u});return t.jsxs("g",{transform:`translate(${n.x+n.itemOffsetX+i.x},${n.y+n.itemOffsetY+i.y})`,children:[d,t.jsx("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:Hn(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${s}-${r}`)})),!i&&o.groups.length-1>s)u.push(t.jsx("line",{x1:0,y1:n.y+n.height-6,x2:o.width,y2:n.y+n.height-6,stroke:r},"legend-group-separator-"+s));else if(i&&o.groups.length-1>s){const e=n.x+n.width+6;u.push(t.jsx("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:r},"legend-group-separator-"+s))}return u});return t.jsx("g",{className:"semiotic-legend",transform:`translate(${s},${a})`,"data-orientation":i?"horizontal":"vertical",children:l})}(Object.assign(Object.assign({},o),{legendGroups:e.legendGroups})):w(e)?function(e){const n=Un(e),o="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=e.gradient.format||(t=>Math.round(100*t)/100+"");let s,a;"left"===e.position?(s=Math.max(4,e.margin.left-n.width-10),a=e.margin.top):"top"===e.position?(s=e.margin.left,a=e.hasTitle?32:8):"bottom"===e.position?(s=e.margin.left,a=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-n.height-2)):(s=Math.min(e.totalWidth-n.width-4,e.totalWidth-e.margin.right+10),a=e.margin.top);const l=Array.from({length:17},(n,i)=>{const r=i/16;return t.jsx("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(o?e.gradient.domain[0]+r*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-r*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(o){const o=12,c=e.gradient.label?0:void 0,u=e.gradient.label?8:0;return t.jsxs("g",{className:"semiotic-legend",transform:`translate(${s},${a})`,children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),e.gradient.label&&t.jsx("text",{x:n.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),t.jsx("rect",{x:0,y:u,width:n.width,height:o,fill:`url(#${i})`,rx:2}),t.jsx("text",{x:0,y:u+o+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])}),t.jsx("text",{x:n.width,y:u+o+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return t.jsxs("g",{className:"semiotic-legend",transform:`translate(${s},${a+(e.gradient.label?12:0)})`,children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),e.gradient.label&&t.jsx("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])}),t.jsx("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])})]})}(Object.assign(Object.assign({},o),{gradient:e.gradient})):null}function Pa(t){return Math.round(100*t)/100+""}function Oa(e,n){const o=Yn(n.theme),i=n.idPrefix?n.idPrefix+"-":"",r="string"==typeof n.title?n.title:void 0,s=r?i+"semiotic-title":void 0,a=n.description?i+"semiotic-desc":void 0,l=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:n.className,width:n.width,height:n.height,role:"img","aria-labelledby":l,style:{fontFamily:o.fontFamily},children:[r&&t.jsx("title",{id:s,children:r}),n.description&&t.jsx("desc",{id:a,children:n.description}),n.defs&&t.jsx("defs",{children:n.defs}),n.background&&"transparent"!==n.background&&t.jsx("rect",{x:0,y:0,width:n.width,height:n.height,fill:n.background}),t.jsx("g",{id:i+"data-area",transform:n.innerTransform,children:e}),r&&t.jsx("text",{id:i+"chart-title",x:n.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:r}),n.legend&&t.jsx("g",{id:i+"legend",children:n.legend}),n.outerElements]})}function Ta(e,n){var o,i,r,s,a,l,c,u;const d=In(e.theme),h=e.size||[500,300],f=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),g=si(e.data),y=e.showLegend?Qn(g,e.colorAccessor||e.groupAccessor):[],p=e.legendPosition;k(e.legend)||w(e.legend)?Ma(f,{legend:e.legend,theme:d,position:p||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&y.length>0&&ja(f,{categories:y,theme:d,position:p||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout});const x=h[0]-f.left-f.right,b=h[1]-f.top-f.bottom,A="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),S=e.colorScheme||d.colors.categorical,j={chartType:e.chartType,windowSize:null!==(o=e.windowSize)&&void 0!==o?o:200,windowMode:null!==(i=e.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:A&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(s=e.extentPadding)&&void 0!==s?s:.1,xAccessor:A?void 0:e.xAccessor,yAccessor:A?void 0:e.yAccessor,timeAccessor:A?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:S,barColors:e.barColors},M=new Et(j);if(e.data&&M.ingest({inserts:g,bounded:!0}),M.computeScene({width:x,height:b}),!M.scales||0===M.scene.length)return n&&(n.evidence=vn({frameType:"xy",width:h[0],height:h[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:M.scales?[]:["NO_SCALES"]})),v.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${f.left},${f.top})`,idPrefix:e._idPrefix}));n&&(n.evidence=vn({frameType:"xy",width:h[0],height:h[1],marks:M.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:mn(null===(l=null===(a=M.scales.x)||void 0===a?void 0:a.domain)||void 0===l?void 0:l.call(a)),yDomain:mn(null===(u=null===(c=M.scales.y)||void 0===c?void 0:c.domain)||void 0===u?void 0:u.call(c)),legendItems:y.length>0?y.length:void 0}));const _=e._idPrefix,P=e.showGrid?function(e,n,o,i){const{grid:r}=Yn(o),s=i?i+"-":"",a=e.x.ticks(5),l=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,i)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:n.height,stroke:r,strokeWidth:.5},"gx-"+i)}),l.map((o,i)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:n.width,y2:s,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(M.scales,{width:x,height:b},d,_):null,O=M.scene.map((t,e)=>_n(t,e,_)).filter(Boolean),T=!1!==e.showAxes?function(e,n,o,i,r){var s,a,l,c;const u=Yn(i),d=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||Pa)(t)})),h=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||Pa)(t)}));return t.jsxs("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:u.border,strokeWidth:1}),d.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:u.border,strokeWidth:1}),h.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+n)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:n.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(l=o.margin)||void 0===l?void 0:l.left)&&void 0!==c?c:40)}, ${n.height/2})`,children:o.yLabel})]})}(M.scales,{width:x,height:b},e,d,_):null,$=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:M.scales.x,y:M.scales.y},layout:{width:x,height:b},theme:d,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:_}):null,L=e.svgPreRenderers&&M.scales?e.svgPreRenderers.map((e,n)=>{try{return t.jsx(m.Fragment,{children:e(M.scene,M.scales,{width:x,height:b})},"pre-"+n)}catch(t){return null}}).filter(Boolean):null,C=e.showLegend?0===y.length?null:Zn({categories:y,colorScheme:e.colorScheme,theme:d,position:e.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,E=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:d,position:e.legendPosition||"right",size:h,margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||C,R=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,L,P,O,T,$,e.foregroundGraphics]});return v.renderToStaticMarkup(Oa(R,{width:h[0],height:h[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:d,innerTransform:`translate(${f.left},${f.top})`,legend:E,idPrefix:e._idPrefix}))}function $a(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const La=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ca(e,n){var o,i,s,a,l;const c=In(e.theme),u=e.chartType||"force",d=()=>vn({frameType:"network",width:h[0],height:h[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),h=e.size||[500,500],f=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),g=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const o=si(e.nodes||[]);if(o.length>0)return Qn(o,t);const i=Array.isArray(e.edges)?si(e.edges):[];if(0===i.length)return[];const r=$a(e.sourceAccessor,"source"),s=$a(e.targetAccessor,"target");return Qn(Array.from(new Set(i.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),t)})():[],y=e.legendPosition;k(e.legend)||w(e.legend)?Ma(f,{legend:e.legend,theme:c,position:y||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&g.length>0&&ja(f,{categories:g,theme:c,position:y||"right",size:h,hasTitle:!!e.title,legendLayout:e.legendLayout});const p=h[0]-f.left-f.right,x=h[1]-f.top-f.bottom,b=function(t){return Qe[t]}(u);if(!b)throw Error(`No layout plugin found for chart type: "${u}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const A={chartType:u,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||c.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let S,j;if(La.has(u)){const t=e.data||e.edges;if(!t||Array.isArray(t))return n&&(n.evidence=d()),v.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:c,innerTransform:`translate(${f.left},${f.top})`,idPrefix:e._idPrefix}));A.__hierarchyRoot=t,S=[],j=[]}else{const t=si(e.nodes||[]),o=Array.isArray(e.edges)?si(e.edges):[];if(0===t.length&&0===o.length)return n&&(n.evidence=d()),v.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:c,innerTransform:`translate(${f.left},${f.top})`,idPrefix:e._idPrefix}));if(j=function(t,e){const n=$a(e.sourceAccessor,"source"),o=$a(e.targetAccessor,"target"),i=$a(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:o(t)+"",value:Number(i(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,A),0===t.length&&j.length>0){const t=new Set;for(const e of j){const n=Sa(e.source),o=Sa(e.target);n&&t.add(n),o&&t.add(o)}S=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else S=function(t,e){const n=$a(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:n(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,A)}let M=[],_=[],P=[],O=null;if(A.customNetworkLayout){const t=Ke(A.colorScheme,c.colors.categorical,W),e=Je(t),n={nodes:S,edges:j,dimensions:{width:p,height:x,plot:{x:0,y:0,width:p,height:x}},theme:{semantic:c.colors,categorical:[...t]},resolveColor:e,config:null!==(o=A.layoutConfig)&&void 0!==o?o:{}},r=A.customNetworkLayout(n);M=null!==(i=r.sceneNodes)&&void 0!==i?i:[],_=null!==(s=r.sceneEdges)&&void 0!==s?s:[],P=null!==(a=r.labels)&&void 0!==a?a:[],O=null!==(l=r.overlays)&&void 0!==l?l:null}else{b.computeLayout(S,j,A,[p,x]);const t=b.buildScene(S,j,A,[p,x]);M=t.sceneNodes,_=t.sceneEdges,P=t.labels}const T=Yn(c);for(const t of P)t.fill||(t.fill=T.text);n&&(n.evidence=vn({frameType:"network",width:h[0],height:h[1],marks:[...M.map(t=>{var e;return{type:"node:"+(null!==(e=t.type)&&void 0!==e?e:"node")}}),..._.map(t=>{var e;return{type:"edge:"+(null!==(e=t.type)&&void 0!==e?e:"edge")}})],title:e.title,description:e.description,annotations:e.annotations,nodeCount:M.length,edgeCount:_.length}));const $=_.map((e,n)=>function(e,n){switch(e.type){case"line":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const o=e;return t.jsx("path",{d:o.pathD,fill:Sn(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=e;return t.jsx("path",{d:o.pathD,fill:Sn(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=e;return t.jsx("path",{d:o.pathD,fill:Sn(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),L=M.map((e,n)=>function(e,n){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Sn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Sn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=e,i=r.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(An)||"";return t.jsx("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:Sn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}case"symbol":{const o=e,i=jt(o.symbolType,o.size,o.path);return t.jsx("path",{d:i,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?Sn(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-symbol-"+n)}default:return null}}(e,n)).filter(Boolean),C=P.map((e,n)=>function(e,n){return t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean),E=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:p,height:x},theme:c,idPrefix:e._idPrefix}):null,R=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const o=Qn(S.length>0?S.map(t=>t.data||{id:t.id}):Array.from(new Set(j.flatMap(t=>[Sa(t.source),Sa(t.target)]).filter(Boolean))).map(t=>({id:t})),t);return 0===o.length?null:Zn({categories:o,colorScheme:e.colorScheme,theme:c,position:e.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout})})():null,z=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:c,position:e.legendPosition||"right",size:h,margin:f,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||R,D=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,$,L,C,E,e.foregroundGraphics,O]});return v.renderToStaticMarkup(Oa(D,{width:h[0],height:h[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:c,innerTransform:`translate(${f.left},${f.top})`,legend:z,idPrefix:e._idPrefix}))}function Ea(e,n){var o,i,r,s,a,l,c,u,d;const h=In(e.theme),f=e.size||[500,400],g=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),y=si(e.data),p=e.showLegend?Qn(y,e.colorAccessor||e.stackBy||e.groupBy):[],x=e.legendPosition;k(e.legend)||w(e.legend)?Ma(g,{legend:e.legend,theme:h,position:x||"right",size:f,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&p.length>0&&ja(g,{categories:p,theme:h,position:x||"right",size:f,hasTitle:!!e.title,legendLayout:e.legendLayout});const b=f[0]-g.left-g.right,A=f[1]-g.top-g.bottom,S=e.projection||"vertical",j="radial"===S,M={chartType:e.chartType,windowSize:null!==(o=e.windowSize)&&void 0!==o?o:1e4,windowMode:null!==(i=e.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:S,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||h.colors.categorical,barColors:e.barColors},_=new sn(M);if(e.data&&_.ingest({inserts:y,bounded:!0}),_.computeScene({width:b,height:A}),!_.scales||0===_.scene.length)return n&&(n.evidence=vn({frameType:"ordinal",width:f[0],height:f[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:_.scales?[]:["NO_SCALES"]})),v.renderToStaticMarkup(Oa(null,{width:f[0],height:f[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:h,innerTransform:`translate(${g.left},${g.top})`,idPrefix:e._idPrefix}));if(n){const t=null===(a=null===(s=_.scales.o)||void 0===s?void 0:s.domain)||void 0===a?void 0:a.call(s);n.evidence=vn({frameType:"ordinal",width:f[0],height:f[1],marks:_.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:mn(null===(c=null===(l=_.scales.r)||void 0===l?void 0:l.domain)||void 0===c?void 0:c.call(l)),categories:Array.isArray(t)?t.map(String):void 0})}const P=e._idPrefix,O=e.showGrid?function(e,n,o,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=Yn(o),a=i?i+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t.jsx("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t.jsx("line",{x1:0,y1:i,x2:n.width,y2:i,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t.jsx("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(_,{width:b,height:A},h,P):null,T=_.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let $=null;if(T){const n=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;n.length>t;t++)o=31*o+n.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of _.scene)"rect"===t.type&&(null===(u=t.datum)||void 0===u?void 0:u.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");$=Array.from(o).map((e,o)=>function(e){const{id:n,background:o="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:s=6,angle:a=45}=e,l=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:n,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:l,height:l,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:l,stroke:i,strokeWidth:r}),t.jsx("line",{x1:s,y1:0,x2:s,y2:l,stroke:i,strokeWidth:r})]},n)}({id:`funnel-hatch-${n}-${o}`,background:e,stroke:"transparent"===h.colors.background?"#fff":h.colors.background,lineWidth:1.5,spacing:5,angle:45}));const i=new Map;Array.from(o).forEach((t,e)=>i.set(t,`funnel-hatch-${n}-${e}`));for(const t of _.scene)if("rect"===t.type&&(null===(d=t.datum)||void 0===d?void 0:d.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${i.get(e)})`})}}const L=_.scene.map((t,e)=>Pn(t,e,P)).filter(Boolean),C=!1!==e.showAxes?function(e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=Yn(i),p="vertical"===g.projection,m=o.categoryFormat||o.oFormat,v=o.valueFormat||o.rFormat,x=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),w=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(v||Pa)(t)}));return t.jsxs("g",p?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:y.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),x&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:x}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:y.border,strokeWidth:1}),w.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+n)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:n.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(l=o.margin)||void 0===l?void 0:l.left)&&void 0!==c?c:40)}, ${n.height/2})`,children:b})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:y.border,strokeWidth:1}),w.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:y.border,strokeWidth:1}),k.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+n)),x&&t.jsx("text",{x:15-(null!==(d=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==d?d:40),y:n.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(f=null===(h=o.margin)||void 0===h?void 0:h.left)&&void 0!==f?f:40)}, ${n.height/2})`,children:x})]})}(_,{width:b,height:A},e,h,P):null,E=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{r:_.scales.r,y:"vertical"===_.scales.projection?_.scales.r:void 0},layout:{width:b,height:A},theme:h,projection:S,idPrefix:P}):null,R=e.showLegend?0===p.length?null:Zn({categories:p,colorScheme:e.colorScheme,theme:h,position:e.legendPosition||"right",totalWidth:f[0],totalHeight:f[1],margin:g,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,z=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:h,position:e.legendPosition||"right",size:f,margin:g,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||R,D=j?g.left+b/2:g.left,N=j?g.top+A/2:g.top,F=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,O,L,C,E,e.foregroundGraphics]});return v.renderToStaticMarkup(Oa(F,{width:f[0],height:f[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:h,innerTransform:`translate(${D},${N})`,legend:z,defs:$,idPrefix:e._idPrefix}))}function Ra(e,n){var o,i,r,s,a,l,c,u,d,h;const f=In(e.theme),g=e.size||[e.width||600,e.height||400],y=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),p=Array.isArray(e.areas)?si(e.areas):e.areas,x=si(e.points),b=si(e.lines),A=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return Qn(x.length>0?x:Array.isArray(p)&&p.length>0?"string"==typeof t?p.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):p:[],t)})():[],S=e.legendPosition;k(e.legend)||w(e.legend)?Ma(y,{legend:e.legend,theme:f,position:S||"right",size:g,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&A.length>0&&ja(y,{categories:A,theme:f,position:S||"right",size:g,hasTitle:!!e.title,legendLayout:e.legendLayout});const j=g[0]-(null!==(o=y.left)&&void 0!==o?o:0)-(null!==(i=y.right)&&void 0!==i?i:0),M=g[1]-(null!==(r=y.top)&&void 0!==r?r:0)-(null!==(s=y.bottom)&&void 0!==s?s:0),_=new yn({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(p){if("string"==typeof p)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${p}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${p}')\` before calling renderGeoToStaticSVG.`);_.setAreas(p)}if(e.points&&_.setPoints(x),e.lines&&_.setLines(b),_.computeScene({width:j,height:M}),n&&(n.evidence=vn({frameType:"geo",width:g[0],height:g[1],marks:_.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:A.length>0?A.length:void 0})),0===_.scene.length){const n=e.backgroundGraphics||e.foregroundGraphics||e.annotations?t.jsxs(t.Fragment,{children:[e.backgroundGraphics,e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:(null===(a=_.scales)||void 0===a?void 0:a.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:j,height:M},theme:f,idPrefix:e._idPrefix}):null,e.foregroundGraphics]}):null;return v.renderToStaticMarkup(Oa(n,{width:g[0],height:g[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:f,innerTransform:`translate(${null!==(l=y.left)&&void 0!==l?l:0},${null!==(c=y.top)&&void 0!==c?c:0})`,idPrefix:e._idPrefix}))}const P=_.scene.map((e,n)=>function(e,n){var o,i,r,s,a,l;switch(e.type){case"geoarea":{const r=e;return r.pathData?t.jsx("path",{d:r.pathData,fill:Sn(r.style.fill,"#e0e0e0"),fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(i=r._decayOpacity)&&void 0!==i?i:1},"geoarea-"+n):null}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Sn(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const o=e;if(2>o.path.length)return null;const i="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(e,n)).filter(Boolean),O=e.annotations?Fo({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:(null===(u=_.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:j,height:M},theme:f,idPrefix:e._idPrefix}):null,T=e.showLegend?0===A.length?null:Zn({categories:A,colorScheme:e.colorScheme,theme:f,position:e.legendPosition||"right",totalWidth:g[0],totalHeight:g[1],margin:y,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,$=m.isValidElement(e.legend)?e.legend:_a(e.legend,{theme:f,position:e.legendPosition||"right",size:g,margin:y,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||T,L=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,P,O,e.foregroundGraphics]});return v.renderToStaticMarkup(Oa(L,{width:g[0],height:g[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:f,innerTransform:`translate(${null!==(d=y.left)&&void 0!==d?d:0},${null!==(h=y.top)&&void 0!==h?h:0})`,legend:$,idPrefix:e._idPrefix}))}function za(t,e){switch(t){case"xy":return Ta(e);case"ordinal":return Ea(e);case"network":return Ca(e);case"geo":return Ra(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}const Da=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Na(t,e,n){return Fa(t,e).svg}function Fa(e,n,o,i){var r;const{data:s,width:a=600,height:l=400,theme:c,title:u,description:d,showLegend:h,showGrid:f,background:g,className:y,annotations:p,margin:m,colorScheme:x,colorBy:b,legendPosition:k}=n,w=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);o.length>i;i++)0>e.indexOf(o[i])&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(n,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),A=[a,l],S=w.frameProps||{},j=function(t,e){const n={};for(const o of e)void 0!==t[o]&&(n[o]=t[o]);return n}(w,Da),M=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},S),j),{theme:c,title:u,description:d,showLegend:h,showGrid:f,background:g,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==k&&{legendPosition:k}),{_idPrefix:w._idPrefix}),_=Aa[e];if(!_)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const P=_.buildProps(s,b,x,M,w);let O=(0,{xy:Ta,ordinal:Ea,network:Ca,geo:Ra}[_.frameType])(P,i);if("GaugeChart"===e&&P.__gauge){const e=P.__gauge,n=M.margin||{top:20,right:20,bottom:30,left:40},o=(a||300)-n.left-n.right,i=(l||300)-n.top-n.bottom,s=Math.min(o,i)/2*.85,u=n.left+o/2,d=n.top+i/2,h=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(h-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,g=In(c).colors.text,y=v.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:d,x2:u+s*Math.cos(f),y2:d+s*Math.sin(f),stroke:g,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:d,r:4,fill:g})]}));O=O.replace("</svg>",y+"</svg>")}return{svg:O,frameType:_.frameType}}function Wa(t,e,n,o={}){const{stepSize:i,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=o,f=n.width||600,g=n.height||400,y=In(n.theme),p=Object.assign(Object.assign(Object.assign({},n),a&&{xExtent:a}),l&&{yExtent:l});if(!e||0===e.length)return[];const m=i||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const x=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-b.left-b.right,w=g-b.top-b.bottom,A=[];if(x)for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical},h&&{decay:h}),l=new sn(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(Ya(l.scene,f,g,y,p))}else for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:l,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange},h&&{decay:h}),c>0&&{transition:{duration:c*(1e3/u),easing:d}}),x=new Et(m);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:w}),0===x.scene.length)continue;const b=x.scales?{y:x.scales.y}:void 0;if(A.push(Ia(x.scene,f,g,y,p,b)),c>0&&o>0&&x.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/c*t),A.push(Ia(x.scene,f,g,y,p,b))}}return A}function Ba(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function Ia(e,n,o,i,r,s){const a=Yn(i),l=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),c=n-l.left-l.right,u=o-l.top-l.bottom,d=Ba(r,i),h=e.map((t,e)=>_n(t,e)).filter(Boolean),f=function(e,n,o,i,r,s){var a;if(!e||0===e.length)return null;const l=Yn(i),c=[];for(let i=0;e.length>i;i++){const u=e[i];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(r){const[t,n]=r,i=n-t;if(0===i)continue;e=o-(u.value-t)/i*o}if(null==e)continue;const d=u.color||l.primary,h=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";c.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:n,y2:e,stroke:d,strokeWidth:h,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?n/2:n-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:l.tickSize,fill:d,fontFamily:l.fontFamily,children:u.label})]},"ann-"+i))}}return c.length>0?t.jsx(t.Fragment,{children:c}):null}(r.annotations,c,u,i,r.yExtent,null==s?void 0:s.y),g="string"==typeof r.title?r.title:void 0,y="string"==typeof r.description?r.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:o,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily},children:[g&&t.jsx("title",{id:p,children:g}),y&&t.jsx("desc",{id:m,children:y}),d&&t.jsx("rect",{x:0,y:0,width:n,height:o,fill:d}),t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[f,h]}),g&&t.jsx("text",{x:n/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return v.renderToStaticMarkup(b)}function Ya(e,n,o,i,r){const s=Yn(i),a=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),l="radial"===r.projection,c=l?a.left+(n-a.left-a.right)/2:a.left,u=l?a.top+(o-a.top-a.bottom)/2:a.top,d=Ba(r,i),h=e.map((t,e)=>Pn(t,e)).filter(Boolean),f="string"==typeof r.title?r.title:void 0,g="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:o,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:y,children:f}),g&&t.jsx("desc",{id:p,children:g}),d&&t.jsx("rect",{x:0,y:0,width:n,height:o,fill:d}),t.jsx("g",{transform:`translate(${c},${u})`,children:h}),f&&t.jsx("text",{x:n/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return v.renderToStaticMarkup(x)}exports.generateFrameSVGs=Wa,exports.generateFrameSequence=function(t,e,n={}){return e.map(e=>{try{return Na(t,Object.assign(Object.assign({},n),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})},exports.renderChart=Na,exports.renderChartWithEvidence=function(t,e,n){var o;const i={},{svg:r,frameType:s}=Fa(t,e,0,i),a=null!==(o=i.evidence)&&void 0!==o?o:vn({frameType:s,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return a.component=t,{svg:r,evidence:a}},exports.renderDashboard=function(e,n={}){var o;const{title:i,subtitle:r,theme:s,width:a=1200,height:l,layout:c={},background:u}=n,d=Yn(In(s)),h=c.columns||2,f=null!==(o=c.gap)&&void 0!==o?o:16;let g=0;i&&(g+=30),r&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-f-f*(h-1))/h),p=[];let m=0,x=g+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,h),n=t.props.height||300;m+e>h&&(x+=b+f,m=0,b=0),p.push({chart:t,x:f/2+m*(y+f),y:x,w:y*e+f*(e-1),h:n}),b=Math.max(b,n),m+=e}const k=l||x+b+f,w=p.map((e,n)=>{const{chart:o,x:i,y:r,w:a,h:l}=e,c=Object.assign(Object.assign({},o.props),{width:a,height:l,theme:s,_idPrefix:"chart-"+n});let u;return u=o.component?Na(o.component,c):o.frameType?za(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${l}"></svg>`,t.jsx("g",{transform:`translate(${i},${r})`,children:t.jsx("foreignObject",{width:a,height:l,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),A=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":i||"Dashboard",style:{fontFamily:d.fontFamily},children:[i&&t.jsx("title",{children:i}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),i&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:d.titleSize+4,fontWeight:"bold",fill:d.text,fontFamily:d.fontFamily,children:i}),r&&t.jsx("text",{x:a/2,y:i?46:20,textAnchor:"middle",fontSize:d.labelSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:r}),w]});return v.renderToStaticMarkup(A)},exports.renderGeoToStaticSVG=function(t){return Ra(t)},exports.renderNetworkToStaticSVG=function(t){return Ca(t)},exports.renderOrdinalToStaticSVG=function(t){return Ea(t)},exports.renderToAnimatedGif=function(t,e,n){return b(this,arguments,void 0,function*(t,e,n,o={}){var i,r,s,a,l,c,u,d,h,f,g,y,p,m,v,x;const{fps:b=12,loop:k=!0,scale:w=1,background:A}=o,S=n.height||400,j=Math.round((n.width||600)*w),M=Math.round(S*w),_=Wa(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,o);if(0===_.length)throw Error("No frames generated — check that data is not empty");let P,O,T,$;try{const t="sharp",e=yield import(t);P=null!==(i=e.default)&&void 0!==i?i:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);O=null!==(a=null!==(r=e.GIFEncoder)&&void 0!==r?r:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(c=null===(l=e.default)||void 0===l?void 0:l.default)||void 0===c?void 0:c.GIFEncoder,T=null!==(h=null!==(u=e.quantize)&&void 0!==u?u:null===(d=e.default)||void 0===d?void 0:d.quantize)&&void 0!==h?h:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,$=null!==(m=null!==(y=e.applyPalette)&&void 0!==y?y:null===(p=e.default)||void 0===p?void 0:p.applyPalette)&&void 0!==m?m:null===(x=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===x?void 0:x.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const L=Math.round(1e3/b),C=O();for(let t=0;_.length>t;t++){const e=_[t],n=yield P(Buffer.from(e),{density:72*w}).resize(j,M).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),i=T(o,256),r=$(o,i);C.writeFrame(r,j,M,{palette:i,delay:L,repeat:k?0:-1})}return C.finish(),Buffer.from(C.bytes())})},exports.renderToImage=function(t,e){return b(this,arguments,void 0,function*(t,e,n={}){var o,i,r;const{format:s="png",scale:a=1,background:l}=n;let c,u;c=["xy","ordinal","network","geo"].includes(t)?za(t,e):Na(t,e),l&&(c=c.replace(/<svg /,`<svg style="background:${l}" `));try{const t="sharp",e=yield import(t);u=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const d=e.width||(null===(i=e.size)||void 0===i?void 0:i[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*a}).resize(Math.round(d*a),Math.round(h*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=za,exports.renderXYToStaticSVG=function(t){return Ta(t)},exports.resolveTheme=In,exports.themeStyles=Yn;
1
+ "use strict";var t,e=Object.create,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(t,e,r,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let c of n(e))s.call(t,c)||c===r||i(t,c,{get:()=>e[c],enumerable:!(a=o(e,c))||a.enumerable});return t},c=(t,o,n)=>(n=null!=t?e(r(t)):{},a(!o&&t&&t.__esModule?n:i(n,"default",{value:t,enumerable:!0}),t)),l={};((t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})})(l,{generateFrameSVGs:()=>Ul,generateFrameSequence:()=>Ql,generatePhysicsFrameSVGs:()=>tu,renderChart:()=>ql,renderChartWithEvidence:()=>Xl,renderDashboard:()=>Hl,renderGeoToStaticSVG:()=>Wl,renderNetworkToStaticSVG:()=>Ol,renderOrdinalToStaticSVG:()=>Fl,renderPhysicsToAnimatedGif:()=>ru,renderToAnimatedGif:()=>nu,renderToImage:()=>Vl,renderToStaticSVG:()=>Il,renderXYToStaticSVG:()=>Bl,resolveTheme:()=>to,themeStyles:()=>eo}),module.exports=(t=l,a(i({},"__esModule",{value:!0}),t));var u=c(require("react-dom/server")),h=c(require("react")),d=require("d3-scale");function f(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function p(t,e,i){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function y(t){const e=t.map(f),i=e.length-1;return t=>{if(0>=t){const[t,i,o]=e[0];return p(t,i,o)}if(t>=1){const[t,o,n]=e[i];return p(t,o,n)}const o=t*i,n=Math.floor(o),r=o-n,[s,a,c]=e[n],[l,u,h]=e[n+1];return p(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(h-c)*r))}}var g=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=y(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),x=y(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),b=y(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),v=y(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=y(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),k=y(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),S=y(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=y(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),M=y(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),_=y(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),P=y(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),T=y(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),R={blues:m,reds:x,greens:b,viridis:S,oranges:v,purples:w,greys:k,plasma:A,inferno:M,magma:_,cividis:P,turbo:T};function L(t){return t&&R[t]||m}y(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),y(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),y(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),y(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),y(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var C={category10:g,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...R},$=g,j=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],z=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function E(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||z.has(e)}(o)?i(o):o}const o=t?.[e]+"";return i?i(o):$[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o))%$.length]}function D(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const i=t[e];return"string"==typeof i&&i.length>0?i:void 0}function N(t,e,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const t=i;return e=>D(t,e)??"#999"}const o=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),n=o.every(t=>!isNaN(Number(t)));if(Array.isArray(i))return(0,d.scaleOrdinal)().domain(o).range(i).unknown("#999");const r=C[i]||C.category10;if(n&&"function"==typeof r){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:$;return(0,d.scaleOrdinal)().domain(o).range(t).unknown("#999")}}function I(t,e,i=[3,20],o){let n;if(n="function"==typeof e?e(t):t?.[e],!o)return n;const[r,s]=o,[a,c]=i;if(s===r)return(a+c)/2;let l=(n-r)/(s-r);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function B(t,e,i){return"function"==typeof t?t(i):i[t||e]}function F(t){return t instanceof Date?t.getTime():Number(t)}function O(t,e){return S(1===e?.5:t/(e-1))}function W(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>q(e(t))}function Y(t,e){const i=W(e??"value"),o=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=o?o(t):void 0;return{value:i(t),category:null==e?void 0:e+""}}}function q(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}}function X(t,e,i){const o=t.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(e,i):function(t,e,i){const o=null!=t.axis?i[t.axis]:null!=t.field?e[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const n=q(o);if(void 0===n)return!1;if(void 0!==t.gt&&t.gt>=n)return!1;if(void 0!==t.gte&&t.gte>n)return!1;if(void 0!==t.lt&&n>=t.lt)return!1;if(void 0!==t.lte&&n>t.lte)return!1;if(void 0!==t.within){const[e,i]=t.within;if(e>n||n>i)return!1}if(void 0!==t.outside){const[e,i]=t.outside;if(n>=e&&i>=n)return!1}return!0}(o,e,i))}function G(t,e,i){if(!e||0===e.length)return{};let o={};for(const n of e){if(!X(n,t,i))continue;const e="function"==typeof n.style?n.style(t,i):n.style;e&&(o={...o,...e})}return o}function V(t,e,i,o=t=>t){const n=t??(()=>({}));return e&&0!==e.length?(t,r)=>{const s=o(t),a={...n(t,r)};return Object.assign(a,G(s,e,i(s,r))),a}:n}function H(t,e,i){return t&&0!==t.length?(o,n)=>{const r=G(o,t,e(o,n)),s=i?i(o,n):void 0;return s?{...r,...s}:r}:i}function Z(t,e,i,o){if(!t||0===t.length)return o;const n=Y(e,i);return(e,i)=>{const r=e&&e.data||e,s=G(r,t,n(r)),a=o?o(e,i):void 0;return a?{...s,...a}:s}}function K(t,e,i,o){return H(t,function(t,e){const i=W(t),o=W(e);return(t,e)=>{const n=o(t);return{value:n,x:i(t),y:n,category:e}}}(e,i),o)}function U(t,e,i){const o=W(e);return H(t,(t,e)=>({value:o(t),category:e}),i)}var Q={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:n.lineStyle,...o,...n.styleRules&&{lineStyle:K(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.lineStyle||n.lineStyle)}})},J={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"area",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",y0Accessor:n.y0Accessor,groupAccessor:n.areaBy||e,colorAccessor:e,colorScheme:i,...o,...n.styleRules&&{lineStyle:K(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.lineStyle)}})},tt={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=n.xAccessor||"x",s=n.seriesAAccessor||"a",a=n.seriesBAccessor||"b",c=t=>F(B(r,"x",t)),l=t=>F(B(s,"a",t)),u=t=>F(B(a,"b",t)),h=n.seriesAColor||"var(--semiotic-danger, #dc2626)",d=n.seriesBColor||"var(--semiotic-info, #2563eb)",f=n.areaOpacity??.6,p=n.lineWidth??1.5,y=!1!==n.showLines,g=function(t,e,i,o){if(!t.length)return[];const n=t.filter(t=>Number.isFinite(e(t))).sort((t,i)=>e(t)-e(i)),r=[];let s=0,a=null,c=null,l=[];const u=(t,e)=>t>e?"A":e>t?"B":null,h=t=>`seg-${s}-${t}`,d=t=>r.push(t),f=(t,e)=>{d({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:h(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;n.length>t;t++){const r=n[t],p=e(r),y=i(r),g=o(r);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let t,e;if(l.length>0)t=l[0].x,e=l[0].y;else{const i=y-c.a-(g-c.b);if(0!==i){const o=Math.max(0,Math.min(1,(c.b-c.a)/i));t=c.x+o*(p-c.x),e=c.a+o*(y-c.a)}else t=c.x,e=c.a}d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:r})}for(const t of l)f(t,a??"A");return r}(Array.isArray(t)?t:[],c,l,u),m=[];if(y&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(c(t))).sort((t,e)=>c(t)-c(e));for(const t of e){const e=c(t),i=l(t),o=u(t);Number.isFinite(i)&&m.push({__x:e,__y:i,__diffSegment:"line-A"}),Number.isFinite(o)&&m.push({__x:e,__y:o,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...g,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(g.map(t=>t.__diffSegment))),areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?h:d,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:n.curve||"linear",...o}}},et={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=e||n.areaBy,s="string"==typeof r&&Array.isArray(t)?N(t,r,i):void 0;return{chartType:"stackedarea",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.areaBy,colorAccessor:r,colorScheme:i,normalize:n.normalize,stackOrder:n.stackOrder,lineStyle:null==n.areaOpacity?void 0:t=>{const e=null==r?void 0:E(t,r,s),i=n.showLine??!0;return{fill:n.color??e,stroke:i?n.stroke??e:"none",...i?{strokeWidth:n.strokeWidth??n.lineWidth??2}:{},fillOpacity:n.areaOpacity,...null==n.opacity?{}:{opacity:n.opacity}}},...o}}},it={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,colorScheme:i,...o,...n.styleRules&&{pointStyle:K(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.pointStyle)}})},ot={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=n.xCenter,s=n.yCenter,a=n.quadrants,c=n.centerlineStyle||{},l=!1!==n.showQuadrantLabels,u=n.quadrantLabelSize??12,d=c.stroke||"#999",f=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,y=h.createElement,g=a?[(t,e,i)=>{if(!e?.x||!e?.y)return null;const o=i.width,n=i.height,c=null!=r?e.x(r):o/2,g=null!=s?e.y(s):n/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(o,c)),x=Math.max(0,Math.min(n,g)),b=[{c:a.topLeft,x:0,y:0,w:m,h:x},{c:a.topRight,x:m,y:0,w:o-m,h:x},{c:a.bottomLeft,x:0,y:x,w:m,h:n-x},{c:a.bottomRight,x:m,y:x,w:o-m,h:n-x}],v=l?[y("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),y("text",{key:"ltr",x:o-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),y("text",{key:"lbl",x:8,y:n-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),y("text",{key:"lbr",x:o-8,y:n-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return y(h.Fragment,null,...b.map((t,e)=>t.w>0&&t.h>0?y("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),y("line",{key:"vc",x1:m,y1:0,x2:m,y2:n,stroke:d,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:o,y2:x,stroke:d,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange,colorScheme:i,pointStyle:n.pointStyle,...o,...g&&{svgPreRenderers:g}}}},nt={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const i=e.xAccessor||"x",o=e.yAccessor||"y",n=e.orderAccessor?[...t].sort((t,i)=>null==t||"object"!=typeof t?1:null==i||"object"!=typeof i?-1:F(B(e.orderAccessor,"order",t))-F(B(e.orderAccessor,"order",i))):t,r=new WeakMap;let s=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=F(B(i,"x",t)),n=F(B(o,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&s++}let a=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=F(B(i,"x",t)),n=F(B(o,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&r.set(t,{idx:a++,total:s})}return{data:n,orderMap:r}}(t,n),s=n.pointRadius??4;return{chartType:"line",data:r.data,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:i,lineStyle:n.lineStyle||{stroke:n.stroke||"#6366f1",strokeWidth:n.strokeWidth??s,opacity:n.opacity},pointStyle:t=>{const e=r.orderMap.get(t),i=e?.idx??0,o=e?.total??1;return{fill:o>0?O(i,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...o}}};function rt(t){return Math.max(0,Math.min(1,t))}function st(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const i=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){const t=[Number(i[1]),Number(i[2]),Number(i[3])];if(t.every(Number.isFinite))return t}return null}function at(t,e,i){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function ct(t,e){const i=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:rt(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===i.length)return"#999999";if(1===i.length)return i[0].color;const o=rt(e);if(i[0].offset>=o)return i[0].color;if(o>=i[i.length-1].offset)return i[i.length-1].color;for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1];if(e.offset>o||o>n.offset)continue;const r=n.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=st(e.color),c=st(n.color);if(!a||!c)return.5>s?e.color:n.color;const[l,u,h]=a,[d,f,p]=c;return at(l+(d-l)*s,u+(f-u)*s,h+(p-h)*s)}return i[i.length-1].color}function lt(t,e,i){return null==i?`${t}-${e}`:`${t}-${e}-${i}`}var ut={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,colorAccessor:e,colorScheme:i,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,...n.styleRules&&{pieceStyle:U(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},ht={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.stackBy,colorAccessor:e||n.stackBy,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",normalize:n.normalize,oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,...n.styleRules&&{pieceStyle:U(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},dt={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"clusterbar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",groupBy:n.groupBy,colorAccessor:e||n.groupBy,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,...n.styleRules&&{pieceStyle:U(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},ft={frameType:"ordinal",buildProps:(t,e,i,o,n)=>{const r=n.min??0,s=n.max??100,a=n.sweep??240,c=n.arcWidth??.3,l=180+(360-a)/2,u=n.thresholds||[{value:s,color:n.color||"#4e79a7"}],h=o.gradientFill,d=function(t){const{min:e,max:i,value:o,thresholds:n,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,h=i-e||1,d=(Math.max(e,Math.min(i,o))-e)/h;let f=n&&n.length>0?[...n].sort((t,e)=>t.value-e.value):[{value:i,color:r||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(i,t.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?d:1,e=lt("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;i>e;e++)o.push(ct(l.colorStops,t*(e+.5)/i));const n=lt("fill",0);y.push({category:n,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(n,{fill:o[0]||s})}}else{let t=e;for(let i=0;f.length>i;i++){const o=f[i],n=(o.value-t)/h,r=(t-e)/h,c=(o.value-e)/h,l=Math.max(0,(a?Math.min(d,c):c)-r),u=a?Math.max(0,n-l):0;if(l>0){const t=lt("fill",i);y.push({category:t,value:l,_zone:o.label||"Zone "+(i+1),_isFill:!0}),g.set(t,{fill:o.color})}if(u>0){const t=lt("bg",i);y.push({category:t,value:u,_zone:o.label||"Zone "+(i+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=o.value}}if(c&&n&&n.length>0)for(const t of n)t.value>e&&i>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>g.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:r,max:s,value:n.value,thresholds:u,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:!1!==n.fillZones,showScaleLabels:!1!==n.showScaleLabels,gradientFill:h&&"object"==typeof h&&"colorStops"in h?h:void 0}),f=o.margin||{top:20,right:20,bottom:30,left:40},[p,y]=o.size||[300,300];return{chartType:"donut",data:d.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(f.left||0)-(f.right||0),y-(f.top||0)-(f.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:d.pieceStyle,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o,showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...d.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:n.value,startAngleDeg:l,thresholds:u}}}},pt=require("d3-scale");function yt(t){let e=1/0,i=-1/0;for(const o of t)e>o&&(e=o),o>i&&(i=o);return[e,i]}function gt(t,e=-1/0){let i=e;for(const e of t)e>i&&(i=e);return i}function mt(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function xt(t,e,i){const o=e.incoming[t.id],n=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:i.get(t.id).targetSide});for(const t of n)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:i.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>t.time-e.time||(s[t.kind]??99)-(s[e.kind]??99))},c=r.length?function(t,e=1/0){let i=e;for(const e of t)i>e&&(i=e);return i}(r.map(t=>t.time)):null,l=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,h=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),d=new Map;for(let t=1;h.length>t;t++)d.set(h[t],h[t-1]);const f=t=>{const e=d.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const p=[];let y=0,g=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let i=e-("top"===t.side?y:g);if(i>0){const e="top"===t.side?"bot":"top",o=Math.min(i,"top"===e?y:g);if(o>0){const n=f(t.time);p.push({time:n,delta:-o,kind:"transfer-out",side:e}),p.push({time:n,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:g-=o,"top"===t.side?y+=o:g+=o,i-=o}i>0&&null!==u&&(p.push({time:u,delta:+i,kind:"create",side:t.side}),"top"===t.side?y+=i:g+=i)}"top"===t.side?y-=e:g-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:g+=e}r.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const t of r){if(k.push({t:t.time,topMass:m,botMass:x}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:x;S.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:x+=t.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:t.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let t=M;for(;k.length>t+1&&k[t+1].t===k[M].t;)t++;A.push(k[M]);for(let e=M+1;t>=e;e++){const t=A[A.length-1];k[e].topMass===t.topMass&&k[e].botMass===t.botMass||A.push(k[e])}M=t+1}const _=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of n)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let T=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===T||t.systemOutTime>T)&&(T=t.systemOutTime);if(A.length>0){const t=A[A.length-1],e=Math.max(null!=_?_:-1/0,null!=T?T:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&A.push({t:e,topMass:t.topMass,botMass:t.botMass});const i=A[0],o=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(o)&&i.t>o&&i.topMass+i.botMass>0&&A.unshift({t:o,topMass:i.topMass,botMass:i.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function bt(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function vt(t,e){return t.map(t=>({t:bt(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function wt(t,e,i){const o=t.value*i;if("out"===t.kind){const n=t.sideMassBefore*i;if("top"===t.side){const t=e-n;return[t,t+o]}const r=e+n;return[r-o,r]}const n=t.sideMassAfter*i;if("top"===t.side){const t=e-n;return[t,t+o]}const r=e+n;return[r-o,r]}function kt(t,e){let i=0;for(let o=0;e.length>o;o++)for(let n=o+1;e.length>n;n++){const r=e[o],s=e[n];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&i++)}return i}function St(t,e){let i=0;for(const o of e)i+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return i}function At(t,e){return 1e3*kt(t,e)+St(t,e)}function Mt(t,e){return{slots:t.map(t=>({peak:{...t.peak},occupants:t.occupants.slice()})),map:{...e}}}function _t(t,e,i){t.length>8||i.length>40?(function(t,e,i,o=6){const n=t.length;if(1>=n)return;let r=Mt(t,e),s=At(e,i);for(let a=0;o>a;a++){const o=Array(n).fill(0),a=Array(n).fill(0);for(const t of i){const i=e[t.source],n=e[t.target];o[i]+=n*(t.value||1),a[i]+=t.value||1,o[n]+=i*(t.value||1),a[n]+=t.value||1}const c=Array.from({length:n},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),l=c.map(e=>t[e]),u=new Map;c.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e);const h=At(e,i);if(s>h)s=h,r=Mt(t,e);else if(h===s)break}!function(t,e,i){t.length=0;for(const e of i.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(i.map))e[t]=i.map[t]}(t,e,r)}(t,e,i,6),function(t,e,i,o=6){const n=t.length;if(1>=n)return;let r=At(e,i);for(let s=0;o>s;s++){let o=!1;for(let s=0;n-1>s;s++){const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=At(e,i);if(r>a)r=a,o=!0;else{const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,i,6)):function(t,e,i){const o=t.length;if(1>=o)return;const n={...e},r=Object.keys(n),s=Array.from({length:o},(t,e)=>e),a=s.slice(),c={...n};let l=s.slice(),u=1/0;const h=()=>{for(const t of r)c[t]=a[n[t]];const t=At(c,i);u>t&&(u=t,l=s.slice())},d=(t,e)=>{const i=s[t],o=s[e];s[t]=o,s[e]=i,a[i]=e,a[o]=t};h();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(d(p%2==0?0:f[p],p),h(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(e=>t[e]),g=new Map;l.forEach((t,e)=>g.set(t,e));for(const t of Object.keys(e))e[t]=g.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,i)}function Pt(t,e,i,o,n){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=n,h={},d={};for(const e of t)h[e.id]=i[e.id].topPeak||0,d[e.id]=i[e.id].botPeak||0;const f="half"===u,p={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,i=Array.isArray(e.xExtent)?e.xExtent[1]:null;let n=null!=t&&Number.isFinite(t)?t:1/0,r=null!=i&&Number.isFinite(i)?i:-1/0;for(const t of o.outgoing[e.id]){n>t.startTime&&(n=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&n>t.systemInTime&&(n=t.systemInTime);const e=f?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=f?(t.startTime+t.endTime)/2:t.startTime;n>e&&(n=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}p[e.id]={start:Number.isFinite(n)?n:null,end:Number.isFinite(r)?r:null}}const y={},g=[];if("reuse"===c){const i=new Map;for(const e of t)i.set(e.id,0);const n=new Map;for(const e of t)n.set(e.id,0);for(const t of e)n.set(t.target,(n.get(t.target)??0)+1);const r=[];for(const e of t)0===(n.get(e.id)??0)&&r.push(e.id);for(;r.length;){const t=r.shift();for(const e of o.outgoing[t]??[]){const o=(i.get(t)??0)+1;o>(i.get(e.target)??0)&&i.set(e.target,o),n.set(e.target,n.get(e.target)-1),0===n.get(e.target)&&r.push(e.target)}}const s=[...t].filter(t=>null!==p[t.id].start).sort((t,e)=>{const o=i.get(t.id)??0,n=i.get(e.id)??0;return o!==n?o-n:p[t.id].start-p[e.id].start}),a=t.filter(t=>null===p[t.id].start);for(const t of[...s,...a]){const e=p[t.id];let i=-1;for(let t=0;g.length>t;t++){const o=g[t].occupants[g[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){i=t;break}}-1===i&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),i=g.length-1),g[i].occupants.push({id:t.id,end:e?.end??-1/0}),g[i].peak.topPeak=Math.max(g[i].peak.topPeak,h[t.id]),g[i].peak.botPeak=Math.max(g[i].peak.botPeak,d[t.id]),y[t.id]=i}}else t.forEach((t,e)=>{g.push({occupants:[{id:t.id,end:p[t.id]?.end??-1/0}],peak:{topPeak:h[t.id],botPeak:d[t.id]}}),y[t.id]=e});let m=null,x=null,b=null,v=null;const w=()=>{m=kt(y,e),b=St(y,e)},k=()=>{x=kt(y,e),v=St(y,e)};"crossing-min"===l?(w(),_t(g,y,e),k()):"inside-out"===l?(w(),function(t,e){const i=t.length;if(1>=i)return;const o=t=>t.peak.topPeak+t.peak.botPeak,n=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(i),s=Math.floor((i-1)/2);r[s]=n[0].idx;let a=s-1,c=s+1;for(let t=1;n.length>t;t++)t%2==1&&i>c||0>a?r[c++]=n[t].idx:r[a--]=n[t].idx;const l=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),_t(g,y,e),function(t,e,i){const o=t.length;if(1>=o)return;const n=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=At(e,i);for(const{slot:a}of n){const n=t.indexOf(a);if(0>n)continue;const c=r;if(n===c)continue;const l=t[n];t.splice(n,1),t.splice(c,0,l);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(c>n){for(let t=n+1;c>=t;t++)u.set(t,t-1);u.set(n,c)}else{for(let t=c;n>t;t++)u.set(t,t+1);u.set(n,c)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const h=At(e,i);if(h>s){const i=t[c];t.splice(c,1),t.splice(n,0,i);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(n>c){for(let t=c+1;n>=t;t++)r.set(t,t-1);r.set(c,n)}else{for(let t=n;c>t;t++)r.set(t,t+1);r.set(c,n)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=h}}(g,y,e),k());const S=g.map(t=>{const e=new Map;for(const o of t.occupants){const t=i[o.id];if(t)for(const i of t.samples){const t=e.get(i.t)||{top:0,bot:0};e.set(i.t,{top:Math.max(t.top,i.topMass),bot:Math.max(t.bot,i.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),A=(t,e)=>{let i={top:0,bot:0};for(const[o,n]of t){if(o>e)break;i=n}return i},M=[];for(let t=0;g.length-1>t;t++){const e=S[t],i=S[t+1],o=new Set([...e.map(t=>t[0]),...i.map(t=>t[0])]);let n=0;for(const t of o){const o=A(e,t),r=A(i,t);o.bot+r.top>n&&(n=o.bot+r.top)}M.push(n)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let t=1;g.length>t;t++)P+=M[t-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>r){const t=r/P;for(let e=0;_.length>e;e++)_[e]*=t}const T=0===g.length?0:g[0].peak.topPeak+M.reduce((t,e)=>t+e,0)+g[g.length-1].peak.botPeak,R={};for(const e of t)R[e.id]=_[y[e.id]];return{effectiveSlotsHeight:T,centerlines:R,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Tt(t){const{sx:e,sTop:i,sBot:o,tx:n,tTop:r,tBot:s,cp1X:a,cp2X:c}=t,l=(i+o)/2,u=(r+s)/2;return{pathD:[`M${e},${i}`,`C${a},${i} ${c},${r} ${n},${r}`,`L${n},${s}`,`C${c},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:n,y:u}],halfWidth:(o-i)/2}}}function Rt(t){const{nodes:e,edges:i,domain:o,plotW:n,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=t,u=function(t,e,i){const o=[],n=new Set(t.map(t=>t.id)),r=Array.isArray(i)&&2===i.length,s=r&&Number.isFinite(i[0])&&Number.isFinite(i[1]);r&&s&&s&&i[1]>=i[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)n.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),n.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,i,o),h=(0,pt.scaleTime)().domain(o).range([0,n]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(t,e,i){const{plotH:o,pairing:n="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=i,c=function(t,e){const i={},o={};for(const e of t)i[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),i[t.target]&&i[t.target].push(t);return{incoming:i,outgoing:o}}(t,e),l=function(t,e,i,o="value"){const n="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const i=new Map;for(const o of t){const t=o[e];i.has(t)||i.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const n=i.get(t);n.edges.push(o),n.total+=o.value,n.earliestStart=Math.min(n.earliestStart,o.startTime),n.latestEnd=Math.max(n.latestEnd,o.endTime)}const s=[...i.values()];s.sort("temporal"===o?(t,i)=>"target"===e?t.earliestStart-i.earliestStart:t.latestEnd-i.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:n);return s};for(const e of t){const t=i.outgoing[e.id],o=i.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=i});else if(0===t.length)a(o,"source").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=i});else{const e=a(o,"source"),i=a(t,"target"),n=Math.max(e.length,i.length);for(let t=0;n>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const i of e[t].edges)s.get(i.id).targetSide=o;if(i[t])for(const e of i[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,n);let u={};for(const e of t)u[e.id]=xt(e,c,l);const h=Pt(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),d=new Set;for(const t of e){const e=h.slotByNode[t.source],i=h.slotByNode[t.target];if(void 0===e||void 0===i)continue;const o=l.get(t.id);e!==i?e>i?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(d.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],i=c.incoming[e.id],o=new Set(t.map(t=>l.get(t.id).sourceSide)),n=new Set(i.map(t=>l.get(t.id).targetSide));if(1===o.size&&i.length>0){const t=[...o][0];for(const e of i)h.slotByNode[e.source]===h.slotByNode[e.target]&&(l.get(e.id).targetSide=t)}if(1===n.size&&t.length>0){const e=[...n][0];for(const i of t)h.slotByNode[i.source]===h.slotByNode[i.target]&&(l.get(i.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],i=c.outgoing[e.id];if(0===t.length||0===i.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const i of t)"top"===l.get(i.id).targetSide?e.inTop+=i.value:e.inBot+=i.value;for(const t of i)"top"===l.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},n=(t,e)=>{const n=o(),r="top"===t?n.outTop-n.inTop:n.outBot-n.inBot,s="top"===e?n.inTop-n.outTop:n.inBot-n.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),c=i.filter(e=>!d.has(e.id)&&l.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=e,!0)};let r=i.length+1;for(;r-- >0&&(n("top","bot")||n("bot","top")););}u={};for(const e of t)u[e.id]=xt(e,c,l);const f=Pt(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(o-y*(f.slots.length+1))/p):1,m=Pt(t,e,u,c,{plotH:o,padding:y,valueScale:g,packing:r,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(e,i,{plotH:r,...l}),{centerlines:f,nodeData:p,valueScale:y}=d,g=[],m=[];e.forEach((t,e)=>{const n=p[t.id];if(!n||0===n.samples.length)return;const r=function(t,e,i,o,n){if(0===t.length)return null;const r=vt(t,n),s=t=>e-r[t].topMass*i,a=t=>e+r[t].botMass*i;let c=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)c+=` L${o(r[t].t)},${s(t)}`;c+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)c+=` L${o(r[t].t)},${a(t)}`;return c+" Z"}(n.samples,f[t.id],y,h,o);if(!r)return;const s=vt(n.samples,o),a=s.find(t=>t.topMass+t.botMass>0)||s[0],l=f[t.id]+(a.botMass-a.topMass)*y/2,u=c(t.id,e),m=function(t,e,i,o,n){const r=i.nodeData[t];if(!r||0===r.samples.length)return[];const s=i.valueScale,a=i.centerlines[t],c=vt(r.samples,n),l=c.find(t=>t.topMass+t.botMass>0)||c[0],u=[...c].reverse().find(t=>t.topMass+t.botMass>0)||c[c.length-1],h=o(l.t),d=o(u.t),f=t=>o(bt(t,n)),p=[],y=(t,e,i,o)=>`M${t},${e} L${i},${e} L${i},${o} L${t},${o} Z`;for(const i of e){if(i.source===t&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){const t=r.localAttachments.get(i.id);if(t&&"out"===t.kind&&i.startTime>i.systemInTime){const e=f(i.systemInTime),o=f(i.startTime),n=e-20,r=Math.max(h,n);if(o>r){const[i,c]=wt(t,a,s);p.push({pathD:y(r,i,o,c),x0:n,x1:e,from:0,to:1})}}}if(i.target===t&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){const t=r.localAttachments.get(i.id);if(t&&"in"===t.kind&&i.systemOutTime>i.endTime){const e=f(i.systemOutTime),o=f(i.endTime),n=e+20,r=Math.min(d,n);if(r>o){const[i,c]=wt(t,a,s);p.push({pathD:y(o,i,r,c),x0:e,x1:n,from:1,to:0})}}}}return p}(t.id,i,d,h,o);g.push({id:t.id,pathD:r,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:t.__raw??t,labelX:h(a.t)-4,labelY:l,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),i.forEach(t=>{const e=p[t.source]?.localAttachments.get(t.id),i=p[t.target]?.localAttachments.get(t.id);if(!e||!i)return;const n=x.get(t.source)??0,r=c(t.source,n),l=function(t,e,i,o,n,r,s,a){const c=n,l=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(l(t.time)),h=r(l(i.time)),d=t.value*c,f=i.value*c,p=t.sideMassBefore*c,y=i.sideMassAfter*c;let g,m,x,b;"top"===t.side?(g=e-p,m=g+d):(m=e+p,g=m-d),"top"===i.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(h-u):"target"===s?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:g,sBot:m,tx:h,tTop:x,tBot:b,cp1X:v,cp2X:v}}(e,f[t.source],i,f[t.target],y,h,s,o),{pathD:u,bezier:d}=Tt(l);m.push({id:t.id,pathD:u,fill:r,opacity:a,rawDatum:t.__raw??t,bezier:d})}),{layout:d,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:h}}var Lt=t=>{const{bands:e=[],ribbons:i=[],showLabels:o=!0}=t.config,n=[];for(const t of i)n.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}});for(const t of e)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const i=t.gradientStubs[e];n.push({type:"bezier",pathD:i.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:i.x0,x1:i.x1,from:i.from,to:i.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of e)n.push({type:"bezier",pathD:t.pathD,style:{...t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86},stroke:t.stroke??t.fill,strokeWidth:t.strokeWidth??.5},datum:{__kind:"band",data:t.rawDatum,id:t.id}});const r=o?e.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:e.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:n,labels:r}},Ct={frameType:"network",buildProps:(t,e,i,o,n)=>{const{edgeWidth:r,edgeColor:s,edgeOpacity:a}=n,c=n.edgeStyle??(void 0!==r||void 0!==s||void 0!==a?t=>{const e=t?.data||t;let i=1;if("number"==typeof r)i=r;else if("function"==typeof r)i=r(e);else if("string"==typeof r){const t=e?.[r],o="number"==typeof t?t:Number(t);i=Number.isFinite(o)&&o>0?o:1}return{stroke:s??"#999",strokeWidth:i,opacity:a??.6}}:void 0);return{chartType:"force",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,colorBy:e,colorScheme:i,iterations:n.iterations,forceStrength:n.forceStrength,showLabels:n.showLabels,nodeLabel:n.nodeLabel,nodeSize:n.nodeSize,nodeSizeRange:n.nodeSizeRange,nodeStyle:Z(n.styleRules,e,"number"==typeof n.nodeSize?void 0:n.nodeSize,n.nodeStyle)??n.nodeStyle,edgeStyle:c,...o}}},$t={frameType:"network",buildProps:(t,e,i,o,n)=>{const r=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),s=n.sourceAccessor||"source",a=n.targetAccessor||"target",c=n.valueAccessor||"value",l=n.nodeIdAccessor||"id",u=n.startTimeAccessor||"startTime",h=n.endTimeAccessor||"endTime",d=n.systemInTimeAccessor,f=n.systemOutTimeAccessor,p=n.xExtentAccessor||"xExtent",y=n.edgeIdAccessor||"id",g=(t,e)=>"function"==typeof t?t(e):e[t],m=Array.isArray(n.edges)?n.edges:[],x=Array.isArray(n.nodes)?n.nodes:[],b=x.length>0?x:function(t,e,i,o){const n=new Set;return e.forEach(t=>{const e="function"==typeof i?i(t):t[i],r="function"==typeof o?o(t):t[o];n.add(e),n.add(r)}),Array.from(n).map(t=>({id:t}))}(0,m,s,a),v=[r(n.domain?.[0]),r(n.domain?.[1])],w=b.map(t=>{const e=g(l,t)+"",i=g(p,t),o={id:e,__raw:t};if(Array.isArray(i)&&2===i.length){const t=r(i[0]),e=r(i[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),k=m.map((t,e)=>{const i=g(y,t),o={id:null!=i?i+"":`${g(s,t)}-${g(a,t)}-${e}`,source:g(s,t)+"",target:g(a,t)+"",value:Number(g(c,t)),startTime:r(g(u,t)),endTime:r(g(h,t)),__raw:t};if(d){const e=r(g(d,t));Number.isFinite(e)&&(o.systemInTime=e)}if(f){const e=r(g(f,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[S,A]=o.size??[600,400],M={top:20,right:20,bottom:20,left:20,...o.margin},_=o.legendPosition??"right";o.showLegend&&("right"===_?M.right=Math.max(M.right,100):"left"===_?M.left=Math.max(M.left,100):"bottom"===_?M.bottom=Math.max(M.bottom,70):"top"===_&&(M.top=Math.max(M.top,40)));const P=M,T=S-P.left-P.right,R=A-P.top-P.bottom,L=Array.isArray(i)?i:null,C=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],$="function"==typeof e?e:null,j=$?b.map(t=>({_cat:$(t)})):b,z=$?"_cat":"string"==typeof e?e:void 0,D=z?N(j,z,i):null,I=new Map;for(const t of w)I.set(t.id,t.__raw);const{layoutConfig:B,issues:F}=Rt({nodes:w,edges:k,domain:v,plotW:T,plotH:R,ribbonLane:n.ribbonLane||"both",edgeOpacity:"number"==typeof n.edgeOpacity?n.edgeOpacity:.35,colorOf:(t,i)=>{if(e&&I.has(t)){const i=I.get(t);return $?E({_cat:$(i)},"_cat",D??void 0):E(i,"string"==typeof e?e:"id",D??void 0)}const o=L||C;return o[i%o.length]},layoutOpts:{pairing:n.pairing||"temporal",packing:n.packing||"reuse",laneOrder:n.laneOrder||"crossing-min",lifetimeMode:n.lifetimeMode||"half"}});if(F.length>0){const t=F.map(mt).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Lt,layoutConfig:B,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:e,colorScheme:i,...o,margin:P}}},jt=(require("react"),require("react")),zt=require("react/jsx-runtime");function Et(t,e){const i=new Set;let o={...t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o={...o,...e};for(const t of i)t()}}),...e??{}};return{getState:()=>o,subscribe:function(t){return i.add(t),()=>{i.delete(t)}}}}function Dt(t){if(!t?.colors)return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function Nt(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:It}}),t.accessibility.highContrast){const t="dark"===e.mode;e={...e,colors:{...e.colors,text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"}}}return e}var It=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Bt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Ft={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Ot={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:It,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Wt(t,e){if("light"===e)return Bt;if("dark"===e)return Ft;if("high-contrast"===e)return Ot;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Ft:Bt;return Nt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return Nt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[Yt,qt]=function(t){let e=null;const i=()=>(e||(e=(0,jt.createContext)(null)),e),o=Et(t);return[function({children:e,initialState:o}){const n=(0,jt.useRef)(o),r=(0,jt.useMemo)(()=>Et(t,n.current),[]),s=i();return(0,zt.jsx)(s.Provider,{value:r,children:e})},(t,e)=>{const n=i(),r=(0,jt.useContext)(n)??o,s=(0,jt.useRef)(t);s.current=t;const a=(0,jt.useRef)({hasValue:!1,value:void 0}),c=(0,jt.useCallback)(()=>{const t=s.current(r.getState()),i=a.current;return i.hasValue&&e&&e(i.value,t)?i.value:(a.current={hasValue:!0,value:t},t)},[r,e]),l=(0,jt.useCallback)(()=>s.current(r.getState()),[r]);return(0,jt.useSyncExternalStore)(r.subscribe,c,l)}]}(t=>({theme:Bt,setTheme(e){t(t=>({theme:Wt(t.theme,e)}))}})),Xt={light:Bt,dark:Ft,"high-contrast":Ot,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}},Gt=require("d3-scale");function Vt(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}var Ht={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r="string"==typeof i?i:"blues",s=n.areaStyle??function(t,e,i,o){if(!Array.isArray(t))return;const n=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let r=1/0,s=-1/0;for(const e of t){const t=n(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>s&&(s=t))}const a=(0,Gt.scaleSequential)(L(i)).domain([Number.isFinite(r)?r:0,Number.isFinite(s)?s:1]);return t=>{const e=n(t);return{fill:null!=e&&isFinite(e)?a(e):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(n.areas,n.valueAccessor,r,n.areaOpacity??1),a=n.styleRules?V(s,n.styleRules,t=>{return{value:(e=t,"function"==typeof n.valueAccessor?n.valueAccessor(e):null!=n.valueAccessor?e?.properties?.[n.valueAccessor]??e?.[n.valueAccessor]:void 0)};var e},Vt):s;return{areas:n.areas,projection:n.projection||"equalEarth",areaStyle:a,valueAccessor:n.valueAccessor,colorScheme:r,graticule:n.graticule,fitPadding:n.fitPadding,...o}}},Zt={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r=t||n.points,s=n.pointStyle??function(t,e,i,o){const n=Array.isArray(t)?t:[];let r,s;if(e){const t="string"==typeof e?e:"__geoColorBy",o="string"==typeof e?n:n.map(t=>({...t,__geoColorBy:e(t)}));r=N(o,t,i)}if(o.sizeBy){const t=n.map("function"==typeof o.sizeBy?o.sizeBy:t=>t?.[o.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=yt(t))}return t=>({fill:e&&r?E(t,e,r):"#007bff",fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?I(t,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(r,e,i,{sizeBy:n.sizeBy,sizeRange:n.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=n.styleRules?V(s,n.styleRules,Y(e,n.sizeBy)):s;return{points:r,xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",areas:n.areas,areaStyle:n.areaStyle,pointStyle:a,sizeBy:n.sizeBy,colorBy:e,colorScheme:i,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,...o}}},Kt={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r=(Array.isArray(t)?t:null)||n.flows||[],s=n.nodeIdAccessor||"id",a=n.valueAccessor||"value",c=n.xAccessor||"lon",l=n.yAccessor||"lat",u="function"==typeof c?c:t=>t[c],h="function"==typeof l?l:t=>t[l],d=(n.nodes||[]).map(t=>({...t,x:u(t),y:h(t)})),f=new Map;for(const t of d)f.set(t[s]+"",t);const p=n.edgeColorBy??e,y="function"==typeof p,g=r.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=f.get(t.source+""),i=f.get(t.target+"");return e&&i?{...t,coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?N(g.map(t=>({[m]:p(t)})),m,i||"category10"):N(g,p,i||"category10"):null,b=t=>p&&x?E(t,p,x):"#007bff";let v=1/0,w=-1/0;for(const t of g){const e=Number(t[a]??0);isFinite(e)&&(v>e&&(v=e),e>w&&(w=e))}const k=w>v?w-v:0,[S,A]=n.edgeWidthRange??[1,8],M=A-S,_=n.edgeOpacity??.6,P=n.edgeLinecap??"round";return{lines:g,points:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:n.lineType||"geo",flowStyle:n.flowStyle||"basic",areas:n.areas,areaStyle:n.areaStyle,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(t?.[a]),i=Number.isFinite(e)?e:v,o=S+Math.max(0,Math.min(1,k>0?(i-v)/k:0))*M;return{stroke:b(t),strokeWidth:o,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}};function Ut(t){const[e,i]=t;return{width:e,height:i,plot:{x:32,y:24,width:Math.max(80,e-64),height:Math.max(80,i-58)}}}function Qt(t){const e=(t??"")+"";if(!e)return"#4e79a7";const i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let t=0;e.length>t;t+=1)o=31*o+e.charCodeAt(t)>>>0;return i[o%i.length]}function Jt(t,e="#4e79a7",i){const o=i?.styleRules,n=!!o&&o.length>0,r=n?W(i?.valueAccessor):void 0;return i=>{const s=i.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,c={fill:null==a?e:Qt(a),stroke:"#111827",strokeWidth:1,opacity:.9};return n&&s&&Object.assign(c,G(s,o,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function te(t,e,i,o){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:i},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function ee(t,e,i){return"function"==typeof i?i(t,e):t[i]}function ie(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function oe(t,e,i){return Math.max(e,Math.min(i,t))}function ne(t,e){const i=ie(t);return null!=i&&i>0?i:e}function re(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function se(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}var ae=require("d3-scale");function ce(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var le={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},ue=1e-9,he=.005;function de(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function fe(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function pe(t,e,i){return Math.max(e,Math.min(i,t))}function ye(t){return 0>t?-1:1}function ge(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function me(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function xe(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function be(t,e,i,o,n,r,s,a){const c=n-t,l=(i+s)/2-Math.abs(c);if(0>=l)return null;const u=r-e,h=(o+a)/2-Math.abs(u);return h>0?h>l?{nx:ye(c),ny:0,penetration:l}:{nx:0,ny:ye(u),penetration:h}:null}function ve(t,e,i,o,n,r,s){const a=r/2,c=s/2;let l=t-pe(t,o-a,o+a),u=e-pe(e,n-c,n+c);const h=l*l+u*u;if(h>i*i)return null;if(ue>=h){const r=Math.abs(t-(o-a)),s=Math.abs(t-(o+a)),h=Math.abs(e-(n-c)),d=Math.abs(e-(n+c)),f=Math.min(r,s,h,d);return f===r?(l=-1,u=0,{nx:l,ny:u,penetration:i+r}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:i+s}):f===h?(l=0,u=-1,{nx:l,ny:u,penetration:i+h}):(l=0,u=1,{nx:l,ny:u,penetration:i+d})}const d=Math.sqrt(h);return{nx:l/d,ny:u/d,penetration:i-d}}function we(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,o,n,r){const s=o-t,a=n-e,c=i+r,l=s*s+a*a;if(l>=c*c)return null;if(ue>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return be(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=ve(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?ve(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function ke(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?ve(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):be(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,o,n,r,s,a=0){const c=r-o,l=s-n,u=c*c+l*l,h=u>ue?pe(((t-o)*c+(e-n)*l)/u,0,1):0,d=i+a/2,f=t-(o+c*h),p=e-(n+l*h),y=f*f+p*p;if(y>=d*d)return null;if(ue>=y){const t=Math.sqrt(u);return t>ue?{nx:-l/t,ny:c/t,penetration:d}:{nx:1,ny:0,penetration:d}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:d-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Se(t,e){return`${t}\0${e}`}function Ae(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function Me(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:de(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function _e(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function Pe(t){return{id:t.id,shape:fe(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:_e(t.bodyFilter),index:t.index}}function Te(t,e){return!!e?.some(e=>Object.is(t,e))}function Re(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const o=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(o,i.equals)||"notEquals"in i&&Object.is(o,i.notEquals)||i.oneOf&&!Te(o,i.oneOf)||i.notOneOf&&Te(o,i.notOneOf))}var Le=class{constructor(t={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...le,...t},this.random=ce(this.options.seed)}init(t={}){this.options={...le,...t},this.random=ce(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(ue,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:de(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))Ae(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:fe(e.shape),bodyFilter:_e(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const o=this.bodies.get(t);o&&(o.vx+=e/o.mass,o.vy+=i/o.mass,this.wake(o))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const o=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,o>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>o){const i=o/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(i),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,n,0===t),this.resolveColliders(i,r,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:de(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Ae)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Me),colliders:this.sortedColliders().map(Pe),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(t){this.options={...t.options,gravity:{...t.options.gravity}},this.random=ce(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(t.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of t.bodies){const t=Me(e);this.bodies.set(t.id,t),this.nextBodyIndex=Math.max(this.nextBodyIndex,t.index+1)}this.nextColliderIndex=0;for(const e of t.colliders){const t=Pe(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of t.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const o="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!o)continue;const n=o.x-i.x,r=o.y-i.y,s=Math.sqrt(n*n+r*r);if(ue>=s)continue;const a=n/s,c=r/s,l=(s-e.restLength)*e.stiffness+((("vx"in o?o.vx:0)-i.vx)*a+(("vy"in o?o.vy:0)-i.vy)*c)*e.damping;i.vx+=l*a*t/i.mass,i.vy+=l*c*t/i.mass}}resolveBodyPairs(t,e,i){for(const o of e){const[e,n]=o.split(":").map(Number),r=t[e],s=t[n];if(!r||!s)continue;const a=we(r,s);a&&(this.resolveDynamicCollision(r,s,a),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let o=0;t.length>o;o+=1){if(!1===t[o].bodyCollisions)continue;const n=ge(t[o]),r=Math.floor(n.minX/e),s=Math.floor(n.maxX/e),a=Math.floor(n.minY/e),c=Math.floor(n.maxY/e);for(let t=r;s>=t;t+=1)for(let e=a;c>=e;e+=1){const n=`${t}:${e}`,r=i.get(n);r?r.push(o):i.set(n,[o])}}const o=new Set;for(const e of Array.from(i.keys()).sort()){const n=i.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let i=e+1;n.length>i;i+=1){const r=n[e],s=n[i];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&xe(ge(t[r]),ge(t[s]))&&o.add(`${r}:${s}`)}}return Array.from(o).sort((t,e)=>{const[i,o]=t.split(":").map(Number),[n,r]=e.split(":").map(Number);return i===n?o-r:i-n})}resolveDynamicCollision(t,e,i){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,n=e.sleeping?0:1/e.mass,r=o+n;if(ue>=r)return;const s=Math.max(0,i.penetration-he)/r;t.x-=i.nx*s*o,t.y-=i.ny*s*o,e.x+=i.nx*s*n,e.y+=i.ny*s*n;const a=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*a/r,u=l*i.nx,h=l*i.ny;t.vx-=u*o,t.vy-=h*o,e.vx+=u*n,e.vy+=h*n,this.applyFriction(t,e,i,l,o,n),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,o,n,r){const s=-i.ny,a=i.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=n+r;if(ue>=Math.abs(c)||ue>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),h=pe(-c/l,-o*u,o*u),d=h*s,f=h*a;t.vx-=d*n,t.vy-=f*n,e.vx+=d*r,e.vy+=f*r}resolveColliders(t,e,i){for(const o of t)for(const t of e){if(!Re(t,o))continue;if(!xe(ge(o),me(t)))continue;const e=ke(o,t);e&&(this.resolveStaticCollision(o,t,e),this.supportedThisStep.add(o.id),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-he),t.y+=i.ny*Math.max(0,i.penetration-he);const o=t.vx*i.nx+t.vy*i.ny;if(0>o){const n=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+n)*o*i.nx,t.vy-=(1+n)*o*i.ny;const r=-i.ny,s=i.nx,a=t.vx*r+t.vy*s,c=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*r*c,t.vy-=a*s*c}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const o of t){const t=ge(o);for(const n of i){if(!Re(n,o))continue;if(!xe(t,me(n)))continue;if(!ke(o,n))continue;const i=Se(n.id,o.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:o}=Ae(t);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of t)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*e||i&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=e,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},Ce=class{constructor(t={}){this.id="builtin",this.capabilities={...(new Le).capabilities,engine:"builtin"},this.world=new Le(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function $e(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new Ce(t)}(e)}var je=["binId","targetBin","category","windowIndex","lane","group"];function ze(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function Ee(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function De(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function Ne(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Ie(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?Ne(e,t):void 0}function Be(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Fe(t){const e=Ee(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Ee(t.x),y:Ee(t.y),value:e}}var Oe=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=Be(Ie(this.config.binAccessor,t,e))??function(t){for(const e of je){const i=Be(Ne(t,e));if(i)return i}return"sediment"}(t),o=Be(Ie(this.config.labelAccessor,t,e))??i,n=function(t,e,i){if("number"==typeof t)return t;const o="function"==typeof t?t(e,i):"string"==typeof t?Ne(e,t):1,n="number"==typeof o?o:Number(o);return Number.isFinite(n)?n:1}(this.config.valueAccessor,t,e),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(i);return s||(s={id:i,label:o,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,s)),s.label=o,s.lastBodyId=t.id,s.lastDatum=t.datum,ze(s.x,t.x),ze(s.y,t.y),ze(s.value,n),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),Fe(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Fe)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:De(e.x),y:De(e.y),value:De(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function We(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var Ye={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},qe={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Xe(t={},e=qe){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function Ge(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function Ve(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function He(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Ze(t){return{...Ge(t),sequence:t.sequence,spawnAt:t.spawnAt}}function Ke(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function Ue(t){return!1!==t&&{...t}}function Qe(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function Je(t){return{...t,gravity:{...t.gravity}}}function ti(t,e,i,o){if("circle"===t.shape.type){const n=t.x-e,r=t.y-i,s=t.shape.radius+o,a=n*n+r*r;return a>s*s?null:a}const n=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),r=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),s=n*n+r*r;return s>o*o?null:s}function ei(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function ii(t,e={}){const{idPrefix:i="plot",includeFloor:o=!0,includeCeiling:n=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,h=t.y+t.height/2;return o&&l.push({id:i+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),n&&l.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),r&&l.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:h,width:a,height:t.height+2*c}}),s&&l.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:h,width:a,height:t.height+2*c}}),l}function oi(t){const{idPrefix:e="bin",count:i,domainStart:o,domainStep:n,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:h,lidY:d=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?i:i-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&i>t)continue;const s=r(o+t*n);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=h)for(let t=0;i>t;t+=1){const i=o+t*n,s=i+n;if(s>=h)continue;const a=r(i),l=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:d,x2:Math.max(a,l)-c/2,y2:d,thickness:f}})}return p}var ni={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function ri(t,e){const i={...t};for(const t of e)i[ni[t]]++;return i}function si(t,e,i){const o=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:o,revisions:ri(i,o)}}var ai=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=si({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}record(t,e){const i=si(t,e,this.revisions);this.revisions=i.revisions,this.latest=i;for(const t of[...this.listeners])t();return i}},ci=require("d3-quadtree"),li=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,o,n,r=0){const s=this.ensure(t,e);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,r)+this.maxSearchRadius,u=o-l,h=o+l,d=n-l,f=n+l;return s.visit((t,e,s,l,p)=>{if(u>l||e>h||d>p||s>f)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=ti(t,o,n,Math.max(0,r));null!=e&&(c>e||e===c&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,c=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=(0,ci.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},ui=["data","scene-geometry","data-paint","accessibility","evidence"],hi=["scene-geometry","data-paint","accessibility","evidence"],di=["overlay","accessibility","evidence"],fi=(t,e)=>({retainedData:t,invalidations:e}),pi=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yi=["scene-geometry","data-paint","accessibility","evidence"],gi=[],mi={engine:fi("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:fi("preserve",yi),colliders:fi("preserve",yi),sediment:fi("preserve",yi),bodyBudget:fi("preserve",pi),bodyLimit:fi("preserve",pi),eviction:fi("preserve",pi),fixedDt:fi("preserve",gi),maxDeltaSeconds:fi("preserve",gi),maxSubsteps:fi("preserve",gi),settleStepLimit:fi("preserve",gi),timeScale:fi("preserve",gi),observation:fi("preserve",gi)},xi=fi("preserve",pi);function bi(t){let e="preserve";const i=new Set;for(const o of t){const t=mi[o]??xi;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var vi=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function wi(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&vi.every(i=>t[i]===e[i])}function ki(t,e,i,o){return t||!e?"paused":i||!o?"running":"settled"}var Si=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new li,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new ai,this.simulationState="settled",this.visible=!0;const{bodyBudget:e,colliders:i,engine:o,kernel:n,observation:r,sediment:s,...a}=t;this.config={...Ye,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=o,this.observation=Xe(r),this.sediment=new Oe(s??!1),this.world=$e(o,{fixedDt:this.config.fixedDt,...n}),i&&this.world.setColliders(Ke(i))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!wi(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:o,engine:n,kernel:r,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=$e(n,t.options),this.world.restore(t),this.revision+=1}if(r&&!wi(r,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...r,gravity:{...t.options.gravity,...r.gravity}};this.world.restore({...t,options:e}),this.revision+=1}s&&(this.observation=Xe(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(Ke(i)),this.revision+=1),this.configInput={...this.configInput,...t};const l=bi(e);this.updateResults.record({kind:"config",keys:e},l.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(Ke(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},bi(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],o=e?function(t,e={}){const i=Ve(e.startAt)??0,o=e.pacing??"immediate";if("arrival"===o){const o=t.map((t,i)=>function(t,e,i){return"function"==typeof i?Ve(i(t,e)):"string"==typeof i?Ve(He(t,i)):Ve(t.spawnAt)??Ve(He(t,"arrivalTime"))??Ve(He(t,"timestamp"))??Ve(He(t,"time"))??Ve(He(t,"eventTime"))}(t,i,e.timeAccessor)),n=o.filter(t=>null!=t),r=n.length>0?Math.min(...n):0,s=Ve(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const n=o[e],s=null==n?0:Math.max(0,n-r);return{...Ge(t),spawnAt:i+s/a}})}if("object"==typeof o){const e=Ve(o.ratePerSec);if(e&&e>0)return t.map((t,o)=>({...Ge(t),spawnAt:i+o/e}))}return t.map(t=>({...Ge(t),spawnAt:i}))}(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of o)this.queue.push({...Ge(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Qe),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?ui:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(Ge(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},ui)}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},ui)}tick(t){const e=this.revision,i=[],o=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,n,r,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),n.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||i.length>0||o.length>0||n.length>0||r.length>0)&&(this.revision+=1);const h=this.result(u,i,o,n,r,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?i.length||o.length||n.length?ui:hi:[]),h}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?hi:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],o=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,n,r,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);o.push(...c.evicted),n.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(;t>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),l+=1}(l>0||i.length>0||o.length>0||n.length>0||r.length>0)&&(this.revision+=1);const u=this.result(l,i,o,n,r,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==e?i.length||o.length||n.length?ui:hi:[]),u}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return function(t,e={}){const{baselineY:i=0,binWidth:o=24,gap:n=2,maxHeight:r=80,value:s="count",x:a}=e,c=Math.max(1,...t.map(t=>t[s]));return t.map((t,e)=>{const l=Math.max(0,t[s]/c*r),u=a?.(t,e)??e*(o+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:i-l,width:o,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:i,chartId:o,...n}=t,r={...n,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?di:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?di:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),o=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>i.has(t)||o.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?ui:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},hi),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},hi)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},hi)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,o)=>t.applyImpulse(e,i,o),clear:()=>t.clear(),hitTest:(e,i,o)=>t.hitTest(e,i,o),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Ue(this.bodyBudget),config:{...this.config,kernel:Je(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Ze),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:Ue(t.bodyBudget??{}),kernel:Je(t.world.options)},this.bodyBudget=Ue(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(Ze).sort(Qe),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??ki(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},ui)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,o,n,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:n,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:o,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const o=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=o.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const o=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===o.size&&0===e.size)return o;const n=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:o,bodyId:r}=ei(e),s=i.observation.sensors[o],a=n.get(r);i.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const t of Array.from(o).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())o.has(t)||r("exit",t);return o}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(ei(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return function(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),o=e+i,n=We(t.bodyLimit),r=We(t.engineMaxBodiesHint),s=function(t,e,i){if(!1===i)return;const o=We(i?.warnAt);return null!=o?o:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,r,t.options),a=null==n?0:Math.max(0,e-n),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:o,queuedBodies:i,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=ki(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const e=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(e))return{evicted:[],sedimented:[]};const i=this.liveBodyOrder.length-e;if(0>=i)return{evicted:[],sedimented:[]};const o=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,i);if(0===o.length)return{evicted:[],sedimented:[]};const n=this.absorbSediment(o,t);this.world.remove(o);const r=new Set(o);return this.liveBodyOrder=this.liveBodyOrder.filter(t=>!r.has(t)),this.removeActiveSensorPairsForBodies(r),{evicted:o,sedimented:n}}absorbSediment(t,e){const i=new Map(this.world.readState().map(t=>[t.id,t])),o=[];for(const n of t){const t=i.get(n);if(!t)continue;const r=this.sediment.add(t);r&&(o.push(n),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:n,datum:t.datum,x:t.x,y:t.y,binId:r.id,count:r.count,total:r.total},e))}return o}sleepingFirstEvictionOrder(){const t=new Map(this.world.readState().map(t=>[t.id,t.sleeping])),e=[],i=[];for(const o of this.liveBodyOrder)t.get(o)?e.push(o):i.push(o);return[...e,...i]}};var Ai=require("d3-scale");function Mi(t){const{count:e,idPrefix:i,wallThickness:o,xScale:n,yBottom:r,yTop:s,yTopForIndex:a}=t;return Array.from({length:e+1},(t,e)=>{const c=Math.min(r-1,a?.(e)??s),l=Math.max(1,r-c);return{id:`${i}-wall-${e}`,shape:{type:"aabb",x:n(e),y:c+l/2,width:o,height:l}}})}var _i=require("d3-scale");function Pi(t){if(Array.isArray(t)&&t.length>=2){const e=ie(t[0]),i=ie(t[1]);return null!=e&&null!=i?{x:e,y:i}:null}if(t&&"object"==typeof t){const e=t,i=ie(e.x),o=ie(e.y);return null!=i&&null!=o?{x:i,y:o}:null}return null}function Ti(t){return Array.isArray(t)?t.map(Pi).filter(t=>null!=t):[]}function Ri(t,e,i){return"normalized"===i?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:oe(t.x,e.plot.x,e.plot.x+e.plot.width),y:oe(t.y,e.plot.y,e.plot.y+e.plot.height)}}function Li(t){let e=0;for(let i=1;t.length>i;i+=1)e+=Math.hypot(t[i].x-t[i-1].x,t[i].y-t[i-1].y);return e}function Ci(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const i=oe(e,0,1)*Li(t);let o=0;for(let e=1;t.length>e;e+=1){const n=t[e-1],r=t[e],s=Math.hypot(r.x-n.x,r.y-n.y);if(s>0){if(o+s>=i){const t=(i-o)/s;return{x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t}}o+=s}}return{...t[t.length-1]}}function $i(t,e){const i=Ci(t,Math.max(0,e-.02)),o=Ci(t,Math.min(1,e+.02)),n=o.x-i.x,r=o.y-i.y,s=Math.hypot(n,r)||1;return{x:n/s,y:r/s}}function ji(t,e,i){return Math.max(e,Math.min(i,t))}function zi(t,e,i,o,n,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:o,y2:n,thickness:r.thickness??8}}}function Ei(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,o=t.width,n=t.height,{type:"aabb",x:e,y:i,width:o,height:n}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,o,n}function Di(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ei({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Ni(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function Ii(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=t.size,o=Ut(i),n=oe(t.ballRadius??6,2,18),r=t.seed??1,s=se(r),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,h=t.workAccessor,d=t.radiusAccessor,f=t.groupCompletion??(l?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),o=Math.max(1,Math.round(t.height)),n=t.padX??46,r=t.padY??72,s=n,a=i-n,c=r,l=o-Math.max(24,Math.round(.45*r)),u=(c+l)/2,h=Math.max(1,l-c),d=ji(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=ji(h*d+p,.06*h,.5*h),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,S=t.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=ji(t.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(S),_=a-s;let P=s;const T=S.map((t,e)=>{const i=P,o=e===S.length-1?a:P+(t.share??1)/M*_;return P=o,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:o,x:(i+o)/2,width:o-i,y:u,height:h}}),R=T[A],L=R.x0,C=R.x1,$=(t,i)=>{if("lane"===e)return"top"===i?c:l;if("funnel"===e){const e=ji((t-s)/Math.max(1,a-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(L>=t){const e=ji((t-s)/Math.max(1,L-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(C>=t)return"top"===i?m:x;const o=ji((t-C)/Math.max(1,a-C),0,1);return"top"===i?m+(c-m)*o:x+(l-x)*o},j=T.map(t=>{const e=Math.min($(t.x0,"top"),$(t.x1,"top")),i=Math.max($(t.x0,"bottom"),$(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),z={thickness:k,friction:v,restitution:w},E=[];"lane"===e?E.push(zi(b+"-top",s,c,a,c,z),zi(b+"-bottom",s,l,a,l,z),zi(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),zi(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)})):"funnel"===e?E.push(zi(b+"-top",s,c,a,m,z),zi(b+"-bottom",s,l,a,x,z),zi(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),zi(b+"-right",a,m,a,x,{...z,thickness:Math.max(6,k)})):E.push(zi(b+"-left-top",s,c,L,m,z),zi(b+"-left-bottom",s,l,L,x,z),zi(b+"-center-top",L,m,C,m,z),zi(b+"-center-bottom",L,x,C,x,z),zi(b+"-right-top",C,m,a,c,z),zi(b+"-right-bottom",C,x,a,l,z),zi(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),zi(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)}));const D=t.membraneDampingScale??.5,N=s,I=Math.max(1,("bowtie"===e?L:a)-N),B=(t.membranes??[]).map(t=>{const e=N+ji(t.offset,0,1)*I,i=t.width??18+18*t.cost,o=h-16,n=u+.25*(t.wobble??0);return{...t,x:e,y:n,width:i,height:o}}),F=!1===t.includeMembraneRegions?[]:B.map(t=>function(t){const e=t.dampingScale??.5,i=t.energyScale??1,o=ji(t.cost,0,2);return{...Ei({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o*e,energyDelta:-o*i}}({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??D,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:o,padX:n,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:L,centerRight:C,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:j,membranes:B,colliders:E,regionEffects:F,boundaryY:$}}({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],S=new Set(e.filter(t=>t.absorb).map(t=>t.id)),A=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const i={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Ei({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}({...i,kind:t.kind??"sink",force:Ni(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return o={...i,kind:t.kind??"force-field",force:Ni(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Ei({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ei({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}({...i,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Ni(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...i.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return function(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,o=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Ei({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*o,energyDelta:n?-e*n:void 0,force:t.force}}({...i,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:Ni(t.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Di({...i,kind:t.kind??"force-field",force:Ni(t.force,14),damping:t.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):function(t){return{...Ei({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}({...i,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Di({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const t of x.stages)M.set(t.id,0);const _=[];t.data.forEach((t,e)=>{const i=(a?ee(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",o=(ee(t,e,c)??w)+"",r=b.has(o)?o:w;M.set(r,(M.get(r)??0)+1);const s=l?(ee(t,e,l)??"")+"":void 0,f=s&&u?(ee(t,e,u)??s)+"":s,p=h?ie(ee(t,e,h))??1:1,y=d?ie(ee(t,e,d)):null,g=oe(null!=y&&y>0?y:n,2,18);_.push({datum:t,id:i,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const P=new Map,T=new Map;for(const t of _){if(!t.groupId)continue;const e=P.get(t.groupId)??[];e.push(t.id),P.set(t.groupId,e),t.groupLabel&&T.set(t.groupId,t.groupLabel)}const R=oe(t.groupAnchorAlong??.55,.15,.9),L=x.left+(x.right-x.left)*R,C=Array.from(P.keys()),$=C.map((t,i)=>{const o=P.get(t)??[],n=C.length>1?x.topY+28+i/Math.max(1,C.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:T.get(t)??t,bodyIds:o,anchor:{x:L,y:n},x:L,y:n,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),j=function(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],o=e.filter(t=>!i.has(t)),n=e.length-o.length,r=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},c=e.reduce((t,e)=>t+a(e),0),l=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),u=t.completion?.threshold,h="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:r,complete:e.length>0&&("anyAbsorbed"===r?n>0:"threshold"===r?l>=(h??c):0===o.length),absorbed:n,total:e.length,absorbedValue:l,totalValue:c,threshold:h,missing:o}})}($,_.filter(t=>S.has(t.stageId)).map(t=>t.id)),z=new Map($.map(t=>[t.id,t])),E=_.map((t,e)=>{const i=v.get(t.stageId)??k,o=i.x+(s()-.5)*Math.min(24,.2*i.width),n=x.boundaryY(o,"top")+t.radius+10,r=x.boundaryY(o,"bottom")-t.radius-10,a=r>n?n+s()*Math.max(1,r-n):x.midY,c=g?o:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=z.get(t.groupId);e?.anchor&&!S.has(t.stageId)&&u.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:g?0:.03*e,springs:u,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),D={kernel:{seed:r,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},N=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),I=e.map(t=>{const e=v.get(t.id)??k;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:M.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:D,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:N,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:I,groups:$,groupCompletion:j,regionEffects:A}}}var Bi=require("d3-scale");function Fi(t,e,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=C[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:i}function Oi(t,e){const i=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>i&&D(i,t)||"#4e79a7":e=>{if(i){const t=D(i,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}function Wi(t,e){const i=e.config??{},o=(e.sensors??[]).map(t=>({...t,sensor:!0})),n=[...e.colliders??[],...o],r=[...t.colliders??[],...i.colliders??[],...n];return{...t,...i,observation:{...t.observation,...i.observation},...r.length>0&&{colliders:r}}}function Yi(t){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:t.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:t.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:t.floorY,x2:t.width-30,y2:t.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-30,y1:76,x2:t.width-30,y2:t.floorY,thickness:8}}]}function qi(t,e,i,o){return i?"function"==typeof i?i(t,e):t[i]??o:o}function Xi(t){return`gauntlet:${t}:core`}function Gi(t,e){return`gauntlet:${t}:positive:${e}`}function Vi(t,e,i){return`gauntlet:${t}:negative:${e}:${i}`}function Hi(t,e,i,o){const n=Math.max(2,i+2),r=80+n,s=o.floorY-n;return{x:Math.max(32+n,Math.min(o.width-30-4-n,t)),y:Math.max(r,Math.min(s,e))}}function Zi(t,e){const i=[...t].sort((t,e)=>t.localeCompare(e)),o=Math.max(0,i.indexOf(e));return{angle:.82*-Math.PI+(i.length>1?o/(i.length-1):.5)*Math.PI*.64,index:o,radius:48+o%2*6}}function Ki(t,e,i){const o=t.activePositiveIds.reduce((t,i)=>t+(e.get(i)?.value??1),0),n=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(i.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*r-1.2*t.delay-5*n))}function Ui(t){const e=function(t,e,i){const[o,n]=t,r=Math.round(.48*n),s=n-36,a=(e??[]).filter(t=>!1!==t.enabled),c=Math.max(1,a.length),l=.22*o,u=c>1?(.78*o-l)/(c-1):0,h=Math.max(Math.round(.14*o),110);return{crashY:s-i,floorY:s,gates:a.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(l+e*u),width:t.width??Math.max(54,Math.round(.07*o))})),graveyardX:Math.round(.84*o),graveyardY:s-4,height:n,routeY:r,socketX:Math.round(.92*o),startX:h,width:o}}(t.size??[900,520],t.gates,t.crashOffset??30),i=t.positiveProperties??[],o=new Map(i.map(t=>[t.id,t])),n=new Map((t.negativeProperties??[]).map(t=>[t.id,t])),r={idAccessor:t.idAccessor,initialViability:t.initialViability,metricsAccessor:t.metricsAccessor,negativeAccessor:t.negativeAccessor,positiveAccessor:t.positiveAccessor,startTimeAccessor:t.startTimeAccessor},s=(t.data??[]).map((e,s)=>{const a=function(t,e,i,o,n){const r=qi(t,e,i.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=o.map(t=>t.id),a=[...qi(t,e,i.positiveAccessor,s)],c=[...qi(t,e,i.negativeAccessor,[])].filter(t=>n.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...qi(t,e,i.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(qi(t,e,i.startTimeAccessor,0))||0),stage:"project filed",viability:qi(t,e,i.initialViability,100)}}(e,s,r,i,n);return{...a,viability:t.viability?.(a,{negativeProperties:n,positiveProperties:o})??Ki(a,o,n)}}),a=s.flatMap((i,r)=>{const s=function(t,e,i,o){const n=function(t){return{graveyardX:t.graveyardX,graveyardY:t.graveyardY,routeY:t.routeY,socketX:t.socketX,socketY:t.routeY-4,startX:t.startX,startY:t.routeY}}(i),r=o?.(t,e,i)??{};return{...n,...r,startY:r.startY??r.routeY??n.startY,socketY:r.socketY??r.routeY??n.socketY,graveyardY:r.graveyardY??n.graveyardY}}(i,r,e,t.projectPlacement);return function(t,e,i,o,n,r,s){const a=o.startX,c=o.startY+(o.startY===i.routeY?38*e:0),l=s?.(t,e,i,o)??{},u={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},h=[{...l,id:Xi(t.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??t.startedAt,datum:u}],d=Hi(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,i);h[0].x=d.x,h[0].y=d.y;for(const e of t.activePositiveIds){const o=n.get(e);if(!o)continue;const r=Zi(t.activePositiveIds,e),s=o.radius??10,a=Hi(d.x+Math.cos(r.angle)*r.radius,d.y+Math.sin(r.angle)*r.radius,s,i);h.push({id:Gi(t.id,e),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:o,sourceDatum:t.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:Xi(t.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...o.spring??{}}]})}return t.negativeIds.forEach((e,o)=>{const n=r.get(e);n&&h.push(function(t,e,i,o,n,r,s){const a=e.radius??7.2,c=Hi(o-12+i%4*12,n+54+12*Math.floor(i/4),a,r);return{id:Vi(t.id,e.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:Xi(t.id)},stiffness:.62,damping:.92,restLength:52+i%4*3,...e.spring??{}}]}}(t,n,o,d.x,d.y,i,l.spawnAt??t.startedAt))}),h}(i,r,e,s,o,n,t.coreBody)});return{layout:e,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Yi(e)}}}function Qi(t){return t.map(t=>({...t,spawnAt:void 0}))}var Ji={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,...o,showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:Q,AreaChart:J,DifferenceChart:tt,StackedAreaChart:et,Scatterplot:it,CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"candlestick",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.highAccessor||"high",highAccessor:n.highAccessor||"high",lowAccessor:n.lowAccessor||"low",openAccessor:n.openAccessor,closeAccessor:n.closeAccessor,candlestickStyle:n.candlestickStyle,...o})},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[5,40],colorScheme:i,...o})},ConnectedScatterplot:nt,QuadrantChart:ot,Heatmap:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"heatmap",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",valueAccessor:n.valueAccessor,colorScheme:i||n.colorScheme||"blues",showValues:n.showValues,cellBorderColor:n.cellBorderColor,...o})},XYCustomChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"custom",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o,showAxes:o.showAxes??!1})},BarChart:ut,StackedBarChart:ht,GroupedBarChart:dt,PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"pie",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",colorAccessor:e||n.categoryAccessor,colorScheme:i,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o})},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"donut",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",innerRadius:n.innerRadius||60,colorAccessor:e||n.categoryAccessor,colorScheme:i,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o})},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"histogram",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal",bins:n.bins,colorAccessor:e,colorScheme:i,...o})},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"boxplot",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorScheme:i,...o})},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"violin",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",bins:n.bins,colorScheme:i,...o})},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"swarm",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:i,...o})},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"point",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:i,...o,showGrid:o.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"swimlane",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.subcategoryAccessor,colorAccessor:e||n.subcategoryAccessor,categoryAccessor:n.categoryAccessor,subcategoryAccessor:n.subcategoryAccessor,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",...o})},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"ridgeline",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",bins:n.bins,amplitude:n.amplitude,...o})},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.levelAccessor||"level",colorAccessor:e||n.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===n.orientation?"vertical":"horizontal",...o})},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>{const r="vertical"===n.orientation;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:n.stepAccessor||"step",rAccessor:n.valueAccessor||"value",colorAccessor:e||n.categoryAccessor,categoryAccessor:n.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:n.connectorAccessor,connectorStyle:n.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:i,...o}}},GaugeChart:ft,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"custom",data:t,oAccessor:n.categoryAccessor||n.oAccessor||"category",rAccessor:n.valueAccessor||n.rAccessor||"value",projection:n.projection||"vertical",colorAccessor:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o,showAxes:o.showAxes??!1})},ForceDirectedGraph:Ct,NetworkCustomChart:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"force",nodes:n.nodes||t||[],edges:n.edges||[],nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor||"id",sourceAccessor:n.sourceAccessor||"source",targetAccessor:n.targetAccessor||"target",valueAccessor:n.valueAccessor||"value",colorBy:e,colorScheme:i,customNetworkLayout:n.layout||n.customNetworkLayout,layoutConfig:n.layoutConfig,...o})},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"sankey",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,valueAccessor:n.valueAccessor,orientation:n.orientation,nodeAlign:n.nodeAlign,nodeWidth:n.nodeWidth,nodePaddingRatio:n.nodePaddingRatio,showLabels:n.showLabels,nodeLabel:n.nodeLabel,colorBy:e,edgeColorBy:n.edgeColorBy,edgeOpacity:n.edgeOpacity,nodeStyle:n.nodeStyle,edgeStyle:n.edgeStyle,colorScheme:i,...o})},ProcessSankey:$t,ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"chord",nodes:n.nodes,edges:n.edges,valueAccessor:n.valueAccessor,padAngle:n.padAngle,groupWidth:n.groupWidth,showLabels:n.showLabels,colorBy:e,edgeColorBy:n.edgeColorBy,colorScheme:i,...o})},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"cluster"===n.layout?"cluster":"tree",data:t,childrenAccessor:n.childrenAccessor,colorBy:e,colorByDepth:n.colorByDepth,orientation:n.orientation,showLabels:n.showLabels,colorScheme:i,...o})},Treemap:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"treemap",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,colorScheme:i,...o})},CirclePack:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"circlepack",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,colorScheme:i,...o})},ChoroplethMap:Ht,ProportionalSymbolMap:Zt,FlowMap:Kt,GeoCustomChart:{frameType:"geo",buildProps:(t,e,i,o,n)=>({points:n.points||t||[],areas:n.areas||[],lines:n.lines||[],projection:n.projection||"equirectangular",xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",lineDataAccessor:n.lineDataAccessor,colorBy:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s=n.bins??21,a=n.seed??1,c=Math.max(1,Math.round(n.pegRows??s-1)),l="mechanical"===n.mode,u=l?function(t){const e=Math.max(2,Math.round(t.bins)),i=Math.max(1,Math.round(t.pegRows??e-1)),o=Math.max(1,Math.round(t.count??Math.max(64,4*e))),n=oe(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=se(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:o},(t,e)=>{let o=0;for(let t=0;i>t;t+=1)r()<n&&(o+=1);const a=i/2;return{id:`${s}-${e}`,value:o,mechanical:!0,pegRows:i,branchProbability:n,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:a}):Array.isArray(t)?t:[],h=function(t){const{data:e,valueAccessor:i,bins:o,ballRadius:n,seed:r,size:s,valueExtent:a}=t,c=Ut(s),l=e.map((t,e)=>ie(ee(t,e,i))).filter(t=>null!=t),u=function(t){if(!t)return;const e=ie(t[0]),i=ie(t[1]);return null!=e&&null!=i?e>i?[i,e]:[e,i]:void 0}(a),h=u?.[0]??(l.length?Math.min(...l):0),d=u?.[1]??(l.length?Math.max(...l):1),f=d===h?1:d-h,p=(0,ae.scaleLinear)().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),g=[];e.forEach((t,e)=>{const r=ie(ee(t,e,i));if(null==r)return;const s=Math.max(0,Math.min(o-1,Math.floor((r-h)/f*o)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:c.plot.y+n+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:n},datum:{...t,value:r,bin:s}})});const m=c.plot.y+c.plot.height;return{config:te(r,[...ii({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...oi({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[h,d]}}}({data:u,valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??4,seed:a,size:r,valueExtent:l?[0,c]:void 0});return{...o,config:h.config,initialSpawns:Qi(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:Jt(e||n.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s=function(t){const{data:e,timeAccessor:i,arrivalAccessor:o,windows:n,watermark:r,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=t,h=Ut(c),d=e.map((t,e)=>ie(ee(t,e,i))).filter(t=>null!=t),f=ie(l?.[0]),p=ie(l?.[1]),y=d.length?Math.min(...d):0,g=d.length?Math.max(...d):y+n.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/n.size)*n.size,v=Math.max(1,Math.ceil((x-b+n.size)/n.size)),w=d.length?Math.max(...d):0,k="function"==typeof r?r(w):ie(r?.value)??w-(r?.delay??n.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>b+(e+1)*n.size>k?t:t+1,0))),A=function(t,e){const i=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:i,height:t.plot.height},windowPlot:{x:t.plot.x+i,y:t.plot.y,width:Math.max(40,t.plot.width-i),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(h,s),M=b+v*n.size,_=(0,Ai.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),T=[];e.forEach((t,e)=>{const r=ie(ee(t,e,i));if(null==r)return;const a=ie(ee(t,e,o))??r,c=Math.max(0,Math.min(v-1,Math.floor((r-b)/n.size))),l=k>=b+(c+1)*n.size;P[c].value+=l?0:1,P[c].secondary+=l?1:0,T.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(r))),y:h.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...t,eventTime:r,arrivalTime:a,windowIndex:c,late:l}})});const R=h.plot.y+h.plot.height,L=function(t,e){const i=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!i)return[];const o=t.windowStart,n=t.windowStart+t.windowCount*t.windowSize,r=(0,Ai.scaleLinear)().domain([o,n]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+i*t.windowSize),a=t.windowPlot.x,c=e+Math.max(18,Math.min(.3*t.windowPlot.height,s-a)),l=t=>s===a?e:c+(t-a)/(s-a)*(e-c),u=[];for(let e=0;i>e;e+=1){const i=t.windowStart+e*t.windowSize,o=i+t.windowSize,n=r(i),s=r(o);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:n,y1:l(n),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:h.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:n.size,windowStart:b},h.plot.y+.28*h.plot.height);return{config:te(a,[...ii({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Mi({idPrefix:"eventdrop-window",count:v,xScale:t=>_(b+t*n.size),yTop:A.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?L[0]?.y1:L[t-1]?.y2??L[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:R,wallThickness:6}),...L.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:T,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:P.map((t,e)=>({label:`${b+e*n.size}-${b+(e+1)*n.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:L,lateCount:P.reduce((t,e)=>t+e.secondary,0),plot:h.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:n.size,windowStart:b}}}({data:Array.isArray(t)?t:[],timeAccessor:n.timeAccessor||"time",arrivalAccessor:n.arrivalAccessor||"arrivalTime",windows:n.windows||{size:10},watermark:n.watermark,ballRadius:n.ballRadius??5,seed:n.seed??1,size:r,timeExtent:n.timeExtent,timeScale:n.timeScale??1});return{...o,config:s.config,initialSpawns:Qi(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Jt(e||n.colorBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||n.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s="mechanical"===n.mode,a=function(t){const{data:e,categoryAccessor:i,valueAccessor:o,unitValue:n,ballRadius:r,seed:s,size:a}=t,c=ne(n,1),l=Ut(a),u=[],h=new Map,d=new Map,f=[];function p(t){let e=h.get(t);return null==e&&(e=u.length,u.push(t),h.set(t,e)),e}e.forEach((t,e)=>{p((ee(t,e,i)??"unknown")+"")});const y=Math.max(1,u.length),g=function(t,e,i){const o=t.width/Math.max(1,e),n=Math.max(2,2*i),r=Math.min(.7*o,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(r/n));return{laneWidth:o,tubeWidth:r,ballDiameter:n,perRow:s,centerX:e=>t.x+(e+.5)*o,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*n}}(l.plot,y,r),m=Math.max(0,g.tubeWidth/2-r-1),x=u.map(()=>[]);e.forEach((t,e)=>{const n=(ee(t,e,i)??"unknown")+"",s=p(n),a=o?ie(ee(t,e,o)):1,u=Math.max(0,Math.round((a??0)/c)),h=g.centerX(s);for(let i=0;u>i;i+=1){const o=d.get(n)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;d.set(n,o+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${i}`,x:h+a,y:l.plot.y+r+2,vx:(i%3-1)*r/2,vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,category:n,unitIndex:i}})}});const b=x.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of x)e.length>t&&f.push(e[t]);const v=l.plot.y+l.plot.height,w=[...ii({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let t=0;y>t;t+=1){const e=g.centerX(t);for(const i of[-1,1])w.push({id:`pile-tube-${t}-${0>i?"l":"r"}`,shape:{type:"aabb",x:e+i*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:te(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:d.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),i=e.length?e:["Intake"],o=Math.max(i.length,Math.round(t.count??Math.max(48,12*i.length))),n=ne(t.unitValue,1),r=se(t.seed??1),s=t.idPrefix??"mechanical-pile",a=i.map(()=>.65+.9*r()),c=a.reduce((t,e)=>t+e,0)||1,l=o-i.length,u=a.map(t=>t/c*l),h=u.map(t=>1+Math.floor(t));let d=o-h.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%f.length)h[f[t].index]+=1,d-=1;return i.map((t,e)=>({id:`${s}-${e}`,category:t,value:h[e]*n,mechanical:!0,unitCount:h[e],unitValue:n,share:h[e]/o}))}({categories:n.mechanicalCategories,count:n.mechanicalCount,seed:n.seed??1,unitValue:n.unitValue??1}):Array.isArray(t)?t:[],categoryAccessor:n.categoryAccessor||"category",valueAccessor:n.valueAccessor||(s?"value":void 0),unitValue:n.unitValue??1,ballRadius:n.ballRadius??5,seed:n.seed??1,size:r});return{...o,config:a.config,initialSpawns:Qi(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:Jt(e||n.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,360],s=function(t){const{data:e,xAccessor:i,groupAccessor:o,radiusAccessor:n,pointRadius:r,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,h=Ut(a),d=se(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=ie(ee(t,e,i));if(null==s)return;const a=o?(ee(t,e,o)??"All")+"":"All",c=n?ie(ee(t,e,n)):null,l=oe(null!=c&&c>0?c:r,2,18);!function(t){let e=y.get(t);null==e&&(e=p.length,p.push(t),y.set(t,e))}(a),f.push({datum:t,index:e,value:s,group:a,radius:l})});const g=f.map(t=>t.value),m=c?ie(c[0]):null,x=c?ie(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const t=k;k=w,w=t}const S=Math.max(r,...f.map(t=>t.radius)),A=h.plot.x+S+8,M=h.plot.x+h.plot.width-S-8,_=(0,_i.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),T=h.plot.y+Math.max(28,3*S),R=Math.max(0,h.plot.y+h.plot.height-Math.max(28,3*S)-T),L=t=>{const e=y.get(t)??0;return 1===P?h.plot.y+.54*h.plot.height:T+e/(P-1)*R},C=new Map,$=f.map((t,e)=>{C.set(t.group,(C.get(t.group)??0)+1);const i=_(t.value),o=L(t.group),n=(d()-.5)*t.radius*1.6,r=(d()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?i+n:oe(i+(e%9-4)*t.radius*2.5,A,M),y:u?o+r:h.plot.y-18-e%12*t.radius,vx:u?0:22*(d()-.5),vy:u?0:24+18*d(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:i,targetY:o},springs:[{target:{type:"point",x:i,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:te(s,ii({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:$,projectionRows:p.map(t=>({label:t,value:C.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(t=>({label:t,y:L(t),count:C.get(t)??0})),plot:h.plot}}}({data:Array.isArray(t)?t:[],xAccessor:n.xAccessor||"x",groupAccessor:n.groupAccessor,radiusAccessor:n.radiusAccessor,pointRadius:n.pointRadius??5,seed:n.seed??1,size:r,xExtent:n.xExtent,collisionIterations:n.collisionIterations,settle:n.settle});return{...o,config:s.config,initialSpawns:Qi(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Jt(e||n.colorBy||n.groupAccessor,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[900,420],s=Array.isArray(n.stages)?n.stages:[],a=Ii({data:Array.isArray(t)?t:[],stages:s,size:r,idAccessor:n.idAccessor,stageAccessor:n.stageAccessor||"stage",groupBy:n.groupBy,groupLabelAccessor:n.groupLabelAccessor,workAccessor:n.workAccessor,radiusAccessor:n.radiusAccessor,ballRadius:n.ballRadius??6,seed:n.seed??1,groupCompletion:n.groupCompletion,groupAnchorAlong:n.groupAnchorAlong,settle:n.settle??!0,gravityX:n.gravityX,gravityY:n.gravityY}),c=a.metadata;return{...o,config:a.config,initialSpawns:Qi(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:Jt(e||n.colorBy||n.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[900,520],s=Ui({data:Array.isArray(t)?t:[],size:r,gates:n.gates,positiveProperties:n.positiveProperties,negativeProperties:n.negativeProperties,crashOffset:n.crashOffset,idAccessor:n.idAccessor,positiveAccessor:n.positiveAccessor,negativeAccessor:n.negativeAccessor,metricsAccessor:n.metricsAccessor,initialViability:n.initialViability,projectPlacement:n.projectPlacement,coreBody:n.coreBody,viability:n.viability});return{...o,config:s.config,initialSpawns:Qi(s.initialSpawns),projectionRows:[],bodyStyle:Jt(e||n.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:i,links:o,maxParticles:n,nodeIdAccessor:r,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:h,pathConstraint:d="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=Ut(y),v=se(p),w=new Map,k=new Map,S=[];function A(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof r){const t=r(e,0);if(null!=t)return t+""}if("string"==typeof r&&null!=e[r])return e[r]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const i=(ee(t,e,r)??t.id??e)+"",o=ie(ee(t,e,s)),n=ie(ee(t,e,a));if(null!=o&&null!=n){const t={x:o,y:n};w.set(i,t),S.push(t)}k.set(i,(t.label??t.name??i)+"")});const M=[];o.forEach((t,e)=>{const i=A(ee(t,e,g)),o=A(ee(t,e,m)),n=Math.max(0,ie(ee(t,e,x))??0),r=Ti(h?ee(t,e,h):void 0),s=r.length?r:Ti(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${i}-${o}-${e}`)+"",link:t,index:e,source:i,target:o,throughput:n,rawPath:s})});const _=(T=S,"normalized"===(P=e)||"pixels"===P?P:T.length>0&&T.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var P,T;const R=new Map;for(const[t,e]of w)R.set(t,Ri(e,b,_));const L=[];for(const t of M){let e=t.rawPath.map(t=>Ri(t,b,_));if(2>e.length){const i=R.get(t.source),o=R.get(t.target);i&&o&&(e=[i,o])}else R.has(t.source)||R.set(t.source,e[0]),R.has(t.target)||R.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),L.push({...t,path:e,packetCount:0}))}const C=ne(u,.12),$=Math.max(1,Math.round(n)),j=L.map(t=>Math.max(1,Math.round(t.throughput*C))),z=j.reduce((t,e)=>t+e,0),E=z>$?$/z:1;L.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(j[e]*E))});let D=L.reduce((t,e)=>t+e.packetCount,0);for(;D>$;){const t=L.reduce((t,e,i)=>e.packetCount>1&&(-1===t||e.packetCount>L[t].packetCount)?i:t,-1);if(-1===t)break;L[t].packetCount-=1,D-=1}const N=new Map,I=new Map,B=[],F=ne(i,90),O=ne(l,4);L.forEach((t,e)=>{N.set(t.target,(N.get(t.target)??0)+t.throughput),I.set(t.source,(I.get(t.source)??0)+t.throughput);const i=Li(t.path);for(let o=0;t.packetCount>o;o+=1){const n=(o+.5)/t.packetCount,r=f?n:oe(.12+.84*n+.04*(v()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*v())),a=Ci(t.path,s),c=Ci(t.path,r),l=$i(t.path,s),u={x:-l.y,y:l.x},h=(v()-.5)*O*1.5;B.push({id:`${t.id}-packet-${o}`,x:a.x+u.x*h,y:a.y+u.y*h,vx:f?0:l.x*F+10*(v()-.5),vy:f?0:l.y*F+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+o/32,shape:{type:"circle",radius:O},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:o,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:i,flowRouteId:t.id,flowSpeed:F,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==d&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*O,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*O),Y=Array.from(R,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+re(t),point:e})),q=Y.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:W,height:W}})),X=Object.fromEntries(Y.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=te(p,[...ii({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*O),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=$,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(R,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+re(t),incoming:N.get(t)??0,outgoing:I.get(t)??0})),H=L.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:G,initialSpawns:B,projectionRows:V.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:B.length,totalThroughput:L.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:V,links:H}}}({nodes:Array.isArray(n.nodes)?n.nodes:[],links:Array.isArray(n.links)?n.links:Array.isArray(n.edges)?n.edges:Array.isArray(t)?t:[],nodeIdAccessor:n.nodeIdAccessor||"id",nodeXAccessor:n.nodeXAccessor||"x",nodeYAccessor:n.nodeYAccessor||"y",sourceAccessor:n.sourceAccessor||"source",targetAccessor:n.targetAccessor||"target",throughputAccessor:n.throughputAccessor||"value",pathAccessor:n.pathAccessor||"path",coordinateMode:n.coordinateMode||"auto",particleRate:n.particleRate??.16,maxParticles:n.maxParticles??180,particleRadius:n.particleRadius??4,flowSpeed:n.flowSpeed??90,pathConstraint:n.pathConstraint||"path",reducedMotion:!0,seed:n.seed??1,size:r});return{...o,config:s.config,initialSpawns:Qi(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Jt(e||n.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[700,380],s=function(t){const e=function(t,e,i){const o=t?.observation;return{...t,observation:{...o,chartId:e??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:i??o?.onObservation}}}(t.config,t.chartId,t.onObservation),i=Fi(t.colorScheme,t.themeCategorical,g),o=Ut(t.size),n={data:t.data,scales:{x:(0,Bi.scaleLinear)().domain(t.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,Bi.scaleLinear)().domain(t.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:t.semantic,categorical:[...i]},resolveColor:Oi(i,t.colorScheme),config:t.layoutConfig??{},world:new Si(e)},r=t.skipLayout?{}:t.layout(n)??{},s=function(t,e){if(!e?.length)return t;const i=new Map;for(const t of e){const{bodyId:e,...o}=t,n=i.get(e)??[];n.push(o),i.set(e,n)}return t.map(t=>{const e=i.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Wi(e,r),context:n,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}({chartId:n.chartId,colorScheme:i,config:n.config,data:Array.isArray(t)?t:[],layout:n.layout,layoutConfig:n.layoutConfig,semantic:Dt(Bt)??{},size:r,themeCategorical:Bt.colors.categorical,xExtent:n.xExtent,yExtent:n.yExtent});return{...o,config:s.config,initialSpawns:Qi(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Jt(e||n.colorBy)}}}};function to(t){if(!t)return Bt;if("string"==typeof t){if("light"===t)return Bt;if("dark"===t)return Ft;if("high-contrast"===t)return Ot;return Xt[t]||Bt}const e="dark"===t.mode?Ft:Bt;return Nt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}},tooltip:{...e.tooltip,...t.tooltip||{}}})}function eo(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:t.colors.annotation??t.colors.text,legendSize:t.typography.legendSize??t.typography.labelSize,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}function io(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function oo(t){if(!t||2>t.length)return;const e=io(t[0]),i=io(t[t.length-1]);return null!==e&&null!==i?[e,i]:void 0}function no(t){const{count:e,byType:i}=function(t){const e={};for(const i of t){const t="string"==typeof i?.type&&i.type.length>0?i.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),o=0===e,n=[...t.extraWarnings??[]];return o&&!n.includes("EMPTY_SCENE")&&n.push("EMPTY_SCENE"),{component:"",frameType:t.frameType,status:o?"empty":"ok",empty:o,markCount:e,markCountByType:i,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:Array.isArray(t.annotations)?t.annotations.length:0,ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:n}}function ro(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function so(t){return"object"==typeof t&&null!==t&&"gradient"in t}var ao=Object.freeze([]);function co(t){if(!t)return ao;let e=!1;for(let i=0;t.length>i;i++){const o=t[i];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const i=[];for(const e of t)null!=e&&"object"==typeof e&&i.push(e);return i}var lo=c(require("react")),uo=c(require("react-dom/server")),ho=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let i=0,o=[];e.length>t&&(i=e.length-t,o=e.slice(0,i)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=i;e.length>t;t++)this.push(e[t]);return o}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++){const r=(o+n)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},i.push(t),this.buffer[r]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},fo=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function po(t,e){return t===e}function yo(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function go(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function mo(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var xo=/^\d{4}-\d{1,2}$/;function bo(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const i=xo.test(e)?e+"-01":e;if(i===e&&10>e.length)return NaN;const o=Date.parse(i);return Number.isFinite(o)?o:NaN}function vo(t){return t instanceof Date?t.getTime():"string"==typeof t?bo(t):+t}function wo(t){return new Set(Array.isArray(t)?t:[t])}function ko(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function So(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Ao(t,e,i){return t+(e-t)*i}function Mo(){return"undefined"!=typeof performance?performance.now():Date.now()}function _o(t,e,i){if(1>=i)return 1;const o=i-1;return function(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const i=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>i?1:e;if("exponential"===t.type){const o=t.halfLife??t.extent/2;return e+Math.pow(.5,i/(o>0?o:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-i/t.extent))*(1-e)}({age:o-e,extent:o,type:t.type,halfLife:t.halfLife??i/2,threshold:t.stepThreshold??.5*i,minOpacity:t.minOpacity??.1})}function Po(t){const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return e}function To(t,e,i){const o=t.duration??500,n=i-e;return o>n?1-n/o:0}function Ro(t,e,i,o){let n=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,n=!0),t._pulseColor!==i&&(t._pulseColor=i,n=!0),t._pulseGlowRadius!==o&&(t._pulseGlowRadius=o,n=!0),n):(0!==t._pulseIntensity&&(t._pulseIntensity=0,n=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,n=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,n=!0),n)}function Lo(t,e,i=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const o=t.duration??500,n=e.peek();return null!=n&&o>i-n}function Co(t,e,i){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+i;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function $o(t,e,i,o,n,r){const s=[];for(const n of t){const t=i(n),r=o(n);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:n})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:n,datum:l,group:r}}function jo(t,e,i,o,n,r,s,a){const c=[];for(const r of t){const t=i(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(r):n;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:r,datum:t,group:s}}function zo(t,e,i,o){const n=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const n of e)t+=i(n,o)||0;n.set(o,-t/2)}else if("wiggle"===o){t.length>0&&n.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let a=0,c=0,l=0;for(const t of e){const e=i(t,s)||0;a+=(2*l+e)*(e-(i(t,r)||0)),c+=e,l+=e}const u=n.get(r)??0;n.set(s,u-(c>0?a/(2*c):0))}if(t.length>0){let o=0;for(const r of t){let t=0;for(const o of e)t+=i(o,r)||0;o+=(n.get(r)??0)+t/2}const r=o/t.length;for(const e of t)n.set(e,(n.get(e)??0)-r)}}else for(const e of t)n.set(e,0);return n}function Eo(t,e,i,o,n,r,s){const a=i(t),c=o(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:n,style:r,datum:t};return void 0!==s&&(l.pointId=s),l}function Do(t,e,i,o,n,r,s,a){const c=i(t),l=o(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:n,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function No(t,e,i,o,n,r,s){return{type:"rect",x:t,y:e,w:i,h:o,style:n,datum:r,group:s}}function Io(t,e,i,o,n,r,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:n,datum:r};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Bo(t,e,i,o){return"function"==typeof e.style?e.style(o||{},i):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(i,o)}function Fo(t,e,i,o){if(!t.scales)return null;const n=[],r=[];for(const i of e){const e=t.getX(i);if(!Number.isFinite(e))continue;const s=o.getTop(i),a=o.getBottom(i);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=t.scales.x(e),l=t.scales.y(s),u=t.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(n.push([c,l]),r.push([c,u]))}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:Bo(t,o,i,e[0]),datum:e,group:i,interactive:o.interactive}}function Oo(t){const e=[],i=[];if(!t)return{perSeries:e,aggregate:i};for(const o of t)o.perSeries?e.push(o):i.push(o);return{perSeries:e,aggregate:i}}function Wo(t,e,i){const o=[];for(const n of i){const i=Fo(t,e,"__ribbon_aggregate",n);i&&o.push(i)}return o}function Yo(t,e,i,o){const n=[];for(const r of o){const o=Fo(t,e,i,r);o&&n.push(o)}return n}function qo(t,e,i,o){if(!t.config.pointStyle)return;const n=o??t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const r of o.data){let o=t.config.pointStyle(r);!o.fill&&e&&(o={...o,fill:e});const s=o.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,c=Eo(r,t.scales,t.getX,n,s,o,a);c&&i.push(c)}}}function Xo(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var Go={topOpacity:.8,bottomOpacity:.05};function Vo(t){if(t)return!0===t?Go:"colorStops"in t?t:{topOpacity:t.topOpacity??Go.topOpacity,bottomOpacity:t.bottomOpacity??Go.bottomOpacity}}var Ho=require("d3-shape"),Zo={circle:Ho.symbolCircle,square:Ho.symbolSquare,triangle:Ho.symbolTriangle,diamond:Ho.symbolDiamond,star:Ho.symbolStar,cross:Ho.symbolCross,wye:Ho.symbolWye},Ko=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Uo(t,e,i){if(i)return i;const o=t??"circle";return"chevron"===o?function(t){const e=1.5*function(t){return Math.sqrt(Math.max(1,t)/Math.PI)}(t),i=.92*e;return`M0,${-e}L${i},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-i},${(.78*e).toFixed(3)}Z`}(e):(0,Ho.symbol)(Zo[o]??Ho.symbolCircle,Math.max(1,e))()??""}var Qo=new Map;function Jo(t,e,i,o,n){const r=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=r.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},r.set(c,l)),l.total+=a,n){const t=n(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return r}function tn(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:i,overlays:o,warned:n}=t;en(o)&&0===i.length&&on(n,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(t=>null==t.datum)&&on(n,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function en(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(en))}function on(t,e,i){t.has(e)||(t.add(e),console.warn(i))}function nn(t,e,i,o){const n=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),r="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:r,message:`Semiotic ${t} ${r} failed: ${n.message}`,error:n,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:o}}function rn(t,e){const i="function"==typeof t?t:i=>i[t||e];return t=>{const e=i(t);return null==e?NaN:+e}}function sn(t){const e=[],i=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=rn(i&&t.valueAccessor||t.yAccessor,i?"value":"y");if(t.boundsAccessor){const i=yo(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const n=i(t);return Number.isFinite(n)&&0!==n?e+n:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const n=i(t);return Number.isFinite(n)&&0!==n?e-n:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const i=Array.isArray(t.band)?t.band:[t.band];for(const t of i)e.push({kind:"band",getTop:rn(t.y1Accessor,"y1"),getBottom:rn(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}var an=require("d3-scale");function cn(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function ln(t,e,i){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return(0,an.scaleLog)().domain(t).range(i).clamp(!0)}return"symlog"===t?(0,an.scaleSymlog)().domain(e).range(i):"time"===t?(0,an.scaleTime)().domain([new Date(e[0]),new Date(e[1])]).range(i):(0,an.scaleLinear)().domain(e).range(i)}function un(t,e,i){e>t.capacity&&(t.resize(e),i&&e>i.capacity&&i.resize(e))}function hn(t,e){const i=new ho(t.capacity);return t.forEach(()=>i.push(e)),i}function dn(t,e,i,o){const n=t.push(e);return i&&i.push(o),n}function fn(t,e,i){if(!e||0===e.size)return;const o=new Set;if(t.forEach((t,e)=>{i(t)&&o.add(e)}),0===o.size)return;const n=e.toArray();e.clear();for(let t=0;n.length>t;t++)o.has(t)||e.push(n[t])}var pn=new WeakMap;function yn(){return this.updateResults.last}function gn(){return this.updateResults.last}function mn(t){return this.updateResults.subscribe(t)}function xn(t){this.config.layoutSelection=t}function bn(){pn.set(this,!0)}function vn(){const t=!0===pn.get(this);return pn.delete(this),t}function wn(t){Object.assign(t.prototype,{getLastUpdateResult:yn,getUpdateSnapshot:gn,subscribeUpdateResult:mn,setLayoutSelection:xn,markStylePaintPending:bn,consumeStylePaintPending:vn})}var kn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Sn=["scene-style","data-paint","accessibility","evidence"],An=(t,e)=>({retainedData:t,invalidations:e}),Mn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],_n=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Tn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rn=["scene-geometry","data-paint","accessibility","evidence"],Ln=["scene-style","data-paint","accessibility","evidence"],Cn=[],$n={chartType:An("rebuild",Mn),runtimeMode:An("rebuild",Mn),xAccessor:An("rebuild",Mn),yAccessor:An("rebuild",Mn),timeAccessor:An("rebuild",Mn),valueAccessor:An("rebuild",Mn),y0Accessor:An("rebuild",Mn),boundsAccessor:An("rebuild",Mn),band:An("rebuild",Mn),openAccessor:An("rebuild",Mn),highAccessor:An("rebuild",Mn),lowAccessor:An("rebuild",Mn),closeAccessor:An("rebuild",Mn),candlestickRangeMode:An("rebuild",Mn),accessorRevision:An("rebuild",Mn),groupAccessor:An("rebuild",_n),categoryAccessor:An("rebuild",_n),lineDataAccessor:An("rebuild",_n),colorAccessor:An("rebuild",Ln),sizeAccessor:An("rebuild",Rn),symbolAccessor:An("rebuild",Rn),pointIdAccessor:An("rebuild",Rn),xScaleType:An("preserve",Pn),yScaleType:An("preserve",Pn),xExtent:An("preserve",Pn),yExtent:An("preserve",Pn),extentPadding:An("preserve",Pn),scalePadding:An("preserve",Pn),axisExtent:An("preserve",Pn),binSize:An("preserve",Pn),normalize:An("preserve",Pn),heatmapAggregation:An("preserve",Pn),heatmapXBins:An("preserve",Pn),heatmapYBins:An("preserve",Pn),arrowOfTime:An("preserve",Tn),baseline:An("preserve",Tn),stackOrder:An("preserve",Tn),sizeRange:An("preserve",Tn),curve:An("preserve",Tn),areaGroups:An("preserve",Tn),customLayout:An("preserve",Tn),layoutConfig:An("preserve",Tn),layoutMargin:An("preserve",Tn),symbolMap:An("preserve",Rn),showValues:An("preserve",Rn),heatmapValueFormat:An("preserve",Rn),lineStyle:An("preserve",Ln),pointStyle:An("preserve",Ln),areaStyle:An("preserve",Ln),barStyle:An("preserve",Ln),swarmStyle:An("preserve",Ln),waterfallStyle:An("preserve",Ln),candlestickStyle:An("preserve",Ln),boundsStyle:An("preserve",Ln),gradientFill:An("preserve",Ln),lineGradient:An("preserve",Ln),colorScheme:An("preserve",Ln),themeCategorical:An("preserve",Ln),themeSemantic:An("preserve",Ln),themeSequential:An("preserve",Ln),themeDiverging:An("preserve",Ln),barColors:An("preserve",Ln),decay:An("preserve",Ln),pulse:An("preserve",Ln),staleness:An("preserve",Ln),layoutSelection:An("preserve",Ln),annotations:An("preserve",["overlay","accessibility","evidence"]),windowSize:An("preserve",Cn),windowMode:An("preserve",Cn),maxCapacity:An("preserve",Cn),clock:An("preserve",Cn),transition:An("preserve",Cn),introAnimation:An("preserve",Cn),onLayoutError:An("preserve",Cn)},jn=An("preserve",Tn),zn=class{constructor(){this.tracker=new ai}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},kn)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Sn):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=$n[o]??jn;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},En=require("d3-quadtree"),Dn=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let i=0,o=0;for(const t of e)"point"===t.type&&(i++,t.r>o&&(o=t.r));if(this.maxRadius=o,500>=i)return void(this.tree=null);const n=Array(i);let r=0;for(const t of e)"point"===t.type&&(n[r++]=t);this.tree=(0,En.quadtree)().x(t=>t.x).y(t=>t.y).addAll(n)}},Nn=class t{constructor(t){if(this.xExtent=new fo,this.yExtent=new fo,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new zn,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new Dn,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,n,r=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;const l=n??(()=>{const t=new Map;for(let e=0;i.length>e;e++)t.set(i[e],e);return t})();for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let n=0,a=!1;for(const i of e){const e=l.get(i);if(null==e)continue;a=!0;const s=o.get(e);if(null==s)continue;const c=To(t,s,r);c>n&&(n=c)}a&&(c=Ro(i,n,s)||c);continue}const e=l.get(i.datum);if(null==e)continue;const n=o.get(e);c=Ro(i,null==n?0:To(t,n,r),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),i),this.config=t,this.buffer=new ho(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=yo(t.timeAccessor||t.xAccessor,"time"),this.getY=yo(t.valueAccessor||t.yAccessor,"value")):(this.getX=yo(t.xAccessor,"x"),this.getY=yo(t.yAccessor,"y")),this.getGroup=mo(t.groupAccessor),this.getCategory=mo(t.categoryAccessor),this.getSize=t.sizeAccessor?yo(t.sizeAccessor,"size"):void 0,this.getColor=mo(t.colorAccessor),this.getSymbol=mo(t.symbolAccessor),this.getY0=t.y0Accessor?yo(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=sn(t),this.getPointId=mo(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?yo(t.openAccessor,"open"):void 0,this.getHigh=yo(t.highAccessor,"high"),this.getLow=yo(t.lowAccessor,"low"),this.getClose=i?yo(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new ho(t.windowSize))}currentTime(){return this.config.clock?.()??Mo()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=hn(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?yo(this.config.timeAccessor||this.config.xAccessor,"time"):yo(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],n=o instanceof Date,r="string"==typeof o&&Number.isFinite(bo(o));if(this.xIsDate=n||r,r){const t="string"==typeof i?i:void 0;this.getX=t?e=>vo(e[t]):t=>vo(i(t))}}un(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)dn(this.buffer,i,this.timestampBuffer,e),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=dn(this.buffer,i,this.timestampBuffer,e);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,n=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.yExtent.extent;let a=cn(this.xExtent.extent,e.xExtent),c=cn(s,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&i.size>0){const t=function(t){const{config:e,groups:i,getX:o,getY:n}=t,r="exact"===e.axisExtent;if(e.normalize){const i=[0,r?1:1+e.extentPadding];return{yDomain:i,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:i}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const t of i){const e=new Map;let i=0;for(const r of t.data){const t=o(r),s=n(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),i+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),h.set(t.key,i)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===d)p=i.map(t=>t.key);else if("insideOut"===d){const t=[...i].map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}),e=[],o=[];let n=0,r=0;for(const i of t)r>n?(e.push(i),n+=h.get(i)??0):(o.push(i),r+=h.get(i)??0);p=[...o.reverse(),...e]}else p="asc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(t)??0)-(h.get(e)??0);return 0!==i?i:f(t,e)}):"desc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}):i.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),i=zo(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let o=1/0,n=-1/0;for(const e of t){const t=i.get(e)??0,r=u.get(e)??0;o>t&&(o=t),t+r>n&&(n=t+r)}Number.isFinite(o)&&Number.isFinite(n)||(o=0,n=0);const s=n-o,l=r?0:s>0?s*e.extentPadding:1;y=[o-l,n+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[i,o]=function(t,e,i){let o=0,n=0;for(const r of t){let t=0,s=0;for(const o of e){const e=i(o,r)||0;0>e?s+=e:t+=e}o>s&&(o=s),t>n&&(n=t)}return[o,n]}(t,p,(t,e)=>a.get(t)?.get(e)||0),n=o-i,s=r?0:n>0?n*e.extentPadding:1;y=[i-s,o+s]}else y=[0,l+(r?0:l>0?l*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&i.size>0?c=function(t,e,i,o,n,r,s){const[,a]=function(t,e,i,o,n){const r=Jo(t,e,i,o,n);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(t,e,i,o,n);return[0,s?a:a+a*r]}(i,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!l&&i.size>0?c=function(t,e,i,o){const[n,r]=function(t,e){let i=0,o=0,n=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(n+=t,i>n&&(i=n),n>o&&(o=n))}return[i,o]}(t,e),s=r-n,a=o?0:s>0?s*i:1;return[Math.min(0,n-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(i,this.getY,e.extentPadding,h):l||c[0]===1/0||(c=function(t,e,i){if(!i.length)return t;let[o,n]=t;for(const t of e)for(const e of i){const i=e.getTop(t),r=e.getBottom(t);Number.isFinite(i)&&(o>i&&(o=i),i>n&&(n=i)),Number.isFinite(r)&&(o>r&&(o=r),r>n&&(n=r))}return[o,n]}(c,r,this.resolvedRibbons),c=function(t,e){const i=t[1]-t[0],o=e.exactMode?0:i>0?i*e.extentPadding:1,n=[null!=e.userMin?t[0]:t[0]-o,null!=e.userMax?t[1]:t[1]+o];return"log"!==e.yScaleType||n[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(n[0]=e.dataYDomain[0]/(1+e.extentPadding)),n}(c,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));c=function(t,e,i){if(!e||i)return t;const o=e[0],n=e[1];return null==o&&null==n?t:[null!=o?o:t[0],null!=n?n:t[1]]}(c,e.yExtent,!!l),({xDomain:a,yDomain:c}=function(t,e,i){let o=t,n=e;if(o[0]===1/0||o[1]===-1/0)if("time"===i){const t=Date.now();o=[t-864e5,t]}else o=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:o,yDomain:n}}(a,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:i,xDomain:o,yDomain:n}=t,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(i.width,i.height)/2-1));if(r){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,i.width-s]:[i.width-s,s];return{x:(0,an.scaleLinear)().domain(o).range(t),y:ln(e.yScaleType,n,[i.height-s,s])}}const t="down"===e.arrowOfTime?[s,i.height-s]:[i.height-s,s];return{x:ln(e.yScaleType,n,[s,i.width-s]),y:(0,an.scaleLinear)().domain(o).range(t)}}var a;return{x:ln(e.xScaleType,o,[s,i.width-s]),y:ln(e.yScaleType,n,[i.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=n):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":case"glyph":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),n=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=ln,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,r[0]>r[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,n,l?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:i,scales:o}=this;if(!o)return[];if(i.customLayout){const n={data:e,scales:o,dimensions:{width:t.width,height:t.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??j},resolveColor:(t,e)=>{const o=this.resolveGroupColor(t);if(o)return o;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null};let r;try{r=i.customLayout(n)}catch(t){const e=null!==this.lastCustomLayoutResult,o=nn("xy",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{i.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const s=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return tn({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const n={scales:o,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){const i=t.groupData(e),o=[],n=t.config.annotations?.filter(Xo).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Oo(t.ribbons);if(r.length>0&&o.push(...Wo(t,e,r)),n.length>0)for(const e of i)o.push(...Yo(t,e.data,e.key,n))}for(const e of i){const i=t.resolveLineStyle(e.key,e.data[0]),r=$o(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(r.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return qo(t,i,o),o}(n,e);case"area":return function(t,e){const i=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Oo(t.ribbons);if(r.length>0&&o.push(...Wo(t,e,r)),n.length>0)for(const e of i)o.push(...Yo(t,e.data,e.key,n))}const n=t.scales.y.domain()[0],r=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=jo(e.data,t.scales,t.getX,t.getY,n,i,e.key,r),a=Vo(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return qo(t,i,o),o}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],n=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Oo(t.ribbons);if(r.length>0&&o.push(...Wo(t,e,r)),n.length>0)for(const e of i)o.push(...Yo(t,e.data,e.key,n))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i)if(n.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),n=jo(e.data,t.scales,t.getX,t.getY,r,i,e.key,s),a=Vo(t.config.gradientFill);a&&(n.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}else{const i=t.resolveLineStyle(e.key,e.data[0]),n=$o(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}return qo(t,i,o),o}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e),o=t.config.stackOrder??"key",n=()=>i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===o);else if("key"===o)n();else if("asc"===o||"desc"===o||"insideOut"===o){const e=new Map;for(const o of i){let i=0;for(const e of o.data){const o=t.getX(e),n=t.getY(e);Number.isFinite(o)&&Number.isFinite(n)&&(i+=n)}e.set(o.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===o)i.sort((t,i)=>{const o=(e.get(t.key)??0)-(e.get(i.key)??0);return 0!==o?o:n(t.key,i.key)});else if("desc"===o)i.sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:n(t.key,i.key)});else{const t=[...i].sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:n(t.key,i.key)}),o=[],r=[];let s=0,a=0;for(const i of t)a>s?(o.push(i),s+=e.get(i.key)??0):(r.push(i),a+=e.get(i.key)??0);i.length=0,i.push(...r.reverse(),...o)}}else n();const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:c}=function(t,e,i,o,n,r,s,a="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);Number.isFinite(e)&&c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=i(n),r=o(n);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let h;if(r){h=new Map;for(const e of l){let i=0;for(const o of t)i+=u.get(o.key)?.get(e)||0;h.set(e,i||1)}}const d=zo(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!r,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of l)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const i of t){const t=u.get(i.key),o=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:c,style:n(i.key,i.data[0]),datum:i.data,group:i.key};s&&(t.curve=s),p.push(t)}a=[],c=[]};for(const i of l){const n=t.has(i);let s,l,u=n?t.get(i):0;if(r&&n&&(u/=h.get(i)),!n||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(i),l=s+u,m.set(i,l)):(s=x.get(i),l=s+u,x.set(i,l)):(s=g.get(i),l=s+u,g.set(i,l));const p=e.x(i);c.push([p,e.y(s)]),a.push([p,e.y(l)]),o.set(i,l)}d(),y.set(i.key,o)}return{nodes:p,stackedTops:y}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,r,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=c.get(o.key);if(i)for(const n of o.data){const o=t.getX(n),r=t.getY(n);null==o||Number.isNaN(o)||null==r||Number.isNaN(r)||!i.has(o)||e.set(n,i.get(o))}}const o=i=>e.get(i)??t.getY(i);qo(t,i,l,o)}return l}(n,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let r=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);r=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",c=t.getSymbol,l=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=l?.[t];if(e)return e;let i=u.get(t);return i||(i=Ko[h%Ko.length],h++,u.set(t,i)),i};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},l=e.r||o;if(r&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(l=r(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(n);i&&s.has(i)&&(e={...e,fill:s.get(i)})}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const o=d(c(n)+""),r=Do(n,t.scales,t.getX,t.getY,Math.PI*l*l,o,e,u);r&&i.push(r)}else{const o=Eo(n,t.scales,t.getX,t.getY,l,e,u);o&&i.push(o)}}return i}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){const o=Math.max(1,Math.floor(t.config.heatmapXBins??20)),n=Math.max(1,Math.floor(t.config.heatmapYBins??20)),r=t.config.heatmapAggregation??"count",s=yo(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),h=(c-a||1)/o,d=(u-l||1)/n,f=o*n;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let i=0;e.length>i;i++){const r=e[i],c=t.getX(r),u=t.getY(r);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),o-1),g=Math.min(Math.floor((u-l)/d),n-1);if(0>f||0>g)continue;const m=g*o+f;p[m]++;const x=s(r);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===p[t])continue;let e;switch(r){case"sum":e=y[t];break;case"mean":e=y[t]/p[t];break;default:e=p[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,b=i.width/o,v=i.height/n,w=t.config.showValues,k=t.config.heatmapValueFormat,S=[];for(let t=0;n>t;t++){const e=t*o;for(let i=0;o>i;i++){const o=e+i;if(0===p[o])continue;let s;switch(r){case"sum":s=y[o];break;case"mean":s=y[o]/p[o];break;default:s=p[o]}const c=(s-g)/x;S.push(Io(i*b,(n-1-t)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:i,yi:t,value:s,count:p[o],sum:y[o],xCenter:a+(i+.5)*h,yCenter:l+(t+.5)*d,agg:r},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(t,e,i);if(0===e.length)return[];const o=yo(t.config.valueAccessor,"value"),n=go(t.config.xAccessor,"x"),r=go(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=n(i),u=r(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),p=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(p){d.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),b=new Map;let v=0;for(let t=0;e.length>t;t++){const i=e[t],n=s.get(c[t]),r=a.get(l[t]);if(void 0===n||void 0===r)continue;const h=o(i),d=r*u+n,f=b.get(d);let p;void 0!==f?p=f:(p=v++,b.set(d,p)),g[p]=d,m[p]=h,x[p]=i}let w=1/0,k=-1/0;for(let t=0;v>t;t++){const e=m[t];isFinite(e)&&(w>e&&(w=e),e>k&&(k=e))}if(!isFinite(w)||!isFinite(k))return[];const S=function(t){const e=t in R?t:"blues";let i=Qo.get(e);if(i)return i;i=Array(256);const o=L(e);for(let t=0;256>t;t++)i[t]=o(t/255);return Qo.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),A=255/(k-w||1),M=i.width/u,_=i.height/h,P=t.config.showValues,T=t.config.heatmapValueFormat,C=[];for(let t=0;v>t;t++){const e=m[t];if(!isFinite(e))continue;const i=g[t],o=i%u;C.push(Io(o*M,(h-1-(i-o)/u)*_,M,_,S[Math.min((e-w)*A+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:T}:void 0))}return C}(n,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=Jo(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const i of t.categories.keys())e.add(i);const n=t.config.barColors?Object.keys(t.config.barColors):[],r=new Set(n),s=Array.from(e).filter(t=>!r.has(t)).sort(),a=n.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:c,order:o})}const n=[],r=t.scales,[s,a]=r.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const e of i.values()){const i=Math.max(e.start,s),u=Math.min(e.end,a);if(i>=u)continue;const f=r.x(i),p=r.x(u),y=Math.abs(p-f),g=y>h+1?h:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&e.categories.size>0){let i=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=r.y(i),u=r.y(i+o);n.push(No(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),i+=o}}else{const t=r.y(0),i=r.y(e.total);n.push(No(m,Math.min(t,i),x,Math.abs(t-i),{fill:c?.fill||l||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of i.values())f.add(t.start),f.add(t.end);return{nodes:n,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=n.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const i=[],o=t.config.swarmStyle||{},n=o.radius??3,r=o.fill??t.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,c=o.strokeWidth;for(const o of e){const e=t.getX(o),l=t.getY(o);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),h=t.scales.y(l);let d=r;if(t.getCategory){const e=t.getCategory(o);d=t.config.barColors?.[e]||d}const{r:f,...p}=t.config.pointStyle?.(o)??{},y={type:"point",x:u,y:h,r:f??n,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...p},datum:o};t.getPointId&&(y.pointId=t.getPointId(o)+""),i.push(y)}return i}(n,e);case"waterfall":return function(t,e,i){const o=[],n=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,h=r?.strokeWidth,d=r?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-y:e>0?y-t.getX(s[e-1]):0;const b=n.x(y),v=0!==x?n.x(y+x):b+i.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=n.y(f),A=n.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),o.push(No(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth})),f=m}return o}(n,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const i=t.config.candlestickRangeMode??!1;if(!(i||t.getOpen&&t.getClose))return[];const o=[],n=t.config.candlestickStyle||{},r=n.rangeColor||"#6366f1",s=i?r:n.upColor||"#28a745",a=i?r:n.downColor||"#dc3545",c=i?r:n.wickColor||"#333",l=n.wickWidth||(i?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=n.bodyWidth??0;if(null==n.bodyWidth)if(u.length>1){let e=1/0;for(let i=1;u.length>i;i++){const o=Math.abs(t.scales.x(u[i])-t.scales.x(u[i-1]));o>0&&e>o&&(e=o)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),u=t.getLow(n);if(null==r||Number.isNaN(r)||null==u||Number.isNaN(u))continue;const d=i?r:t.getOpen(n),f=i?u:t.getClose(n);if(!i&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const p=f>=d,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:n};i&&(y.isRange=!0),o.push(y)}return o}(n,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,i,o){const n=t.boundsStyle;return"function"==typeof n?n(i||{},e):n&&"object"==typeof n?n:{fill:o(e,i).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?_o(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=Po(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,i,o=Po(i)){const n=i.length;if(n>1)for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let i=0;e.length>i;i++){const a=o.get(e[i]);null!=a?(r[i]=_o(t,a,n),1>r[i]&&(s=!0)):r[i]=1}s&&(i._decayOpacities=r);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let i=0;e.length>i;i++){const r=o.get(e[i]);null!=r?(s[i]=_o(t,r,n),1>s[i]&&(a=!0)):s[i]=1}a&&(i._decayOpacities=s)}else{let s=1;for(const i of e){const e=o.get(i);if(null!=e){const i=_o(t,e,n);s>i&&(s=i)}}if(1>s){const t=Array(r);t.fill(s),i._decayOpacities=t}}continue}const e=o.get(i.datum);if(null==e)continue;const r=_o(t,e,n);"heatcell"===i.type?i.style={opacity:r}:"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Lo(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){i.clear(),o.clear();for(let n=0;e.length>n;n++){const r=e[n],s=Co(t,r,n);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:r.style.opacity,glyph:r.glyph}):"rect"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style?.opacity}):"candlestick"===r.type?i.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:r.style?.opacity}):"line"===r.type?o.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&o.set(s,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=Co(this.transitionContext,i,e);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(o,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(o,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,n,r=Mo()){if(0===o.size&&0===n.size)return i;const s=e.duration??300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let e=0;i.scene.length>e;e++){const r=i.scene[e],s=Co(t,r,e);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){const t=n.get(s);if(t){if(l.add(s),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];a=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];a=!0}r._targetOpacity=r.style.opacity??1,r._startOpacity=t.opacity??r.style.opacity??1}else r._targetOpacity=r.style.opacity??1,r._startOpacity=0,r.style={...r.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=u.x,r.y=u.y,r.r=u.r??r.r,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("glyph"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,size:r.size};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.size,r.x=u.x,r.y=u.y,r.size=u.r??r.size,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("rect"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("heatcell"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){c.add(s);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=r.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=u.x,r.openY=u.openY,r.closeY=u.closeY??r.closeY,r.highY=u.highY??r.highY,r.lowY=u.lowY??r.lowY,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0}for(const[t,e]of n)if(!l.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}for(const[t,e]of o)if(!c.has(t)){if(t.startsWith("p:"))i.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)i.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))i.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const o=e.openY??e.y;i.exitNodes.push({type:"candlestick",x:e.x,openY:o,closeY:e.closeY??o,highY:e.highY??o,lowY:e.lowY??o,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:r,duration:s}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){if(!i.activeTransition)return!1;const n=So(t,i.activeTransition),r=ko(n,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Ao(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Ao(i.x,t._targetX,r),t.y=Ao(i.y,t._targetY,r),void 0!==t._targetR&&void 0!==i.r&&(t.r=Ao(i.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Ao(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Ao(i.x,t._targetX,r),t.y=Ao(i.y,t._targetY,r),void 0!==t._targetR&&void 0!==i.r&&(t.size=Ao(i.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Ao(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Ao(i.x,t._targetX,r),t.y=Ao(i.y,t._targetY,r),void 0!==i.w&&(t.w=Ao(i.w,t._targetW,r)),void 0!==i.h&&(t.h=Ao(i.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Ao(i?i.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Ao(i.x,t._targetX,r),t.y=Ao(i.y,t._targetY,r),void 0!==i.w&&(t.w=Ao(i.w,t._targetW,r)),void 0!==i.h&&(t.h=Ao(i.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Ao(i?i.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Ao(i.x,t._targetX,r),void 0!==i.openY&&(t.openY=Ao(i.openY,t._targetOpenY,r)),void 0!==i.closeY&&(t.closeY=Ao(i.closeY,t._targetCloseY,r)),void 0!==i.highY&&(t.highY=Ao(i.highY,t._targetHighY,r)),void 0!==i.lowY&&(t.lowY=Ao(i.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Ao(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=Ao(e[o][0],i[o][0],r),t.path[o][1]=Ao(e[o][1],i[o][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Ao(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,n=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=Ao(e[i][0],o[i][0],r),t.topPath[i][1]=Ao(e[i][1],o[i][1],r);if(i&&n&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Ao(i[e][0],n[e][0],r),t.bottomPath[e][1]=Ao(i[e][1],n[e][1],r)}}if(n>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:i}=function(t,e,i,o){if(o&&o.version===i&&o.group===e&&o.data===t)return{result:o.result,cache:o};let n;if(e){const i=new Map;for(const o of t){const t=e(o);i.has(t)||i.set(t,[]),i.get(t).push(o)}n=Array.from(i.entries()).map(([t,e])=>({key:t,data:e}))}else n=[{key:"_default",data:t}];return{result:n,cache:{version:i,group:e,data:t,result:n}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,e}resolveColorMap(t){const{map:e,cache:i}=function(t,e,i,o,n){if(n&&n.version===o)return{map:n.map,cache:n};const r=new Set;if(e)for(const i of t){const t=e(i);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(n&&n.key===a){const t={...n,version:o};return{map:t.map,cache:t}}const c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical||j,l=new Map;for(let t=0;s.length>t;t++)l.set(s[t],c[t%c.length]);return{map:l,cache:{key:a,map:l,version:o}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,e}resolveLineStyle(t,e){return function(t,e,i,o){const n=t.lineStyle;if("function"==typeof n){const t=n(i||{},e);if(t&&!t.stroke&&e){const i=o(e);if(i)return{...t,stroke:i}}return t}const r=t.themeSemantic?.primary;return n&&"object"==typeof n?{stroke:n.stroke||r||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:o(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,i,o){if(t.areaStyle){const n=t.areaStyle(i||{});if(n&&!n.fill&&e){const t=o(e);if(t)return{...n,fill:t,stroke:n.stroke||t}}return n}const n=t.lineStyle;if("function"==typeof n){const t=n(i||{},e);if(t&&!t.fill&&e){const i=o(e);if(i)return{...t,fill:i,stroke:t.stroke||i}}return t}const r=t.themeSemantic?.primary;if(n&&"object"==typeof n)return{fill:n.fill||n.stroke||r||"#4e79a7",fillOpacity:n.fillOpacity??.7,stroke:n.stroke||r||"#4e79a7",strokeWidth:n.strokeWidth||2};const s=o(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:i,groupColorCounter:o}=function(t){const{group:e,colorMapCache:i,groupColorMap:o,groupColorMapCap:n,config:r}=t;let{groupColorCounter:s}=t;if(i){const t=i.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=o.get(e);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(r.colorScheme)&&r.colorScheme.length>0?r.colorScheme:null)||(Array.isArray(r.themeCategorical)&&r.themeCategorical.length>0?r.themeCategorical:null)||j;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(e,l),o.size>n){const t=o.keys().next().value;void 0!==t&&o.delete(t)}return{color:l,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=wo(t),i=this.getPointId,o=t=>e.has(i(t));fn(this.buffer,this.timestampBuffer,o);const n=this.buffer.remove(o);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=wo(t),o=this.getPointId,n=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&n.add(e)});const r=this.buffer.update(t=>i.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{n.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},n=i(o,e);o.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let o=!1,n=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const r="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(r||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=r||!po(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!po(i,s);(a||c)&&(t?(this.getX=yo(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=yo(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=yo(this.config.xAccessor,"x"),this.getY=yo(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=sn(this.config)),o=!0,n=!0)}if("groupAccessor"in t&&!po(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?mo(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in t&&!po(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?mo(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in t&&!po(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?yo(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in t&&!po(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?mo(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in t&&!po(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?mo(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in t&&!po(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?yo(this.config.y0Accessor,"y0"):void 0,o=!0,n=!0),("boundsAccessor"in t&&!po(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=sn(this.config),o=!0,n=!0),"pointIdAccessor"in t&&!po(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?mo(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!po(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!po(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!po(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!po(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?yo(this.config.openAccessor,"open"):void 0,this.getHigh=yo(this.config.highAccessor,"high"),this.getLow=yo(this.config.lowAccessor,"low"),this.getClose=e?yo(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,o=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(o=!0,n=!0),!o){const i=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of i)if(t[n]!==e[n]){o=!0;break}}o&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Nn.GROUP_COLOR_MAP_CAP=1e3;var In=Nn;wn(In);var Bn=c(require("react")),Fn=require("d3-shape"),On=require("react/jsx-runtime");function Wn(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function Yn(t,e){const{background:i="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45,lineOpacity:a=1}=t,c=Math.max(8,Math.ceil(2*r));return(0,On.jsxs)("pattern",{id:e,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&(0,On.jsx)("rect",{width:c,height:c,fill:i}),(0,On.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:n,strokeOpacity:a}),(0,On.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:o,strokeWidth:n,strokeOpacity:a})]},e)}function qn(t,e,i="#4e79a7"){if(Wn(t)){const i=function(t,e){let i=2166136261;const o=function(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}(e);for(let t=0;o.length>t;t++)i^=o.charCodeAt(t),i=Math.imul(i,16777619);return`${t}-hatch-${(i>>>0).toString(36)}`}(e,t);return{fill:`url(#${i})`,def:Yn(t,i)}}return t&&"string"==typeof t?{fill:t}:{fill:i}}var Xn=[40,40],Gn=[.5,.5];function Vn(t,e,i,o){if("none"!==t)return"color"===t||null==t?e??o:"accent"===t?i:t}var Hn=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function Zn(t){const{innerRadius:e,outerRadius:i,startAngle:o,endAngle:n}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=Hn(i,o),e=Hn(i,n);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${n-o>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=Hn(i,o),s=Hn(i,n),a=Hn(e,n),c=Hn(e,o),l=n-o>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(i-e)/2));if(0===s)return Zn({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,i-s))),c=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=n-o,u=t.roundStart&&t.roundEnd?l/2:l,h=!!t.roundStart&&u>a,d=!!t.roundEnd&&u>a;if(!h&&!d)return Zn({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(h?a:0),p=n-(d?a:0),y=o+(h?c:0),g=n-(d?c:0),m=Hn(i,f),x=Hn(i,p),b=(i-s)*Math.cos(a),v=Hn(b,o),w=Hn(b,n),k=r?null:Hn(e,g),S=r?null:Hn(e,y),A=r?0:(e+s)*Math.cos(c),M=r?null:Hn(A,o),_=r?null:Hn(A,n),P=p-f>Math.PI?1:0,T=r?0:g-y>Math.PI?1:0;let R="";if(h)R+=`M${v.x},${v.y}`,R+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=Hn(i,o);R+=`M${t.x},${t.y}`}if(d)R+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,R+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=Hn(i,n);R+=` A${i},${i} 0 ${P} 1 ${t.x},${t.y}`}if(r)R+=" L0,0";else{if(d)R+=` L${_.x},${_.y}`,R+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=Hn(e,n);R+=` L${t.x},${t.y}`}if(h)R+=` A${e},${e} 0 ${T} 0 ${S.x},${S.y}`,R+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=Hn(e,o);R+=` A${e},${e} 0 ${T} 0 ${t.x},${t.y}`}}return R+=" Z",R}var Kn=require("react/jsx-runtime"),Un={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Qn(t,e="#4e79a7"){return Wn(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function Jn(t,e,i){const o=Uo(t.symbolType,t.size,t.path);return(0,Kn.jsx)("path",{d:o,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?Qn(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${i??""}symbol-${e}`)}function tr(t,e,i,o){const n=t.glyph;if(!n?.parts?.length||0>=t.size)return null;const r=function(t,e){const[i,o]=t.viewBox??Xn,[n,r]=t.anchor??Gn,s=o>0?o:1,a=Math.max(0,e)/s,c=(i>0?i:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-n*c,offsetY:-r*l}}(n,t.size);if(0>=r.scale)return null;const s=`translate(${e},${i})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${r.offsetX},${r.offsetY}) scale(${r.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),c=function(t,e,i=0,o="horizontal"){const[n,r]=t.viewBox??Xn,s=Math.min(1,Math.max(0,i)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===o?{x:0,y:r*(1-a),width:n,height:r*(a-s)}:{x:n*s,y:0,width:n*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}(n,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),l=c?er(o+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>n.parts.map((i,o)=>{const n=e?"none"===i.fill?void 0:e:Vn(i.fill,a,t.accent),r=e?i.stroke&&"none"!==i.stroke?e:void 0:Vn(i.stroke??"none",a,t.accent);return n||r?(0,Kn.jsx)("path",{d:i.d,fill:n??"none",stroke:r,strokeWidth:r?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},o):null});return(0,Kn.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,Kn.jsx)("clipPath",{id:l,children:(0,Kn.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?(0,Kn.jsx)("g",{children:h(t.ghostColor)}):null,c&&l?(0,Kn.jsx)("g",{clipPath:`url(#${l})`,children:h()}):h()]},o)}function er(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function ir(t,e,i){switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return(0,Kn.jsx)("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+e)}case"area":{const o=t;if(0===o.topPath.length)return null;const n=`M${o.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`,r=`${i?i+"-":""}area-${e}-hatch`,s=Wn(o.style.fill)?Yn(o.style.fill,r):void 0,a=s?`url(#${r})`:Qn(o.style.fill);if(o.clipRect){const t=`${i?i+"-":""}area-clip-${e}`;return(0,Kn.jsxs)("g",{children:[(0,Kn.jsxs)("defs",{children:[s,(0,Kn.jsx)("clipPath",{id:t,children:(0,Kn.jsx)("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),(0,Kn.jsx)("path",{d:n,fill:a,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+e)}return(0,Kn.jsxs)(Bn.Fragment,{children:[s&&(0,Kn.jsx)("defs",{children:s}),(0,Kn.jsx)("path",{d:n,fill:a,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"area-"+e)}case"point":{const o=t,n=`${i?i+"-":""}point-${e}-hatch`,r=Wn(o.style.fill)?Yn(o.style.fill,n):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[r&&(0,Kn.jsx)("defs",{children:r}),(0,Kn.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:r?`url(#${n})`:Qn(o.style.fill),opacity:o.style.opacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+e)}case"symbol":return Jn(t,e);case"glyph":return tr(t,t.x,t.y,`${i??""}glyph-${t.pointId??e}`);case"rect":{const o=t,n=`${i?i+"-":""}xyrect-${e}-hatch`,r=Wn(o.style.fill)?Yn(o.style.fill,n):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[r&&(0,Kn.jsx)("defs",{children:r}),(0,Kn.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r?`url(#${n})`:Qn(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+e)}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),s=.299*o+.587*n+.114*r>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return(0,Kn.jsxs)("g",{children:[(0,Kn.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),(0,Kn.jsx)("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return(0,Kn.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+e)}case"candlestick":{const i=t,o=Math.min(i.openY,i.closeY),n=Math.max(Math.abs(i.openY-i.closeY),1),r=i.isUp?i.upColor:i.downColor;return(0,Kn.jsxs)("g",{children:[(0,Kn.jsx)("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),(0,Kn.jsx)("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:n,fill:r,stroke:r,strokeWidth:1})]},"candle-"+e)}default:return null}}function or(t,e,i){const o=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",n=i=>`ord-${t.type}-${o}-${e}-${i}`,r=`ord-${t.type}-${o}-${e}`;switch(t.type){case"rect":{const e=t,i=er(r)+"-grad",o=function(t,e){const i=t.fillGradient;if(!i)return null;let o=t.x,n=t.y,r=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(n=t.y+t.h,s=t.y):"right"===t.roundedEdge?(o=t.x+t.w,n=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(o=t.x,n=t.y,r=t.x+t.w,s=t.y);const a=[];if("colorStops"in i){const t=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>t.length)return null;for(let e=0;t.length>e;e++)a.push((0,Kn.jsx)("stop",{offset:t[e].offset,stopColor:t[e].color},e))}else{const e=Qn(t.style.fill);a.push((0,Kn.jsx)("stop",{offset:0,stopColor:e,stopOpacity:i.topOpacity},"0")),a.push((0,Kn.jsx)("stop",{offset:1,stopColor:e,stopOpacity:i.bottomOpacity},"1"))}return(0,Kn.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:o,y1:n,x2:r,y2:s,children:a})}(e,i);let n,a;if(o)a=`url(#${i})`;else if(Wn(e.style.fill)){const t=er(r)+"-hatch";n=Yn(e.style.fill,t),a=`url(#${t})`}else a=Qn(e.style.fill);const c=o||n?(0,Kn.jsxs)("defs",{children:[o,n]}):null;if(e.cornerRadii&&(((s=e.cornerRadii).tl??0)>0||(s.tr??0)>0||(s.br??0)>0||(s.bl??0)>0)){const t=function(t){const{x:e,y:i,w:o,h:n}=t,{tl:r,tr:s,br:a,bl:c}=function(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const i=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(t??0,i));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}(t);let l=`M${e+r},${i}`;return l+=` L${e+o-s},${i}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+o},${i+s}`),l+=` L${e+o},${i+n-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+o-a},${i+n}`),l+=` L${e+c},${i+n}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${i+n-c}`),l+=` L${e},${i+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${e+r},${i}`),l+=" Z",l}(e);return(0,Kn.jsxs)(Bn.Fragment,{children:[c,(0,Kn.jsx)("path",{d:t,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}if(e.roundedTop&&e.roundedTop>0){const t=Math.min(e.roundedTop,e.w/2,e.h/2),{x:i,y:o,w:n,h:s}=e;let l;switch(e.roundedEdge){case"right":l=`M${i},${o} L${i+n-t},${o} A${t},${t} 0 0 1 ${i+n},${o+t} L${i+n},${o+s-t} A${t},${t} 0 0 1 ${i+n-t},${o+s} L${i},${o+s} Z`;break;case"left":l=`M${i+n},${o} L${i+t},${o} A${t},${t} 0 0 0 ${i},${o+t} L${i},${o+s-t} A${t},${t} 0 0 0 ${i+t},${o+s} L${i+n},${o+s} Z`;break;case"bottom":l=`M${i},${o} L${i+n},${o} L${i+n},${o+s-t} A${t},${t} 0 0 1 ${i+n-t},${o+s} L${i+t},${o+s} A${t},${t} 0 0 1 ${i},${o+s-t} Z`;break;default:l=`M${i},${o+s} L${i},${o+t} A${t},${t} 0 0 1 ${i+t},${o} L${i+n-t},${o} A${t},${t} 0 0 1 ${i+n},${o+t} L${i+n},${o+s} Z`}return(0,Kn.jsxs)(Bn.Fragment,{children:[c,(0,Kn.jsx)("path",{d:l,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return(0,Kn.jsxs)(Bn.Fragment,{children:[c,(0,Kn.jsx)("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}case"point":{const e=t;return(0,Kn.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:Qn(e.style.fill),opacity:e.style.opacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return Jn(t,e,i);case"glyph":return tr(t,t.x,t.y,`${i??""}ord-glyph-${t.pointId??e}`);case"wedge":{const o=t;if(o._gradientBand&&o._gradientBand.colors.length>0){const t=er(`${i?i+"-":""}gauge-grad-${o.category||r}-${e}`),{clipPath:n,slices:s}=function(t){const e=Zn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),i=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let n=0;o.length>n;n++)i.push({d:Zn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+n*e,endAngle:t.endAngle}),color:o[n]})}return{clipPath:e,slices:i}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return(0,Kn.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,Kn.jsx)("defs",{children:(0,Kn.jsx)("clipPath",{id:t,children:(0,Kn.jsx)("path",{d:n})})}),(0,Kn.jsx)("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>(0,Kn.jsx)("path",{d:t.d,fill:Qn(t.color)},e))}),o.style.stroke&&"none"!==o.style.stroke&&(0,Kn.jsx)("path",{d:n,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},r)}let n;if(o.roundedEnds)n=Zn({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const t=(0,Fn.arc)().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&t.cornerRadius(o.cornerRadius),n=t(Un)||""}return(0,Kn.jsx)("path",{d:n,transform:`translate(${o.cx},${o.cy})`,fill:Qn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},r)}case"boxplot":{const e=t,i=e.columnWidth/2;return(0,Kn.jsxs)("g","vertical"===e.projection?{children:[(0,Kn.jsx)("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Kn.jsx)("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:Qn(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Kn.jsx)("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),(0,Kn.jsx)("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Kn.jsx)("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,Kn.jsx)("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Kn.jsx)("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:Qn(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Kn.jsx)("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),(0,Kn.jsx)("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Kn.jsx)("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1})]},r)}case"violin":{const e=t,i=[(0,Kn.jsx)("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:Qn(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},n("path"))];if(e.iqrLine&&e.bounds){const t=e.bounds,o=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?i.push((0,Kn.jsx)("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,Kn.jsx)("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med"))):i.push((0,Kn.jsx)("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,Kn.jsx)("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med")))}return(0,Kn.jsx)("g",{children:i},r)}case"connector":return(0,Kn.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity??.5},r);case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return(0,Kn.jsx)("polygon",{points:i,fill:Qn(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}var s}var nr=new Set;function rr(t){const{node:e,index:i,renderMode:o,fallback:n}=t,r=function(t,e){const i="function"==typeof t?t(e.datum??null,e):t;return(o=i)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?i:void 0;var o}(o,e);if(!r)return n();const s=r.renderStaticSVG({node:e,style:e.style??{},key:`${r.id}-${i}`});return null!=s?s:(function(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${t}:${e}`;nr.has(i)||(nr.add(i),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}(r.id,e.type??"unknown"),n())}var sr=require("d3-scale"),ar=require("react/jsx-runtime"),cr=14,lr=20,ur=6,hr=8;function dr(t){return"left"===t?"start":"right"===t?"end":t??"start"}function fr(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function pr(t,e,i,o){const n=fr(o);return e+i+Math.ceil(t.length*n*.58)}function yr(t){const{categories:e,theme:i,position:o="right",totalWidth:n,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??cr),l=Math.max(0,a?.labelGap??ur),u=Math.max(0,a?.itemGap??hr),h=Math.max(c,a?.rowHeight??lr),d=c+l,f=Math.min(2,c/2),p="top"===o||"bottom"===o,y=Math.max(c,n-s.left-s.right),g=Math.max(h,r-s.top-s.bottom),m=e.map(t=>pr(t,c,l,i));if(p){const t=Math.max(c,a?.maxWidth??y),i=[];let o=0,n=0;m.forEach((e,r)=>{const s=0===n?e:n+u+e;n>0&&s>t?(i.push({start:o,end:r,width:n}),o=r,n=e):n=s}),e.length>0&&i.push({start:o,end:e.length,width:n});const r=dr(a?.align),s=[];return i.forEach((i,o)=>{let n="center"===r?Math.max(0,(t-i.width)/2):"end"===r?Math.max(0,t-i.width):0;for(let t=i.start;i.end>t;t++)s.push({category:e[t],width:m[t],x:n,y:o*h}),n+=m[t]+u}),{items:s,width:Math.max(0,...i.map(t=>t.width)),height:i.length*h,swatchSize:c,labelOffset:d,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/h)),v=Math.max(1,Math.ceil(e.length/b));return{items:e.map((t,e)=>({category:t,width:m[e],x:Math.floor(e/b)*(x+u),y:e%b*h})),width:v*x+Math.max(0,v-1)*u,height:Math.min(e.length,b)*h,swatchSize:c,labelOffset:d,swatchRadius:f}}function gr(t){const{legendGroups:e,theme:i,position:o="right",totalWidth:n,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??cr),l=Math.max(0,a?.labelGap??ur),u=Math.max(0,a?.itemGap??hr),h=Math.max(c,a?.rowHeight??lr),d=c+l,f=Math.min(2,c/2),p=Math.max(12,fr(i)),y="top"===o||"bottom"===o,g=Math.max(c,n-s.left-s.right),m=Math.max(h,r-s.top-s.bottom);if(y){const o=Math.max(c,a?.maxWidth??g),n=dr(a?.align);let r=0,s=0;const l=[];for(const n of e){const e=n.items.map(t=>t.label),u=yr({...t,categories:e,legendLayout:{...a,maxWidth:Math.max(c,o-p-8),align:"start"}}),h=n.label?p:0,d=n.label?pr(n.label,0,0,i):0,f=h>0?h+8:0,y=f+u.width,g=Math.max(u.height,d);l.push({group:n,x:r,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,s=Math.max(s,g)}const u=l.length>0?r-12:0,h=u>o?0:"center"===n?Math.max(0,(o-u)/2):"end"===n?Math.max(0,o-u):0;return{groups:l.map(t=>({...t,x:t.x+h})),width:u,height:s,swatchSize:c,labelOffset:d,swatchRadius:f}}let x=0,b=0;const v=[];for(const t of e){const e=t.items.map(t=>t.label).map(t=>pr(t,c,l,i)),o=Math.max(0,...e),n=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(h,m-x)/h)))),r=Math.max(1,Math.ceil(t.items.length/n)),s=t.items.map((t,i)=>({category:t.label,width:e[i],x:Math.floor(i/n)*(o+u),y:i%n*h})),a=r*o+Math.max(0,r-1)*u,d=Math.min(t.items.length,n)*h,f=t.label?pr(t.label,0,0,i):0,y=t.label?p+8:0,g=y+d+12,w=Math.max(a,f);v.push({group:t,x:0,y:x,itemOffsetX:0,itemOffsetY:y,width:w,height:g,items:s}),b=Math.max(b,w),x+=g}return{groups:v,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:d,swatchRadius:f}}function mr(t){const e="top"===t.position||"bottom"===t.position,i=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??i,200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function xr(t){const{categories:e,colorScheme:i,theme:o,position:n="right",totalWidth:r,totalHeight:s,margin:a,hasTitle:c=!1}=t;if(!e||0===e.length)return null;const l=function(t,e,i){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>D(t,e)??"#999"}const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:g;return(0,sr.scaleOrdinal)().domain(t).range(o)}(e,i,o),u="top"===n||"bottom"===n,h=yr(t);let d,f;if("left"===n?(d=Math.max(4,a.left-h.width-10),f=a.top):"top"===n?(d=a.left,f=c?32:8):"bottom"===n?(d=a.left,f=Math.min(s-a.bottom+38,s-h.height-2)):(d=Math.min(r-h.width-4,r-a.right+10),f=a.top),u){const t=h.items.map((t,e)=>(0,ar.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,ar.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(t.category),rx:h.swatchRadius}),(0,ar.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:fr(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return(0,ar.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:t})}const p=h.items.map((t,e)=>(0,ar.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,ar.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(t.category),rx:h.swatchRadius}),(0,ar.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:fr(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return(0,ar.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:p})}function br(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}var vr=require("react/jsx-runtime");function wr(t,e=120,i=8){if(!t)return[];const o=Math.max(1,Math.floor(e/i)),n=t.split(/\s+/),r=[];let s="";for(const t of n)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function kr(t,e,i,o){return"curly"===t?o?`M0,0 C${.6*i},0 ${.4*i},${e/2} ${i},${e/2} C${.4*i},${e/2} ${.6*i},${e} 0,${e}`:`M0,0 C0,${.6*i} ${e/2},${.4*i} ${e/2},${i} C${e/2},${.4*i} ${e},${.6*i} ${e},0`:o?`M0,0 L${i},0 L${i},${e} L0,${e}`:`M0,0 L0,${i} L${e},${i} L${e},0`}function Sr(t,e,i,o){if(!t)return(0,vr.jsx)("g",{className:"annotation-note"});const{label:n,title:r,orientation:s,align:a,wrap:c=120,noWrap:l}=t;if(!n&&!r)return(0,vr.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>i?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,p=r?l?[r]:wr(r,c):[],y=n?l?[n]:wr(n,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push((0,vr.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(r&&n?2:0))+f,style:{overflow:"visible"},children:(0,vr.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[r&&(0,vr.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),n&&(0,vr.jsx)("div",{className:"annotation-note-label",children:n})]})},"annotation-note-html")):(p.length>0&&(x.push((0,vr.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:d,fontWeight:"bold",children:p.map((t,e)=>(0,vr.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,vr.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:d,y:m,children:y.map((t,e)=>(0,vr.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((r||n)&&(0!==e||0!==i))if("topBottom"===u){const t=Math.min(c,120);let e=0,i=t;"end"===d?(e=-t,i=0):"middle"===d&&(e=-t/2,i=t/2),v=(0,vr.jsx)("line",{className:"note-line",x1:e,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,i=t;"bottom"===h?(e=-t,i=0):"middle"===h&&(e=-t/2,i=t/2),v=(0,vr.jsx)("line",{className:"note-line",x1:0,x2:0,y1:e,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>i?-(w+2):18:"leftRight"===u&&(k="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),(0,vr.jsxs)("g",{className:"annotation-note",transform:`translate(${e},${i})`,children:[(0,vr.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function Ar(t,e,i,o,n){const r=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&r.push((0,vr.jsx)("circle",{r:t,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,o=e?.height||0;(t>0||o>0)&&r.push((0,vr.jsx)("rect",{width:t,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&r.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=o||0,s=n||0;if(void 0!==e?.x){const o=(e.x||0)-t;r.push((0,vr.jsx)("line",{x1:o,y1:(e.y1||0)-s,x2:o,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const o=(e.y||0)-s;r.push((0,vr.jsx)("line",{x1:(e.x1||0)-t,y1:o,x2:(e.x2||0)-t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?r.push((0,vr.jsx)("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||r.push((0,vr.jsx)("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",o=e?.width??e?.height;void 0!==o&&r.push((0,vr.jsx)("path",{d:kr(t,o,e?.depth||30,void 0===e?.width),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,vr.jsx)("g",{className:"annotation-subject",children:r})}function Mr(t,e,i,o,n,r){const s=[];let a=0,c=0;if("callout-circle"!==n&&"label"!==n||!r?.radius){if("callout-rect"===n&&r){const i=r.width||0,o=r.height||0;if(i>0||o>0){const n=i/2,r=o/2,s=t-n,l=e-r;if(0!==s||0!==l){const t=Math.abs(s),e=Math.abs(l),u=i/2,h=o/2,d=t*h>e*u?u/t:h/e;a=n+s*d,c=r+l*d}}}else if("bracket"===n&&r){const t=r.width,e=r.height,i=r.depth||30;void 0!==t?(a=t/2,c=i):void 0!==e&&(a=i,c=e/2)}}else{const i=(r.radius||0)+(r.radiusPadding||0);if(i>0&&(0!==t||0!==e)){const o=Math.atan2(e,t);a=Math.cos(o)*i,c=Math.sin(o)*i}}const l=Math.sqrt((t-a)**2+(e-c)**2);if(l>.5){const n=o||"var(--semiotic-text-secondary, currentColor)",r="curve"===i?.type;let u=Math.atan2(e-c,t-a);if(r){const o=(a+t)/2,r=(c+e)/2,h=-(e-c)/l,d=(t-a)/l,f=(i?.curve??.25)*l,p=o+h*f,y=r+d*f;s.push((0,vr.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${t},${e}`,fill:"none",stroke:n},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,vr.jsx)("line",{x1:a,y1:c,x2:t,y2:e,stroke:n},"connector-line"));if("arrow"===i?.end){const t=10,e=16/180*Math.PI;s.push((0,vr.jsx)("path",{d:`M${a},${c}L${a+t*Math.cos(u+e)},${c+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${c+t*Math.sin(u-e)}Z`,fill:n,stroke:"none"},"connector-arrow"))}}return(0,vr.jsx)("g",{className:"annotation-connector",children:s})}function _r(t){const{x:e=0,y:i=0,dx:o,dy:n,nx:r,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(i)?i[0]??0:i,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=n||0;null!=r&&(w=r-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const t=l.depth||30;k=t+(0>t?-5:5)}else if(void 0!==l.height){const t=l.depth||30;w=t+(0>t?-5:5),k=l.height/2}return(0,vr.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&Mr(w,k,c,h,S,l),!v.has("subject")&&Ar(S,l,h,x,b),!v.has("note")&&Sr(a,w,k,h)]})}function Pr(t){const{noteData:e}=t,{screenCoordinates:i}=e,o="string"==typeof e.type?e.type:"label",n=e.eventListeners||e.events||{};if(e.coordinates&&i){const t=e.nx||i[0][0]+(e.dx??0),n=e.ny||i[0][1]+(e.dy??0),r=i.map((i,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:i[0],y:i[1],nx:t,ny:n});return(0,vr.jsx)(_r,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+r)});return(0,vr.jsx)("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return(0,vr.jsx)(_r,{"data-testid":"semiotic-annotation",events:n,...e,type:o},s)}var Tr=require("react/jsx-runtime"),Rr={secondary:0,primary:3},Lr=1,Cr=2,$r=.6,jr="0.88em",zr=.95,Er=.72,Dr=.06,Nr=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}",Ir=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Br(t){return!0===t?._annotationDeferred}function Fr(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function Or(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function Wr(t){return Math.max(Er,zr-t*Dr)}function Yr(t,e){const i=e.scales?.x??e.scales?.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function qr(t,e){const i=e.scales?.y??e.scales?.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function Xr(t){return null==t?null:t+""}function Gr(t,e,i){return e.stickyPositionCache?.set(t,i),i}var Vr=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Hr(t){return!!t&&"object"==typeof t&&Vr.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}new Set(["label","callout","callout-circle","callout-rect"]);var Zr=2e4,Kr=1;function Ur(t){return"primary"===t?.emphasis||!0===t?.defensive}function Qr(t,e,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:Zr))):1/0}function Jr(t){let e;const i=t?.emphasis;e="primary"===i?100:"secondary"===i?10:50;const o=t?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(e+=15*Math.max(0,Math.min(1,o))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}var ts=32,es=6,is=4,os=8,ns=72,rs=30,ss=-30,as=8,cs=480,ls=3;var us={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function hs(t){if(!ds(t))return t;const e=("string"==typeof t.mobileText?t.mobileText:void 0)??("string"==typeof t.shortText?t.shortText:void 0);return!e||"string"!=typeof t.label&&null!=t.label?t:{...t,label:e}}function ds(t){return Hr(t)}function fs(t,e){if(!t)return[];const i=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),n=[];let r="";for(const t of o)r&&r.length+t.length+1>i?(n.push(r),r=t):r=r?`${r} ${t}`:t;return r&&n.push(r),n}function ps(t,e,i,o,n){const r=t+i,s=e+o;return Math.abs(i)>Math.abs(o)?{x:0>i?r-n.width-4:r+4,y:0>o?s-n.height:s,width:n.width,height:n.height}:{x:0>i?r-n.width:r,y:0>o?s-n.height-4:s+4,width:n.width,height:n.height}}function ys(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function gs(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function ms(t,e,i,o,n,r,s,a){const c=ys(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,i,o){const n=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(n+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(i-o)))*t.width}(c,n,r,a);for(const t of i)l+=12*gs(c,t);for(const t of o)l+=4*gs(c,t);return l}function xs(t,e,i){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const o=t.pointId??t.nodeId;if(null!=o&&i.pointNodes){const t=i.pointNodes.find(t=>t.pointId===o);if(t)return{x:t.x,y:t.y}}const n=t.coordinates,r=i.scales?.geoProjection;if(Array.isArray(n)&&n.length>=2&&r){const t=n[0],e=n[1];if("number"==typeof t&&"number"==typeof e){const i=r([t,e]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof t.x||"number"!=typeof t.y?function(t,e,i){const o=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=t.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let o=i.pointNodes.length-1;o>=0;o--){const n=i.pointNodes[o];if(n.pointId===t.pointId)return Gr(e,i,{x:n.x,y:n.y})}const o=function(t){const e=t.data;if(!e||0===e.length)return null;const i=e[e.length-1],o=t.scales?.x??t.scales?.time,n=t.scales?.y??t.scales?.value;if(!o||!n)return null;const r=i[t.xAccessor||"x"],s=i[t.yAccessor||"y"];return null==r||null==s?null:{x:o(r),y:n(s)}}(i);return o?Gr(e,i,o):null}if("semantic"===o){const o=function(t,e,i){const o=function(t){return Xr(t.provenance?.stableId??t.stableId)}(t);if(!o)return null;const n=i.pointNodes?.find(t=>Xr(t.pointId)===o);if(n)return Gr(e,i,{x:n.x,y:n.y});const r=i.data?.find(t=>function(t){return Xr(t.stableId??t.id??t.provenance?.stableId)}(t)===o);if(!r)return null;const s=Yr(r,i),a=qr(r,i);return null==s||null==a?null:Gr(e,i,{x:s,y:a})}(t,e,i);if(o)return o}let n=null,r=null;if(null!=t.pointId&&i.pointNodes){const e=i.pointNodes.find(e=>e.pointId===t.pointId);e&&(n=e.x,r=e.y)}if(null!=n&&null!=r||(n=Yr(t,i),r=qr(t,i)),null!=n&&null!=r)return Gr(e,i,{x:n,y:r});if("sticky"===o){const t=i.stickyPositionCache?.get(e);if(t)return t}return null}(t,e,i):{x:t.x,y:t.y}}function bs(t){const{annotations:e,context:i,defaultOffset:o=ts,notePadding:n=es,markPadding:r=is,edgePadding:s=os,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ns,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=i.width||0,x=i.height||0,b="object"==typeof p?p:{},v=b.breakpoint??cs,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(hs):e,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=h||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const P=[],T=function(t,e){return(t.pointNodes||[]).map(t=>{const i=Math.max(1,t.r||1)+e;return{x:t.x-i,y:t.y-i,width:2*i,height:2*i}})}(i,r);let R=!1;const L=k.map((t,e)=>{if(!ds(t))return t;const r=xs(t,e,i);if(!r)return t;const u=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,i=[...fs("string"==typeof t.title?t.title:void 0,e),...fs("string"==typeof t.label?t.label:void 0,e)],o=i.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*i.length+6)}}(t);if(a&&("number"==typeof(h=t).dx||"number"==typeof h.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:rs,dy:ss}}(t);return P.push(ys(ps(r.x,r.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),n)),t}var h;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(o)){const e=ms(ps(r.x,r.y,t.dx,t.dy,u),t,P,T,m,x,n,s);f>e&&(d=t,f=e)}if(!d)return t;const p=ys(ps(r.x,r.y,d.dx,d.dy,u),n);P.push(p);const y=Math.hypot(d.dx,d.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return R=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),C=R?L:k.slice();let $=C;if(d){let t=!1;const e=C.map(e=>{const i=function(t){return"text"!==t.type||"string"!=typeof t.color||Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)<as?t:{...t,_redundantConnector:!0}}(e);return i!==e&&(t=!0),i});$=t?e:C}{let t=!1;const e=$.map(e=>{if(!0!==e?.defensive)return e;const i=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const i="string"==typeof e.source?us[e.source]??e.source:null,o="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!i&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const n=[i,o].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${n})`)?t:{...t,label:r?`${r} (${n})`:`(${n})`}}(e);return i!==e&&(t=!0),i});$=t?e:$}const j=new Set;if(S){const t="object"==typeof S?S:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return ls;const i=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===i.length?ls:i.reduce((t,e)=>t+e,0)/i.length}(t);return e>2?4>e?1:.6:1.5}(g),i=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??Qr(m,x,t))*e))},{deferred:o}=function(t){const{annotations:e,width:i,height:o}=t,n=Math.max(0,t.minVisible??Kr),r=Qr(i,o,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(i=t,Hr(i))};var i}),a=s.filter(t=>t.note);if(0===a.length||r>=a.length)return{visible:e.slice(),deferred:[],budget:r};const c=a.filter(t=>Ur(t.annotation)),l=a.filter(t=>!Ur(t.annotation)).sort((t,e)=>Jr(e.annotation)-Jr(t.annotation)||t.index-e.index),u=Math.min(l.length,Math.max(Math.max(0,r-c.length),Math.max(0,n-c.length))),h=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),d=[],f=[];for(const{annotation:t,index:e,note:i}of s)!i||h.has(e)?d.push(t):f.push(t);return{visible:d,deferred:f,budget:r}}({annotations:$,width:m,height:x,...i});for(const t of o)j.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:cs)>=m)for(const t of $)ds(t)&&"secondary"===t.emphasis&&j.add(t);if(j.size>0)for(const t of $)!0===t?.defensive&&j.delete(t);let z;return z=0===j.size?$:A?$.map(t=>j.has(t)?{...t,_annotationDeferred:!0}:t):$.filter(t=>!j.has(t)),_?function(t,e){let i=!1;const o=t.map(t=>ds(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(i=!0,{...t,cohesion:e}):t);return i?o:t}(z,_):z}var vs=require("react/jsx-runtime"),ws="var(--semiotic-bg, #ffffff)",ks=.85;function Ss(t){const{x:e,y:i,text:o,fill:n,fontSize:r=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=t,d=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(u),f=t=>(0,vs.jsx)("text",{x:e,y:i,textAnchor:c,dominantBaseline:l,fill:n,fontSize:r,fontWeight:s,fontFamily:a,className:h,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??ws,strokeWidth:d.haloWidth??3});const p=d.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(t,e){return(t+"").length*e*.6}(o,r),x=r+2*g;let b,v;return b="middle"===c?e-m/2-y:"end"===c?e-m-y:e-y,v="middle"===l||"central"===l?i-x/2:"hanging"===l||"text-before-edge"===l?i-g:i-.8*r-g,(0,vs.jsxs)("g",{className:h,children:[(0,vs.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??ws,fillOpacity:d.opacity??ks,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}var As=require("react/jsx-runtime"),Ms=16,_s=20;function Ps(t,e){return t.color||e.colors.annotation||e.colors.text}function Ts(t,e,i){const o=t.labelBackground,n=e.colors.background;return void 0===o?"none"===i?"none":{type:"halo",fill:n}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:n}:"box"===o?{type:"box",fill:n}:{fill:n,...o}}function Rs(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):"number"==typeof t.x?t.x:null}function Ls(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):"number"==typeof t.y?t.y:null}function Cs(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=t.autoPlaceAnnotations?bs({annotations:e,context:{scales:{x:t.scales.x,y:t.scales.y,time:t.scales.x,value:t.scales.y,o:t.scales.o,geoProjection:t.scales.geoProjection},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,frameType:t.projection?"ordinal":"xy",projection:"horizontal"===t.projection?"horizontal":"vertical"},..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):e,o=[];for(let e=0;i.length>e;e++){const n=$s(i[e],e,t);n&&o.push({node:n,annotation:i[e]})}const n=function(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(i=t.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:Or(t.annotation),readingOrder:null,rank:Lr};var i}),i=e.some(t=>null!=t.emphasis||null!=t.confidence),o=t.some(t=>Br(t.annotation)),n=t.some(t=>null!=Fr(t.annotation)),r=t.some(t=>"layer"===Fr(t.annotation));if(!i&&!o&&!n)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=Cr-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Rr[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:i,emphasis:o,readingOrder:n}=t,r=Br(e.annotation);let s=e.node;if("primary"===o||"secondary"===o||null!=n){const t=null==o&&null!=n;s=(0,Tr.jsx)("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:$r,fontSize:jr}:{},...t?{opacity:Wr(n),"data-annotation-reading-order":n}:{},children:e.node},"annotation-emphasis-"+i)}const a=Fr(e.annotation);return a&&(s=(0,Tr.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+i)),r&&(s=(0,Tr.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+i)),s});return o&&a.unshift((0,Tr.jsx)("style",{children:Nr},"annotation-disclosure-style")),r&&a.unshift((0,Tr.jsx)("style",{children:Ir},"annotation-cohesion-style")),a}(o);return n.length>0?(0,As.jsx)("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:n}):null}function $s(t,e,i){const{scales:o,layout:n,theme:r,xAccessor:s,yAccessor:a}=i;switch(t.type){case"y-threshold":{const s=t.value;if(null==s)return null;const a=Ps(t,r),c=t.label,l=t.labelPosition||"right",u=t.strokeDasharray||"6,4",h=t.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){const i=o.r(s);return null==i?null:(0,As.jsxs)("g",{opacity:t.opacity,children:[(0,As.jsx)("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&(0,As.jsx)(Ss,{x:i+4,y:Ms,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ts(t,r,"halo")})]},"ann-ythresh-"+e)}const d=o.y?o.y(s):o.r?o.r(s):null;return null==d?null:(0,As.jsxs)("g",{children:[(0,As.jsx)("line",{x1:0,y1:d,x2:n.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&(0,As.jsx)(Ss,{x:"left"===l?4:"center"===l?n.width/2:n.width-4,y:_s>d?Math.min(n.height-4,d+Ms):d-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ts(t,r,"halo")})]},"ann-ythresh-"+e)}case"x-threshold":{const i=t.value;if(null==i||!o.x)return null;const s=o.x(i);if(null==s)return null;const a=Ps(t,r),c=t.label,l=t.labelPosition||"top";return(0,As.jsxs)("g",{opacity:t.opacity,children:[(0,As.jsx)("line",{x1:s,y1:0,x2:s,y2:n.height,stroke:a,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),c&&(0,As.jsx)(Ss,{x:s>.6*n.width?s-4:s+4,y:"bottom"===l?n.height-4:"center"===l?n.height/2:Ms,textAnchor:s>.6*n.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ts(t,r,"halo")})]},"ann-xthresh-"+e)}case"band":{const i=null!=t.y0&&o.y?o.y(t.y0):null,s=null!=t.y1&&o.y?o.y(t.y1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=qn(t.fill||Ps(t,r),"ssr-band-"+e),u=t.fillOpacity??.1;return(0,As.jsxs)("g",{opacity:t.opacity,children:[l.def&&(0,As.jsx)("defs",{children:l.def}),(0,As.jsx)("rect",{x:0,y:a,width:n.width,height:c,fill:l.fill,fillOpacity:u}),t.label&&(0,As.jsx)(Ss,{x:n.width-4,y:Math.max(a,0)+Ms,textAnchor:"end",fontSize:r.typography.tickSize,fill:t.color||Ps(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Ts(t,r,"halo")})]},"ann-band-"+e)}case"x-band":{const i=null!=t.x0&&o.x?o.x(t.x0):null,s=null!=t.x1&&o.x?o.x(t.x1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=qn(t.fill||Ps(t,r),"ssr-xband-"+e),u=t.fillOpacity??.1;return(0,As.jsxs)("g",{opacity:t.opacity,children:[l.def&&(0,As.jsx)("defs",{children:l.def}),(0,As.jsx)("rect",{x:a,y:0,width:c,height:n.height,fill:l.fill,fillOpacity:u}),t.label&&(0,As.jsx)(Ss,{x:a+4,y:Ms,textAnchor:"start",fontSize:r.typography.tickSize,fill:t.color||Ps(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Ts(t,r,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!o.o)return null;const s=o.o(t.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,c=Ps(t,r),l=t.opacity??.1,u=t.label;return(0,As.jsxs)("g","horizontal"===i.projection?{children:[(0,As.jsx)("rect",{x:0,y:s,width:n.width,height:a,fill:c,opacity:l}),u&&(0,As.jsx)(Ss,{x:12,y:s+a/2,dominantBaseline:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Ts(t,r,"none")})]}:{children:[(0,As.jsx)("rect",{x:s,y:0,width:a,height:n.height,fill:c,opacity:l}),u&&(0,As.jsx)(Ss,{x:s+a/2,y:Ms,textAnchor:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Ts(t,r,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:i,y:n}=function(t,e,i,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const i=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:Rs(t,e,i),y:Ls(t,e,o)}}(t,o,s,a);if(null==i||null==n)return null;const c="text"===t.type,l=t.dx??(c?0:30),u=t.dy??(c?0:-30),h=t.color||r.colors.text;if(!c){const o="callout"===t.type?"callout-circle":t.type,r="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return(0,As.jsx)(Pr,{noteData:{x:i,y:n,dx:l,dy:u,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:o,...r?{subject:r}:{},connector:t.connector||{end:"arrow"},color:h,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return(0,As.jsx)("g",{children:(0,As.jsx)("text",{x:i+l,y:n+u,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||r.typography.labelSize,fill:h,fontFamily:r.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}var js=36,zs=34,Es=58,Ds=22;function Ns(t){return"string"==typeof t&&t.length>0}function Is(t,e){return function(t,e,i=!1){const o=i?e?Es:zs:e?js:0;return o>t.top?{...t,top:o}:t}(t,Ns(e))}var Bs=require("react/jsx-runtime");function Fs(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function Os(t,e){if(0===e.categories.length)return;const i=e.position||"right",o=function(t){const{width:e,height:i,swatchSize:o}=yr(t);return{width:e,height:i,swatchSize:o}}({categories:e.categories,colorScheme:e.colorScheme,theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout});"right"===i?t.right=Math.max(t.right,o.width+14):"left"===i?t.left=Math.max(t.left,o.width+14):"top"===i?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4)}function Ws(t,e){const i=e.position||"right",o={theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},n=ro(e.legend)?function(t){const{width:e,height:i,swatchSize:o}=gr(t);return{width:e,height:i,swatchSize:o}}({...o,legendGroups:e.legend.legendGroups}):so(e.legend)?mr({...o,gradient:e.legend.gradient}):null;n&&("right"===i?t.right=Math.max(t.right,n.width+14):"left"===i?t.left=Math.max(t.left,n.width+14):"top"===i?t.top=Math.max(t.top,(e.hasTitle?32:8)+n.height+4):t.bottom=Math.max(t.bottom,38+n.height+4))}function Ys(t,e){const i={theme:e.theme,position:e.position||"right",totalWidth:e.size[0],totalHeight:e.size[1],margin:e.margin,hasTitle:e.hasTitle,legendLayout:e.legendLayout,idPrefix:e.idPrefix};return ro(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,i)=>({group:t,item:e,itemIndex:i,label:e.label})))).length)return null;var e;const i=gr(t),o="top"===t.position||"bottom"===t.position,n=t.theme.colors.grid||t.theme.colors.textSecondary;let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-i.width-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=Math.min(t.totalHeight-t.margin.bottom+38,t.totalHeight-i.height-2)):(r=Math.min(t.totalWidth-i.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=i.groups.flatMap((e,r)=>{const{group:s}=e,a=s.type??"fill",c=[];if(s.label&&c.push((0,ar.jsx)("text",o?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:fr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label}:{x:e.x,y:e.y+fr(t.theme),fontSize:fr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label},"legend-group-label-"+r)),c.push(...e.items.map((o,n)=>{const c=s.items[n],l=s.styleFn(c,n),u="function"==typeof a?a(c):"line"===a?(0,ar.jsx)("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:l}):(0,ar.jsx)("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:l});return(0,ar.jsxs)("g",{transform:`translate(${e.x+e.itemOffsetX+o.x},${e.y+e.itemOffsetY+o.y})`,children:[u,(0,ar.jsx)("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:fr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.category})]},`legend-${r}-${n}`)})),!o&&i.groups.length-1>r)c.push((0,ar.jsx)("line",{x1:0,y1:e.y+e.height-6,x2:i.width,y2:e.y+e.height-6,stroke:n},"legend-group-separator-"+r));else if(o&&i.groups.length-1>r){const t=e.x+e.width+6;c.push((0,ar.jsx)("line",{x1:t,y1:0,x2:t,y2:i.height,stroke:n},"legend-group-separator-"+r))}return c});return(0,ar.jsx)("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,"data-orientation":o?"horizontal":"vertical",children:a})}({...i,legendGroups:t.legendGroups}):so(t)?function(t){const e=mr(t),i="top"===t.position||"bottom"===t.position,o=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",n=t.gradient.format||(t=>Math.round(100*t)/100+"");let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-e.width-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=Math.min(t.totalHeight-t.margin.bottom+38,t.totalHeight-e.height-2)):(r=Math.min(t.totalWidth-e.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=Array.from({length:17},(e,o)=>{const n=o/16;return(0,ar.jsx)("stop",{offset:100*n+"%",stopColor:t.gradient.colorFn(i?t.gradient.domain[0]+n*(t.gradient.domain[1]-t.gradient.domain[0]):t.gradient.domain[1]-n*(t.gradient.domain[1]-t.gradient.domain[0]))},o)});if(i){const i=12,c=t.gradient.label?0:void 0,l=t.gradient.label?8:0;return(0,ar.jsxs)("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,children:[(0,ar.jsx)("defs",{children:(0,ar.jsx)("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),t.gradient.label&&(0,ar.jsx)("text",{x:e.width/2,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),(0,ar.jsx)("rect",{x:0,y:l,width:e.width,height:i,fill:`url(#${o})`,rx:2}),(0,ar.jsx)("text",{x:0,y:l+i+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[0])}),(0,ar.jsx)("text",{x:e.width,y:l+i+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[1])})]})}const c=t.gradient.label?-6:void 0;return(0,ar.jsxs)("g",{className:"semiotic-legend",transform:`translate(${r},${s+(t.gradient.label?12:0)})`,children:[(0,ar.jsx)("defs",{children:(0,ar.jsx)("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),t.gradient.label&&(0,ar.jsx)("text",{x:7,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),(0,ar.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${o})`,rx:2}),(0,ar.jsx)("text",{x:19,y:10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[1])}),(0,ar.jsx)("text",{x:19,y:100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[0])})]})}({...i,gradient:t.gradient}):null}function qs(t){return Math.round(100*t)/100+""}function Xs(t,e){const i=eo(e.theme),o=e.idPrefix?e.idPrefix+"-":"",n="string"==typeof e.title?e.title:void 0,r=n?o+"semiotic-title":void 0,s=e.description?o+"semiotic-desc":void 0,a=[r,s].filter(Boolean).join(" ")||void 0;return(0,Bs.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":a,style:{fontFamily:i.fontFamily},children:[n&&(0,Bs.jsx)("title",{id:r,children:n}),e.description&&(0,Bs.jsx)("desc",{id:s,children:e.description}),e.defs&&(0,Bs.jsx)("defs",{children:e.defs}),e.background&&"transparent"!==e.background&&(0,Bs.jsx)("rect",{x:0,y:0,width:e.width,height:e.height,fill:e.background}),(0,Bs.jsx)("g",{id:o+"data-area",transform:e.innerTransform,children:t}),n&&(0,Bs.jsx)("text",{id:o+"chart-title",x:e.width/2,y:Ds,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:n}),e.legend&&(0,Bs.jsx)("g",{id:o+"legend",children:e.legend}),e.outerElements]})}var Gs=require("react/jsx-runtime");function Vs(t,e){const i=to(t.theme),o=t.size||[500,300],n=Is({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Ns(t.title),s=co(t.data),a=t.showLegend?br(s,t.colorAccessor||t.groupAccessor):[],c=t.legendPosition;ro(t.legend)||so(t.legend)?Ws(n,{legend:t.legend,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&a.length>0&&Os(n,{categories:a,colorScheme:t.colorScheme,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const l=o[0]-n.left-n.right,u=o[1]-n.top-n.bottom,h="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),d=t.colorScheme||i.colors.categorical,f={chartType:t.chartType,windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:h?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:h?void 0:t.xAccessor,yAccessor:h?void 0:t.yAccessor,timeAccessor:h?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:!0===t.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===t.gradientFill?void 0:t.gradientFill,lineGradient:t.lineGradient,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,barStyle:t.barStyle,waterfallStyle:t.waterfallStyle,swarmStyle:t.swarmStyle,colorScheme:d,themeCategorical:i.colors.categorical,themeSemantic:Dt(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},p=new In(f);if(t.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return e&&(e.evidence=no({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),uo.renderToStaticMarkup(Xs(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));e&&(e.evidence=no({frameType:"xy",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,xDomain:oo(p.scales.x?.domain?.()),yDomain:oo(p.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const y=t._idPrefix,g=t.showGrid?function(t,e,i,o){const{grid:n}=eo(i),r=o?o+"-":"",s=t.x.ticks(5),a=t.y.ticks(5);return(0,Bs.jsxs)("g",{id:r+"grid",className:"semiotic-grid",opacity:.8,children:[s.map((i,o)=>{const r=t.x(i);return(0,Bs.jsx)("line",{x1:r,y1:0,x2:r,y2:e.height,stroke:n,strokeWidth:.5},"gx-"+o)}),a.map((i,o)=>{const r=t.y(i);return(0,Bs.jsx)("line",{x1:0,y1:r,x2:e.width,y2:r,stroke:n,strokeWidth:.5},"gy-"+o)})]})}(p.scales,{width:l,height:u},i,y):null,m=p.scene.map((e,i)=>rr({node:e,index:i,renderMode:t.renderMode,fallback:()=>ir(e,i,y)})).filter(Boolean),x=!1!==t.showAxes?function(t,e,i,o,n){const r=eo(o),s=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||qs)(e)})),a=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||qs)(e)}));return(0,Bs.jsxs)("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[(0,Bs.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:r.border,strokeWidth:1}),s.map((t,i)=>(0,Bs.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,Bs.jsx)("line",{y2:5,stroke:r.border,strokeWidth:1}),(0,Bs.jsx)("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"xtick-"+i)),i.xLabel&&(0,Bs.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:i.xLabel}),(0,Bs.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:r.border,strokeWidth:1}),a.map((t,e)=>(0,Bs.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Bs.jsx)("line",{x2:-5,stroke:r.border,strokeWidth:1}),(0,Bs.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"ytick-"+e)),i.yLabel&&(0,Bs.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:i.yLabel})]})}(p.scales,{width:l,height:u},t,i,y):null,b=t.annotations?Cs({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:p.scales.x,y:p.scales.y},layout:{width:l,height:u},theme:i,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:y}):null,v=t.svgPreRenderers&&p.scales?t.svgPreRenderers.map((t,e)=>{try{return(0,Gs.jsx)(lo.Fragment,{children:t(p.scene,p.scales,{width:l,height:u})},"pre-"+e)}catch{return null}}).filter(Boolean):null,w=t.showLegend?0===a.length?null:xr({categories:a,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,k=lo.isValidElement(t.legend)?t.legend:Ys(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||w;return uo.renderToStaticMarkup(Xs((0,Gs.jsxs)(Gs.Fragment,{children:[t.backgroundGraphics,v,g,m,x,b,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,legend:k,idPrefix:t._idPrefix}))}var Hs=c(require("react")),Zs=c(require("react-dom/server")),Ks=require("d3-scale"),Us=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,i){if(e&&"function"==typeof t.pieceStyle){const o=t.pieceStyle(e,i);return o&&!o.fill&&i?{...o,fill:this.getColorFromScheme(t,i)}:o}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&i?{fill:t.barColors[i]||"#007bff"}:{fill:i?this.getColorFromScheme(t,i):"#007bff"}}resolveSummaryStyle(t,e,i){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,i):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const i=this.colorSchemeMap.get(e);if(i)return i;const o=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||j,n=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,n),n}};function Qs(t){const e=t.getSymbol;if(!e)return null;const i=t.config.symbolMap,o=new Map;let n=0;return t=>{const r=e(t)+"",s=i?.[r];if(s)return s;let a=o.get(r);return a||(a=Ko[n%Ko.length],n++,o.set(r,a)),a}}function Js(t,e,i,o,n,r,s){t.push(e?{type:"symbol",x:o,y:n,size:Math.PI*r*r,symbolType:e(i),style:s,datum:i}:{type:"point",x:o,y:n,r:r,style:s,datum:i})}function ta(t,e){const{columns:i,config:o,resolvePieceStyle:n}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,h=Object.values(i),d=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!d&&h.length>1&&(o.cornerRadius??0)>0;for(let t=0;h.length>t;t++){const e=h[t],i=e.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:e.pctStart,d=c+u*l,p=c+(u+("number"==typeof i?._pct?i._pct:e.pct))*l,y=n(e.pieceData[0],e.name),g=0===t,m=t===h.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:d,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:i?._nonInteractive?null:e.pieceData,category:e.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),r.push(x)}return r}var ea=require("d3-array");function ia(t){const e=t.length,i=t[0],o=t[e-1];return{n:e,min:i,q1:(0,ea.quantile)(t,.25)??i,median:(0,ea.quantile)(t,.5)??(i+o)/2,q3:(0,ea.quantile)(t,.75)??o,max:o,mean:t.reduce((t,e)=>t+e,0)/e}}var oa=require("d3-scale"),na={bar:function(t,e){const{scales:i,columns:o,config:n,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d="horizontal"===l,f=n.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(o))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(o)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=r(i),o.pieces.push(i)}let i=0;if(f)for(const t of e.values())i+=Math.abs(t.total);let o=0,n=0;for(const r of p){const l=e.get(r);if(!l)continue;let p=l.total;f&&i>0&&(p/=i);const y=a(l.pieces[0],s?r:t.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name};if(h){const e=c(0>p?n:o+p),i=0>p?c(n+p)-c(n):c(o)-c(o+p);u.push(No(t.x,e,t.width,Math.abs(i),y,g,r)),0>p?n+=p:o+=p}else if(d){const e=c(0>p?n+p:o),i=0>p?c(n)-c(n+p):c(o+p)-c(o);u.push(No(e,t.x,Math.abs(i),t.width,y,g,r)),0>p?n+=p:o+=p}}}const y="vertical"===l,g=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;const e=t.datum?.__aggregateValue??0;t.roundedEdge=y?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}if(g>0){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const i=e.datum?.category||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),i=e.filter(t=>0>(t.datum?.__aggregateValue??0));t.length>0&&(t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=g),i.length>0&&(i.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=g)}}return u},clusterbar:function(t,e){const{scales:i,columns:o,config:n,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const p=d.length||1;for(const t of Object.values(o)){const e=t.width/p,i=.2*e,o=e-i,n=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";n.has(t)||n.set(t,[]),n.get(t).push(e)}for(let s=0;d.length>s;s++){const l=n.get(d[s])||[];for(const n of l){const l=r(n),f=a(n,d[s]);if(h){const r=t.x+s*e+i/2,a=c(0),h=c(l);u.push(No(r,Math.min(a,h),o,Math.abs(a-h),f,n,d[s]))}else{const r=t.x+s*e+i/2,a=c(0),h=c(l);u.push(No(Math.min(a,h),r,Math.abs(h-a),o,f,n,d[s]))}}}}const y=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}return u},point:function(t,e){const{scales:i,columns:o,getR:n,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h="radial"===c,d=r.length>0,f=Qs(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const i=e.__rIndex??0,o=e.__rValue??n(e),c=d&&r[i]||a,g=s(e,t.name),m=g.r||5;let x,b;if(h){const e=y+(t.pctStart+t.pct/2)*p,i=c(o);x=Math.cos(e)*i,b=Math.sin(e)*i}else u?(x=t.middle,b=c(o)):(x=c(o),b=t.middle);Js(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:i,columns:o,getR:n,resolvePieceStyle:r}=t,{r:s,projection:a}=i,c=[],l="vertical"===a,u=Qs(t);for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=n(o),h=r(o,t.name),d=h.r||4,f=(7919*i%100/100-.5)*e*.8;Js(c,u,o,l?t.middle+f:s(a),l?s(a):t.middle+f,d,h)}}return c},pie:ta,donut:ta,boxplot:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=!1!==n.showOutliers;for(const e of Object.values(o)){const i=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===i.length)continue;const o=i[0],n=i[i.length-1],c=(0,ea.quantile)(i,.25)??o,d=(0,ea.quantile)(i,.5)??(o+n)/2,f=(0,ea.quantile)(i,.75)??n,p=f-c,y=c-1.5*p,g=f+1.5*p,m=i.find(t=>t>=y)??o,x=[...i].reverse().find(t=>g>=t)??n,b=s(e.pieceData[0],e.name),v=[];if(h)for(const t of e.pieceData){const i=r(t);if(y>i||i>g){const o=u?e.middle:a(i),n=u?a(i):e.middle;v.push({px:o,py:n,value:i,datum:t})}}if(l.push({type:"boxplot",x:u?e.middle:0,y:u?0:e.middle,projection:u?"vertical":"horizontal",columnWidth:.6*e.width,minPos:a(m),q1Pos:a(c),medianPos:a(d),q3Pos:a(f),maxPos:a(x),stats:{n:i.length,min:m,q1:c,median:d,q3:f,max:x,mean:i.reduce((t,e)=>t+e,0)/i.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),h)for(const e of v)l.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:b.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6},datum:e.datum})}return l},violin:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=n.bins||20,d=!1!==n.showIQR;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/h||1,c=Array(h).fill(0);for(const t of e)c[Math.min(Math.floor((t-i)/n),h-1)]++;const f=gt(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(i)}`;for(let e=0;h>e;e++){const o=a(i+(e+.5)*n);y+=` L ${t.middle+c[e]/f*p} ${o}`}y+=` L ${t.middle} ${a(o)}`;for(let e=h-1;e>=0;e--){const o=a(i+(e+.5)*n);y+=` L ${t.middle-c[e]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(i)} ${t.middle}`;for(let e=0;h>e;e++)y+=` L ${a(i+(e+.5)*n)} ${t.middle-c[e]/f*p}`;y+=` L ${a(o)} ${t.middle}`;for(let e=h-1;e>=0;e--)y+=` L ${a(i+(e+.5)*n)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(d&&e.length>=4){const n=(0,ea.quantile)(e,.25)??i,r=(0,ea.quantile)(e,.5)??(i+o)/2,s=(0,ea.quantile)(e,.75)??o;m={q1Pos:a(n),medianPos:a(r),q3Pos:a(s),centerPos:t.middle,isVertical:u}}const x=u?{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))}:{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:ia(e),style:g,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a}=i,c=[],l=n.bins||25,u=n.normalize,h=a.domain?.(),d=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[i,o]=yt(e),n=null!=d&&isFinite(d)?d:i,h=null!=f&&isFinite(f)?f:o,p=(h-n)/l||1,y=Array(l).fill(0);for(const t of e)n>t||t>h||y[Math.min(Math.floor((t-n)/p),l-1)]++;const g=e.length,m=gt(y,1),x=s(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===y[e])continue;const i=(u?y[e]/g:y[e]/m)*t.width*.9,o=a(n+e*p),r=a(n+(e+1)*p);c.push(No(Math.min(o,r),t.x+t.width-i,Math.abs(r-o),i,x,{bin:e,count:y[e],range:[n+e*p,n+(e+1)*p],category:t.name},t.name))}}return c},ridgeline:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u=n.bins||20,h="horizontal"===c,d=n.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/u||1,c=Array(u).fill(0);for(const t of e)i>t||t>o||c[Math.min(Math.floor((t-i)/n),u-1)]++;const f=gt(c,1),p=s(t.pieceData[0],t.name),y=t.width*d;let g;if(h){const e=t.x+t.width;g=`M ${a(i)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(i+(t+.5)*n)} ${e-c[t]/f*y}`;g+=` L ${a(o)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(i)}`;for(let t=0;u>t;t++){const o=a(i+(t+.5)*n);g+=` L ${e+c[t]/f*y} ${o}`}g+=` L ${e} ${a(o)} Z`}const m=h?{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width}:{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:ia(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:i,columns:o,getRawRange:n,resolvePieceStyle:r}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=n(e);if(!i)continue;const[o,a]=i,u=r(e,t.name);if(l){const i=s(Math.min(o,a)),n=s(Math.max(o,a));c.push(No(i,t.x,n-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),n=s(Math.min(o,a));c.push(No(t.x,i,t.width,n-i,u,e,t.name))}}return c},funnel:function(t,e){const{columns:i,getR:o,getStack:n,resolvePieceStyle:r}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>i[t]).filter(Boolean);if(0===l.length)return s;const u=[],h=new Set;for(const t of l)for(const e of t.pieceData){const t=n?n(e):"_default";h.has(t)||(h.add(t),u.push(t))}const d=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let i=0;for(const r of t.pieceData){const t=n?n(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),i+=a}f.push({col:t,groups:e,stepTotal:i}),d||i>p&&(p=i)}if(d)for(const t of f){let e=0,i=0;for(let o=0;u.length>o;o++){const n=t.groups.get(u[o]);n&&(o%2==0?e+=n.total:i+=n.total)}const o=Math.max(e,i);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=d?.95*a:.9*e.width,x=(0,oa.scaleLinear)().domain([0,p]).range([0,m]),b=t.config.connectorOpacity??.3;let v=new Map;for(let e=0;f.length>e;e++){const i=f[e],o=i.col,n=0===e,l=o.width,h=.55*l,p=o.x+(l-h)/2,m=new Map;if(d){let t=0;for(const e of u){const o=i.groups.get(e);o&&(t+=x(o.total))}let e=a,l=a;for(let d=0;u.length>d;d++){const f=u[d],g=i.groups.get(f);if(!g)continue;const b=x(g.total),v=d%2==0,w=v?e:l-b;v?e+=b:l-=b;const k=r(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:n,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===d&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(No(w,p,b,h,k,A,f)),m.set(f,{x:w,y:p,w:b,h:h})}}else{const t=i.stepTotal,e=x(t),l=a-e/2,d=u[0],f="_default"!==d,y=i.groups.get(d)?.pieces[0]??o.pieceData[0],b=f?d:o.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:n,category:f?d:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(No(l,p,e,h,v,k,b)),m.set(d,{x:l,y:p,w:e,h:h})}if(e>0&&v.size>0){const e=d?u:[u[0]];for(const n of e){const e=v.get(n),a=m.get(n);if(!e||!a)continue;const c=(()=>{const t=i.groups.get(n);return r(t?t.pieces[0]:o.pieceData[0],"_default"===n?o.name:n)})(),l={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||t.config.themeSemantic?.secondary||"#999",opacity:b},datum:i.groups.get(n)?.pieces[0]??o.pieceData[0],category:"_default"===n?o.name:n};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:i,getR:o,getStack:n,resolvePieceStyle:r,scales:s}=t,a=[],c=s.o.domain().map(t=>i[t]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const t of c)for(const e of t.pieceData){const t=n?n(e):"_default";u.has(t)||(u.add(t),l.push(t))}const h=l.length>1&&"_default"!==l[0],d=[];for(const t of c){const e=new Map;let i=0;for(const r of t.pieceData){const t=n?n(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),i+=a}d.push({col:t,groups:e,stepTotal:i})}const f=new Map;for(const t of l){const e=d[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=h?l.length:1,g=h?.15:0;for(let t=0;d.length>t;t++){const e=d[t],i=e.col,o=0===t,n=t>0?d[t-1]:null,s=i.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const d=l[t],y=e.groups.get(d);if(!y)continue;const g=y.total,m=f.get(d)??g,x=m>0?g/m*100:0,b=n?.groups.get(d),v=o?0:Math.max(0,(b?.total??g)-g),w=i.x+t*s+c/2,k=p(g),S=p(0)-k,A=r(y.pieces[0],h?d:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(No(w,k,u,S,A,M,h?d:i.name)),v>0){const t=p(g+v),e=k-t,o={...A},n={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name};a.push(No(w,t,u,e,o,n,h?d:i.name))}}}return a},swimlane:function(t,e){const{scales:i,columns:o,getR:n,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c,h=t.config.gradientFill,d=u?"left":"bottom",f=t.config.trackFill;if(f){const t="string"==typeof f?f:f.color,e="string"==typeof f?1:f.opacity??1,[i,n]=a.range(),r=Math.min(i,n),s=Math.abs(n-i);for(const i of Object.values(o)){const o={fill:t,opacity:e},n=u?No(r,i.x,s,i.width,o,null,"__track__"):No(i.x,r,i.width,s,o,null,"__track__");l.push(n)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(o)){let e=0;const i=l.length;for(const i of t.pieceData){const o=Math.abs(n(i));if(0===o)continue;const c=r?r(i):t.name,f=s(i,c);let p;if(u){const n=a(e),r=a(e+o);p=No(n,t.x,r-n,t.width,f,i,c)}else{const n=a(e+o),r=a(e);p=No(t.x,n,t.width,r-n,f,i,c)}h&&(p.fillGradient=h,p.roundedEdge=d),l.push(p),e+=o}if(p>0&&l.length>i){const t=l.slice(i),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(e.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return l}},ra=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],sa=["scene-style","data-paint","accessibility","evidence"],aa=(t,e)=>({retainedData:t,invalidations:e}),ca=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],la=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ua=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ha=["scene-geometry","data-paint","accessibility","evidence"],da=["scene-style","data-paint","accessibility","evidence"],fa=[],pa={chartType:aa("rebuild",ca),runtimeMode:aa("rebuild",ca),categoryAccessor:aa("rebuild",ca),valueAccessor:aa("rebuild",ca),oAccessor:aa("rebuild",ca),rAccessor:aa("rebuild",ca),stackBy:aa("rebuild",ca),groupBy:aa("rebuild",ca),timeAccessor:aa("rebuild",ca),accessorRevision:aa("rebuild",ca),colorAccessor:aa("rebuild",da),symbolAccessor:aa("rebuild",ha),connectorAccessor:aa("rebuild",ha),dataIdAccessor:aa("rebuild",ha),projection:aa("preserve",la),extentPadding:aa("preserve",la),axisExtent:aa("preserve",la),rExtent:aa("preserve",la),oExtent:aa("preserve",la),multiAxis:aa("preserve",la),normalize:aa("preserve",la),bins:aa("preserve",la),oSort:aa("preserve",ua),barPadding:aa("preserve",ua),roundedTop:aa("preserve",ua),baselinePadding:aa("preserve",ua),innerRadius:aa("preserve",ua),cornerRadius:aa("preserve",ua),startAngle:aa("preserve",ua),sweepAngle:aa("preserve",ua),trackFill:aa("preserve",ua),showOutliers:aa("preserve",ua),showIQR:aa("preserve",ua),amplitude:aa("preserve",ua),connectorOpacity:aa("preserve",ua),showLabels:aa("preserve",ua),dynamicColumnWidth:aa("rebuild",ua),customLayout:aa("preserve",ua),layoutConfig:aa("preserve",ua),layoutMargin:aa("preserve",ua),symbolMap:aa("preserve",ha),pieceStyle:aa("preserve",da),summaryStyle:aa("preserve",da),connectorStyle:aa("preserve",da),gradientFill:aa("preserve",da),colorScheme:aa("preserve",da),themeCategorical:aa("preserve",da),themeSemantic:aa("preserve",da),themeSequential:aa("preserve",da),themeDiverging:aa("preserve",da),barColors:aa("preserve",da),decay:aa("preserve",da),pulse:aa("preserve",da),staleness:aa("preserve",da),layoutSelection:aa("preserve",da),windowSize:aa("preserve",fa),windowMode:aa("preserve",fa),clock:aa("preserve",fa),transition:aa("preserve",fa),introAnimation:aa("preserve",fa),onLayoutError:aa("preserve",fa)},ya=aa("preserve",ua),ga=class{constructor(){this.tracker=new ai}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},ra)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},sa):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=pa[o]??ya;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},ma=require("d3-quadtree"),xa=class{constructor(t){this.rExtent=new fo,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new ga,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new Us,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new ho(t.windowSize),this.getO=mo(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>yo(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new fo)):(this.getR=yo(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=mo(t.stackBy),this.getGroup=mo(t.groupBy),this.getColor=mo(t.colorAccessor),this.getSymbol=mo(t.symbolAccessor),this.getConnector=mo(t.connectorAccessor),this.getDataId=mo(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new ho(t.windowSize))}syncPulseTimestampBuffer(){var t,e,i,o;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,i=this.timestampBuffer,o=this.currentTime(),t?null!=i&&i.capacity===e.capacity&&i.size===e.size?i:hn(e,o):null)}currentTime(){return this.config.clock?.()??Mo()}ingest(t){const e=this.currentTime();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),un(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)dn(this.buffer,i,this.timestampBuffer,e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=dn(this.buffer,i,this.timestampBuffer,e);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,n=this.multiScales,r=this.columns;if(0===i.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(h){f=(0,Ks.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;p=(0,Ks.scaleLinear)().domain(l).range([o,i])}else u?(f=(0,Ks.scaleBand)().domain(c).range([0,t.height]).padding(d),p=(0,Ks.scaleLinear)().domain(l).range([0,t.width])):(f=(0,Ks.scaleBand)().domain(c).range([0,t.width]).padding(d),p=(0,Ks.scaleLinear)().domain(l).range([t.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,n)=>{const r=this.rExtents[n];r.dirty&&r.recalculate(i,o);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(e.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Ks.scaleLinear)().domain([s,a]).range([0,t.width]):(0,Ks.scaleLinear)().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,i)=>({...t,__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,c,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=n,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let n=null;if(i){n=new Set;for(const e of t)n.add(this.getO(e))}const r=n?Array.from(this.categories).filter(t=>n.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*n.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;n.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:i,projection:o,normalize:n,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:h,rawRExtent:d}=t,f=s;if("radial"===o&&("pie"===i||"donut"===i))return[0,1];let p=0,y=0;if("bar"===i&&h&&n)p=0,y=1;else if("bar"===i&&h){const t=new Map,i=new Map;for(const o of e){const e=l(o),n=u(o);0>n?i.set(e,(i.get(e)||0)+n):t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>y&&(y=e);for(const t of i.values())p>t&&(p=t)}else if("bar"===i){const t=new Map;for(const i of e){const e=l(i),o=u(i);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===i){const t=new Map;for(const i of e){const e=l(i),o=Math.abs(u(i));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===i||"bar-funnel"===i)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=d[0],e=d[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(y=r[1]));const g="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==i&&"exact"!==c){const t=y-p,e=t>0?t*f:1,o=g&&!a&&0===p,n=g&&!a&&0===y||"swimlane"===i;null!=r?.[0]||o||(p-=e),null!=r?.[1]||n||(y+=e)}return[p,y]}({data:t,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(t,e,i,o,n){return function(t){const{data:e,oExtent:i,oScale:o,projection:n,layout:r,dynamicColumnWidth:s,getO:a,getR:c}=t,l={},u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let h=0;if("radial"===n)for(const t of e)h+=Math.abs(c(t));let d=null;if(s&&"radial"!==n){d=new Map;let t=0;for(const e of i){const i=u.get(e)||[];let o;o="string"==typeof s?i.reduce((t,e)=>t+(Number(e[s])||0),0):s(i),d.set(e,o),t+=o}const e=("horizontal"===n?r.height:r.width)-o.padding()*o.step()*i.length;if(t>0)for(const[i,o]of d)d.set(i,o/t*e)}let f=0,p=0;for(const t of i){const e=u.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(c(e)),0),n=h>0?i/h:0;let r,s;d?(r=p,s=d.get(t)||o.bandwidth(),p+=s+o.padding()*o.step()):(r=o(t)??0,s=o.bandwidth()),l[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:o.padding()*o.step(),pieceData:e,pct:n,pctStart:f},f+=n}return l}({data:t,oExtent:e,oScale:i,projection:o,layout:n,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.styleResolver.resolvePieceStyle(this.config,t,e),resolveSummaryStyle:(t,e)=>this.styleResolver.resolveSummaryStyle(this.config,t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(t,e);let o;try{o=this.config.customLayout(i)}catch(t){const e=null!==this.lastCustomLayoutResult,i=nn("ordinal",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of n)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return tn({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const i=this.getSceneContext(),o=na[this.config.chartType];let n=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:o,getConnector:n,getO:r}=t;if(!n||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=n(e);if(!i)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:o,y:s,datum:e,category:r(e)})}const l=i.o.domain(),u=o.connectorStyle;for(const[e,i]of c)if(i.length>=2){i.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let o=0;i.length-1>o;o++){const n=i[o],r=i[o+1],a="function"==typeof u?u(n.datum):u||{stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:n.x,y1:n.y,x2:r.x,y2:r.y,style:a,datum:n.datum,group:e})}}return s}(i,n);n=[...t,...n]}return n}buildLayoutContext(t,e){const i=this.config,o=i.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Fi(i.colorScheme,i.themeCategorical,j),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:o,plot:"radial"===r.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:[...n]},resolveColor:Oi(n,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?_o(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=Po(t);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=function(t,e){const i="function"==typeof e,o=i?null:e||"category",n=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=i?e(s):s[o],c=n.get(a);c?c.push(r):n.set(a,[r])}return n}(t,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:e},e}rebuildPointQuadtree(){const t=function(t){let e=0,i=0;for(const o of t)"point"===o.type&&(e++,o.r>i&&(i=o.r));if(500>=e)return{quadtree:null,maxRadius:i};const o=Array(e);let n=0;for(const e of t)"point"===e.type&&(o[n++]=e);return{maxRadius:i,quadtree:(0,ma.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=o.get(e.datum);if(null==t)continue;const n=this.computeDecayOpacity(t,i);e.style={...e.style,opacity:(e.style?.opacity??1)*n}}}applyPulse(t,e,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,n,r){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;for(const l of e){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const e=l.category;if(!e)continue;let o=0;for(const s of n(e)??[]){const e=i.get(s);null!=e&&(o=Math.max(o,To(t,e,r)))}c=Ro(l,o,s)||c;continue}if(null==l.datum)continue;const e=o.get(l.datum);if(null==e)continue;const u=i.get(e);c=Ro(l,null==u?0:To(t,u,r),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),i)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Lo(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const t=new Map,e=this.scales?.r(0)??0,i="horizontal"!==this.scales?.projection;let o;for(let n=0;this.scene.length>n;n++){const r=this.scene[n],s=this.getNodeKey(r,t);s&&("rect"===r.type?this.prevPositionMap.set(s,i?{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}:{x:e,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===o&&(o=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:o,endAngle:o,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${t.datum?.category??""}`:"wedge"===t.type?"w:"+(t.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=this.getNodeKey(i,t);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"wedge"===i.type&&this.prevPositionMap.set(o,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const t=this.config.transition.duration??300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let e=!1;const i=new Set,o=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=this.getNodeKey(n,o);if(!r)continue;n._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===n.type)s?(i.add(r),n._targetOpacity=n.style.opacity??1,(s.x!==n.x||s.y!==n.y||void 0!==s.r&&s.r!==n.r)&&(n._targetX=n.x,n._targetY=n.y,n._targetR=n.r,n.x=s.x,n.y=s.y,void 0!==s.r&&(n.r=s.r),e=!0)):(n._targetOpacity=n.style.opacity??1,n._targetR=n.r,n.r=0,n.style={...n.style,opacity:0},e=!0);else if("rect"===n.type)s?(i.add(r),n._targetOpacity=n.style.opacity??1,s.x===n.x&&s.y===n.y&&s.w===n.w&&s.h===n.h||(n._targetX=n.x,n._targetY=n.y,n._targetW=n.w,n._targetH=n.h,n.x=s.x,n.y=s.y,n.w=s.w??n.w,n.h=s.h??n.h,e=!0)):(n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},e=!0);else if("wedge"===n.type)if(s)i.add(r),n._targetOpacity=n.style.opacity??1,s.startAngle===n.startAngle&&s.endAngle===n.endAngle||(n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle,n.startAngle=s.startAngle,n.endAngle=s.endAngle,e=!0);else{n._targetOpacity=n.style.opacity??1,n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle;const t=n.startAngle;n.startAngle=t,n.endAngle=t,n.style={...n.style,opacity:0},this.prevPositionMap.set(r,{x:n.cx,y:n.cy,startAngle:t,endAngle:t,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0}),e=!0}}this.exitNodes=[];for(const[t,o]of this.prevPositionMap)if(!i.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((o.startAngle??0)+(o.endAngle??0))/2,i={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(i)}e=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),e&&(this.activeTransition={startTime:this.currentTime(),duration:t})}advanceTransition(t){if(!this.activeTransition)return!1;const e=So(t,this.activeTransition),i=ko(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Ao(o?o.opacity??1:0,t._targetOpacity,i)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Ao(o.x,t._targetX,i),t.y=Ao(o.y,t._targetY,i)),void 0!==t._targetR&&void 0!==o?.r&&(t.r=Ao(o.r,t._targetR,i))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Ao(o?o.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=Ao(o.x,t._targetX,i),t.y=Ao(o.y,t._targetY,i),void 0!==o.w&&(t.w=Ao(o.w,t._targetW,i),t.h=Ao(o.h,t._targetH,i))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style={...t.style,opacity:Ao(o?o.opacity??1:0,t._targetOpacity,i)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const o=this.prevPositionMap.get(e);o&&void 0!==o.startAngle&&(t.startAngle=Ao(o.startAngle,t._targetStartAngle,i),t.endAngle=Ao(o.endAngle,t._targetEndAngle,i))}}}if(e>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style={...t.style||{},opacity:0===t._targetOpacity?0:t._targetOpacity},t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=wo(t),i=this.getDataId,o=t=>e.has(i(t));fn(this.buffer,this.timestampBuffer,o);const n=this.buffer.remove(o);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=wo(t),o=this.getDataId,n=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&n.add(e)});const r=this.buffer.update(t=>i.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),n.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},n=i(o,e);o.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();this._categoryIndexCache=null,this.buffer.forEach(t=>{this.categories.add(this.getO(t)),this.pushValueExtent(t)})}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!po(t.colorAccessor,e.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in t&&!po(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!po(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in t||"oAccessor"in t)&&(po(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=mo(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let n=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,i=e.valueAccessor||e.rAccessor,o=Array.isArray(t)?t:[t],r=Array.isArray(i)?i:[i];if(n=o.length!==r.length||o.some((t,e)=>!po(t,r[e])),n){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>yo(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new fo)):(this.getR=yo(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!po(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?mo(this.config.stackBy):void 0),"groupBy"in t&&!po(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?mo(this.config.groupBy):void 0),"colorAccessor"in t&&!po(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?mo(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!po(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?mo(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!po(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?mo(this.config.connectorAccessor):void 0),(o||n||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};wn(xa);var ba=require("react/jsx-runtime"),va=require("react/jsx-runtime");function wa(t,e){const i=to(t.theme),o=t.size||[500,400],n=Is({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Ns(t.title),s=co(t.data),a=t.showLegend?br(s,t.colorAccessor||t.stackBy||t.groupBy):[],c=t.legendPosition;ro(t.legend)||so(t.legend)?Ws(n,{legend:t.legend,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&a.length>0&&Os(n,{categories:a,colorScheme:t.colorScheme,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const l=o[0]-n.left-n.right,u=o[1]-n.top-n.bottom,h=t.projection||"vertical",d="radial"===h,f={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:h,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,roundedTop:t.roundedTop,innerRadius:t.innerRadius,cornerRadius:t.cornerRadius,normalize:t.normalize,startAngle:t.startAngle,sweepAngle:t.sweepAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme||i.colors.categorical,themeCategorical:i.colors.categorical,themeSemantic:Dt(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},p=new xa(f);if(t.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return e&&(e.evidence=no({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),Zs.renderToStaticMarkup(Xs(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));if(e){const i=p.scales.o?.domain?.();e.evidence=no({frameType:"ordinal",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,yDomain:oo(p.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0})}const y=t._idPrefix,g=t.showGrid?function(t,e,i,o){const n=t.scales;if(!n||"radial"===n.projection)return null;const{grid:r}=eo(i),s=o?o+"-":"",a="vertical"===n.projection,c=n.r.ticks(5);return(0,Bs.jsx)("g",a?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,i)=>{const o=n.r(t);return(0,Bs.jsx)("line",{x1:0,y1:o,x2:e.width,y2:o,stroke:r,strokeWidth:.5},"gr-"+i)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,i)=>{const o=n.r(t);return(0,Bs.jsx)("line",{x1:o,y1:0,x2:o,y2:e.height,stroke:r,strokeWidth:.5},"gr-"+i)})})}(p,{width:l,height:u},i,y):null;let m=null;if(p.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(t),o=new Set;for(const t of p.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");m=Array.from(o).map((t,o)=>function(t){const{id:e,background:i="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return(0,ba.jsxs)("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&(0,ba.jsx)("rect",{width:a,height:a,fill:i}),(0,ba.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:n}),(0,ba.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:o,strokeWidth:n})]},e)}({id:`funnel-hatch-${e}-${o}`,background:t,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(o).forEach((t,i)=>n.set(t,`funnel-hatch-${e}-${i}`));for(const t of p.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&(t.style={...t.style,fill:`url(#${n.get("string"==typeof t.style.fill?t.style.fill:"#666")})`})}const x=p.scene.map((e,i)=>rr({node:e,index:i,renderMode:t.renderMode,fallback:()=>or(e,i,y)})).filter(Boolean),b=!1!==t.showAxes?function(t,e,i,o,n){const r=t.scales;if(!r)return null;if("radial"===r.projection)return null;const s=eo(o),a="vertical"===r.projection,c=i.categoryFormat||i.oFormat,l=i.valueFormat||i.rFormat,u=i.categoryLabel||i.oLabel,h=i.valueLabel||i.rLabel,d=Object.values(t.columns).map(t=>({pixel:t.middle,label:(c||String)(t.name)})),f=r.r.ticks(5).map(t=>({pixel:r.r(t),label:(l||qs)(t)}));return(0,va.jsxs)("g",a?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[(0,va.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,i)=>(0,va.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,va.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,va.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),u&&(0,va.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,va.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,e)=>(0,va.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,va.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,va.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),h&&(0,va.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:h})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[(0,va.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,i)=>(0,va.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,va.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,va.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),h&&(0,va.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:h}),(0,va.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,e)=>(0,va.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,va.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,va.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),u&&(0,va.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:u})]})}(p,{width:l,height:u},t,i,y):null,v=t.annotations?Cs({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{o:p.scales.o,r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:l,height:u},theme:i,projection:h,idPrefix:y}):null,w=t.showLegend?0===a.length?null:xr({categories:a,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,k=Hs.isValidElement(t.legend)?t.legend:Ys(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||w,S=d?n.left+l/2:n.left,A=d?n.top+u/2:n.top;return Zs.renderToStaticMarkup(Xs((0,va.jsxs)(va.Fragment,{children:[t.backgroundGraphics,g,x,b,v,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${S},${A})`,innerWidth:l,innerHeight:u,legend:k,defs:m,idPrefix:t._idPrefix}))}var ka=c(require("react")),Sa=c(require("react-dom/server"));function Aa(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Ma(t,e){var i,o=[],n=[],r=[],s={},a=[];function c(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&c(e)})}function l(t){var e,o,h=!1;for(n.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,n),h=!0):r[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return n.pop(),h}function u(t,i){var n=[].concat(i).concat(t);e?e(n):o.push(n)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),n=Array(e),r=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,n[c]=!1,r[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,n[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>r[e]){for(var p=r[e];f.length>p;++p){var y=f[p];if(0>i[y]){i[y]=o[y]=u,n[y]=!0,u+=1,c.push(y),l.push(y);break}n[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=p}else{if(o[e]===i[e]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(n[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=h.length,b===e){c.length=p;break}}h.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];d.push(v)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var p=d[c];if(0!==p.length){p.sort(function(t,e){return t-e}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),n=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;n.length>s;s++)for(var a=0;n[s].length>a;a++)r>n[s][a]&&(r=n[s][a],i=s);var c=n[i];return!!c&&{leastVertex:r,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];r[+g]=!1,s[g]={}}l(i),i+=1}else i=d}return e?void 0:o}function _a(t){return t.y0-t.y1>0?"up":"down"}function Pa(t,e){return e(t.source)==e(t.target)}function Ta(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Ra(t){return t.target.x0-t.source.x1}function La(t,e){var i=$a(t),o=Ra(e)/Math.tan(i);return"up"==_a(t)?t.y1-o:t.y1+o}function Ca(t,e){var i=$a(t),o=Ra(e)/Math.tan(i);return"up"==_a(t)?t.y1+o:t.y1-o}function $a(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function ja(t,e){return e(t)}function za(t){return Da(t.source)}function Ea(t){return Da(t.target)}function Da(t){return(t.y0+t.y1)/2}function Na(t){return t.virtual?0:t.value}function Ia(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Pa(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Pa(t,e)?o+1:o}),i+o}function Ba(t){return t.target.depth}function Fa(t,e){return t.sourceLinks.length?t.depth:e-1}function Oa(t,e){return t.y0-e.y0}function Wa(t,e){return e.y0-t.y0}function Ya(t,e){return t.y1-e.y1}function qa(t,e){return e.y1-t.y1}function Xa(t,e){return Va(t.source,e.source)||t.index-e.index}function Ga(t,e){return Va(t.target,e.target)||t.index-e.index}function Va(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ha(t,e){return Za(t)==Za(e)?"bottom"==t.circularLinkType?Wa(t,e):Oa(t,e):Za(e)-Za(t)}function Za(t){return t.target.column-t.source.column}function Ka(t,e){return Ua(t)==Ua(e)}function Ua(t){return t.y0-t.y1>0?"up":"down"}var Qa=require("d3-array");function Ja(t,e,i,o,n){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=(0,Qa.min)(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),tc(r.links.filter(function(t){return"top"==t.circularLinkType}),e,i),tc(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Pa(t,e)&&Ta(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,c=t.circularLinkType,l=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?Wa:Oa);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?qa:Ya),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,o=t.target.x0,n=t.y1,r=(e+o)/2;return"M"+e+","+i+"C"+r+","+i+" "+r+","+n+" "+o+","+n}(t)}),r}function tc(t,e,i){t.sort(Ha);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Pa(t,e)&&Ta(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&ec(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;r=c>r?c:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function ec(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}var ic=require("d3-array");function oc(t){return function(){return t}}function nc(t){return t.index}function rc(t){return t.nodes}function sc(t){return t.links}function ac(t,e,i){var o=(0,ic.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(n,r){var s=n.length;if(e)n.sort(e);else if(r>0){var a=new Map;n.forEach(function(t,e){var i,o,n,r=(o=0,n=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Da(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Da(t.target)*e,o+=e}}),o>0?n/o:NaN);a.set(t,{bc:r,idx:e})}),n.sort(function(t,e){var i=a.get(t),o=a.get(e),n=i.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(n)||isNaN(r)?isNaN(n)?isNaN(r)?i.idx-o.idx:1:-1:n-r})}else n.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ia(e,i)-Ia(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});n.forEach(function(e,n){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Ia(e,i)?(e.y0=t.y1/2+n,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+n,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-n,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*n,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+n,e.y1=e.y0+e.value*t.ky)})})}function cc(t,e,i,o,n,r){var s=(0,ic.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,c=r;c>0;--c)l(a*=.99,i),u();function l(e,i){var o=s.length;s.forEach(function(n){var r=n.length,s=n[0].depth;n.forEach(function(n){var a;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&Ia(n,i)>0){var c=(0,ic.mean)(n.sourceLinks,Ea),l=(0,ic.mean)(n.targetLinks,za),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Da(n))*e*.3;n.y0+=h,n.y1+=h}}else if(0==s&&1==r)n.y0=t.y1/2-(a=n.y1-n.y0)/2,n.y1=t.y1/2+a/2;else if(s==o-1&&1==r)n.y0=t.y1/2-(a=n.y1-n.y0)/2,n.y1=t.y1/2+a/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)a=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+a;else{var d=(0,ic.mean)(n.sourceLinks,Ea),f=(0,ic.mean)(n.targetLinks,za),p=((d&&f?(d+f)/2:d||f)-Da(n))*e;n.y0+=p,n.y1+=p}})})}function u(){s.forEach(function(i){var r,s,a,c=t.y0,l=i.length;for(i.sort(e||Va),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+o;if((s=c-o-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+n-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function lc(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Ga),t.targetLinks.sort(Xa)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,n=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function uc(){var t=0,e=0,i=1,o=1,n=24,r=8,s=null,a=nc,c=Fa,l=void 0,u=32,h=2,d=rc,f=sc;function p(){var p={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return(0,ic.group)(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,n=t.target;"object"!=typeof o&&(o=t.source=Aa(i,o)),"object"!=typeof n&&(n=t.target=Aa(i,n)),o.sourceLinks.push(t),n.targetLinks.push(t)})}(d,a),function(t,e){var i=0;if(null==e){for(var o=[],n=0;t.links.length>n;n++){var r=t.links[n],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Ma(o);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,l),function(t,e){var i=0,o=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:o>i?"top":"bottom","top"==n.circularLinkType?i++:o++,t.nodes.forEach(function(t){ja(t,e)!=ja(n.source,e)&&ja(t,e)!=ja(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Pa(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max((0,ic.sum)(t.sourceLinks,Na),(0,ic.sum)(t.targetLinks,Na)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,i){var o,n,r;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,n=[],r=0;o.length;++r,o=n,n=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(o=t.nodes,n=[],r=0;o.length;++r,o=n,n=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,r):t.column})}(d,l,c);var f=r;if(null!==s){var p=(0,ic.groups)(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=(0,ic.max)(p,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=(0,ic.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var n=(0,ic.min)(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/(0,ic.sum)(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var r=(0,ic.max)(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/r),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,f,n),ac(d,l,a),cc(d,l,a,f,f,u),lc(d),Ja(d,a,h,10,8),ac(d,l,a),cc(d,l,a,f,f,u),lc(d),Ja(d,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return ja(i.source,e)==ja(t,e)}),n=o.length;n>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ka(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=La(e,t);return t.y1-i}if(e.target.column>t.target.column)return La(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var r=i+1,s=0;n>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return ja(i.target,e)==ja(t,e)}),n=o.length;n>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ka(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=Ca(e,t);return t.y0-i}if(e.source.column>t.source.column)return Ca(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var r=i+1,s=0;n>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,i=t.links,o=!1,n=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==o||0==n){let o=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=(0,ic.min)(e,function(t){return t.y0}),s=(0,ic.max)(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1)}),i.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=o(t.y0)-t.y0;t.y0=o(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),Ja(d,a,h,10,8)}(p),p}return p.update=function(t){return lc(t),Ja(t,a,h,10,8),t},p.nodeWidth=function(t){return arguments.length?(n=+t,p):n},p.nodePadding=function(t){return arguments.length?(r=+t,p):r},p.nodePaddingRatio=function(t){return arguments.length?(s=+t,p):s},p.nodes=function(t){return arguments.length?(d="function"==typeof t?t:oc(t),p):d},p.links=function(t){return arguments.length?(f="function"==typeof t?t:oc(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:oc(t),p):a},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:oc(t),p):c},p.nodeSort=function(t){return arguments.length?(l=t,p):l},p.iterations=function(t){return arguments.length?(u=+t,p):u},p.circularLinkGap=function(t){return arguments.length?(h=+t,p):h},p.extent=function(n){return arguments.length?(t=+n[0][0],e=+n[0][1],i=+n[1][0],o=+n[1][1],p):[[t,e],[i,o]]},p.size=function(n){return arguments.length?(t=e=0,i=+n[0],o=+n[1],p):[i-t,o-e]},p}var hc=require("d3-interpolate"),dc=(require("d3-shape"),.5),fc=t=>{let e,i,o,n,r,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=(0,hc.interpolateNumber)(r,s),c=a(dc),l=a(.5),`M${e},${r}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${n},${c} ${n},${r}Z`;const u=t.sankeyWidth/2,h=(0,hc.interpolateNumber)(t.source.x1,t.target.x0),{pathD:d}=Tt({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(dc),cp2X:h(.5)});return d};function pc(t){const e=t.sankeyWidth/2,i=(t._circularWidth??t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const i=o.sourceX,n=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-i))),c=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${i},${n-e}L${i+a},${n-e}L${i+a},${n+e}L${i},${n+e}ZM${r},${s-e}L${r-c},${s-e}L${r-c},${s+e}L${r},${s+e}Z`}const n=o.sourceX,r=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(i,15));return`M${n},${r-h*e}L${c},${r-h*e}L${c+i},${r-h*e+h*d}L${c+i},${u+h*i-h*d}L${c+i-d},${u+h*i}L${l-i+d},${u+h*i}L${l-i},${u+h*i-h*d}L${l-i},${a-h*e+h*d}L${l-i+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${l+i},${a+h*e}L${l+i},${u-h*i}L${c-i},${u-h*i}L${c-i},${r+h*e}L${n},${r+h*e}Z`}var yc=new Set,gc=new WeakMap;function mc(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=gc.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,gc.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;yc.has(t)||(yc.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}var xc={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Ba))-1:0},justify:Fa};function bc(t){return"string"==typeof t?t:t.id}var vc={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const n="vertical"===i.orientation?"down":"right",r=i.nodeAlign||"justify",s=i.nodeWidth??15,a=i.nodePaddingRatio??.05,c=i.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===n?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const d=uc().extent(h).links(u).nodes(l).nodeAlign(xc[r]||Fa).nodeId(t=>t.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const o of l)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>n&&(n=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(o._circularWidth??o.width??0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),i>r.verticalFullExtent-s&&(i=r.verticalFullExtent-s),r.verticalFullExtent+s>n&&(n=r.verticalFullExtent+s)}const r=e-t,s=n-i,a=o[0],c=o[1];if(r>0&&s>0&&(0>t||0>i||e>a||n>c)){const e=Math.min(a/r,c/s),o=-t*e+(a-r*e)/2,n=-i*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of u)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+n,i.targetY=i.targetY*e+n,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+n,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+n,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+n,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of l){const e=f.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const p=new Map;for(const t of e)p.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=bc(t.source),i=bc(t.target),o=p.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=t.width??0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=n;const r=f.get(e),s=f.get(i);r&&(o.source=r),s&&(o.target=s)}}},buildScene(t,e,i,o){const n="vertical"===i.orientation?"down":"right",r=i.nodeStyle,s=i.edgeStyle,a=i.edgeOpacity??.5,c=i.edgeColorBy||"source",l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:g,u=new Map;t.forEach((t,e)=>{u.set(t.id,l[e%l.length])});const h=[],d=[],f=[],p=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=r?r(mc(e,"nodeStyle")):{},s={fill:o.fill||u.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),h.push("down"===n?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:s,datum:e,id:e.id,label:e.id})}const y=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of y){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let n=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";n="function"==typeof c?c(t)||n:"target"===c?p.get(o.id)||u.get(o.id)||n:p.get(e.id)||u.get(e.id)||n;const r=s?s(mc(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=r.fill||n;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),d.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-s},${e.targetY-i}L${e.targetX-s},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;(l=t.circular&&t.circularPathData?pc(t):fc(t),l)&&d.push({type:"bezier",pathD:l,bezierCache:t.bezier,style:{fill:r.fill||n,fillOpacity:r.fillOpacity??a,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity},datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const s=e?e(i):i.id;if(!s)continue;let a,c,l;"down"===n?(a=i.y0+(i.y1-i.y0)/2,c=i.x1+14,l="start"):(o[0]/2>i.x0+t/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),c=i.y0+r/2),f.push({x:a,y:c,text:s+"",anchor:"down"===n?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:h,sceneEdges:d,labels:f}}},wc=require("d3-force"),kc=require("d3-scale"),Sc={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const n=i.forceStrength??.1,r=o[0]/2,s=o[1]/2,a=i.__previousPositions;let c=0;const l=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=a?.get(e.id);t?c++:i?(e.x=i.x,e.y=i.y,c++):l.push(e)}const u=c>0&&.3>=(t.length>0?l.length/t.length:1);if(u){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of l){const o=Ac(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const n=Mc(t.id),r=n%360*(Math.PI/180),s=10+n%20;t.x=e/o.length+s*Math.cos(r),t.y=i/o.length+s*Math.sin(r)}else{const e=Mc(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=r+o*Math.cos(i),t.y=s+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),n=i*e;o.x=r+t*Math.cos(n),o.y=s+t*Math.sin(n)}}}const h=i.__skipForceSimulation||0===i.iterations?0:u?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),d=_c(i.nodeSize,i.nodeSizeRange,t),f=t=>d(t);if(h>0){const o=new Map,a=new Map;for(const e of t)o.set(e.id,0),a.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id;o.set(e,(o.get(e)??0)+1),o.set(i,(o.get(i)??0)+1)}const c=(0,wc.forceLink)().strength(t=>{const e=t.weight,i="string"==typeof t.target?t.target:t.target.id,r=Math.max(1,Math.min(o.get("string"==typeof t.source?t.source:t.source.id)??1,o.get(i)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*n/(.1*r))}).distance(t=>{const e="string"==typeof t.source?a.get(t.source):t.source,i="string"==typeof t.target?a.get(t.target):t.target,o=(e?f(e):0)+(i?f(i):0)+12;return Math.max(40,o)}).id(t=>t.id),l=(0,wc.forceSimulation)();if(void 0===i.random&&void 0===i.seed||l.randomSource(i.random??function(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}(i.seed)),l.force("charge",(0,wc.forceManyBody)().strength(t=>{const e=o.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",(0,wc.forceCollide)(t=>f(t)+3).strength(.9).iterations(2)).force("center",(0,wc.forceCenter)(r,s).strength(.8)).force("x",(0,wc.forceX)(r).strength(.06)).force("y",(0,wc.forceY)(s).strength(.06)),l.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));c.links(t),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let t=0;h>t;++t)l.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=p.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=p.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){const n=i.nodeStyle,r=i.edgeStyle,s=_c(i.nodeSize,i.nodeSizeRange,t),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:g,c=new Map;t.forEach((t,e)=>{c.set(t.id,a[e%a.length])});const l=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(mc(e,"nodeSize")),o=n?n(mc(e,"nodeStyle")):{},r={fill:o.fill||c.get(e.id)||i.themeSemantic?.primary||"#007bff",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};l.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:d.get(t.source),o="object"==typeof t.target?t.target:d.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const n=r?r(mc(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:n.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6},datum:t})}if(!1!==i.showLabels){const e=(f=i.nodeLabel)?"function"==typeof f?f:t=>t[f]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=s(mc(i,"nodeSize"));h.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Ac(t,e,i){const o=[];for(const n of e){const e="string"==typeof n.source?n.source:n.source.id,r="string"==typeof n.target?n.target:n.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Mc(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function _c(t,e,i){if(i.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],n=[];for(const e of i){const i=e.data?.[t];"number"==typeof i&&n.push(i)}if(0===n.length)return()=>o[0];const[r,s]=yt(n);if(r===s)return()=>(o[0]+o[1])/2;const a=(0,kc.scaleLinear)().domain([r,s]).range(o).clamp(!0);return e=>{const i=e.data?.[t];return null==i||"number"!=typeof i?o[0]:a(i)}}var Pc=require("d3-chord"),Tc=require("d3-shape"),Rc=g,Lc={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:n=.01,groupWidth:r=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-r,l=o[0]/2,u=o[1]/2,h=(d=i.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const n=h(t);y[i][o]=n}const g=(0,Pc.chord)().padAngle(n);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,Tc.arc)().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],o=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});i.x=o[0]+l,i.y=o[1]+u,i.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=v.get("string"==typeof t.source?t.source:t.source.id),o=v.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const i=t[e.source.index].id,o=t[e.target.index].id,n=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);n&&(n.__chordData=e)}},buildScene(t,e,i,o){const{groupWidth:n=20,edgeOpacity:r=.5}=i,s=Math.min(o[0],o[1])/2,a=s-n,c=o[0]/2,l=o[1]/2,u=i.nodeStyle,h=i.edgeStyle,d=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Rc,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=(0,Pc.ribbon)().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.__arcData;if(!o)continue;let n;n=u?u(mc(i,"nodeStyle")).fill||p.get(i.id)||f[e%f.length]:p.get(i.id)||f[e%f.length];const r=u?u(mc(i,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:n,stroke:r.stroke||"black",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=y(e);if(!o)continue;const n=Cc(o,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";if(h)s=h(mc(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===d&&i?s=p.get(i.id)||s:e&&(s=p.get(e.id)||s)}const a=h?h(mc(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:n,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==i.showLabels){const e=(b=i.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,o=s+12;for(const i of t){const t=i.__arcData;if(!t)continue;const n=e?e(i):i.id;if(!n)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:n+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Cc(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const n=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("C"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("Q"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("A"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&(n.push(Number(o[r])+e+""),r++),o.length>r&&(n.push(Number(o[r])+i+""),r++);else"Z"===t||"z"===t?(n.push(t),r++):(n.push(o[r]),r++)}return n.join(" ")}var $c=require("d3-hierarchy"),jc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function zc(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Ec(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Dc(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function Nc(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:jc}function Ic(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Bc(t,e,i,o,n){if("horizontal"===n){const n=(t+i)/2;return`M ${t},${e} C ${n},${e} ${n},${o} ${i},${o}`}if("radial"===n){const n=(t+i)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+o)/2} T ${i},${o}`}{const n=(e+o)/2;return`M ${t},${e} C ${t},${n} ${i},${n} ${i},${o}`}}var Fc={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){const n=i.__hierarchyRoot;if(!n)return;const r=i.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),a=i.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=(0,$c.hierarchy)(n,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=o;switch(r){case"tree":!function(t,e,i,o){const n=e.treeOrientation||"vertical",r=(0,$c.tree)();r.size("horizontal"===n?[o,i]:"radial"===n?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),r(t)}(l,i,u,h);break;case"cluster":!function(t,e,i,o){const n=e.treeOrientation||"vertical",r=(0,$c.cluster)();r.size("horizontal"===n?[o,i]:"radial"===n?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),r(t)}(l,i,u,h);break;case"treemap":!function(t,e,i,o){const n=e.padding??4,r=e.paddingTop??0,s=(0,$c.treemap)().size([i,o]).tile($c.treemapBinary).padding(n);r>0&&s.paddingTop(r),s(t)}(l,i,u,h);break;case"circlepack":!function(t,e,i,o){const n=e.padding??4;(0,$c.pack)().size([i,o]).padding(n)(t)}(l,i,u,h);break;case"partition":!function(t,e,i,o){(0,$c.partition)().size([i,o]).padding(e.padding??1)(t)}(l,i,u,h)}const d=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const o=d[e],n={id:Ec(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===r||"cluster"===r?Oc(n,o,i):"treemap"===r||"partition"===r?Wc(n,o):"circlepack"===r&&Yc(n,o),n.__hierarchyNode=o,t.push(n),f.set(o,n)}if("tree"===r||"cluster"===r)for(const t of d)if(t.parent){const i=f.get(t.parent),o=f.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const n=i.nodeStyle||(()=>({})),r=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,n,r){const s=[],a=[],c=[],l=i.treeOrientation||"vertical",u="radial"===l,h=o[0]/2,d=o[1]/2,f="number"==typeof(p=i.nodeSize)?p:5;var p;for(const e of t){let t=e.x,o=e.y;u&&(t+=h,o+=d);const r=n(mc(e,"nodeStyle"));let a=r.fill||Ic(i);if(i.colorByDepth&&void 0!==e.depth){const t=Nc(i);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:o,r:f,style:{fill:a,stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=i.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let n=e.x,s=e.y,c=o.x,f=o.y;u&&(n+=h,s+=d,c+=h,f+=d);const p=Bc(n,s,c,f,l),g=r(mc(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:t})}if(!1!==i.showLabels){const e=Dc(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,n,r,s=i.x,a=i.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,n=a+e/i*10,r=0>t?"end":"start"):(o=s,n=a-12,r="middle")}else"horizontal"===l?(i.data?.children&&0!==i.data.children.length?(o=s-f-6,r="end"):(o=s+f+6,r="start"),n=a):(o=s,n=a+f+14,r="middle");c.push({x:o,y:n,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,i,o,n,r);case"treemap":case"partition":return function(t,e,i,o){const n=[],r=[];for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const s=o(mc(i,"nodeStyle"));let a=s.fill||Ic(e);if(e.colorByDepth&&void 0!==i.depth){const t=Nc(e);a=t[i.depth%t.length]}n.push({type:"rect",x:i.x0,y:i.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Dc(e.nodeLabel),n=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,c=a.y1-a.y0;if(0>=t||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===n&&!l)continue;if("parent"===n&&l)continue}const u=i?i(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let h=o(mc(a,"nodeStyle")).fill||Ic(e);if(e.colorByDepth&&void 0!==a.depth){const t=Nc(e);h=t[a.depth%t.length]}const d="string"==typeof h?zc(h):e.themeSemantic?.text??"#000";r.push(l?{x:a.x0+t/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,i,0,n);case"circlepack":return function(t,e,i,o){const n=[],r=[];for(const i of t){const t=i.__radius??5;if(0>=t)continue;const r=o(mc(i,"nodeStyle"));let s=r.fill||Ic(e);if(e.colorByDepth&&void 0!==i.depth){const t=Nc(e);s=t[i.depth%t.length]}n.push({type:"circle",cx:i.x,cy:i.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Dc(e.nodeLabel);for(const n of t){const t=n.__radius??5,s=i?i(n):n.id;if(!s)continue;if(15>t)continue;const a=!(n.data?.children&&n.data.children.length>0);let c=o(mc(n,"nodeStyle")).fill||Ic(e);if(e.colorByDepth&&void 0!==n.depth){const t=Nc(e);c=t[n.depth%t.length]}if(a){const i="string"==typeof c?zc(c):e.themeSemantic?.text??"#000";r.push({x:n.x,y:n.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else r.push({x:n.x,y:n.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,i,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Oc(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Wc(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Yc(t,e){const i=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}var qc=require("d3-shape");function Xc(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var Gc={sankey:vc,force:Sc,chord:Lc,tree:Fc,cluster:Fc,treemap:Fc,circlepack:Fc,partition:Fc,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const n=i.__hierarchyRoot;n&&function(t,e,i,o,n){const r=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(i.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,l=i.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=Xc(i);d.metaMap.clear(),o.length=0,n.length=0;const f=new Map;function p(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const y=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=p(s(t));o.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,c,l,f,y,g){const m=r(e);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:i,depth:y,data:e,parentId:i},M=g?f/u(A)*S:f*S,_=(0,qc.pie)().value(t=>{const e=r(t)?.length;return e?4:1}).sort(null)(w),P=h(A);for(let e=0;w.length>e;e++){const r=(_[e].startAngle+_[e].endAngle)/2,a=w[e],u=p(s(a)),h=c+M*Math.sin(r),f=l+M*Math.cos(r)*P;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),d.metaMap.set(u,{ring:M,angle:r,depth:y,parentId:i,eccentricity:P}),n.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(a,u,h,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(n,o,i,t,e)},buildScene(t,e,i,o){const n=i.nodeStyle,r=i.nodeSize,s="number"==typeof r?()=>r:"function"==typeof r?r:()=>6,a=[],c=[],l=[];if(!1!==i.orbitShowRings){const e=Xc(i),o=new Map;for(const e of t)o.set(e.id,e);const n=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;n.has(i)||n.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of n)for(let n=0;r>n;n++){const a=n/r*Math.PI*2,l=(n+1)/r*Math.PI*2;c.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(l),y2:e+i*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(mc(e,"nodeSize")),o=n?n(mc(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:o.fill||i.themeSemantic?.primary||"#6366f1",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const u=new Map;for(const e of t)u.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:u.get(t.source),i="object"==typeof t.target?t.target:u.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&c.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=s(mc(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e?i.data?.[e]??i.id:i.id;l.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(t,e,i,o,n)=>!1!==i.orbitAnimated&&(function(t,e){const i=Xc(e),o=e.orbitSpeed??.25,n=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),r=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const o=a.get(t.parentId);if(!o)continue;const c=t.angle+r*s*n({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=o.x+t.ring*Math.sin(c),e.y=o.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}},Vc=require("react/jsx-runtime");function Hc(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var Zc=new Set(["tree","cluster","treemap","circlepack","partition"]);function Kc(t,e){const i=to(t.theme),o=t.chartType||"force",n=()=>no({frameType:"network",width:r[0],height:r[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,nodeCount:0,edgeCount:0}),r=t.size||[500,500],s=Is({top:20,right:20,bottom:20,left:20,...t.margin},t.title),a=Ns(t.title),c=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;if(!e)return[];const o=co(t.nodes||[]);if(o.length>0)return br(o,e);const n=Array.isArray(t.edges)?co(t.edges):[];if(0===n.length)return[];const r=Hc(t.sourceAccessor,"source"),s=Hc(t.targetAccessor,"target");return br(Array.from(new Set(n.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[],l=t.legendPosition;ro(t.legend)||so(t.legend)?Ws(s,{legend:t.legend,theme:i,position:l||"right",size:r,hasTitle:a,legendLayout:t.legendLayout}):t.showLegend&&c.length>0&&Os(s,{categories:c,colorScheme:t.colorScheme,theme:i,position:l||"right",size:r,hasTitle:a,legendLayout:t.legendLayout});const u=r[0]-s.left-s.right,h=r[1]-s.top-s.bottom,d=function(t){return Gc[t]}(o);if(!d&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const f={chartType:o,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme||i.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let p,y;if(Zc.has(o)){const o=t.data||t.edges;if(!o||Array.isArray(o))return e&&(e.evidence=n()),Sa.renderToStaticMarkup(Xs(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:h,idPrefix:t._idPrefix}));f.__hierarchyRoot=o,p=[],y=[]}else{const o=co(t.nodes||[]),a=Array.isArray(t.edges)?co(t.edges):[];if(0===o.length&&0===a.length)return e&&(e.evidence=n()),Sa.renderToStaticMarkup(Xs(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:h,idPrefix:t._idPrefix}));if(y=function(t,e){const i=Hc(e.sourceAccessor,"source"),o=Hc(e.targetAccessor,"target"),n=Hc(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(a,f),0===o.length&&y.length>0){const t=new Set;for(const e of y){const i=Fs(e.source),o=Fs(e.target);i&&t.add(i),o&&t.add(o)}p=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else p=function(t,e){const i=Hc(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(o,f)}let m=[],x=[],b=[],v=null;if(f.customNetworkLayout){const t=f.colorScheme,e=Fi(t,i.colors.categorical,g),o=Oi(e,t),n={nodes:p,edges:y,dimensions:{width:u,height:h,plot:{x:0,y:0,width:u,height:h}},theme:{semantic:i.colors,categorical:[...e]},resolveColor:o,config:f.layoutConfig??{}},r=f.customNetworkLayout(n);m=r.sceneNodes??[],x=r.sceneEdges??[],b=r.labels??[],v=r.overlays??null}else if(d){d.computeLayout(p,y,f,[u,h]);const t=d.buildScene(p,y,f,[u,h]);m=t.sceneNodes,x=t.sceneEdges,b=t.labels}const w=eo(i);for(const t of b)t.fill||(t.fill=w.text);e&&(e.evidence=no({frameType:"network",width:r[0],height:r[1],marks:[...m.map(t=>({type:"node:"+(t.type??"node")})),...x.map(t=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,nodeCount:m.length,edgeCount:x.length}));const k=x.map((e,i)=>rr({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"line":return(0,Kn.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const i=t;return(0,Kn.jsx)("path",{d:i.pathD,fill:Qn(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"ribbon":{const i=t;return(0,Kn.jsx)("path",{d:i.pathD,fill:Qn(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"curved":{const i=t;return(0,Kn.jsx)("path",{d:i.pathD,fill:Qn(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+e)}default:return null}}(e,i)})).filter(Boolean),S=m.map((e,i)=>rr({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"circle":{const i=t,o=Wn(i.style.fill)?Yn(i.style.fill,`net-circle-${e}-hatch`):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[o&&(0,Kn.jsx)("defs",{children:o}),(0,Kn.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:o?`url(#net-circle-${e}-hatch)`:Qn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-circle-"+e)}case"rect":{const i=t,o=Wn(i.style.fill)?Yn(i.style.fill,`net-rect-${e}-hatch`):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[o&&(0,Kn.jsx)("defs",{children:o}),(0,Kn.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:o?`url(#net-rect-${e}-hatch)`:Qn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-rect-"+e)}case"arc":{const i=t,o=(0,Fn.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Un)||"",n=Wn(i.style.fill)?Yn(i.style.fill,`net-arc-${e}-hatch`):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[n&&(0,Kn.jsx)("defs",{children:n}),(0,Kn.jsx)("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:n?`url(#net-arc-${e}-hatch)`:Qn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-arc-"+e)}case"symbol":{const i=t,o=Uo(i.symbolType,i.size,i.path);return(0,Kn.jsx)("path",{d:o,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?Qn(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-symbol-"+e)}case"glyph":return tr(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(e,i)})).filter(Boolean),A=b.map((t,e)=>function(t,e){return(0,Kn.jsx)("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}(t,e)).filter(Boolean),M=t.annotations?Cs({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{},layout:{width:u,height:h},theme:i,idPrefix:t._idPrefix}):null,_=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;if(!e)return[];const n=br(p.length>0?p.map(t=>t.data||{id:t.id}):Array.from(new Set(y.flatMap(t=>[Fs(t.source),Fs(t.target)]).filter(Boolean))).map(t=>({id:t})),e);return 0===n.length?null:xr({categories:n,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:s,hasTitle:a,legendLayout:t.legendLayout})})():null,P=ka.isValidElement(t.legend)?t.legend:Ys(t.legend,{theme:i,position:t.legendPosition||"right",size:r,margin:s,hasTitle:a,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||_;return Sa.renderToStaticMarkup(Xs((0,Vc.jsxs)(Vc.Fragment,{children:[t.backgroundGraphics,k,S,A,M,t.foregroundGraphics,v]}),{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:h,legend:P,idPrefix:t._idPrefix}))}var Uc=c(require("react")),Qc=c(require("react-dom/server")),Jc=require("d3-geo"),tl=require("d3-quadtree"),el=require("d3-geo"),il={mercator:el.geoMercator,equalEarth:el.geoEqualEarth,albersUsa:el.geoAlbersUsa,orthographic:el.geoOrthographic,naturalEarth:el.geoNaturalEarth1,equirectangular:el.geoEquirectangular};function ol(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function nl(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function rl(t,e,i){return t?"function"==typeof t?{...i,...t(e)}:{...i,...t}:{...i}}function sl(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let n=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>i?(2>n.length||o.push(n),n=[r]):n.push(r)}return 2>n.length||o.push(n),o}function al(t,e,i=24){const o=e[0]-t[0],n=e[1]-t[1],r=Math.sqrt(o*o+n*n);if(0===r)return[t,e];const s=-n/r,a=o/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const n=o/i,r=1-n;h.push([r*r*t[0]+2*r*n*l+n*n*e[0],r*r*t[1]+2*r*n*u+n*n*e[1]])}return h}function cl(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const n=t[e];let r,s;0===e?(r=t[1][0]-n[0],s=t[1][1]-n[1]):e===t.length-1?(r=n[0]-t[e-1][0],s=n[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([n[0]+s/a*i,n[1]+-r/a*i])}return o}function ll(t,e,i,o,n){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const c=s/a,l=-r/a,u=n/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}var ul=require("d3-scale"),hl=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dl=["scene-style","data-paint","accessibility","evidence"],fl=(t,e)=>({retainedData:t,invalidations:e}),pl=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yl=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gl=["scene-geometry","data-paint","accessibility","evidence"],ml=["scene-style","data-paint","accessibility","evidence"],xl=["overlay","accessibility","evidence"],bl=[],vl={xAccessor:fl("rebuild",pl),yAccessor:fl("rebuild",pl),lineDataAccessor:fl("rebuild",pl),pointIdAccessor:fl("rebuild",gl),lineIdAccessor:fl("rebuild",gl),windowSize:fl("rebuild",pl),projection:fl("preserve",yl),projectionExtent:fl("preserve",yl),fitPadding:fl("preserve",yl),lineType:fl("preserve",yl),flowStyle:fl("preserve",yl),graticule:fl("preserve",yl),projectionTransform:fl("preserve",yl),customLayout:fl("preserve",yl),layoutConfig:fl("preserve",yl),layoutMargin:fl("preserve",yl),areaStyle:fl("preserve",ml),pointStyle:fl("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:fl("preserve",ml),colorScheme:fl("preserve",ml),themeCategorical:fl("preserve",ml),themeDiverging:fl("preserve",ml),themeSemantic:fl("preserve",ml),themeSequential:fl("preserve",ml),decay:fl("preserve",ml),pulse:fl("preserve",ml),layoutSelection:fl("preserve",ml),annotations:fl("preserve",xl),autoPlaceAnnotations:fl("preserve",xl),clock:fl("preserve",bl),transition:fl("preserve",bl),introAnimation:fl("preserve",bl),onLayoutError:fl("preserve",bl)},wl=fl("preserve",yl),kl=class{constructor(){this.tracker=new ai}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},hl)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},dl):this.recordNoop("restyle")}recordConfig(t,e={}){const i=function(t){let e="preserve";const i=new Set;for(const o of t){const t=vl[o]??wl;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t),o=new Set(i.invalidations);return e.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:t},o)}},Sl=require("d3-geo");function Al(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var Ml=class t{constructor(t){this.updateResults=new kl,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(t){return{...t,fitPadding:Al(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??Mo()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],o=e.slice(-t),n=i.slice(-o.length),r=this.currentTime();this.pointBuffer=new ho(t),this.timestampBuffer=new ho(t),o.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(n[e]??r)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:Al(t.fitPadding)}:t}(t),i=this.config,o=this.getConfiguredWindowSize(),n=Object.keys(e).filter(t=>e[t]!==i[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==o;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(n,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],n=i.slice(-e),r=o.slice(-n.length),s=this.currentTime();this.pointBuffer=new ho(e),this.timestampBuffer=new ho(e),n.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??s)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();dn(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const i of t)dn(this.pointBuffer,i,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),n=[];return this.lineData=this.lineData.filter(t=>!o.has(i(t)+"")||(n.push(t),!1)),n.length>0?(this.version++,this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");fn(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(t){const e=this._customRestyle;if(e){for(const i of this.scene){const o=this._baseStyles.get(i)??i.style,n=e(i,t);i.style=n?{...o,...n}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,i=this.projection,o=this.geoPath,n=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return(0,el.geoEqualEarth)();if("string"==typeof t){const e=il[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),(0,el.geoEqualEarth)())}if("object"==typeof t&&"type"in t){const e=il[t.type],i=e?e():(0,el.geoEqualEarth)();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=(0,Jc.geoPath)(this.projection),this.fitProjection(t),this.geoPath=(0,Jc.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(t,e)=>l([t,e]),invertedPoint:(t,e)=>l.invert?l.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=o,this.scales=n,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,i=this.config,o=[...this.areas],n=ol(i.xAccessor,"lon"),r=ol(i.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[n(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=nl(i.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[n(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==o.length){if(i.projectionExtent){const[[o,n],[r,s]]=i.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,n],[r,n],[r,s],[o,s],[o,n]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const o=i.fitPadding??0,n=Math.min(t.width,t.height);e.scale(n/2-n*o),e.translate([t.width/2,t.height/2])}else{const n=i.fitPadding??0,r=t.width*n,s=t.height*n;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,n=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=(0,Jc.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,n=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=(0,Jc.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;if(!i||!i.rotate)return;const o=this.geoPath,n=this.scales,r=[...i.rotate()];i.rotate(t),this.geoPath=(0,Jc.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(r),this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,i=0;for(const t of this.scene)"point"===t.type&&(i++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);const o=Array(i);let n=0;for(const t of this.scene)"point"===t.type&&(o[n++]=t);this._quadtree=(0,tl.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,i=this.projection,o=this.geoPath;if(e.customLayout&&this.scales){const i=e.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Fi(e.colorScheme,e.themeCategorical,j),n={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:i,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...o]},resolveColor:Oi(o,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(n)}catch(t){const i=null!==this.lastCustomLayoutResult,o=nn("geo",t,i,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return i?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return tn({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:t,projection:e,path:i,areas:o,points:n,lines:r,layout:s}){const a=ol(t.xAccessor,"lon"),c=ol(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,o=(0,Sl.geoGraticule)();e.step&&o.step(e.step);const n=i(o())||"";n&&l.push({type:"geoarea",pathData:n,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of o){const o=i(e);if(!o)continue;const n=i.centroid(e),r=i.bounds(e),s=i.area(e);l.push({type:"geoarea",pathData:o,centroid:n,bounds:r,screenArea:s,style:rl(t.areaStyle,e,u),datum:e,interactive:!0})}const f=nl(t.lineDataAccessor);for(const i of r){const o=f(i);if(!o||2>o.length)continue;let n=[];if("geo"===t.lineType){const t=Array(o.length);for(let e=0;o.length>e;e++)t[e]=[a(o[e]),c(o[e])];for(let i=0;t.length-1>i;i++){const o=t[i],r=t[i+1],s=(0,Sl.geoDistance)(o,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,Sl.geoInterpolate)(o,r);for(let t=0;a>=t;t++){if(i>0&&0===t)continue;const o=e(c(t/a));null!=o&&n.push(o)}}}else for(let t=0;o.length>t;t++){const i=o[t],r=e([a(i),c(i)]);null!=r&&n.push(r)}if(2>n.length)continue;const r=rl(t.lineStyle,i,h),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==o.length||2>n.length||"arc"!==t.flowStyle?2!==o.length||2>n.length||"offset"!==t.flowStyle||(n="geo"===t.lineType?cl(n,u):ll(n[0],n[n.length-1],0,0,u)):n=al(n[0],n[n.length-1]);const d=sl(n,s.width);if(d.length>1)for(const t of d)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:i});else l.push({type:"line",path:2>n.length&&d[0]||n,style:r,datum:i})}const p=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,y=e.clipAngle?e.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=e.rotate?e.rotate():[0,0,0],x="function"==typeof e.center?e.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const i of n){const o=a(i),n=c(i);if(null!=g&&(0,Sl.geoDistance)([o,n],b)>g)continue;const r=e([o,n]);if(!r)continue;const s=t.pointStyle?t.pointStyle(i):{...d},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:i,pointId:p?p(i)+"":void 0};l.push(u)}return l}({config:e,projection:i,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const i=function(t,e,i,o){const n=t.filter(t=>"point"===t.type);if(2>n.length)return null;const r=e.strength??1;if(0===r)return null;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,a="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=n.find(t=>t.datum&&s(t.datum)+""==e.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const l=c.x,u=c.y,h=gt(n.map(t=>t.datum?a(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),d=Math.min(i.width,i.height)/2,f=(0,ul.scaleLinear)().domain([0,h]).range([0,d]);o>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const i=t[e];"geoarea"===i.type&&i.interactive&&t.splice(e,1)}for(const t of n){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-u,t.x-l),i=Math.sqrt((t.x-l)**2+(t.y-u)**2),o=a(t.datum),n=i+((isFinite(o)?f(o):i)-i)*r;t.x=l+Math.cos(e)*n,t.y=u+Math.sin(e)*n}const p=i.width/2,y=i.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const t of n)t.x+=g,t.y+=m;const x={cx:p,cy:y,maxCost:h,availableRadius:d},b=t.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==e.lineMode){const t=new Map;for(const e of n)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const i=e.datum?.source,o=e.datum?.target;if(i&&o){const n=t.get(i+""),r=t.get(o+"");n&&r&&(e.path=[n,r])}}}return x}(this.scene,t,e,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const n=_o(t,o,e);i[o]._decayOpacity=n,i[o].style={...i[o].style,opacity:n}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const i=this.scene.filter(t=>"point"===t.type),o=this.timestampBuffer.toArray(),n=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let s=!1;for(let a=0;i.length>a&&o.length>a;a++){const c=To(e,o[a],t);s=Ro(i[a],c,n,r)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&Lo(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const i=new Map;for(const e of t)"point"===e.type&&e.pointId&&i.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let n=!1;for(const t of o)if(t.pointId){const e=i.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(n=!0))}for(const t of o)t.pointId&&!i.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},n=!0);n&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=So(t,this.activeTransition),i=ko(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Ao(t.x,t._targetX,i),t.y=Ao(e,t._targetY,i)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*i})}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Ml.QUADTREE_THRESHOLD=500;var _l=Ml;wn(_l);var Pl=require("react/jsx-runtime");function Tl(t,e){const i=to(t.theme),o=t.size||[t.width||600,t.height||400],n=Is({top:10,right:10,bottom:10,left:10,...t.margin},t.title),r=Ns(t.title),s=Array.isArray(t.areas)?co(t.areas):t.areas,a=co(t.points),c=co(t.lines),l=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;return br(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof e?s.map(t=>({...t.properties||{},...t})):s:[],e)})():[],u=t.legendPosition;ro(t.legend)||so(t.legend)?Ws(n,{legend:t.legend,theme:i,position:u||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&l.length>0&&Os(n,{categories:l,colorScheme:t.colorScheme,theme:i,position:u||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const h=o[0]-(n.left??0)-(n.right??0),d=o[1]-(n.top??0)-(n.bottom??0),f={projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,themeCategorical:i.colors.categorical,themeSemantic:Dt(i)},p=new _l(f);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);p.setAreas(s)}if(t.points&&p.setPoints(a),t.lines&&p.setLines(c),p.computeScene({width:h,height:d}),e&&(e.evidence=no({frameType:"geo",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,legendItems:l.length>0?l.length:void 0})),0===p.scene.length){const e=t.backgroundGraphics||t.foregroundGraphics||t.annotations||p.customLayoutOverlays?(0,Pl.jsxs)(Pl.Fragment,{children:[t.backgroundGraphics,t.annotations?Cs({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,t.foregroundGraphics,p.customLayoutOverlays]}):null;return Qc.renderToStaticMarkup(Xs(e,{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:h,innerHeight:d,idPrefix:t._idPrefix}))}const y=p.scene.map((e,i)=>rr({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"geoarea":{const i=t;if(!i.pathData)return null;const o=Wn(i.style.fill)?Yn(i.style.fill,`geoarea-${e}-hatch`):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[o&&(0,Kn.jsx)("defs",{children:o}),(0,Kn.jsx)("path",{d:i.pathData,fill:o?`url(#geoarea-${e}-hatch)`:Qn(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:i._decayOpacity??1})]},"geoarea-"+e)}case"point":{const i=t,o=Wn(i.style.fill)?Yn(i.style.fill,`geopoint-${e}-hatch`):void 0;return(0,Kn.jsxs)(Bn.Fragment,{children:[o&&(0,Kn.jsx)("defs",{children:o}),(0,Kn.jsx)("circle",{cx:i.x,cy:i.y,r:i.r,fill:o?`url(#geopoint-${e}-hatch)`:Qn(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+e)}case"line":{const i=t;if(2>i.path.length)return null;const o="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return(0,Kn.jsx)("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+e)}case"glyph":return tr(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(e,i)})).filter(Boolean),g=t.annotations?Cs({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,m=t.showLegend?0===l.length?null:xr({categories:l,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,x=Uc.isValidElement(t.legend)?t.legend:Ys(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||m;return Qc.renderToStaticMarkup(Xs((0,Pl.jsxs)(Pl.Fragment,{children:[t.backgroundGraphics,y,g,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:h,innerHeight:d,legend:x,idPrefix:t._idPrefix}))}var Rl=c(require("react-dom/server"));function Ll(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}var Cl={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function $l(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function jl(t,e){const i="function"==typeof e?e(t):e;return{...Cl,...i??{}}}function zl(t,e={}){return t.map(t=>function(t,e={}){const i=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),o={label:e.getBodyLabel?.(t)??$l(t)},n={style:jl(t,e.bodyStyle),datum:i,accessibleDatum:i,accessibility:o,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...n}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...n}}(t,e))}var El=require("react/jsx-runtime");function Dl(t,e){const i=t.size??[t.width??600,t.height??400],o=new Si(t.config);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&o.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const n=function(t,e={}){const{width:i=640,height:o=360,title:n,description:r,background:s,className:a,idPrefix:c="physics",...l}=e,u=function(t,e={}){const i=t.settle(e.maxSteps),o=t.readBodies(),n=t.snapshot(),r=zl(o,e),s=function(t,e={}){const i=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),o=i.filter(t=>t.sleeping).length;return{bodyCount:i.length,sleepingCount:o,settled:"settled"===t.simulationState&&0===t.queue.length&&o===i.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:Ll(e.projectionRows)}}(n,{bodies:o,projectionRows:e.projectionRows,stepsRun:i});return{snapshot:n,bodies:o,sceneNodes:r,evidence:s,stepsRun:i}}(t,l),h=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(c),d=n?h+"-title":void 0,f=r?h+"-desc":void 0,p=[d,f].filter(Boolean).join(" ")||void 0;return{svg:Rl.renderToStaticMarkup((0,El.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:i,height:o,viewBox:`0 0 ${i} ${o}`,role:"img","aria-labelledby":p,children:[n&&(0,El.jsx)("title",{id:d,children:n}),r&&(0,El.jsx)("desc",{id:f,children:r}),s&&"transparent"!==s?(0,El.jsx)("rect",{x:0,y:0,width:i,height:o,fill:s}):null,(0,El.jsx)("g",{id:h+"-data-area",children:u.sceneNodes.map((t,e)=>ir(t,e,h))})]})),scene:u,evidence:u.evidence}}(o,{...t,width:i[0],height:i[1],idPrefix:t.idPrefix??t._idPrefix??"physics"});return e&&(e.evidence=no({frameType:"physics",width:i[0],height:i[1],marks:n.scene.sceneNodes,title:t.title,description:t.description,annotations:[],extraWarnings:0===n.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),n.svg}var Nl=require("react/jsx-runtime");function Il(t,e){switch(t){case"xy":return Vs(e);case"ordinal":return wa(e);case"network":return Kc(e);case"geo":return Tl(e);case"physics":return Dl(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Bl(t){return Vs(t)}function Fl(t){return wa(t)}function Ol(t){return Kc(t)}function Wl(t){return Tl(t)}var Yl=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function ql(t,e,i){return Gl(t,e).svg}function Xl(t,e,i){const o={},{svg:n,frameType:r}=Gl(t,e,0,o),s=o.evidence??no({frameType:r,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=t,{svg:n,evidence:s}}function Gl(t,e,i,o){const{data:n,width:r=600,height:s=400,theme:a,title:c,description:l,showLegend:h,showGrid:d,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=e,w=[r,s],k={...v.frameProps||{},...function(t,e){const i={};for(const o of e)void 0!==t[o]&&(i[o]=t[o]);return i}(v,Yl),theme:a,title:c,description:l,showLegend:h,showGrid:d,background:f,className:p,annotations:y,size:w,...void 0!==g&&{margin:g},...void 0!==m&&{colorScheme:m},...void 0!==b&&{legendPosition:b},_idPrefix:v._idPrefix},S=Ji[t];if(!S)throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`);const A=S.buildProps(n,x,m,k,v);let M;switch(S.frameType){case"xy":M=Vs(A,o);break;case"ordinal":M=wa(A,o);break;case"network":M=Kc(A,o);break;case"geo":M=Tl(A,o);break;case"physics":M=Dl(A,o)}if("GaugeChart"===t&&A.__gauge){const t=A.__gauge,e=k.margin||{top:20,right:20,bottom:30,left:40},i=(r||300)-e.left-e.right,o=(s||300)-e.top-e.bottom,n=Math.min(i,o)/2*.85,c=e.left+i/2,l=e.top+o/2,h=(t.startAngleDeg+(t.gMax===t.gMin?0:(Math.max(t.gMin,Math.min(t.gMax,t.value??t.gMin))-t.gMin)/(t.gMax-t.gMin))*t.sweep-90)*Math.PI/180,d=to(a).colors.text,f=u.renderToStaticMarkup((0,Nl.jsxs)(Nl.Fragment,{children:[(0,Nl.jsx)("line",{x1:c,y1:l,x2:c+n*Math.cos(h),y2:l+n*Math.sin(h),stroke:d,strokeWidth:2.5,strokeLinecap:"round"}),(0,Nl.jsx)("circle",{cx:c,cy:l,r:4,fill:d})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}async function Vl(t,e,i={}){const{format:o="png",scale:n=1,background:r}=i;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?Il(t,e):ql(t,e),r&&(s=s.replace(/<svg /,`<svg style="background:${r}" `));try{const t="sharp",e=await import(t);a=e.default??e}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=e.width||e.size?.[0]||600,l=e.height||e.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*n}).resize(Math.round(c*n),Math.round(l*n));return"jpeg"===o?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function Hl(t,e={}){const{title:i,subtitle:o,theme:n,width:r=1200,height:s,layout:a={},background:c}=e,l=eo(to(n)),h=a.columns||2,d=a.gap??16;let f=0;i&&(f+=30),o&&(f+=20),f>0&&(f+=10);const p=Math.floor((r-d-d*(h-1))/h),y=[];let g=0,m=f+d,x=0;for(const e of t){const t=Math.min(e.colSpan||1,h),i=e.props.height||300;g+t>h&&(m+=x+d,g=0,x=0),y.push({chart:e,x:d/2+g*(p+d),y:m,w:p*t+d*(t-1),h:i}),x=Math.max(x,i),g+=t}const b=s||m+x+d,v=y.map((t,e)=>{const{chart:i,x:o,y:r,w:s,h:a}=t,c={...i.props,width:s,height:a,theme:n,_idPrefix:"chart-"+e};let l;return l=i.component?ql(i.component,c):i.frameType?Il(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Nl.jsx)("g",{transform:`translate(${o},${r})`,children:(0,Nl.jsx)("foreignObject",{width:s,height:a,children:(0,Nl.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+e)});return u.renderToStaticMarkup((0,Nl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:b,role:"img","aria-label":i||"Dashboard",style:{fontFamily:l.fontFamily},children:[i&&(0,Nl.jsx)("title",{children:i}),c&&(0,Nl.jsx)("rect",{x:0,y:0,width:r,height:b,fill:c}),i&&(0,Nl.jsx)("text",{x:r/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:i}),o&&(0,Nl.jsx)("text",{x:r/2,y:i?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:o}),v]}))}var Zl=c(require("react-dom/server")),Kl=require("react/jsx-runtime");function Ul(t,e,i,o={}){const{stepSize:n,windowSize:r,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,p=i.height||400,y=to(i.theme),g={...i,...a&&{xExtent:a},...c&&{yExtent:c}};if(!e||0===e.length)return[];const m=n||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),v=Is({top:20,right:20,bottom:30,left:40,...i.margin},i.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let o=0;x.length>o;o++){const n=x[o],s=e.slice(r?Math.max(0,n-r):0,n),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical,...d&&{decay:d}},c=new xa(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(ou(c.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const n=x[o],s=e.slice(r?Math.max(0,n-r):0,n),m={chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...d&&{decay:d},...l>0&&{transition:{duration:l*(1e3/u),easing:h}}},b=new In(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(iu(b.scene,f,p,y,g,v)),l>0&&o>0&&b.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/l*t),S.push(iu(b.scene,f,p,y,g,v))}}return S}function Ql(t,e,i={}){return e.map(e=>{try{return ql(t,{...i,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function Jl(t,e,i){const o=e.size??[e.width??600,e.height??400],n=to(e.theme),r=eo(n),s=e.background||n.colors.background,a=e.idPrefix??"physics-gif",c=e.title?`${a}-title-${i}`:void 0,l=e.description?`${a}-desc-${i}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,h=zl(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),d=(0,Kl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:r.fontFamily},children:[e.title&&(0,Kl.jsx)("title",{id:c,children:e.title}),e.description&&(0,Kl.jsx)("desc",{id:l,children:e.description}),s&&"transparent"!==s?(0,Kl.jsx)("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,(0,Kl.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((t,e)=>ir(t,e,`${a}-${i}`))})]});return Zl.renderToStaticMarkup(d)}function tu(t,e={}){const{fps:i=12,frameCount:o,durationSeconds:n=2,includeInitialFrame:r=!0,stepDt:s,stepsPerFrame:a,background:c}=e,l=Math.max(.001,s??t.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,i)/l)),h=o??Math.max(1,Math.ceil(n*Math.max(1,i))),d=c?{...t,background:c}:t,f=new Si(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push(Jl(f,d,0)));h>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(Jl(f,d,p.length))}return p}function eu(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function iu(t,e,i,o,n,r){const s=eo(o),a=Is({top:20,right:20,bottom:30,left:40,...n.margin},n.title),c=e-a.left-a.right,l=i-a.top-a.bottom,u=eu(n,o),h=n.renderMode,d=t.map((t,e)=>rr({node:t,index:e,renderMode:h,fallback:()=>ir(t,e)})).filter(Boolean),f=function(t,e,i,o,n,r){if(!t||0===t.length)return null;const s=eo(o),a=[];for(let o=0;t.length>o;o++){const c=t[o];if("y-threshold"===c.type&&null!=c.value){let t=null;if(r)t=r(c.value);else if(n){const[e,o]=n,r=o-e;if(0===r)continue;t=i-(c.value-e)/r*i}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,Kl.jsxs)("g",{children:[(0,Kl.jsx)("line",{x1:0,y1:t,x2:e,y2:t,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,Kl.jsx)("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(i-4,t+16):t-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+o))}}return a.length>0?(0,Kl.jsx)(Kl.Fragment,{children:a}):null}(n.annotations,c,l,o,n.yExtent,r?.y),p="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return Zl.renderToStaticMarkup((0,Kl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,Kl.jsx)("title",{id:g,children:p}),y&&(0,Kl.jsx)("desc",{id:m,children:y}),u&&(0,Kl.jsx)("rect",{x:0,y:0,width:e,height:i,fill:u}),(0,Kl.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,d]}),p&&(0,Kl.jsx)("text",{x:e/2,y:Ds,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function ou(t,e,i,o,n){const r=eo(o),s=Is({top:20,right:20,bottom:30,left:40,...n.margin},n.title),a="radial"===n.projection,c=a?s.left+(e-s.left-s.right)/2:s.left,l=a?s.top+(i-s.top-s.bottom)/2:s.top,u=eu(n,o),h=n.renderMode,d=t.map((t,e)=>rr({node:t,index:e,renderMode:h,fallback:()=>or(t,e)})).filter(Boolean),f="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return Zl.renderToStaticMarkup((0,Kl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[f&&(0,Kl.jsx)("title",{id:y,children:f}),p&&(0,Kl.jsx)("desc",{id:g,children:p}),u&&(0,Kl.jsx)("rect",{x:0,y:0,width:e,height:i,fill:u}),(0,Kl.jsx)("g",{transform:`translate(${c},${l})`,children:d}),f&&(0,Kl.jsx)("text",{x:e/2,y:Ds,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:f})]}))}async function nu(t,e,i,o={}){const{fps:n=12,loop:r=!0,scale:s=1,background:a}=o,c=i.width||600,l=i.height||400,u=Ul(t,e,a?{...i,background:a}:i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return su(u,c,l,{fps:n,loop:r,scale:s})}async function ru(t,e={}){const{fps:i=12,loop:o=!0,scale:n=1}=e,r=t.size??[t.width??600,t.height??400],s=tu(t,e);if(0===s.length)throw Error("No physics frames generated");return su(s,r[0],r[1],{fps:i,loop:o,scale:n})}async function su(t,e,i,o={}){const{fps:n=12,loop:r=!0,scale:s=1}=o,a=Math.round(e*s),c=Math.round(i*s);let l,u,h,d;try{const t="sharp",e=await import(t);l=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await import(t),i=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!i)throw Error("gifenc did not expose its encoder functions");u=i.GIFEncoder,h=i.quantize,d=i.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:t})}const f=Math.round(1e3/n),p=u();for(let e=0;t.length>e;e++){const i=t[e],o=await l(Buffer.from(i),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),n=new Uint8Array(o),u=h(n,256),y=d(n,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}