semiotic 3.7.4 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +60 -15
- package/README.md +135 -24
- package/agent-skill/semiotic-charts/SKILL.md +146 -0
- package/ai/cli.js +133 -45
- package/ai/componentMetadata.cjs +6 -1
- package/ai/dist/mcp-server.js +1651 -154
- package/ai/examples.md +174 -0
- package/ai/schema.json +2934 -517
- package/ai/surface-manifest.json +200 -0
- package/ai/system-prompt.md +19 -3
- package/dist/components/Annotation.d.ts +4 -0
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartContainer.d.ts +91 -0
- package/dist/components/ChartGrid.d.ts +11 -1
- package/dist/components/CircularBrush.d.ts +61 -0
- package/dist/components/ContextLayout.d.ts +5 -1
- package/dist/components/DataSummaryContext.d.ts +1 -0
- package/dist/components/DirectManipulationControl.d.ts +63 -0
- package/dist/components/LinkedCharts.d.ts +3 -1
- package/dist/components/MobileAnnotationCalloutList.d.ts +13 -0
- package/dist/components/MobileChartContainer.d.ts +51 -0
- package/dist/components/MobileStandardControls.d.ts +68 -0
- package/dist/components/SmallMultipleChart.d.ts +84 -0
- package/dist/components/Tooltip/FlippingTooltip.d.ts +21 -0
- package/dist/components/ai/ChartRecipe.d.ts +16 -0
- package/dist/components/ai/IntentMark.d.ts +15 -0
- package/dist/components/ai/chartCapabilities.d.ts +8 -1
- package/dist/components/ai/chartCapabilityTypes.d.ts +42 -1
- package/dist/components/ai/chartClinic.d.ts +91 -0
- package/dist/components/ai/chartRecipeRegistry.d.ts +14 -0
- package/dist/components/ai/chartRecipes.d.ts +278 -0
- package/dist/components/ai/dataPitfallsBridge.d.ts +203 -0
- package/dist/components/ai/dataQualityBridge.d.ts +201 -0
- package/dist/components/ai/describeChart.d.ts +9 -0
- package/dist/components/ai/describeRecipeChart.d.ts +16 -0
- package/dist/components/ai/generativeChart.d.ts +170 -0
- package/dist/components/ai/intentManifest.d.ts +62 -0
- package/dist/components/ai/navigationTree.d.ts +3 -0
- package/dist/components/ai/observedSceneAudit.d.ts +72 -0
- package/dist/components/ai/readerGrounding.d.ts +83 -0
- package/dist/components/ai/recipeCapability.d.ts +8 -0
- package/dist/components/ai/recipeNavigation.d.ts +13 -0
- package/dist/components/ai/recipeSemantics.d.ts +11 -0
- package/dist/components/ai/repairChartConfig.d.ts +9 -0
- package/dist/components/ai/suggestCharts.d.ts +11 -1
- package/dist/components/charts/custom/GeoCustomChart.d.ts +48 -0
- package/dist/components/charts/custom/NetworkCustomChart.d.ts +22 -3
- package/dist/components/charts/custom/OrdinalCustomChart.d.ts +8 -2
- package/dist/components/charts/custom/XYCustomChart.d.ts +11 -2
- package/dist/components/charts/geo/DistanceCartogram.d.ts +1 -1
- package/dist/components/charts/geo/FlowMap.d.ts +1 -1
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +1 -1
- package/dist/components/charts/geo/index.d.ts +2 -0
- package/dist/components/charts/index.d.ts +29 -1
- package/dist/components/charts/network/ChordDiagram.d.ts +1 -1
- package/dist/components/charts/network/CirclePack.d.ts +1 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +15 -5
- package/dist/components/charts/network/OrbitDiagram.d.ts +1 -1
- package/dist/components/charts/network/ProcessSankey.d.ts +1 -1
- package/dist/components/charts/network/SankeyDiagram.d.ts +1 -1
- package/dist/components/charts/network/TreeDiagram.d.ts +1 -1
- package/dist/components/charts/network/Treemap.d.ts +1 -1
- package/dist/components/charts/network/useForceLayout.d.ts +17 -0
- package/dist/components/charts/ordinal/BarChart.d.ts +1 -1
- package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -1
- package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
- package/dist/components/charts/ordinal/DotPlot.d.ts +1 -1
- package/dist/components/charts/ordinal/FunnelChart.d.ts +1 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -1
- package/dist/components/charts/ordinal/Histogram.d.ts +1 -1
- package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -1
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -1
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +8 -1
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +1 -1
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -1
- package/dist/components/charts/physics/ChainReactionChart.d.ts +9 -0
- package/dist/components/charts/physics/CollisionSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +47 -0
- package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/EventDropChart.d.ts +53 -0
- package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +66 -0
- package/dist/components/charts/physics/GauntletChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/GauntletChart.d.ts +73 -0
- package/dist/components/charts/physics/PhysicalFlowChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/PhysicalFlowChart.d.ts +63 -0
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +120 -0
- package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/PhysicsPileChart.d.ts +53 -0
- package/dist/components/charts/physics/ProcessFlowChart.capability.d.ts +2 -0
- package/dist/components/charts/physics/ProcessFlowChart.d.ts +96 -0
- package/dist/components/charts/physics/chainReactionOverlay.d.ts +22 -0
- package/dist/components/charts/physics/chainReactionRuntime.d.ts +37 -0
- package/dist/components/charts/physics/chainReactionTypes.d.ts +97 -0
- package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +27 -0
- package/dist/components/charts/physics/dependencyMachine.d.ts +188 -0
- package/dist/components/charts/physics/eventDropPhysics.d.ts +64 -0
- package/dist/components/charts/physics/galtonBoardPhysics.d.ts +28 -0
- package/dist/components/charts/physics/gauntletChartProps.d.ts +67 -0
- package/dist/components/charts/physics/gauntletChrome.d.ts +33 -0
- package/dist/components/charts/physics/gauntletController.d.ts +73 -0
- package/dist/components/charts/physics/gauntletEffects.d.ts +36 -0
- package/dist/components/charts/physics/gauntletPhysics.d.ts +71 -0
- package/dist/components/charts/physics/gauntletRuntime.d.ts +42 -0
- package/dist/components/charts/physics/gauntletTypes.d.ts +213 -0
- package/dist/components/charts/physics/physicalFlowPhysics.d.ts +57 -0
- package/dist/components/charts/physics/physicsChartShared.d.ts +41 -0
- package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -0
- package/dist/components/charts/physics/physicsEncoding.d.ts +142 -0
- package/dist/components/charts/physics/physicsHocHandle.d.ts +53 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +128 -0
- package/dist/components/charts/physics/physicsPilePhysics.d.ts +41 -0
- package/dist/components/charts/physics/physicsProcessPrimitives.d.ts +38 -0
- package/dist/components/charts/physics/processFlowPhysics.d.ts +97 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -1
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +9 -1
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +30 -1
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +16 -2
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -1
- package/dist/components/charts/realtime/aggregate.d.ts +51 -0
- package/dist/components/charts/realtime/eventTime.d.ts +26 -0
- package/dist/components/charts/shared/auditMobileVisualization.d.ts +91 -0
- package/dist/components/charts/shared/chartDefinitionPilot.d.ts +145 -0
- package/dist/components/charts/shared/chartFamilySets.d.ts +20 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +165 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +8 -127
- package/dist/components/charts/shared/chartSpecsGeo.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsNetwork.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsOrdinal.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsPhysics.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsRealtime.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsValue.d.ts +2 -0
- package/dist/components/charts/shared/chartSpecsXY.d.ts +2 -0
- package/dist/components/charts/shared/colorContrast.d.ts +3 -0
- package/dist/components/charts/shared/colorPalettes.d.ts +2 -0
- package/dist/components/charts/shared/colorUtils.d.ts +17 -13
- package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +4 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +9 -14
- package/dist/components/charts/shared/diagnoseMisleadingChecks.d.ts +9 -0
- package/dist/components/charts/shared/diagnosePhysicsChecks.d.ts +3 -0
- package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
- package/dist/components/charts/shared/hooks.d.ts +28 -5
- package/dist/components/charts/shared/minMax.d.ts +3 -0
- package/dist/components/charts/shared/motionEncoding.d.ts +145 -0
- package/dist/components/charts/shared/radialGeometry.d.ts +0 -18
- package/dist/components/charts/shared/responsiveRules.d.ts +56 -0
- package/dist/components/charts/shared/smartTooltip.d.ts +27 -0
- package/dist/components/charts/shared/statisticalOverlays.d.ts +35 -0
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +12 -2
- package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +2 -0
- package/dist/components/charts/shared/types.d.ts +49 -1
- package/dist/components/charts/shared/useChartSetup.d.ts +10 -3
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +15 -6
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +1 -1
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
- package/dist/components/charts/shared/validateChartData.d.ts +1 -1
- package/dist/components/charts/shared/validationMap.d.ts +0 -11
- package/dist/components/charts/xy/AreaChart.d.ts +1 -1
- package/dist/components/charts/xy/BubbleChart.d.ts +1 -1
- package/dist/components/charts/xy/LineChart.d.ts +1 -1
- package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +2 -2
- package/dist/components/charts/xy/QuadrantChart.d.ts +1 -1
- package/dist/components/charts/xy/Scatterplot.d.ts +10 -1
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
- package/dist/components/charts/xy/StackedAreaChart.d.ts +9 -4
- package/dist/components/controls/controlAudit.d.ts +24 -0
- package/dist/components/controls/controlContract.d.ts +57 -0
- package/dist/components/data/fromArrow.d.ts +54 -0
- package/dist/components/data/fromFlintChart.d.ts +74 -0
- package/dist/components/data/fromMermaid.d.ts +47 -0
- package/dist/components/data/fromObservablePlot.d.ts +69 -0
- package/dist/components/data/fromVegaLite.d.ts +27 -0
- package/dist/components/data/portability/index.d.ts +17 -0
- package/dist/components/data/portability/result.d.ts +52 -0
- package/dist/components/data/portability/spec.d.ts +160 -0
- package/dist/components/data/portability/vegaLite.d.ts +80 -0
- package/dist/components/export/chartConfig.d.ts +11 -0
- package/dist/components/realtime/ReorderBuffer.d.ts +54 -0
- package/dist/components/realtime/RunningStats.d.ts +66 -0
- package/dist/components/realtime/WindowAccumulator.d.ts +105 -0
- package/dist/components/realtime/parseWindowDuration.d.ts +12 -0
- package/dist/components/realtime/types.d.ts +11 -0
- package/dist/components/recipes/annotationLayout.d.ts +29 -0
- package/dist/components/recipes/axisFixedForce.d.ts +119 -0
- package/dist/components/recipes/boba.d.ts +23 -0
- package/dist/components/recipes/customTooltip.d.ts +31 -0
- package/dist/components/recipes/cyclical.d.ts +39 -0
- package/dist/components/recipes/edgeRouter.d.ts +103 -0
- package/dist/components/recipes/forceLayout.d.ts +48 -0
- package/dist/components/recipes/forceLayoutAsync.d.ts +17 -0
- package/dist/components/recipes/gofishBobaHandwritten.d.ts +3 -0
- package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +37 -0
- package/dist/components/recipes/gofishIR.d.ts +215 -0
- package/dist/components/recipes/gofishIRExamples.d.ts +38 -0
- package/dist/components/recipes/intervalLanes.d.ts +87 -0
- package/dist/components/recipes/intervals.d.ts +80 -0
- package/dist/components/recipes/isometricLandmarks.d.ts +88 -0
- package/dist/components/recipes/isotypeGlyphs.d.ts +17 -0
- package/dist/components/recipes/mermaidDag.d.ts +44 -0
- package/dist/components/recipes/mobileAnnotationStrategy.d.ts +48 -0
- package/dist/components/recipes/mobileChartFamilyRecipes.d.ts +59 -0
- package/dist/components/recipes/networkAnalysis.d.ts +102 -0
- package/dist/components/recipes/networkLayouts.d.ts +83 -0
- package/dist/components/recipes/packedClusterMatrix.d.ts +166 -0
- package/dist/components/recipes/physics.d.ts +122 -0
- package/dist/components/recipes/physicsReference.d.ts +102 -0
- package/dist/components/recipes/processAggregates.d.ts +32 -0
- package/dist/components/recipes/processChrome.d.ts +67 -0
- package/dist/components/recipes/processJourney.d.ts +54 -0
- package/dist/components/recipes/processPhysics.d.ts +300 -0
- package/dist/components/recipes/processVolumeGeometry.d.ts +28 -0
- package/dist/components/recipes/radialCoords.d.ts +69 -0
- package/dist/components/recipes/random.d.ts +2 -0
- package/dist/components/recipes/recipeChrome.d.ts +191 -0
- package/dist/components/recipes/recipeGlyph.d.ts +42 -0
- package/dist/components/recipes/recipeLegend.d.ts +109 -0
- package/dist/components/recipes/recipeUtils.d.ts +157 -0
- package/dist/components/recipes/runs.d.ts +59 -0
- package/dist/components/recipes/tokenEncoding.d.ts +157 -0
- package/dist/components/recipes/tokenLayer.d.ts +79 -0
- package/dist/components/recipes/unitize.d.ts +108 -0
- package/dist/components/recipes/vector.d.ts +28 -0
- package/dist/components/recipes/waffle.d.ts +43 -0
- package/dist/components/semiotic-ai-core.d.ts +47 -0
- package/dist/components/semiotic-ai.d.ts +52 -4
- package/dist/components/semiotic-controls.d.ts +18 -0
- package/dist/components/semiotic-data.d.ts +2 -0
- package/dist/components/semiotic-experimental.d.ts +49 -0
- package/dist/components/semiotic-geo.d.ts +11 -0
- package/dist/components/semiotic-network.d.ts +14 -1
- package/dist/components/semiotic-ordinal.d.ts +10 -0
- package/dist/components/semiotic-physics-matter.d.ts +10 -0
- package/dist/components/semiotic-physics-rapier.d.ts +9 -0
- package/dist/components/semiotic-physics.d.ts +56 -0
- package/dist/components/semiotic-realtime-core.d.ts +34 -0
- package/dist/components/semiotic-realtime-react.d.ts +10 -0
- package/dist/components/semiotic-realtime.d.ts +4 -22
- package/dist/components/semiotic-recipes-core.d.ts +92 -0
- package/dist/components/semiotic-recipes-react.d.ts +7 -0
- package/dist/components/semiotic-recipes.d.ts +4 -26
- package/dist/components/semiotic-server-edge.d.ts +8 -0
- package/dist/components/semiotic-server-node.d.ts +5 -0
- package/dist/components/semiotic-server.d.ts +2 -2
- package/dist/components/semiotic-themes-core.d.ts +53 -0
- package/dist/components/semiotic-themes-react.d.ts +4 -0
- package/dist/components/semiotic-themes.d.ts +6 -74
- package/dist/components/semiotic-utils-core.d.ts +46 -0
- package/dist/components/semiotic-utils-react.d.ts +5 -0
- package/dist/components/semiotic-utils.d.ts +3 -39
- package/dist/components/semiotic-xy.d.ts +10 -0
- package/dist/components/semiotic.d.ts +39 -7
- package/dist/components/server/animatedGif.d.ts +36 -0
- package/dist/components/server/renderEvidence.d.ts +1 -1
- package/dist/components/server/renderToStaticSVG.d.ts +3 -35
- package/dist/components/server/serverChartConfigShared.d.ts +17 -0
- package/dist/components/server/serverChartConfigs.d.ts +19 -9
- package/dist/components/server/serverChartConfigsCustom.d.ts +5 -0
- package/dist/components/server/serverChartConfigsGeo.d.ts +9 -0
- package/dist/components/server/serverChartConfigsNetwork.d.ts +8 -0
- package/dist/components/server/serverChartConfigsOrdinal.d.ts +16 -0
- package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
- package/dist/components/server/serverChartConfigsXY.d.ts +11 -0
- package/dist/components/server/staticGeo.d.ts +4 -0
- package/dist/components/server/staticLegend.d.ts +1 -1
- package/dist/components/server/staticNetwork.d.ts +8 -0
- package/dist/components/server/staticOrdinal.d.ts +11 -0
- package/dist/components/server/staticPhysics.d.ts +3 -0
- package/dist/components/server/staticSVGChrome.d.ts +110 -0
- package/dist/components/server/staticXY.d.ts +4 -0
- package/dist/components/store/ObservationStore.d.ts +23 -3
- package/dist/components/store/SelectionStore.d.ts +1 -1
- package/dist/components/store/ThemeStore.d.ts +1 -1
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/createStore.d.ts +1 -1
- package/dist/components/store/designTokens.d.ts +15 -0
- package/dist/components/store/themeSerialization.d.ts +32 -0
- package/dist/components/store/useChartInterrogation.d.ts +9 -0
- package/dist/components/stream/AccessibleDataTable.d.ts +3 -13
- package/dist/components/stream/FocusRing.d.ts +4 -2
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +28 -0
- package/dist/components/stream/NetworkHtmlMarksLayer.d.ts +44 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +62 -25
- package/dist/components/stream/NetworkSVGOverlay.d.ts +15 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +64 -2
- package/dist/components/stream/PipelineStore.d.ts +100 -162
- package/dist/components/stream/SceneGraph.d.ts +14 -2
- package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +1 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
- package/dist/components/stream/StreamXYFrame.d.ts +2 -18
- package/dist/components/stream/accessibleDataRows.d.ts +33 -0
- package/dist/components/stream/accessorUtils.d.ts +23 -10
- package/dist/components/stream/brushAccessibility.d.ts +25 -0
- package/dist/components/stream/canvasBackground.d.ts +24 -0
- package/dist/components/stream/canvasSetup.d.ts +4 -1
- package/dist/components/stream/customLayout.d.ts +20 -0
- package/dist/components/stream/customLayoutDiagnostics.d.ts +11 -0
- package/dist/components/stream/customLayoutFailure.d.ts +33 -0
- package/dist/components/stream/customLayoutPalette.d.ts +19 -9
- package/dist/components/stream/customLayoutSelection.d.ts +52 -0
- package/dist/components/stream/frameThemeColors.d.ts +24 -0
- package/dist/components/stream/geoAnnotationAnchors.d.ts +14 -0
- package/dist/components/stream/geoCartogram.d.ts +17 -0
- package/dist/components/stream/geoCustomLayout.d.ts +59 -0
- package/dist/components/stream/geoDefaultTooltip.d.ts +11 -0
- package/dist/components/stream/geoFrameHelpers.d.ts +34 -0
- package/dist/components/stream/geoPipelineHelpers.d.ts +46 -0
- package/dist/components/stream/geoTypes.d.ts +56 -7
- package/dist/components/stream/glyphDef.d.ts +98 -0
- package/dist/components/stream/hitTarget.d.ts +170 -0
- package/dist/components/stream/hoverUtils.d.ts +3 -0
- package/dist/components/stream/keyboardNav.d.ts +4 -1
- package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +9 -1
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +57 -0
- package/dist/components/stream/networkBezier.d.ts +10 -0
- package/dist/components/stream/networkColorAccessors.d.ts +49 -0
- package/dist/components/stream/networkCustomLayout.d.ts +66 -1
- package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
- package/dist/components/stream/networkFramePaint.d.ts +43 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
- package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
- package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
- package/dist/components/stream/networkTypes.d.ts +104 -5
- package/dist/components/stream/ordinalCanvasRenderers.d.ts +7 -0
- package/dist/components/stream/ordinalCustomLayout.d.ts +17 -1
- package/dist/components/stream/ordinalDataIndex.d.ts +5 -0
- package/dist/components/stream/ordinalDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/ordinalDomain.d.ts +38 -0
- package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +12 -0
- package/dist/components/stream/ordinalPulse.d.ts +10 -0
- package/dist/components/stream/ordinalPulseResources.d.ts +3 -0
- package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +5 -0
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
- package/dist/components/stream/ordinalSpatialIndex.d.ts +9 -0
- package/dist/components/stream/ordinalTypes.d.ts +56 -8
- package/dist/components/stream/paintNeeds.d.ts +31 -0
- package/dist/components/stream/physics/CapacityQueueController.d.ts +5 -0
- package/dist/components/stream/physics/CapacityQueueTypes.d.ts +134 -0
- package/dist/components/stream/physics/MatterPhysicsEngineAdapter.d.ts +42 -0
- package/dist/components/stream/physics/PhysicsAccessibility.d.ts +48 -0
- package/dist/components/stream/physics/PhysicsAnnotations.d.ts +58 -0
- package/dist/components/stream/physics/PhysicsBodyBudget.d.ts +26 -0
- package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +10 -0
- package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +26 -0
- package/dist/components/stream/physics/PhysicsControllers.d.ts +75 -0
- package/dist/components/stream/physics/PhysicsEngineAdapter.d.ts +59 -0
- package/dist/components/stream/physics/PhysicsEngineConformance.d.ts +23 -0
- package/dist/components/stream/physics/PhysicsEvidence.d.ts +25 -0
- package/dist/components/stream/physics/PhysicsKernel.d.ts +207 -0
- package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +12 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +84 -0
- package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +72 -0
- package/dist/components/stream/physics/PhysicsSediment.d.ts +69 -0
- package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +18 -0
- package/dist/components/stream/physics/PhysicsSettledScene.d.ts +21 -0
- package/dist/components/stream/physics/PhysicsWorkerClient.d.ts +24 -0
- package/dist/components/stream/physics/PhysicsWorkerProtocol.d.ts +101 -0
- package/dist/components/stream/physics/PhysicsWorkerRuntime.d.ts +5 -0
- package/dist/components/stream/physics/RapierPhysicsEngineAdapter.d.ts +18 -0
- package/dist/components/stream/physics/ServiceOperationsControllers.d.ts +27 -0
- package/dist/components/stream/physics/ServiceOperationsTypes.d.ts +89 -0
- package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +6 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +302 -0
- package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -0
- package/dist/components/stream/physics/physicsPipelineControls.d.ts +4 -0
- package/dist/components/stream/physics/physicsPipelineHelpers.d.ts +41 -0
- package/dist/components/stream/physics/physicsPipelineObservations.d.ts +14 -0
- package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +9 -0
- package/dist/components/stream/physics/physicsRegionRuntime.d.ts +54 -0
- package/dist/components/stream/physics/physicsSemanticUI.d.ts +20 -0
- package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +16 -0
- package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
- package/dist/components/stream/pipelineConfig.d.ts +177 -0
- package/dist/components/stream/pipelineDecay.d.ts +20 -2
- package/dist/components/stream/pipelineDomainResolution.d.ts +62 -0
- package/dist/components/stream/pipelineIdentityOps.d.ts +26 -0
- package/dist/components/stream/pipelinePulse.d.ts +16 -2
- package/dist/components/stream/pipelineRibbons.d.ts +41 -0
- package/dist/components/stream/pipelineSpatialIndex.d.ts +12 -0
- package/dist/components/stream/pipelineStoreUpdateResults.d.ts +12 -0
- package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
- package/dist/components/stream/pipelineTransitions.d.ts +2 -0
- package/dist/components/stream/pipelineUpdateContract.d.ts +62 -0
- package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
- package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
- package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +2 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
- package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +2 -0
- package/dist/components/stream/sceneRevisionDiagnostics.d.ts +18 -0
- package/dist/components/stream/stalenessBands.d.ts +28 -0
- package/dist/components/stream/streamStoreSync.d.ts +37 -0
- package/dist/components/stream/symbolPath.d.ts +24 -0
- package/dist/components/stream/types.d.ts +206 -9
- package/dist/components/stream/useFrame.d.ts +21 -2
- package/dist/components/stream/useHydration.d.ts +6 -0
- package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -0
- package/dist/components/stream/useStalenessCheck.d.ts +6 -1
- package/dist/components/stream/workerModuleUrl.d.ts +10 -0
- package/dist/components/stream/xyAnnotationAnchors.d.ts +13 -0
- package/dist/components/stream/xyCanvasRenderers.d.ts +7 -0
- package/dist/components/stream/xyCrosshair.d.ts +11 -0
- package/dist/components/stream/xyDateTicks.d.ts +9 -0
- package/dist/components/stream/xyDefaultTooltip.d.ts +10 -0
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/xySceneBuilders/types.d.ts +9 -4
- package/dist/controls.min.js +2 -0
- package/dist/controls.module.min.js +2 -0
- package/dist/forceLayoutWorker.js +1 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics-matter.min.js +1 -0
- package/dist/physics-matter.module.min.js +1 -0
- package/dist/physics-rapier.min.js +1 -0
- package/dist/physics-rapier.module.min.js +1 -0
- package/dist/physics.min.js +2 -0
- package/dist/physics.module.min.js +2 -0
- package/dist/physicsWorker.js +1 -0
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-chunk-OG7BQUUW.module.min.js +2 -0
- package/dist/semiotic-ai-core.d.ts +47 -0
- package/dist/semiotic-ai-core.min.js +1 -0
- package/dist/semiotic-ai-core.module.min.js +1 -0
- package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +2 -0
- package/dist/semiotic-ai.d.ts +52 -4
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-chunk-3FSVZ46U.module.min.js +2 -0
- package/dist/semiotic-controls.d.ts +18 -0
- package/dist/semiotic-data.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental.d.ts +49 -0
- package/dist/semiotic-experimental.min.js +1 -0
- package/dist/semiotic-experimental.module.min.js +1 -0
- package/dist/semiotic-geo.d.ts +11 -0
- package/dist/semiotic-network.d.ts +14 -1
- package/dist/semiotic-ordinal.d.ts +10 -0
- package/dist/semiotic-physics-matter.d.ts +10 -0
- package/dist/semiotic-physics-rapier.d.ts +9 -0
- package/dist/semiotic-physics.d.ts +56 -0
- package/dist/semiotic-realtime-core.d.ts +34 -0
- package/dist/semiotic-realtime-core.min.js +1 -0
- package/dist/semiotic-realtime-core.module.min.js +1 -0
- package/dist/semiotic-realtime-react.d.ts +10 -0
- package/dist/semiotic-realtime-react.min.js +2 -0
- package/dist/semiotic-realtime-react.module.min.js +2 -0
- package/dist/semiotic-realtime.d.ts +4 -22
- package/dist/semiotic-recipes-core.d.ts +92 -0
- package/dist/semiotic-recipes-core.min.js +1 -0
- package/dist/semiotic-recipes-core.module.min.js +1 -0
- package/dist/semiotic-recipes-react.d.ts +7 -0
- package/dist/semiotic-recipes-react.min.js +2 -0
- package/dist/semiotic-recipes-react.module.min.js +2 -0
- package/dist/semiotic-recipes.d.ts +4 -26
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.d.ts +8 -0
- package/dist/semiotic-server-edge.min.js +1 -0
- package/dist/semiotic-server-edge.module.min.js +1 -0
- package/dist/semiotic-server-node.d.ts +5 -0
- package/dist/semiotic-server-node.min.js +1 -0
- package/dist/semiotic-server-node.module.min.js +1 -0
- package/dist/semiotic-server.d.ts +2 -2
- package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +2 -0
- package/dist/semiotic-themes-core.d.ts +53 -0
- package/dist/semiotic-themes-core.min.js +1 -0
- package/dist/semiotic-themes-core.module.min.js +1 -0
- package/dist/semiotic-themes-react.d.ts +4 -0
- package/dist/semiotic-themes-react.min.js +2 -0
- package/dist/semiotic-themes-react.module.min.js +2 -0
- package/dist/semiotic-themes.d.ts +6 -74
- package/dist/semiotic-themes.min.js +1 -2
- package/dist/semiotic-themes.module.min.js +1 -2
- package/dist/semiotic-utils-core.d.ts +46 -0
- package/dist/semiotic-utils-core.min.js +1 -0
- package/dist/semiotic-utils-core.module.min.js +1 -0
- package/dist/semiotic-utils-react.d.ts +5 -0
- package/dist/semiotic-utils-react.min.js +2 -0
- package/dist/semiotic-utils-react.module.min.js +2 -0
- package/dist/semiotic-utils.d.ts +3 -39
- package/dist/semiotic-utils.min.js +1 -2
- package/dist/semiotic-utils.module.min.js +1 -2
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +10 -0
- package/dist/semiotic.d.ts +39 -7
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy-chunk-IWD6IB6V.module.min.js +2 -0
- package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +2 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +246 -86
- package/spec/README.md +152 -0
- package/spec/bindings/README.md +35 -0
- package/spec/bindings/vega-lite.mjs +112 -0
- package/spec/v0.1/annotation-provenance.schema.json +127 -0
- package/spec/v0.1/audience-profile.schema.json +67 -0
- package/spec/v0.1/chart-capability.schema.json +186 -0
- package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +0 -1
- package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +0 -1
- package/dist/xy-statisticalOverlays-C2PPlmXv.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRef as o,useMemo as r,useContext as s,useCallback as a,useSyncExternalStore as l,createContext as c,useEffect as u,useState as d,useLayoutEffect as h,forwardRef as f,useId as g,useImperativeHandle as p}from"react";import*as y from"react-dom/server";import{scaleOrdinal as m,scaleLinear as v,scaleLog as b,scaleTime as x,scaleBand as k}from"d3-scale";import{quadtree as w}from"d3-quadtree";import{min as A,groups as S,max as M,sum as _,mean as P,group as O,quantile as T,bin as $}from"d3-array";import{interpolateNumber as j}from"d3-interpolate";import{forceLink as L,forceSimulation as C,forceManyBody as z,forceCenter as D,forceX as E,forceY as N}from"d3-force";import{ribbon as R,chord as F}from"d3-chord";import{arc as W,pie as B,curveNatural as I,curveBasis as Y,curveStepAfter as G,curveStepBefore as H,curveStep as X,curveCatmullRom as q,curveCardinal as V,curveMonotoneY as U,curveMonotoneX as Z,line as Q,area as K,curveLinear as J}from"d3-shape";import{hierarchy as tt,partition as et,pack as nt,treemap as it,treemapBinary as ot,cluster as rt,tree as st,packEnclose as at}from"d3-hierarchy";import{geoPath as lt,geoGraticule as ct,geoDistance as ut,geoInterpolate as dt,geoEqualEarth as ht,geoEquirectangular as ft,geoNaturalEarth1 as gt,geoOrthographic as pt,geoAlbersUsa as yt,geoMercator as mt}from"d3-geo";import{select as vt}from"d3-selection";import{brushX as bt,brushY as xt,brush as kt}from"d3-brush";import wt from"regression";function At(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}l((i=i.apply(t,e||[])).next())})}function St(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Mt(t){return"object"==typeof t&&null!==t&&"gradient"in t}"function"==typeof SuppressedError&&SuppressedError;class _t{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=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%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(i=>{t(i)?n.push(i):e.push(i)}),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 Pt{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 Ot(t,e,n,i,o){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/i)*i;let c=r.get(l);if(c||(c={start:l,end:l+i,total:0,categories:new Map},r.set(l,c)),c.total+=a,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function Tt(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}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:o,datum:c,group:r}}function $t(t,e,n,i,o,r,s,a){const l=[];for(const r of t){const t=n(r),s=i(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):o;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 jt(t,e,n,i){var o,r,s;const a=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;a.set(i,-t/2)}else if("wiggle"===i){t.length>0&&a.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];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!==(o=a.get(r))&&void 0!==o?o:0;a.set(s,d-(c>0?l/(2*c):0))}if(t.length>0){let i=0;for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;i+=(null!==(r=a.get(o))&&void 0!==r?r:0)+t/2}const o=i/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-o)}}else for(const e of t)a.set(e,0);return a}function Lt(t,e,n,i,o,r,s){const a=n(t),l=i(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:o,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function Ct(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function zt(t,e,n,i,o,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Dt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Et(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Nt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function Rt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function Ft(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Wt(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Bt(t){const e=t.map(Ft),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return Wt(t,n,i)}if(t>=1){const[t,i,o]=e[n];return Wt(t,i,o)}const i=t*n,o=Math.floor(i),r=i-o,[s,a,l]=e[o],[c,u,d]=e[o+1];return Wt(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const It=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Yt=Bt(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Gt=Bt(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Ht=Bt(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Xt=Bt(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),qt=Bt(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Vt=Bt(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Ut=Bt(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Zt=Bt(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Qt=Bt(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Kt=Bt(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Jt=Bt(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),te=Bt(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);Bt(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Bt(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Bt(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Bt(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Bt(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Bt(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Bt(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const ee={category10:It,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Yt,reds:Gt,greens:Ht,oranges:Xt,purples:qt,viridis:Ut,plasma:Zt},ne=It,ie=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],oe=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 re(t,e,n){if("function"==typeof e){const i=e(t);return n&&i&&"string"==typeof i&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||oe.has(e)}(i)?n(i):i}const i=(null==t?void 0:t[e])+"";return n?n(i):ne[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)}(i))%ne.length]}function se(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+""))),o=i.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return m().domain(i).range(n).unknown("#999");const r=ee[n]||ee.category10;if(o&&"function"==typeof r){let t=-1/0;for(const e of i){const n=Number(e);n>t&&(t=n)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:ne;return m().domain(i).range(t).unknown("#999")}}function ae(t,e,n){var i,o,r;if(1>=n)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,a=n-1-e;switch(t.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o: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 le(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function ce(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}function ue(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function de(t,e){return Math.min((t-e.startTime)/e.duration,1)}function he(t,e,n){return t+(e-t)*n}function fe(){return"undefined"!=typeof performance?performance.now():Date.now()}function ge(t,e,n){var i,o,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),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o: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 pe(t,e,n,i){return"function"==typeof e.style?e.style(i||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,i)}function ye(t,e,n,i){if(!t.scales)return null;const o=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=i.getTop(n),a=i.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)&&(o.push([l,c]),r.push([l,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:pe(t,i,n,e[0]),datum:e,group:n,interactive:i.interactive}}function me(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const i of t)i.perSeries?e.push(i):n.push(i);return{perSeries:e,aggregate:n}}function ve(t,e,n){const i=[];for(const o of n){const n=ye(t,e,"__ribbon_aggregate",o);n&&i.push(n)}return i}function be(t,e,n,i){const o=[];for(const r of i){const i=ye(t,e,n,r);i&&o.push(i)}return o}function xe(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const i of e){if("band"!==i.kind)continue;const e=i.getTop(t),o=i.getBottom(t);Number.isFinite(o)&&Number.isFinite(e)&&n.push({y0:o,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function ke(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const a=null!==(o=i.r)&&void 0!==o?o:3,l=t.getPointId?t.getPointId(s)+"":void 0,c=Lt(s,t.scales,t.getX,r,a,i,l);c&&n.push(c)}}}const we={topOpacity:.8,bottomOpacity:.05};function Ae(t){var e,n;if(t)return!0===t?we:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:we.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:we.bottomOpacity}}const Se={blues:Yt,reds:Gt,greens:Ht,viridis:Ut,oranges:Xt,purples:qt,greys:Vt,plasma:Zt,inferno:Qt,magma:Kt,cividis:Jt,turbo:te},Me=new Map;function _e(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Pe(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=_e(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=Et(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e+o:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e-o: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:_e(t.y1Accessor,"y1"),getBottom:_e(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class Oe{constructor(t){if(this.xExtent=new Pt,this.yExtent=new Pt,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.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new _t(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Et(t.timeAccessor||t.xAccessor,"time"),this.getY=Et(t.valueAccessor||t.yAccessor,"value")):(this.getX=Et(t.xAccessor,"x"),this.getY=Et(t.yAccessor,"y")),this.getGroup=Rt(t.groupAccessor),this.getCategory=Rt(t.categoryAccessor),this.getSize=t.sizeAccessor?Et(t.sizeAccessor,"size"):void 0,this.getColor=Rt(t.colorAccessor),this.getY0=t.y0Accessor?Et(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Pe(t),this.getPointId=Rt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Et(t.openAccessor,"open"):void 0,this.getHigh=Et(t.highAccessor,"high"),this.getLow=Et(t.lowAccessor,"low"),this.getClose=n?Et(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new _t(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),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}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?Et(this.config.timeAccessor||this.config.xAccessor,"time"):Et(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||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),i=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(i)&&this.yExtent.push(i)}}}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),i=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(i)&&this.yExtent.push(i)}}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),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}}return!0}computeScene(t){var e,n,i,o,r,s,a,l,c,u,d,h,f,g;const{config:p,buffer:y}=this;if(!this.needsFullRebuild&&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(y,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const m=this.getBufferArray(),k=this.xExtent.extent,w=this.yExtent.extent;let A=p.xExtent?[null!==(n=p.xExtent[0])&&void 0!==n?n:k[0],null!==(i=p.xExtent[1])&&void 0!==i?i:k[1]]:k,S=p.yExtent?[null!==(o=p.yExtent[0])&&void 0!==o?o:w[0],null!==(r=p.yExtent[1])&&void 0!==r?r:w[1]]:w;const M=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1],_="exact"===p.axisExtent;if("stackedarea"===p.chartType&&!M&&y.size>0)if(p.normalize)S=[0,_?1:1+p.extentPadding];else{const t=`${y.size}:${this._ingestVersion}:${null!==(s=p.baseline)&&void 0!==s?s:"zero"}:${null!==(a=p.stackOrder)&&void 0!==a?a:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)S=this._stackExtentCache.yDomain;else{const e=this.groupData(m),n=new Map,i=new Set;let o=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),i.add(t),a+=s;const l=(r.get(t)||0)+s;r.set(t,l),l>o&&(o=l)}n.set(t.key,e),s.set(t.key,a)}const a=null!==(l=p.stackOrder)&&void 0!==l?l:"key",f=(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,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}),n=[],i=[];let o=0,r=0;for(const e of t)r>o?(n.push(e),o+=null!==(c=s.get(e))&&void 0!==c?c:0):(i.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0);g=[...i.reverse(),...n]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(i=s.get(e))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):e.map(t=>t.key).sort(f);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(i).sort((t,e)=>t-e),e=jt(t,g,(t,e)=>{var i;return(null===(i=n.get(t))||void 0===i?void 0:i.get(e))||0},p.baseline);let o=1/0,s=-1/0;for(const n of t){const t=null!==(d=e.get(n))&&void 0!==d?d:0,i=null!==(h=r.get(n))&&void 0!==h?h:0;o>t&&(o=t),t+i>s&&(s=t+i)}Number.isFinite(o)&&Number.isFinite(s)||(o=0,s=0);const a=s-o,l=_?0:a>0?a*p.extentPadding:1;S=[o-l,s+l]}else S=[0,o+(_?0:o>0?o*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:S}}}else if("bar"===p.chartType&&p.binSize&&!M&&y.size>0){const[,t]=function(t,e,n,i,o){const r=Ot(t,e,n,i,o);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]}(y,this.getX,this.getY,p.binSize,this.getCategory);S=[0,_?t:t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!M&&y.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(y,this.getY),n=e-t,i=_?0:n>0?n*p.extentPadding:1;S=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!M&&S[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of m)for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&(S[0]>n&&(S[0]=n),n>S[1]&&(S[1]=n)),Number.isFinite(i)&&(S[0]>i&&(S[0]=i),i>S[1]&&(S[1]=i))}const t=S[1]-S[0],e=_?0:t>0?t*p.extentPadding:1,n=null===(f=p.yExtent)||void 0===f?void 0:f[0],i=null===(g=p.yExtent)||void 0===g?void 0:g[1];S=[null!=n?S[0]:S[0]-e,null!=i?S[1]:S[1]+e],"log"!==p.yScaleType||S[0]>0||0>=w[0]||_||(S[0]=null!=n?S[0]:w[0]/(1+p.extentPadding))}if(p.yExtent&&!M){const t=p.yExtent[0],e=p.yExtent[1];null==t&&null==e||(S=[null!=t?t:S[0],null!=e?e:S[1]])}if(A[0]===1/0||A[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();A=[t-864e5,t]}else A=[0,1];S[0]!==1/0&&S[1]!==-1/0||(S=[0,1]);const P="streaming"===p.runtimeMode,O=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(T=p.arrowOfTime)||"down"===T?"y":"x")){const e="right"===p.arrowOfTime?[O,t.width-O]:[t.width-O,O];this.scales={x:v().domain(A).range(e),y:v().domain(S).range([t.height-O,O])}}else{const e="down"===p.arrowOfTime?[O,t.height-O]:[t.height-O,O];this.scales={x:v().domain(S).range([O,t.width-O]),y:v().domain(A).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 b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)};this.scales={x:e(p.xScaleType,A,[O,t.width-O]),y:e(p.yScaleType,S,[t.height-O,O])}}var T;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,m),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),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,Oe.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(i)}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 i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[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(),o=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,r[0]>r[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,o,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,i,o,r,s,a,l;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const l=null!==(n=c.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},d={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:l,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(i=c.themeSemantic)&&void 0!==i?i:{},categorical:null!==(o=c.themeCategorical)&&void 0!==o?o:ie},resolveColor:(t,e)=>{var n,i;const o=this.resolveGroupColor(t);if(o)return o;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(i=null===(n=c.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==i?i:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null,null!==(a=h.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,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(c.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],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}=me(t.ribbons);if(r.length>0&&o.push(...ve(t,e,r)),n.length>0)for(const e of i)o.push(...be(t,e.data,e.key,n))}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=Tt(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return ke(t,i,o),o}(d,e);case"area":return function(t,e){const n=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=me(t.ribbons);if(r.length>0&&i.push(...ve(t,e,r)),o.length>0)for(const e of n)i.push(...be(t,e.data,e.key,o))}const o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=$t(e.data,t.scales,t.getX,t.getY,o,n,e.key,r),a=Ae(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),i.push(s)}return ke(t,n,i),i}(d,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=me(t.ribbons);if(r.length>0&&i.push(...ve(t,e,r)),o.length>0)for(const e of n)i.push(...be(t,e.data,e.key,o))}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(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=$t(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=Ae(t.config.gradientFill);a&&(o.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Tt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return ke(t,n,i),i}(d,e);case"stackedarea":return function(t,e){var n,i,o,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 i=0;for(const e of n.data){const n=t.getX(e),o=t.getY(e);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}e.set(n.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(t.key))&&void 0!==o?o:0)-(null!==(r=e.get(i.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else if("desc"===a)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else{const t=[...s].sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)}),r=[],a=[];let l=0,c=0;for(const n of t)c>l?(r.push(n),l+=null!==(i=e.get(n.key))&&void 0!==i?i:0):(a.push(n),c+=null!==(o=e.get(n.key))&&void 0!==o?o: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,i,o,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 o of e.data){const e=n(o),r=i(o);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 i of t)n+=(null===(l=h.get(i.key))||void 0===l?void 0:l.get(e))||0;f.set(e,n||1)}}const g=jt(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),p=[],y=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),i=[],a=[],l=new Map;for(const n of d){let o=t.get(n)||0;const s=m.get(n);r&&(o/=f.get(n));const c=s+o,u=e.x(n);a.push([u,e.y(s)]),i.push([u,e.y(c)]),m.set(n,c),l.set(n,c)}y.set(n.key,l);const c={type:"area",topPath:i,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),p.push(c)}return{nodes:p,stackedTops:y}}(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 i=h.get(n.key);if(i)for(const o of n.data){const n=t.getX(o),r=t.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||e.set(o,i.get(n))}}const n=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};ke(t,s,f,n)}return f}(d,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="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 i of n)t>i&&(t=i),i>e&&(e=i);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";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:l,opacity:.8},r=e.r||o;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(a&&t.getColor&&!e.fill){const i=t.getColor(n);i&&a.has(i)&&(e=Object.assign(Object.assign({},e),{fill:a.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=Lt(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(d,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),a=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),l=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Et(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,p=(f-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const l=Math.min(Math.floor((o-u)/g),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const y=c(i);v[f]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let t=0;y>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]}b>e&&(b=e),e>x&&(x=e)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/s,A=n.height/a,S=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let t=0;a>t;t++){const e=t*s;for(let n=0;s>n;n++){const i=e+n;if(0===m[i])continue;let o;switch(l){case"sum":o=v[i];break;case"mean":o=v[i]/m[i];break;default:o=m[i]}const r=(o-b)/k;_.push(zt(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:o,count:m[i],sum:v[i],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*p,agg:l},S?{value:o,showValues:!0,valueFormat:M}:void 0))}}return _}(t,e,n);if(0===e.length)return[];const i=Et(t.config.valueAccessor,"value"),o=Nt(t.config.xAccessor,"x"),r=Nt(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],i=o(n),u=r(n);l[t]=i,c[t]=u,s.has(i)||s.set(i,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)),p=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(p){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const y=new Float64Array(e.length),m=new Float64Array(e.length),v=Array(e.length),b=new Map;let x=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(l[t]),r=a.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=b.get(h);let g;void 0!==f?g=f:(g=x++,b.set(h,g)),y[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;x>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 Se?t:"blues";let n=Me.get(e);if(n)return n;n=Array(256);const i=Se[e]||Yt;for(let t=0;256>t;t++)n[t]=i(t/255);return Me.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),M=n.width/u,_=n.height/d,P=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;x>t;t++){const e=m[t];if(!isFinite(e))continue;const n=y[t],i=n%u;T.push(zt(i*M,(d-1-(n-i)/u)*_,M,_,A[Math.min((e-k)*S+.5|0,255)],v[t],P?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}(d,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=Ot(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),s=Array.from(e).filter(t=>!i.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 o.values()){const n=Math.max(e.start,l),o=Math.min(e.end,c);if(n>=o)continue;const h=a.x(n),p=a.x(o),y=Math.abs(p-h),m=y>f+1?f:0,v=Math.min(h,p)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(Ct(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=a.y(0),n=a.y(e.total);s.push(Ct(v,Math.min(t,n),b,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 p=new Set;for(const t of o.values())p.add(t.start),p.add(t.end);return{nodes:s,binBoundaries:Array.from(p).sort((t,e)=>t-e)}}(d,e);return this._barCategoryCache=null!==(l=d.barCategoryCache)&&void 0!==l?l:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,s,a;const l=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.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),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);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:o,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}(d,e);case"waterfall":return function(t,e,n){var i,o,r,s,a,l,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",p=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",y=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,b=null==h?void 0:h.opacity;let x=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=x+r;let a;a=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const l=d.x(o),c=0!==a?d.x(o+a):l+n.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const A=d.y(x),S=d.y(s),M=Math.min(A,S),_=Math.abs(A-S),P={fill:0>r?p:g,stroke:m,strokeWidth:v};null!=b&&(P.opacity=b),u.push(Ct(k,M,w,_,P,Object.assign(Object.assign({},i),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(d,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=o?a:s.upColor||"#28a745",c=o?a:s.downColor||"#dc3545",u=o?a:s.wickColor||"#333",d=s.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}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 i=t.getHigh(n),s=t.getLow(n);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const a=o?i:t.getOpen(n),h=o?s:t.getClose(n);if(!o&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=a,p={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(p.isRange=!0),r.push(p)}return r}(d,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{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?ae(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;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 i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const a=s.get(e[n]);null!=a?(i[n]=ae(t,a,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let a=!1;for(let n=0;e.length>n;n++){const i=s.get(e[n]);null!=i?(o[n]=ae(t,i,r),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=s.get(n);if(null!=e){const n=ae(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const a=ae(t,e,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o: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,i){var o,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"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 o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const a=le(t,r,s);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=le(t,o,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&&ce(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,i){var o,r,s,a;n.clear(),i.clear();for(let l=0;e.length>l;l++){const c=e[l],u=ge(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===(o=c.style)||void 0===o?void 0:o.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?i.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&&i.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 i=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],o=ge(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{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,i,o){var r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,M,_,P,O,T,$,j,L,C,z,D,E,N,R,F,W,B,I,Y,G,H;if(0===i.size&&0===o.size)return n;const X=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 q=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],$=ge(t,r,e);if(!$)continue;if(r._transitionKey=$,"line"===r.type||"area"===r.type){const t=o.get($);if(t){if(U.add($),"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]];q=!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]];q=!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}),q=!0;continue}const j=i.get($);if("point"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,j.x===t.x&&j.y===t.y&&j.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=j.x,r.y=j.y,r.r=null!==(d=j.r)&&void 0!==d?d:r.r,q=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("rect"===r.type)if(j){V.add($);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,j.x===t.x&&j.y===t.y&&j.w===t.w&&j.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=j.x,r.y=j.y,r.w=null!==(g=j.w)&&void 0!==g?g:r.w,r.h=null!==(p=j.h)&&void 0!==p?p:r.h,q=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("heatcell"===r.type)if(j){V.add($);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,j.x===t.x&&j.y===t.y&&j.w===t.w&&j.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=j.x,r.y=j.y,r.w=null!==(b=j.w)&&void 0!==b?b:r.w,r.h=null!==(x=j.h)&&void 0!==x?x:r.h,q=!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}),q=!0;else if("candlestick"===r.type)if(j&&null!=j.openY){V.add($);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,(j.x!==t.x||j.openY!==t.openY||j.closeY!==t.closeY||j.highY!==t.highY||j.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=j.x,r.openY=j.openY,r.closeY=null!==(M=j.closeY)&&void 0!==M?M:r.closeY,r.highY=null!==(_=j.highY)&&void 0!==_?_:r.highY,r.lowY=null!==(P=j.lowY)&&void 0!==P?P:r.lowY,q=!0)}else r._targetOpacity=null!==(T=null===(O=r.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0}for(const[t,e]of o)if(!U.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={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!==(j=e.opacity)&&void 0!==j?j:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}for(const[t,e]of i)if(!V.has(t)){if(t.startsWith("p:")){const i={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(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==(D=e.h)&&void 0!==D?D:0,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(N=e.w)&&void 0!==N?N:0,h:null!==(R=e.h)&&void 0!==R?R:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(W=e.openY)&&void 0!==W?W:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(B=e.closeY)&&void 0!==B?B:i,highY:null!==(I=e.highY)&&void 0!==I?I:i,lowY:null!==(Y=e.lowY)&&void 0!==Y?Y:i,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(o)}q=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),q&&(n.activeTransition={startTime:fe(),duration:X}),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,i){var o,r,s,a,l,c;if(!n.activeTransition)return!1;const u=de(t,n.activeTransition),d=ue(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?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=he(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=he(n.x,t._targetX,d),t.y=he(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=he(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=he(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=he(n.x,t._targetX,d),t.y=he(n.y,t._targetY,d),void 0!==n.w&&(t.w=he(n.w,t._targetW,d)),void 0!==n.h&&(t.h=he(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:he(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=he(n.x,t._targetX,d),t.y=he(n.y,t._targetY,d),void 0!==n.w&&(t.w=he(n.w,t._targetW,d)),void 0!==n.h&&(t.h=he(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:he(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=he(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=he(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=he(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=he(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=he(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:he(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 i=0;t.path.length>i;i++)t.path[i][0]=he(e[i][0],n[i][0],d),t.path[i][1]=he(e[i][1],n[i][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:he(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=he(e[n][0],i[n][0],d),t.topPath[n][1]=he(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=he(n[e][0],o[e][0],d),t.bottomPath[e][1]=he(n[e][1],o[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(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ie,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(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 o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;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 o=this.config.lineStyle;if("function"==typeof o){const n=o(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(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.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)||ie;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>Oe.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return 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=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=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)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)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++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(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)=>{o.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++,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}updateConfig(t){var e,n,i,o;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||!Dt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!Dt(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Et(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Et(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Et(this.config.xAccessor,"x"),this.getY=Et(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Pe(this.config)),s=!0,a=!0)}if("groupAccessor"in t&&!Dt(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Rt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!Dt(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Rt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!Dt(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Et(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!Dt(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Rt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!Dt(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Et(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in t&&!Dt(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Pe(this.config),s=!0,a=!0),"pointIdAccessor"in t&&!Dt(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Rt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!Dt(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!Dt(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!Dt(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!Dt(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Et(this.config.openAccessor,"open"):void 0,this.getHigh=Et(this.config.highAccessor,"high"),this.getLow=Et(this.config.lowAccessor,"low"),this.getClose=e?Et(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 Te(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function $e(t,e){var n,i=[],o=[],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,i,d=!1;for(o.push(t),r[t]=!0,e=0;a[t].length>e;e++)(i=a[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)l(t);else for(e=0;a[t].length>e;e++){var h=s[i=a[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.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,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,i[l]=0,o[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]=i[e]=u,o[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 p=f[g];if(0>n[p]){n[p]=i[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(i[e]=0|Math.min(i[e],i[p])),0>s[p]||a[e].push(s[p])}r[e]=g}else{if(i[e]===n[e]){var y=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(o[b]=!1,y.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===e){l.length=g;break}}d.push(y);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}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 p=1;g.length>p;p++)g[p]!==g[p-1]&&c.push(g[p]);h[l]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)r>o[s][a]&&(r=o[s][a],n=s);var l=o[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 p=0;a[g].length>p;p++){var y=a[g][p];r[+y]=!1,s[y]={}}c(n),n+=1}else n=h}return i}function je(t){return t.y0-t.y1>0?"up":"down"}function Le(t,e){return e(t.source)==e(t.target)}function Ce(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 ze(t){return t.target.x0-t.source.x1}function De(t,e){var n=Ne(t),i=ze(e)/Math.tan(n);return"up"==je(t)?t.y1-i:t.y1+i}function Ee(t,e){var n=Ne(t),i=ze(e)/Math.tan(n);return"up"==je(t)?t.y1+i:t.y1-i}function Ne(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Re(t,e){return e(t)}function Fe(t){return Be(t.source)}function We(t){return Be(t.target)}function Be(t){return(t.y0+t.y1)/2}function Ie(t){return t.virtual?0:t.value}function Ye(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Le(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Le(t,e)?i+1:i}),n+i}function Ge(t){return t.target.depth}function He(t,e){return t.sourceLinks.length?t.depth:e-1}function Xe(t,e){return t.y0-e.y0}function qe(t,e){return e.y0-t.y0}function Ve(t,e){return t.y1-e.y1}function Ue(t,e){return e.y1-t.y1}function Ze(t,e){return Ke(t.source,e.source)||t.index-e.index}function Qe(t,e){return Ke(t.target,e.target)||t.index-e.index}function Ke(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Je(t,e){return tn(t)==tn(e)?"bottom"==t.circularLinkType?qe(t,e):Xe(t,e):tn(e)-tn(t)}function tn(t){return t.target.column-t.source.column}function en(t,e){return nn(t)==nn(e)}function nn(t){return t.y0-t.y1>0?"up":"down"}function on(t,e,n,i,o){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=A(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=r.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),rn(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),rn(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+i,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,Le(t,e)&&Ce(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+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-o-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,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?qe:Xe);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Ue:Ve),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+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-o-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,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function rn(t,e,n){t.sort(Je);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Le(t,e)&&Ce(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&sn(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 sn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function an(t){return function(){return t}}function ln(t){return t.index}function cn(t){return t.nodes}function un(t){return t.links}function dn(t,e,n){var i=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var a=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Be(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Be(t.target)*e,i+=e}}),i>0?o/i:NaN);a.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=a.get(t),i=a.get(e),o=n.bc,r=i.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(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ye(e,n)-Ye(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.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==Ye(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function hn(t,e,n,i,o,r){var s=S(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,l=r;l>0;--l)c(a*=.99,n),u();function c(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Ye(o,n)>0){var l=P(o.sourceLinks,We),c=P(o.targetLinks,Fe),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Be(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=P(o.sourceLinks,We),f=P(o.targetLinks,Fe),g=((h&&f?(h+f)/2:h||f)-Be(o))*e;o.y0+=g,o.y1+=g}})})}function u(){s.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||Ke),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+i;if((s=l-i-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+o-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function fn(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Qe),t.targetLinks.sort(Ze)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function gn(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=ln,l=He,c=void 0,u=32,d=2,h=cn,f=un;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.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 O(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 i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=Te(n,i)),"object"!=typeof o&&(o=t.target=Te(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,a=r.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var l=$e(i);l.sort(function(t,e){return t.length-e.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][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++)})}(h,c),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){Re(t,e)!=Re(o.source,e)&&Re(t,e)!=Re(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Le(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(_(t.sourceLinks,Ie),_(t.targetLinks,Ie)),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)})})}(h),function(t,e,n){var i,o,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(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,l);var f=r;if(null!==s){var g=S(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=M(g,function(t){return t.length});p>1&&(f=Math.max(1,(i-e)*s/(p-1)))}(function(t,e,n){var i=S(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 o=A(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/_(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=M(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})})(h,f,o),dn(h,c,a),hn(h,c,a,f,f,u),fn(h),on(h,a,d,10,8),dn(h,c,a),hn(h,c,a,f,f,u),fn(h),on(h,a,d,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 i=n.links.filter(function(n){return Re(n.source,e)==Re(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!en(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=De(e,t);return t.y1-n}if(e.target.column>t.target.column)return De(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;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return Re(n.target,e)==Re(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!en(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Ee(e,t);return t.y0-n}if(e.source.column>t.source.column)return Ee(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;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=A(e,function(t){return t.y0}),s=M(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function l(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),n.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=l(t.y0)-t.y0;t.y0=l(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})})}}(h),on(h,a,d,10,8)}(g),g}return g.update=function(t){return fn(t),on(t,a,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:an(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:an(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:an(t),g):a},g.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:an(t),g):l},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],g):[[t,e],[n,i]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],g):[n-t,i-e]},g}function pn(t){const{sx:e,sTop:n,sBot:i,tx:o,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+i)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${o},${r}`,`L${o},${s}`,`C${l},${s} ${a},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(i-n)/2}}}Oe.GROUP_COLOR_MAP_CAP=1e3,Oe.QUADTREE_THRESHOLD=500;const yn=t=>{let e,n,i,o,r,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=j(r,s),l=a(.5),c=a(.5),`M${e},${r}C${e},${l} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${l} ${o},${r}Z`;const u=t.sankeyWidth/2,d=j(t.source.x1,t.target.x0),{pathD:h}=pn({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:d(.5),cp2X:d(.5)});return h};function mn(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=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-e))),l=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+a},${i-n}L${e+a},${i+n}L${e},${i+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}Z`}const r=o.sourceX,s=o.sourceY,a=o.targetX,l=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+i},${s-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${l-h*n+h*f}L${u-i+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+i},${l+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${s+h*n}L${r},${s+h*n}Z`}const vn=new Set,bn=new WeakMap;function xn(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=bn.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,bn.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;vn.has(t)||(vn.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,i)}});return n.set(e,i),i}const kn={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(Ge))-1:0},justify:He};function wn(t){return"string"==typeof t?t:t.id}const An={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,a,l,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=n.iterations)&&void 0!==s?s:100,y=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],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const b=gn().extent(v).links(m).nodes(y).nodeAlign(kn[h]||He).nodeId(t=>t.id).nodeWidth(f).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of y)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of m){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(null!==(l=null!==(a=i._circularWidth)&&void 0!==a?a:i.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>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,u=i[0],d=i[1];if(r>0&&s>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/s),i=-t*e+(u-r*e)/2,o=-n*e+(d-s*e)/2;for(const t of y)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of m)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,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+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,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 x=new Map;for(const e of t)x.set(e.id,e);for(const t of y){const e=x.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=wn(t.source),n=wn(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=x.get(e),r=x.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:It,y=new Map;t.forEach((t,e)=>{y.set(t.id,p[e%p.length])});const m=[],v=[],b=[],x=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 i=d?d(xn(e,"nodeStyle")):{},o={fill:i.fill||y.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};x.set(e.id,("string"==typeof o.fill?o.fill:null)||y.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";o="function"==typeof g?g(t)||o:"target"===g?x.get(i.id)||y.get(i.id)||o:x.get(e.id)||y.get(e.id)||o;const u=h?h(xn(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=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||o;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${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+i}}),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?mn(t):yn(t),!d)continue;const p={fill:u.fill||o,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:p,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,o=n.y1-n.y0;if(0>=t||0>=o)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"):(i[0]/2>n.x0+t/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+o/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},Sn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=i[0]/2,l=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=Mn(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=_n(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=_n(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=a+i*Math.cos(n),t.y=l+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=a+t*Math.cos(o),i.y=l+t*Math.sin(o)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,p=Pn(n.nodeSize,n.nodeSizeRange,t),y=t=>p(t);if(g>0){const n=L().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=C().force("charge",z().strength(t=>-25*y(t))).force("center",D(a,l).strength(.8)).force("x",E(a).strength(.15)).force("y",N(l).strength(.15));if(i.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),i.force("link",n)}h?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;g>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=y(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Pn(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:It,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const y=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(xn(e,"nodeSize")),i=d?d(xn(e,"nodeStyle")):{},a={fill:i.fill||p.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:2,opacity:i.opacity};y.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),i="object"==typeof t.target?t.target:b.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=h?h(xn(t,"edgeStyle")):{},r={stroke:o.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=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(x=n.nodeLabel)?"function"==typeof x?x:t=>t[x]||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 i=f(xn(n,"nodeSize"));v.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}};function Mn(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.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||i.push({x:t.x,y:t.y})}}return i}function _n(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 Pn(t,e,n){var i,o;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=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>r[0];const a=null!==(i=A(s))&&void 0!==i?i:0,l=null!==(o=M(s))&&void 0!==o?o:1;if(a===l)return()=>(r[0]+r[1])/2;const c=v().domain([a,l]).range(r).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?r[0]:c(i)}}const On=It,Tn={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,l=a-r,c=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);p[n][i]=o}const y=F().padAngle(o);s&&y.sortGroups(s);const m=y(p),v=m.groups,b=W().innerRadius(l).outerRadius(a);for(const e of v){const n=t[e.index],i=b.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+c,n.y=i[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=x.get("string"==typeof t.source?t.source:t.source.id),i=x.get(e);n&&(t.source=n),i&&(t.target=i)}const k=new Map;for(const t of e)k.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 n=t[e.source.index].id,i=t[e.target.index].id,o=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,i){var o,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-l,h=i[0]/2,f=i[1]/2,g=n.nodeStyle,p=n.edgeStyle,y=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:On,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const b=R().radius(d),x=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let r;r=g?g(xn(n,"nodeStyle")).fill||v.get(n.id)||m[e%m.length]:v.get(n.id)||m[e%m.length];const s=g?g(xn(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.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 i=b(e);if(!i)continue;const o=$n(i,h,f);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(xn(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?l=v.get(n.id)||l:e&&(l=v.get(e.id)||l)}const u=p?p(xn(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,i=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;w.push({x:h+Math.cos(s)*i,y:f+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:x,sceneEdges:k,labels:w}}};function $n(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const jn=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ln(t){const[e,n,i]=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*i>150?"#222":"#fff"}function Cn(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function zn(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Dn(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:jn}function En(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 Nn(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const Rn={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;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,u=tt(r,a);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,h]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=st();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=rt();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=it().size([n,i]).tile(ot).padding(s);a>0&&l.paddingTop(a),l(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;nt().size([n,i]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,i){var o;et().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:Cn(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Fn(r,i,n):"treemap"===s||"partition"===s?Wn(r,i):"circlepack"===s&&Bn(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const n=g.get(t.parent),i=g.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,a,l,c,u,d,h,f;const g=[],p=[],y=[],m=n.treeOrientation||"vertical",v="radial"===m,b=i[0]/2,x=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;v&&(t+=b,i+=x);const r=o(xn(e,"nodeStyle"));let l=r.fill||En(n);if(n.colorByDepth&&void 0!==e.depth){const t=Dn(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:i,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,a=i.x,l=i.y;v&&(o+=b,s+=x,a+=b,l+=x);const f=Nn(o,s,a,l,m),g=r(xn(t,"edgeStyle")),y={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};p.push({type:"curved",pathD:f,style:y,datum:t})}if(!1!==n.showLabels){const e=zn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,a=n.y;if(v&&(s+=b,a+=x),v){const t=s-b,e=a-x,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=a+e/n*10,r=0>t?"end":"start"):(i=s,o=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=s-k-6,r="end"):(i=s+k+6,r="start"),o=a):(i=s,o=a+k+14,r="middle");y.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:p,labels:y}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,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=i(xn(n,"nodeStyle"));let l=a.fill||En(e);if(e.colorByDepth&&void 0!==n.depth){const t=Dn(e);l=t[n.depth%t.length]}const u={fill:l,stroke:a.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.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=zn(e.nodeLabel),o=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"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(xn(c,"nodeStyle")).fill||En(e);if(e.colorByDepth&&void 0!==c.depth){const t=Dn(e);g=t[c.depth%t.length]}const p="string"==typeof g?Ln(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:p}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,a,l,c,u,d,h,f;const g=[],p=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const l=i(xn(n,"nodeStyle"));let c=l.fill||En(e);if(e.colorByDepth&&void 0!==n.depth){const t=Dn(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=zn(e.nodeLabel);for(const o of t){const t=null!==(l=o.__radius)&&void 0!==l?l:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let a=i(xn(o,"nodeStyle")).fill||En(e);if(e.colorByDepth&&void 0!==o.depth){const t=Dn(e);a=t[o.depth%t.length]}if(s){const n="string"==typeof a?Ln(a):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";p.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else p.push({x:o.x,y:o.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:p}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Fn(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 Wn(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 Bn(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n: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}function In(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const Yn={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),l=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),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=In(n);g.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function y(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 m=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,x=y(l(t));i.push({id:x,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(x,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,u,d,p){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let b=0,x=0,k=0;for(;v>x;)x+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let v=0;b>v;v++){const x=c[Math.min(v,c.length-1)],k=m.slice(w,w+x);if(!k.length)break;const A=(v+1)/b,S={id:n,depth:d,data:e,parentId:n},M=p?u/h(S)*A:u*A,_=B().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(k),O=f(S);for(let e=0;k.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=y(l(c)),h=r+M*Math.sin(a),f=s+M*Math.cos(a)*O;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:M,angle:a,depth:d,parentId:n,eccentricity:O}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,M,d+1,!0)}w+=x}}(t,x,m,v,b,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],p=[],y=[];if(!1!==n.orbitShowRings){const e=In(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.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:i}]of o)for(let o=0;r>o;o++){const a=o/r*Math.PI*2,l=(o+1)/r*Math.PI*2;p.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*i,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(xn(e,"nodeSize")),i=d?d(xn(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=i.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&&p.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(xn(n,"nodeSize"));if(4>=t)continue;const i="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;y.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:p,labels:y}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=In(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i: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())-o.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=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=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(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Gn={sankey:An,force:Sn,chord:Tn,tree:Rn,cluster:Rn,treemap:Rn,circlepack:Rn,partition:Rn,orbit:Yn};function Hn(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=ee[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function Xn(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(i)%t.length])&&void 0!==n?n:"#4e79a7"}}function qn(t,e){var n;const{columns:i,config:o,resolvePieceStyle:r}=t,s=[],a=Math.min(e.width,e.height)/2-4,l="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,u=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,d=null!=o.sweepAngle&&360>o.sweepAngle,h=Object.values(i),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=o.cornerRadius)&&void 0!==n?n:0)>0;for(let t=0;h.length>t;t++){const e=h[t],n=e.pieceData[0],i="number"==typeof(null==n?void 0:n._pctStart)?n._pctStart:e.pctStart,d=c+i*u,f=c+(i+("number"==typeof(null==n?void 0:n._pct)?n._pct:e.pct))*u,p=r(e.pieceData[0],e.name),y=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},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:p,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:y,end:m}),(null==n?void 0:n._gradientBand)&&(v._gradientBand=n._gradientBand),s.push(v)}return s}function Vn(t){var e,n,i;const o=t.length,r=t[0],s=t[o-1];return{n:o,min:r,q1:null!==(e=T(t,.25))&&void 0!==e?e:r,median:null!==(n=T(t,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(i=T(t,.75))&&void 0!==i?i:s,max:s,mean:t.reduce((t,e)=>t+e,0)/o}}const Un={bar:function(t,e){var n,i,o;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,p="horizontal"===h,y=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 i=e.get(t);i.total+=l(n),i.pieces.push(n)}let n=0;if(y)for(const t of e.values())n+=Math.abs(t.total);let i=0,o=0;for(const r of m){const s=e.get(r);if(!s)continue;let a=s.total;y&&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?o:i+a),n=0>a?d(o+a)-d(o):d(i)-d(i+a);f.push(Ct(t.x,e,t.width,Math.abs(n),l,h,r)),0>a?o+=a:i+=a}else if(p){const e=d(0>a?o+a:i),n=0>a?d(o)-d(o+a):d(i+a)-d(i);f.push(Ct(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?o+=a:i+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==i?i:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(b>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const n=(null===(o=e.datum)||void 0===o?void 0:o.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=b),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=b)}}return f},clusterbar:function(t,e){const{scales:n,columns:i,config:o,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(i))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(i)){const e=t.width/g,n=.2*e,i=e-n,o=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";o.has(t)||o.set(t,[]),o.get(t).push(e)}for(let s=0;h.length>s;s++){const c=o.get(h[s])||[];for(const o of c){const c=r(o),f=a(o,h[s]);if(d){const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(Ct(r,Math.min(a,d),i,Math.abs(a-d),f,o,h[s]))}else{const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(Ct(Math.min(a,d),r,Math.abs(d-a),i,f,o,h[s]))}}}}const p=o.roundedTop&&o.roundedTop>0?Math.max(0,o.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);p>0&&(t.roundedTop=p),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",o.gradientFill&&(t.fillGradient=o.gradientFill)}return u},point:function(t,e){var n,i;const{scales:o,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=t,{r:c,projection:u}=o,d=[],h="vertical"===u,f="radial"===u,g=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(r))for(const e of t.pieceData){const o=null!==(n=e.__rIndex)&&void 0!==n?n:0,r=null!==(i=e.__rValue)&&void 0!==i?i:s(e),u=g&&a[o]||c,m=l(e,t.name),v=m.r||5;let b,x;if(f){const e=y+(t.pctStart+t.pct/2)*p,n=u(r);b=Math.cos(e)*n,x=Math.sin(e)*n}else h?(b=t.middle,x=u(r)):(b=u(r),x=t.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:e})}return d},swarm:function(t,e){const{scales:n,columns:i,getR:o,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a;for(const t of Object.values(i)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const i=t.pieceData[n],a=o(i),u=r(i,t.name),d=u.r||4,h=(7919*n%100/100-.5)*e*.8,f=c?t.middle+h:s(a),g=c?s(a):t.middle+h;l.push({type:"point",x:f,y:g,r:d,style:u,datum:i})}}return l},pie:qn,donut:qn,boxplot:function(t,e){var n,i,o,r,s,a;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=t,{r:f,projection:g}=l,p=[],y="vertical"===g,m=!1!==u.showOutliers;for(const e of Object.values(c)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const c=l[0],u=l[l.length-1],g=null!==(n=T(l,.25))&&void 0!==n?n:c,v=null!==(i=T(l,.5))&&void 0!==i?i:(c+u)/2,b=null!==(o=T(l,.75))&&void 0!==o?o:u,x=b-g,k=g-1.5*x,w=b+1.5*x,A=null!==(r=l.find(t=>t>=k))&&void 0!==r?r:c,S=null!==(s=[...l].reverse().find(t=>w>=t))&&void 0!==s?s:u,M=h(e.pieceData[0],e.name),_=[];if(m)for(const t of e.pieceData){const n=d(t);if(k>n||n>w){const i=y?e.middle:f(n),o=y?f(n):e.middle;_.push({px:i,py:o,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(A),q1Pos:f(g),medianPos:f(v),q3Pos:f(b),maxPos:f(S),stats:{n:l.length,min:A,q1:g,median:v,q3:b,max:S,mean:l.reduce((t,e)=>t+e,0)/l.length},style:M,datum:e.pieceData,category:e.name,outliers:_}),m)for(const e of _)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:M.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var n,i,o;const{scales:r,columns:s,config:a,getR:l,resolveSummaryStyle:c}=t,{r:u,projection:d}=r,h=[],f="vertical"===d,g=a.bins||20,p=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],s=e[e.length-1],a=(s-r)/g||1,d=Array(g).fill(0);for(const t of e)d[Math.min(Math.floor((t-r)/a),g-1)]++;const y=Math.max(...d,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${u(r)}`;for(let e=0;g>e;e++){const n=u(r+(e+.5)*a);v+=` L ${t.middle+d[e]/y*m} ${n}`}v+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const n=u(r+(e+.5)*a);v+=` L ${t.middle-d[e]/y*m} ${n}`}v+=" Z"}else{v=`M ${u(r)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${u(r+(e+.5)*a)} ${t.middle-d[e]/y*m}`;v+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${u(r+(e+.5)*a)} ${t.middle+d[e]/y*m}`;v+=" Z"}const b=c(t.pieceData[0],t.name);let x;if(p&&e.length>=4){const a=null!==(n=T(e,.25))&&void 0!==n?n:r,l=null!==(i=T(e,.5))&&void 0!==i?i:(r+s)/2,c=null!==(o=T(e,.75))&&void 0!==o?o:s;x={q1Pos:u(a),medianPos:u(l),q3Pos:u(c),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(u(s),u(r)),width:t.width,height:Math.abs(u(s)-u(r))}:{x:Math.min(u(r),u(s)),y:t.x,width:Math.abs(u(s)-u(r)),height:t.width};h.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:x,stats:Vn(e),style:b,datum:t.pieceData,category:t.name})}return h},histogram:function(t,e){var n;const{scales:i,columns:o,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l}=i,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(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const n=null!=f&&isFinite(f)?f:Math.min(...e),i=null!=g&&isFinite(g)?g:Math.max(...e),o=(i-n)/u||1,r=Array(u).fill(0);for(const t of e)n>t||t>i||r[Math.min(Math.floor((t-n)/o),u-1)]++;const h=e.length,p=Math.max(...r,1),y=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===r[e])continue;const i=(d?r[e]/h:r[e]/p)*t.width*.9,s=l(n+e*o),a=l(n+(e+1)*o);c.push(Ct(Math.min(s,a),t.x+t.width-i,Math.abs(a-s),i,y,{bin:e,count:r[e],range:[n+e*o,n+(e+1)*o],category:t.name},t.name))}}return c},ridgeline:function(t,e){var n;const{scales:i,columns:o,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l,projection:c}=i,u=[],d=r.bins||20,h="horizontal"===c,f=r.amplitude||1.5;for(const t of Object.values(o)){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 i=e[0],o=e[e.length-1],r=(o-i)/d||1,c=Array(d).fill(0);for(const t of e)i>t||t>o||c[Math.min(Math.floor((t-i)/r),d-1)]++;const g=Math.max(...c,1),p=a(t.pieceData[0],t.name),y=t.width*f;let m="";if(h){const e=t.x+t.width;m=`M ${l(i)} ${e}`;for(let t=0;d>t;t++)m+=` L ${l(i+(t+.5)*r)} ${e-c[t]/g*y}`;m+=` L ${l(o)} ${e} Z`}else{const e=t.x;m=`M ${e} ${l(i)}`;for(let t=0;d>t;t++){const n=l(i+(t+.5)*r);m+=` L ${e+c[t]/g*y} ${n}`}m+=` L ${e} ${l(o)} Z`}const v=h?{x:Math.min(l(i),l(o)),y:t.x,width:Math.abs(l(o)-l(i)),height:t.width}:{x:t.x,y:Math.min(l(o),l(i)),width:t.width,height:Math.abs(l(o)-l(i))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:Vn(e),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:n,columns:i,getRawRange:o,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(i))for(const e of t.pieceData){const n=o(e);if(!n)continue;const[i,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(i,a)),o=s(Math.max(i,a));l.push(Ct(n,t.x,o-n,t.width,u,e,t.name))}else{const n=s(Math.max(i,a)),o=s(Math.min(i,a));l.push(Ct(t.x,n,t.width,o-n,u,e,t.name))}}return l},funnel:function(t,e){var n,i,o,r,s,a,l,c;const{columns:u,getR:d,getStack:h,resolvePieceStyle:f}=t,g=[],p=e.width/2,y=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const b=[],x=new Set;for(const t of m)for(const e of t.pieceData){const t=h?h(e):"_default";x.has(t)||(x.add(t),b.push(t))}const k=b.length>1&&"_default"!==b[0],w=[];let A=0;for(const t of m){const e=new Map;let n=0;for(const i of t.pieceData){const t=h?h(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),r=d(i);o.total+=r,o.pieces.push(i),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 i=0;b.length>i;i++){const o=t.groups.get(b[i]);o&&(i%2==0?e+=o.total:n+=o.total)}const i=Math.max(e,n);i>A&&(A=i)}if(0===A)return g;const S=new Map;for(const t of b){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const M=w[0].stepTotal,_=k?.95*p:.9*e.width,P=v().domain([0,A]).range([0,_]),O=null!==(i=t.config.connectorOpacity)&&void 0!==i?i:.3;let T=new Map;for(let e=0;w.length>e;e++){const n=w[e],i=n.col,u=0===e,d=i.width,h=.55*d,m=i.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of b){const i=n.groups.get(e);i&&(t+=P(i.total))}let e=p,o=p;for(let r=0;b.length>r;r++){const a=b[r],l=n.groups.get(a);if(!l)continue;const c=P(l.total),d=r%2==0,x=d?e:o-c;d?e+=c:o-=c;const k=f(l.pieces[0],a),w=null!==(s=S.get(a))&&void 0!==s?s:l.total,A=w>0?l.total/w*100:0,M=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:A,__funnelStep:i.name,__funnelIsFirstStep:u,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:a});y&&(0===r&&(M.__funnelStepLabel=i.name,M.__funnelStepLabelX=p,M.__funnelStepLabelY=m,M.__funnelRowWidth=t),M.__funnelValueLabelX=x+c/2,M.__funnelValueLabelY=m,M.__funnelBarW=c),g.push(Ct(x,m,c,h,k,M,a)),v.set(a,{x:x,y:m,w:c,h:h})}}else{const t=n.stepTotal,e=P(t),s=p-e/2,a=b[0],l="_default"!==a,c=null!==(r=null===(o=n.groups.get(a))||void 0===o?void 0:o.pieces[0])&&void 0!==r?r:i.pieceData[0],d=l?a:i.name,x=f(c,d),k=M>0?t/M*100:0,w=Object.assign(Object.assign({},c),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:u,category:l?a:i.name});y&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=m,w.__funnelRowWidth=e,w.__funnelValueLabelX=p,w.__funnelValueLabelY=m,w.__funnelBarW=e),g.push(Ct(s,m,e,h,x,w,d)),v.set(a,{x:s,y:m,w:e,h:h})}if(e>0&&T.size>0){const e=k?b:[b[0]];for(const o of e){const e=T.get(o),r=v.get(o);if(!e||!r)continue;const s=(()=>{const t=n.groups.get(o);return f(t?t.pieces[0]:i.pieceData[0],"_default"===o?i.name:o)})(),u={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===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:O},datum:null!==(c=null===(l=n.groups.get(o))||void 0===l?void 0:l.pieces[0])&&void 0!==c?c:i.pieceData[0],category:"_default"===o?i.name:o};g.push(u)}}T=v}return g},"bar-funnel":function(t,e){var n,i,o,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 p=f.length>1&&"_default"!==f[0],y=[];for(const t of h){const e=new Map;let n=0;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),r=a(i);o.total+=r,o.pieces.push(i),n+=r}y.push({col:t,groups:e,stepTotal:n})}const m=new Map;for(const t of f){const e=null===(n=y[0])||void 0===n?void 0:n.groups.get(t);m.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const v=u.r,b=p?f.length:1,x=p?.15:0;for(let t=0;y.length>t;t++){const e=y[t],n=e.col,i=0===t,s=t>0?y[t-1]:null,a=n.width/b,l=a*x,u=a-l;for(let t=0;f.length>t;t++){const h=f[t],g=e.groups.get(h);if(!g)continue;const y=g.total,b=null!==(o=m.get(h))&&void 0!==o?o:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,A=i?0:Math.max(0,w-y),S=n.x+t*a+l/2,M=v(y),_=v(0)-M,P=c(g.pieces[0],p?h:n.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(y+A)});if(d.push(Ct(S,M,u,_,P,O,p?h:n.name)),A>0){const t=v(y+A),e=M-t,i=Object.assign({},P),o=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(Ct(S,t,u,e,i,o,p?h:n.name))}}}return d},swimlane:function(t,e){var n;const{scales:i,columns:o,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=i,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,[i,r]=l.range(),s=Math.min(i,r),a=Math.abs(r-i);for(const n of Object.values(o)){const i={fill:t,opacity:e},o=d?Ct(s,n.x,a,n.width,i,null,"__track__"):Ct(n.x,s,n.width,a,i,null,"__track__");u.push(o)}}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 n=u.length;for(const n of t.pieceData){const i=Math.abs(r(n));if(0===i)continue;const o=s?s(n):t.name,c=a(n,o);let g;if(d){const r=l(e),s=l(e+i);g=Ct(r,t.x,s-r,t.width,c,n,o)}else{const r=l(e+i),s=l(e);g=Ct(t.x,r,t.width,s-r,c,n,o)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),e+=i}if(p>0&&u.length>n){const t=u.slice(n),e=t[0],i=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:d?(e.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return u}};class Zn{constructor(t){this.rExtent=new Pt,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.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 _t(t.windowSize),this.getO=Rt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>Et(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Pt)):(this.getR=Et(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Rt(t.stackBy),this.getGroup=Rt(t.groupBy),this.getColor=Rt(t.colorAccessor),this.getConnector=Rt(t.connectorAccessor),this.getDataId=Rt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new _t(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(),o=e.projection||"vertical",r=e.oExtent||this.resolveCategories(i),s=this.computeValueDomain(i,r),a="horizontal"===o,l="radial"===o,c=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===o?t.width:t.height):.1));let u,d;if(l){u=k().domain(r).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,i=e.innerRadius||0;d=v().domain(s).range([i,n])}else a?(u=k().domain(r).range([0,t.height]).padding(c),d=v().domain(s).range([0,t.width])):(u=k().domain(r).range([0,t.width]).padding(c),d=v().domain(s).range([t.height,0]));this.scales={o:u,r:d,projection:o},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((i,o)=>{var r;const s=this.rExtents[o];s.dirty&&s.recalculate(n,i);let[l,c]=s.extent;l===1/0&&(l=0,c=1);const u=null!==(r=e.extentPadding)&&void 0!==r?r:.05,d=c-l,h=d>0?d*u:1;return l-=h,c+=h,l>0&&(l=0),a?v().domain([l,c]).range([0,t.width]):v().domain([l,c]).range([t.height,0])}):[];let h=i;this.rAccessors.length>1&&(h=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(h,r,u,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,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,i="auto"===e?void 0:e;let o=null;if(n){o=new Set;for(const e of t)o.add(this.getO(e))}const r=o?Array.from(this.categories).filter(t=>o.has(t)):Array.from(this.categories);if(n&&void 0===i){const t=Math.max(50,3*o.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;o.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===i)return r;if("function"==typeof i)return r.sort(i);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"===i?(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,i,o,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 i of t){const t=this.getO(i),o=this.getR(i);0>o?n.set(t,(n.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}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),i=this.getR(n);e.set(t,(e.get(t)||0)+i)}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),i=Math.abs(this.getR(n));e.set(t,(e.get(t)||0)+i)}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===(i=this.config.rExtent)||void 0===i?void 0:i[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[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,i,o){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"===i)for(const e of t)l+=Math.abs(this.getR(e));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==i){u=new Map;let t=0;for(const n of e){const e=a.get(n)||[];let i;i="string"==typeof c?e.reduce((t,e)=>t+(Number(e[c])||0),0):c(e),u.set(n,i),t+=i}const r=("horizontal"===i?o.height:o.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)||[],i=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),o=l>0?i/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:o,pctStart:d},d+=o}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,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,i;if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(t,e);let r;try{r=this.config.customLayout(o)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(n=r.overlays)&&void 0!==n?n:null,null!==(i=r.nodes)&&void 0!==i?i:[]}this.customLayoutOverlays=null;const o=this.getSceneContext(),r=Un[this.config.chartType];let s=r?r(o,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var n,i;const{scales:o,config:r,getConnector:s,getO:a}=t;if(!s||!o)return[];const l=[],{projection:c}=o,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 i,o;"point"===t.type?(i=t.x,o=t.y):(i=t.x+t.w/2,o=t.y+("vertical"===c?0:t.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:i,y:o,datum:e,category:a(e)})}const d=o.o.domain(),h=r.connectorStyle;for(const[e,o]of u)if(o.length>=2){o.sort((t,e)=>d.indexOf(t.category)-d.indexOf(e.category));for(let r=0;o.length-1>r;r++){const s=o[r],a=o[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.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}(o,s);s=[...t,...s]}return s}buildLayoutContext(t,e){var n,i,o;const r=this.config,s=null!==(n=r.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},a=Hn(r.colorScheme,r.themeCategorical,ie),l=this.scales;return{data:t,scales:{o:l.o,r:l.r,projection:l.projection},dimensions:{width:e.width,height:e.height,margin:s,plot:"radial"===l.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!==(i=r.themeSemantic)&&void 0!==i?i:{},categorical:[...a]},resolveColor:Xn(a),config:null!==(o=r.layoutConfig)&&void 0!==o?o:{}}}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||ie,i=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,i),i}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?ae(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,i=n?null:e||"category",o=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[i];let l=o.get(a);l||(l=[],o.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:o},o}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,Zn.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const n=Array(t);let i=0;for(const t of this.scene)"point"===t.type&&(n[i++]=t);this._pointQuadtree=w().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,i;if(!this.config.decay)return;const o=e.length;if(1>=o)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,o),a=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var n,i,o;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!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o: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 i=u.get(t);if(!i)continue;let o=0;for(let t=0;i.length>t;t++){const e=this.timestampBuffer.get(i[t]);if(null==e)continue;const n=r-e;if(s>n){const t=1-n/s;t>o&&(o=t)}}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const o=r-i;s>o&&(n._pulseIntensity=1-o/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,i=this.timestampBuffer.peek();return null!=i&&n>e-i}synthesizeIntroPositions(){var t,e,n,i,o;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!==(i=e.style.opacity)&&void 0!==i?i:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(o=e.style.opacity)&&void 0!==o?o: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,i,o;if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,i=e.get(n)||0;return e.set(n,i+1),`${n}:${i}`}return"rect"===t.type?`r:${t.group||""}:${null!==(i=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==i?i:""}`:"wedge"===t.type?"w:"+(null!==(o=t.category)&&void 0!==o?o:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let n=0;this.scene.length>n;n++){const i=this.scene[n],o=this.getNodeKey(i,e);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:null!==(t=i.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,n,i,o,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x;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!==(i=c.style.opacity)&&void 0!==i?i: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!==(o=d.w)&&void 0!==o?o: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!==(p=e.endAngle)&&void 0!==p?p:0))/2,i={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(y=e.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(b=e.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,category:t.slice(2),_targetStartAngle:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(i)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:fe(),duration:k})}advanceTransition(t){var e,n,i,o;if(!this.activeTransition)return!1;const r=de(t,this.activeTransition),s=ue(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 i=this.prevPositionMap.get(e),o=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=he(o,t._targetOpacity,s)}const i=this.prevPositionMap.get(e);void 0!==t._targetX&&i&&(t.x=he(i.x,t._targetX,s),t.y=he(i.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==i?void 0:i.r)&&(t.r=he(i.r,t._targetR,s))}else if("rect"===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.opacity=he(o,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=he(n.x,t._targetX,s),t.y=he(n.y,t._targetY,s),void 0!==n.w&&(t.w=he(n.w,t._targetW,s),t.h=he(n.h,t._targetH,s))}else if("wedge"===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=Object.assign(Object.assign({},t.style),{opacity:he(i,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=he(n.startAngle,t._targetStartAngle,s),t.endAngle=he(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,i=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)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,o}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(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)),o.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,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}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&&!Dt(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!Dt(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!Dt(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(Dt(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=Rt(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const n=t.valueAccessor||t.rAccessor,i=e.valueAccessor||e.rAccessor,o=Array.isArray(n)?n:[n],r=Array.isArray(i)?i:[i];if(o.length!==r.length||o.some((t,e)=>!Dt(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>Et(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Pt)):(this.getR=Et(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!Dt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?Rt(this.config.stackBy):void 0),"groupBy"in t&&!Dt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?Rt(this.config.groupBy):void 0),"colorAccessor"in t&&!Dt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Rt(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!Dt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Rt(this.config.connectorAccessor):void 0)}}Zn.QUADTREE_THRESHOLD=500;const Qn={mercator:mt,equalEarth:ht,albersUsa:yt,orthographic:pt,naturalEarth:gt,equirectangular:ft};function Kn(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Jn(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ti(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function ei(t,e){if(2>t.length)return[t];const n=.4*e,i=[];let o=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>o.length||i.push(o),o=[r]):o.push(r)}return 2>o.length||i.push(o),i}function ni(t,e,n=24){const i=e[0]-t[0],o=e[1]-t[1],r=Math.sqrt(i*i+o*o);if(0===r)return[t,e];const s=-o/r,a=i/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 i=0;n>=i;i++){const o=i/n,r=1-o;d.push([r*r*t[0]+2*r*o*c+o*o*e[0],r*r*t[1]+2*r*o*u+o*o*e[1]])}return d}function ii(t,e){if(2>t.length)return t;const n=e/2+1,i=[];for(let e=0;t.length>e;e++){const o=t[e];let r,s;0===e?(r=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(r=o[0]-t[e-1][0],s=o[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;i.push([o[0]+s/a*n,o[1]+-r/a*n])}return i}function oi(t,e,n,i,o){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=o/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}class ri{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 _t(t),this.timestampBuffer=new _t(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],i=new Set(Array.isArray(t)?t:[t]),o=[];return this.lineData=this.lineData.filter(t=>!i.has(n(t)+"")||(o.push(t),!1)),o.length>0&&this.version++,o}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],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(n(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((e,i)=>{t(e)&&n.add(i)}),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=>!i.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 ht();if("string"==typeof t){const e=Qn[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),ht())}if("object"==typeof t&&"type"in t){const e=Qn[t.type],n=e?e():ht();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=lt(this.projection),this.fitProjection(t),this.geoPath=lt(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 i=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,i=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&i.length>0&&this.startTransition(i),this.version++}fitProjection(t){var e,n,i,o,r;const s=this.projection,a=this.config,l=[...this.areas],c=Kn(a.xAccessor,"lon"),u=Kn(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=Jn(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],[i,o]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,n],[i,n],[i,o],[e,o],[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,i=Math.min(t.width,t.height);s.scale(i/2-i*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,n=t.width*e,o=t.height*e;s.fitExtent([[n,o],[t.width-n,t.height-o]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(r=null===(o=s.rotate)||void 0===o?void 0:o.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=lt(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=lt(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=lt(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,ri.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const n=Array(e);let i=0;for(const t of this.scene)"point"===t.type&&(n[i++]=t);this._quadtree=w().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,i;const o=[],{config:r}=this,s=this.projection,a=this.geoPath,l=Kn(r.xAccessor,"lon"),c=Kn(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),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),h=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=ct();e.step&&n.step(e.step);const i=a(n())||"";i&&o.push({type:"geoarea",pathData:i,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),i=a.bounds(t),s=a.area(t),l=ti(r.areaStyle,t,u);o.push({type:"geoarea",pathData:e,centroid:n,bounds:i,screenArea:s,style:l,datum:t,interactive:!0})}const f=Jn(r.lineDataAccessor);for(const e of this.lineData){const n=f(e);if(!n||2>n.length)continue;let i=[];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],o=t[e+1],r=ut(n,o)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=dt(n,o);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const n=s(l(t/a));null!=n&&i.push(n)}}}else for(let t=0;n.length>t;t++){const e=n[t],o=s([l(e),c(e)]);null!=o&&i.push(o)}if(2>i.length)continue;const a=ti(r.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==n.length||2>i.length||"arc"!==r.flowStyle?2!==n.length||2>i.length||"offset"!==r.flowStyle||(i="geo"===r.lineType?ii(i,u):oi(i[0],i[i.length-1],0,0,u)):i=ni(i[0],i[i.length-1]);const h=ei(i,t.width);if(h.length>1)for(const t of h){if(2>t.length)continue;const n={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};o.push(n)}else o.push({type:"line",path:2>i.length&&h[0]||i,style:a,datum:e})}const g=this.getPoints(),p=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,y=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=y>0?y*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],x=[(null!==(n=b[0])&&void 0!==n?n:0)-v[0],(null!==(i=b[1])&&void 0!==i?i:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],n=l(e),i=c(e);if(null!=m&&ut([n,i],x)>m)continue;const a=s([n,i]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},h),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};o.push(d)}return o}applyCartogramTransform(t,e){var n,i,o;const r=this.scene.filter(t=>"point"===t.type);if(2>r.length)return;const s=null!==(n=t.strength)&&void 0!==n?n:1;if(0===s)return;const a=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&a(e.datum)+""==t.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=c.x,d=c.y,h=r.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),f=Math.max(...h,1),g=Math.min(e.width,e.height)/2,p=v().domain([0,f]).range([0,g]);this.cartogramLayout={cx:u,cy:d,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 r){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-u),n=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),i=l(t.datum),o=n+((isFinite(i)?p(i):n)-n)*s;t.x=u+Math.cos(e)*o,t.y=d+Math.sin(e)*o}const y=e.width/2,m=e.height/2,b=y-c.x,x=m-c.y;if(Math.abs(b)>.5||Math.abs(x)>.5)for(const t of r)t.x+=b,t.y+=x;this.cartogramLayout={cx:y,cy:m,maxCost:f,availableRadius:g};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of r)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const n=null===(i=e.datum)||void 0===i?void 0:i.source,r=null===(o=e.datum)||void 0===o?void 0:o.target;if(n&&r){const i=t.get(n+""),o=t.get(r+"");i&&o&&(e.path=[i,o])}}}}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 i=0;n.length>i;i++){const o=ae(t,i,e);n[i]._decayOpacity=o,n[i].style=Object.assign(Object.assign({},n[i].style),{opacity:o})}}applyPulse(){var t;const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const n=performance.now(),i=this.scene.filter(t=>"point"===t.type),o=this.timestampBuffer.toArray();for(let r=0;i.length>r&&o.length>r;r++){const s=le(e,o[r],n);s>0&&(i[r]._pulseIntensity=s,i[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",i[r]._pulseGlowRadius=null!==(t=e.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var t;return ce(null!==(t=this.config.pulse)&&void 0!==t?t:{},this.timestampBuffer)}startTransition(t){var e,n,i,o;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!==(o=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o: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=de(t,this.activeTransition),n=ue(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=he(t.x,t._targetX,n),t.y=he(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 i)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 si(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function ai(t){if(!t||2>t.length)return;const e=si(t[0]),n=si(t[t.length-1]);return null!==e&&null!==n?[e,n]:void 0}function li(t){var e;const{count:n,byType:i}=function(t){var e;const n={};for(const i of t){const t="string"==typeof(null==i?void 0:i.type)&&i.type.length>0?i.type:"node";n[t]=(null!==(e=n[t])&&void 0!==e?e:0)+1}return{count:t.length,byType:n}}(t.marks),o=0===n,r=[...null!==(e=t.extraWarnings)&&void 0!==e?e:[]];o&&!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:o?"empty":"ok",empty:o,markCount:n,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:s,ariaLabel:a,warnings:r})}function ci(t){var e,n,i,o;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(i=t.br)&&void 0!==i?i:0)>0||(null!==(o=t.bl)&&void 0!==o?o:0)>0}function ui(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,i=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:i(e.tl),tr:i(e.tr),br:i(e.br),bl:i(e.bl)}}ri.QUADTREE_THRESHOLD=500;const di=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function hi(t){var e,n;const{innerRadius:i,outerRadius:o,startAngle:r,endAngle:s}=t,a=0>=i;if(0>=(null!==(e=t.cornerRadius)&&void 0!==e?e:0)||!t.roundStart&&!t.roundEnd){if(a){const t=di(o,r),e=di(o,s);return`M0,0 L${t.x},${t.y} A${o},${o} 0 ${s-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=di(o,r),e=di(o,s),n=di(i,s),l=di(i,r),c=s-r>Math.PI?1:0;return`M${t.x},${t.y} A${o},${o} 0 ${c} 1 ${e.x},${e.y} L${n.x},${n.y} A${i},${i} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=t.cornerRadius)&&void 0!==n?n:0,(o-i)/2));if(0===l)return hi(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,o-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,i+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 hi(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const p=r+(f?c:0),y=s-(g?c:0),m=r+(f?u:0),v=s-(g?u:0),b=di(o,p),x=di(o,y),k=(o-l)*Math.cos(c),w=di(k,r),A=di(k,s),S=a?null:di(i,v),M=a?null:di(i,m),_=a?0:(i+l)*Math.cos(u),P=a?null:di(_,r),O=a?null:di(_,s),T=y-p>Math.PI?1:0,$=a?0:v-m>Math.PI?1:0;let j="";if(f)j+=`M${w.x},${w.y}`,j+=` A${l},${l} 0 0 1 ${b.x},${b.y}`;else{const t=di(o,r);j+=`M${t.x},${t.y}`}if(g)j+=` A${o},${o} 0 ${T} 1 ${x.x},${x.y}`,j+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const t=di(o,s);j+=` A${o},${o} 0 ${T} 1 ${t.x},${t.y}`}if(a)j+=" L0,0";else{if(g)j+=` L${O.x},${O.y}`,j+=` A${l},${l} 0 0 1 ${S.x},${S.y}`;else{const t=di(i,s);j+=` L${t.x},${t.y}`}if(f)j+=` A${i},${i} 0 ${$} 0 ${M.x},${M.y}`,j+=` A${l},${l} 0 0 1 ${P.x},${P.y}`;else{const t=di(i,r);j+=` A${i},${i} 0 ${$} 0 ${t.x},${t.y}`}}return j+=" Z",j}const fi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function gi(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function pi(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function yi(n,i,o){var r,s,a,l,c;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const o="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:o,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+i)}case"area":{const c=n;if(0===c.topPath.length)return null;const u=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const n=`${o?o+"-":""}area-clip-${i}`;return e("g",{children:[t("defs",{children:t("clipPath",{id:n,children:t("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t("path",{d:u,fill:gi(c.style.fill),fillOpacity:null!==(s=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==s?s:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${n})`})]},"area-"+i)}return t("path",{d:u,fill:gi(c.style.fill),fillOpacity:null!==(l=null!==(a=c.style.fillOpacity)&&void 0!==a?a:c.style.opacity)&&void 0!==l?l:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+i)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:gi(e.style.fill),opacity:null!==(c=e.style.opacity)&&void 0!==c?c:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+i)}case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:gi(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=n;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const n=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),[r,s,a]=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),l=.299*r+.587*s+.114*a>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e("g",{children:[t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:c+"px",children:n})]},"heatcell-"+i)}return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=n,r=Math.min(o.openY,o.closeY),s=Math.max(Math.abs(o.openY-o.closeY),1),a=o.isUp?o.upColor:o.downColor;return e("g",{children:[t("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+i)}default:return null}}function mi(n,o,r){var s,a,l,c,u,d,h,f,g;const p=("category"in n?n.category:void 0)||("group"in n?n.group:void 0)||"",y=t=>`ord-${n.type}-${p}-${o}-${t}`,m=`ord-${n.type}-${p}-${o}`;switch(n.type){case"rect":{const o=n,r=pi(m)+"-grad",s=function(e,n){const i=e.fillGradient;if(!i)return null;let o=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?(o=e.x+e.w,r=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(o=e.x,r=e.y,s=e.x+e.w,a=e.y);const l=[];if("colorStops"in i){const e=i.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("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=gi(e.style.fill);l.push(t("stop",{offset:0,stopColor:n,stopOpacity:i.topOpacity},"0")),l.push(t("stop",{offset:1,stopColor:n,stopOpacity:i.bottomOpacity},"1"))}return t("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:s,y2:a,children:l})}(o,r),a=s?`url(#${r})`:gi(o.style.fill);if(o.cornerRadii&&ci(o.cornerRadii)){const n=function(t){const{x:e,y:n,w:i,h:o}=t,{tl:r,tr:s,br:a,bl:l}=ui(t);let c=`M${e+r},${n}`;return c+=` L${e+i-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+i},${n+s}`),c+=` L${e+i},${n+o-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+i-a},${n+o}`),c+=` L${e+l},${n+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+o-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(o);return e(i.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:n,fill:a,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}if(o.roundedTop&&o.roundedTop>0){const n=Math.min(o.roundedTop,o.w/2,o.h/2),{x:r,y:l,w:c,h:u}=o;let d;switch(o.roundedEdge){case"right":d=`M${r},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r},${l+u} Z`;break;case"left":d=`M${r+c},${l} L${r+n},${l} A${n},${n} 0 0 0 ${r},${l+n} L${r},${l+u-n} A${n},${n} 0 0 0 ${r+n},${l+u} L${r+c},${l+u} Z`;break;case"bottom":d=`M${r},${l} L${r+c},${l} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r+n},${l+u} A${n},${n} 0 0 1 ${r},${l+u-n} Z`;break;default:d=`M${r},${l+u} L${r},${l+n} A${n},${n} 0 0 1 ${r+n},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u} Z`}return e(i.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:d,fill:a,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}return e(i.Fragment,{children:[s&&t("defs",{children:s}),t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:a,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:gi(e.style.fill),opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},m)}case"wedge":{const i=n;if(i._gradientBand&&i._gradientBand.colors.length>0){const n=pi(`${r?r+"-":""}gauge-grad-${i.category||m}-${o}`),{clipPath:s,slices:d}=function(t){const e=hi({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],i=t.colors;if(i.length>0){const e=(t.endAngle-t.startAngle)/i.length;for(let o=0;i.length>o;o++)n.push({d:hi({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+o*e,endAngle:t.endAngle}),color:i[o]})}return{clipPath:e,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:null===(l=null===(a=i.roundedEnds)||void 0===a?void 0:a.start)||void 0===l||l,roundEnd:null===(u=null===(c=i.roundedEnds)||void 0===c?void 0:c.end)||void 0===u||u,colors:i._gradientBand.colors});return e("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[t("defs",{children:t("clipPath",{id:n,children:t("path",{d:s})})}),t("g",{clipPath:`url(#${n})`,children:d.map((e,n)=>t("path",{d:e.d,fill:gi(e.color)},n))}),i.style.stroke&&"none"!==i.style.stroke&&t("path",{d:s,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},m)}let s;if(i.roundedEnds)s=hi({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=W().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),s=t(fi)||""}return t("path",{d:s,transform:`translate(${i.cx},${i.cy})`,fill:gi(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},m)}case"boxplot":{const i=n,o=i.columnWidth/2;return e("g","vertical"===i.projection?{children:[t("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:gi(i.style.fill),fillOpacity:null!==(d=i.style.fillOpacity)&&void 0!==d?d:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:gi(i.style.fill),fillOpacity:null!==(h=i.style.fillOpacity)&&void 0!==h?h:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1})]},m)}case"violin":{const e=n,i=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:gi(e.style.fill),fillOpacity:null!==(f=e.style.fillOpacity)&&void 0!==f?f:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},y("path"))];if(e.iqrLine&&e.bounds){const n=e.bounds,o=n.x+n.width/2,r=n.y+n.height/2;n.height>n.width?i.push(t("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},y("iqr")),t("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},y("med"))):i.push(t("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},y("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},y("med")))}return t("g",{children:i},m)}case"connector":return t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:null!==(g=n.style.opacity)&&void 0!==g?g:.5},m);case"trapezoid":{const e=n,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:i,fill:gi(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},m)}default:return null}}const vi="undefined"==typeof window||"undefined"==typeof document;function bi(e){let n=null;const i=()=>(n||(n=c(null)),n),u=xi(e);return[function({children:n,initialState:s}){const a=o(s),l=r(()=>xi(e,a.current),[]),c=i();return t(c.Provider,{value:l,children:n})},t=>{var e;const n=i(),r=null!==(e=s(n))&&void 0!==e?e:u,c=o(t);c.current=t;const d=a(()=>c.current(r.getState()),[r]),h=a(()=>c.current(r.getState()),[r]);return l(r.subscribe,d,h)}]}function xi(t,e){const n=new EventTarget;let i=Object.assign(Object.assign({},t(function(t){i=Object.assign(Object.assign({},i),t(i)),n.dispatchEvent(new Event("update"))})),null!=e?e:{});return{getState:()=>i,subscribe:function(t){return n.addEventListener("update",t),()=>n.removeEventListener("update",t)}}}function ki(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 wi(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:Ai})})),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 Ai=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Si={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}},Mi={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}},_i={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Ai,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 Pi(t,e){if("light"===e)return Si;if("dark"===e)return Mi;if("high-contrast"===e)return _i;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?Mi:Si;return wi(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 wi(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[Oi,Ti]=bi(t=>({theme:Si,setTheme(e){t(t=>({theme:Pi(t.theme,e)}))}})),$i={light:Si,dark:Mi,"high-contrast":_i,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 ji(t){if(!t)return Si;if("string"==typeof t){if("light"===t)return Si;if("dark"===t)return Mi;if("high-contrast"===t)return _i;return $i[t]||Si}const e="dark"===t.mode?Mi:Si;return wi(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 Li(t){var e,n,i,o;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!==(i=t.typography.titleFontSize)&&void 0!==i?i:t.typography.titleSize,tickFontFamily:null!==(o=t.typography.tickFontFamily)&&void 0!==o?o:t.typography.fontFamily}}function Ci(t){return"left"===t?"start":"right"===t?"end":null!=t?t:"start"}function zi(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 Di(t,e,n,i){const o=zi(i);return e+n+Math.ceil(t.length*o*.58)}function Ei(t){var e,n,i,o,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),p=Math.max(0,null!==(i=null==h?void 0:h.itemGap)&&void 0!==i?i:8),y=Math.max(f,null!==(o=null==h?void 0:h.rowHeight)&&void 0!==o?o:20),m=f+g,v=Math.min(2,f/2),b="top"===l||"bottom"===l,x=Math.max(f,c-d.left-d.right),k=Math.max(y,u-d.top-d.bottom),w=s.map(t=>Di(t,f,g,a));if(b){const t=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:x),e=[];let n=0,i=0;w.forEach((o,r)=>{const s=0===i?o:i+p+o;i>0&&s>t?(e.push({start:n,end:r,width:i}),n=r,i=o):i=s}),s.length>0&&e.push({start:n,end:s.length,width:i});const o=Ci(null==h?void 0:h.align),a=[];return e.forEach((e,n)=>{let i="center"===o?Math.max(0,(t-e.width)/2):"end"===o?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:i,y:n*y}),i+=w[t]+p}),{items:a,width:Math.max(0,...e.map(t=>t.width)),height:e.length*y,swatchSize:f,labelOffset:m,swatchRadius:v}}const A=Math.max(0,...w),S=Math.max(1,Math.floor(k/y)),M=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+p),y:e%S*y})),width:M*A+Math.max(0,M-1)*p,height:Math.min(s.length,S)*y,swatchSize:f,labelOffset:m,swatchRadius:v}}function Ni(t){var e,n,i,o,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),p=Math.max(0,null!==(i=null==h?void 0:h.itemGap)&&void 0!==i?i:8),y=Math.max(f,null!==(o=null==h?void 0:h.rowHeight)&&void 0!==o?o:20),m=f+g,v=Math.min(2,f/2),b=Math.max(12,zi(a)),x="top"===l||"bottom"===l,k=Math.max(f,c-d.left-d.right),w=Math.max(y,u-d.top-d.bottom);if(x){const e=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:k),n=Ci(null==h?void 0:h.align);let i=0,o=0;const l=[];for(const n of s){const r=n.items.map(t=>t.label),s=Ei(Object.assign(Object.assign({},t),{categories:r,legendLayout:Object.assign(Object.assign({},h),{maxWidth:Math.max(f,e-b-8),align:"start"})})),c=n.label?b:0,u=n.label?Di(n.label,0,0,a):0,d=c>0?c+8:0,g=d+s.width,p=Math.max(s.height,u);l.push({group:n,x:i,y:0,itemOffsetX:d,itemOffsetY:0,width:g,height:p,items:s.items}),i+=g+12,o=Math.max(o,p)}const c=l.length>0?i-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:o,swatchSize:f,labelOffset:m,swatchRadius:v}}let A=0,S=0;const M=[];for(const t of s){const e=t.items.map(t=>t.label).map(t=>Di(t,f,g,a)),n=Math.max(0,...e),i=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(y,w-A)/y)))),o=Math.max(1,Math.ceil(t.items.length/i)),r=t.items.map((t,o)=>({category:t.label,width:e[o],x:Math.floor(o/i)*(n+p),y:o%i*y})),s=o*n+Math.max(0,o-1)*p,l=Math.min(t.items.length,i)*y,c=t.label?Di(t.label,0,0,a):0,u=t.label?b+8:0,d=u+l+12,h=Math.max(s,c);M.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:M,width:S,height:Math.max(0,A),swatchSize:f,labelOffset:m,swatchRadius:v}}function Ri(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 Fi(n){const{categories:i,colorScheme:o,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=n;if(!i||0===i.length)return null;const d=function(t,e,n){const i=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:It;return m().domain(t).range(i)}(i,o,r),h="top"===s||"bottom"===s,f=Ei(n);let g,p;if("left"===s?(g=Math.max(4,c.left-f.width-10),p=c.top):"top"===s?(g=c.left,p=u?32:8):"bottom"===s?(g=c.left,p=Math.min(l-c.bottom+38,l-f.height-2)):(g=Math.min(a-f.width-4,a-c.right+10),p=c.top),h){const n=f.items.map((n,i)=>e("g",{transform:`translate(${n.x},${n.y})`,children:[t("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(n.category),rx:f.swatchRadius}),t("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:zi(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n.category})]},"legend-"+i));return t("g",{className:"semiotic-legend",transform:`translate(${g},${p})`,children:n})}const y=f.items.map((n,i)=>e("g",{transform:`translate(${n.x},${n.y})`,children:[t("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(n.category),rx:f.swatchRadius}),t("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:zi(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n.category})]},"legend-"+i));return t("g",{className:"semiotic-legend",transform:`translate(${g},${p})`,children:y})}function Wi(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],i=new Set;for(const e of t){const t=n(e);null!=t&&i.add(t+"")}return Array.from(i)}function Bi(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function Ii(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Yi(n,i,o,r){if(!n)return t("g",{className:"annotation-note"});const{label:s,title:a,orientation:l,align:c,wrap:u=120,noWrap:d}=n;if(!s&&!a)return t("g",{className:"annotation-note"});let h=l;h||(h=Math.abs(i)>Math.abs(o)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>i?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>i?"end":"start";const p=16,y=a?d?[a]:Bi(a,u):[],m=s?d?[s]:Bi(s,u):[],v="leftRight"===h?"end"===g?-4:4:0;let b=0;const x=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:y.map((e,n)=>t("tspan",{x:v,dy:0===n?0:p,children:e},n))},"annotation-note-title")),b=y.length*p),m.length>0&&x.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:b,children:m.map((e,n)=>t("tspan",{x:v,dy:0===n?0:p,children:e},n))},"annotation-note-label"));let w=null;if((a||s)&&(0!==i||0!==o))if("topBottom"===h){const e=Math.min(u,120);let n=0,i=e;"end"===g?(n=-e,i=0):"middle"===g&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+m.length)*p+(m.length>0?p:0);let n=0,i=e;"bottom"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,y.length+m.length-1)*p;let S=0;return"topBottom"===h?S=0>o?-(A+2):18:"leftRight"===h&&(S="middle"===f?-(A+p+(m.length>0&&y.length>0?2:0))/2+8:"bottom"===f||0>o?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${i},${o})`,children:[t("g",{className:"annotation-note-content",transform:0!==S?`translate(0,${S})`:void 0,children:x}),w]})}function Gi(e,n,i,o,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("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&a.push(t("rect",{width:e,height:o,fill:"none",stroke:i||"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=o||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;a.push(t("line",{x1:o,y1:(n.y1||0)-s,x2:o,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-s;a.push(t("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"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("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"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("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:i||"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("path",{d:Ii((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:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:a})}function Hi(e,n,i,o,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,i=s.height||0;if(t>0||i>0){const o=t/2,r=i/2,s=e-o,a=n-r;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),l=t/2,d=i/2,h=e*d>n*l?l/e:d/n;c=o+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 i=Math.atan2(n,e);c=Math.cos(i)*t,u=Math.sin(i)*t}}const d=Math.sqrt(Math.pow(e-c,2)+Math.pow(n-u,2));if(d>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",s="curve"===(null==i?void 0:i.type);let h=Math.atan2(n-u,e-c);if(s){const o=(null!==(a=null==i?void 0:i.curve)&&void 0!==a?a:.25)*d,s=(c+e)/2+-(n-u)/d*o,f=(u+n)/2+(e-c)/d*o;l.push(t("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("line",{x1:c,y1:u,x2:e,y2:n,stroke:r},"connector-line"));if("arrow"===(null==i?void 0:i.end)){const e=10,n=16/180*Math.PI;l.push(t("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("g",{className:"annotation-connector",children:l})}function Xi(t){var n,i;const{x:o=0,y:r=0,dx:s,dy:a,nx:l,ny:c,note:u,connector:d,subject:h,type:f,color:g,className:p,disable:y,opacity:m,strokeDasharray:v,events:b={},"data-testid":x}=t,k=Array.isArray(o)?null!==(n=o[0])&&void 0!==n?n:0:o,w=Array.isArray(r)?null!==(i=r[0])&&void 0!==i?i:0:r,A=new Set(Array.isArray(y)?y:[]);let S=s||0,M=a||0;null!=l&&(S=l-k),null!=c&&(M=c-w);const _="string"==typeof f?f:"label";if("bracket"===_&&h&&0===S&&0===M)if(void 0!==h.width){S=h.width/2;const t=h.depth||30;M=t+(0>t?-5:5)}else if(void 0!==h.height){const t=h.depth||30;S=t+(0>t?-5:5),M=h.height/2}return e("g",Object.assign({className:("annotation "+(p||"")).trim(),transform:`translate(${k},${w})`,"data-testid":x},null!=m&&{opacity:m},v&&{strokeDasharray:v},b,{children:[!A.has("connector")&&Hi(S,M,d,g,_,h),!A.has("subject")&&Gi(_,h,g,k,w),!A.has("note")&&Yi(u,S,M,g)]}))}function qi(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,s="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),a=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),l=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t(Xi,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t("g",{children:l})}const l=o.note||{title:"none",label:o.label},c=`${l.label}-${l.title}-${o.i}`;return t(Xi,Object.assign({"data-testid":"semiotic-annotation",events:a},o,{type:s}),c)}const Vi={secondary:0,primary:3};function Ui(t){return!0===(null==t?void 0:t._annotationDeferred)}function Zi(t){return"blended"===(null==t?void 0:t.cohesion)||"layer"===(null==t?void 0:t.cohesion)?t.cohesion:null}function Qi(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 Ki(t){return Math.max(.72,.95-.06*t)}function Ji(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:Qi(t.annotation),readingOrder:null,rank:1};var n}),i=n.some(t=>null!=t.emphasis||null!=t.confidence),o=e.some(t=>Ui(t.annotation)),r=e.some(t=>null!=Zi(t.annotation)),s=e.some(t=>"layer"===Zi(t.annotation));if(!i&&!o&&!r)return e.map(t=>t.node);const a=n.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>{var n,i;return(null!==(n=e.confidence)&&void 0!==n?n:0)-(null!==(i=t.confidence)&&void 0!==i?i: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=Vi[t.emphasis]);const l=n.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(e=>{const{p:n,i:i,emphasis:o,readingOrder:r}=e,s=Ui(n.annotation);let a=n.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;a=t("g",Object.assign({className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o},"secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},e?{opacity:Ki(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+i)}const l=Zi(n.annotation);return l&&(a=t("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+i)),s&&(a=t("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+i)),a});return o&&l.unshift(t("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("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 to(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function eo(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function no(t){return null==t?null:t+""}function io(t,e,n){var i;return null===(i=e.stickyPositionCache)||void 0===i||i.set(t,n),n}function oo(t,e,n){var i,o;const r=t.anchor||(null===(i=t.lifecycle)||void 0===i?void 0:i.anchor)||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const o=n.pointNodes[i];if(o.pointId===t.pointId)return io(e,n,{x:o.x,y:o.y})}const i=function(t){var e,n,i,o,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===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.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 i?io(e,n,i):null}if("semantic"===r){const i=function(t,e,n){var i,o;const r=function(t){var e,n;return no(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===(i=n.pointNodes)||void 0===i?void 0:i.find(t=>no(t.pointId)===r);if(s)return io(e,n,{x:s.x,y:s.y});const a=null===(o=n.data)||void 0===o?void 0:o.find(t=>function(t){var e,n,i;return no(null!==(n=null!==(e=t.stableId)&&void 0!==e?e:t.id)&&void 0!==n?n:null===(i=t.provenance)||void 0===i?void 0:i.stableId)}(t)===r);if(!a)return null;const l=to(a,n),c=eo(a,n);return null==l||null==c?null:io(e,n,{x:l,y:c})}(t,e,n);if(i)return i}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=to(t,n),a=eo(t,n)),null!=s&&null!=a)return io(e,n,{x:s,y:a});if("sticky"===r){const t=null===(o=n.stickyPositionCache)||void 0===o?void 0:o.get(e);if(t)return t}return null}function ro(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const so=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function ao(t){return!!t&&"object"==typeof t&&so.has(function(t){return"string"==typeof(null==t?void 0:t.type)?t.type:""}(t))}function lo(t){return"primary"===(null==t?void 0:t.emphasis)||!0===(null==t?void 0:t.defensive)}function co(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 uo(t){var e,n;let i;const o=null==t?void 0:t.emphasis;i="primary"===o?100:"secondary"===o?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)&&(i+=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":i+=8;break;case"aging":i+=4;break;case"stale":i+=1;break;case"expired":i-=200}return i}new Set(["label","callout","callout-circle","callout-rect"]);const ho=32,fo=6,go=4,po=8,yo=72;const mo={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function vo(t){return ao(t)}function bo(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),i=t.split(/\s+/).filter(Boolean),o=[];let r="";for(const t of i)r&&r.length+t.length+1>n?(o.push(r),r=t):r=r?`${r} ${t}`:t;return r&&o.push(r),o}function xo(t,e,n,i,o){const r=t+n,s=e+i;return Math.abs(n)>Math.abs(i)?{x:0>n?r-o.width-4:r+4,y:0>i?s-o.height:s,width:o.width,height:o.height}:{x:0>n?r-o.width:r,y:0>i?s-o.height-4:s+4,width:o.width,height:o.height}}function ko(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function wo(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 Ao(t,e,n,i,o,r,s,a){const l=ko(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,i){const o=Math.max(0,i-t.x),r=Math.max(0,i-t.y);return(o+Math.max(0,t.x+t.width-(e-i)))*t.height+(r+Math.max(0,t.y+t.height-(n-i)))*t.width}(l,o,r,a);for(const t of n)c+=12*wo(l,t);for(const t of i)c+=4*wo(l,t);return c}function So(t){var e;const{annotations:n,context:i,defaultOffset:o=ho,notePadding:r=fo,markPadding:s=go,edgePadding:a=po,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:u=yo,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:p,audience:y}=t,m=i.width||0,v=i.height||0;if(0===n.length||0>=m||0>=v)return n.slice();const b=[],x=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}})}(i,s);let k=!1;const w=n.map((t,e)=>{if(!vo(t))return t;const n=function(t,e,n){var i,o;if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=null!==(i=t.pointId)&&void 0!==i?i: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===(o=n.scales)||void 0===o?void 0:o.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?oo(t,e,n):{x:t.x,y:t.y}}(t,e,i);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=[...bo("string"==typeof t.title?t.title:void 0,e),...bo("string"==typeof t.label?t.label:void 0,e)],i=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*i)+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 b.push(ko(xo(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}]}(o)){const e=Ao(xo(n.x,n.y,t.dx,t.dy,s),t,b,x,m,v,r,a);f>e&&(h=t,f=e)}if(!h)return t;const g=ko(xo(n.x,n.y,h.dx,h.dy,s),r);b.push(g);const p=Math.hypot(h.dx,h.dy),y=c&&p>=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}),y?{connector:y}:{})}),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 i="string"==typeof n.source?null!==(e=mo[n.source])&&void 0!==e?e:n.source:null,o="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!i&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[i,o].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 M=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}(y),i=1===n?t:Object.assign(Object.assign({},t),{maxAnnotations:Math.max(0,Math.round((null!==(e=t.maxAnnotations)&&void 0!==e?e:co(m,v,t))*n))}),{deferred:o}=function(t){var e;const{annotations:n,width:i,height:o}=t,r=Math.max(0,null!==(e=t.minVisible)&&void 0!==e?e:1),s=co(i,o,t),a=n.map((t,e)=>{return{annotation:t,index:e,note:(n=t,ao(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=>lo(t.annotation)),u=l.filter(t=>!lo(t.annotation)).sort((t,e)=>uo(e.annotation)-uo(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},i));for(const t of o)M.add(t)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const t of S)vo(t)&&"secondary"===t.emphasis&&M.add(t);if(M.size>0)for(const t of S)!0===(null==t?void 0:t.defensive)&&M.delete(t);let _;return _=0===M.size?S:h?S.map(t=>M.has(t)?Object.assign(Object.assign({},t),{_annotationDeferred:!0}):t):S.filter(t=>!M.has(t)),p?function(t,e){let n=!1;const i=t.map(t=>vo(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,Object.assign(Object.assign({},t),{cohesion:e})):t);return n?i:t}(_,p):_}function Mo(t,e){return t.color||e.colors.annotation||e.colors.text}function _o(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 Po(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 Oo(e){const{annotations:n}=e;if(!n||0===n.length)return null;const i=e.autoPlaceAnnotations?So(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,o=[];for(let t=0;i.length>t;t++){const n=To(i[t],t,e);n&&o.push({node:n,annotation:i[t]})}const r=Ji(o);return r.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function To(n,i,o){var r,s,a,l,c,u,d;const{scales:h,layout:f,theme:g,xAccessor:p,yAccessor:y}=o;switch(n.type){case"y-threshold":{const s=n.value;if(null==s)return null;const a=Mo(n,g),l=n.label,c=n.labelPosition||"right",u=n.strokeDasharray||"6,4",d=null!==(r=n.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&h.r){const n=h.r(s);return null==n?null:e("g",{children:[t("line",{x1:n,y1:0,x2:n,y2:f.height,stroke:a,strokeWidth:d,strokeDasharray:u}),l&&t("text",{x:n+4,y:12,textAnchor:"start",fontSize:g.typography.tickSize,fill:a,fontFamily:g.typography.fontFamily,children:l})]},"ann-ythresh-"+i)}const p=h.y?h.y(s):h.r?h.r(s):null;return null==p?null:e("g",{children:[t("line",{x1:0,y1:p,x2:f.width,y2:p,stroke:a,strokeWidth:d,strokeDasharray:u}),l&&t("text",{x:"left"===c?4:"center"===c?f.width/2:f.width-4,y:p-6,textAnchor:"left"===c?"start":"center"===c?"middle":"end",fontSize:g.typography.tickSize,fill:a,fontFamily:g.typography.fontFamily,children:l})]},"ann-ythresh-"+i)}case"x-threshold":{const o=n.value;if(null==o||!h.x)return null;const r=h.x(o);if(null==r)return null;const a=Mo(n,g),l=n.label,c=n.labelPosition||"top",u=null!==(s=n.strokeWidth)&&void 0!==s?s:1.5;return e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:f.height,stroke:a,strokeWidth:u,strokeDasharray:n.strokeDasharray||"6,4"}),l&&t("text",{x:r+4,y:"bottom"===c?f.height-4:"center"===c?f.height/2:12,textAnchor:"start",fontSize:g.typography.tickSize,fill:a,fontFamily:g.typography.fontFamily,children:l})]},"ann-xthresh-"+i)}case"band":{const o=null!=n.y0&&h.y?h.y(n.y0):null,r=null!=n.y1&&h.y?h.y(n.y1):null;if(null==o||null==r)return null;const s=Math.min(o,r),l=Math.abs(r-o),c=n.fill||Mo(n,g),u=null!==(a=n.opacity)&&void 0!==a?a:.1;return e("g",{children:[t("rect",{x:0,y:s,width:f.width,height:l,fill:c,opacity:u}),n.label&&t("text",{x:f.width-4,y:s+12,textAnchor:"end",fontSize:g.typography.tickSize,fill:c,fontFamily:g.typography.fontFamily,children:n.label})]},"ann-band-"+i)}case"category-highlight":{if(!n.category||!h.o)return null;const e=h.o(n.category);if(null==e)return null;const r=h.o.bandwidth?h.o.bandwidth():40,s=Mo(n,g),a=null!==(l=n.opacity)&&void 0!==l?l:.1;return t("rect","horizontal"===o.projection?{x:0,y:e,width:f.width,height:r,fill:s,opacity:a}:{x:e,y:0,width:r,height:f.height,fill:s,opacity:a},"ann-cathighlight-"+i)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:e,y:o}=function(t,e,n,i){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:_o(t,e,n),y:Po(t,e,i)}}(n,h,p,y);if(null==e||null==o)return null;const r="text"===n.type,s=null!==(c=n.dx)&&void 0!==c?c:r?0:30,a=null!==(u=n.dy)&&void 0!==u?u:r?0:-30,l=n.color||g.colors.text;if(!r){const r="callout"===n.type?"callout-circle":n.type,c="callout-circle"===r?{radius:null!==(d=n.radius)&&void 0!==d?d:12,radiusPadding:n.radiusPadding}:"callout-rect"===r?{width:n.width,height:n.height}:void 0;return t(qi,{noteData:Object.assign(Object.assign({x:e,y:o,dx:s,dy:a,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:r},c?{subject:c}:{}),{connector:n.connector||{end:"arrow"},color:l,disable:n.disable,opacity:n.opacity,strokeDasharray:n.strokeDasharray,className:n.className})},"ann-label-"+i)}return t("g",{children:t("text",{x:e+s,y:o+a,textAnchor:n.textAnchor||"start",fontSize:n.fontSize||g.typography.labelSize,fill:l,fontFamily:g.typography.fontFamily,fontWeight:n.fontWeight,opacity:n.opacity,strokeDasharray:n.strokeDasharray,children:n.label||n.title})},"ann-label-"+i)}default:return null}}function $o(t){return Math.max(0,Math.min(1,t))}function jo(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 Lo(t,e,n){const i=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Co(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:$o(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 i=$o(e);if(n[0].offset>=i)return n[0].color;if(i>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],o=n[t+1];if(e.offset>i||i>o.offset)continue;const r=o.offset-e.offset,s=r>0?(i-e.offset)/r:0,a=jo(e.color),l=jo(o.color);if(!a||!l)return.5>s?e.color:o.color;const[c,u,d]=a,[h,f,g]=l;return Lo(c+(h-c)*s,u+(f-u)*s,d+(g-d)*s)}return n[n.length-1].color}function zo(t,e,n){return`${t}-${e}`}function Do(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 Eo(t,e,n){const i=e.incoming[t.id],o=e.outgoing[t.id],r=[];for(const t of i)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of o)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,i;return t.time-e.time||(null!==(n=s[t.kind])&&void 0!==n?n:99)-(null!==(i=s[e.kind])&&void 0!==i?i:99)})},l=r.length?Math.min(...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 p=0,y=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?p:y);if(n>0){const e="top"===t.side?"bot":"top",i=Math.min(n,"top"===e?p:y);if(i>0){const o=f(t.time);g.push({time:o,delta:-i,kind:"transfer-out",side:e}),g.push({time:o,delta:+i,kind:"transfer-in",side:t.side}),"top"===e?p-=i:y-=i,"top"===t.side?p+=i:y+=i,n-=i}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?p+=n:y+=n)}"top"===t.side?p-=e:y-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?p+=e:y+=e}r.push(...g),a();let m=0,v=0,b=0,x=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>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let M=0;for(;w.length>M;){let t=M;for(;w.length>t+1&&w[t+1].t===w[M].t;)t++;S.push(w[M]);for(let e=M+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[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 o)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let O=null;for(const t of i)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===O||t.systemOutTime>O)&&(O=t.systemOutTime);if(S.length>0){const t=S[S.length-1],e=Math.max(null!=_?_:-1/0,null!=O?O:-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],i=Math.min(null!=c?c:1/0,null!=P?P:1/0);Number.isFinite(i)&&n.t>i&&n.topMass+n.botMass>0&&S.unshift({t:i,topMass:n.topMass,botMass:n.botMass})}return{samples:S,peak:b,topPeak:x,botPeak:k,localAttachments:A}}function No(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Ro(t,e){return t.map(t=>({t:No(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Fo(t,e,n){const i=t.value*n;if("out"===t.kind){const o=t.sideMassBefore*n;if("top"===t.side){const t=e-o;return[t,t+i]}const r=e+o;return[r-i,r]}const o=t.sideMassAfter*n;if("top"===t.side){const t=e-o;return[t,t+i]}const r=e+o;return[r-i,r]}function Wo(t,e){let n=0;for(let i=0;e.length>i;i++)for(let o=i+1;e.length>o;o++){const r=e[i],s=e[o];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 Bo(t,e){let n=0;for(const i of e)n+=Math.abs(t[i.source]-t[i.target])*(i.value||1);return n}function Io(t,e){return 1e3*Wo(t,e)+Bo(t,e)}function Yo(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function Go(t,e,n){t.length>8||n.length>40?(function(t,e,n,i=6){const o=t.length;if(1>=o)return;let r=Yo(t,e),s=Io(e,n);for(let a=0;i>a;a++){const i=Array(o).fill(0),a=Array(o).fill(0);for(const t of n){const n=e[t.source],o=e[t.target];i[n]+=o*(t.value||1),a[n]+=t.value||1,i[o]+=n*(t.value||1),a[o]+=t.value||1}const l=Array.from({length:o},(t,e)=>e).sort((t,e)=>(a[t]>0?i[t]/a[t]:t)-(a[e]>0?i[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=Io(e,n);if(s>d)s=d,r=Yo(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,i=6){const o=t.length;if(1>=o)return;let r=Io(e,n);for(let s=0;i>s;s++){let i=!1;for(let s=0;o-1>s;s++){const o=t[s];t[s]=t[s+1],t[s+1]=o;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Io(e,n);if(r>a)r=a,i=!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(!i)break}}(t,e,n,6)):function(t,e,n){const i=t.length;if(1>=i)return;const o=Object.assign({},e),r=Object.keys(o),s=Array.from({length:i},(t,e)=>e),a=s.slice(),l=Object.assign({},o);let c=s.slice(),u=1/0;const d=()=>{for(const t of r)l[t]=a[o[t]];const t=Io(l,n);u>t&&(u=t,c=s.slice())},h=(t,e)=>{const n=s[t],i=s[e];s[t]=i,s[e]=n,a[n]=e,a[i]=t};d();const f=Array(i).fill(0);let g=0;for(;i>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const p=c.map(e=>t[e]),y=new Map;c.forEach((t,e)=>y.set(t,e));for(const t of Object.keys(e))e[t]=y.get(e[t]);t.length=0;for(const e of p)t.push(e)}(t,e,n)}function Ho(t,e,n,i,o){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:p,packing:y,laneOrder:m,lifetimeMode:v="full"}=o,b={},x={};for(const e of t)b[e.id]=n[e.id].topPeak||0,x[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 o=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of i.outgoing[e.id]){o>t.startTime&&(o=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&o>t.systemInTime&&(o=t.systemInTime);const e=k?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of i.incoming[e.id]){const e=k?(t.startTime+t.endTime)/2:t.startTime;o>e&&(o=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(o)?o:null,end:Number.isFinite(r)?r:null}}const A={},S=[];if("reuse"===y){const n=new Map;for(const e of t)n.set(e.id,0);const o=new Map;for(const e of t)o.set(e.id,0);for(const t of e)o.set(t.target,(null!==(r=o.get(t.target))&&void 0!==r?r:0)+1);const d=[];for(const e of t)0===(null!==(s=o.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=i.outgoing[t])&&void 0!==a?a:[]){const i=(null!==(l=n.get(t))&&void 0!==l?l:0)+1;i>(null!==(c=n.get(e.target))&&void 0!==c?c:0)&&n.set(e.target,i),o.set(e.target,o.get(e.target)-1),0===o.get(e.target)&&d.push(e.target)}}const h=[...t].filter(t=>null!==w[t.id].start).sort((t,e)=>{var i,o;const r=null!==(i=n.get(t.id))&&void 0!==i?i:0,s=null!==(o=n.get(e.id))&&void 0!==o?o: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 i=S[t].occupants[S[t].occupants.length-1];if(null===e.start||void 0===i||e.start>=i.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,b[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,x[t.id]),A[t.id]=n}}else t.forEach((t,e)=>{var n,i;S.push({occupants:[{id:t.id,end:null!==(i=null===(n=w[t.id])||void 0===n?void 0:n.end)&&void 0!==i?i:-1/0}],peak:{topPeak:b[t.id],botPeak:x[t.id]}}),A[t.id]=e});let M=null,_=null,P=null,O=null;const T=()=>{M=Wo(A,e),P=Bo(A,e)},$=()=>{_=Wo(A,e),O=Bo(A,e)};"crossing-min"===m?(T(),Go(S,A,e),$()):"inside-out"===m?(T(),function(t,e){const n=t.length;if(1>=n)return;const i=t=>t.peak.topPeak+t.peak.botPeak,o=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>i(e.slot)-i(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=o[0].idx;let a=s-1,l=s+1;for(let t=1;o.length>t;t++)t%2==1&&n>l||0>a?r[l++]=o[t].idx:r[a--]=o[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),$()):"crossing-min+inside-out"===m&&(T(),Go(S,A,e),function(t,e,n){const i=t.length;if(1>=i)return;const o=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((i-1)/2);let s=Io(e,n);for(const{slot:a}of o){const o=t.indexOf(a);if(0>o)continue;const l=r;if(o===l)continue;const c=t[o];t.splice(o,1),t.splice(l,0,c);const u=new Map;for(let t=0;i>t;t++)u.set(t,t);if(l>o){for(let t=o+1;l>=t;t++)u.set(t,t-1);u.set(o,l)}else{for(let t=l;o>t;t++)u.set(t,t+1);u.set(o,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=Io(e,n);if(d>s){const n=t[l];t.splice(l,1),t.splice(o,0,n);const r=new Map;for(let t=0;i>t;t++)r.set(t,t);if(o>l){for(let t=l+1;o>=t;t++)r.set(t,t-1);r.set(l,o)}else{for(let t=o;l>t;t++)r.set(t,t+1);r.set(l,o)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(S,A,e),$());const j=S.map(t=>{const e=new Map;for(const i of t.occupants){const t=n[i.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[i,o]of t){if(i>e)break;n=o}return n},C=[];for(let t=0;S.length-1>t;t++){const e=j[t],n=j[t+1],i=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let o=0;for(const t of i){const i=L(e,t),r=L(n,t);i.bot+r.top>o&&(o=i.bot+r.top)}C.push(o)}const z=[];let D=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;S.length>0&&z.push(D);for(let t=1;S.length>t;t++)D+=C[t-1]*p+g,z.push(D);if(S.length>0&&(D+=S[S.length-1].peak.botPeak*p+g),D>f){const t=f/D;for(let e=0;z.length>e;e++)z[e]*=t}const E=0===S.length?0:S[0].peak.topPeak+C.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,N={};for(const e of t)N[e.id]=z[A[e.id]];return{effectiveSlotsHeight:E,centerlines:N,laneLifetime:w,slots:S,slotByNode:A,slotCenter:z,crossingsBefore:M,crossingsAfter:_,lengthBefore:P,lengthAfter:O}}function Xo(t){const{nodes:e,edges:n,domain:i,plotW:o,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:l,layoutOpts:c}=t,u=function(t,e,n){const i=[],o=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]||i.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]||i.push({kind:"invalid-node-time",id:e.id}));for(const t of e)o.has(t.source)||i.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),o.has(t.target)||i.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||i.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||i.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):i.push({kind:"invalid-edge-time",id:t.id});return i}(e,n,i),d=x().domain(i).range([0,o]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(t,e,n){var i;const{plotH:o,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(t,e){const n={},i={};for(const e of t)n[e.id]=[],i[e.id]=[];for(const t of e)i[t.source]&&i[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:i}}(t,e),u=function(t,e,n,i="value"){const o="temporal"===i?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===i?(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 i of t){const t=i[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(t);o.edges.push(i),o.total+=i.value,o.earliestStart=Math.min(o.earliestStart,i.startTime),o.latestEnd=Math.max(o.latestEnd,i.endTime)}const s=[...n.values()];s.sort("temporal"===i?(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:o);return s};for(const e of t){const t=n.outgoing[e.id],i=n.incoming[e.id];if(0===i.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(i,"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(i,"source"),n=a(t,"target"),o=Math.max(e.length,n.length);for(let t=0;o>t;t++){const i=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=i;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=i}}}return s}(t,e,c,r);let d={};for(const e of t)d[e.id]=Eo(e,c,u);const h=Ho(t,e,d,c,{plotH:o,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 i=u.get(t.id);e!==n?e>n?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(f.add(t.id),i.sourceSide="bot",i.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],i=new Set(t.map(t=>u.get(t.id).sourceSide)),o=new Set(n.map(t=>u.get(t.id).targetSide));if(1===i.size&&n.length>0){const t=[...i][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(u.get(e.id).targetSide=t)}if(1===o.size&&t.length>0){const e=[...o][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 i=()=>{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},o=(t,e)=>{const o=i(),r="top"===t?o.outTop-o.inTop:o.outBot-o.inBot,s="top"===e?o.inTop-o.outTop:o.inBot-o.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&&(o("top","bot")||o("bot","top")););}d={};for(const e of t)d[e.id]=Eo(e,c,u);const g=Ho(t,e,d,c,{plotH:o,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),p=null!==(i=g.effectiveSlotsHeight)&&void 0!==i?i:g.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(g.slots.length+1,1)),m=p>0?Math.max(0,(o-y*(g.slots.length+1))/p):1,v=Ho(t,e,d,c,{plotH:o,padding:y,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:y,compressedPadding:12>y,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:r},c)),{centerlines:f,nodeData:g,valueScale:p}=h,y=[],m=[];e.forEach((t,e)=>{var o;const r=g[t.id];if(!r||0===r.samples.length)return;const s=function(t,e,n,i,o){if(0===t.length)return null;const r=Ro(t,o),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${i(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${i(r[t].t)},${s(t)}`;l+=` L${i(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${i(r[t].t)},${a(t)}`;return l+" Z"}(r.samples,f[t.id],p,d,i);if(!s)return;const a=Ro(r.samples,i),c=a.find(t=>t.topMass+t.botMass>0)||a[0],u=f[t.id]+(c.botMass-c.topMass)*p/2,m=l(t.id,e),v=function(t,e,n,i,o){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=Ro(r.samples,o),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=i(c.t),h=i(u.t),f=t=>i(No(t,o)),g=[],p=(t,e,n,i)=>`M${t},${e} L${n},${e} L${n},${i} L${t},${i} 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),i=f(n.startTime),o=e-20,r=Math.max(d,o);if(i>r){const[n,l]=Fo(t,a,s);g.push({pathD:p(r,n,i,l),x0:o,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),i=f(n.endTime),o=e+20,r=Math.min(h,o);if(r>i){const[n,l]=Fo(t,a,s);g.push({pathD:p(i,n,r,l),x0:e,x1:o,from:1,to:0})}}}}return g}(t.id,n,h,d,i);y.push(Object.assign(Object.assign({id:t.id,pathD:s,fill:m,stroke:m,strokeWidth:.5},v.length>0&&{gradientStubs:v}),{rawDatum:null!==(o=t.__raw)&&void 0!==o?o:t,labelX:d(c.t)-4,labelY:u,labelText:t.id}))});const v=new Map;return e.forEach((t,e)=>v.set(t.id,e)),n.forEach(t=>{var e,n,o,r;const c=null===(e=g[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=g[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!c||!u)return;const h=null!==(o=v.get(t.source))&&void 0!==o?o:0,y=l(t.source,h),b=function(t,e,n,i,o,r,s,a){const l=o,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,p=n.sideMassAfter*l;let y,m,v,b;"top"===t.side?(y=e-g,m=y+h):(m=e+g,y=m-h),"top"===n.side?(v=i-p,b=v+f):(b=i+p,v=b-f);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:y,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,f[t.source],u,f[t.target],p,d,s,i),{pathD:x,bezier:k}=pn(b);m.push({id:t.id,pathD:x,fill:y,opacity:a,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:h,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:d}}const qo=t=>{var e,n;const{bands:i=[],ribbons:o=[],showLabels:r=!0}=t.config,s=[];for(const t of o)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 i)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 i)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?i.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:i.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}},Vo=Object.freeze([]);function Uo(t){if(!t)return Vo;let e=!1;for(let n=0;t.length>n;n++){const i=t[n];if(null==i||"object"!=typeof i){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 Zo(t){return Array.isArray(t)?t[0]:t}function Qo(t,e,n,i){return Object.assign({data:Zo(t),x:e,y:n,__semioticHoverData:!0},i)}const Ko={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 Jo(t,e){return"function"==typeof e?e(t):t[e]}function tr(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 er(n={}){const{fields:i,title:o,format:r,style:s={},className:a=""}=n;return n=>{if(!n||"object"!=typeof n)return null;let l;const c=[];if(o){const t=Jo(n,o);l=tr(t,r)}if(i&&i.length>0)i.forEach(t=>{let e,i,o;"string"==typeof t?(e=t,i=t,o=r):(e=t.label,i=t.accessor||t.key||"",o=t.format||r);const s=Jo(n,i);c.push({label:e,value:tr(s,o)})});else if(!o){const t=["value","y","name","id","label"];for(const e of t)if(void 0!==n[e]){l=tr(n[e],r);break}if(!l){const t=Object.keys(n).filter(t=>!t.startsWith("_"));t.length>0&&(l=tr(n[t[0]],r))}}const u=Object.assign(Object.assign({},Ko),s);return e("div",{className:("semiotic-tooltip "+a).trim(),style:u,children:[l&&t("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:l}),c.map((t,n)=>e("div",{style:{marginTop:0===n&&l?"4px":0},children:[t.label&&e("span",{children:[t.label,": "]}),t.value]},n))]})}}function nr(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function ir(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function or({width:e,height:n,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:p,streaming:y}){const m=o(null),v=o(null),b=o(d);b.current=d;const x=o(c);x.current=c;const k=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=o(k);w.current=k;const A=o(!1),S=o(null);return u(()=>{if(!m.current)return;const t=vt(m.current).select(".brush-g"),i="x"===l?bt():"y"===l?xt():kt();return i.extent([[0,0],[e,n]]),i.on("brush end",o=>{if(A.current)return;const r=x.current;if(!r)return;if(!o.selection)return S.current=null,void b.current(null);let s,a;if("x"===l){const[t,e]=o.selection;s=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(0)]}else if("y"===l){const[t,n]=o.selection;s=[r.x.invert(0),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,i]]=o.selection;s=[r.x.invert(t),r.x.invert(n)],a=[r.y.invert(i),r.y.invert(e)]}if("bin"===f&&"y"!==l&&("end"===o.type||"brush"===o.type&&p)){const e=w.current;e&&e.length>0?s=function(t,e){return 0===e.length?t:[nr(t[0],e),ir(t[1],e)]}(s,e):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const n=r.x(s[0]),a=r.x(s[1]);if(A.current=!0,"x"===l)t.call(i.move,[n,a]);else if("xy"===l){const e=o.selection;t.call(i.move,[[n,e[0][1]],[a,e[1][1]]])}A.current=!1}const c={x:s,y:a};S.current=c,b.current(c)}),t.call(i),v.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),v.current=null}},[e,n,l,f,h,p]),u(()=>{if(!(y&&c&&v.current&&S.current))return;if(!m.current)return;if("y"===l)return;const t=S.current,e=c.x.domain()[0],n=vt(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 b.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===f){const t=w.current;t&&t.length>0?i=ir(e,t):h&&h>0&&(i=Math.ceil(e/h)*h)}if(i>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);o=!0}const r=c.x(i),s=c.x(t.x[1]);if(A.current=!0,"x"===l)n.call(v.current.move,[r,s]);else{const e=c.y(t.y[1]),i=c.y(t.y[0]);n.call(v.current.move,[[r,e],[s,i]])}if(A.current=!1,o){const e={x:[i,t.x[1]],y:t.y};S.current=e,b.current(e)}},[c,y,l,f,h]),t("svg",{ref:m,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class rr{constructor(t,e){var n,i;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!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i: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=Uo(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=Uo(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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 i=t[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),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 sr(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:i.createElement(i.Fragment,null,...e)}function ar(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 lr(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function cr(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function ur(t,e){const n=cr(t);if(!n)return!1;const i=cr(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}const dr=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,hr=new WeakMap;let fr=0,gr=!1,pr=null,yr=null,mr=null;function vr(t,e){var n,i;if(!e)return e;const o=dr.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if(gr)return;if("undefined"==typeof window||"undefined"==typeof document)return;gr=!0;const t=()=>{fr++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(pr=new MutationObserver(t),pr.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{yr=window.matchMedia("(prefers-color-scheme: dark)"),mr=t,"function"==typeof yr.addEventListener?yr.addEventListener("change",mr):"function"==typeof yr.addListener&&yr.addListener(mr)}catch(t){}}();let s=hr.get(r);s&&s.version===fr||(s={version:fr,map:new Map},hr.set(r,s));const a=s.map.get(e);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return s.map.set(e,l),l}function br(t){switch(t){case"monotoneX":return Z;case"monotoneY":return U;case"cardinal":return V;case"catmullRom":return q;case"step":return X;case"stepBefore":return H;case"stepAfter":return G;case"basis":return Y;case"natural":return I;default:return null}}function xr(t,e,n){return null==e?n:"string"!=typeof e?e:vr(t,e)||n}function kr(t,e,n,i,o,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(i,o,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(i,o,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.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 wr(t,e,n,i,o,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,i,o,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}const Ar=new WeakMap;function Sr(t,e){const n=br(e);if(!n)return t;const i=Ar.get(t);if(i)return i;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const i=[];let o=null;const r={moveTo(t,e){o=[t,e],i.push([t,e])},lineTo(t,e){o=[t,e],i.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!o)return o=[a,l],void i.push([a,l]);const[c,u]=o;for(let o=1;n>=o;o++){const d=o/n,h=1-d;i.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])}o=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){o=[n,r],i.push([n,r])}};return Q().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return Ar.set(t,o),o}function Mr(t,e,n,i=30,o,r=0){let s=null;if(o){const t=function(t,e,n,i,o,r=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(i,o+5,12),c=e-l,u=e+l,d=n-l,h=n+l;let f=null,g=1/0;return t.visit((t,o,l,p,y)=>{if(o>u||c>p||l>h||d>y)return!0;if(!t.length){let o=t;do{const t=o.data,l=r(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);lr(a(t),i)>=u&&g>u&&(f=t,g=u),o=o.next}while(o)}return!1}),f?{node:f,distance:g}:null}(o,e,n,i,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(o)break;t=Pr(r,e,n,i);break;case"line":t=Or(r,e,n,i);break;case"rect":if(null==r.datum)break;t=$r(r,e,n);break;case"heatcell":t=jr(r,e,n);break;case"area":if(!1===r.interactive)break;t=Cr(r,e,n);break;case"candlestick":t=Lr(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function _r(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=zr(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,a]=t[o],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function Pr(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>lr(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Or(t,e,n,i=30){var o,r;if(0===t.path.length)return null;const s=zr(t.path,e);if(0>s)return null;const[a,l]=t.path[s];let c;if(t.path.length>1){let i=1/0;const o=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=o;r>=s;s++){const[o,r]=t.path[s],[a,l]=t.path[s+1],c=Tr(e,n,o,r,a,l);i>c&&(i=c)}c=i}else{const t=e-a,i=n-l;c=Math.sqrt(t*t+i*i)}const u=t.style,d=null!==(r=null!==(o=u.strokeWidth)&&void 0!==o?o:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:a,y:l,distance:c}}function Tr(t,e,n,i,o,r){const s=o-n,a=r-i,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*s+(e-i)*a)/l;c=Math.max(0,Math.min(1,c));const u=i+c*a;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function $r(t,e,n){const i=ar(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function jr(t,e,n){const i=ar(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Lr(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function Cr(t,e,n){if(0===t.topPath.length)return null;const i=zr(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:l}}function zr(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Dr(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function Er(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}function Nr({isStale:e,position:n}){return t("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 Rr={fill:(e,n)=>t("rect",{style:e,width:n,height:n}),line:(e,n)=>t("line",{style:e,x1:0,y1:0,x2:n,y2:n})};function Fr(t,e,n,i,o){let r;return r="function"==typeof n?n(t):(0,Rr[n])(i(t,e),o),r}function Wr({swatchSize:e}){return t("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 Br(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Ir=(n,i,o,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:p}=n,y=[];let m=0;const v=!(!i&&!o),b="isolate"===d||void 0===d&&null!=s,{swatchSize:x,labelGap:k,rowHeight:w}=h;return p.forEach((n,d)=>{const h=Fr(n,d,f,g,x),A=Br(n,r,s),S=s&&s.size>0&&s.has(n.label);y.push(e("g",{transform:`translate(0,${m})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?c===a&&d===l?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?S||!1:void 0,"aria-current":v&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:v?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+p.length)%p.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:v?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+k+2+7*n.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),h,S&&t(Wr,{swatchSize:x}),t("text",{y:x/2,x:x+k,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),m+=w}),y};function Yr({config:n,orientation:o="vertical",width:r=100}){const{colorFn:s,domain:a,label:l,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+i.useId();if("horizontal"===o){const n=12,i=Math.min(r,200),o=Math.max(0,(r-i)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:s(a[0]+n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),l&&t("text",{x:o+i/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("rect",{x:o,y:0,width:i,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])}),t("text",{x:o+i,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:s(a[1]-n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[l&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])})]})}function Gr(n){const{legendGroups:o,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical",legendLayout:g}=n,p=function(t){var e,n,i,o,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!==(i=null==t?void 0:t.labelGap)&&void 0!==i?i:6),itemGap:Math.max(0,null!==(o=null==t?void 0:t.itemGap)&&void 0!==o?o: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}}(g),[y,m]=i.useState(0),[v,b]=i.useState(0),x=i.useCallback((t,e)=>{m(t),b(e)},[]),k="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,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("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("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("g",{className:"legend-item",transform:`translate(0,${h})`,children:Ir(e,i,o,r,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:o||[],width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:y,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:c,metrics:p}):(({legendGroups:n,height:i,width:o,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h,metrics:f})=>{var g;let p=0;const y=[];n.forEach((n,i)=>{var g;let m=0;n.label&&(m+=16);const v=((n,i,o,r,s,a,l,c,u,d,h,f)=>{const{type:g="fill",styleFn:p,items:y}=n,m=[],{swatchSize:v,labelGap:b,itemGap:x,rowHeight:k,align:w}=h,A=!(!i&&!o),S="isolate"===d||void 0===d&&null!=s,M=y.map(t=>v+b+7*t.label.length),_=[];let P=0,O=0;M.forEach((t,e)=>{const n=0===O?t:O+x+t;f&&f>0&&O>0&&n>f?(_.push({start:P,end:e,width:O}),P=e,O=t):O=n}),y.length>0&&_.push({start:P,end:y.length,width:O}),_.forEach((n,d)=>{let h="center"===w?Math.max(0,((null!=f?f:n.width)-n.width)/2):"end"===w?Math.max(0,(null!=f?f:n.width)-n.width):0;for(let f=n.start;n.end>f;f++){const n=y[f],w=Fr(n,f,g,p,v),_=Br(n,r,s),P=s&&s.size>0&&s.has(n.label);m.push(e("g",{transform:`translate(${h},${d*k})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:A?c===a&&f===l?0:-1:void 0,role:A?"option":void 0,"aria-selected":A&&S?P||!1:void 0,"aria-current":A&&!S&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:A?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(f+("ArrowRight"===t.key?1:-1)+y.length)%y.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:A?t=>{u(c,f),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:A?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:A?"pointer":"default",opacity:_,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[A&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+b+2+7*n.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),w,P&&t(Wr,{swatchSize:v}),t("text",{y:v/2,x:v+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+f)),h+=M[f]+x}});const T=Math.max(0,..._.map(t=>t.width)),$=_.length;return{items:m,offset:T,totalRows:$,totalHeight:$*k}})(n,r,s,a,l,c,u,i,d,h,f,null!==(g=f.maxWidth)&&void 0!==g?g:o);m+=v.offset+5,y.push(Object.assign(Object.assign({label:n.label},v),{offset:m,totalRows:v.totalRows,totalHeight:v.totalHeight})),p+=m+12});const m=null!==(g=f.maxWidth)&&void 0!==g?g:o;let v=p>m?0:"center"===f.align?Math.max(0,(m-p)/2):"end"===f.align?Math.max(0,m-p):0;const b=[];return y.forEach((e,o)=>{const r=n[o];r.label&&(b.push(t("text",{transform:`translate(${v},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-"+o)),v+=16),b.push(t("g",{className:"legend-item",transform:`translate(${v},0)`,children:e.items},"legend-group-"+o)),v+=e.offset+5,n[o+1]&&b.push(t("line",{stroke:"gray",x1:v,y1:-8,x2:v,y2:(e.totalHeight||i)+0+8},"legend-top-line legend-symbol-"+o)),v+=12}),t("g",{children:b})})({legendGroups:o||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:y,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:c,metrics:p}),w=!(!r&&!s);return e("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"isolate"!==c&&(void 0!==c||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),k]})}function Hr(e){var n;const{legend:i,totalWidth:o,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=e;if(!i)return null;const p="top"===a||"bottom"===a,y=!!c,m=Math.max(1,p?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,o-s.left-s.right):100);let v,b;return"left"===a?(v=Math.max(4,s.left-m-10),b=s.top):"top"===a?(v=s.left,b=y?32:8):"bottom"===a?(v=s.left,b=r-s.bottom+38):(v=o-s.right+10,b=s.top),t("g",{transform:`translate(${v}, ${b})`,children:Mt(i)?t(Yr,{config:i.gradient,orientation:p?"horizontal":"vertical",width:m}):St(i)?t(Gr,{legendGroups:i.legendGroups,title:"",width:m,orientation:p?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):i})}function Xr(t){return"string"==typeof t?{type:t}:t}function qr({orient:n,config:i,values:o,scale:s,size:a,length:l}){const c=function(t){var e,n,i,o,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!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=r(()=>{if(0===o.length)return null;const i=s.domain(),r=a-8;if("boxplot"===c.type){const i=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!i)return null;const{q1:a,median:l,q3:d,whiskerLow:h,whiskerHigh:f}=i,g=Math.min(.5*r,20),p=(r-g)/2+4;if(u){const i=s(a),o=s(d),r=s(l),u=s(h),y=s(f),m="top"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:v+m*(p+g/2),x2:y,y2:v+m*(p+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:v+m*p,x2:u,y2:v+m*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:y,y1:v+m*p,x2:y,y2:v+m*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(i,o),y:"top"===n?v-p-g:v+p,width:Math.abs(o-i),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?v-p-g:v+p,x2:r,y2:"top"===n?v-p:v+p+g,stroke:c.fill,strokeWidth:2})]})}{const i=s(a),o=s(d),r=s(l),u=s(h),y=s(f),m="left"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:v+m*(p+g/2),y1:u,x2:v+m*(p+g/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*p,y1:u,x2:v+m*(p+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*p,y1:y,x2:v+m*(p+g),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?v-p-g:v+p,y:Math.min(i,o),width:g,height:Math.abs(o-i),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?v-p-g:v+p,y1:r,x2:"left"===n?v-p:v+p+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=$().domain(i).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/h*r;if(u){const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:r,y:"top"===n?-4-o:4,width:Math.max(a,.5),height:o,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:"left"===n?-4-o:4,y:Math.min(r,r+a),width:o,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=r/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*(r/2),a=s((t.x0+t.x1)/2);i.push(u?`${a},${"top"===n?-(e-o):e-o}`:`${"left"===n?-(e-o):e-o},${a}`)}for(let t=d.length-1;t>=0;t--){const o=d[t];if(null==o.x0||null==o.x1)continue;const a=o.length/h*(r/2),l=s((o.x0+o.x1)/2);i.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("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?s(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*r,o=s((t.x0+t.x1)/2);e.push(`L${o},${"top"===n?-i-4:i+4}`)}const o=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${o},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?s(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*r,o=s((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${o}`)}const o=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${t},${o}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,s,c,a,l,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}const Vr={linear:J,monotoneX:Z,monotoneY:U,step:X,stepAfter:G,stepBefore:H,basis:Y,cardinal:V,catmullRom:q};let Ur={positions:new Map};const Zr=new Set;function Qr(){for(const t of Zr)t()}function Kr(t,e){const n=Ur.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(Ur.positions);i.delete(t),Ur={positions:i},Qr()}function Jr(t,e){const n=Ur.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(Ur.positions);i.delete(t),Ur={positions:i},Qr()}function ts(){return Ur}function es(t){return Zr.add(t),()=>Zr.delete(t)}const ns={positions:new Map};function is(){return()=>{}}function os(){return ns}function rs(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),i=n[0],o=n[n.length-1],r=i instanceof Date,s=i instanceof Date?i.getTime():i,a=o instanceof Date?o.getTime():o;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 ss(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function as(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function ls(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const i of t)e>i.pixel&&(e=i.pixel),i.pixel>n&&(n=i.pixel);return{min:e,max:n}}function cs(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function us(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function ds(n){const{width:i,height:o,totalWidth:s,totalHeight:a,margin:l,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g,axisExtent:p}=n,y=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||f||hs,r=Math.max(2,Math.floor(i/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:rs(c.x,"exact"===p?Math.max(2,s):Math.min(s,r),p),l=a.map(t=>t.valueOf()),u=a.map((t,e)=>({value:t,pixel:c.x(t),label:o(t,e,l)})),h=u.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 fs(u,Math.max(55,h+8))},[c,d,f,i,p]),m=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||g||hs,r=Math.max(2,Math.floor(o/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return fs((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:rs(c.y,"exact"===p?Math.max(2,s):Math.min(s,r),p)).map(t=>({value:t,pixel:c.y(t),label:i(t)})),22)},[c,d,g,o,p]),v=h&&c,b=u&&c;if(!v&&!b)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),k=null==d?void 0:d.find(t=>"left"===t.orient),w=b&&(!x||!1!==x.baseline),A=b&&(!k||!1!==k.baseline),S=(null==x?void 0:x.jaggedBase)||!1,M=(null==k?void 0:k.jaggedBase)||!1,_="var(--semiotic-border, #ccc)";return t("svg",{width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${l.left},${l.top})`,children:[v&&(()=>{var n,r;const s=cs(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),a=cs(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[y.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"xgrid-"+n)),m.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:a},"ygrid-"+n))]})})(),w&&!S&&t("line",{x1:0,y1:o,x2:i,y2:o,stroke:_,strokeWidth:1}),S&&t("path",{d:us("bottom",i,o),fill:"none",stroke:_,strokeWidth:1}),A&&!M&&t("line",{x1:0,y1:0,x2:0,y2:o,stroke:_,strokeWidth:1}),M&&t("path",{d:us("left",i,o),fill:"none",stroke:_,strokeWidth:1})]})})}function hs(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function fs(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function gs(s){var a,c;const{width:d,height:h,totalWidth:f,totalHeight:g,margin:p,scales:y,showAxes:m,axes:v,xLabel:b,yLabel:x,yLabelRight:k,xFormat:w,yFormat:A,axisExtent:S,showGrid:M,title:_,legend:P,legendHoverBehavior:O,legendClickBehavior:T,legendHighlightedCategory:$,legendIsolatedCategories:j,legendPosition:L="right",legendLayout:C,foregroundGraphics:z,marginalGraphics:D,xValues:E,yValues:N,annotations:R,autoPlaceAnnotations:F,svgAnnotationRules:W,xAccessor:B,yAccessor:I,annotationData:Y,pointNodes:G,curve:H,underlayRendered:X,canvasObscuresUnderlay:q=!0,linkedCrosshairName:V,linkedCrosshairSourceId:U,children:Z}=s,Q=r(()=>{var t,e;if(!m||!y)return[];const n=null==v?void 0:v.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||w||hs,o=Math.max(2,Math.floor(d/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,s=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:rs(y.x,"exact"===S?Math.max(2,r):Math.min(r,o),S),a=s.map(t=>t.valueOf()),l=s.map((t,e)=>({value:t,pixel:y.x(t),label:i(t,e,a)})),c=l.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),u=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(c+8,55)):Math.max(55,c+8);let h=fs(l,u);if(h.length>1&&(h=h.filter((t,e)=>0===e||t.label+""!=h[e-1].label+"")),(null==n?void 0:n.includeMax)&&h.length>0&&"exact"!==S&&!(null==n?void 0:n.tickValues)){const t=y.x.domain()[1],e=y.x(t),n=h[h.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t,h.length,a);u>e-n&&h.length>1&&(h=h.slice(0,-1)),h.push({value:t,pixel:e,label:o})}}return h},[m,y,v,w,d,S]),tt=r(()=>{var t,e;if(!m||!y)return[];const n=null==v?void 0:v.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||A||hs,o=Math.max(2,Math.floor(h/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=fs((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:rs(y.y,"exact"===S?Math.max(2,r):Math.min(r,o),S)).map(t=>({value:t,pixel:y.y(t),label:i(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"!==S&&!(null==n?void 0:n.tickValues)){const t=y.y.domain()[1],e=y.y(t),n=s[s.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:o})}}return s},[m,y,v,A,h,S]),et=r(()=>{var t,e;if(!m||!y)return[];const n=null==v?void 0:v.find(t=>"right"===t.orient);if(!n)return[];const i=n.tickFormat||A||hs,o=Math.max(2,Math.floor(h/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return fs((null!==(e=n.tickValues)&&void 0!==e?e:rs(y.y,"exact"===S?Math.max(2,r):Math.min(r,o),S)).map(t=>({value:t,pixel:y.y(t),label:i(t)})),22)},[m,y,v,A,h,S]),nt=o(new Map),it=o(null!==(a=null==R?void 0:R.length)&&void 0!==a?a:0),ot=null!==(c=null==R?void 0:R.length)&&void 0!==c?c:0;it.current!==ot&&(it.current=ot,nt.current=new Map);const rt=r(()=>{if(!R||0===R.length)return null;const n=function(n,o,r){var s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,M,_,P,O,T,$,j,L,C,z,D,E,N,R,F,W,B,I,Y,G,H,X,q,V,U,Z,Q,tt,et,nt,it,ot;switch(n.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const e=oo(n,o,r);if(!e)return null;const{x:i,y:c}=e;if(!ro(i,c,r))return null;const u="callout"===n.type?"callout-circle":n.type,d="callout-circle"===u?{radius:null!==(s=n.radius)&&void 0!==s?s:12,radiusPadding:n.radiusPadding}:"callout-rect"===u?{width:n.width,height:n.height}:void 0;return t(qi,{noteData:Object.assign(Object.assign({x:i,y:c,dx:null!==(a=n.dx)&&void 0!==a?a:30,dy:null!==(l=n.dy)&&void 0!==l?l:-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:u},d?{subject:d}:{}),{connector:n.connector||{end:"arrow"},color:n.color,disable:n.disable,opacity:n.opacity,strokeDasharray:n.strokeDasharray,className:n.className})},"ann-"+o)}case"x-threshold":{const i=to(null!=n.value?Object.assign(Object.assign({},n),{x:n.value}):n,r);if(null==i)return null;const s=n.color||"#f97316",a=n.labelPosition||"top";let l;return l="bottom"===a?(r.height||0)-4:"center"===a?(r.height||0)/2:12,e("g",{children:[t("line",{x1:i,y1:0,x2:i,y2:r.height||0,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:i+4,y:l,fill:s,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+o)}case"y-threshold":{const i=eo(null!=n.value?Object.assign(Object.assign({},n),{y:n.value}):n,r);if(null==i)return null;const s=n.color||"#f97316",a=n.labelPosition||"right";let l,c;return"left"===a?(l=4,c="start"):"center"===a?(l=(r.width||0)/2,c="middle"):(l=(r.width||0)-4,c="end"),e("g",{children:[t("line",{x1:0,y1:i,x2:r.width||0,y2:i,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:l,y:i-4,textAnchor:c,fill:s,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+o)}case"enclose":{const i=(n.coordinates||[]).map(t=>({x:to(Object.assign(Object.assign({},t),{type:"point"}),r),y:eo(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const s=at(i),a=n.padding||10;return e("g",{children:[t("circle",{cx:s.x,cy:s.y,r:s.r+a,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:s.x,y:s.y-s.r-a-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+o)}case"rect-enclose":{const i=(n.coordinates||[]).map(t=>({x:to(Object.assign(Object.assign({},t),{type:"point"}),r),y:eo(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const s=n.padding||10,a=i.map(t=>t.x),l=i.map(t=>t.y),c=Math.min(...a)-s,u=Math.max(...a)+s,d=Math.min(...l)-s,h=Math.max(...l)+s;return e("g",{children:[t("rect",{x:c,y:d,width:u-c,height:h-d,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+o)}case"highlight":{const e=r.data||[],i="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],s={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:i.map((e,i)=>{const o=to(e,r),a=eo(e,r);if(null==o||null==a)return null;const l="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||s;return t("circle",Object.assign({cx:o,cy:a,r:l},c),"hl-"+i)})},"ann-"+o)}case"bracket":{const e=to(n,r),i=eo(n,r);return t(qi,{noteData:{x:null!=e?e:0,y:null!=i?i:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+o)}case"trend":{const i=r.data||[];if(2>i.length)return null;const s=r.xAccessor||"x",a=r.yAccessor||"y",l="ordinal"===r.frameType,y="horizontal"===r.projection,m=l?s:null,v=l?a:null;let b;const x=[],k=new Map;if(l&&m&&v){for(const t of i){const e=t[m];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,x.length),x.push(n))}b=i.map(t=>{const e=t[m],n=t[v];if(null==e||null==n)return null;const i=k.get(e+"");return null!=i?[i,+n]:null}).filter(t=>null!==t)}else b=i.map(t=>[t[s],t[a]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>b.length)return null;const w=null!==(u=null===(c=r.scales)||void 0===c?void 0:c.x)&&void 0!==u?u:null===(d=r.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=r.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=r.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)),i=Math.min(x.length-1,n+1),o=e-n,r=t(x[n]);return r+(t(x[i])-r)*o},M=w,_=A;let P;if(l)if(y){const t=S(_);P=(e,n)=>[M(n),t(e)]}else{const t=S(M);P=(e,n)=>[t(e),_(n)]}else P=(t,e)=>[M(t),_(e)];const O=n.method||"linear";let T;T="loess"===O?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),l=i.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:i[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*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const p=u*f-d*d;if(1e-12>Math.abs(p))a.push([e,h/u]);else{const t=(u*g-d*h)/p;a.push([e,(h-t*d)/u+t*e])}}return a}(b,null!==(p=n.bandwidth)&&void 0!==p?p:.3):("polynomial"===O?wt.polynomial(b,{order:n.order||2}):wt.linear(b)).points;const $=T.map(([t,e])=>{const[n,i]=P(t,e);return`${n},${i}`}).join(" "),j=n.color||"#6366f1",L=T[T.length-1],[C,z]=P(L[0],L[1]);return e("g",{children:[t("polyline",{points:$,fill:"none",stroke:j,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:C+4,y:z-4,fill:j,fontSize:11,children:n.label})]},"ann-"+o)}case"band":{const i=null!==(m=null===(y=r.scales)||void 0===y?void 0:y.y)&&void 0!==m?m:null===(v=r.scales)||void 0===v?void 0:v.value,s=null!==(b=null==i?void 0:i(n.y0))&&void 0!==b?b:0,a=null!==(x=null==i?void 0:i(n.y1))&&void 0!==x?x:r.height||0;return e("g",{children:[t("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(r.width||0)-4,y:Math.min(s,a)-4,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:n.label})]},"ann-"+o)}case"envelope":{const i=r.data||[];if(2>i.length)return null;const s=r.xAccessor||"x",a=null!==(w=null===(k=r.scales)||void 0===k?void 0:k.x)&&void 0!==w?w:null===(A=r.scales)||void 0===A?void 0:A.time,l=null!==(M=null===(S=r.scales)||void 0===S?void 0:S.y)&&void 0!==M?M:null===(_=r.scales)||void 0===_?void 0:_.value;if(!a||!l)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.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=Vr[r.curve||"linear"]||J,g=K().x(t=>a(t[s])).y0(t=>l(t[u])).y1(t=>l(t[c])).curve(f)(h);if(!g)return null;const p=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:p,fillOpacity:null!==(P=n.fillOpacity)&&void 0!==P?P:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:a(h[h.length-1][s])+4,y:l(h[h.length-1][c])-4,fill:p,fontSize:11,children:n.label})]},"ann-"+o)}case"anomaly-band":{const i=r.data||[];if(2>i.length)return null;const s=r.yAccessor||"y",a=null!==(T=null===(O=r.scales)||void 0===O?void 0:O.x)&&void 0!==T?T:null===($=r.scales)||void 0===$?void 0:$.time,l=null!==(L=null===(j=r.scales)||void 0===j?void 0:j.y)&&void 0!==L?L:null===(C=r.scales)||void 0===C?void 0:C.value;if(!a||!l)return null;const c=i.map(t=>t[s]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==(z=n.threshold)&&void 0!==z?z:2,g=u-f*h,p=!1!==n.showBand,y=n.fill||"#6366f1",m=null!==(D=n.fillOpacity)&&void 0!==D?D:.1,v=n.anomalyColor||"#ef4444",b=null!==(E=n.anomalyRadius)&&void 0!==E?E:6,x=l(u+f*h),k=l(g),w=i.filter(t=>{const e=t[s];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[p&&t("rect",{x:0,y:Math.min(x,k),width:r.width||0,height:Math.abs(k-x),fill:y,fillOpacity:m}),w.map((e,n)=>{const i=to(e,r),o=eo(e,r);return null==i||null==o?null:t("circle",{cx:i,cy:o,r:b,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(r.width||0)-4,y:Math.min(x,k)-4,textAnchor:"end",fill:y,fontSize:11,children:n.label})]},"ann-"+o)}case"forecast":{const i=r.data||[];if(3>i.length)return null;const s=r.xAccessor||"x",a=r.yAccessor||"y",l=null!==(R=null===(N=r.scales)||void 0===N?void 0:N.x)&&void 0!==R?R:null===(F=r.scales)||void 0===F?void 0:F.time,c=null!==(B=null===(W=r.scales)||void 0===W?void 0:W.y)&&void 0!==B?B:null===(I=r.scales)||void 0===I?void 0:I.value;if(!l||!c)return null;const u=i.map(t=>[t[s],t[a]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=wt.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=u.length;let e=0,n=0,i=0,o=0;for(const[t,r]of u)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,a=(n-s*e)/t;d=t=>a+s*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),p=u.reduce((t,e)=>t+e[0],0)/h,y=u.reduce((t,e)=>t+Math.pow(e[0]-p,2),0),m=null!==(Y=n.confidence)&&void 0!==Y?Y:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(G=n.steps)&&void 0!==G?G:5,x=u[h-1][0],k=(x-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;b>=t;t++)w.push(x+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(y>0?Math.pow(t-p,2)/y:0))*v;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${c(t.yLower)}`).join(" L")} Z`,M=A.map(t=>`${l(t.x)},${c(t.yCenter)}`).join(" "),_=`${l(x)},${c(d(x))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:S,fill:n.fill||"#6366f1",fillOpacity:null!==(H=n.fillOpacity)&&void 0!==H?H:.15,stroke:"none"}),t("polyline",{points:`${_} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(X=n.strokeWidth)&&void 0!==X?X:2,strokeDasharray:null!==(q=n.strokeDasharray)&&void 0!==q?q:"6,3"}),n.label&&A.length>0&&t("text",{x:l(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+o)}case"widget":{let e=null,i=null;if(null!=n.px&&null!=n.py)e=n.px,i=n.py;else{const t=oo(n,o,r);if(!t)return null;e=t.x,i=t.y}if(null==e||null==i)return null;if(!ro(e,i,r))return null;const s=null!==(V=n.dx)&&void 0!==V?V:0,a=null!==(U=n.dy)&&void 0!==U?U:0,l=null!==(Z=n.width)&&void 0!==Z?Z:32,c=null!==(Q=n.height)&&void 0!==Q?Q:32,u=null!==(tt=n.content)&&void 0!==tt?tt:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+s-l/2,y:i+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const s=oo(n,o,r);if(!s)return null;const{x:a,y:l}=s,c=a+(n.dx||0),u=l+(n.dy||0),d=n.color||"var(--semiotic-text, #333)",h=t("text",{x:c,y:u,fill:d,fontSize:n.fontSize||11,opacity:n.opacity,strokeDasharray:n.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label});return!0!==n._redundantConnector?i.cloneElement(h,{key:"ann-text-"+o}):e("g",{opacity:n.opacity,strokeDasharray:n.strokeDasharray,children:[t("line",{x1:a,y1:l,x2:c,y2:u,stroke:d,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),i.cloneElement(h,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+o)}case"category-highlight":{const i=n.category;if(null==i)return null;const s=t=>"function"==typeof t&&"function"==typeof t.bandwidth,a=null===(et=r.scales)||void 0===et?void 0:et.o,l=null===(nt=r.scales)||void 0===nt?void 0:nt.x,c=null===(it=r.scales)||void 0===it?void 0:it.y,u=s(a)?a:s(l)?l:s(c)?c:null;if(!u)return null;const d=u(i+"");if(null==d)return null;const h=u.bandwidth(),f=n.color||"var(--semiotic-primary, #4589ff)",g=null!==(ot=n.opacity)&&void 0!==ot?ot:.15,p=n.label;return e("g",(r.projection?"vertical"===r.projection:u===l)?{children:[t("rect",{x:d,y:0,width:h,height:r.height||0,fill:f,fillOpacity:g}),p&&t("text",{x:d+h/2,y:12,textAnchor:"middle",fill:f,fontSize:12,fontWeight:"bold",children:p})]}:{children:[t("rect",{x:0,y:d,width:r.width||0,height:h,fill:f,fillOpacity:g}),p&&t("text",{x:12,y:d+h/2,dominantBaseline:"middle",fill:f,fontSize:12,fontWeight:"bold",children:p})]},"ann-"+o)}default:return null}},o={scales:y?{x:y.x,y:y.y,time:y.x,value:y.y}:null,timeAxis:"x",xAccessor:B,yAccessor:I,width:d,height:h,data:Y,frameType:"xy",pointNodes:G,curve:H,stickyPositionCache:nt.current};return function(t,e,n,i){const o=[];return t.forEach((t,r)=>{let s;if(n){const o=n(t,r,i);s=null!=o?o:e(t,r,i)}else s=e(t,r,i);s&&o.push({node:s,annotation:t})}),Ji(o)}(F?So(Object.assign({annotations:R,context:o},"object"==typeof F?F:{})):R,n,W,o)},[R,F,W,d,h,B,I,Y,y,G,H]),st=function(t){var e;const n=l(t?es:is,t?ts:os,t?ts:os);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(V);return u(()=>{if(!(null==st?void 0:st.locked)||!V)return;const t=t=>{"Escape"===t.key&&Jr(V)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==st?void 0:st.locked,V]),m||_||P||z||D||rt&&rt.length>0||M||Z||st?e("svg",{role:"img",width:f,height:g,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof _?_:"XY Chart"}),t("desc",{children:"string"==typeof _?_+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${p.left},${p.top})`,children:[M&&y&&(!X||q)&&(()=>{var n,i;const o=cs(null===(n=null==v?void 0:v.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=cs(null===(i=null==v?void 0:v.find(t=>"left"===t.orient))||void 0===i?void 0:i.gridStyle);return e("g",{className:"stream-grid",children:[Q.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:h,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),tt.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:d,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),m&&y&&(()=>{const n=null==v?void 0:v.find(t=>"left"===t.orient),i=null==v?void 0:v.find(t=>"bottom"===t.orient),o=!n||!1!==n.baseline,r=!i||!1!==i.baseline,s=(null==n?void 0:n.jaggedBase)||!1,a=(null==i?void 0:i.jaggedBase)||!1,l=null==i?void 0:i.landmarkTicks,c=null==n?void 0:n.landmarkTicks,u="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",y=!!(null==i?void 0:i.autoRotate)&&Q.length>1&&(()=>{const t=d/Math.max(Q.length-1,1),e=Q.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})(),m={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=null==i?void 0:i.tickAnchor,M=null==n?void 0:n.tickAnchor,_=ls(Q),P=ls(tt);return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!X||q)&&r&&!a&&t("line",{x1:0,y1:h,x2:d,y2:h,stroke:u,strokeWidth:1}),(!X||q)&&a&&t("path",{d:us("bottom",d,h),fill:"none",stroke:u,strokeWidth:1}),Q.map((n,i)=>{const o=!!l&&("function"==typeof l?l(n.value,i):ur(n.value,i>0?Q[i-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${h})`,children:[t("line",{y2:5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:y?10:18,textAnchor:y?"end":ss(S,n.pixel===_.min,n.pixel===_.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w:m),transform:y?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"center",userSelect:"none"},m),children:n.label})})]},"xtick-"+i)}),b&&t("text",{x:d/2,y:h+40,textAnchor:"middle",fill:g,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:b})]}),e("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!X||q)&&o&&!s&&t("line",{x1:0,y1:0,x2:0,y2:h,stroke:u,strokeWidth:1}),(!X||q)&&s&&t("path",{d:us("left",d,h),fill:"none",stroke:u,strokeWidth:1}),tt.map((n,i)=>{const o=!!c&&("function"==typeof c?c(n.value,i):ur(n.value,i>0?tt[i-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:as(M,n.pixel===P.min,n.pixel===P.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w:m),children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"right",userSelect:"none"},m),children:n.label})})]},"ytick-"+i)}),(()=>{const e=(null==n?void 0:n.label)||x;return e?t("text",{x:15-p.left,y:h/2,textAnchor:"middle",fill:g,transform:`rotate(-90, ${15-p.left}, ${h/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:e}):null})()]}),(()=>{const n=null==v?void 0:v.find(t=>"right"===t.orient);if(!n||0===et.length)return null;const i=!1!==n.baseline,o=n.landmarkTicks,r=n.label||k,s=n.tickAnchor,a=ls(et);return e("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&t("line",{x1:d,y1:0,x2:d,y2:h,stroke:u,strokeWidth:1}),et.map((n,i)=>{const r=!!o&&("function"==typeof o?o(n.value,i):ur(n.value,i>0?et[i-1].value:void 0));return e("g",{transform:`translate(${d},${n.pixel})`,children:[t("line",{x2:5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:as(s,n.pixel===a.min,n.pixel===a.max),fontWeight:r?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},r?w:m),children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"left",userSelect:"none"},m),children:n.label})})]},"ytick-r-"+i)}),r&&t("text",{x:d+p.right-15,y:h/2,textAnchor:"middle",fill:g,transform:`rotate(90, ${d+p.right-15}, ${h/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:r})]})})()]})})(),rt,D&&y&&E&&N&&e(n,{children:[D.top&&t("g",{transform:"translate(0, 0)",children:t(qr,{orient:"top",config:Xr(D.top),values:E,scale:y.x,size:p.top,length:d})}),D.bottom&&t("g",{transform:`translate(0, ${h})`,children:t(qr,{orient:"bottom",config:Xr(D.bottom),values:E,scale:y.x,size:p.bottom,length:d})}),D.left&&t("g",{transform:"translate(0, 0)",children:t(qr,{orient:"left",config:Xr(D.left),values:N,scale:y.y,size:p.left,length:h})}),D.right&&t("g",{transform:`translate(${d}, 0)`,children:t(qr,{orient:"right",config:Xr(D.right),values:N,scale:y.y,size:p.right,length:h})})]}),z,st&&st.sourceId!==U&&(null==y?void 0:y.x)&&(()=>{const e=y.x(st.xValue);if(null==e||0>e||e>d)return null;const n=st.locked;return t("line",{x1:e,y1:0,x2:e,y2:h,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"})})(),Z]}),_&&t("text",{x:f/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 _?_:null}),Hr({legend:P,totalWidth:f,totalHeight:g,margin:p,legendPosition:L,title:_,legendLayout:C,legendHoverBehavior:O,legendClickBehavior:T,legendHighlightedCategory:$,legendIsolatedCategories:j})]}):null}const ps="undefined"!=typeof window?h:u,ys=()=>()=>{},ms=()=>!1,vs=()=>!0;function bs(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}function xs(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 ks(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 ws=i.createContext(null),As={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ss(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 i=[],o={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),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}const Ms=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""};function _s(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,i]of Object.entries(t))n.startsWith("_")||null!=i&&""!==i&&("number"==typeof i?Number.isFinite(i)&&(e[n]=i):"string"==typeof i?e[n]=i:"boolean"==typeof i?e[n]=i+"":i instanceof Date&&(e[n]=i.toISOString().slice(0,10)));return e}const Ps="semiotic-accessible-data-table",Os=Ps+" semiotic-accessible-data-table-hidden",Ts=Ps+" semiotic-accessible-data-table-visible",$s={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"},js={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Ls={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)"},Cs={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},zs={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))"},Ds={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Es={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ns={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 Rs({scene:n,chartType:o,tableId:r,chartTitle:s}){var a;const[l,c]=i.useState(!1),[u,d]=i.useState(5),h=i.useContext(ws),f=null!==(a=null==h?void 0:h.visible)&&void 0!==a&&a,g=l||f,p=i.useRef(null),y=s?"Data summary for "+s:r?`Data summary for ${o} ${r}`:"Data summary for "+o;i.useEffect(()=>{g||d(5)},[g]);const m=i.useCallback(t=>{t.target===t.currentTarget&&(l||f||c(!0))},[l,f]),v=i.useCallback(t=>{var e;f||(null===(e=p.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[f]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:As}):null;if(!g)return t("div",{id:r,className:Os,tabIndex:-1,onFocus:m,style:As,role:"region","aria-label":y,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const b=function(t){var e,n,i,o,r,s,a,l,c,u,d,h,f,g,p,y,m;const v=[];if(!Array.isArray(t))return v;const b=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const x of t)if(x&&"object"==typeof x&&null!==x.datum)try{switch(x.type){case"point":if(b)break;v.push({label:"Point",values:_s(x.datum)});break;case"line":case"area":{const t=Array.isArray(x.datum)?x.datum:[],e="line"===x.type?"Line point":"Area point";for(const n of t)v.push({label:e,values:_s(n)});break}case"rect":{const t=null!=x.datum&&"object"==typeof x.datum?x.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:x.group)&&void 0!==n?n:"",s=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;v.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":{const t=_s(x.datum);null==t.value&&"number"==typeof x.value&&Number.isFinite(x.value)&&(t.value=x.value),v.push({label:"Cell",values:t});break}case"wedge":v.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=x.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=x.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=x.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":v.push({label:"Node",values:_s(x.datum)});break;case"arc":v.push({label:"Arc",values:_s(x.datum)});break;case"candlestick":v.push({label:"Candlestick",values:_s(x.datum)});break;case"geoarea":v.push({label:"Region",values:{name:null!==(p=null!==(f=null===(h=null===(d=x.datum)||void 0===d?void 0:d.properties)||void 0===h?void 0:h.name)&&void 0!==f?f:null===(g=x.datum)||void 0===g?void 0:g.name)&&void 0!==p?p:"",value:null!==(m=null===(y=x.datum)||void 0===y?void 0:y.value)&&void 0!==m?m:""}})}}catch(t){}return v}(n),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 i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(b),k=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Ms(t.min)} to ${Ms(t.max)}, mean ${Ms(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(b.length,x),w=Math.min(u,b.length),A=b.slice(0,w),S=b.length-w,M=new Set;for(const t of A)for(const e of Object.keys(t.values))M.add(e);const _=Array.from(M);return e("div",{ref:p,id:r,className:Ts,tabIndex:-1,onBlur:v,style:$s,role:"region","aria-label":y,children:[t("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{f&&h&&h.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:Ls,children:"×"}),t("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:js,children:k}),e("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+o,style:Cs,children:[t("caption",{className:"semiotic-accessible-data-table-caption",style:Es,children:S>0?`First ${w} of ${b.length} data points`:`All ${b.length} data points`}),t("thead",{children:e("tr",{children:[t("th",{style:zs,children:"type"}),_.map(e=>t("th",{style:zs,children:e},e))]})}),t("tbody",{children:A.map((n,i)=>e("tr",{children:[t("td",{style:Ds,children:n.label}),_.map(e=>{return t("td",{style:Ds,children:(i=n.values[e],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":Ms(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},e);var i})]},i))})]}),S>0&&e("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>d(t=>t+25),style:Ns,children:["Show ",Math.min(25,S)," more"," ",1===S?"row":"rows"," (",S," remaining)"]})]})}function Fs({summary:e}){return e?t("div",{role:"note",style:As,children:e}):null}function Ws({tableId:e}){return t("a",{href:"#"+e,style:As,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,As)},children:"Skip to data table"})}function Bs({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("div",{"aria-live":"polite","aria-atomic":"true",style:As,children:n})}const Is="var(--semiotic-focus, #005fcc)";function Ys({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:s,height:a}){if(!e||!n)return null;const l=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=s&&null!=a){const e=Math.max(s,4),n=Math.max(a,4);u=t("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Is,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Is,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Is,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Gs({x:e,y:n,containerWidth:o,containerHeight:r,margin:s,children:a,className:l="stream-frame-tooltip",zIndex:c=1}){const u=Number.isFinite(e)&&Number.isFinite(n),d=i.useRef(null),[h,f]=i.useState(null);i.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=t.getBoundingClientRect();f(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[a,l,o,r]);let g;g=h?`translate(${h.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const p=function(t){if(!i.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}(a),y=p?null:Ko;return u?t("div",{ref:d,className:p?l:(l+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:s.left+e,top:s.top+n,transform:g,pointerEvents:"none",zIndex:c,width:"max-content"}),children:a}):null}const Hs="undefined"==typeof window?u:h;function Xs(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function qs(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return u(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(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=>e(t.matches))},[]),t}(),n=o(e);n.current=e;const[s,l]=function(t,e,n){const i=o(null),[r,s]=d(null);return u(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=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 o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),c=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=l[0]-c.left-c.right,f=l[1]-c.top-c.bottom,g=Xs(t.foregroundGraphics,l,c),p=Xs(t.backgroundGraphics,l,c),y=Ti(t=>t.theme),{transition:m,introEnabled:v}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="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!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),b="semiotic-table-"+i.useId(),x=o(0),k=o(()=>{}),w=a(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);u(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const A=o(()=>{}),S=o(()=>{}),M=o(null),_=o(0),P=a(()=>{_.current=0;const t=M.current;M.current=null,t&&A.current(t)},[]),O=a(t=>{M.current={clientX:t.clientX,clientY:t.clientY},0===_.current&&(_.current=requestAnimationFrame(P))},[P]),T=a(()=>{M.current=null,0!==_.current&&(cancelAnimationFrame(_.current),_.current=0),S.current()},[]);u(()=>()=>{M.current=null,0!==_.current&&(cancelAnimationFrame(_.current),_.current=0)},[]);const $=t.themeDirtyRef;return Hs(()=>{$&&(fr++,$.current=!0,w())},[y,w,$]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:l,margin:c,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:p,currentTheme:y,transition:m,introEnabled:v,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:S,onPointerMove:O,onPointerLeave:T}}function Vs(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,s=e[1]*i,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),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function Us(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Zs(t,e,n,i,o,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],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;l>i&&(r*=i/l),l>a-i&&(r*=(a-i)/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 Qs=(t,e,n,i)=>{var o,r;const s=e.filter(t=>"line"===t.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,i.width*l,i.height),t.clip());const c=a.style.stroke||"#007bff",u=vr(t,c)||c,d=a.style.strokeWidth||2,h=a.colorThresholds,f=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=d,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(o=a.style.opacity)&&void 0!==o?o:1;Zs(t,a.path,u,d,m,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=br(a.curve),p=h&&h.length>0&&f&&f.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){t.strokeStyle=u;const v=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(y[b]+y[b+1])*v,t.beginPath(),t.moveTo(a.path[b][0],a.path[b][1]),t.lineTo(a.path[b+1][0],a.path[b+1][1]),t.stroke()}else if(p){let x=null,k=null,w=null,A=null,S=!1;function M(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),S=!0}function _(){S&&(t.stroke(),S=!1)}for(let P=0;a.path.length>P;P++){const[O,T]=a.path[P],$=f[P],j=Us($,h,u);if(null!==x&&null!==A&&null!==w){if(j===A)t.lineTo(O,T);else{const L=[];for(const C of h){const z=C.value;(w>z||z>$)&&(z>w||$>z)||w===z||$===z||L.push({t:(z-w)/($-w)})}L.sort((t,e)=>t.t-e.t);for(const D of L){const E=x+(O-x)*D.t,N=k+(T-k)*D.t,R=Us(w+($-w)*Math.min(D.t+1e-4,1),h,u);t.lineTo(E,N),_(),M(R,E,N)}t.lineTo(O,T)}x=O,k=T,w=$,A=j}else M(j,O,T),x=O,k=T,w=$,A=j}_()}else{t.beginPath();const F=a.strokeGradient&&a.path.length>=2?wr(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=F||u,g)Q().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[W,B]=a.path[0];t.moveTo(W,B);for(let I=1;a.path.length>I;I++)t.lineTo(a.path[I][0],a.path[I][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=xr(t,a.style.fill,a.style.fill),g&&!p)Q().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[G,H]=a.path[0];t.moveTo(G,H);for(let X=1;a.path.length>X;X++)t.lineTo(a.path[X][0],a.path[X][1])}const Y=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],i.height),t.lineTo(Y,i.height),t.closePath(),t.fill()}void 0!==l&&1>l&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Ks(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Js(t,e,n=.3){Ks(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 ta(t,e,n=.6){var i,o,r,s,a;if(!Ks(e))return;const l=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+l*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o: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 ea(t,e,n,i=.35){Ks(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function na(t,e){const n=br(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 i=K().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const ia=(t,e,n,i)=>{var o,r,s;const a=e.filter(t=>"area"===t.type);for(const e of a){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 a=e._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const l=xr(t,e.style.fill,"#4e79a7"),c=e._decayOpacities;if(c&&c.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=l;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(c[i]+c[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=vr(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*(c[n]+c[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 u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(na(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 i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=kr(t,e.fillGradient,"string"==typeof l?l:"#4e79a7",0,n,0,i);t.fillStyle=o||l,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(na(t,e),ea(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=u;const n=e.strokeGradient&&e.topPath.length>=2?wr(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||vr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=br(e.curve);if(t.beginPath(),i)Q().x(t=>t[0]).y(t=>t[1]).curve(i).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!==a&&1>a&&t.restore(),n&&t.restore(),t.globalAlpha=1}},oa=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=xr(t,e.style.fill,"#4e79a7"),t.fill(),e.style.stroke&&(t.strokeStyle=xr(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth||1,t.stroke()),ta(t,e),t.globalAlpha=1}}finally{t.restore()}}};function ra(t,e){const{x:n,y:i,w:o,h:r}=e,{tl:s,tr:a,br:l,bl:c}=ui(e);t.beginPath(),t.moveTo(n+s,i),t.lineTo(n+o-a,i),a>0&&t.arcTo(n+o,i,n+o,i+a,a),t.lineTo(n+o,i+r-l),l>0&&t.arcTo(n+o,i+r,n+o-l,i+r,l),t.lineTo(n+c,i+r),c>0&&t.arcTo(n,i+r,n,i+r-c,c),t.lineTo(n,i+s),s>0&&t.arcTo(n,i,n+s,i,s),t.closePath()}function sa(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 aa=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)la(t,e);else if(e.cornerRadii&&ci(e.cornerRadii)){const n=xr(t,e.style.fill,vr(t,"var(--semiotic-primary, #007bff)")),i=sa(e),o=e.fillGradient&&"string"==typeof n?kr(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,ra(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=vr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=xr(t,e.style.fill,vr(t,"var(--semiotic-primary, #007bff)")),i=sa(e),o=e.fillGradient&&"string"==typeof n?kr(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||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=vr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=xr(t,e.style.fill,vr(t,"var(--semiotic-primary, #007bff)")),i=sa(e),o=e.fillGradient&&"string"==typeof n?kr(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=vr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Js(t,e),t.globalAlpha=1}};function la(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)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=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function ca(t){const[e,n,i]=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*i>128?"#000":"#fff"}function ua(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const da=(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){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=vr(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Js(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):ua(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=ca(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},ha=(t,e,n,i)=>{var o,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const a=(null!==(o=e._decayOpacity)&&void 0!==o?o: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=vr(t,e.wickColor)||e.wickColor,c=60>i.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*i.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),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=vr(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}};function fa(t,e,n,i){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:i,fn:e}:{key:void 0,fn:null}}const ga=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function pa(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`${ga[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${ga[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const ya={line:[ia,Qs,oa],area:[ia,oa],stackedarea:[ia,oa],scatter:[oa],bubble:[oa],heatmap:[da],bar:[aa],swarm:[oa],waterfall:[(t,e,n,i)=>{var o;aa(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=vr(t,a)||a,t.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const i=r[e],o=r[e+1],s=i.datum,a=o.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[ha],mixed:[ia,Qs,oa],custom:[ia,aa,da,Qs,oa,ha]},ma={top:20,right:20,bottom:30,left:40},va={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 ba(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const xa={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 ka({hover:n}){var i,o,r;const s=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",a=null!==(i=n.data)&&void 0!==i?i:{},l=null!==(o=a.y)&&void 0!==o?o:a.value,c=null!==(r=a.x)&&void 0!==r?r:a.time;return e("div",{className:"semiotic-tooltip",style:xa,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:s(l)}),t("div",{style:{opacity:.7,fontSize:11},children:s(c)})]})}ka.ownsChrome=!0;const wa=f(function(n,s){var c,h,f,y,m,v,b,x,k,w,A,S,M;const{chartType:_,runtimeMode:P,data:O,chunkThreshold:T,chunkSize:$,xAccessor:j,yAccessor:L,colorAccessor:C,sizeAccessor:z,groupAccessor:D,lineDataAccessor:E,curve:N,normalize:R,baseline:F,stackOrder:W,binSize:B,valueAccessor:I,arrowOfTime:Y="right",windowMode:G="sliding",windowSize:H=200,timeAccessor:X,xExtent:q,yExtent:V,extentPadding:U=.1,scalePadding:Z,sizeRange:Q,size:K=[500,300],responsiveWidth:J,responsiveHeight:tt,margin:et,className:nt,background:it,lineStyle:ot,pointStyle:rt,areaStyle:st,barStyle:at,waterfallStyle:lt,swarmStyle:ct,barColors:ut,colorScheme:dt,boundsAccessor:ht,boundsStyle:ft,y0Accessor:gt,band:pt,gradientFill:yt,lineGradient:mt,areaGroups:vt,openAccessor:bt,highAccessor:xt,lowAccessor:kt,closeAccessor:wt,candlestickStyle:At,showAxes:St=!0,axes:Mt,xLabel:_t,yLabel:Pt,yLabelRight:Ot,xFormat:Tt,yFormat:$t,axisExtent:jt,tickFormatTime:Lt,tickFormatValue:Ct,hoverAnnotation:zt,tooltipContent:Dt,customHoverBehavior:Et,customClickBehavior:Nt,enableHover:Rt,hoverRadius:Ft=30,tooltipMode:Wt,annotations:Bt,autoPlaceAnnotations:It,svgAnnotationRules:Yt,showGrid:Gt,legend:Ht,legendHoverBehavior:Xt,legendClickBehavior:qt,legendHighlightedCategory:Vt,legendIsolatedCategories:Ut,legendPosition:Zt,legendLayout:Qt,legendCategoryAccessor:Kt,onCategoriesChange:Jt,backgroundGraphics:te,foregroundGraphics:ee,canvasPreRenderers:ne,svgPreRenderers:ie,title:oe,categoryAccessor:re,brush:se,onBrush:ae,decay:le,pulse:ce,transition:ue,animate:de,staleness:he,heatmapAggregation:fe,heatmapXBins:ge,heatmapYBins:pe,showValues:ye,heatmapValueFormat:me,marginalGraphics:ve,pointIdAccessor:be,xScaleType:ke,yScaleType:we,accessibleTable:Ae=!0,description:Se,summary:Me,linkedCrosshairName:_e,linkedCrosshairSourceId:Pe,customLayout:Te,layoutConfig:$e}=n,je=g().replace(/:/g,""),Le=o(!1),Ce=qs({sizeProp:K,responsiveWidth:J,responsiveHeight:tt,userMargin:et,marginDefault:ma,animate:de,transitionProp:ue,themeDirtyRef:Le}),ze=function(){const[t,e]=d(!1);return ps(()=>{e(!0)},[]),t}(),De=function(){const t=l(ys,ms,vs);return o(t).current}(),{reducedMotionRef:Ee,responsiveRef:Ne,size:Re,currentTheme:Fe,transition:We,introEnabled:Be,tableId:Ie,rafRef:Ye,renderFnRef:Ge,scheduleRender:He}=Ce;let Xe=Ce.margin;if(ve){const t=60,e=Object.assign({},Ce.margin);ve.top&&t>e.top&&(e.top=t),ve.bottom&&t>e.bottom&&(e.bottom=t),ve.left&&t>e.left&&(e.left=t),ve.right&&t>e.right&&(e.right=t),Xe=e}const qe="function"==typeof ee?ee({size:Re,margin:Xe}):ee,Ve="function"==typeof te?te({size:Re,margin:Xe}):te,Ue=Re[0]-Xe.left-Xe.right,Ze=Re[1]-Xe.top-Xe.bottom,Qe=r(()=>Uo(O),[O]),Ke=null!=zt?zt:Rt,Je=o(null),tn=o(null),[en,nn]=d(0),[on,rn]=d(null),sn=o(null),an=o(null),[ln,cn]=d(null),un=o(va.primary),dn=o([]),hn=o(Kt),fn=o(Jt);hn.current=Kt,fn.current=Jt;const[gn,pn]=d(!1),[yn,mn]=d([]),[vn,bn]=d([]),xn="streaming"===P||["bar","swarm","waterfall"].includes(_),kn=r(()=>{var t,e,n;return{chartType:_,runtimeMode:xn?"streaming":"bounded",windowSize:H,windowMode:G,arrowOfTime:xn?Y:"right",extentPadding:U,scalePadding:Z,axisExtent:jt,xAccessor:j,yAccessor:L,timeAccessor:xn?X:void 0,valueAccessor:I,colorAccessor:C,sizeAccessor:z,groupAccessor:D||(E?"_lineGroup":void 0),categoryAccessor:re,lineDataAccessor:E,xScaleType:ke,yScaleType:we,xExtent:q,yExtent:V,sizeRange:Q,binSize:B,normalize:R,baseline:F,stackOrder:W,boundsAccessor:ht,boundsStyle:ft,y0Accessor:gt,band:pt,gradientFill:!0===yt?{topOpacity:.8,bottomOpacity:.05}:!1===yt?void 0:yt,areaGroups:vt?new Set(vt):void 0,lineGradient:mt,openAccessor:bt,highAccessor:xt,lowAccessor:kt,closeAccessor:wt,candlestickStyle:At,lineStyle:ot,pointStyle:rt,areaStyle:st,swarmStyle:ct,waterfallStyle:lt,colorScheme:dt,barColors:ut,barStyle:at,annotations:Bt,decay:le,pulse:ce,transition:We,introAnimation:Be,staleness:he,heatmapAggregation:fe,heatmapXBins:ge,heatmapYBins:pe,showValues:ye,heatmapValueFormat:me,pointIdAccessor:be,curve:N,themeCategorical:null===(t=null==Fe?void 0:Fe.colors)||void 0===t?void 0:t.categorical,themeSemantic:ki(Fe),themeSequential:null===(e=null==Fe?void 0:Fe.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Fe?void 0:Fe.colors)||void 0===n?void 0:n.diverging,customLayout:Te,layoutConfig:$e,layoutMargin:Xe}},[_,H,G,Y,U,Z,jt,j,L,X,I,ke,we,C,z,D,re,E,q,V,Q,B,R,F,W,ht,ft,gt,pt,yt,mt,vt,bt,xt,kt,wt,At,ot,rt,st,ct,lt,at,dt,ut,Bt,le,ce,null==We?void 0:We.duration,null==We?void 0:We.easing,Be,he,fe,ge,pe,ye,me,xn,be,N,Fe,Te,$e,Xe]),wn=function(t){const e=o(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return xs(t,e);if(!ks(t)||!ks(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;const n=t[i],o=e[i];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!xs(n,o))return!1}else{if(!ks(n)||!ks(o))return!1;if(!bs(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}(kn),An=o(null);An.current||(An.current=new Oe(wn));const Sn=a(()=>{var t,e;const n=hn.current,i=fn.current;if(!i||!n)return;const o=function(t,e){if(!e)return[];const n=new Set,i=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),i.push(r))}return i}(null!==(e=null===(t=An.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})(o,dn.current)||(dn.current=o,i(o))},[]);u(()=>{var t;null===(t=An.current)||void 0===t||t.updateConfig(wn),Le.current=!0,He()},[wn,He]);const Mn=o(null);Mn.current||(Mn.current=new rr(t=>{const e=An.current;e&&e.ingest(t)&&(Le.current=!0,He())},{chunkThreshold:T,chunkSize:$})),u(()=>{var t;null===(t=Mn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:T,chunkSize:$})},[T,$]);const _n=a(t=>{var e;null===(e=Mn.current)||void 0===e||e.push(t)},[]),Pn=a(t=>{var e;null===(e=Mn.current)||void 0===e||e.pushMany(t)},[]),On=a(()=>{var t,e;null===(t=Mn.current)||void 0===t||t.clear(),null===(e=An.current)||void 0===e||e.clear(),Le.current=!0,He()},[He]);p(s,()=>({push:_n,pushMany:Pn,remove:t=>{var e,n,i;null===(e=Mn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=An.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(sn.current&&o.some(t=>{var e;return t===(null===(e=sn.current)||void 0===e?void 0:e.data)})&&(sn.current=null,cn(null)),Le.current=!0,He()),o},update:(t,e)=>{var n,i,o;null===(n=Mn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=An.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(Le.current=!0,He()),r},clear:On,getData:()=>{var t,e,n;return null===(t=Mn.current)||void 0===t||t.flush(),null!==(n=null===(e=An.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=An.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=An.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[_n,Pn,On,He]),u(()=>{var t,e;if(O){if(E&&Qe.length>0&&"object"==typeof Qe[0]&&null!==Qe[0]){const e="string"==typeof E?E:"coordinates";if(Array.isArray(Qe[0][e])){const n=[];for(const t of Qe){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=Mn.current)||void 0===t||t.setBoundedData(n))}}null===(e=Mn.current)||void 0===e||e.setBoundedData(Qe)}},[O,Qe,E]);const{hoverHandlerRef:Tn,hoverLeaveRef:$n,onPointerMove:jn,onPointerLeave:Ln}=Ce;Tn.current=t=>{var e,n,i,o;if(!Ke)return;const r=Je.current;if(!r)return;const s=r.getBoundingClientRect(),a=t.clientX-s.left-Xe.left,l=t.clientY-s.top-Xe.top;if(0>a||a>Ue||0>l||l>Ze)return void(sn.current&&(sn.current=null,an.current=null,cn(null),Et&&(Et(null),Le.current=!0),He()));const c=An.current;if(!c||0===c.scene.length)return;const u=Mr(c.scene,a,l,Ft,c.quadtree,c.maxPointRadius),d="multi"===Wt,h=()=>{sn.current&&(sn.current=null,an.current=null,cn(null),Et&&Et(null),He())};if(!u&&!d)return void h();const f=d||!u?a:u.x,g=d||!u?l:u.y,p=(null==u?void 0:u.datum)?xe(u.datum,c.resolvedRibbons):{},y=null===(n=null===(e=c.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,m="function"==typeof y?y(f):void 0;let v=Qo(p,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 i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=_r(Sr(t.path,t.curve),e,n);if(null===r)continue;const s=zr(t.path,e);i.push({node:o,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"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=Sr(t.topPath,t.curve),s=Sr(t.bottomPath,t.curve),a=_r(r,e,n);if(null===a)continue;const l=_r(s,e,n),c=zr(t.topPath,e);i.push({node:o,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 i}(c.scene,f,Math.max(Ft,Ue));if(t.length>0){const e=c.scales.y.invert,n=un.current,i=y?y(f):f;if(u)v.xValue=i,v.xPx=f;else{const t={xValue:i};"string"==typeof j&&(t[j]=i),v=Qo(t,f,g,{xValue:i,xPx:f})}v.allSeries=t.map(t=>{const i=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===_&&null!=o?i-o:i,valuePx:t.y,color:t.color||n,datum:xe(t.datum,c.resolvedRibbons)}})}}u||(null===(i=v.allSeries)||void 0===i?void 0:i.length)?(sn.current=v,an.current=null!==(o=null==u?void 0:u.node)&&void 0!==o?o:null,cn(v),Et&&(Et(v),Le.current=!0),He()):h()},$n.current=()=>{sn.current&&(sn.current=null,an.current=null,cn(null),Et&&(Et(null),Le.current=!0),He())};const Cn=o(()=>{});Cn.current=t=>{var e,n;if(!Nt)return;const i=Je.current;if(!i)return;const o=i.getBoundingClientRect(),r=t.clientX-o.left-Xe.left,s=t.clientY-o.top-Xe.top;if(0>r||r>Ue||0>s||s>Ze)return void Nt(null);const a=An.current;if(!a||0===a.scene.length)return void Nt(null);const l=Mr(a.scene,r,s,Ft,a.quadtree,a.maxPointRadius);if(!l)return void Nt(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;Nt(Qo(c,l.x,l.y,null!=d?{xValue:d,xPx:l.x}:void 0))};const zn=a(t=>Cn.current(t),[]),Dn=o(-1),En=o(null),Nn=o(null),Rn=a(t=>{const e=An.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Nn.current&&Nn.current.version===n)i=Nn.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.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:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.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!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.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 o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=function(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.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 o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.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:o,byGroup:i,idToIdx:s}}(t),Nn.current={version:n,graph:i}}const o=Dn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Dn.current=0;const n=i.flat[0];En.current={shape:n.shape,w:n.w,h:n.h};const o=Er(Object.assign(Object.assign({},n),{datum:xe(n.datum,e.resolvedRibbons)}));return sn.current=o,cn(o),Et&&Et(o),void He()}const r=function(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}(i,o),s=function(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?Dr(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?Dr(n,n.groups[t-1],r[o]):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,i);if(null===s)return;if(t.preventDefault(),0>s)return Dn.current=-1,En.current=null,sn.current=null,an.current=null,cn(null),Et&&Et(null),void He();Dn.current=s;const a=i.flat[s];En.current={shape:a.shape,w:a.w,h:a.h};const l=Er(Object.assign(Object.assign({},a),{datum:xe(a.datum,e.resolvedRibbons)}));sn.current=l,cn(l),Et&&Et(l),He()},[Et,He]),Fn=a(t=>{Dn.current=-1,En.current=null,jn(t)},[jn]);Ge.current=()=>{var t,e;Ye.current=0;const n=Je.current,i=tn.current;if(!n||!i)return;const o=An.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=o.advanceTransition(Ee.current?r+1e6:r),a=!Ee.current&&s,l=Le.current||s;l&&!a&&(o.computeScene({width:Ue,height:Ze}),Sn());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return va;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||va.axisStroke,tickText:s||va.tickText,crosshair:s?ba(s,"66"):va.crosshair,hoverFill:c?ba(c,"4D"):va.hoverFill,hoverStroke:s?ba(s,"99"):va.hoverStroke,pointRing:c||va.pointRing,primary:r||va.primary}:va}(n);un.current=u.primary;const d=null!==(t=null==he?void 0:he.threshold)&&void 0!==t?t:5e3,h=he&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(l){const t=Vs(n,Re,Xe,c);if(t){if(t.clearRect(-Xe.left,-Xe.top,Re[0],Re[1]),h&&(t.globalAlpha=null!==(e=null==he?void 0:he.dimOpacity)&&void 0!==e?e:.5),"transparent"!==it&&!te){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=it||(e&&"transparent"!==e?e:null),o=i?vr(t,i):null;o&&(t.fillStyle=o,t.fillRect(-Xe.left,-Xe.top,Re[0],Re[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Ue,Ze),t.clip()),ne&&o.scales)for(const e of ne)t.save(),e(t,o.scene,o.scales,{width:Ue,height:Ze}),t.restore();const i=Te?ya.custom:ya[_];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:Ue,height:Ze});t.restore(),h&&(t.globalAlpha=1)}}{const t=Vs(i,Re,Xe,c);if(t&&(t.clearRect(-Xe.left,-Xe.top,Re[0],Re[1]),Ke&&sn.current&&o.scales&&function(t,e,n,i,o,r,s){var a;if(!1===o.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 o.crosshair?o.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,i),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=o.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,sn.current,Ue,Ze,"object"==typeof Ke?Ke:{},an.current,u),an.current&&Array.isArray(zt))){const e=zt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){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 i.style?n.datum?i.style(n.datum):{}:i.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||o.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,o.scene,an.current,e,u)}}l&&n&&n.setAttribute("aria-label",Ss(o.scene,_+" chart"));const f=Le.current;if(Le.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!on||t(on.x.domain()[0])!==t(o.scales.x.domain()[0])||t(on.x.domain()[1])!==t(o.scales.x.domain()[1])||t(on.y.domain()[0])!==t(o.scales.y.domain()[0])||t(on.y.domain()[1])!==t(o.scales.y.domain()[1])||on.x.range()[0]!==o.scales.x.range()[0]||on.x.range()[1]!==o.scales.x.range()[1]||on.y.range()[0]!==o.scales.y.range()[0]||on.y.range()[1]!==o.scales.y.range()[1])&&rn(o.scales),ve){const t=o.getData(),e="function"==typeof j?j:t=>t[j||"x"],n="function"==typeof L?L:t=>t[L||"y"];mn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),bn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Bt&&Bt.length>0&&nn(t=>t+1),(null==he?void 0:he.showBadge)&&pn(!!h),(a||null!=o.activeTransition||o.hasActivePulses)&&(Ye.current=requestAnimationFrame(()=>Ge.current()))},function(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=t;ps(()=>{var t,o;e&&n&&(null===(o=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===o||o.call(t)),r.current=!0,s.current()},[e,n]);const l=o(a);l.current=a,u(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:ze,wasHydratingFromSSR:De,storeRef:An,dirtyRef:Le,renderFnRef:Ge,cleanup:()=>{var t;return null===(t=Mn.current)||void 0===t?void 0:t.clear()}}),u(()=>{Le.current=!0,He()},[_,Ue,Ze,St,it,ot,ne,He]),function(t,e,n,i,o,r){u(()=>{if(!t)return;const s=setInterval(()=>{var s;const a=e.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(s=t.threshold)&&void 0!==s?s:5e3,u=l-a.lastIngestTime>c;u!==o&&(r(u),n.current=!0,i())},1e3);return()=>clearInterval(s)},[t,o,i])}(he,An,Le,He,gn,pn);const Wn=r(()=>{if(Tt||Lt)return;const t=An.current;return(null==t?void 0:t.xIsDate)&&on?pa(on.x.domain()):void 0},[Tt,Lt,on]),Bn=Tt||Lt||Wn,In=Ke&&ln?Dt?Dt(ln):t(ka,{hover:ln}):null,Yn=In?t(Gs,{x:ln.x,y:ln.y,containerWidth:Ue,containerHeight:Ze,margin:Xe,className:"stream-frame-tooltip",children:In}):null,Gn=En.current,Hn=t(Ys,{active:Dn.current>=0,hoverPoint:ln,margin:Xe,size:Re,shape:null==Gn?void 0:Gn.shape,width:null==Gn?void 0:Gn.w,height:null==Gn?void 0:Gn.h}),Xn=fa(j,X,"__semiotic_resolvedX","__semiotic_resolvedTime"),qn=fa(L,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),Vn=Xn.key,Un=qn.key,Zn=function(t,e,n){return i=>{if(!i||!n||!t.fn&&!e.fn)return i;let o=!1;const r=i.map(n=>{const i=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!i&&!r)return n;o=!0;const s=Object.assign({},n);return i&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return o?r:i}}(Xn,qn,Bt&&Bt.length>0||!1);if(vi||!ze&&De){const n=An.current;n&&O&&(n.ingest({inserts:Qe,bounded:!0}),n.computeScene({width:Ue,height:Ze}));const o=null!==(c=null==n?void 0:n.scene)&&void 0!==c?c:[],r=null!==(h=null==n?void 0:n.scales)&&void 0!==h?h:null,s=Bn||(()=>{if((null==n?void 0:n.xIsDate)&&r)return pa(r.x.domain())})();return e("div",{ref:Ne,className:"stream-xy-frame"+(nt?" "+nt:""),role:"img","aria-label":Se||("string"==typeof oe?oe:"XY chart"),style:{position:"relative",width:J?"100%":Re[0],height:tt?"100%":Re[1]},children:[t(Fs,{summary:Me}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:Re[0],height:Re[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${Xe.left},${Xe.top})`,children:Ve}),e("g",{transform:`translate(${Xe.left},${Xe.top})`,children:[it&&t("rect",{x:0,y:0,width:Ue,height:Ze,fill:it}),ie&&r&&ie.map((e,n)=>t(i.Fragment,{children:e(o,r,{width:Ue,height:Ze})},"svgpre-"+n)),o.map((t,e)=>yi(t,e,je)).filter(Boolean)]})]}),t(gs,{width:Ue,height:Ze,totalWidth:Re[0],totalHeight:Re[1],margin:Xe,scales:r,showAxes:St,axes:Mt,xLabel:_t,yLabel:Pt,yLabelRight:Ot,xFormat:s,yFormat:$t||Ct,axisExtent:jt,showGrid:Gt,title:oe,legend:Ht,legendHoverBehavior:Xt,legendClickBehavior:qt,legendHighlightedCategory:Vt,legendIsolatedCategories:Ut,legendPosition:Zt,legendLayout:Qt,foregroundGraphics:sr(qe,null===(f=An.current)||void 0===f?void 0:f.customLayoutOverlays),marginalGraphics:ve,xValues:[],yValues:[],annotations:Bt,autoPlaceAnnotations:It,svgAnnotationRules:Yt,annotationFrame:0,xAccessor:Vn,yAccessor:Un,annotationData:Zn(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof N?N:void 0,linkedCrosshairName:_e,linkedCrosshairSourceId:Pe})]})}return e("div",{ref:Ne,className:"stream-xy-frame"+(nt?" "+nt:""),role:"group","aria-label":Se||("string"==typeof oe?oe:"XY chart"),tabIndex:0,style:{position:"relative",width:J?"100%":Re[0],height:tt?"100%":Re[1],overflow:"visible"},onKeyDown:Rn,children:[Ae&&t(Ws,{tableId:Ie}),Ae&&t(Rs,{scene:null!==(m=null===(y=An.current)||void 0===y?void 0:y.scene)&&void 0!==m?m:[],chartType:_+" chart",tableId:Ie,chartTitle:"string"==typeof oe?oe:void 0}),t(Fs,{summary:Me}),t(Bs,{hoverPoint:ln}),e("div",{role:"img","aria-label":Se||("string"==typeof oe?oe:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ke?Fn:void 0,onMouseLeave:Ke?Ln:void 0,onClick:Nt?zn:void 0,children:[Ve&&t("svg",{style:{position:"absolute",left:0,top:0,width:Re[0],height:Re[1],pointerEvents:"none"},children:t("g",{transform:`translate(${Xe.left},${Xe.top})`,children:Ve})}),t(ds,{width:Ue,height:Ze,totalWidth:Re[0],totalHeight:Re[1],margin:Xe,scales:on,showAxes:St,axes:Mt,showGrid:Gt,xFormat:Bn,yFormat:$t||Ct,axisExtent:jt}),t("canvas",{ref:Je,"aria-label":Ss(null!==(b=null===(v=An.current)||void 0===v?void 0:v.scene)&&void 0!==b?b:[],_+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:tn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t(gs,{width:Ue,height:Ze,totalWidth:Re[0],totalHeight:Re[1],margin:Xe,scales:on,showAxes:St,axes:Mt,xLabel:_t,yLabel:Pt,yLabelRight:Ot,xFormat:Bn,yFormat:$t||Ct,axisExtent:jt,showGrid:Gt,title:oe,legend:Ht,legendHoverBehavior:Xt,legendClickBehavior:qt,legendHighlightedCategory:Vt,legendIsolatedCategories:Ut,legendPosition:Zt,legendLayout:Qt,foregroundGraphics:sr(qe,null===(x=An.current)||void 0===x?void 0:x.customLayoutOverlays),marginalGraphics:ve,xValues:yn,yValues:vn,annotations:Bt,autoPlaceAnnotations:It,svgAnnotationRules:Yt,annotationFrame:en,xAccessor:Vn,yAccessor:Un,annotationData:Zn(null===(k=An.current)||void 0===k?void 0:k.getData()),pointNodes:null===(w=An.current)||void 0===w?void 0:w.scene.filter(t=>"point"===t.type),curve:"string"==typeof N?N:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==it&&!te,linkedCrosshairName:_e,linkedCrosshairSourceId:Pe}),(se||ae)&&t(or,{width:Ue,height:Ze,totalWidth:Re[0],totalHeight:Re[1],margin:Xe,dimension:null!==(A=null==se?void 0:se.dimension)&&void 0!==A?A:"xy",scales:on,onBrush:null!=ae?ae:()=>{},binSize:B,snap:null==se?void 0:se.snap,binBoundaries:null!==(S=null==se?void 0:se.binBoundaries)&&void 0!==S?S:"bar"===_?null===(M=An.current)||void 0===M?void 0:M.getBinBoundaries():void 0,snapDuring:null==se?void 0:se.snapDuring,streaming:"streaming"===P}),(null==he?void 0:he.showBadge)&&t(Nr,{isStale:gn,position:he.badgePosition}),Hn,Yn]})]})});wa.displayName="StreamXYFrame";const Aa=c(null);function Sa(){return s(Aa)}function Ma(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function _a(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}const[Pa,Oa]=bi(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=_a(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=_a(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[Ta,$a]=bi(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 ja(t){const e=g(),n=t.clientId||e,{name:i}=t,o=Oa(t=>t.selections.get(i)),s=Oa(t=>t.setClause),l=Oa(t=>t.clearClause),c=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Ma(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};s(i,{clientId:n,type:"point",fields:e})},[n,i,s]),selectInterval:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};s(i,{clientId:n,type:"interval",fields:e})},[n,i,s]),clear:a(()=>{l(i,n)},[l,i,n]),clientId:n}}const La=c(!1),Ca=c(null),za="undefined"==typeof window?u:h;function Da(t,e,n){var i;const o=null!==(i=t.xValue)&&void 0!==i?i:null==e?void 0:e[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function Ea(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 Na(){var t;const e=Ti(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 Ra({data:t,colorBy:e,colorScale:n,showLegend:i,legendPosition:a="right",userMargin:l,defaults:c={top:50,bottom:60,left:70,right:40},categories:u}){const d=s(La),h=null!==s(Ca),f=void 0!==i?i:!d&&!!e,p=!!e&&(f||h),y=r(()=>{if(!p)return[];if(void 0!==u)return u;const n=new Set;for(const i of t){const t="function"==typeof e?e(i):i[e];null!=t&&n.add(t+"")}return Array.from(n)},[u,e,t,p]);!function(t){const e=s(Ca),n=g(),i=function(t){const e=new Set,n=[];for(const i of t)e.has(i)||(e.add(i),n.push(i));return n}(t),r=o([]);(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 a=r.current;za(()=>{if(e)return()=>e.unregisterCategories(n)},[e,n]),za(()=>{e&&e.registerCategories(n,a)},[e,n,a])}(h&&e?y:[]);const m=r(()=>{if(!f||!e)return;const i=function({data:t,colorBy:e,colorScale:n,getColor:i,strokeColor:o,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((o,r)=>{const s=t.find("function"==typeof e?t=>e(t)===o:t=>t[e]===o),a=s?i(s,e,n):n?n(o):ie[r%ie.length];return{label:o+"",color:a}});return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==o&&(n.stroke=o),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}({data:t,colorBy:e,colorScale:n,getColor:re,categories:y}),o=i.legendGroups.reduce((t,e)=>t+e.items.length,0);return 0!==o?i:void 0},[f,e,t,n,y]),v=r(()=>{const t="number"==typeof l?{top:l,bottom:l,left:l,right:l}:null!=l?l:{},e=e=>{const n=t[e];return"number"==typeof n?n:c[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},i=e=>"number"==typeof t[e];return m&&("right"===a&&!i("right")&&110>n.right?n.right=110:"left"===a&&!i("left")&&110>n.left?n.left=110:"top"===a&&!i("top")&&50>n.top?n.top=50:"bottom"===a&&!i("bottom")&&80>n.bottom&&(n.bottom=80)),n},[c,l,m,a]);return{legend:m,margin:v,legendPosition:a}}i.createContext(void 0);const Fa={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 Wa(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}function Ba({componentName:n,message:i,diagnosticHint:o,width:r,height:s}){return t("div",{role:"alert",style:{width:r,height:Math.max(s,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:e("div",{style:{textAlign:"center",maxWidth:400},children:[t("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:n}),t("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:i}),o&&t("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 Ia extends i.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){var n,i;null===(i=(n=this.props).onError)||void 0===i||i.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(Ba,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Ya({componentName:e,width:n,height:i,children:o}){return t(Ia,{fallback:o=>t(Ba,{componentName:e,message:o.message,width:n,height:i}),children:o})}"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"},Ha={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Xa(e){const{data:n,rawData:i,colorBy:o,colorScheme:s,legendInteraction:l,legendPosition:c,selection:h,linkedHover:f,fallbackFields:p,unwrapData:y=!1,onObservation:m,chartType:v,chartId:b,showLegend:x,userMargin:k,marginDefaults:w,onClick:A,hoverHighlight:S,loading:M,loadingContent:_,emptyContent:P,width:O,height:T}=e,$=void 0===i,j=r(()=>Uo(n),[n]),[L,C]=d([]),z=a(t=>{C(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),D="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:E,hoverSelectionHook:N,customHoverBehavior:R,customClickBehavior:F,crosshairSourceId:W}=function({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:s,chartId:l,onClick:c,hoverHighlight:h,colorByField:f}){const p=g(),y=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}(e,n),m="series"===(null==y?void 0:y.mode)?[y.seriesField||f||n[0]].filter(t=>!!t):(null==y?void 0:y.fields)||n||[],v=ja({name:(null==t?void 0:t.name)||"__unused__"}),b=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:s}=ja({name:e});return{onHover:a(t=>{if(!t)return void s();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&r(e)},[n,r,s,e]),predicate:i,isActive:o}}({name:(null==y?void 0:y.name)||"hover",fields:m}),x=$a(t=>t.pushObservation),k=t?{isActive:v.isActive,predicate:v.predicate}:null,[w,A]=d(null),S=f||n[0],M=r(()=>{if(!h||null==w||!S)return null;const t=w,e=S;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[h,w,S]),_=a(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==y?void 0:y.mode)&&y.xField){const n=Da(t,e,y.xField);null!=n&&function(t,e,n){const i=Ur.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(Ur={positions:new Map(Ur.positions).set(t,{xValue:e,sourceId:n})},Qr())}(y.name||"hover",n,p)}"x-position"!==(null==y?void 0:y.mode)&&b.onHover(e)}else"x-position"===(null==y?void 0:y.mode)&&Kr(y.name||"hover",p),"x-position"!==(null==y?void 0:y.mode)&&b.onHover(null);if(h&&S)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[S];A(null!=n?n+"":null)}else A(null);if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const r=Ea(t),s=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(s),x&&x(s)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});o&&o(t),x&&x(t)}}},[e,b,y,p,o,s,l,x,h,S]),P=a(t=>{var e,n,i,r;if("x-position"===(null==y?void 0:y.mode)&&y.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=Da(t,e,y.xField);null!=n&&function(t,e,n){const i=Ur.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(Ur.positions);return e.delete(t),Ur={positions:e},Qr(),!1}Ur={positions:new Map(Ur.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Qr()}(y.name||"hover",n,p)}if(t&&c){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),c(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const n=Ea(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(s),x&&x(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});o&&o(t),x&&x(t)}}},[c,o,x,s,l,y,p]);return u(()=>{if("x-position"!==(null==y?void 0:y.mode))return;const t=y.name||"hover";return()=>{Jr(t,p),Kr(t,p)}},[null==y?void 0:y.mode,null==y?void 0:y.name,p]),{activeSelectionHook:k,hoverSelectionHook:M,customHoverBehavior:_,customClickBehavior:P,crosshairSourceId:p}}({selection:h,linkedHover:f,fallbackFields:p,unwrapData:y,onObservation:m,chartType:v,chartId:b,onClick:A,hoverHighlight:S,colorByField:D}),B=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}}(f,W),I=function(t,e,n){const i=Sa(),o=Na();return r(()=>{var r;if(!e)return;const s=null!==(r=null!=n?n:o&&o.length>0?o:void 0)&&void 0!==r?r:"category10";if(0!==t.length){if("function"==typeof e){const n=Array.from(new Set(t.map(t=>e(t)+"")));if(i&&Object.keys(i).length>0){const t=se(n.map(t=>({_cat:t})),"_cat",s);return e=>i[e]||t(e)}return se(n.map(t=>({_cat:t})),"_cat",s)}if(i&&Object.keys(i).length>0){const n=se(t,e,s);return t=>i[t]||n(t)}return se(t,e,s)}if(i&&Object.keys(i).length>0){const t=se([{_:"a"}],"_",s);return e=>i[e]||t(e)}},[t,e,n,i,o])}(j,o,s),Y=r(()=>{if(!o)return[];const t=new Set;for(const e of j){const n="function"==typeof o?o(e):e[o];null!=n&&t.add(n+"")}return Array.from(t)},[j,o]),G=r(()=>$&&L.length>0?L:Y,[$,L,Y]),H=function(t,e,n){const[i,o]=d(null),[s,l]=d(new Set),c=a(e=>{"highlight"===t&&o(e?e.label:null)},[t]),u=a(e=>{"isolate"===t&&l(t=>{const i=new Set(t);return i.has(e.label)?i.delete(e.label):i.add(e.label),i.size===n.length?new Set:i})},[t,n.length]),h=r(()=>{if(!t||"none"===t||!e)return null;const n="string"==typeof e?e:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(n?t[n]:"function"==typeof e?e(t):null)===i}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const i=n?t[n]:"function"==typeof e?e(t):null;return s.has(i)}}:null},[t,e,i,s]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:c,onLegendClick:u,legendSelectionHook:h}}(l,o,G),X=r(()=>N||(H.legendSelectionHook?H.legendSelectionHook:E),[N,H.legendSelectionHook,E]),q=function(t){const e=Ti(t=>t.theme.colors.selectionOpacity);return r(()=>{var n,i;if(void 0!==t||void 0!==e)return Object.assign(Object.assign({name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:""},t),{unselectedOpacity:null!==(i=null==t?void 0:t.unselectedOpacity)&&void 0!==i?i:e})},[t,e])}(h),V=Na(),U=Sa(),Z=r(()=>{if(I)return I;if(!o||0===G.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:V&&V.length>0?V:ie,e="__streamCat",n=se(G.map(t=>({[e]:t})),e,t);return t=>(null==U?void 0:U[t])||n(t)||"#999"},[I,o,G,s,V,U]),{legend:Q,margin:K,legendPosition:J}=Ra({data:j,colorBy:o,colorScale:Z,showLegend:x,legendPosition:c,userMargin:k,defaults:w,categories:G}),tt=r(()=>{const t={};return Q&&(t.legend=Q,t.legendPosition=J),l&&"none"!==l&&(t.legendHoverBehavior=H.onLegendHover,t.legendClickBehavior=H.onLegendClick,t.legendHighlightedCategory=H.highlightedCategory,t.legendIsolatedCategories=H.isolatedCategories),$&&o&&(t.legendCategoryAccessor=o,t.onCategoriesChange=z),t},[Q,J,l,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,$,o,z]),et=Array.isArray(i)?Uo(i):i,nt=function(e,n,i,o){if(!e)return null;if(!1===o)return null;if(null!=o)return t("div",{style:{width:n,height:i,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(i/40)),s=Math.max(8,Math.floor(i/(3*r))),a=Math.max(6,Math.floor(i/(2.5*r))),l=Math.floor((i-(r*(s+a)-a))/2);return t("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,i)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ha),{position:"absolute",top:l+i*(s+a),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:s,opacity:.5+i%2*.2})},i))})}(M,O,T,_),it=nt?null:function(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},Ga),{width:n,height:i}),children:o||"No data available"}):null}(et,O,T,P);return{data:j,colorScale:I,allCategories:G,legendState:H,effectiveSelectionHook:X,activeSelectionHook:E,customHoverBehavior:R,customClickBehavior:F,legend:Q,margin:K,legendPosition:J,earlyReturn:nt||it||null,legendBehaviorProps:tt,crosshairProps:B,resolvedSelection:q}}function qa(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 Va(t,e,n,i){if(!t.length)return[];const o=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;o.length>t;t++){const r=o[t],g=e(r),p=n(r),y=i(r);if(!Number.isFinite(g)||!Number.isFinite(p)||!Number.isFinite(y))continue;const m=u(p,y);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=p-l.a-(y-l.b);if(0!==n){const i=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+i*(g-l.x),e=l.a+i*(p-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:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else{a=m;for(const t of c)f(t,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else c.push({x:g,y:p,datum:r})}for(const t of c)f(t,null!=a?a:"A");return r}const Ua=f(function(n,i){const s=o(null),l=function(t,e){var n,i,o,r,s,a,l;const c=Fa[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(n=e.width)&&void 0!==n?n:c.width,height:null!==(i=e.height)&&void 0!==i?i:c.height,showAxes:null!==(o=e.showAxes)&&void 0!==o?o: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:Wa(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:c,margin:u,className:h,xFormat:f,yFormat:g,xAccessor:y="x",seriesAAccessor:m="a",seriesBAccessor:v="b",seriesALabel:b="A",seriesBLabel:x="B",seriesAColor:k="var(--semiotic-danger, #dc2626)",seriesBColor:w="var(--semiotic-info, #2563eb)",showLines:A=!0,lineWidth:S=1.5,showPoints:M=!1,pointRadius:_=3,curve:P="linear",areaOpacity:O=.6,gradientFill:T,tooltip:$,annotations:j,xExtent:L,yExtent:C,frameProps:z={},selection:D,linkedHover:E,onObservation:N,onClick:R,hoverHighlight:F,chartId:W,loading:B,loadingContent:I,emptyContent:Y,legendInteraction:G,legendPosition:H,pointIdAccessor:X,windowSize:q}=n,{width:V,height:U,enableHover:Z,showGrid:Q,showLegend:K,title:J,description:tt,summary:et,accessibleTable:nt,xLabel:it,yLabel:ot}=l,rt=r(()=>"function"==typeof y?t=>qa(y(t)):t=>qa(t[y]),[y]),st=r(()=>"function"==typeof m?t=>qa(m(t)):t=>qa(t[m]),[m]),at=r(()=>"function"==typeof v?t=>qa(v(t)):t=>qa(t[v]),[v]),[lt,ct]=d([]),ut=o([]),dt=null==c,ht=r(()=>Uo(dt?lt:c),[dt,lt,c]),ft=r(()=>Va(ht,rt,st,at),[ht,rt,st,at]),gt=r(()=>A?function(t,e,n,i){if(!t.length)return[];const o=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of o){const o=e(t),s=n(t),a=i(t);Number.isFinite(s)&&r.push({__x:o,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:o,__y:a,__diffSegment:"line-B"})}return r}(ht,rt,st,at):[],[A,ht,rt,st,at]),pt=r(()=>[...ft,...gt],[ft,gt]),yt=r(()=>{const t=new Set;for(const e of ft)t.add(e.__diffSegment);return Array.from(t)},[ft]);p(i,()=>{const t=t=>{const e=q&&t.length>q?t.slice(t.length-q):t;ut.current=e,ct(e)},e=X?"function"==typeof X?X:t=>t[X]:null;return{push:e=>t([...ut.current,e]),pushMany:e=>t([...ut.current,...e]),remove:n=>{if(!e)return[];const i=Array.isArray(n)?n:[n],o=[],r=[];for(const t of ut.current)i.includes(e(t))?o.push(t):r.push(t);return t(r),o},update:(n,i)=>{if(!e)return[];const o=Array.isArray(n)?n:[n],r=[],s=ut.current.map(t=>{if(o.includes(e(t))){const e=i(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>dt?ut.current:ht,getScales:()=>{var t,e;return null!==(e=null===(t=s.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[dt,ht,X,q]);const mt=Xa({data:ht,rawData:c,colorBy:"__diffWinner",colorScheme:[k,w],legendInteraction:G,legendPosition:H,selection:D,linkedHover:E,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:N,onClick:R,hoverHighlight:F,chartType:"DifferenceChart",chartId:W,showLegend:K,userMargin:u,marginDefaults:l.marginDefaults,loading:B,loadingContent:I,emptyContent:Y,width:V,height:U}),vt=r(()=>{if(!1!==K)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:b,color:k},{label:x,color:w}]}]}},[K,b,x,k,w]),bt=a(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?k:w,stroke:"none",fillOpacity:O}},[k,w,O]),xt=a(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,strokeWidth:S,fill:"none"}),[k,w,S]),kt=a(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,r:_}),[k,w,_]),wt=a(n=>{var i;const o=n.data,r=n.allSeries,s=null!==(i=n.xValue)&&void 0!==i?i:null==o?void 0:o.__x;let a=null==o?void 0:o.__valA,l=null==o?void 0:o.__valB;if(r&&r.length>0){const t=r.find(t=>"line-A"===t.group),e=r.find(t=>"line-B"===t.group);null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(a=t.value),null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(l=e.value)}if(null!=s&&(null==a||null==l)){const t=ht.find(t=>rt(t)===s);t&&(null==a&&(a=st(t)),null==l&&(l=at(t)))}const c=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",u=f&&null!=s?f(s):null!=s?s+"":"";return e("div",{className:"semiotic-tooltip",style:Ko,children:[u&&t("div",{style:{fontWeight:600,marginBottom:4},children:u}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:k,display:"inline-block",borderRadius:2}}),e("span",{children:[b,": ",c(a)]})]}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:w,display:"inline-block",borderRadius:2}}),e("span",{children:[x,": ",c(l)]})]}),null!=a&&null!=l&&Number.isFinite(a)&&Number.isFinite(l)&&e("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",c(a-l)]})]})},[ht,rt,st,at,f,k,w,b,x]),At="multi"===$,St=r(()=>{if(!1===$)return()=>null;if(At)return wt;const e=function(e){if(!0!==e){if("function"==typeof e){const n=e;return e=>{var i;const o=Zo(!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!==(i=e.data)&&void 0!==i?i:{}:e),r=n(o);return null==r?null:t("div",{className:"semiotic-tooltip",style:Ko,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?er(e):er())}}($);return e||wt},[$,At,wt]);if(mt.earlyReturn)return mt.earlyReturn;const Mt=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:pt,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:yt,curve:P,areaStyle:bt,lineStyle:xt},M&&{pointStyle:kt}),{size:[V,U],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:mt.margin,showAxes:l.showAxes,xLabel:it,yLabel:ot,xFormat:f,yFormat:g,enableHover:Z,showGrid:Q}),T&&{gradientFill:!0===T?{topOpacity:.85,bottomOpacity:.15}:T}),vt&&{legend:vt,legendPosition:mt.legendPosition}),function(t){const{title:e,description:n,summary:i,accessibleTable:o,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:l}=t,c={};return e&&(c.title=e),n&&(c.description=n),i&&(c.summary=i),void 0!==o&&(c.accessibleTable=o),r&&(c.className=r),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}({title:J,description:tt,summary:et,accessibleTable:nt,className:h,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),{tooltipContent:St}),At&&{tooltipMode:"multi"}),function(t){const{linkedHover:e,onObservation:n,onClick:i,hoverHighlight:o,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=t,l={};return(e||n||i||o)&&(l.customHoverBehavior=r),(a?n||i||e:n||i)&&(l.customClickBehavior=s),l}({linkedHover:E,onObservation:N,onClick:R,hoverHighlight:F,customHoverBehavior:mt.customHoverBehavior,customClickBehavior:mt.customClickBehavior})),j&&j.length>0&&{annotations:j}),L&&{xExtent:L}),C&&{yExtent:C}),mt.crosshairProps),z);return t(Ya,{componentName:"DifferenceChart",width:V,height:U,children:t(wa,Object.assign({ref:s},Mt))})});function Za(t,e,n){return"function"==typeof t?t(n):n[t||e]}function Qa(t){return t instanceof Date?t.getTime():Number(t)}function Ka(t,e){return Ut(1===e?.5:t/(e-1))}"function"==typeof Ua&&(Ua.displayName="DifferenceChart");const Ja={frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r,s,a,l;const c=null!==(r=o.min)&&void 0!==r?r:0,u=null!==(s=o.max)&&void 0!==s?s:100,d=null!==(a=o.sweep)&&void 0!==a?a:240,h=null!==(l=o.arcWidth)&&void 0!==l?l:.3,f=180+(360-d)/2,g=o.thresholds||[{value:u,color:o.color||"#4e79a7"}],p=i.gradientFill,y=function(t){const{min:e,max:n,value:i,thresholds:o,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,i))-e)/d;let f=o&&o.length>0?[...o].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,p=[],y=new Map,m=[];if(g){const t=a?h:1,e=zo("bg",0);if(p.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.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))),i=[];for(let e=0;n>e;e++)i.push(Co(c.colorStops,t*(e+.5)/n));const o=zo("fill",0);p.push({category:o,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),y.set(o,{fill:i[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const i=f[n],o=(i.value-t)/d,r=(t-e)/d,l=(i.value-e)/d,c=Math.max(0,(a?Math.min(h,l):l)-r),u=a?Math.max(0,o-c):0;if(c>0){const t=zo("fill",n);p.push({category:t,value:c,_zone:i.label||"Zone "+(n+1),_isFill:!0}),y.set(t,{fill:i.color})}if(u>0){const t=zo("bg",n);p.push({category:t,value:u,_zone:i.label||"Zone "+(n+1),_isFill:!1}),y.set(t,{fill:s,opacity:.4})}t=i.value}}if(l&&o&&o.length>0)for(const t of o)t.value>e&&n>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:p,pieceStyle:(t,e)=>y.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:c,max:u,value:o.value,thresholds:g,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:!1!==o.fillZones,showScaleLabels:!1!==o.showScaleLabels,gradientFill:p&&"object"==typeof p&&"colorStops"in p?p:void 0}),m=i.margin||{top:20,right:20,bottom:30,left:40},[v,b]=i.size||[300,300];return Object.assign(Object.assign(Object.assign({chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),b-(m.top||0)-(m.bottom||0))/2*(1-h)),sweepAngle:d,startAngle:f,oSort:!1,pieceStyle:y.pieceStyle},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i),{showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:c,gMax:u,sweep:d,arcWidth:h,value:o.value,startAngleDeg:f,thresholds:g}})}},tl={frameType:"geo",buildProps:(t,e,n,i,o)=>{var r,s,a,l,c;const u=(Array.isArray(t)?t:null)||o.flows||[],d=o.nodeIdAccessor||"id",h=o.valueAccessor||"value",f=o.xAccessor||"lon",g=o.yAccessor||"lat",p="function"==typeof f?f:t=>t[f],y="function"==typeof g?g:t=>t[g],m=(o.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:p(t),y:y(t)})),v=new Map;for(const t of m)v.set(t[d]+"",t);const b=null!==(r=o.edgeColorBy)&&void 0!==r?r:e,x="function"==typeof b,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=b?x?se(k.map(t=>({[w]:b(t)})),w,n||"category10"):se(k,b,n||"category10"):null,S=t=>b&&A?re(t,b,A):"#007bff";let M=1/0,_=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(M>e&&(M=e),e>_&&(_=e))}const P=_>M?_-M:0,[O,T]=null!==(a=o.edgeWidthRange)&&void 0!==a?a:[1,8],$=T-O,j=null!==(l=o.edgeOpacity)&&void 0!==l?l:.6,L=null!==(c=o.edgeLinecap)&&void 0!==c?c:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(null==t?void 0:t[h]),n=O+Math.max(0,Math.min(1,P>0?((Number.isFinite(e)?e:M)-M)/P:0))*$;return{stroke:S(t),strokeWidth:n,strokeLinecap:L,opacity:j,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},i)}},el={Sparkline:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e},i),{showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:o.lineStyle},i)},AreaChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"area",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||e,colorAccessor:e,colorScheme:n},i)},DifferenceChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>{var r,s;const a=o.xAccessor||"x",l=o.seriesAAccessor||"a",c=o.seriesBAccessor||"b",u=t=>Qa(Za(a,"x",t)),d=t=>Qa(Za(l,"a",t)),h=t=>Qa(Za(c,"b",t)),f=o.seriesAColor||"var(--semiotic-danger, #dc2626)",g=o.seriesBColor||"var(--semiotic-info, #2563eb)",p=null!==(r=o.areaOpacity)&&void 0!==r?r:.6,y=null!==(s=o.lineWidth)&&void 0!==s?s:1.5,m=!1!==o.showLines,v=Va(Array.isArray(t)?t:[],u,d,h),b=[];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),i=h(t);Number.isFinite(n)&&b.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(i)&&b.push({__x:e,__y:i,__diffSegment:"line-B"})}}const x=[...v,...b],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:x,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:p}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?f:g,strokeWidth:y,fill:"none"}),curve:o.curve||"linear"},i)}},StackedAreaChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:e||o.areaBy,colorScheme:n,normalize:o.normalize},i)},Scatterplot:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,colorScheme:n},i)},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"candlestick",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle},i)},BubbleChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:n},i)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,n,i,o)=>{var r,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",i=e.yAccessor||"y",o=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:Qa(Za(e.orderAccessor,"order",t))-Qa(Za(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of o){if(null==t||"object"!=typeof t)continue;const e=Qa(Za(n,"x",t)),o=Qa(Za(i,"y",t));Number.isFinite(e)&&Number.isFinite(o)&&s++}let a=0;for(const t of o){if(null==t||"object"!=typeof t)continue;const e=Qa(Za(n,"x",t)),o=Qa(Za(i,"y",t));Number.isFinite(e)&&Number.isFinite(o)&&r.set(t,{idx:a++,total:s})}return{data:o,orderMap:r}}(t,o),l=null!==(r=o.pointRadius)&&void 0!==r?r:4;return Object.assign({chartType:"line",data:a.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:o.lineStyle||{stroke:o.stroke||"#6366f1",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:l,opacity:o.opacity},pointStyle:t=>{var e,n;const i=a.orderMap.get(t),o=null!==(e=null==i?void 0:i.idx)&&void 0!==e?e:0,r=null!==(n=null==i?void 0:i.total)&&void 0!==n?n:1;return{fill:r>0?Ka(o,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},i)}},QuadrantChart:{frameType:"xy",buildProps:(t,e,n,o,r)=>{var s,a;const l=r.xCenter,c=r.yCenter,u=r.quadrants,d=r.centerlineStyle||{},h=!1!==r.showQuadrantLabels,f=null!==(s=r.quadrantLabelSize)&&void 0!==s?s:12,g=d.stroke||"#999",p=null!==(a=d.strokeWidth)&&void 0!==a?a:1,y=Array.isArray(d.strokeDasharray)?d.strokeDasharray.join(","):d.strokeDasharray,m=i.createElement,v=u?[(t,e,n)=>{if(!(null==e?void 0:e.x)||!(null==e?void 0:e.y))return null;const o=n.width,r=n.height,s=null!=l?e.x(l):o/2,a=null!=c?e.y(c):r/2;if(null!=l&&!Number.isFinite(s))return null;if(null!=c&&!Number.isFinite(a))return null;const d=Math.max(0,Math.min(o,s)),v=Math.max(0,Math.min(r,a)),b=[{c:u.topLeft,x:0,y:0,w:d,h:v},{c:u.topRight,x:d,y:0,w:o-d,h:v},{c:u.bottomLeft,x:0,y:v,w:d,h:r-v},{c:u.bottomRight,x:d,y:v,w:o-d,h:r-v}],x=h?[m("text",{key:"ltl",x:8,y:8+f,fill:u.topLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.topLeft.label),m("text",{key:"ltr",x:o-8,y:8+f,fill:u.topRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.topRight.label),m("text",{key:"lbl",x:8,y:r-8,fill:u.bottomLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.bottomLeft.label),m("text",{key:"lbr",x:o-8,y:r-8,fill:u.bottomRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.bottomRight.label)]:[];return m(i.Fragment,null,...b.map((t,e)=>{var n;return t.w>0&&t.h>0?m("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}),m("line",{key:"vc",x1:d,y1:0,x2:d,y2:r,stroke:g,strokeWidth:p,strokeDasharray:y}),m("line",{key:"hc",x1:0,y1:v,x2:o,y2:v,stroke:g,strokeWidth:p,strokeDasharray:y}),...x)}]:void 0;return Object.assign(Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle},o),v&&{svgPreRenderers:v})}},Heatmap:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"heatmap",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,colorScheme:n||o.colorScheme||"blues",showValues:o.showValues,cellBorderColor:o.cellBorderColor},i)},BarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(r=o.sort)&&void 0!==r&&r,colorAccessor:e,colorScheme:n,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:e||o.stackBy,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",normalize:o.normalize,oSort:null!==(r=o.sort)&&void 0!==r&&r,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:e||o.groupBy,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(r=o.sort)&&void 0!==r&&r,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},PieChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:e||o.categoryAccessor,colorScheme:n},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i)},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",innerRadius:o.innerRadius||60,colorAccessor:e||o.categoryAccessor,colorScheme:n},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i)},Histogram:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"histogram",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal",bins:o.bins,colorAccessor:e,colorScheme:n},i)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"boxplot",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorScheme:n},i)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"violin",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,colorScheme:n},i)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"swarm",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:n},i)},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:n},i),{showGrid:null===(r=i.showGrid)||void 0===r||r})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"swimlane",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:e||o.subcategoryAccessor,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical"},i)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,amplitude:o.amplitude},i)},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.levelAccessor||"level",colorAccessor:e||o.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===o.orientation?"vertical":"horizontal"},i)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{const r="vertical"===o.orientation;return Object.assign({chartType:r?"bar-funnel":"funnel",data:t,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:e||o.categoryAccessor,categoryAccessor:o.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:n},i)}},GaugeChart:Ja,ForceDirectedGraph:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:e,colorScheme:n,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle},i)},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:e,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle,colorScheme:n},i)},ProcessSankey:{frameType:"network",buildProps:(t,e,n,i,o)=>{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=o.sourceAccessor||"source",d=o.targetAccessor||"target",h=o.valueAccessor||"value",f=o.nodeIdAccessor||"id",g=o.startTimeAccessor||"startTime",p=o.endTimeAccessor||"endTime",y=o.systemInTimeAccessor,m=o.systemOutTimeAccessor,v=o.xExtentAccessor||"xExtent",b=o.edgeIdAccessor||"id",x=(t,e)=>"function"==typeof t?t(e):e[t],k=Array.isArray(o.edges)?o.edges:[],w=Array.isArray(o.nodes)?o.nodes:[],A=w.length>0?w:function(t,e,n,i){const o=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof i?i(t):t[i];o.add(e),o.add(r)}),Array.from(o).map(t=>({id:t}))}(0,k,u,d),S=[c(null===(r=o.domain)||void 0===r?void 0:r[0]),c(null===(s=o.domain)||void 0===s?void 0:s[1])],M=A.map(t=>{const e=x(f,t)+"",n=x(v,t),i={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)&&(i.xExtent=[t,e])}return i}),_=k.map((t,e)=>{const n=x(b,t),i={id:null!=n?n+"":`${x(u,t)}-${x(d,t)}-${e}`,source:x(u,t)+"",target:x(d,t)+"",value:Number(x(h,t)),startTime:c(x(g,t)),endTime:c(x(p,t)),__raw:t};if(y){const e=c(x(y,t));Number.isFinite(e)&&(i.systemInTime=e)}if(m){const e=c(x(m,t));Number.isFinite(e)&&(i.systemOutTime=e)}return i}),[P,O]=null!==(a=i.size)&&void 0!==a?a:[600,400],T=Object.assign({top:20,right:20,bottom:20,left:20},i.margin),$=null!==(l=i.legendPosition)&&void 0!==l?l:"right";i.showLegend&&("right"===$?T.right=Math.max(T.right,100):"left"===$?T.left=Math.max(T.left,100):"bottom"===$?T.bottom=Math.max(T.bottom,70):"top"===$&&(T.top=Math.max(T.top,40)));const j=T,L=P-j.left-j.right,C=O-j.top-j.bottom,z=Array.isArray(n)?n:null,D=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],E="function"==typeof e?e:null,N=E?A.map(t=>({_cat:E(t)})):A,R=E?"_cat":"string"==typeof e?e:void 0,F=R?se(N,R,n):null,W=new Map;for(const t of M)W.set(t.id,t.__raw);const{layoutConfig:B,issues:I}=Xo({nodes:M,edges:_,domain:S,plotW:L,plotH:C,ribbonLane:o.ribbonLane||"both",edgeOpacity:"number"==typeof o.edgeOpacity?o.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&W.has(t)){const n=W.get(t);return E?re({_cat:E(n)},"_cat",null!=F?F:void 0):re(n,e,null!=F?F:void 0)}const i=z||D;return i[n%i.length]},layoutOpts:{pairing:o.pairing||"temporal",packing:o.packing||"reuse",laneOrder:o.laneOrder||"crossing-min",lifetimeMode:o.lifetimeMode||"half"}});if(I.length>0){const t=I.map(Do).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:A,edges:k,customNetworkLayout:qo,layoutConfig:B,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},i),{margin:j})}},ChordDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:e,edgeColorBy:o.edgeColorBy,colorScheme:n},i)},TreeDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"cluster"===o.layout?"cluster":"tree",data:t,childrenAccessor:o.childrenAccessor,colorBy:e,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,colorScheme:n},i)},Treemap:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:n},i)},CirclePack:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,colorScheme:n},i)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,i,o)=>Object.assign({areas:o.areas,projection:o.projection||"equalEarth",areaStyle:o.areaStyle,valueAccessor:o.valueAccessor,colorScheme:n||"blues",graticule:o.graticule,fitPadding:o.fitPadding},i)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,i,o)=>Object.assign({points:t||o.points,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle,sizeBy:o.sizeBy,colorBy:e,colorScheme:n,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding},i)},FlowMap:tl};function nl(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function il(t,e){if(0===e.categories.length)return;const n=e.position||"right",i=function(t){const{width:e,height:n,swatchSize:i}=Ei(t);return{width:e,height:n,swatchSize:i}}({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,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 ol(t,e){const n=e.position||"right",i={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},o=St(e.legend)?function(t){const{width:e,height:n,swatchSize:i}=Ni(t);return{width:e,height:n,swatchSize:i}}(Object.assign(Object.assign({},i),{legendGroups:e.legend.legendGroups})):Mt(e.legend)?Ri(Object.assign(Object.assign({},i),{gradient:e.legend.gradient})):null;o&&("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 rl(n,i){const o={theme:i.theme,position:i.position||"right",totalWidth:i.size[0],totalHeight:i.size[1],margin:i.margin,hasTitle:i.hasTitle,legendLayout:i.legendLayout,idPrefix:i.idPrefix};return St(n)?function(n){if(0===(i=n.legendGroups,i.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var i;const o=Ni(n),r="top"===n.position||"bottom"===n.position,s=n.theme.colors.grid||n.theme.colors.textSecondary;let a,l;"left"===n.position?(a=Math.max(4,n.margin.left-o.width-10),l=n.margin.top):"top"===n.position?(a=n.margin.left,l=n.hasTitle?32:8):"bottom"===n.position?(a=n.margin.left,l=Math.min(n.totalHeight-n.margin.bottom+38,n.totalHeight-o.height-2)):(a=Math.min(n.totalWidth-o.width-4,n.totalWidth-n.margin.right+10),l=n.margin.top);const c=o.groups.flatMap((i,a)=>{var l;const{group:c}=i,u=null!==(l=c.type)&&void 0!==l?l:"fill",d=[];if(c.label&&d.push(t("text",r?{transform:`translate(${i.x},${i.y}) rotate(90)`,textAnchor:"start",fontSize:zi(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:c.label}:{x:i.x,y:i.y+zi(n.theme),fontSize:zi(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:c.label},"legend-group-label-"+a)),d.push(...i.items.map((r,s)=>{const l=c.items[s],d=c.styleFn(l,s),h="function"==typeof u?u(l):"line"===u?t("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:d}):t("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:d});return e("g",{transform:`translate(${i.x+i.itemOffsetX+r.x},${i.y+i.itemOffsetY+r.y})`,children:[h,t("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:zi(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:r.category})]},`legend-${a}-${s}`)})),!r&&o.groups.length-1>a)d.push(t("line",{x1:0,y1:i.y+i.height-6,x2:o.width,y2:i.y+i.height-6,stroke:s},"legend-group-separator-"+a));else if(r&&o.groups.length-1>a){const e=i.x+i.width+6;d.push(t("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:s},"legend-group-separator-"+a))}return d});return t("g",{className:"semiotic-legend",transform:`translate(${a},${l})`,"data-orientation":r?"horizontal":"vertical",children:c})}(Object.assign(Object.assign({},o),{legendGroups:n.legendGroups})):Mt(n)?function(n){const i=Ri(n),o="top"===n.position||"bottom"===n.position,r=(n.idPrefix?n.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=n.gradient.format||(t=>Math.round(100*t)/100+"");let a,l;"left"===n.position?(a=Math.max(4,n.margin.left-i.width-10),l=n.margin.top):"top"===n.position?(a=n.margin.left,l=n.hasTitle?32:8):"bottom"===n.position?(a=n.margin.left,l=Math.min(n.totalHeight-n.margin.bottom+38,n.totalHeight-i.height-2)):(a=Math.min(n.totalWidth-i.width-4,n.totalWidth-n.margin.right+10),l=n.margin.top);const c=Array.from({length:17},(e,i)=>{const r=i/16;return t("stop",{offset:100*r+"%",stopColor:n.gradient.colorFn(o?n.gradient.domain[0]+r*(n.gradient.domain[1]-n.gradient.domain[0]):n.gradient.domain[1]-r*(n.gradient.domain[1]-n.gradient.domain[0]))},i)});if(o){const o=12,u=n.gradient.label?0:void 0,d=n.gradient.label?8:0;return e("g",{className:"semiotic-legend",transform:`translate(${a},${l})`,children:[t("defs",{children:t("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),n.gradient.label&&t("text",{x:i.width/2,y:u,textAnchor:"middle",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:n.gradient.label}),t("rect",{x:0,y:d,width:i.width,height:o,fill:`url(#${r})`,rx:2}),t("text",{x:0,y:d+o+12,textAnchor:"start",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[0])}),t("text",{x:i.width,y:d+o+12,textAnchor:"end",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[1])})]})}const u=n.gradient.label?-6:void 0;return e("g",{className:"semiotic-legend",transform:`translate(${a},${l+(n.gradient.label?12:0)})`,children:[t("defs",{children:t("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),n.gradient.label&&t("text",{x:7,y:u,textAnchor:"middle",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:n.gradient.label}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${r})`,rx:2}),t("text",{x:19,y:10,fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[1])}),t("text",{x:19,y:100,fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[0])})]})}(Object.assign(Object.assign({},o),{gradient:n.gradient})):null}function sl(t){return Math.round(100*t)/100+""}function al(n,i){const o=Li(i.theme),r=i.idPrefix?i.idPrefix+"-":"",s="string"==typeof i.title?i.title:void 0,a=s?r+"semiotic-title":void 0,l=i.description?r+"semiotic-desc":void 0,c=[a,l].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[s&&t("title",{id:a,children:s}),i.description&&t("desc",{id:l,children:i.description}),i.defs&&t("defs",{children:i.defs}),i.background&&"transparent"!==i.background&&t("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t("g",{id:r+"data-area",transform:i.innerTransform,children:n}),s&&t("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:s}),i.legend&&t("g",{id:r+"legend",children:i.legend}),i.outerElements]})}function ll(o,r){var s,a,l,c,u,d,h,f;const g=ji(o.theme),p=o.size||[500,300],m=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),o.margin),v=Uo(o.data),b=o.showLegend?Wi(v,o.colorAccessor||o.groupAccessor):[],x=o.legendPosition;St(o.legend)||Mt(o.legend)?ol(m,{legend:o.legend,theme:g,position:x||"right",size:p,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&b.length>0&&il(m,{categories:b,theme:g,position:x||"right",size:p,hasTitle:!!o.title,legendLayout:o.legendLayout});const k=p[0]-m.left-m.right,w=p[1]-m.top-m.bottom,A="streaming"===o.runtimeMode||["bar","swarm","waterfall"].includes(o.chartType),S=o.colorScheme||g.colors.categorical,M={chartType:o.chartType,windowSize:null!==(s=o.windowSize)&&void 0!==s?s:200,windowMode:null!==(a=o.windowMode)&&void 0!==a?a:"sliding",arrowOfTime:A&&null!==(l=o.arrowOfTime)&&void 0!==l?l:"right",extentPadding:null!==(c=o.extentPadding)&&void 0!==c?c:.1,xAccessor:A?void 0:o.xAccessor,yAccessor:A?void 0:o.yAccessor,timeAccessor:A?o.timeAccessor:void 0,valueAccessor:o.valueAccessor,colorAccessor:o.colorAccessor,sizeAccessor:o.sizeAccessor,groupAccessor:o.groupAccessor,categoryAccessor:o.categoryAccessor,lineDataAccessor:o.lineDataAccessor,xExtent:o.xExtent,yExtent:o.yExtent,sizeRange:o.sizeRange,xScaleType:o.xScaleType,yScaleType:o.yScaleType,scalePadding:o.scalePadding,binSize:o.binSize,normalize:o.normalize,boundsAccessor:o.boundsAccessor,boundsStyle:o.boundsStyle,y0Accessor:o.y0Accessor,areaGroups:o.areaGroups?o.areaGroups instanceof Set?o.areaGroups:new Set(o.areaGroups):void 0,curve:o.curve,gradientFill:!0===o.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===o.gradientFill?void 0:o.gradientFill,lineGradient:o.lineGradient,openAccessor:o.openAccessor,highAccessor:o.highAccessor,lowAccessor:o.lowAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,barStyle:o.barStyle,waterfallStyle:o.waterfallStyle,swarmStyle:o.swarmStyle,colorScheme:S,barColors:o.barColors},_=new Oe(M);if(o.data&&_.ingest({inserts:v,bounded:!0}),_.computeScene({width:k,height:w}),!_.scales||0===_.scene.length)return r&&(r.evidence=li({frameType:"xy",width:p[0],height:p[1],marks:[],title:o.title,description:o.description,annotations:o.annotations,extraWarnings:_.scales?[]:["NO_SCALES"]})),y.renderToStaticMarkup(al(null,{width:p[0],height:p[1],className:"stream-xy-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:g,innerTransform:`translate(${m.left},${m.top})`,idPrefix:o._idPrefix}));r&&(r.evidence=li({frameType:"xy",width:p[0],height:p[1],marks:_.scene,title:o.title,description:o.description,annotations:o.annotations,xDomain:ai(null===(d=null===(u=_.scales.x)||void 0===u?void 0:u.domain)||void 0===d?void 0:d.call(u)),yDomain:ai(null===(f=null===(h=_.scales.y)||void 0===h?void 0:h.domain)||void 0===f?void 0:f.call(h)),legendItems:b.length>0?b.length:void 0}));const P=o._idPrefix,O=o.showGrid?function(n,i,o,r){const{grid:s}=Li(o),a=r?r+"-":"",l=n.x.ticks(5),c=n.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((e,o)=>{const r=n.x(e);return t("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gx-"+o)}),c.map((e,o)=>{const r=n.y(e);return t("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gy-"+o)})]})}(_.scales,{width:k,height:w},g,P):null,T=_.scene.map((t,e)=>yi(t,e,P)).filter(Boolean),$=!1!==o.showAxes?function(n,i,o,r,s){var a,l,c,u;const d=Li(r),h=n.x.ticks(5).map(t=>({pixel:n.x(t),label:(o.xFormat||o.tickFormatTime||sl)(t)})),f=n.y.ticks(5).map(t=>({pixel:n.y(t),label:(o.yFormat||o.tickFormatValue||sl)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:d.border,strokeWidth:1}),h.map((n,o)=>e("g",{transform:`translate(${n.pixel},${i.height})`,children:[t("line",{y2:5,stroke:d.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"xtick-"+o)),o.xLabel&&t("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,children:o.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:d.border,strokeWidth:1}),f.map((n,i)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:d.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"ytick-"+i)),o.yLabel&&t("text",{x:15-(null!==(l=null===(a=o.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:i.height/2,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${i.height/2})`,children:o.yLabel})]})}(_.scales,{width:k,height:w},o,g,P):null,j=o.annotations?Oo({annotations:o.annotations,autoPlaceAnnotations:o.autoPlaceAnnotations,scales:{x:_.scales.x,y:_.scales.y},layout:{width:k,height:w},theme:g,xAccessor:"string"==typeof o.xAccessor?o.xAccessor:void 0,yAccessor:"string"==typeof o.yAccessor?o.yAccessor:void 0,idPrefix:P}):null,L=o.svgPreRenderers&&_.scales?o.svgPreRenderers.map((e,n)=>{try{return t(i.Fragment,{children:e(_.scene,_.scales,{width:k,height:w})},"pre-"+n)}catch(t){return null}}).filter(Boolean):null,C=o.showLegend?0===b.length?null:Fi({categories:b,colorScheme:o.colorScheme,theme:g,position:o.legendPosition||"right",totalWidth:p[0],totalHeight:p[1],margin:m,hasTitle:!!o.title,legendLayout:o.legendLayout}):null,z=i.isValidElement(o.legend)?o.legend:rl(o.legend,{theme:g,position:o.legendPosition||"right",size:p,margin:m,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||C,D=e(n,{children:[o.backgroundGraphics,L,O,T,$,j,o.foregroundGraphics]});return y.renderToStaticMarkup(al(D,{width:p[0],height:p[1],className:"stream-xy-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:g,innerTransform:`translate(${m.left},${m.top})`,legend:z,idPrefix:o._idPrefix}))}function cl(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const ul=new Set(["tree","cluster","treemap","circlepack","partition"]);function dl(o,r){var s,a,l,c,u;const d=ji(o.theme),h=o.chartType||"force",f=()=>li({frameType:"network",width:g[0],height:g[1],marks:[],title:o.title,description:o.description,annotations:o.annotations,nodeCount:0,edgeCount:0}),g=o.size||[500,500],p=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),o.margin),m=o.showLegend?(()=>{const t="string"==typeof(e=o.colorBy)||"function"==typeof e?o.colorBy:void 0;var e;if(!t)return[];const n=Uo(o.nodes||[]);if(n.length>0)return Wi(n,t);const i=Array.isArray(o.edges)?Uo(o.edges):[];if(0===i.length)return[];const r=cl(o.sourceAccessor,"source"),s=cl(o.targetAccessor,"target");return Wi(Array.from(new Set(i.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),t)})():[],v=o.legendPosition;St(o.legend)||Mt(o.legend)?ol(p,{legend:o.legend,theme:d,position:v||"right",size:g,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&m.length>0&&il(p,{categories:m,theme:d,position:v||"right",size:g,hasTitle:!!o.title,legendLayout:o.legendLayout});const b=g[0]-p.left-p.right,x=g[1]-p.top-p.bottom,k=function(t){return Gn[t]}(h);if(!k)throw Error(`No layout plugin found for chart type: "${h}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const w={chartType:h,nodeIDAccessor:o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,childrenAccessor:o.childrenAccessor,hierarchySum:o.hierarchySum,orientation:o.orientation,nodeAlign:o.nodeAlign,nodePaddingRatio:o.nodePaddingRatio,nodeWidth:o.nodeWidth,iterations:o.iterations,forceStrength:o.forceStrength,padAngle:o.padAngle,groupWidth:o.groupWidth,sortGroups:o.sortGroups,edgeSort:o.edgeSort,treeOrientation:o.treeOrientation,edgeType:o.edgeType,padding:o.padding,paddingTop:o.paddingTop,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle,nodeLabel:o.nodeLabel,showLabels:o.showLabels,colorBy:o.colorBy,colorScheme:o.colorScheme||d.colors.categorical,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,colorByDepth:o.colorByDepth,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,customNetworkLayout:o.customNetworkLayout,layoutConfig:o.layoutConfig};let A,S;if(ul.has(h)){const t=o.data||o.edges;if(!t||Array.isArray(t))return r&&(r.evidence=f()),y.renderToStaticMarkup(al(null,{width:g[0],height:g[1],className:"stream-network-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:d,innerTransform:`translate(${p.left},${p.top})`,idPrefix:o._idPrefix}));w.__hierarchyRoot=t,A=[],S=[]}else{const t=Uo(o.nodes||[]),e=Array.isArray(o.edges)?Uo(o.edges):[];if(0===t.length&&0===e.length)return r&&(r.evidence=f()),y.renderToStaticMarkup(al(null,{width:g[0],height:g[1],className:"stream-network-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:d,innerTransform:`translate(${p.left},${p.top})`,idPrefix:o._idPrefix}));if(S=function(t,e){const n=cl(e.sourceAccessor,"source"),i=cl(e.targetAccessor,"target"),o=cl(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:i(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(e,w),0===t.length&&S.length>0){const t=new Set;for(const e of S){const n=nl(e.source),i=nl(e.target);n&&t.add(n),i&&t.add(i)}A=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 A=function(t,e){const n=cl(e.nodeIDAccessor,"id");return t.map(t=>{var e,i;return{id:n(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,w)}let M=[],_=[],P=[],O=null;if(w.customNetworkLayout){const t=Hn(w.colorScheme,d.colors.categorical,It),e=Xn(t),n={nodes:A,edges:S,dimensions:{width:b,height:x,plot:{x:0,y:0,width:b,height:x}},theme:{semantic:d.colors,categorical:[...t]},resolveColor:e,config:null!==(s=w.layoutConfig)&&void 0!==s?s:{}},i=w.customNetworkLayout(n);M=null!==(a=i.sceneNodes)&&void 0!==a?a:[],_=null!==(l=i.sceneEdges)&&void 0!==l?l:[],P=null!==(c=i.labels)&&void 0!==c?c:[],O=null!==(u=i.overlays)&&void 0!==u?u:null}else{k.computeLayout(A,S,w,[b,x]);const t=k.buildScene(A,S,w,[b,x]);M=t.sceneNodes,_=t.sceneEdges,P=t.labels}const T=Li(d);for(const t of P)t.fill||(t.fill=T.text);r&&(r.evidence=li({frameType:"network",width:g[0],height:g[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:o.title,description:o.description,annotations:o.annotations,nodeCount:M.length,edgeCount:_.length}));const $=_.map((e,n)=>function(e,n){switch(e.type){case"line":return t("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 i=e;return t("path",{d:i.pathD,fill:gi(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t("path",{d:i.pathD,fill:gi(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t("path",{d:i.pathD,fill:gi(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),j=M.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:gi(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:gi(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=W().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(fi)||"";return t("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:gi(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),L=P.map((e,n)=>function(e,n){return t("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),C=o.annotations?Oo({annotations:o.annotations,autoPlaceAnnotations:o.autoPlaceAnnotations,scales:{},layout:{width:b,height:x},theme:d,idPrefix:o._idPrefix}):null,z=o.showLegend?(()=>{const t="string"==typeof(e=o.colorBy)||"function"==typeof e?o.colorBy:void 0;var e;if(!t)return[];const n=Wi(A.length>0?A.map(t=>t.data||{id:t.id}):Array.from(new Set(S.flatMap(t=>[nl(t.source),nl(t.target)]).filter(Boolean))).map(t=>({id:t})),t);return 0===n.length?null:Fi({categories:n,colorScheme:o.colorScheme,theme:d,position:o.legendPosition||"right",totalWidth:g[0],totalHeight:g[1],margin:p,hasTitle:!!o.title,legendLayout:o.legendLayout})})():null,D=i.isValidElement(o.legend)?o.legend:rl(o.legend,{theme:d,position:o.legendPosition||"right",size:g,margin:p,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||z,E=e(n,{children:[o.backgroundGraphics,$,j,L,C,o.foregroundGraphics,O]});return y.renderToStaticMarkup(al(E,{width:g[0],height:g[1],className:"stream-network-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:d,innerTransform:`translate(${p.left},${p.top})`,legend:D,idPrefix:o._idPrefix}))}function hl(o,r){var s,a,l,c,u,d,h,f,g;const p=ji(o.theme),m=o.size||[500,400],v=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),o.margin),b=Uo(o.data),x=o.showLegend?Wi(b,o.colorAccessor||o.stackBy||o.groupBy):[],k=o.legendPosition;St(o.legend)||Mt(o.legend)?ol(v,{legend:o.legend,theme:p,position:k||"right",size:m,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&x.length>0&&il(v,{categories:x,theme:p,position:k||"right",size:m,hasTitle:!!o.title,legendLayout:o.legendLayout});const w=m[0]-v.left-v.right,A=m[1]-v.top-v.bottom,S=o.projection||"vertical",M="radial"===S,_={chartType:o.chartType,windowSize:null!==(s=o.windowSize)&&void 0!==s?s:1e4,windowMode:null!==(a=o.windowMode)&&void 0!==a?a:"sliding",extentPadding:null!==(l=o.extentPadding)&&void 0!==l?l:.05,projection:S,oAccessor:o.oAccessor,rAccessor:o.rAccessor,colorAccessor:o.colorAccessor,stackBy:o.stackBy,groupBy:o.groupBy,categoryAccessor:o.categoryAccessor,valueAccessor:o.valueAccessor,timeAccessor:o.timeAccessor,rExtent:o.rExtent,oExtent:o.oExtent,barPadding:o.barPadding,roundedTop:o.roundedTop,innerRadius:o.innerRadius,cornerRadius:o.cornerRadius,normalize:o.normalize,startAngle:o.startAngle,sweepAngle:o.sweepAngle,bins:o.bins,showOutliers:o.showOutliers,showIQR:o.showIQR,amplitude:o.amplitude,oSort:o.oSort,connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,dynamicColumnWidth:o.dynamicColumnWidth,pieceStyle:o.pieceStyle,summaryStyle:o.summaryStyle,colorScheme:o.colorScheme||p.colors.categorical,barColors:o.barColors},P=new Zn(_);if(o.data&&P.ingest({inserts:b,bounded:!0}),P.computeScene({width:w,height:A}),!P.scales||0===P.scene.length)return r&&(r.evidence=li({frameType:"ordinal",width:m[0],height:m[1],marks:[],title:o.title,description:o.description,annotations:o.annotations,extraWarnings:P.scales?[]:["NO_SCALES"]})),y.renderToStaticMarkup(al(null,{width:m[0],height:m[1],className:"stream-ordinal-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:p,innerTransform:`translate(${v.left},${v.top})`,idPrefix:o._idPrefix}));if(r){const t=null===(u=null===(c=P.scales.o)||void 0===c?void 0:c.domain)||void 0===u?void 0:u.call(c);r.evidence=li({frameType:"ordinal",width:m[0],height:m[1],marks:P.scene,title:o.title,description:o.description,annotations:o.annotations,yDomain:ai(null===(h=null===(d=P.scales.r)||void 0===d?void 0:d.domain)||void 0===h?void 0:h.call(d)),categories:Array.isArray(t)?t.map(String):void 0})}const O=o._idPrefix,T=o.showGrid?function(e,n,i,o){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=Li(i),a=o?o+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,i)=>{const o=r.r(e);return t("line",{x1:0,y1:o,x2:n.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,i)=>{const o=r.r(e);return t("line",{x1:o,y1:0,x2:o,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}(P,{width:w,height:A},p,O):null,$=P.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let j=null;if($){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 i=0;for(let t=0;n.length>t;t++)i=31*i+n.charCodeAt(t)|0;return"c"+(i>>>0).toString(36)}(o),i=new Set;for(const t of P.scene)"rect"===t.type&&(null===(f=t.datum)||void 0===f?void 0:f.__barFunnelIsDropoff)&&i.add("string"==typeof t.style.fill?t.style.fill:"#666");j=Array.from(i).map((i,o)=>function(n){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:s=1.5,spacing:a=6,angle:l=45}=n,c=Math.max(8,Math.ceil(2*a));return e("pattern",{id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==l?`rotate(${l})`:void 0,children:[o&&"transparent"!==o&&t("rect",{width:c,height:c,fill:o}),t("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:c,stroke:r,strokeWidth:s})]},i)}({id:`funnel-hatch-${n}-${o}`,background:i,stroke:"transparent"===p.colors.background?"#fff":p.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((t,e)=>r.set(t,`funnel-hatch-${n}-${e}`));for(const t of P.scene)if("rect"===t.type&&(null===(g=t.datum)||void 0===g?void 0:g.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const L=P.scene.map((t,e)=>mi(t,e,O)).filter(Boolean),C=!1!==o.showAxes?function(n,i,o,r,s){var a,l,c,u,d,h,f,g;const p=n.scales;if(!p)return null;if("radial"===p.projection)return null;const y=Li(r),m="vertical"===p.projection,v=o.categoryFormat||o.oFormat,b=o.valueFormat||o.rFormat,x=o.categoryLabel||o.oLabel,k=o.valueLabel||o.rLabel,w=Object.values(n.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),A=p.r.ticks(5).map(t=>({pixel:p.r(t),label:(b||sl)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),w.map((n,o)=>e("g",{transform:`translate(${n.pixel},${i.height})`,children:[t("line",{y2:5,stroke:y.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oxtick-"+o)),x&&t("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:x}),t("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((n,i)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:y.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oytick-"+i)),k&&t("text",{x:15-(null!==(l=null===(a=o.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${i.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((n,o)=>e("g",{transform:`translate(${n.pixel},${i.height})`,children:[t("line",{y2:5,stroke:y.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oxtick-"+o)),k&&t("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),w.map((n,i)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:y.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oytick-"+i)),x&&t("text",{x:15-(null!==(h=null===(d=o.margin)||void 0===d?void 0:d.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=o.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${i.height/2})`,children:x})]})}(P,{width:w,height:A},o,p,O):null,z=o.annotations?Oo({annotations:o.annotations,autoPlaceAnnotations:o.autoPlaceAnnotations,scales:{r:P.scales.r,y:"vertical"===P.scales.projection?P.scales.r:void 0},layout:{width:w,height:A},theme:p,projection:S,idPrefix:O}):null,D=o.showLegend?0===x.length?null:Fi({categories:x,colorScheme:o.colorScheme,theme:p,position:o.legendPosition||"right",totalWidth:m[0],totalHeight:m[1],margin:v,hasTitle:!!o.title,legendLayout:o.legendLayout}):null,E=i.isValidElement(o.legend)?o.legend:rl(o.legend,{theme:p,position:o.legendPosition||"right",size:m,margin:v,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||D,N=M?v.left+w/2:v.left,R=M?v.top+A/2:v.top,F=e(n,{children:[o.backgroundGraphics,T,L,C,z,o.foregroundGraphics]});return y.renderToStaticMarkup(al(F,{width:m[0],height:m[1],className:"stream-ordinal-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:p,innerTransform:`translate(${N},${R})`,legend:E,defs:j,idPrefix:o._idPrefix}))}function fl(o,r){var s,a,l,c,u,d,h,f,g,p;const m=ji(o.theme),v=o.size||[o.width||600,o.height||400],b=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),o.margin),x=Array.isArray(o.areas)?Uo(o.areas):o.areas,k=Uo(o.points),w=Uo(o.lines),A=o.showLegend?(()=>{const t="string"==typeof(e=o.colorBy)||"function"==typeof e?o.colorBy:void 0;var e;return Wi(k.length>0?k:Array.isArray(x)&&x.length>0?"string"==typeof t?x.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):x:[],t)})():[],S=o.legendPosition;St(o.legend)||Mt(o.legend)?ol(b,{legend:o.legend,theme:m,position:S||"right",size:v,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&A.length>0&&il(b,{categories:A,theme:m,position:S||"right",size:v,hasTitle:!!o.title,legendLayout:o.legendLayout});const M=v[0]-(null!==(s=b.left)&&void 0!==s?s:0)-(null!==(a=b.right)&&void 0!==a?a:0),_=v[1]-(null!==(l=b.top)&&void 0!==l?l:0)-(null!==(c=b.bottom)&&void 0!==c?c:0),P=new ri({projection:o.projection||"equalEarth",xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineDataAccessor:o.lineDataAccessor,pointIdAccessor:o.pointIdAccessor,lineType:o.lineType,areaStyle:o.areaStyle,pointStyle:o.pointStyle,lineStyle:o.lineStyle,graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:o.projectionTransform});if(x){if("string"==typeof x)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${x}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${x}')\` before calling renderGeoToStaticSVG.`);P.setAreas(x)}if(o.points&&P.setPoints(k),o.lines&&P.setLines(w),P.computeScene({width:M,height:_}),r&&(r.evidence=li({frameType:"geo",width:v[0],height:v[1],marks:P.scene,title:o.title,description:o.description,annotations:o.annotations,legendItems:A.length>0?A.length:void 0})),0===P.scene.length){const t=o.backgroundGraphics||o.foregroundGraphics||o.annotations?e(n,{children:[o.backgroundGraphics,o.annotations?Oo({annotations:o.annotations,autoPlaceAnnotations:o.autoPlaceAnnotations,scales:{geoProjection:(null===(u=P.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>P.scales.projectedPoint(t,e):void 0},layout:{width:M,height:_},theme:m,idPrefix:o._idPrefix}):null,o.foregroundGraphics]}):null;return y.renderToStaticMarkup(al(t,{width:v[0],height:v[1],className:"stream-geo-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:m,innerTransform:`translate(${null!==(d=b.left)&&void 0!==d?d:0},${null!==(h=b.top)&&void 0!==h?h:0})`,idPrefix:o._idPrefix}))}const O=P.scene.map((e,n)=>function(e,n){var i,o,r,s,a,l;switch(e.type){case"geoarea":{const r=e;return r.pathData?t("path",{d:r.pathData,fill:gi(r.style.fill,"#e0e0e0"),fillOpacity:null!==(i=r.style.fillOpacity)&&void 0!==i?i:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(o=r._decayOpacity)&&void 0!==o?o:1},"geoarea-"+n):null}case"point":{const i=e;return t("circle",{cx:i.x,cy:i.y,r:i.r,fill:gi(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:null!==(s=i._decayOpacity)&&void 0!==s?s:null!==(a=i.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const i=e;if(2>i.path.length)return null;const o="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return t("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(l=i.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(e,n)).filter(Boolean),T=o.annotations?Oo({annotations:o.annotations,autoPlaceAnnotations:o.autoPlaceAnnotations,scales:{geoProjection:(null===(f=P.scales)||void 0===f?void 0:f.projectedPoint)?([t,e])=>P.scales.projectedPoint(t,e):void 0},layout:{width:M,height:_},theme:m,idPrefix:o._idPrefix}):null,$=o.showLegend?0===A.length?null:Fi({categories:A,colorScheme:o.colorScheme,theme:m,position:o.legendPosition||"right",totalWidth:v[0],totalHeight:v[1],margin:b,hasTitle:!!o.title,legendLayout:o.legendLayout}):null,j=i.isValidElement(o.legend)?o.legend:rl(o.legend,{theme:m,position:o.legendPosition||"right",size:v,margin:b,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||$,L=e(n,{children:[o.backgroundGraphics,O,T,o.foregroundGraphics]});return y.renderToStaticMarkup(al(L,{width:v[0],height:v[1],className:"stream-geo-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:m,innerTransform:`translate(${null!==(g=b.left)&&void 0!==g?g:0},${null!==(p=b.top)&&void 0!==p?p:0})`,legend:j,idPrefix:o._idPrefix}))}function gl(t,e){switch(t){case"xy":return ll(e);case"ordinal":return hl(e);case"network":return dl(e);case"geo":return fl(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function pl(t){return ll(t)}function yl(t){return hl(t)}function ml(t){return dl(t)}function vl(t){return fl(t)}const bl=["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 xl(t,e,n){return wl(t,e).svg}function kl(t,e,n){var i;const o={},{svg:r,frameType:s}=wl(t,e,0,o),a=null!==(i=o.evidence)&&void 0!==i?i:li({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}}function wl(i,o,r,s){var a;const{data:l,width:c=600,height:u=400,theme:d,title:h,description:f,showLegend:g,showGrid:p,background:m,className:v,annotations:b,margin:x,colorScheme:k,colorBy:w,legendPosition:A}=o,S=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&0>e.indexOf(i)&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);i.length>o;o++)0>e.indexOf(i[o])&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}(o,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),M=[c,u],_=S.frameProps||{},P=function(t,e){const n={};for(const i of e)void 0!==t[i]&&(n[i]=t[i]);return n}(S,bl),O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_),P),{theme:d,title:h,description:f,showLegend:g,showGrid:p,background:m,className:v,annotations:b,size:M}),void 0!==x&&{margin:x}),void 0!==k&&{colorScheme:k}),void 0!==A&&{legendPosition:A}),{_idPrefix:S._idPrefix}),T=el[i];if(!T)throw Error(`Unknown chart component: "${i}". See CLAUDE.md for supported chart types.`);const $=T.buildProps(l,w,k,O,S);let j=(0,{xy:ll,ordinal:hl,network:dl,geo:fl}[T.frameType])($,s);if("GaugeChart"===i&&$.__gauge){const i=$.__gauge,o=O.margin||{top:20,right:20,bottom:30,left:40},r=(c||300)-o.left-o.right,s=(u||300)-o.top-o.bottom,l=Math.min(r,s)/2*.85,h=o.left+r/2,f=o.top+s/2,g=Math.max(i.gMin,Math.min(i.gMax,null!==(a=i.value)&&void 0!==a?a:i.gMin)),p=(i.startAngleDeg+(i.gMax===i.gMin?0:(g-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,m=ji(d).colors.text,v=y.renderToStaticMarkup(e(n,{children:[t("line",{x1:h,y1:f,x2:h+l*Math.cos(p),y2:f+l*Math.sin(p),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:h,cy:f,r:4,fill:m})]}));j=j.replace("</svg>",v+"</svg>")}return{svg:j,frameType:T.frameType}}function Al(t,e){return At(this,arguments,void 0,function*(t,e,n={}){var i,o,r;const{format:s="png",scale:a=1,background:l}=n;let c,u;c=["xy","ordinal","network","geo"].includes(t)?gl(t,e):xl(t,e),l&&(c=c.replace(/<svg /,`<svg style="background:${l}" `));try{const t="sharp",e=yield import(t);u=null!==(i=e.default)&&void 0!==i?i: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===(o=e.size)||void 0===o?void 0:o[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()})}function Sl(n,i={}){var o;const{title:r,subtitle:s,theme:a,width:l=1200,height:c,layout:u={},background:d}=i,h=Li(ji(a)),f=u.columns||2,g=null!==(o=u.gap)&&void 0!==o?o:16;let p=0;r&&(p+=30),s&&(p+=20),p>0&&(p+=10);const m=Math.floor((l-g-g*(f-1))/f),v=[];let b=0,x=p+g,k=0;for(const t of n){const e=Math.min(t.colSpan||1,f),n=t.props.height||300;b+e>f&&(x+=k+g,b=0,k=0),v.push({chart:t,x:g/2+b*(m+g),y:x,w:m*e+g*(e-1),h:n}),k=Math.max(k,n),b+=e}const w=c||x+k+g,A=v.map((e,n)=>{const{chart:i,x:o,y:r,w:s,h:l}=e,c=Object.assign(Object.assign({},i.props),{width:s,height:l,theme:a,_idPrefix:"chart-"+n});let u;return u=i.component?xl(i.component,c):i.frameType?gl(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${l}"></svg>`,t("g",{transform:`translate(${o},${r})`,children:t("foreignObject",{width:s,height:l,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:w,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t("title",{children:r}),d&&t("rect",{x:0,y:0,width:l,height:w,fill:d}),r&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),s&&t("text",{x:l/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:s}),A]});return y.renderToStaticMarkup(S)}function Ml(t,e,n,i={}){const{stepSize:o,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=n.width||600,g=n.height||400,p=ji(n.theme),y=Object.assign(Object.assign(Object.assign({},n),a&&{xExtent:a}),l&&{yExtent:l});if(!e||0===e.length)return[];const m=o||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 b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),x=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-x.left-x.right,w=g-x.top-x.bottom,A=[];if(b)for(let i=0;v.length>i;i++){const o=v[i],s=e.slice(r?Math.max(0,o-r):0,o),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||p.colors.categorical},h&&{decay:h}),l=new Zn(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(Tl(l.scene,f,g,p,y))}else for(let i=0;v.length>i;i++){const o=v[i],s=e.slice(r?Math.max(0,o-r):0,o),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||p.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}}),b=new Oe(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:k,height:w}),0===b.scene.length)continue;const x=b.scales?{y:b.scales.y}:void 0;if(A.push(Ol(b.scene,f,g,p,y,x)),c>0&&i>0&&b.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/c*t),A.push(Ol(b.scene,f,g,p,y,x))}}return A}function _l(t,e,n={}){return e.map(e=>{try{return xl(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>`}})}function Pl(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function Ol(i,o,r,s,a,l){const c=Li(s),u=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),d=o-u.left-u.right,h=r-u.top-u.bottom,f=Pl(a,s),g=i.map((t,e)=>yi(t,e)).filter(Boolean),p=function(i,o,r,s,a,l){var c;if(!i||0===i.length)return null;const u=Li(s),d=[];for(let n=0;i.length>n;n++){const s=i[n];if("y-threshold"===s.type&&null!=s.value){let i=null;if(l)i=l(s.value);else if(a){const[t,e]=a,n=e-t;if(0===n)continue;i=r-(s.value-t)/n*r}if(null==i)continue;const h=s.color||u.primary,f=null!==(c=s.strokeWidth)&&void 0!==c?c:1.5,g=s.labelPosition||"right";d.push(e("g",{children:[t("line",{x1:0,y1:i,x2:o,y2:i,stroke:h,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?o/2:o-4,y:i-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:u.tickSize,fill:h,fontFamily:u.fontFamily,children:s.label})]},"ann-"+n))}}return d.length>0?t(n,{children:d}):null}(a.annotations,d,h,s,a.yExtent,null==l?void 0:l.y),m="string"==typeof a.title?a.title:void 0,v="string"==typeof a.description?a.description:void 0,b=m?"semiotic-title":void 0,x=v?"semiotic-desc":void 0,k=[b,x].filter(Boolean).join(" ")||void 0,w=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:r,role:"img","aria-labelledby":k,style:{fontFamily:c.fontFamily},children:[m&&t("title",{id:b,children:m}),v&&t("desc",{id:x,children:v}),f&&t("rect",{x:0,y:0,width:o,height:r,fill:f}),e("g",{transform:`translate(${u.left},${u.top})`,children:[p,g]}),m&&t("text",{x:o/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:m})]});return y.renderToStaticMarkup(w)}function Tl(n,i,o,r,s){const a=Li(r),l=Object.assign({top:20,right:20,bottom:30,left:40},s.margin),c="radial"===s.projection,u=c?l.left+(i-l.left-l.right)/2:l.left,d=c?l.top+(o-l.top-l.bottom)/2:l.top,h=Pl(s,r),f=n.map((t,e)=>mi(t,e)).filter(Boolean),g="string"==typeof s.title?s.title:void 0,p="string"==typeof s.description?s.description:void 0,m=g?"semiotic-title":void 0,v=p?"semiotic-desc":void 0,b=[m,v].filter(Boolean).join(" ")||void 0,x=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":b,style:{fontFamily:a.fontFamily},children:[g&&t("title",{id:m,children:g}),p&&t("desc",{id:v,children:p}),h&&t("rect",{x:0,y:0,width:i,height:o,fill:h}),t("g",{transform:`translate(${u},${d})`,children:f}),g&&t("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return y.renderToStaticMarkup(x)}function $l(t,e,n){return At(this,arguments,void 0,function*(t,e,n,i={}){var o,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b;const{fps:x=12,loop:k=!0,scale:w=1,background:A}=i,S=n.height||400,M=Math.round((n.width||600)*w),_=Math.round(S*w),P=Ml(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,i);if(0===P.length)throw Error("No frames generated — check that data is not empty");let O,T,$,j;try{const t="sharp",e=yield import(t);O=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);T=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,$=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,j=null!==(m=null!==(p=e.applyPalette)&&void 0!==p?p:null===(y=e.default)||void 0===y?void 0:y.applyPalette)&&void 0!==m?m:null===(b=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===b?void 0:b.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const L=Math.round(1e3/x),C=T();for(let t=0;P.length>t;t++){const e=P[t],n=yield O(Buffer.from(e),{density:72*w}).resize(M,_).ensureAlpha().raw().toBuffer(),i=new Uint8Array(n),o=$(i,256),r=j(i,o);C.writeFrame(r,M,_,{palette:o,delay:L,repeat:k?0:-1})}return C.finish(),Buffer.from(C.bytes())})}export{Ml as generateFrameSVGs,_l as generateFrameSequence,xl as renderChart,kl as renderChartWithEvidence,Sl as renderDashboard,vl as renderGeoToStaticSVG,ml as renderNetworkToStaticSVG,yl as renderOrdinalToStaticSVG,$l as renderToAnimatedGif,Al as renderToImage,gl as renderToStaticSVG,pl as renderXYToStaticSVG,ji as resolveTheme,Li as themeStyles};
|
|
1
|
+
import*as t from"react-dom/server";import*as e from"react";import{scaleOrdinal as n}from"d3-scale";function i(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function o(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function r(t){const e=t.map(i),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return o(t,n,i)}if(t>=1){const[t,i,r]=e[n];return o(t,i,r)}const i=t*n,r=Math.floor(i),s=i-r,[a,c,l]=e[r],[u,d,h]=e[r+1];return o(Math.round(a+(u-a)*s),Math.round(c+(d-c)*s),Math.round(l+(h-l)*s))}}var s=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],a=r(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),c=r(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),l=r(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),u=r(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),d=r(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),h=r(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),f=r(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),p=r(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),y=r(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),g=r(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),m=r(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),x=r(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),b={blues:a,reds:c,greens:l,viridis:f,oranges:u,purples:d,greys:h,plasma:p,inferno:y,magma:g,cividis:m,turbo:x};r(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),r(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),r(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),r(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),r(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),r(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),r(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var v={category10:s,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...b},w=s,k=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],S=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 A(t,e,n){if("function"==typeof e){const i=e(t);return n&&i&&"string"==typeof i&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||S.has(e)}(i)?n(i):i}const i=t?.[e]+"";return n?n(i):w[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)}(i))%w.length]}function M(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const n=t[e];return"string"==typeof n&&n.length>0?n:void 0}function P(t,e,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const t=i;return e=>M(t,e)??"#999"}const o=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),r=o.every(t=>!isNaN(Number(t)));if(Array.isArray(i))return n().domain(o).range(i).unknown("#999");const s=v[i]||v.category10;if(r&&"function"==typeof s){let t=-1/0;for(const e of o){const n=Number(e);n>t&&(t=n)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:w;return n().domain(o).range(t).unknown("#999")}}var _=Object.freeze([]);function I(t){if(!t)return _;let e=!1;for(let n=0;t.length>n;n++){const i=t[n];if(null==i||"object"!=typeof i){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 C(t,e){return"touch"===e?Math.max(t,24):t}function T(t){return Array.isArray(t)?t[0]:t}function R(t,e,n,i){return{data:T(t),x:e,y:n,__semioticHoverData:!0,...i}}var L=["name","label","title"],$=["type","kind","category","group","class","status","role","shape"],z=["value","amount","total","count","weight","score"],D=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function E(t,e){for(const n of e){const e=t.find(t=>t.lower===n);if(e)return e}}import{jsx as B,jsxs as F}from"react/jsx-runtime";var N={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 O(t,e){return"function"==typeof e?e(t):t[e]}function W(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 j(t={}){const{fields:e,title:n,format:i,style:o={},className:r=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const a=[];if(n){const e=O(t,n);s=W(e,i)}if(e&&e.length>0)e.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const s=O(t,o);a.push({label:n,value:W(s,r)})});else if(!n){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=W(t[n],i);break}if(!s){const e=Object.keys(t).filter(t=>!t.startsWith("_"));e.length>0&&(s=W(t[e[0]],i))}}const c={...N,...o};return F("div",{className:("semiotic-tooltip "+r).trim(),style:c,children:[s&&B("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((t,e)=>F("div",{style:{marginTop:0===e&&s?"4px":0},children:[t.label&&F("span",{children:[t.label,": "]}),t.value]},e))]})}}function Y(t){if(!0!==t){if("function"==typeof t){const e=t;return t=>{let n=T(!0===t?.__semioticHoverData||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?t.data??{}:t);("node"===t?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===t?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data);const i=e(n);return null==i?null:B("div",{className:"semiotic-tooltip",style:N,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?j(t):j())}}function q(t){const{title:e,description:n,summary:i,accessibleTable:o,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:c}=t,l={};return e&&(l.title=e),n&&(l.description=n),i&&(l.summary=i),void 0!==o&&(l.accessibleTable=o),r&&(l.className=r),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function H(t){const{linkedHover:e,selection:n,onObservation:i,onClick:o,hoverRadius:r,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=t,f={},p=l?.enabled?Math.max(r??30,Math.ceil((l.targetSize||44)/2),24):r;return(a||e||i||o||s)&&(f.customHoverBehavior=u),d&&(c||(h?i||o||e:i||o)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(e||s||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}import{useMemo as X,forwardRef as G,useRef as V,useState as U,useImperativeHandle as K,useCallback as Z}from"react";import*as Q from"react";import{useRef as J,useState as tt,useEffect as et,useMemo as nt,useCallback as it,useImperativeHandle as ot,useId as rt,forwardRef as st,memo as at}from"react";import{useRef as ct,useEffect as lt,useMemo as ut}from"react";import{select as dt}from"d3-selection";import{brush as ht,brushX as ft,brushY as pt}from"d3-brush";import*as yt from"react";import{jsx as gt,jsxs as mt}from"react/jsx-runtime";function xt(t,e,n,i){const[o,r]=[Math.min(...e),Math.max(...e)],s=(r-o)/20;let[a,c]=t;if(i)0>n?a=Math.max(o,a-s):c=Math.min(r,c+s);else{const t=c-a;a=Math.max(o,Math.min(r-t,a+n*s)),c=a+t}return[a,c]}function bt(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function vt(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function wt({width:t,height:e,totalWidth:n,totalHeight:i,margin:o,dimension:r,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:u,snapDuring:d,streaming:h}){const f=ct(null),p=ct(null),y=ct(a);y.current=a;const g=ct(s);g.current=s;const m=ut(()=>u?[...u].sort((t,e)=>t-e):void 0,[u]),x=ct(m);x.current=m;const b=ct(!1),v=ct(null),w=function({label:t="Data range brush",description:e="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const i=yt.useId().replace(/:/g,""),o=yt.useRef(n);return o.current=n,{description:e,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":t,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:yt.useCallback(t=>{const e=function(t){return"Escape"===t.key?{type:"clear"}:"ArrowLeft"===t.key?{type:"nudge",direction:"left",resize:t.shiftKey}:"ArrowRight"===t.key?{type:"nudge",direction:"right",resize:t.shiftKey}:"ArrowUp"===t.key?{type:"nudge",direction:"up",resize:t.shiftKey}:"ArrowDown"===t.key?{type:"nudge",direction:"down",resize:t.shiftKey}:null}(t);e&&(t.preventDefault(),o.current?.(e))},[])}}}({label:"xy"===r?"Two-dimensional data range brush":r.toUpperCase()+" data range brush",onAction:t=>{const e=g.current,n=p.current;if(!e||!n||!f.current)return;const i=dt(f.current).select(".brush-g");if("clear"===t.type)return b.current=!0,i.call(n.move,null),b.current=!1,v.current=null,void y.current(null);const o=e.x.domain(),s=e.y.domain(),a=v.current;let c=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===t.direction||"right"===t.direction,d="left"===t.direction||"down"===t.direction?-1:1;if(u&&"y"!==r&&(c=xt(c,o,d,t.resize)),u||"x"===r||(l=xt(l,s,d,t.resize)),u&&"y"===r||!u&&"x"===r)return;const h={x:c,y:l};b.current=!0,i.call(n.move,"x"===r?[e.x(c[0]),e.x(c[1])]:"y"===r?[e.y(l[1]),e.y(l[0])]:[[e.x(c[0]),e.y(l[1])],[e.x(c[1]),e.y(l[0])]]),b.current=!1,v.current=h,y.current(h)}});return lt(()=>{if(!f.current)return;const n=dt(f.current).select(".brush-g"),i="x"===r?ft():"y"===r?pt():ht();return i.extent([[0,0],[t,e]]),i.on("brush end",o=>{if(b.current)return;const s=g.current;if(!s)return;if(!o.selection)return v.current=null,void y.current(null);let a,u;if("x"===r){const[t,n]=o.selection;a=[s.x.invert(t),s.x.invert(n)],u=[s.y.invert(e),s.y.invert(0)]}else if("y"===r){const[e,n]=o.selection;a=[s.x.invert(0),s.x.invert(t)],u=[s.y.invert(n),s.y.invert(e)]}else{const[[t,e],[n,i]]=o.selection;a=[s.x.invert(t),s.x.invert(n)],u=[s.y.invert(i),s.y.invert(e)]}if("bin"===l&&"y"!==r&&("end"===o.type||"brush"===o.type&&d)){const t=x.current;t&&t.length>0?a=function(t,e){return 0===e.length?t:[bt(t[0],e),vt(t[1],e)]}(a,t):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const e=s.x(a[0]),l=s.x(a[1]);if(b.current=!0,"x"===r)n.call(i.move,[e,l]);else if("xy"===r){const t=o.selection;n.call(i.move,[[e,t[0][1]],[l,t[1][1]]])}b.current=!1}const h={x:a,y:u};v.current=h,y.current(h)}),n.call(i),p.current=i,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),p.current=null}},[t,e,r,l,c,d]),lt(()=>{if(!(h&&s&&p.current&&v.current))return;if(!f.current)return;if("y"===r)return;const t=v.current,e=s.x.domain()[0],n=dt(f.current).select(".brush-g");if(e>=t.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===l){const t=x.current;t&&t.length>0?i=vt(e,t):c&&c>0&&(i=Math.ceil(e/c)*c)}if(i>=t.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);o=!0}const a=s.x(i),u=s.x(t.x[1]);if(b.current=!0,"x"===r)n.call(p.current.move,[a,u]);else{const e=s.y(t.y[1]),i=s.y(t.y[0]);n.call(p.current.move,[[a,e],[u,i]])}if(b.current=!1,o){const e={x:[i,t.x[1]],y:t.y};v.current=e,y.current(e)}},[s,h,r,l,c]),mt("svg",{ref:f,width:n,height:i,...w.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[gt("title",{children:w.svgProps["aria-label"]}),gt("desc",{id:w.descriptionId,children:w.description}),gt("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}var kt=class{constructor(t,e){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=e?.chunkThreshold??5e3,this.chunkSize=e?.chunkSize??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=I(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=I(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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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 i=t[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),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}};import{createContext as St,useCallback as At,useContext as Mt,useMemo as Pt,useRef as _t,useSyncExternalStore as It}from"react";import{jsx as Ct}from"react/jsx-runtime";function Tt(t){let e=null;const n=()=>(e||(e=St(null)),e),i=Rt(t);return[function({children:e,initialState:i}){const o=_t(i),r=Pt(()=>Rt(t,o.current),[]),s=n();return Ct(s.Provider,{value:r,children:e})},(t,e)=>{const o=n(),r=Mt(o)??i,s=_t(t);s.current=t;const a=_t({hasValue:!1,value:void 0}),c=At(()=>{const t=s.current(r.getState()),n=a.current;return n.hasValue&&e&&e(n.value,t)?n.value:(a.current={hasValue:!0,value:t},t)},[r,e]),l=At(()=>s.current(r.getState()),[r]);return It(r.subscribe,c,l)}]}function Rt(t,e){const n=new Set;let i={...t(function(t){const e=t(i);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){i={...i,...e};for(const t of n)t()}}),...e??{}};return{getState:()=>i,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function Lt(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 $t(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:zt}}),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 zt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Dt={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}},Et={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}},Bt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:zt,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 Ft(t,e){if("light"===e)return Dt;if("dark"===e)return Et;if("high-contrast"===e)return Bt;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?Et:Dt;return $t({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return $t({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[Nt,Ot]=Tt(t=>({theme:Dt,setTheme(e){t(t=>({theme:Ft(t.theme,e)}))}})),Wt=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 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();let n=0,i=[];e.length>t&&(n=e.length-t,i=e.slice(0,n)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=n;e.length>t;t++)this.push(e[t]);return i}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),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}},jt=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 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 Yt(t,e){return t===e}function qt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Ht(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function Xt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var Gt=/^\d{4}-\d{1,2}$/;function Vt(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=Gt.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const i=Date.parse(n);return Number.isFinite(i)?i:NaN}function Ut(t){return t instanceof Date?t.getTime():"string"==typeof t?Vt(t):+t}function Kt(t){return new Set(Array.isArray(t)?t:[t])}function Zt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Qt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Jt(t,e,n){return t+(e-t)*n}function te(){return"undefined"!=typeof performance?performance.now():Date.now()}function ee(t,e,n){if(1>=n)return 1;const i=n-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 n=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>n?1:e;if("exponential"===t.type){const i=t.halfLife??t.extent/2;return e+Math.pow(.5,n/(i>0?i:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-n/t.extent))*(1-e)}({age:i-e,extent:i,type:t.type,halfLife:t.halfLife??n/2,threshold:t.stepThreshold??.5*n,minOpacity:t.minOpacity??.1})}function ne(t){const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return e}function ie(t,e,n){const i=t.duration??500,o=n-e;return i>o?1-o/i:0}function oe(t,e,n,i){let o=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,o=!0),t._pulseColor!==n&&(t._pulseColor=n,o=!0),t._pulseGlowRadius!==i&&(t._pulseGlowRadius=i,o=!0),o):(0!==t._pulseIntensity&&(t._pulseIntensity=0,o=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,o=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,o=!0),o)}function re(t,e,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const i=t.duration??500,o=e.peek();return null!=o&&i>n-o}function se(t,e,n){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),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+n;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??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 ae(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}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:o,datum:l,group:r}}function ce(t,e,n,i,o,r,s,a){const c=[];for(const r of t){const t=n(r),s=i(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(r):o;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 le(t,e,n,i){const o=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;o.set(i,-t/2)}else if("wiggle"===i){t.length>0&&o.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];let a=0,c=0,l=0;for(const t of e){const e=n(t,s)||0;a+=(2*l+e)*(e-(n(t,r)||0)),c+=e,l+=e}const u=o.get(r)??0;o.set(s,u-(c>0?a/(2*c):0))}if(t.length>0){let i=0;for(const r of t){let t=0;for(const i of e)t+=n(i,r)||0;i+=(o.get(r)??0)+t/2}const r=i/t.length;for(const e of t)o.set(e,(o.get(e)??0)-r)}}else for(const e of t)o.set(e,0);return o}function ue(t,e,n,i,o,r,s){const a=n(t),c=i(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:o,style:r,datum:t};return void 0!==s&&(l.pointId=s),l}function de(t,e,n,i,o,r,s,a){const c=n(t),l=i(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:o,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function he(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function fe(t,e,n,i,o,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function pe(t,e,n,i){return"function"==typeof e.style?e.style(i||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,i)}function ye(t,e,n,i){if(!t.scales)return null;const o=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=i.getTop(n),a=i.getBottom(n);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)&&(o.push([c,l]),r.push([c,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:pe(t,i,n,e[0]),datum:e,group:n,interactive:i.interactive}}function ge(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const i of t)i.perSeries?e.push(i):n.push(i);return{perSeries:e,aggregate:n}}function me(t,e,n){const i=[];for(const o of n){const n=ye(t,e,"__ribbon_aggregate",o);n&&i.push(n)}return i}function xe(t,e,n,i){const o=[];for(const r of i){const i=ye(t,e,n,r);i&&o.push(i)}return o}function be(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const i of e){if("band"!==i.kind)continue;const e=i.getTop(t),o=i.getBottom(t);Number.isFinite(o)&&Number.isFinite(e)&&n.push({y0:o,y1:e})}return 0===n.length?t:{...t,band:n[0],bands:n}}function ve(t,e,n,i){if(!t.config.pointStyle)return;const o=i??t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const r of i.data){let i=t.config.pointStyle(r);!i.fill&&e&&(i={...i,fill:e});const s=i.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,c=ue(r,t.scales,t.getX,o,s,i,a);c&&n.push(c)}}}var we={topOpacity:.8,bottomOpacity:.05};function ke(t){if(t)return!0===t?we:"colorStops"in t?t:{topOpacity:t.topOpacity??we.topOpacity,bottomOpacity:t.bottomOpacity??we.bottomOpacity}}import{symbol as Se,symbolCircle as Ae,symbolCross as Me,symbolDiamond as Pe,symbolSquare as _e,symbolStar as Ie,symbolTriangle as Ce,symbolWye as Te}from"d3-shape";var Re={circle:Ae,square:_e,triangle:Ce,diamond:Pe,star:Ie,cross:Me,wye:Te},Le=["circle","triangle","diamond","star","square","chevron","cross","wye"];function $e(t,e,n){if(n)return n;const i=t??"circle";return"chevron"===i?function(t){const e=1.5*ze(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):Se(Re[i]??Ae,Math.max(1,e))()??""}function ze(t){return Math.sqrt(Math.max(1,t)/Math.PI)}var De=new Map;function Ee(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){const i=Math.max(1,Math.floor(t.config.heatmapXBins??20)),o=Math.max(1,Math.floor(t.config.heatmapYBins??20)),r=t.config.heatmapAggregation??"count",s=qt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),d=(c-a||1)/i,h=(u-l||1)/o,f=i*o;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let n=0;e.length>n;n++){const r=e[n],c=t.getX(r),u=t.getY(r);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),i-1),g=Math.min(Math.floor((u-l)/h),o-1);if(0>f||0>g)continue;const m=g*i+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=n.width/i,v=n.height/o,w=t.config.showValues,k=t.config.heatmapValueFormat,S=[];for(let t=0;o>t;t++){const e=t*i;for(let n=0;i>n;n++){const i=e+n;if(0===p[i])continue;let s;switch(r){case"sum":s=y[i];break;case"mean":s=y[i]/p[i];break;default:s=p[i]}const c=(s-g)/x;S.push(fe(n*b,(o-1-t)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:t,value:s,count:p[i],sum:y[i],xCenter:a+(n+.5)*d,yCenter:l+(t+.5)*h,agg:r},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(t,e,n);if(0===e.length)return[];const i=qt(t.config.valueAccessor,"value"),o=Ht(t.config.xAccessor,"x"),r=Ht(t.config.yAccessor,"y"),s=new Map,c=new Map,l=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),a=r(n);l[t]=i,u[t]=a,s.has(i)||s.set(i,s.size),c.has(a)||c.set(a,c.size)}const d=s.size,h=c.size;if(0===d||0===h)return[];const f=Array.from(s.keys()),p=Array.from(c.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),g=p.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}if(g){p.sort((t,e)=>t-e),c.clear();for(let t=0;p.length>t;t++)c.set(p[t],t)}const m=new Float64Array(e.length),x=new Float64Array(e.length),v=Array(e.length),w=new Map;let k=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(l[t]),r=c.get(u[t]);if(void 0===o||void 0===r)continue;const a=i(n),h=r*d+o,f=w.get(h);let p;void 0!==f?p=f:(p=k++,w.set(h,p)),m[p]=h,x[p]=a,v[p]=n}let S=1/0,A=-1/0;for(let t=0;k>t;t++){const e=x[t];isFinite(e)&&(S>e&&(S=e),e>A&&(A=e))}if(!isFinite(S)||!isFinite(A))return[];const M=function(t){const e=t in b?t:"blues";let n=De.get(e);if(n)return n;n=Array(256);const i=(o=e)&&b[o]||a;var o;for(let t=0;256>t;t++)n[t]=i(t/255);return De.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),P=255/(A-S||1),_=n.width/d,I=n.height/h,C=t.config.showValues,T=t.config.heatmapValueFormat,R=[];for(let t=0;k>t;t++){const e=x[t];if(!isFinite(e))continue;const n=m[t],i=n%d;R.push(fe(i*_,(h-1-(n-i)/d)*I,_,I,M[Math.min((e-S)*P+.5|0,255)],v[t],C?{value:e,showValues:!0,valueFormat:T}:void 0))}return R}function Be(t,e,n,i,o){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 c=Math.floor(t/i)*i;let l=r.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},r.set(c,l)),l.total+=a,o){const t=o(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return r}function Fe(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:i,warned:o}=t;Ne(i)&&0===n.length&&Oe(o,"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)&&Oe(o,"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 Ne(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Ne))}function Oe(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function We(t,e,n,i){const o=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: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:i}}function je(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Ye(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=je(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=qt(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e+o:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e-o: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:je(t.y1Accessor,"y1"),getBottom:je(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as qe,scaleLog as He,scaleSymlog as Xe,scaleTime as Ge}from"d3-scale";function Ve(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Ue(t,e,n){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return He().domain(t).range(n).clamp(!0)}return"symlog"===t?Xe().domain(e).range(n):"time"===t?Ge().domain([new Date(e[0]),new Date(e[1])]).range(n):qe().domain(e).range(n)}function Ke(t,e,n){e>t.capacity&&(t.resize(e),n&&e>n.capacity&&n.resize(e))}function Ze(t,e){const n=new Wt(t.capacity);return t.forEach(()=>n.push(e)),n}function Qe(t,e,n,i){const o=t.push(e);return n&&n.push(i),o}function Je(t,e,n){if(!e||0===e.size)return;const i=new Set;if(t.forEach((t,e)=>{n(t)&&i.add(e)}),0===i.size)return;const o=e.toArray();e.clear();for(let t=0;o.length>t;t++)i.has(t)||e.push(o[t])}var tn={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 en(t,e){const n={...t};for(const t of e)n[tn[t]]++;return n}function nn(t,e,n){const i=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:i,revisions:en(n,i)}}var on=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=nn({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(t,e){const n=nn(t,e,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},rn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],sn=["scene-style","data-paint","accessibility","evidence"],an=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),cn=class{constructor(){this.tracker=new on}get last(){return this.tracker.last}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},rn)}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,e,n){return this.tracker.record({kind:"config",keys:t},e?function(t,e){const n=new Set(["layout","scene-geometry","data-paint","overlay","accessibility","evidence"]);return e&&n.add("domain"),t.some(t=>an.has(t))&&n.add("scene-style"),n}(t,n):[])}};import{quadtree as ln}from"d3-quadtree";var un=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 n=0,i=0;for(const t of e)"point"===t.type&&(n++,t.r>i&&(i=t.r));if(this.maxRadius=i,500>=n)return void(this.tree=null);const o=Array(n);let r=0;for(const t of e)"point"===t.type&&(o[r++]=t);this.tree=ln().x(t=>t.x).y(t=>t.y).addAll(o)}},dn=class t{constructor(t){if(this.xExtent=new jt,this.yExtent=new jt,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 cn,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 un,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,n,i,o,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=o??(()=>{const t=new Map;for(let e=0;n.length>e;e++)t.set(n[e],e);return 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 o=0,a=!1;for(const n of e){const e=l.get(n);if(null==e)continue;a=!0;const s=i.get(e);if(null==s)continue;const c=ie(t,s,r);c>o&&(o=c)}a&&(c=oe(n,o,s)||c);continue}const e=l.get(n.datum);if(null==e)continue;const o=i.get(e);c=oe(n,null==o?0:ie(t,o,r),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),n),this._stylePaintPending=!1,this.config=t,this.buffer=new Wt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=qt(t.timeAccessor||t.xAccessor,"time"),this.getY=qt(t.valueAccessor||t.yAccessor,"value")):(this.getX=qt(t.xAccessor,"x"),this.getY=qt(t.yAccessor,"y")),this.getGroup=Xt(t.groupAccessor),this.getCategory=Xt(t.categoryAccessor),this.getSize=t.sizeAccessor?qt(t.sizeAccessor,"size"):void 0,this.getColor=Xt(t.colorAccessor),this.getSymbol=Xt(t.symbolAccessor),this.getY0=t.y0Accessor?qt(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Ye(t),this.getPointId=Xt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?qt(t.openAccessor,"open"):void 0,this.getHigh=qt(t.highAccessor,"high"),this.getLow=qt(t.lowAccessor,"low"),this.getClose=n?qt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new Wt(t.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ze(this.buffer,te())):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 n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}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 n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}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=te();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 n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?qt(this.config.timeAccessor||this.config.xAccessor,"time"):qt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&Number.isFinite(Vt(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>Ut(e[t]):t=>Ut(n(t))}}Ke(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const n of t.inserts)Qe(this.buffer,n,this.timestampBuffer,e),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n 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=Qe(this.buffer,n,this.timestampBuffer,e);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),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:n}=this,i=this.scales,o=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(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.yExtent.extent;let a=Ve(this.xExtent.extent,e.xExtent),c=Ve(s,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&n.size>0){const t=function(t){const{config:e,groups:n,getX:i,getY:o}=t,r="exact"===e.axisExtent;if(e.normalize){const n=[0,r?1:1+e.extentPadding];return{yDomain:n,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:n}}}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,d=new Map;for(const t of n){const e=new Map;let n=0;for(const r of t.data){const t=i(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),n+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),d.set(t.key,n)}const h=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===h)p=n.map(t=>t.key);else if("insideOut"===h){const t=[...n].map(t=>t.key).sort((t,e)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(t,e)}),e=[],i=[];let o=0,r=0;for(const n of t)r>o?(e.push(n),o+=d.get(n)??0):(i.push(n),r+=d.get(n)??0);p=[...i.reverse(),...e]}else p="asc"===h?n.map(t=>t.key).sort((t,e)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(t,e)}):"desc"===h?n.map(t=>t.key).sort((t,e)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(t,e)}):n.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),n=le(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let i=1/0,o=-1/0;for(const e of t){const t=n.get(e)??0,r=u.get(e)??0;i>t&&(i=t),t+r>o&&(o=t+r)}Number.isFinite(i)&&Number.isFinite(o)||(i=0,o=0);const s=o-i,l=r?0:s>0?s*e.extentPadding:1;y=[i-l,o+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[n,i]=function(t,e,n){let i=0,o=0;for(const r of t){let t=0,s=0;for(const i of e){const e=n(i,r)||0;0>e?s+=e:t+=e}i>s&&(i=s),t>o&&(o=t)}return[i,o]}(t,p,(t,e)=>a.get(t)?.get(e)||0),o=i-n,s=r?0:o>0?o*e.extentPadding:1;y=[n-s,i+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:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&n.size>0?c=function(t,e,n,i,o,r,s){const[,a]=function(t,e,n,i,o){const r=Be(t,e,n,i,o);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,n,i,o);return[0,s?a:a+a*r]}(n,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,d):"waterfall"===e.chartType&&!l&&n.size>0?c=function(t,e,n,i){const[o,r]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(t,e),s=r-o,a=i?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(n,this.getY,e.extentPadding,d):l||c[0]===1/0||(c=function(t,e,n){if(!n.length)return t;let[i,o]=t;for(const t of e)for(const e of n){const n=e.getTop(t),r=e.getBottom(t);Number.isFinite(n)&&(i>n&&(i=n),n>o&&(o=n)),Number.isFinite(r)&&(i>r&&(i=r),r>o&&(o=r))}return[i,o]}(c,r,this.resolvedRibbons),c=function(t,e){const n=t[1]-t[0],i=e.exactMode?0:n>0?n*e.extentPadding:1,o=[null!=e.userMin?t[0]:t[0]-i,null!=e.userMax?t[1]:t[1]+i];return"log"!==e.yScaleType||o[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(o[0]=e.dataYDomain[0]/(1+e.extentPadding)),o}(c,{exactMode:d,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));c=function(t,e,n){if(!e||n)return t;const i=e[0],o=e[1];return null==i&&null==o?t:[null!=i?i:t[0],null!=o?o:t[1]]}(c,e.yExtent,!!l),({xDomain:a,yDomain:c}=function(t,e,n){let i=t,o=e;if(i[0]===1/0||i[1]===-1/0)if("time"===n){const t=Date.now();i=[t-864e5,t]}else i=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:i,yDomain:o}}(a,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:n,xDomain:i,yDomain:o}=t,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(n.width,n.height)/2-1));if(r){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:qe().domain(i).range(t),y:Ue(e.yScaleType,o,[n.height-s,s])}}const t="down"===e.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Ue(e.yScaleType,o,[s,n.width-s]),y:qe().domain(i).range(t)}}var a;return{x:Ue(e.xScaleType,i,[s,n.width-s]),y:Ue(e.yScaleType,o,[n.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.lastLayout=o):(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=h,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),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,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[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":case"glyph":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(),o=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=Ue,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,i,r[0]>r[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,o,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:n,scales:i}=this;if(!i)return[];if(n.customLayout){const o={data:e,scales:i,dimensions:{width:t.width,height:t.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??k},resolveColor:(t,e)=>{const i=this.resolveGroupColor(t);if(i)return i;const o=this.resolveLineStyle(t,e);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let r;try{r=n.customLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,i=We("xy",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{n.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=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,n.layoutSelection??null)}return Fe({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 o={scales:i,config:n,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(n.chartType){case"line":return function(t,e){const n=t.groupData(e),i=[],o=t.config.annotations?.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:o,aggregate:r}=ge(t.ribbons);if(r.length>0&&i.push(...me(t,e,r)),o.length>0)for(const e of n)i.push(...xe(t,e.data,e.key,o))}for(const e of n){const n=t.resolveLineStyle(e.key,e.data[0]),r=ae(e.data,t.scales,t.getX,t.getY,n,e.key);o&&o.length>0&&(r.colorThresholds=o),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),i.push(r)}return ve(t,n,i),i}(o,e);case"area":return function(t,e){const n=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=ge(t.ribbons);if(r.length>0&&i.push(...me(t,e,r)),o.length>0)for(const e of n)i.push(...xe(t,e.data,e.key,o))}const o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=ce(e.data,t.scales,t.getX,t.getY,o,n,e.key,r),a=ke(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),i.push(s)}return ve(t,n,i),i}(o,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=ge(t.ribbons);if(r.length>0&&i.push(...me(t,e,r)),o.length>0)for(const e of n)i.push(...xe(t,e.data,e.key,o))}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(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=ce(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=ke(t.config.gradientFill);a&&(o.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=ae(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return ve(t,n,i),i}(o,e);case"stackedarea":return function(t,e){const n=t.groupData(e),i=t.config.stackOrder??"key",o=()=>n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===i);else if("key"===i)o();else if("asc"===i||"desc"===i||"insideOut"===i){const e=new Map;for(const i of n){let n=0;for(const e of i.data){const i=t.getX(e),o=t.getY(e);Number.isFinite(i)&&Number.isFinite(o)&&(n+=o)}e.set(i.key,n)}const o=(t,e)=>e>t?-1:t>e?1:0;if("asc"===i)n.sort((t,n)=>{const i=(e.get(t.key)??0)-(e.get(n.key)??0);return 0!==i?i:o(t.key,n.key)});else if("desc"===i)n.sort((t,n)=>{const i=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==i?i:o(t.key,n.key)});else{const t=[...n].sort((t,n)=>{const i=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==i?i:o(t.key,n.key)}),i=[],r=[];let s=0,a=0;for(const n of t)a>s?(i.push(n),s+=e.get(n.key)??0):(r.push(n),a+=e.get(n.key)??0);n.length=0,n.push(...r.reverse(),...i)}}else o();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,n,i,o,r,s,a="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=n(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 o of e.data){const e=n(o),r=i(o);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let d;if(r){d=new Map;for(const e of l){let n=0;for(const i of t)n+=u.get(i.key)?.get(e)||0;d.set(e,n||1)}}const h=le(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,h.get(t)??0),m.set(t,0),x.set(t,0);for(const n of t){const t=u.get(n.key),i=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:c,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(t.curve=s),p.push(t)}a=[],c=[]};for(const n of l){const o=t.has(n);let s,l,u=o?t.get(n):0;if(r&&o&&(u/=d.get(n)),!o||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const p=e.x(n);c.push([p,e.y(s)]),a.push([p,e.y(l)]),i.set(n,l)}h(),y.set(n.key,i)}return{nodes:p,stackedTops:y}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const i of n){const n=c.get(i.key);if(n)for(const o of i.data){const i=t.getX(o),r=t.getY(o);null==i||Number.isNaN(i)||null==r||Number.isNaN(r)||!n.has(i)||e.set(o,n.get(i))}}const i=n=>e.get(n)??t.getY(n);ve(t,n,l,i)}return l}(o,e);case"scatter":case"bubble":return function(t,e){const n=[],i="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let r=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 i of n)t>i&&(t=i),i>e&&(e=i);r=n=>t===e?(o[0]+o[1])/2:o[0]+(n-t)/(e-t)*(o[1]-o[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 d=0;const h=t=>{const e=l?.[t];if(e)return e;let n=u.get(t);return n||(n=Le[d%Le.length],d++,u.set(t,n)),n};for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:a,opacity:.8},l=e.r||i;if(r&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(l=r(e))}if(s&&t.getColor&&!e.fill){const n=t.getColor(o);n&&s.has(n)&&(e={...e,fill:s.get(n)})}const u=t.getPointId?t.getPointId(o)+"":void 0;if(c){const i=h(c(o)+""),r=de(o,t.scales,t.getX,t.getY,Math.PI*l*l,i,e,u);r&&n.push(r)}else{const i=ue(o,t.scales,t.getX,t.getY,l,e,u);i&&n.push(i)}}return n}(o,e);case"heatmap":return Ee(o,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const n=Be(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let i=null;if(t.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const o=t.config.barColors?Object.keys(t.config.barColors):[],r=new Set(o),s=Array.from(e).filter(t=>!r.has(t)).sort(),a=o.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?i=t.barCategoryCache.order:(i=[...a,...s],t.barCategoryCache={key:c,order:i})}const o=[],r=t.scales,[s,a]=r.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const e of n.values()){const n=Math.max(e.start,s),u=Math.min(e.end,a);if(n>=u)continue;const f=r.x(n),p=r.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(i&&e.categories.size>0){let n=0;for(const s of i){const i=e.categories.get(s)||0;if(0===i)continue;const a=r.y(n),u=r.y(n+i);o.push(he(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:i},s)),n+=i}}else{const t=r.y(0),n=r.y(e.total);o.push(he(m,Math.min(t,n),x,Math.abs(t-n),{fill:c?.fill||l||"#007bff",...h},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of n.values())f.add(t.start),f.add(t.end);return{nodes:o,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(o,e);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const n=[],i=t.config.swarmStyle||{},o=i.radius??3,r=i.fill??t.config.themeSemantic?.primary??"#007bff",s=i.opacity??.7,a=i.stroke,c=i.strokeWidth;for(const i of e){const e=t.getX(i),l=t.getY(i);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),d=t.scales.y(l);let h=r;if(t.getCategory){const e=t.getCategory(i);h=t.config.barColors?.[e]||h}const{r:f,...p}=t.config.pointStyle?.(i)??{},y={type:"point",x:u,y:d,r:f??o,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...p},datum:i};t.getPointId&&(y.pointId=t.getPointId(i)+""),n.push(y)}return n}(o,e);case"waterfall":return function(t,e,n){const i=[],o=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===s.length)return i;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,d=r?.strokeWidth,h=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=o.x(y),v=0!==x?o.x(y+x):b+n.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=o.y(f),A=o.y(m),M=Math.min(S,A),P=Math.abs(S-A),_={fill:0>g?c:a,stroke:u,strokeWidth:d};null!=h&&(_.opacity=h),i.push(he(w,M,k,P,_,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth})),f=m}return i}(o,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const n=t.config.candlestickRangeMode??!1;if(!(n||t.getOpen&&t.getClose))return[];const i=[],o=t.config.candlestickStyle||{},r=o.rangeColor||"#6366f1",s=n?r:o.upColor||"#28a745",a=n?r:o.downColor||"#dc3545",c=n?r:o.wickColor||"#333",l=o.wickWidth||(n?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let e=1/0;for(let n=1;u.length>n;n++){const i=Math.abs(t.scales.x(u[n])-t.scales.x(u[n-1]));i>0&&e>i&&(e=i)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else d=6;for(const o of e){const e=t.getX(o);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(o),u=t.getLow(o);if(null==r||Number.isNaN(r)||null==u||Number.isNaN(u))continue;const h=n?r:t.getOpen(o),f=n?u:t.getClose(o);if(!n&&[h,f].some(t=>null==t||Number.isNaN(t)))continue;const p=f>=h,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(h),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(u),bodyWidth:d,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:o};n&&(y.isRange=!0),i.push(y)}return i}(o,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,n,i){const o=t.boundsStyle;return"function"==typeof o?o(n||{},e):o&&"object"==typeof o?o:{fill:i(e,n).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?ee(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=ne(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,n,i=ne(n)){const o=n.length;if(o>1)for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let n=0;e.length>n;n++){const a=i.get(e[n]);null!=a?(r[n]=ee(t,a,o),1>r[n]&&(s=!0)):r[n]=1}s&&(n._decayOpacities=r);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let n=0;e.length>n;n++){const r=i.get(e[n]);null!=r?(s[n]=ee(t,r,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of e){const e=i.get(n);if(null!=e){const n=ee(t,e,o);s>n&&(s=n)}}if(1>s){const t=Array(r);t.fill(s),n._decayOpacities=t}}continue}const e=i.get(n.datum);if(null==e)continue;const r=ee(t,e,o);"heatcell"===n.type?n.style={opacity:r}:"candlestick"===n.type?n._decayOpacity=r:n.style={...n.style,opacity:(n.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&&re(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(te())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){n.clear(),i.clear();for(let o=0;e.length>o;o++){const r=e[o],s=se(t,r,o);s&&("point"===r.type?n.set(s,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"glyph"===r.type?n.set(s,{x:r.x,y:r.y,r:r.size,opacity:r.style.opacity,glyph:r.glyph}):"rect"===r.type?n.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?n.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style?.opacity}):"candlestick"===r.type?n.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?i.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&i.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 n=this.scene[e],i=se(this.transitionContext,n,e);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:t,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(i,{path:n.path.map(t=>[t[0],t[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(i,{topPath:n.topPath.map(t=>[t[0],t[1]]),bottomPath:n.bottomPath.map(t=>[t[0],t[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){if(0===i.size&&0===o.size)return n;const r=e.duration??300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let s=!1;const a=new Set,c=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],l=se(t,r,e);if(!l)continue;if(r._transitionKey=l,"line"===r.type||"area"===r.type){const t=o.get(l);if(t){if(c.add(l),"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]];s=!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]];s=!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},s=!0;continue}const u=i.get(l);if("point"===r.type)if(u){a.add(l);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,s=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},s=!0;else if("glyph"===r.type)if(u){a.add(l);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,s=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},s=!0;else if("rect"===r.type)if(u){a.add(l);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,s=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},s=!0;else if("heatcell"===r.type)if(u){a.add(l);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,s=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},s=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){a.add(l);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,s=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},s=!0}for(const[t,e]of o)if(!c.has(t))if(t.startsWith("l:")&&e.path){const i={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};n.exitNodes.push(i),s=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={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};n.exitNodes.push(i),s=!0}for(const[t,e]of i)if(!a.has(t)){if(t.startsWith("p:"))n.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)n.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:"))n.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:"))n.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 i=e.openY??e.y;n.exitNodes.push({type:"candlestick",x:e.x,openY:i,closeY:e.closeY??i,highY:e.highY??i,lowY:e.lowY??i,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})}s=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),s&&(n.activeTransition={startTime:te(),duration:r}),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,i){if(!n.activeTransition)return!1;const o=Qt(t,n.activeTransition),r=Zt(o,"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?i.get(e):void 0;t.style.opacity=Jt(n?n.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=Jt(n.x,t._targetX,r),t.y=Jt(n.y,t._targetY,r),void 0!==t._targetR&&void 0!==n.r&&(t.r=Jt(n.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0;t.style.opacity=Jt(n?n.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=Jt(n.x,t._targetX,r),t.y=Jt(n.y,t._targetY,r),void 0!==t._targetR&&void 0!==n.r&&(t.size=Jt(n.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0;t.style.opacity=Jt(n?n.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=Jt(n.x,t._targetX,r),t.y=Jt(n.y,t._targetY,r),void 0!==n.w&&(t.w=Jt(n.w,t._targetW,r)),void 0!==n.h&&(t.h=Jt(n.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0;t.style={...t.style||{},opacity:Jt(n?n.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=Jt(n.x,t._targetX,r),t.y=Jt(n.y,t._targetY,r),void 0!==n.w&&(t.w=Jt(n.w,t._targetW,r)),void 0!==n.h&&(t.h=Jt(n.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0;t.style={...t.style||{},opacity:Jt(n?n.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=Jt(n.x,t._targetX,r),void 0!==n.openY&&(t.openY=Jt(n.openY,t._targetOpenY,r)),void 0!==n.closeY&&(t.closeY=Jt(n.closeY,t._targetCloseY,r)),void 0!==n.highY&&(t.highY=Jt(n.highY,t._targetHighY,r)),void 0!==n.lowY&&(t.lowY=Jt(n.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Jt(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=Jt(e[i][0],n[i][0],r),t.path[i][1]=Jt(e[i][1],n[i][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Jt(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=Jt(e[n][0],i[n][0],r),t.topPath[n][1]=Jt(e[n][1],i[n][1],r);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Jt(n[e][0],o[e][0],r),t.bottomPath[e][1]=Jt(n[e][1],o[e][1],r)}}if(o>=1){for(const t of n.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 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){const{result:e,cache:n}=function(t,e,n,i){if(i&&i.version===n&&i.group===e&&i.data===t)return{result:i.result,cache:i};let o;if(e){const n=new Map;for(const i of t){const t=e(i);n.has(t)||n.set(t,[]),n.get(t).push(i)}o=Array.from(n.entries()).map(([t,e])=>({key:t,data:e}))}else o=[{key:"_default",data:t}];return{result:o,cache:{version:n,group:e,data:t,result:o}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,e}resolveColorMap(t){const{map:e,cache:n}=function(t,e,n,i,o){if(o&&o.version===i)return{map:o.map,cache:o};const r=new Set;if(e)for(const n of t){const t=e(n);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(o&&o.key===a){const t={...o,version:i};return{map:t.map,cache:t}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||k,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:i}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,e}resolveLineStyle(t,e){return function(t,e,n,i){const o=t.lineStyle;if("function"==typeof o){const t=o(n||{},e);if(t&&!t.stroke&&e){const n=i(e);if(n)return{...t,stroke:n}}return t}const r=t.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:i(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,n,i){if(t.areaStyle){const o=t.areaStyle(n||{});if(o&&!o.fill&&e){const t=i(e);if(t)return{...o,fill:t,stroke:o.stroke||t}}return o}const o=t.lineStyle;if("function"==typeof o){const t=o(n||{},e);if(t&&!t.fill&&e){const n=i(e);if(n)return{...t,fill:n,stroke:t.stroke||n}}return t}const r=t.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=i(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:n,groupColorCounter:i}=function(t){const{group:e,colorMapCache:n,groupColorMap:i,groupColorMapCap:o,config:r}=t;let{groupColorCounter:s}=t;if(n){const t=n.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=i.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)||k;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,i.set(e,l),i.size>o){const t=i.keys().next().value;void 0!==t&&i.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=i,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getLastUpdateResult(){return this.updateResults.last}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Kt(t),n=this.getPointId,i=t=>e.has(n(t));Je(this.buffer,this.timestampBuffer,i);const o=this.buffer.remove(i);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const t of o)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=te(),this.updateResults.recordData("remove",o.length),o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=Kt(t),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(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)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=te(),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}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){const n=this._customRestyle;if(n)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},o=n(i,e);i.style=o?{...t,...o}:t}}consumeStylePaintPending(){const t=this._stylePaintPending;return this._stylePaintPending=!1,t}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this._stylePaintPending=!0,this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},n=Object.keys(t).filter(n=>t[n]!==e[n]);"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 i=!1,o=!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,n=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=r||!Yt(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!Yt(n,s);(a||c)&&(t?(this.getX=qt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=qt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=qt(this.config.xAccessor,"x"),this.getY=qt(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Ye(this.config)),i=!0,o=!0)}if("groupAccessor"in t&&!Yt(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Xt(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in t&&!Yt(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Xt(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in t&&!Yt(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?qt(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in t&&!Yt(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Xt(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in t&&!Yt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Xt(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in t&&!Yt(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?qt(this.config.y0Accessor,"y0"):void 0,i=!0,o=!0),("boundsAccessor"in t&&!Yt(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=Ye(this.config),i=!0,o=!0),"pointIdAccessor"in t&&!Yt(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Xt(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!Yt(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!Yt(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!Yt(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!Yt(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?qt(this.config.openAccessor,"open"):void 0,this.getHigh=qt(this.config.highAccessor,"high"),this.getLow=qt(this.config.lowAccessor,"low"),this.getClose=e?qt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,i=!0,o=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(i=!0,o=!0),!i){const n=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const o of n)if(t[o]!==e[o]){i=!0;break}}i&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,i,o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};dn.GROUP_COLOR_MAP_CAP=1e3;var hn=dn,fn={sceneGeometry:0,layout:0,domain:0},pn="production"!==process.env.NODE_ENV,yn={revisions:fn,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},gn=class{constructor(){this.lastConsumed=fn,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(t,e){if(!pn)return yn;const n=function(t){const{domain:e,layout:n,sceneGeometry:i}=t.revisions;return{domain:e,layout:n,sceneGeometry:i}}(t),i=function(t){return`${t.sceneGeometry}|${t.layout}|${t.domain}`}(n),o=!((r=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&r.layout===s.layout&&r.domain===s.domain);var r,s;return{revisions:n,signature:i,sawSignals:t.changed.has("scene-geometry")||t.changed.has("layout")||t.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!e&&o&&this.lastUnconsumedWarning!==i}}afterCompute(t,e,n){if(pn){if(e&&t.wasUnconsumed&&(this.lastConsumed=t.revisions),t.warnUnconsumed&&!e)return console.warn(`[semiotic] StreamXYFrame observed scene-affecting revisions without a scene rebuild: ${t.signature}.`),void(this.lastUnconsumedWarning=t.signature);e&&t.sawSignals&&!t.wasUnconsumed&&!n&&this.lastDuplicateWarning!==t.signature?(console.warn(`[semiotic] StreamXYFrame performed scene rebuild with unchanged scene revisions: ${t.signature}.`),this.lastDuplicateWarning=t.signature):e&&!t.sawSignals&&(this.lastDuplicateWarning="")}}};import*as mn from"react";function xn(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:mn.createElement(mn.Fragment,null,...e)}import*as bn from"react";import{jsx as vn}from"react/jsx-runtime";var wn=bn.createContext(null);function kn({value:t,children:e}){return vn(wn.Provider,{value:t,children:e})}function Sn(t,e){return null!=t?vn(kn,{value:e,children:t}):t}import{useEffect as An,useRef as Mn}from"react";function Pn(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 _n(t,e=30){return Math.max((t??4)+5,12,e)}function In(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Cn(t,e){const n=In(t);if(!n)return!1;const i=In(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}var Tn=[40,40],Rn=[.5,.5];function Ln(t,e){const[n,i]=t.viewBox??Tn,[o,r]=t.anchor??Rn,s=i>0?i:1,a=Math.max(0,e)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-o*c,offsetY:-r*l}}function $n(t,e,n,i){if("none"!==t)return"color"===t||null==t?e??i:"accent"===t?n:t}var zn=null;function Dn(t){if("undefined"==typeof Path2D)return null;zn||(zn=new Map);const e=zn.get(t);if(e)return e;const n=new Path2D(t);return zn.size>1024&&zn.clear(),zn.set(t,n),n}function En(t,e,n=0,i="horizontal"){const[o,r]=t.viewBox??Tn,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===i?{x:0,y:r*(1-a),width:o,height:r*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}function Bn(t,e){const n=Ln(t,e);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Fn(t,e,n,i,o,r=t=>t){for(const s of e.parts){const e=Dn(s.d);if(!e)continue;const a=s.opacity??1,c=t.globalAlpha;1!==a&&(t.globalAlpha=c*a);const l=o?"none"===s.fill?void 0:o:$n(s.fill,n,i);l&&(t.fillStyle=r(l),t.fill(e));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:$n(s.stroke??"none",n,i);u&&(t.strokeStyle=r(u),t.lineWidth=s.strokeWidth??1,t.lineCap=s.strokeLinecap??"butt",t.lineJoin=s.strokeLinejoin??"miter",t.stroke(e)),1!==a&&(t.globalAlpha=c)}}var Nn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,On=new WeakMap,Wn=0,jn=!1,Yn=null,qn=null;function Hn(t,e){if(!e)return e;const n=Nn.exec(e);if(!n)return e;const i=t.canvas;if(!i)return n[2]?.trim()||e;!function(){if(jn)return;if("undefined"==typeof window||"undefined"==typeof document)return;jn=!0;const t=()=>{Wn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(t).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Yn=window.matchMedia("(prefers-color-scheme: dark)"),qn=t,"function"==typeof Yn.addEventListener?Yn.addEventListener("change",qn):"function"==typeof Yn.addListener&&Yn.addListener(qn)}catch{}}();let o=On.get(i);o&&o.version===Wn||(o={version:Wn,map:new Map},On.set(i,o));const r=o.map.get(e);if(void 0!==r)return r;const s=getComputedStyle(i).getPropertyValue(n[1]).trim()||n[2]?.trim()||e;return o.map.set(e,s),s}import{curveMonotoneX as Xn,curveMonotoneY as Gn,curveCardinal as Vn,curveCatmullRom as Un,curveStep as Kn,curveStepBefore as Zn,curveStepAfter as Qn,curveBasis as Jn,curveNatural as ti}from"d3-shape";function ei(t){switch(t){case"monotoneX":return Xn;case"monotoneY":return Gn;case"cardinal":return Vn;case"catmullRom":return Un;case"step":return Kn;case"stepBefore":return Zn;case"stepAfter":return Qn;case"basis":return Jn;case"natural":return ti;default:return null}}function ni(t,e,n){return null==e?n:"string"!=typeof e?e:Hn(t,e)||n}function ii(t,e,n,i,o,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(i,o,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:c}=e;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),d=t.createLinearGradient(i,o,r,s),[h,f,p]=function(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch{return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.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},${p},${l})`),d.addColorStop(1,`rgba(${h},${f},${p},${u})`),d}function oi(t,e,n,i,o,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,i,o,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}import{line as ri}from"d3-shape";var si=new WeakMap;function ai(t,e){const n=ei(e);if(!n)return t;const i=si.get(t);if(i)return i;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const i=[];let o=null;const r={moveTo(t,e){o=[t,e],i.push([t,e])},lineTo(t,e){o=[t,e],i.push([t,e])},bezierCurveTo(t,e,r,s,a,c){if(!o)return o=[a,c],void i.push([a,c]);const[l,u]=o;for(let o=1;n>=o;o++){const d=o/n,h=1-d;i.push([h*h*h*l+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*c])}o=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){o=[n,r],i.push([n,r])}};return ri().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return si.set(t,o),o}function ci(t,e,n,i=30,o,r=0){let s=null;if(o){const t=function(t,e,n,i,o,r=t=>t.x,s=t=>t.y,a=t=>t.r){const c=Math.max(i,o+5,12),l=e-c,u=e+c,d=n-c,h=n+c;let f=null,p=1/0;return t.visit((t,o,c,y,g)=>{if(o>u||l>y||c>h||d>g)return!0;if(!t.length){let o=t;do{const t=o.data,c=r(t)-e,l=s(t)-n,u=Math.sqrt(c*c+l*l);_n(a(t),i)>=u&&p>u&&(f=t,p=u),o=o.next}while(o)}return!1}),f?{node:f,distance:p}:null}(o,e,n,i,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(o)break;t=ui(r,e,n,i);break;case"symbol":t=di(r,e,n,i);break;case"glyph":t=hi(r,e,n,i);break;case"line":t=fi(r,e,n,i);break;case"rect":if(null==r.datum)break;t=yi(r,e,n);break;case"heatcell":t=gi(r,e,n);break;case"area":if(!1===r.interactive)break;t=xi(r,e,n);break;case"candlestick":t=mi(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function li(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=bi(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,a]=t[o],[c,l]=t[r];return c===s?a:a+Math.max(0,Math.min(1,(e-s)/(c-s)))*(l-a)}function ui(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>_n(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function di(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>_n(ze(t.size),i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function hi(t,e,n,i=30){if(null==t.datum)return null;const o=Bn(t.glyph,t.size),r=t.x+o.centerDx,s=t.y+o.centerDy,a=e-r,c=n-s,l=Math.sqrt(a*a+c*c);return l>_n(o.radius,i)?null:{node:t,datum:t.datum,x:r,y:s,distance:l}}function fi(t,e,n,i=30){if(0===t.path.length)return null;const o=bi(t.path,e);if(0>o)return null;const[r,s]=t.path[o];let a;if(t.path.length>1){let i=1/0;const r=Math.max(0,o-1),s=Math.min(t.path.length-2,o);for(let o=r;s>=o;o++){const[r,s]=t.path[o],[a,c]=t.path[o+1],l=pi(e,n,r,s,a,c);i>l&&(i=l)}a=i}else{const t=e-r,i=n-s;a=Math.sqrt(t*t+i*i)}const c=t.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:r,y:s,distance:a}}function pi(t,e,n,i,o,r){const s=o-n,a=r-i,c=s*s+a*a;if(0===c)return Math.sqrt((t-n)**2+(e-i)**2);let l=((t-n)*s+(e-i)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((t-(n+l*s))**2+(e-(i+l*a))**2)}function yi(t,e,n){const i=Pn(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function gi(t,e,n){const i=Pn(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function mi(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function xi(t,e,n){if(0===t.topPath.length)return null;const i=bi(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,a=n-r,c=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:c}}function bi(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function vi(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function wi(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}import{useEffect as ki,useRef as Si}from"react";var Ai={fresh:1,aging:.7,stale:.45,expired:.25},Mi={alpha:1,band:"fresh",isStale:!1};function Pi(t,e){if(!t||0>=e)return Mi;const n=null!=t.threshold&&t.threshold>0?t.threshold:5e3,i=t.graded;if(i){const t="object"==typeof i?i:{},o=function(t,e,n={}){return Number.isFinite(e)&&e>0?Number.isNaN(t)?"fresh":t===1/0?"expired":0>t||e*(n.fresh??1)>t?"fresh":e*(n.aging??1.5)>t?"aging":e*(n.stale??3)>t?"stale":"expired":"fresh"}(e,n,t.thresholds);return{alpha:{...Ai,...t.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return e>n?{alpha:t.dimOpacity??.5,band:"stale",isStale:!0}:Mi}import{jsx as _i}from"react/jsx-runtime";function Ii({isStale:t,position:e}){return _i("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===e?{top:4,left:4}:"bottom-left"===e?{bottom:4,left:4}:"bottom-right"===e?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"},children:t?"STALE":"LIVE"})}import{useMemo as Ci,useRef as Ti,useEffect as Ri}from"react";import*as Li from"react";import{jsx as $i,jsxs as zi}from"react/jsx-runtime";var Di={fill:(t,e)=>$i("rect",{style:t,width:e,height:e}),line:(t,e)=>$i("line",{style:t,x1:0,y1:0,x2:e,y2:e})};function Ei(t,e,n,i,o){let r;return r="function"==typeof n?n(t):(0,Di[n])(i(t,e),o),r}function Bi({swatchSize:t}){return $i("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Fi(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}var Ni=(t,e,n,i,o,r,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:f}=t,p=[];let y=0;const g=!(!e&&!n),m="isolate"===l||void 0===l&&null!=o,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((t,l)=>{const u=Ei(t,l,d,h,x),w=Fi(t,i,o),k=o&&o.size>0&&o.has(t.label);p.push(zi("g",{transform:`translate(0,${y})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===r&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:g?e=>{c(a,l),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:g?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&$i("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*t.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&$i(Bi,{swatchSize:x}),$i("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+l)),y+=v}),p};function Oi({config:t,orientation:e="vertical",width:n=100}){const{colorFn:i,domain:o,label:r,format:s}=t,a=s||(t=>Math.round(100*t)/100+""),c="grad-legend-"+Li.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),s=Math.max(0,(n-e)/2),l=[];for(let t=0;64>=t;t++){const e=t/64;l.push($i("stop",{offset:100*e+"%",stopColor:i(o[0]+e*(o[1]-o[0]))},t))}return zi("g",{"aria-label":r||"Gradient legend",children:[$i("defs",{children:$i("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),r&&$i("text",{x:s+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:r}),$i("rect",{x:s,y:0,width:e,height:t,fill:`url(#${c})`,rx:2}),$i("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),$i("text",{x:s+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const l=[];for(let t=0;64>=t;t++){const e=t/64;l.push($i("stop",{offset:100*e+"%",stopColor:i(o[1]-e*(o[1]-o[0]))},t))}return zi("g",{"aria-label":r||"Gradient legend",children:[r&&$i("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:r}),$i("defs",{children:$i("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),$i("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),$i("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),$i("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function Wi(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:r,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=t,h=function(t){const e=Math.max(1,t?.swatchSize??16),n=Math.max(e,t?.rowHeight??22);return{swatchSize:e,labelGap:Math.max(0,t?.labelGap??6),itemGap:Math.max(0,t?.itemGap??10),rowHeight:n,align:"left"===t?.align?"start":"right"===t?.align?"end":t?.align??"start",maxWidth:t?.maxWidth}}(d),[f,p]=Li.useState(0),[y,g]=Li.useState(0),m=Li.useCallback((t,e)=>{p(t),g(e)},[]),x="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:r,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let d=24;const h=[];return t.forEach((t,f)=>{d+=5,h.push($i("line",{stroke:"gray",x1:0,y1:d,x2:e,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,t.label&&(d+=16,h.push($i("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),d+=8),h.push($i("g",{className:"legend-item",transform:`translate(0,${d})`,children:Ni(t,n,i,o,r,s,a,f,c,l,u)},"legend-group-"+f)),d+=t.items.length*u.rowHeight+8}),h})({legendGroups:e||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:r,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:t,height:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const f=[];t.forEach((t,e)=>{let p=0;t.label&&(p+=16);const y=((t,e,n,i,o,r,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:f,items:p}=t,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!e&&!n),k="isolate"===l||void 0===l&&null!=o,S=p.map(t=>g+m+7*t.label.length),A=[];let M=0,P=0;S.forEach((t,e)=>{const n=0===P?t:P+x+t;d&&d>0&&P>0&&n>d?(A.push({start:M,end:e,width:P}),M=e,P=t):P=n}),p.length>0&&A.push({start:M,end:p.length,width:P}),A.forEach((t,l)=>{let u="center"===v?Math.max(0,((d??t.width)-t.width)/2):"end"===v?Math.max(0,(d??t.width)-t.width):0;for(let d=t.start;t.end>d;d++){const t=p[d],v=Ei(t,d,h,f,g),A=Fi(t,i,o),M=o&&o.size>0&&o.has(t.label);y.push(zi("g",{transform:`translate(${u},${l*b})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===r&&d===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;c(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:w?e=>{c(a,d),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:w?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&$i("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*t.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,M&&$i(Bi,{swatchSize:g}),$i("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+d)),u+=S[d]+x}});const _=Math.max(0,...A.map(t=>t.width)),I=A.length;return{items:y,offset:_,totalRows:I,totalHeight:I*b}})(t,i,o,r,s,a,c,e,l,u,d,d.maxWidth??n);p+=y.offset+5,f.push({label:t.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=p+12});const p=d.maxWidth??n;let y=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const g=[];return f.forEach((n,i)=>{const o=t[i];o.label&&(g.push($i("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+i)),y+=16),g.push($i("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+i)),y+=n.offset+5,t[i+1]&&g.push($i("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||e)+0+8},"legend-top-line legend-symbol-"+i)),y+=12}),$i("g",{children:g})})({legendGroups:e||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:r,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!i);return zi("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==r))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&$i("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:a}),x]})}function ji(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Yi(t){return"object"==typeof t&&null!==t&&"gradient"in t}import{jsx as qi}from"react/jsx-runtime";function Hi(t){const{legend:e,totalWidth:n,totalHeight:i,margin:o,legendPosition:r="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!e)return null;const f="top"===r||"bottom"===r,p=!!a,y=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??y:100);let m,x;return"left"===r?(m=Math.max(4,o.left-g-10),x=o.top):"top"===r?(m=o.left,x=p?32:8):"bottom"===r?(m=o.left,x=i-o.bottom+38):(m=n-o.right+10,x=o.top),qi("g",{transform:`translate(${m}, ${x})`,children:Yi(e)?qi(Oi,{config:e.gradient,orientation:f?"horizontal":"vertical",width:g}):ji(e)?qi(Wi,{legendGroups:e.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):e})}import{useMemo as Xi}from"react";import{bin as Gi}from"d3-array";function Vi(t){let e=1/0,n=-1/0;for(const i of t)e>i&&(e=i),i>n&&(n=i);return[e,n]}function Ui(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}import{jsx as Ki,jsxs as Zi}from"react/jsx-runtime";function Qi(t){return"string"==typeof t?{type:t}:t}function Ji({orient:t,config:e,values:n,scale:i,size:o,length:r}){const s=function(t){return{type:t.type,bins:t.bins??20,fill:t.fill??"#4e79a7",fillOpacity:t.fillOpacity??.5,stroke:t.stroke??"none",strokeWidth:t.strokeWidth??1}}(e),a="top"===t||"bottom"===t,c=Xi(()=>{if(0===n.length)return null;const e=i.domain(),c=o-8;if("boxplot"===s.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(n);if(!e)return null;const{q1:o,median:r,q3:l,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*c,20),f=(c-h)/2+4;if(a){const e=i(o),n=i(l),a=i(r),c=i(u),p=i(d),y="top"===t?-1:1,g=0;return Zi("g",{"data-testid":"marginal-boxplot-"+t,children:[Ki("line",{x1:c,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),Ki("line",{x1:c,y1:g+y*f,x2:c,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),Ki("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),Ki("rect",{x:Math.min(e,n),y:"top"===t?g-f-h:g+f,width:Math.abs(n-e),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Ki("line",{x1:a,y1:"top"===t?g-f-h:g+f,x2:a,y2:"top"===t?g-f:g+f+h,stroke:s.fill,strokeWidth:2})]})}{const e=i(o),n=i(l),a=i(r),c=i(u),p=i(d),y="left"===t?-1:1,g=0;return Zi("g",{"data-testid":"marginal-boxplot-"+t,children:[Ki("line",{x1:g+y*(f+h/2),y1:c,x2:g+y*(f+h/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),Ki("line",{x1:g+y*f,y1:c,x2:g+y*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),Ki("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),Ki("rect",{x:"left"===t?g-f-h:g+f,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Ki("line",{x1:"left"===t?g-f-h:g+f,y1:a,x2:"left"===t?g-f:g+f+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=Gi().domain(e).thresholds(s.bins)(n);if(0===l.length)return null;const u=Ui(l.map(t=>t.length));if(0===u)return null;if("histogram"===s.type)return Ki("g",{"data-testid":"marginal-histogram-"+t,children:l.map((e,n)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/u*c;if(a){const r=i(e.x0),a=i(e.x1)-i(e.x0);return Ki("rect",{x:r,y:"top"===t?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const r=i(e.x0),a=i(e.x1)-i(e.x0);return Ki("rect",{x:"left"===t?-4-o:4,y:Math.min(r,r+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const e=c/2+4,n=[];for(const o of l){if(null==o.x0||null==o.x1)continue;const r=o.length/u*(c/2),s=i((o.x0+o.x1)/2);n.push(a?`${s},${"top"===t?-(e-r):e-r}`:`${"left"===t?-(e-r):e-r},${s}`)}for(let o=l.length-1;o>=0;o--){const r=l[o];if(null==r.x0||null==r.x1)continue;const s=r.length/u*(c/2),d=i((r.x0+r.x1)/2);n.push(a?`${d},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${d}`)}return Ki("g",{"data-testid":"marginal-violin-"+t,children:Ki("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const e=[];if(a){const n=0,o=null!=l[0].x0?i(l[0].x0):0;e.push(`M${o},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,r=i((n.x0+n.x1)/2);e.push(`L${r},${"top"===t?-o-4:o+4}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):r;e.push(`L${s},${n}`),e.push("Z")}else{const n=0,o=null!=l[0].x0?i(l[0].x0):0;e.push(`M${n},${o}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,r=i((n.x0+n.x1)/2);e.push(`L${"left"===t?-o-4:o+4},${r}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):r;e.push(`L${n},${s}`),e.push("Z")}return Ki("g",{"data-testid":"marginal-ridgeline-"+t,children:Ki("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,i,s,o,r,t,a,4]);return c?Ki("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:c}):null}import*as to from"react";import{jsx as eo,jsxs as no}from"react/jsx-runtime";function io(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function oo(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function ro(t,e,n,i){if(!t)return eo("g",{className:"annotation-note"});const{label:o,title:r,orientation:s,align:a,wrap:c=120,noWrap:l}=t;if(!o&&!r)return eo("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>e?"end":"start";const f=16,p=r?l?[r]:io(r,c):[],y=o?l?[o]:io(o,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push(eo("foreignObject",{className:"annotation-note-html",x:"end"===h?g-c:"middle"===h?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(r&&o?2:0))+f,style:{overflow:"visible"},children:no("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[r&&eo("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),o&&eo("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(p.length>0&&(x.push(eo("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((t,e)=>eo("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push(eo("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((t,e)=>eo("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((r||o)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(c,120);let e=0,n=t;"end"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),v=eo("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,n=t;"bottom"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),v=eo("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),no("g",{className:"annotation-note",transform:`translate(${e},${n})`,children:[eo("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function so(t,e,n,i,o){const r=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&r.push(eo("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,i=e?.height||0;(t>0||i>0)&&r.push(eo("rect",{width:t,height:i,fill:"none",stroke:n||"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=i||0,s=o||0;if(void 0!==e?.x){const i=(e.x||0)-t;r.push(eo("line",{x1:i,y1:(e.y1||0)-s,x2:i,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const i=(e.y||0)-s;r.push(eo("line",{x1:(e.x1||0)-t,y1:i,x2:(e.x2||0)-t,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?r.push(eo("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||r.push(eo("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",i=e?.width??e?.height;void 0!==i&&r.push(eo("path",{d:oo(t,i,e?.depth||30,void 0===e?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return eo("g",{className:"annotation-subject",children:r})}function ao(t,e,n,i,o,r){const s=[];let a=0,c=0;if("callout-circle"!==o&&"label"!==o||!r?.radius){if("callout-rect"===o&&r){const n=r.width||0,i=r.height||0;if(n>0||i>0){const o=n/2,r=i/2,s=t-o,l=e-r;if(0!==s||0!==l){const t=Math.abs(s),e=Math.abs(l),u=n/2,d=i/2,h=t*d>e*u?u/t:d/e;a=o+s*h,c=r+l*h}}}else if("bracket"===o&&r){const t=r.width,e=r.height,n=r.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const n=(r.radius||0)+(r.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const i=Math.atan2(e,t);a=Math.cos(i)*n,c=Math.sin(i)*n}}const l=Math.sqrt((t-a)**2+(e-c)**2);if(l>.5){const o=i||"var(--semiotic-text-secondary, currentColor)",r="curve"===n?.type;let u=Math.atan2(e-c,t-a);if(r){const i=(a+t)/2,r=(c+e)/2,d=-(e-c)/l,h=(t-a)/l,f=(n?.curve??.25)*l,p=i+d*f,y=r+h*f;s.push(eo("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${t},${e}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push(eo("line",{x1:a,y1:c,x2:t,y2:e,stroke:o},"connector-line"));if("arrow"===n?.end){const t=10,e=16/180*Math.PI;s.push(eo("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:o,stroke:"none"},"connector-arrow"))}}return eo("g",{className:"annotation-connector",children:s})}function co(t){const{x:e=0,y:n=0,dx:i,dy:o,nx:r,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=i||0,k=o||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 no("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&ao(w,k,c,d,S,l),!v.has("subject")&&so(S,l,d,x,b),!v.has("note")&&ro(a,w,k,d)]})}function lo(t){const{noteData:e}=t,{screenCoordinates:n}=e,i="string"==typeof e.type?e.type:"label",o=e.eventListeners||e.events||{};if(e.coordinates&&n){const t=e.nx||n[0][0]+(e.dx??0),o=e.ny||n[0][1]+(e.dy??0),r=n.map((n,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:o});return eo(co,{"data-testid":"semiotic-annotation",...s,type:i},"multi-annotation-"+r)});return eo("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return eo(co,{"data-testid":"semiotic-annotation",events:o,...e,type:i},s)}import{packEnclose as uo}from"d3-hierarchy";import{area as ho,curveLinear as fo,curveMonotoneX as po,curveMonotoneY as yo,curveStep as go,curveStepAfter as mo,curveStepBefore as xo,curveBasis as bo,curveCardinal as vo,curveCatmullRom as wo}from"d3-shape";import ko from"regression";function So(t,e){const n=e.scales?.x??e.scales?.time;return n?null!=t.x?n(t.x):e.xAccessor&&null!=t[e.xAccessor]?n(t[e.xAccessor]):null:null}function Ao(t,e){const n=e.scales?.y??e.scales?.value;return n?null!=t.y?n(t.y):e.yAccessor&&null!=t[e.yAccessor]?n(t[e.yAccessor]):null:null}function Mo(t){return null==t?null:t+""}function Po(t,e,n){return e.stickyPositionCache?.set(t,n),n}function _o(t,e,n){const i=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const o=n.pointNodes[i];if(o.pointId===t.pointId)return Po(e,n,{x:o.x,y:o.y})}const i=function(t){const e=t.data;if(!e||0===e.length)return null;const n=e[e.length-1],i=t.scales?.x??t.scales?.time,o=t.scales?.y??t.scales?.value;if(!i||!o)return null;const r=n[t.xAccessor||"x"],s=n[t.yAccessor||"y"];return null==r||null==s?null:{x:i(r),y:o(s)}}(n);return i?Po(e,n,i):null}if("semantic"===i){const i=function(t,e,n){const i=function(t){return Mo(t.provenance?.stableId??t.stableId)}(t);if(!i)return null;const o=n.pointNodes?.find(t=>Mo(t.pointId)===i);if(o)return Po(e,n,{x:o.x,y:o.y});const r=n.data?.find(t=>function(t){return Mo(t.stableId??t.id??t.provenance?.stableId)}(t)===i);if(!r)return null;const s=So(r,n),a=Ao(r,n);return null==s||null==a?null:Po(e,n,{x:s,y:a})}(t,e,n);if(i)return i}let o=null,r=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(o=e.x,r=e.y)}if(null!=o&&null!=r||(o=So(t,n),r=Ao(t,n)),null!=o&&null!=r)return Po(e,n,{x:o,y:r});if("sticky"===i){const t=n.stickyPositionCache?.get(e);if(t)return t}return null}function Io(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}import{jsx as Co}from"react/jsx-runtime";var To={secondary:0,primary:3},Ro=".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}}";function Lo(t){return!0===t?._annotationDeferred}function $o(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function zo(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function Do(t){return Math.max(.72,.95-.06*t)}function Eo(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:zo(t.annotation),readingOrder:null,rank:1};var n}),n=e.some(t=>null!=t.emphasis||null!=t.confidence),i=t.some(t=>Lo(t.annotation)),o=t.some(t=>null!=$o(t.annotation)),r=t.some(t=>"layer"===$o(t.annotation));if(!n&&!i&&!o)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=2-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=To[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:n,emphasis:i,readingOrder:o}=t,r=Lo(e.annotation);let s=e.node;if("primary"===i||"secondary"===i||null!=o){const t=null==i&&null!=o;s=Co("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i,..."secondary"===i?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:Do(o),"data-annotation-reading-order":o}:{},children:e.node},"annotation-emphasis-"+n)}const a=$o(e.annotation);return a&&(s=Co("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),r&&(s=Co("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return i&&a.unshift(Co("style",{children:Ro},"annotation-disclosure-style")),r&&a.unshift(Co("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")),a}import{jsx as Bo,jsxs as Fo}from"react/jsx-runtime";var No={linear:fo,monotoneX:po,monotoneY:yo,step:go,stepAfter:mo,stepBefore:xo,basis:bo,cardinal:vo,catmullRom:wo};function Oo(t,e,n,i){const o=[];return t.forEach((t,r)=>{let s;if(n){const o=n(t,r,i);s=null!=o?o:e(t,r,i)}else s=e(t,r,i);s&&o.push({node:s,annotation:t})}),Eo(o)}function Wo(t){return function(t,e,n){switch(t.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const i=_o(t,e,n);if(!i)return null;const{x:o,y:r}=i;if(!Io(o,r,n))return null;const s="callout"===t.type?"callout-circle":t.type,a="callout-circle"===s?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===s?{width:t.width,height:t.height}:void 0;return Bo(lo,{noteData:{x:o,y:r,dx:t.dx??30,dy:t.dy??-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:s,...a?{subject:a}:{},connector:t.connector||{end:"arrow"},color:t.color,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-"+e)}case"x-threshold":{const i=So(null!=t.value?{...t,x:t.value}:t,n);if(null==i)return null;const o=t.color||"#f97316",r=t.labelPosition||"top";let s;s="bottom"===r?(n.height||0)-4:"center"===r?(n.height||0)/2:12;const a=i>.6*(n.width||0),c=a?i-4:i+4,l=a?"end":"start";return Fo("g",{opacity:t.opacity,children:[Bo("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Bo("text",{x:c,y:s,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"y-threshold":{const i=Ao(null!=t.value?{...t,y:t.value}:t,n);if(null==i)return null;const o=t.color||"#f97316",r=t.labelPosition||"right";let s,a;return"left"===r?(s=4,a="start"):"center"===r?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),Fo("g",{opacity:t.opacity,children:[Bo("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Bo("text",{x:s,y:i-4,textAnchor:a,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"enclose":{const i=(t.coordinates||[]).map(t=>({x:So({...t,type:"point"},n),y:Ao({...t,type:"point"},n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const o=uo(i),r=t.padding||10;return Fo("g",{children:[Bo("circle",{cx:o.x,cy:o.y,r:o.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&Bo("text",{x:o.x,y:o.y-o.r-r-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+e)}case"rect-enclose":{const i=(t.coordinates||[]).map(t=>({x:So({...t,type:"point"},n),y:Ao({...t,type:"point"},n)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const o=t.padding||10,r=i.map(t=>t.x),s=i.map(t=>t.y),[a,c]=Vi(r),[l,u]=Vi(s),d=a-o,h=c+o,f=l-o;return Fo("g",{children:[Bo("rect",{x:d,y:f,width:h-d,height:u+o-f,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&Bo("text",{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+e)}case"highlight":{const i=n.data||[],o="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],r={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return Bo("g",{children:o.map((e,i)=>{const o=So(e,n),s=Ao(e,n);if(null==o||null==s)return null;const a="function"==typeof t.r?t.r(e):t.r||6,c="function"==typeof t.style?t.style(e):t.style||r;return Bo("circle",{cx:o,cy:s,r:a,...c},"hl-"+i)})},"ann-"+e)}case"bracket":{const i=So(t,n),o=Ao(t,n);return Bo(lo,{noteData:{x:i??0,y:o??0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+e)}case"trend":{const i=n.data||[];if(2>i.length)return null;const o=n.xAccessor||"x",r=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,c=s?o:null,l=s?r:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const t of i){const e=t[c];if(null==e)continue;const n=e+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=i.map(t=>{const e=t[c],n=t[l];if(null==e||null==n)return null;const i=h.get(e+"");return null!=i?[i,+n]:null}).filter(t=>null!==t)}else u=i.map(t=>[t[o],t[r]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,p=n.scales?.y??n.scales?.value;if(!f||!p)return null;const y=t=>e=>{const n=Math.max(0,Math.floor(e)),i=Math.min(d.length-1,n+1),o=e-n,r=t(d[n]);return r+(t(d[i])-r)*o},g=f,m=p;let x;if(s)if(a){const t=y(m);x=(e,n)=>[g(n),t(e)]}else{const t=y(g);x=(e,n)=>[t(e),m(n)]}else x=(t,e)=>[g(t),m(e)];const b=t.method||"linear";let v;v="loess"===b?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),c=i.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,l=[];for(let t=0;n>t;t++){const e=0===c?0:i[t]/c;l[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let t=0;n>t;t++){const e=l[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],p+=e*o[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*p-d*h)/y;a.push([e,(h-t*d)/u+t*e])}}return a}(u,t.bandwidth??.3):("polynomial"===b?ko.polynomial(u,{order:t.order||2}):ko.linear(u)).points;const w=v.map(([t,e])=>{const[n,i]=x(t,e);return`${n},${i}`}).join(" "),k=t.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return Fo("g",{children:[Bo("polyline",{points:w,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Bo("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:t.label})]},"ann-"+e)}case"band":{const i=n.scales?.y??n.scales?.value,o=i?.(t.y0)??0,r=i?.(t.y1)??(n.height||0);return Fo("g",{opacity:t.opacity,children:[Bo("rect",{x:0,y:Math.min(o,r),width:n.width||0,height:Math.abs(r-o),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&Bo("text",{x:(n.width||0)-4,y:Math.max(Math.min(o,r),0)+13,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"x-band":{const i=n.scales?.x??n.scales?.time,o=null!=t.x0&&i?i(t.x0):null,r=null!=t.x1&&i?i(t.x1):null;return null==o||null==r?null:Fo("g",{opacity:t.opacity,children:[Bo("rect",{x:Math.min(o,r),y:0,width:Math.abs(r-o),height:n.height||0,fill:t.fill||t.color||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity??.1}),t.label&&Bo("text",{x:Math.min(o,r)+4,y:13,textAnchor:"start",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const o=n.xAccessor||"x",r=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!r||!s)return null;const a=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",l=t.filter,u=i.filter(t=>null!=t[a]&&null!=t[c]&&!(l&&!l(t))).sort((t,e)=>t[o]-e[o]);if(2>u.length)return null;const d=No[n.curve||"linear"]||fo,h=ho().x(t=>r(t[o])).y0(t=>s(t[c])).y1(t=>s(t[a])).curve(d)(u);if(!h)return null;const f=t.fill||"#6366f1";return Fo("g",{children:[Bo("path",{d:h,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&u.length>0&&Bo("text",{x:r(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+e)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const o=n.yAccessor||"y",r=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!r||!s)return null;const a=i.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,l=a.reduce((t,e)=>t+(e-c)**2,0)/a.length,u=Math.sqrt(l),d=t.threshold??2,h=c-d*u,f=!1!==t.showBand,p=t.fill||"#6366f1",y=t.fillOpacity??.1,g=t.anomalyColor||"#ef4444",m=t.anomalyRadius??6,x=s(c+d*u),b=s(h),v=i.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-c)>d*u});return Fo("g",{children:[f&&Bo("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((t,e)=>{const i=So(t,n),o=Ao(t,n);return null==i||null==o?null:Bo("circle",{cx:i,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+e)}),t.label&&Bo("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+e)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const o=n.xAccessor||"x",r=n.yAccessor||"y",s=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!s||!a)return null;const c=i.map(t=>[t[o],t[r]]).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 l;if("polynomial"===(t.method||"linear")){const e=ko.polynomial(c,{order:t.order||2}).equation;l=t=>e.reduce((e,n,i)=>e+n*Math.pow(t,i),0)}else{const t=c.length;let e=0,n=0,i=0,o=0;for(const[t,r]of c)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,a=(n-s*e)/t;l=t=>a+s*t}const u=c.length,d=c.map(([t,e])=>e-l(t)).reduce((t,e)=>t+e*e,0),h=Math.sqrt(d/Math.max(u-2,1)),f=c.reduce((t,e)=>t+e[0],0)/u,p=c.reduce((t,e)=>t+(e[0]-f)**2,0),y=t.confidence??.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,m=t.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),v=[];for(let t=1;m>=t;t++)v.push(x+t*b);const w=[];for(const t of v){const e=l(t),n=h*Math.sqrt(1+1/u+(p>0?(t-f)**2/p:0))*g;w.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const k=`M${w.map(t=>`${s(t.x)},${a(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${s(t.x)},${a(t.yLower)}`).join(" L")} Z`,S=w.map(t=>`${s(t.x)},${a(t.yCenter)}`).join(" "),A=`${s(x)},${a(l(x))}`,M=t.strokeColor||"#6366f1";return Fo("g",{children:[Bo("path",{d:k,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),Bo("polyline",{points:`${A} ${S}`,fill:"none",stroke:M,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&w.length>0&&Bo("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:t.label})]},"ann-"+e)}case"widget":{let i,o;if(null!=t.px&&null!=t.py)i=t.px,o=t.py;else{const r=_o(t,e,n);if(!r)return null;i=r.x,o=r.y}if(!Io(i,o,n))return null;const r=t.width??32,s=t.height??32;return Bo("foreignObject",{x:i+(t.dx??0)-r/2,y:o+(t.dy??0)-s/2,width:r,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:Bo("div",{style:{width:r,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:t.content??Bo("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"})})},"ann-"+e)}case"text":{const i=_o(t,e,n);if(!i)return null;const{x:o,y:r}=i,s=o+(t.dx||0),a=r+(t.dy||0),c=t.color||"var(--semiotic-text, #333)",l=Bo("text",{x:s,y:a,fill:c,fontSize:t.fontSize||11,opacity:t.opacity,strokeDasharray:t.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label});return!0!==t._redundantConnector?to.cloneElement(l,{key:"ann-text-"+e}):Fo("g",{opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:[Bo("line",{x1:o,y1:r,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),to.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+e)}case"category-highlight":{const i=t.category;if(null==i)return null;const o=t=>"function"==typeof t&&"function"==typeof t.bandwidth,r=n.scales?.o,s=n.scales?.x,a=n.scales?.y,c=o(r)?r:o(s)?s:o(a)?a:null;if(!c)return null;const l=c(i+"");if(null==l)return null;const u=c.bandwidth(),d=t.color||"var(--semiotic-primary, #4589ff)",h=t.opacity??.15,f=t.label;return Fo("g",(n.projection?"vertical"===n.projection:c===s)?{children:[Bo("rect",{x:l,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),f&&Bo("text",{x:l+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[Bo("rect",{x:0,y:l,width:n.width||0,height:u,fill:d,fillOpacity:h}),f&&Bo("text",{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+e)}default:return null}}}var jo=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Yo(t){return!!t&&"object"==typeof t&&jo.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}function qo(t){return"primary"===t?.emphasis||!0===t?.defensive}function Ho(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 Xo(t){let e;const n=t?.emphasis;e="primary"===n?100:"secondary"===n?10:50;const i=t?.provenance?.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(e+=15*Math.max(0,Math.min(1,i))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}new Set(["label","callout","callout-circle","callout-rect"]);var Go=32,Vo=6,Uo=4,Ko=8,Zo=72;var Qo={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Jo(t){if(!tr(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 tr(t){return Yo(t)}function er(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),i=t.split(/\s+/).filter(Boolean),o=[];let r="";for(const t of i)r&&r.length+t.length+1>n?(o.push(r),r=t):r=r?`${r} ${t}`:t;return r&&o.push(r),o}function nr(t,e,n,i,o){const r=t+n,s=e+i;return Math.abs(n)>Math.abs(i)?{x:0>n?r-o.width-4:r+4,y:0>i?s-o.height:s,width:o.width,height:o.height}:{x:0>n?r-o.width:r,y:0>i?s-o.height-4:s+4,width:o.width,height:o.height}}function ir(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function or(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 rr(t,e,n,i,o,r,s,a){const c=ir(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,i){const o=Math.max(0,i-t.x),r=Math.max(0,i-t.y);return(o+Math.max(0,t.x+t.width-(e-i)))*t.height+(r+Math.max(0,t.y+t.height-(n-i)))*t.width}(c,o,r,a);for(const t of n)l+=12*or(c,t);for(const t of i)l+=4*or(c,t);return l}function sr(t){const{annotations:e,context:n,defaultOffset:i=Go,notePadding:o=Vo,markPadding:r=Uo,edgePadding:s=Ko,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=Zo,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=n.width||0,x=n.height||0,b="object"==typeof p?p:{},v=b.breakpoint??480,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(Jo):e,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,P=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const _=[],I=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}})}(n,r);let C=!1;const T=k.map((t,e)=>{if(!tr(t))return t;const r=function(t,e,n){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const i=t.pointId??t.nodeId;if(null!=i&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===i);if(t)return{x:t.x,y:t.y}}const o=t.coordinates,r=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&r){const t=o[0],e=o[1];if("number"==typeof t&&"number"==typeof e){const n=r([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?_o(t,e,n):{x:t.x,y:t.y}}(t,e,n);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,n=[...er("string"==typeof t.title?t.title:void 0,e),...er("string"==typeof t.label?t.label:void 0,e)],i=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*i)+10),height:Math.max(18,16*n.length+6)}}(t);if(a&&("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 _.push(ir(nr(r.x,r.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),o)),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=rr(nr(r.x,r.y,t.dx,t.dy,u),t,_,I,m,x,o,s);f>e&&(h=t,f=e)}if(!h)return t;const p=ir(nr(r.x,r.y,h.dx,h.dy,u),o);_.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return C=!0,{...t,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),R=C?T:k.slice();let L=R;if(h){let t=!1;const e=R.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:{...t,_redundantConnector:!0}}(e);return n!==e&&(t=!0),n});L=t?e:R}{let t=!1;const e=L.map(e=>{if(!0!==e?.defensive)return e;const n=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const n="string"==typeof e.source?Qo[e.source]??e.source:null,i="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!n&&!i)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const o=[n,i].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${o})`)?t:{...t,label:r?`${r} (${o})`:`(${o})`}}(e);return n!==e&&(t=!0),n});L=t?e:L}const $=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 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}(g),n=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??Ho(m,x,t))*e))},{deferred:i}=function(t){const{annotations:e,width:n,height:i}=t,o=Math.max(0,t.minVisible??1),r=Ho(n,i,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(n=t,Yo(n))};var n}),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=>qo(t.annotation)),l=a.filter(t=>!qo(t.annotation)).sort((t,e)=>Xo(e.annotation)-Xo(t.annotation)||t.index-e.index),u=Math.min(l.length,Math.max(Math.max(0,r-c.length),Math.max(0,o-c.length))),d=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),h=[],f=[];for(const{annotation:t,index:e,note:n}of s)!n||d.has(e)?h.push(t):f.push(t);return{visible:h,deferred:f,budget:r}}({annotations:L,width:m,height:x,...n});for(const t of i)$.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:480)>=m)for(const t of L)tr(t)&&"secondary"===t.emphasis&&$.add(t);if($.size>0)for(const t of L)!0===t?.defensive&&$.delete(t);let z;return z=0===$.size?L:A?L.map(t=>$.has(t)?{...t,_annotationDeferred:!0}:t):L.filter(t=>!$.has(t)),P?function(t,e){let n=!1;const i=t.map(t=>tr(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,{...t,cohesion:e}):t);return n?i:t}(z,P):z}import{useSyncExternalStore as ar}from"react";var cr={positions:new Map},lr=new Set;function ur(){for(const t of lr)t()}function dr(t,e){const n=cr.positions.get(t);if(n?.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(cr.positions);i.delete(t),cr={positions:i},ur()}function hr(t,e){const n=cr.positions.get(t);if(!n?.locked)return;if(e&&n.sourceId!==e)return;const i=new Map(cr.positions);i.delete(t),cr={positions:i},ur()}function fr(){return cr}function pr(t){return lr.add(t),()=>lr.delete(t)}var yr={positions:new Map};function gr(){return()=>{}}function mr(){return yr}function xr(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),i=n[0],o=n[n.length-1],r=i instanceof Date,s=i instanceof Date?i.getTime():i,a=o instanceof Date?o.getTime():o;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(e-1),l=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*c;l[t]=r?new Date(n):n}return l}(t,e):t.ticks(e)}import{Fragment as br,jsx as vr,jsxs as wr}from"react/jsx-runtime";function kr(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function Sr(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Ar(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const i of t)e>i.pixel&&(e=i.pixel),i.pixel>n&&(n=i.pixel);return{min:e,max:n}}function Mr(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Pr(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function _r(t){const{width:e,height:n,totalWidth:i,totalHeight:o,margin:r,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=t,f=Ci(()=>{if(!s)return[];const t=c?.find(t=>"bottom"===t.orient),n=t?.tickFormat||u||Ir,i=Math.max(2,Math.floor(e/70)),o=t?.ticks??5,r="exact"===h?Math.max(2,o):Math.min(o,i),a=t?.tickValues??xr(s.x,r,h),l=a.map(t=>t.valueOf()),d=a.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,l)})),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 Cr(d,Math.max(55,f+8))},[s,c,u,e,h]),p=Ci(()=>{if(!s)return[];const t=c?.find(t=>"left"===t.orient),e=t?.tickFormat||d||Ir,i=Math.max(2,Math.floor(n/30)),o=t?.ticks??5,r="exact"===h?Math.max(2,o):Math.min(o,i);return Cr((t?.tickValues??xr(s.y,r,h)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[s,c,d,n,h]),y=l&&s,g=a&&s;if(!y&&!g)return null;const m=c?.find(t=>"bottom"===t.orient),x=c?.find(t=>"left"===t.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return vr("svg",{width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:wr("g",{transform:`translate(${r.left},${r.top})`,children:[y&&(()=>{const t=Mr(c?.find(t=>"bottom"===t.orient)?.gridStyle),i=Mr(c?.find(t=>"left"===t.orient)?.gridStyle);return wr("g",{className:"stream-grid",children:[f.map((e,i)=>vr("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+i)),p.map((t,n)=>vr("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),b&&!w&&vr("line",{x1:0,y1:n,x2:e,y2:n,stroke:S,strokeWidth:1}),w&&vr("path",{d:Pr("bottom",e,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&vr("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&vr("path",{d:Pr("left",e,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Ir(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Cr(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Tr(t){const{width:e,height:n,totalWidth:i,totalHeight:o,margin:r,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:f,axisExtent:p,showGrid:y,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:M,xValues:P,yValues:_,annotations:I,autoPlaceAnnotations:C,svgAnnotationRules:T,xAccessor:R,yAccessor:L,annotationData:$,pointNodes:z,curve:D,underlayRendered:E,canvasObscuresUnderlay:B=!0,linkedCrosshairName:F,linkedCrosshairSourceId:N,children:O}=t,W=Ci(()=>{if(!a||!s)return[];const t=c?.find(t=>"bottom"===t.orient),n=t?.tickFormat||h||Ir,i=Math.max(2,Math.floor(e/70)),o=t?.ticks??5,r="exact"===p?Math.max(2,o):Math.min(o,i),l=t?.tickValues??xr(s.x,r,p),u=l.map(t=>t.valueOf()),d=l.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,u)})),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),y=t?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=Cr(d,y);if(g.length>1&&(g=g.filter((t,e)=>0===e||t.label+""!=g[e-1].label+"")),t?.includeMax&&g.length>0&&"exact"!==p&&!t?.tickValues){const t=s.x.domain()[1],e=s.x(t),i=g[g.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,g.length,u);y>e-i&&g.length>1&&(g=g.slice(0,-1)),g.push({value:t,pixel:e,label:o})}}return g},[a,s,c,h,e,p]),j=Ci(()=>{if(!a||!s)return[];const t=c?.find(t=>"left"===t.orient),e=t?.tickFormat||f||Ir,i=Math.max(2,Math.floor(n/30)),o=t?.ticks??5,r="exact"===p?Math.max(2,o):Math.min(o,i);let l=Cr((t?.tickValues??xr(s.y,r,p)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22);if(l.length>1&&(l=l.filter((t,e)=>0===e||t.label+""!=l[e-1].label+"")),t?.includeMax&&l.length>0&&"exact"!==p&&!t?.tickValues){const t=s.y.domain()[1],n=s.y(t),i=l[l.length-1].pixel;if(Math.abs(n-i)>1){const o=e(t);22>Math.abs(n-i)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:t,pixel:n,label:o})}}return l},[a,s,c,f,n,p]),Y=Ci(()=>{if(!a||!s)return[];const t=c?.find(t=>"right"===t.orient);if(!t)return[];const e=t.tickFormat||f||Ir,i=Math.max(2,Math.floor(n/30)),o=t.ticks??5;return Cr((t.tickValues??xr(s.y,"exact"===p?Math.max(2,o):Math.min(o,i),p)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[a,s,c,f,n,p]),q=Ti(new Map),H=Ti(I?.length??0),X=I?.length??0;H.current!==X&&(H.current=X,q.current=new Map);const G=Ci(()=>{if(!I||0===I.length)return null;const t=Wo(),i={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:R,yAccessor:L,width:e,height:n,data:$,frameType:"xy",pointNodes:z,curve:D,stickyPositionCache:q.current};return Oo(C?sr({annotations:I,context:i,..."object"==typeof C?C:{}}):I,t,T,i)},[I,C,T,e,n,R,L,$,s,z,D]),V=function(t){const e=ar(t?pr:gr,t?fr:mr,t?fr:mr);return t?e.positions.get(t)??null:null}(F);return Ri(()=>{if(!V?.locked||!F)return;const t=t=>{"Escape"===t.key&&hr(F)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[V?.locked,F]),a||g||m||A||M||G&&G.length>0||y||O||V?wr("svg",{role:"img",width:i,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[vr("title",{children:"string"==typeof g?g:"XY Chart"}),vr("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),wr("g",{transform:`translate(${r.left},${r.top})`,children:[y&&s&&(!E||B)&&(()=>{const t=Mr(c?.find(t=>"bottom"===t.orient)?.gridStyle),i=Mr(c?.find(t=>"left"===t.orient)?.gridStyle);return wr("g",{className:"stream-grid",children:[W.map((e,i)=>vr("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+i)),j.map((t,n)=>vr("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),a&&s&&(()=>{const t=c?.find(t=>"left"===t.orient),i=c?.find(t=>"bottom"===t.orient),o=!t||!1!==t.baseline,s=!i||!1!==i.baseline,a=t?.jaggedBase||!1,h=i?.jaggedBase||!1,f=i?.landmarkTicks,p=t?.landmarkTicks,y="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!i?.autoRotate&&W.length>1&&(()=>{const t=e/Math.max(W.length-1,1);return W.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),b=x?12:18,v=n+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=i?.tickAnchor,M=t?.tickAnchor,P=Ar(W),_=Ar(j);return wr("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[wr("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!E||B)&&s&&!h&&vr("line",{x1:0,y1:n,x2:e,y2:n,stroke:y,strokeWidth:1}),(!E||B)&&h&&vr("path",{d:Pr("bottom",e,n),fill:"none",stroke:y,strokeWidth:1}),W.map((t,e)=>{const i=!!f&&("function"==typeof f?f(t.value,e):Cn(t.value,e>0?W[e-1].value:void 0));return wr("g",{transform:`translate(${t.pixel},${n})`,children:[vr("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?vr("text",{y:b,textAnchor:x?"end":kr(A,t.pixel===P.min,t.pixel===P.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},transform:x?"rotate(-45)":void 0,children:t.label}):vr("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:vr("div",{style:{textAlign:"center",userSelect:"none",...w},children:t.label})})]},"xtick-"+e)}),l&&vr("text",{x:e/2,y:v,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:l})]}),wr("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!E||B)&&o&&!a&&vr("line",{x1:0,y1:0,x2:0,y2:n,stroke:y,strokeWidth:1}),(!E||B)&&a&&vr("path",{d:Pr("left",e,n),fill:"none",stroke:y,strokeWidth:1}),j.map((t,e)=>{const n=!!p&&("function"==typeof p?p(t.value,e):Cn(t.value,e>0?j[e-1].value:void 0));return wr("g",{transform:`translate(0,${t.pixel})`,children:[vr("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?vr("text",{x:-8,textAnchor:"end",dominantBaseline:Sr(M,t.pixel===_.min,t.pixel===_.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:t.label}):vr("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:vr("div",{style:{textAlign:"right",userSelect:"none",...w},children:t.label})})]},"ytick-"+e)}),(()=>{const e=t?.label||u;return e?vr("text",{x:15-r.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-r.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:e}):null})()]}),(()=>{const t=c?.find(t=>"right"===t.orient);if(!t||0===Y.length)return null;const i=!1!==t.baseline,o=t.landmarkTicks,s=t.label||d,a=t.tickAnchor,l=Ar(Y);return wr("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&vr("line",{x1:e,y1:0,x2:e,y2:n,stroke:y,strokeWidth:1}),Y.map((t,n)=>{const i=!!o&&("function"==typeof o?o(t.value,n):Cn(t.value,n>0?Y[n-1].value:void 0));return wr("g",{transform:`translate(${e},${t.pixel})`,children:[vr("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?vr("text",{x:8,textAnchor:"start",dominantBaseline:Sr(a,t.pixel===l.min,t.pixel===l.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},children:t.label}):vr("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:vr("div",{style:{textAlign:"left",userSelect:"none",...w},children:t.label})})]},"ytick-r-"+n)}),s&&vr("text",{x:e+r.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${e+r.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:s})]})})()]})})(),G,M&&s&&P&&_&&wr(br,{children:[M.top&&vr("g",{transform:"translate(0, 0)",children:vr(Ji,{orient:"top",config:Qi(M.top),values:P,scale:s.x,size:r.top,length:e})}),M.bottom&&vr("g",{transform:`translate(0, ${n})`,children:vr(Ji,{orient:"bottom",config:Qi(M.bottom),values:P,scale:s.x,size:r.bottom,length:e})}),M.left&&vr("g",{transform:"translate(0, 0)",children:vr(Ji,{orient:"left",config:Qi(M.left),values:_,scale:s.y,size:r.left,length:n})}),M.right&&vr("g",{transform:`translate(${e}, 0)`,children:vr(Ji,{orient:"right",config:Qi(M.right),values:_,scale:s.y,size:r.right,length:n})})]}),A,V&&V.sourceId!==N&&s?.x&&(()=>{const t=s.x(V.xValue);if(null==t||0>t||t>e)return null;const i=V.locked;return vr("line",{x1:t,y1:0,x2:t,y2:n,stroke:i?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:i?1.5:1,strokeDasharray:i?"6,3":"4,4",pointerEvents:"none"})})(),O]}),g&&vr("text",{x:i/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 g?g:null}),Hi({legend:m,totalWidth:i,totalHeight:o,margin:r,legendPosition:k,title:g,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w})]}):null}import*as Rr from"react";import{arc as Lr}from"d3-shape";function $r(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}function zr(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,i=t=>Math.max(0,Math.min(t??0,n));return{tl:i(e.tl),tr:i(e.tr),br:i(e.br),bl:i(e.bl)}}var Dr=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function Er(t){const{innerRadius:e,outerRadius:n,startAngle:i,endAngle:o}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=Dr(n,i),e=Dr(n,o);return`M0,0 L${t.x},${t.y} A${n},${n} 0 ${o-i>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=Dr(n,i),s=Dr(n,o),a=Dr(e,o),c=Dr(e,i),l=o-i>Math.PI?1:0;return`M${t.x},${t.y} A${n},${n} 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,(n-e)/2));if(0===s)return Er({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=o-i,u=t.roundStart&&t.roundEnd?l/2:l,d=!!t.roundStart&&u>a,h=!!t.roundEnd&&u>a;if(!d&&!h)return Er({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=i+(d?a:0),p=o-(h?a:0),y=i+(d?c:0),g=o-(h?c:0),m=Dr(n,f),x=Dr(n,p),b=(n-s)*Math.cos(a),v=Dr(b,i),w=Dr(b,o),k=r?null:Dr(e,g),S=r?null:Dr(e,y),A=r?0:(e+s)*Math.cos(c),M=r?null:Dr(A,i),P=r?null:Dr(A,o),_=p-f>Math.PI?1:0,I=r?0:g-y>Math.PI?1:0;let C="";if(d)C+=`M${v.x},${v.y}`,C+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=Dr(n,i);C+=`M${t.x},${t.y}`}if(h)C+=` A${n},${n} 0 ${_} 1 ${x.x},${x.y}`,C+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=Dr(n,o);C+=` A${n},${n} 0 ${_} 1 ${t.x},${t.y}`}if(r)C+=" L0,0";else{if(h)C+=` L${P.x},${P.y}`,C+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=Dr(e,o);C+=` L${t.x},${t.y}`}if(d)C+=` A${e},${e} 0 ${I} 0 ${S.x},${S.y}`,C+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=Dr(e,i);C+=` A${e},${e} 0 ${I} 0 ${t.x},${t.y}`}}return C+=" Z",C}import{jsx as Br,jsxs as Fr}from"react/jsx-runtime";var Nr={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Or(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function Wr(t,e,n){const i=$e(t.symbolType,t.size,t.path);return Br("path",{d:i,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?Or(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${n??""}symbol-${e}`)}function jr(t,e,n,i){const o=t.glyph;if(!o?.parts?.length||0>=t.size)return null;const r=Ln(o,t.size);if(0>=r.scale)return null;const s=`translate(${e},${n})${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=En(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),l=c?Yr(i+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),d=e=>o.parts.map((n,i)=>{const o=e?"none"===n.fill?void 0:e:$n(n.fill,a,t.accent),r=e?n.stroke&&"none"!==n.stroke?e:void 0:$n(n.stroke??"none",a,t.accent);return o||r?Br("path",{d:n.d,fill:o??"none",stroke:r,strokeWidth:r?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},i):null});return Fr("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&Br("clipPath",{id:l,children:Br("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?Br("g",{children:d(t.ghostColor)}):null,c&&l?Br("g",{clipPath:`url(#${l})`,children:d()}):d()]},i)}function Yr(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function qr(t,e,n){switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return Br("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+e)}case"area":{const i=t;if(0===i.topPath.length)return null;const o=`M${i.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...i.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(i.clipRect){const t=`${n?n+"-":""}area-clip-${e}`;return Fr("g",{children:[Br("defs",{children:Br("clipPath",{id:t,children:Br("rect",{x:i.clipRect.x,y:i.clipRect.y,width:i.clipRect.width,height:i.clipRect.height})})}),Br("path",{d:o,fill:Or(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+e)}return Br("path",{d:o,fill:Or(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"area-"+e)}case"point":{const n=t;return Br("circle",{cx:n.x,cy:n.y,r:n.r,fill:Or(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+e)}case"symbol":return Wr(t,e);case"glyph":return jr(t,t.x,t.y,`${n??""}glyph-${t.pointId??e}`);case"rect":{const n=t;return Br("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Or(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+e)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,o,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]}(n.fill),s=.299*i+.587*o+.114*r>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return Fr("g",{children:[Br("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),Br("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return Br("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+e)}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),r=n.isUp?n.upColor:n.downColor;return Fr("g",{children:[Br("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),Br("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:o,fill:r,stroke:r,strokeWidth:1})]},"candle-"+e)}default:return null}}function Hr(t,e,n){const i=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",o=n=>`ord-${t.type}-${i}-${e}-${n}`,r=`ord-${t.type}-${i}-${e}`;switch(t.type){case"rect":{const e=t,n=Yr(r)+"-grad",i=function(t,e){const n=t.fillGradient;if(!n)return null;let i=t.x,o=t.y,r=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(o=t.y+t.h,s=t.y):"right"===t.roundedEdge?(i=t.x+t.w,o=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(i=t.x,o=t.y,r=t.x+t.w,s=t.y);const a=[];if("colorStops"in n){const t=n.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(Br("stop",{offset:t[e].offset,stopColor:t[e].color},e))}else{const e=Or(t.style.fill);a.push(Br("stop",{offset:0,stopColor:e,stopOpacity:n.topOpacity},"0")),a.push(Br("stop",{offset:1,stopColor:e,stopOpacity:n.bottomOpacity},"1"))}return Br("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:i,y1:o,x2:r,y2:s,children:a})}(e,n),o=i?`url(#${n})`:Or(e.style.fill);if(e.cornerRadii&&$r(e.cornerRadii)){const t=function(t){const{x:e,y:n,w:i,h:o}=t,{tl:r,tr:s,br:a,bl:c}=zr(t);let l=`M${e+r},${n}`;return l+=` L${e+i-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+i},${n+s}`),l+=` L${e+i},${n+o-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+i-a},${n+o}`),l+=` L${e+c},${n+o}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${n+o-c}`),l+=` L${e},${n+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${e+r},${n}`),l+=" Z",l}(e);return Fr(Rr.Fragment,{children:[i&&Br("defs",{children:i}),Br("path",{d:t,fill:o,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:n,y:s,w:a,h:c}=e;let l;switch(e.roundedEdge){case"right":l=`M${n},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+c-t} A${t},${t} 0 0 1 ${n+a-t},${s+c} L${n},${s+c} Z`;break;case"left":l=`M${n+a},${s} L${n+t},${s} A${t},${t} 0 0 0 ${n},${s+t} L${n},${s+c-t} A${t},${t} 0 0 0 ${n+t},${s+c} L${n+a},${s+c} Z`;break;case"bottom":l=`M${n},${s} L${n+a},${s} L${n+a},${s+c-t} A${t},${t} 0 0 1 ${n+a-t},${s+c} L${n+t},${s+c} A${t},${t} 0 0 1 ${n},${s+c-t} Z`;break;default:l=`M${n},${s+c} L${n},${s+t} A${t},${t} 0 0 1 ${n+t},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+c} Z`}return Fr(Rr.Fragment,{children:[i&&Br("defs",{children:i}),Br("path",{d:l,fill:o,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return Fr(Rr.Fragment,{children:[i&&Br("defs",{children:i}),Br("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:o,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}case"point":{const e=t;return Br("circle",{cx:e.x,cy:e.y,r:e.r,fill:Or(e.style.fill),opacity:e.style.opacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return Wr(t,e,n);case"glyph":return jr(t,t.x,t.y,`${n??""}ord-glyph-${t.pointId??e}`);case"wedge":{const i=t;if(i._gradientBand&&i._gradientBand.colors.length>0){const t=Yr(`${n?n+"-":""}gauge-grad-${i.category||r}-${e}`),{clipPath:o,slices:s}=function(t){const e=Er({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],i=t.colors;if(i.length>0){const e=(t.endAngle-t.startAngle)/i.length;for(let o=0;i.length>o;o++)n.push({d:Er({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+o*e,endAngle:t.endAngle}),color:i[o]})}return{clipPath:e,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds?.start??!0,roundEnd:i.roundedEnds?.end??!0,colors:i._gradientBand.colors});return Fr("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[Br("defs",{children:Br("clipPath",{id:t,children:Br("path",{d:o})})}),Br("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>Br("path",{d:t.d,fill:Or(t.color)},e))}),i.style.stroke&&"none"!==i.style.stroke&&Br("path",{d:o,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},r)}let o;if(i.roundedEnds)o=Er({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=Lr().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),o=t(Nr)||""}return Br("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:Or(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},r)}case"boxplot":{const e=t,n=e.columnWidth/2;return Fr("g","vertical"===e.projection?{children:[Br("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),Br("rect",{x:e.x-n,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:Or(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),Br("line",{x1:e.x-n,y1:e.medianPos,x2:e.x+n,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),Br("line",{x1:e.x-.5*n,y1:e.minPos,x2:e.x+.5*n,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),Br("line",{x1:e.x-.5*n,y1:e.maxPos,x2:e.x+.5*n,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})]}:{children:[Br("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),Br("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-n,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:Or(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),Br("line",{x1:e.medianPos,y1:e.y-n,x2:e.medianPos,y2:e.y+n,stroke:e.style.stroke||"#333",strokeWidth:2}),Br("line",{x1:e.minPos,y1:e.y-.5*n,x2:e.minPos,y2:e.y+.5*n,stroke:e.style.stroke||"#333",strokeWidth:1}),Br("line",{x1:e.maxPos,y1:e.y-.5*n,x2:e.maxPos,y2:e.y+.5*n,stroke:e.style.stroke||"#333",strokeWidth:1})]},r)}case"violin":{const e=t,n=[Br("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:Or(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},o("path"))];if(e.iqrLine&&e.bounds){const t=e.bounds,i=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?n.push(Br("line",{x1:i,y1:e.iqrLine.q1Pos,x2:i,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},o("iqr")),Br("circle",{cx:i,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},o("med"))):n.push(Br("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},o("iqr")),Br("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},o("med")))}return Br("g",{children:n},r)}case"connector":return Br("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,n=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return Br("polygon",{points:n,fill:Or(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}}var Xr="undefined"==typeof window||"undefined"==typeof document;import{useEffect as Gr,useLayoutEffect as Vr,useRef as Ur,useState as Kr,useSyncExternalStore as Zr}from"react";var Qr="undefined"!=typeof window?Vr:Gr;function Jr(){const[t,e]=Kr(!1);return Qr(()=>{e(!0)},[]),t}var ts=()=>()=>{},es=()=>!1,ns=()=>!0;function is(){const t=Zr(ts,es,ns);return Ur(t).current}function os(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:i,dirtyRef:o,renderFnRef:r,cancelRender:s,cleanup:a}=t;Qr(()=>{e&&n&&i.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),r.current()},[e,n]);const c=Ur(a);c.current=a,Gr(()=>()=>c.current?.(),[])}import{useRef as rs}from"react";function ss(t,e){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}function as(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 cs(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}var ls={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",background:""};function us(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}import*as ds from"react";import*as hs from"react";import{jsx as fs}from"react/jsx-runtime";var ps=hs.createContext(null);function ys(){return hs.useContext(ps)}function gs(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,i]of Object.entries(t))n.startsWith("_")||null!=i&&""!==i&&("number"==typeof i?Number.isFinite(i)&&(e[n]=i):"string"==typeof i?e[n]=i:"boolean"==typeof i?e[n]=i+"":i instanceof Date&&(e[n]=i.toISOString().slice(0,10)));return e}function ms(t){return t&&"object"==typeof t?t:{}}function xs(t){return ms(t.accessibility).tableFields??t.accessibleDatum??t.datum}import{jsx as bs,jsxs as vs}from"react/jsx-runtime";var ws={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ks(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===e?.datum)continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const i=[],o={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),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}var Ss=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},As="semiotic-accessible-data-table",Ms=As+" semiotic-accessible-data-table-hidden",Ps=As+" semiotic-accessible-data-table-visible",_s={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"},Is={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Cs={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)"},Ts={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Rs={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))"},Ls={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},$s={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},zs={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 Ds({scene:t,chartType:e,tableId:n,chartTitle:i}){const[o,r]=ds.useState(!1),[s,a]=ds.useState(5),c=ys(),l=c?.visible??!1,u=o||l,d=ds.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${e} ${n}`:"Data summary for "+e;ds.useEffect(()=>{u||a(5)},[u]);const f=ds.useCallback(t=>{t.target===t.currentTarget&&(o||l||r(!0))},[o,l]),p=ds.useCallback(t=>{l||d.current?.contains(t.relatedTarget)||r(!1)},[l]);if(!t||0===t.length)return n?bs("span",{id:n,tabIndex:-1,style:ws}):null;if(!u)return bs("div",{id:n,className:Ms,tabIndex:-1,onFocus:f,style:ws,role:"region","aria-label":h,children:vs("button",{type:"button",onClick:()=>r(!0),children:["View data summary (",t.length," elements)"]})});const y=function(t){const e=[];if(!Array.isArray(t))return e;const n=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const i of t)if(i&&"object"==typeof i&&null!==i.datum)try{switch(i.type){case"point":if(n)break;e.push({label:"Point",values:gs(xs(i))});break;case"line":case"area":{const t=xs(i),n=Array.isArray(t)?t:[],o="line"===i.type?"Line point":"Area point";for(const t of n)e.push({label:o,values:gs(t)});break}case"rect":{const t=xs(i),n=null!=t&&"object"==typeof t?t:{},o=n.category??i.group??"",r=n.value??n.__aggregateValue??n.total,s=gs(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=r&&(s.value="number"==typeof r||"string"==typeof r?r:r+""),e.push({label:"Bar",values:s});break}case"heatcell":{const t=gs(xs(i));null==t.value&&"number"==typeof i.value&&Number.isFinite(i.value)&&(t.value=i.value),e.push({label:"Cell",values:t});break}case"wedge":{const t=xs(i),n=gs(t);if(null==n.category){const e=ms(t),i=e.category??e.label;null!=i&&(n.category=i+"")}e.push({label:"Wedge",values:n});break}case"circle":e.push({label:"Node",values:gs(xs(i))});break;case"arc":e.push({label:"Arc",values:gs(xs(i))});break;case"candlestick":e.push({label:"Candlestick",values:gs(xs(i))});break;case"geoarea":{const t=ms(xs(i)),n=gs(t);if(null==n.name){const e=ms(t.properties).name??t.name;null!=e&&(n.name=e+"")}e.push({label:"Region",values:n});break}}}catch{}return e}(t),g=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 i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(y),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Ss(t.min)} to ${Ss(t.max)}, mean ${Ss(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const t of b)for(const e of Object.keys(t.values))w.add(e);const k=Array.from(w);return vs("div",{ref:d,id:n,className:Ps,tabIndex:-1,onBlur:p,style:_s,role:"region","aria-label":h,children:[bs("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),r(!1)},"aria-label":"Close data summary",style:Cs,children:"×"}),bs("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Is,children:m}),vs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+e,style:Ts,children:[bs("caption",{className:"semiotic-accessible-data-table-caption",style:$s,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),bs("thead",{children:vs("tr",{children:[bs("th",{style:Rs,children:"type"}),k.map(t=>bs("th",{style:Rs,children:t},t))]})}),bs("tbody",{children:b.map((t,e)=>vs("tr",{children:[bs("td",{style:Ls,children:t.label}),k.map(e=>{return bs("td",{style:Ls,children:(n=t.values[e],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ss(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},e);var n})]},e))})]}),v>0&&vs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(t=>t+25),style:zs,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function Es({summary:t}){return t?bs("div",{role:"note",style:ws,children:t}):null}function Bs({tableId:t}){return bs("a",{href:"#"+t,style:ws,onClick:e=>{e.preventDefault();const n=document.getElementById(t);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,ws)},children:"Skip to data table"})}function Fs({hoverPoint:t}){let e="";if(t){const n=t.data||t;e="object"==typeof n?"Data point: "+Object.entries(n).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Data point: "+n}return bs("div",{"aria-live":"polite","aria-atomic":"true",style:ws,children:e})}import{jsx as Ns}from"react/jsx-runtime";var Os="var(--semiotic-focus, #005fcc)";function Ws({active:t,hoverPoint:e,margin:n,size:i,shape:o="circle",width:r,height:s,pathData:a}){if(!t||!e)return null;const c=e.x+n.left,l=e.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=r&&null!=s){const t=Math.max(r,4),e=Math.max(s,4);u=Ns("rect",{x:c-t/2-3,y:l-e/2-3,width:t+6,height:e+6,rx:3,fill:"none",stroke:Os,strokeWidth:2,strokeDasharray:"4,2"})}else u=Ns("circle","wedge"===o?{cx:c,cy:l,r:12,fill:"none",stroke:Os,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:Os,strokeWidth:2,strokeDasharray:"4,2"});else u=Ns("g",{transform:`translate(${n.left},${n.top})`,children:Ns("path",{d:a,fill:"none",stroke:Os,strokeWidth:2.5,strokeDasharray:"6,3"})});return Ns("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as js from"react";import{jsx as Ys}from"react/jsx-runtime";function qs({x:t,y:e,containerWidth:n,containerHeight:i,margin:o,children:r,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(t)&&Number.isFinite(e),l=js.useRef(null),[u,d]=js.useState(null);js.useLayoutEffect(()=>{const t=l.current;if(!t)return;const e=t.getBoundingClientRect();d(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[r,s,n,i]);let h;h=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-e?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>e?"4px":"calc(-100% - 4px)"})`;const f=function(t){if(!js.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background&&"transparent"!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor&&"transparent"!==i.backgroundColor)return!0}return!1}(r),p=f?null:N;return c?Ys("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:o.left+t,top:o.top+e,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:r}):null}import*as Hs from"react";import{useCallback as Xs,useEffect as Gs,useLayoutEffect as Vs,useMemo as Us,useRef as Ks}from"react";import{useState as Zs,useEffect as Qs}from"react";import{useRef as Js,useState as ta,useEffect as ea}from"react";var na="undefined"==typeof window?Gs:Vs,ia={requestAnimationFrame:t=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(t),cancelAnimationFrame:t=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(t)};function oa(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function ra(t){const e=function(){const[t,e]=Zs(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return Qs(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(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=>e(t.matches))},[]),t}(),n=Ks(e);n.current=e;const[i,o]=function(t,e,n){const i=Js(null),[o,r]=ta(null);return ea(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;r(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&o?o.w:t[0],n&&o?o.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),r=Us(()=>({...t.marginDefault,...t.userMargin}),[t.marginDefault,t.userMargin]),s=o[0]-r.left-r.right,a=o[1]-r.top-r.bottom,c=oa(t.foregroundGraphics,o,r),l=oa(t.backgroundGraphics,o,r),u=Ot(t=>t.theme),{transition:d,introEnabled:h}=function(t,e){if(!1===t)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:t?!0===t?{duration:300}:{duration:t.duration??300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(n||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),f="semiotic-table-"+Hs.useId(),p=Ks(null),y=Ks(t.frameScheduler??ia);y.current=t.frameScheduler??ia;const g=Ks(null),m=Ks(!1),x=Ks(()=>{}),b=Xs(()=>{if(null!==p.current||m.current)return;const t=y.current;let e=!1,n=!1;const i=t.requestAnimationFrame(()=>{e=!0;const t=!n;t&&(m.current=!0),p.current=null,g.current=null;try{x.current()}finally{t&&(m.current=!1)}});n=!0,e||(p.current=i,g.current=t)},[]),v=Xs(()=>{null!==p.current&&((g.current??y.current).cancelAnimationFrame(p.current),p.current=null,g.current=null)},[]);Gs(()=>()=>{v()},[v]);const w=Ks(()=>{}),k=Ks(()=>{}),S=Ks(null),A=Ks(null),M=Ks(null),P=Xs(()=>{const t=S.current;S.current=null,t&&w.current(t)},[]),_=Xs(t=>{if(S.current={clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType},null===A.current){const t=y.current;let e=!1;const n=t.requestAnimationFrame(()=>{e=!0,A.current=null,M.current=null,P()});e||(A.current=n,M.current=t)}},[P]),I=Xs(()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null),k.current()},[]);Gs(()=>()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null)},[]);const C=t.themeDirtyRef;return na(()=>{C&&(Wn++,C.current=!0,b())},[u,b,C]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:i,size:o,margin:r,adjustedWidth:s,adjustedHeight:a,resolvedForeground:c,resolvedBackground:l,currentTheme:u,transition:d,introEnabled:h,tableId:f,rafRef:p,renderFnRef:x,scheduleRender:b,cancelRender:v,hoverHandlerRef:w,hoverLeaveRef:k,onPointerMove:_,onPointerLeave:I}}function sa(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=Math.round(e[0]*i),s=Math.round(e[1]*i),a=r/e[0],c=s/e[1],l=e[0]+"px",u=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==u&&(t.style.height=u),t.width===r&&t.height===s||(t.width=r,t.height=s),o.setTransform(a,0,0,c,0,0),o.translate(n.left,n.top),o}function aa(){if("undefined"==typeof window)return 1;const t=window.devicePixelRatio||1,e=function(){if("undefined"==typeof window)return!1;const t="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,e=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return t||e}()?2:3;return Math.max(1,Math.min(t,e))}import{useCallback as ca}from"react";function la(t,e,n,i){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:i,fn:e}:{key:void 0,fn:null}}var ua=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],da=3156e7;function ha(t){const e=t[1]-t[0];return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:da>e?t=>{const e=new Date(t);return`${ua[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*da>e?t=>{const e=new Date(t);return`${ua[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}function fa(t){if(!t)return;const e=[];for(const n of t)if("point"===n.type)e.push(n);else if("symbol"===n.type)e.push({pointId:n.pointId,x:n.x,y:n.y,r:ze(n.size)});else if("glyph"===n.type){const t=Bn(n.glyph,n.size);e.push({pointId:n.pointId,x:n.x+t.centerDx,y:n.y+t.centerDy,r:t.radius})}return e}import{line as pa}from"d3-shape";function ya(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function ga(t,e,n,i,o,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],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;c>i&&(r*=i/c),c>a-i&&(r*=(a-i)/c),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()}}var ma=(t,e,n,i)=>{const o=e.filter(t=>"line"===t.type);for(const e of o){if(2>e.path.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,i.width*n,i.height),t.clip());const o=e.style.stroke||"#007bff",r=Hn(t,o)||o,s=e.style.strokeWidth||2,a=e.colorThresholds,c=e.rawValues;if(t.setLineDash(e.style.strokeDasharray?e.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),t.lineWidth=s,t.lineCap=e.style.strokeLinecap||"butt",e.style._edgeFade){ga(t,e.path,r,s,e.style.opacity??1,e.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const l=ei(e.curve),u=a&&a.length>0&&c&&c.length===e.path.length,d=e._decayOpacities;if(d&&d.length===e.path.length&&!u){t.strokeStyle=r;const n=e.style.opacity??1;for(let i=0;e.path.length-1>i;i++)t.globalAlpha=.5*(d[i]+d[i+1])*n,t.beginPath(),t.moveTo(e.path[i][0],e.path[i][1]),t.lineTo(e.path[i+1][0],e.path[i+1][1]),t.stroke()}else if(u){let n=function(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),d=!0},i=function(){d&&(t.stroke(),d=!1)},o=null,s=null,l=null,u=null,d=!1;for(let d=0;e.path.length>d;d++){const[h,f]=e.path[d],p=c[d],y=ya(p,a,r);if(null!==o&&null!==u&&null!==l){if(y===u)t.lineTo(h,f);else{const e=[];for(const t of a){const n=t.value;(l>n||n>p)&&(n>l||p>n)||l===n||p===n||e.push({t:(n-l)/(p-l)})}e.sort((t,e)=>t.t-e.t);for(const c of e){const e=o+(h-o)*c.t,u=s+(f-s)*c.t,d=ya(l+(p-l)*Math.min(c.t+1e-4,1),a,r);t.lineTo(e,u),i(),n(d,e,u)}t.lineTo(h,f)}o=h,s=f,l=p,u=y}else n(y,h,f),o=h,s=f,l=p,u=y}i()}else{t.beginPath();const n=e.strokeGradient&&e.path.length>=2?oi(t,e.strokeGradient,e.path[0][0],0,e.path[e.path.length-1][0],0):null;if(t.strokeStyle=n||r,l)pa().x(t=>t[0]).y(t=>t[1]).curve(l).context(t)(e.path);else{const[n,i]=e.path[0];t.moveTo(n,i);for(let n=1;e.path.length>n;n++)t.lineTo(e.path[n][0],e.path[n][1])}t.stroke()}if(e.style.fill&&e.style.fillOpacity&&e.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=e.style.fillOpacity,t.fillStyle=ni(t,e.style.fill,e.style.fill),l&&!u)pa().x(t=>t[0]).y(t=>t[1]).curve(l).context(t)(e.path);else{const[n,i]=e.path[0];t.moveTo(n,i);for(let n=1;e.path.length>n;n++)t.lineTo(e.path[n][0],e.path[n][1])}const n=e.path[0][0];t.lineTo(e.path[e.path.length-1][0],i.height),t.lineTo(n,i.height),t.closePath(),t.fill()}void 0!==n&&1>n&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function xa(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ba(t,e,n=.3){xa(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 va(t,e,n=.6){if(!xa(e))return;const i=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,o=e.cx??e.x??0,r=e.cy??e.y??0;t.beginPath(),t.arc(o,r,i,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 wa(t,e,n,i=.35){xa(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",n?t.fill(n):t.fill())}import{area as ka,line as Sa}from"d3-shape";function Aa(t,e){const n=ei(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 i=ka().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}var Ma=(t,e,n,i)=>{const o=e.filter(t=>"area"===t.type);for(const e of o){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 o=e._introClipFraction;void 0!==o&&1>o&&(t.save(),t.beginPath(),t.rect(0,0,i.width*o,i.height),t.clip());const r=ni(t,e.style.fill,"#4e79a7"),s=e._decayOpacities;if(s&&s.length===e.topPath.length){const n=e.style.fillOpacity??.7;t.fillStyle=r;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(s[i]+s[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Hn(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*(s[n]+s[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 a=e.style.opacity??1;if(Aa(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 i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=ii(t,e.fillGradient,"string"==typeof r?r:"#4e79a7",0,n,0,i);t.fillStyle=o||r,t.globalAlpha=a}else t.globalAlpha=(e.style.fillOpacity??.7)*a,t.fillStyle=r;if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Aa(t,e),wa(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a;const n=e.strokeGradient&&e.topPath.length>=2?oi(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Hn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=ei(e.curve);if(t.beginPath(),i)Sa().x(t=>t[0]).y(t=>t[1]).curve(i).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!==o&&1>o&&t.restore(),n&&t.restore(),t.globalAlpha=1}},Pa=(t,e,n,i)=>{const o=e.filter(t=>"point"===t.type);if(0!==o.length){t.save();try{const e=t.globalAlpha;for(const n of o)t.beginPath(),t.arc(n.x,n.y,n.r,0,2*Math.PI),t.globalAlpha=e*(n.style.opacity??n.style.fillOpacity??1),t.fillStyle=ni(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=ni(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),va(t,n)}finally{t.restore()}}},_a=new Map;function Ia(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let n=_a.get(e);return n||(n=new Path2D($e(t.symbolType,t.size)),_a.size>256&&_a.clear(),_a.set(e,n)),n}catch{return null}}var Ca=(t,e)=>{const n=t.globalAlpha;for(const i of e){if("symbol"!==i.type)continue;const e=i;if(0>=e.size)continue;const o=Ia(e);if(!o)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const r=(e.style.opacity??1)*(e._decayOpacity??1);e.style.fill&&(t.globalAlpha=n*r*(e.style.fillOpacity??1),t.fillStyle=ni(t,e.style.fill,"#4e79a7"),t.fill(o)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*r,t.strokeStyle=ni(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth??1,t.stroke(o)),t.restore()}t.globalAlpha=n};function Ta(t,e,n,i,o){if(0>=e.size)return;const r=e.glyph;if(!r||!r.parts?.length)return;const s=Ln(r,e.size);if(0>=s.scale)return;const a=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=a)return;const c=e=>{const n=ni(t,e,e);return"string"==typeof n?n:e},l=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(n,i),e.rotation&&t.rotate(e.rotation),t.translate(s.offsetX,s.offsetY),t.scale(s.scale,s.scale),t.globalAlpha=o*a*(e.style.fillOpacity??1);const u=En(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");u&&e.ghostColor&&Fn(t,r,l,e.accent,e.ghostColor,c),u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),Fn(t,r,l,e.accent,void 0,c),t.restore()}function Ra(t,e){const{x:n,y:i,w:o,h:r}=e,{tl:s,tr:a,br:c,bl:l}=zr(e);t.beginPath(),t.moveTo(n+s,i),t.lineTo(n+o-a,i),a>0&&t.arcTo(n+o,i,n+o,i+a,a),t.lineTo(n+o,i+r-c),c>0&&t.arcTo(n+o,i+r,n+o-c,i+r,c),t.lineTo(n+l,i+r),l>0&&t.arcTo(n,i+r,n,i+r-l,l),t.lineTo(n,i+s),s>0&&t.arcTo(n,i,n+s,i,s),t.closePath()}function La(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}}}var $a=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)za(t,e);else if(e.cornerRadii&&$r(e.cornerRadii)){const n=ni(t,e.style.fill,Hn(t,"var(--semiotic-primary, #007bff)")),i=La(e),o=e.fillGradient&&"string"==typeof n?ii(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,Ra(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Hn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=ni(t,e.style.fill,Hn(t,"var(--semiotic-primary, #007bff)")),i=La(e),o=e.fillGradient&&"string"==typeof n?ii(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:c,h:l}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+c-r,a),t.arcTo(s+c,a,s+c,a+r,r),t.lineTo(s+c,a+l-r),t.arcTo(s+c,a+l,s+c-r,a+l,r),t.lineTo(s,a+l);break;case"left":t.moveTo(s+c,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+l-r),t.arcTo(s,a+l,s+r,a+l,r),t.lineTo(s+c,a+l);break;case"bottom":t.moveTo(s,a),t.lineTo(s+c,a),t.lineTo(s+c,a+l-r),t.arcTo(s+c,a+l,s+c-r,a+l,r),t.lineTo(s+r,a+l),t.arcTo(s,a+l,s,a+l-r,r);break;default:t.moveTo(s,a+l),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+c-r,a),t.arcTo(s+c,a,s+c,a+r,r),t.lineTo(s+c,a+l)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Hn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=ni(t,e.style.fill,Hn(t,"var(--semiotic-primary, #007bff)")),i=La(e),o=e.fillGradient&&"string"==typeof n?ii(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Hn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ba(t,e),t.globalAlpha=1}};function za(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)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=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function Da(t){const[e,n,i]=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*i>128?"#000":"#fff"}function Ea(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var Ba=(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=n?.opacity&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Hn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ba(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):Ea(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=Da(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},Fa=(t,e,n,i)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const o=(e._decayOpacity??1)*(e.style?.opacity??1);1!==o&&(t.globalAlpha=o);const r=Hn(t,e.wickColor)||e.wickColor,s=60>i.height,a=s?Math.max(e.wickWidth,2):e.wickWidth,c=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=r,t.lineWidth=a,t.stroke()};if(s||c(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=r,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),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=Hn(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}s&&c(),t.restore()}},Na={line:[Ma,ma,Pa],area:[Ma,Pa],stackedarea:[Ma,Pa],scatter:[Pa,Ca],bubble:[Pa,Ca],heatmap:[Ba],bar:[$a],swarm:[Pa],waterfall:[(t,e,n,i)=>{$a(t,e);const o=e.filter(t=>"rect"===t.type);if(2>o.length)return;const r=o[0].datum,s=r?._connectorStroke;if(s){t.save(),t.strokeStyle=Hn(t,s)||s,t.lineWidth=r?._connectorWidth??1,t.setLineDash([]);for(let e=0;o.length-1>e;e++){const i=o[e],r=o[e+1],s=i.datum,a=r.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=i.x+i.w,u=r.x;t.beginPath(),t.moveTo(l,c),t.lineTo(u,c),t.stroke()}t.restore()}}],candlestick:[Fa],mixed:[Ma,ma,Pa],custom:[Ma,$a,Ba,ma,Pa,Ca,(t,e)=>{const n=t.globalAlpha;for(const i of e)"glyph"===i.type&&Ta(t,i,i.x,i.y,n);t.globalAlpha=n},Fa]};import{jsx as Oa,jsxs as Wa}from"react/jsx-runtime";import{jsx as ja,jsxs as Ya}from"react/jsx-runtime";function qa(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function Ha({hover:t}){const e=t.data??{},n=e.y??e.value,i=e.x??e.time;if(void 0===n&&void 0===i){const t=function(t,e={}){if(!t||"object"!=typeof t)return{entries:[]};const n=e.maxEntries??6,i=!1!==e.skipPositional,o=[];for(const[e,n]of Object.entries(t)){if(e.startsWith("_"))continue;if("data"===e)continue;if(i&&D.has(e.toLowerCase()))continue;if(null==n)continue;const t=typeof n;("string"===t||"number"===t||"boolean"===t||n instanceof Date)&&o.push({key:e,lower:e.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let r=o.findIndex(t=>L.includes(t.lower));const s=r>=0;0>r&&(r=o.findIndex(t=>"id"===t.lower)),0>r&&(r=o.findIndex(t=>"string"==typeof t.value));const a=0>r?void 0:o[r];let c=o.filter((t,e)=>e!==r);s&&(c=c.filter(t=>"id"!==t.lower));const l=E(c,$),u=E(c,z),d=new Set($),h=new Set(z),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const t of c){if(f.length>=n)break;t!==l&&t!==u&&(d.has(t.lower)||h.has(t.lower)||f.push({key:t.key,value:t.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}(e);if(null!=t.title||t.entries.length>0)return Ya("div",{className:"semiotic-tooltip",style:N,children:[null!=t.title&&ja("div",{style:{fontWeight:600,marginBottom:t.entries.length?2:0},children:t.title+""}),t.entries.map(t=>Ya("div",{style:{opacity:.7,fontSize:11},children:[t.key,":"," ",ja("span",{style:{fontWeight:600},children:qa(t.value)})]},t.key))]})}return Ya("div",{className:"semiotic-tooltip",style:N,children:[ja("div",{style:{fontWeight:600,marginBottom:2},children:qa(n)}),ja("div",{style:{opacity:.7,fontSize:11},children:qa(i)})]})}Ha.ownsChrome=!0;import{jsx as Xa,jsxs as Ga}from"react/jsx-runtime";var Va={top:20,right:20,bottom:30,left:40},Ua=ls;function Ka(t){if(t)return"x"===t.dimension?"pan-y":"y"===t.dimension?"pan-x":"none"}var Za=at(st(function(t,e){const{chartType:n,runtimeMode:i,data:o,chunkThreshold:r,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p,lineDataAccessor:y,curve:g,normalize:m,baseline:x,stackOrder:b,binSize:v,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:M,xExtent:P,yExtent:_,extentPadding:T=.1,scalePadding:L,sizeRange:$,size:z=[500,300],responsiveWidth:D,responsiveHeight:E,margin:B,className:F,background:N,lineStyle:O,pointStyle:W,areaStyle:j,barStyle:Y,waterfallStyle:q,swarmStyle:H,barColors:X,colorScheme:G,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:st,lineGradient:at,areaGroups:ct,openAccessor:lt,highAccessor:ut,lowAccessor:dt,closeAccessor:ht,candlestickStyle:ft,showAxes:pt=!0,axes:yt,xLabel:gt,yLabel:mt,yLabelRight:xt,xFormat:bt,yFormat:vt,axisExtent:St,tickFormatTime:At,tickFormatValue:Mt,hoverAnnotation:Pt,tooltipContent:_t,customHoverBehavior:It,customClickBehavior:Ct,enableHover:Tt,hoverRadius:Rt=30,tooltipMode:$t,annotations:zt,autoPlaceAnnotations:Dt,svgAnnotationRules:Et,showGrid:Bt,legend:Ft,legendHoverBehavior:Nt,legendClickBehavior:Ot,legendHighlightedCategory:Wt,legendIsolatedCategories:jt,legendPosition:Yt,legendLayout:qt,legendCategoryAccessor:Ht,onCategoriesChange:Xt,backgroundGraphics:Gt,foregroundGraphics:Vt,canvasPreRenderers:Ut,svgPreRenderers:Kt,title:Zt,categoryAccessor:Qt,brush:Jt,onBrush:te,decay:ee,pulse:ne,transition:ie,animate:oe,staleness:re,heatmapAggregation:se,heatmapXBins:ae,heatmapYBins:ce,showValues:le,heatmapValueFormat:ue,marginalGraphics:de,pointIdAccessor:he,xScaleType:fe,yScaleType:pe,accessibleTable:ye=!0,description:ge,summary:me,linkedCrosshairName:xe,linkedCrosshairSourceId:ve,customLayout:we,onLayoutError:ke,layoutConfig:Se,layoutSelection:Ae}=t,Me=rt().replace(/:/g,""),Pe=J(!1),_e=J({w:-1,h:-1}),Ie=J(!1),Ce=ra({sizeProp:z,responsiveWidth:D,responsiveHeight:E,userMargin:B,marginDefault:Va,animate:oe,transitionProp:ie,themeDirtyRef:Pe}),Te=Jr(),Re=is(),{reducedMotionRef:Le,responsiveRef:$e,size:ze,currentTheme:De,transition:Ee,introEnabled:Be,tableId:Fe,rafRef:Ne,renderFnRef:Oe,scheduleRender:We,cancelRender:je}=Ce;let Ye=Ce.margin;if(de){const t=60,e={...Ce.margin};de.top&&t>e.top&&(e.top=t),de.bottom&&t>e.bottom&&(e.bottom=t),de.left&&t>e.left&&(e.left=t),de.right&&t>e.right&&(e.right=t),Ye=e}const qe=ze[0]-Ye.left-Ye.right,He=ze[1]-Ye.top-Ye.bottom,Xe=nt(()=>I(o),[o]),Ge=Pt??Tt,Ve=J(null),Ue=J(null),[Ke,Ze]=tt(0),Qe=J(0),[Je,tn]=tt(null),en=(t,e)=>"function"==typeof t?t({size:ze,margin:Ye,scales:e}):t,nn=en(Vt,Je),on=en(Gt,Je),rn=J(null),sn=J(null),an=J(void 0),[cn,ln]=tt(null),un=J(Ua.primary),dn=J(function(){let t=-1,e=ls;return{resolve(n){if(!n)return ls;const i=Wn;return i===t||(e=function(t){if(!t)return ls;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),c=n||e.getPropertyValue("--surface-3").trim(),l=o||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:c||ls.axisStroke,tickText:s||ls.tickText,crosshair:s?us(s,"66"):ls.crosshair,hoverFill:l?us(l,"4D"):ls.hoverFill,hoverStroke:s?us(s,"99"):ls.hoverStroke,pointRing:l||ls.pointRing,primary:r||ls.primary,background:l||ls.background}:ls}(n),t=i),e},invalidate(){t=-1}}}()),fn=J(!1),pn=J(new gn),yn=J([]),mn=J(Ht),bn=J(Xt);mn.current=Ht,bn.current=Xt;const[vn,wn]=tt(!1),[kn,Pn]=tt([]),[_n,In]=tt([]),Cn="streaming"===i||["bar","swarm","waterfall"].includes(n),Tn=function(t){const e=rs(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return as(t,e);if(!cs(t)||!cs(e))return!1;const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;const n=t[i],o=e[i];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!as(n,o))return!1}else{if(!cs(n)||!cs(o))return!1;if(!ss(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}(nt(()=>({chartType:n,runtimeMode:Cn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Cn?k:"right",extentPadding:T,scalePadding:L,axisExtent:St,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Cn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Qt,lineDataAccessor:y,xScaleType:fe,yScaleType:pe,xExtent:P,yExtent:_,sizeRange:$,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:!0===st?{topOpacity:.8,bottomOpacity:.05}:!1===st?void 0:st,areaGroups:ct?new Set(ct):void 0,lineGradient:at,openAccessor:lt,highAccessor:ut,lowAccessor:dt,closeAccessor:ht,candlestickStyle:ft,lineStyle:O,pointStyle:W,areaStyle:j,swarmStyle:H,waterfallStyle:q,colorScheme:G,barColors:X,barStyle:Y,annotations:zt,decay:ee,pulse:ne,transition:Ee,introAnimation:Be,staleness:re,heatmapAggregation:se,heatmapXBins:ae,heatmapYBins:ce,showValues:le,heatmapValueFormat:ue,pointIdAccessor:he,curve:g,themeCategorical:De?.colors?.categorical,themeSemantic:Lt(De),themeSequential:De?.colors?.sequential,themeDiverging:De?.colors?.diverging,customLayout:we,onLayoutError:ke,layoutConfig:Se,layoutMargin:Ye}),[n,A,S,k,T,L,St,a,c,l,M,w,fe,pe,u,d,h,f,p,Qt,y,P,_,$,v,m,x,b,V,U,K,Z,st,at,ct,lt,ut,dt,ht,ft,O,W,j,H,q,Y,G,X,zt,ee,ne,Ee?.duration,Ee?.easing,Be,re,se,ae,ce,le,ue,Cn,he,g,De,we,ke,Se,Ye])),Rn=J(null);Rn.current||(Rn.current=new hn(Tn));const Ln=function(t,e,n,i){return ca(()=>{const o=e.current,r=n.current;if(!r||!o)return;const s=function(t,e){if(!e)return[];const n=new Set,i=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),i.push(r))}return i}(t.current?.getData()??[],o);(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})(s,i.current)||(i.current=s,r(s))},[e,n,i,t])}(Rn,mn,bn,yn);!function(t,e,n,i){An(()=>{t.current?.updateConfig(e),n.current=!0,i()},[e,i,t,n])}(Rn,Tn,Pe,We),function(t,e,n,i){const o=Mn(null);An(()=>{const r=t.current;if(!r)return;const s=e??null;o.current!==s&&(o.current=s,r.setLayoutSelection(s),r.hasCustomRestyle?r.restyleScene(s):n.current=!0,i())},[e,i,t,n])}(Rn,Ae,Pe,We);const $n=J(null);$n.current||($n.current=new kt(t=>{const e=Rn.current;e&&e.ingest(t)&&(Pe.current=!0,We())},{chunkThreshold:r,chunkSize:s})),et(()=>{$n.current?.updateChunkOptions({chunkThreshold:r,chunkSize:s})},[r,s]);const zn=it(t=>{$n.current?.push(t)},[]),Dn=it(t=>{$n.current?.pushMany(t)},[]),En=it(()=>{$n.current?.clear(),Rn.current?.clear(),Pe.current=!0,We()},[We]);ot(e,()=>({push:zn,pushMany:Dn,remove:t=>{$n.current?.flush();const e=Rn.current?.remove(t)??[];return e.length>0&&(rn.current&&e.some(t=>t===rn.current?.data)&&(rn.current=null,ln(null)),Pe.current=!0,We()),e},update:(t,e)=>{$n.current?.flush();const n=Rn.current?.update(t,e)??[];return n.length>0&&(Pe.current=!0,We()),n},clear:En,getData:()=>($n.current?.flush(),Rn.current?.getData()??[]),getScales:()=>Rn.current?.scales??null,getExtents:()=>Rn.current?.getExtents()??null,getCustomLayout:()=>Rn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Rn.current?.lastCustomLayoutFailure??null}),[zn,Dn,En,We]),et(()=>{if(o){if(y&&Xe.length>0&&"object"==typeof Xe[0]&&null!==Xe[0]){const t="string"==typeof y?y:"coordinates";if(Array.isArray(Xe[0][t])){const e=[];for(const n of Xe){const i=n[t];if(Array.isArray(i)){const t=n.label||n.id||n.key;if(null!=t)for(const n of i)e.push({...n,_lineGroup:t});else for(const t of i)e.push(t)}}return void $n.current?.setBoundedData(e)}}$n.current?.setBoundedData(Xe)}},[o,Xe,y]);const{hoverHandlerRef:Fn,hoverLeaveRef:Nn,onPointerMove:On,onPointerLeave:jn}=Ce;Fn.current=t=>{if(!Ge)return;const e=Ve.current;if(!e)return;const i=e.getBoundingClientRect(),o=t.clientX-i.left-Ye.left,r=t.clientY-i.top-Ye.top;if(0>o||o>qe||0>r||r>He)return void(rn.current&&(rn.current=null,sn.current=null,ln(null),It&&(It(null),Pe.current=!0),We()));const s=Rn.current;if(!s||0===s.scene.length)return;const c=C(Rt,t.pointerType),l=ci(s.scene,o,r,c,s.quadtree,s.maxPointRadius),u="multi"===$t,d=()=>{rn.current&&(rn.current=null,sn.current=null,ln(null),It&&It(null),We())};if(!l&&!u)return void d();const h=u||!l?o:l.x,f=u||!l?r:l.y,p=l?.datum?be(l.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=R(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&s.scene.length>0&&s.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=li(ai(t.path,t.curve),e,n);if(null===r)continue;const s=bi(t.path,e);i.push({node:o,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"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=ai(t.topPath,t.curve),s=ai(t.bottomPath,t.curve),a=li(r,e,n);if(null===a)continue;const c=li(s,e,n),l=bi(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][0],y:a,y0:c??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 i}(s.scene,h,Math.max(c,qe));if(t.length>0){const e=s.scales.y.invert,i=un.current,o=y?y(h):h;if(l)m.xValue=o,m.xPx=h;else{const t={xValue:o};"string"==typeof a&&(t[a]=o),m=R(t,h,f,{xValue:o,xPx:h})}m.allSeries=t.map(t=>{const o=e?e(t.y):t.y,r=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===n&&null!=r?o-r:o,valuePx:t.y,color:t.color||i,datum:be(t.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(rn.current=m,sn.current=l?.node??null,ln(m),It&&(It(m),Pe.current=!0),We()):d()},Nn.current=()=>{rn.current&&(rn.current=null,sn.current=null,ln(null),It&&(It(null),Pe.current=!0),We())};const Yn=J(()=>{});Yn.current=t=>{if(!Ct)return;const e=Ve.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ye.left,o=t.clientY-n.top-Ye.top;if(0>i||i>qe||0>o||o>He)return void Ct(null);const r=Rn.current;if(!r||0===r.scene.length)return void Ct(null);const s=C(Rt,an.current),a=ci(r.scene,i,o,s,r.quadtree,r.maxPointRadius);if(!a)return void Ct(null);const c=a.datum||{},l=r.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Ct(R(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const qn=it(t=>Yn.current(t),[]),Xn=J(-1),Gn=J(null),Vn=J(null),Un=it(t=>{const e=Rn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Vn.current&&Vn.current.version===n)i=Vn.current.graph;else{const t=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const t=Bn(n.glyph,n.size);e.push({x:n.x+t.centerDx,y:n.y+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:"_default"});break}case"line":{const t=n,i=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.path.length>n&&i.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:i[n],shape:"circle",group:o});break}case"area":{const t=n,i=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.topPath.length>n&&i.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:i[n],shape:"circle",group:o});break}case"rect":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===t.length)return;i=function(t){const e=new Map;for(const n of t){const t=n.group??"_default";let i=e.get(t);i||(i=[],e.set(t,i)),i.push(n)}for(const t of e.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 n=Array.from(e.keys()).sort((t,n)=>{const i=e.get(t),o=e.get(n);return(i.length>0?i[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(e.values()).flat();i.sort((t,e)=>t.x-e.x||t.y-e.y);const o=new Map;for(let t=0;i.length>t;t++){i[t]._flatIndex=t;const e=i[t].datum?.id;null!=e&&o.set(e+"",t)}return{flat:i,groups:n,byGroup:e,idToIdx:o}}(t),Vn.current={version:n,graph:i}}const o=Xn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Xn.current=0;const n=i.flat[0];Gn.current={shape:n.shape,w:n.w,h:n.h};const o=wi({...n,datum:be(n.datum,e.resolvedRibbons)});return rn.current=o,ln(o),It&&It(o),void We()}const r=function(t,e){if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(e,t.flat.length-1)),i=t.flat[n];return{flatIndex:n,group:i.group??"_default",indexInGroup:i._groupIndex??0}}(i,o),s=function(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?vi(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?vi(n,n.groups[t-1],r[o]):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,i);if(null===s)return;if(t.preventDefault(),0>s)return Xn.current=-1,Gn.current=null,rn.current=null,sn.current=null,ln(null),It&&It(null),void We();Xn.current=s;const a=i.flat[s];Gn.current={shape:a.shape,w:a.w,h:a.h};const c=wi({...a,datum:be(a.datum,e.resolvedRibbons)});rn.current=c,ln(c),It&&It(c),We()},[It,We]),Kn=it(t=>{an.current=t.pointerType,Xn.current=-1,Gn.current=null,On(t)},[On]),Zn=it(t=>{an.current="mouse",Xn.current=-1,Gn.current=null,On({clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"})},[On]),Qn=it(t=>{an.current=t.pointerType},[]);Oe.current=()=>{Ne.current=null;const t=Ve.current,e=Ue.current;if(!t||!e)return;const i=Rn.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),r=i.advanceTransition(Le.current?o+1e6:o),s=!Le.current&&r,l=_e.current.w!==qe||_e.current.h!==He,u=Pe.current||r||l,d=i.consumeStylePaintPending();let h=!1;const f=i.getLastUpdateResult(),p=pn.current.beforeCompute(f,s);!u||s&&!l||(i.computeScene({width:qe,height:He}),_e.current={w:qe,h:He},h=!0,Ln()),pn.current.afterCompute(p,h,l);const y=function(t,e,n,i){const o=i.current,r=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,s=!r&&t.hasActivePulsesAt(e),a=!(n||r||!s&&!o)&&t.refreshPulse(e);return i.current=s,{changed:a,pending:s}}(i,o,h,Ie),g=aa(),m=dn.current.resolve(t);un.current=m.primary;const x=Pi(re,i.lastIngestTime>0?o-i.lastIngestTime:0),b=re&&x.isStale;if(u||d||y.changed){const e=sa(t,ze,Ye,g);if(e){if(e.clearRect(-Ye.left,-Ye.top,ze[0],ze[1]),re&&1>x.alpha&&(e.globalAlpha=x.alpha),function(t,e){const{background:n,hasBackgroundGraphics:i=!1,themeBackground:o="",x:r=0,y:s=0,width:a,height:c}=e;if("transparent"===n)return!1;if(i)return!1;const l=n||(o&&"transparent"!==o?o:"")||null;if(!l)return!1;const u=Hn(t,l);u&&(t.fillStyle=u,t.fillRect(r,s,a,c))}(e,{background:N,hasBackgroundGraphics:!!Gt,themeBackground:m.background,x:-Ye.left,y:-Ye.top,width:ze[0],height:ze[1]}),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,qe,He),e.clip()),Ut&&i.scales)for(const t of Ut)e.save(),t(e,i.scene,i.scales,{width:qe,height:He}),e.restore();const t=we?Na.custom:Na[n];if(t&&i.scales)for(const n of t)n(e,i.scene,i.scales,{width:qe,height:He});e.restore(),re&&1>x.alpha&&(e.globalAlpha=1)}}const v=!!(Ge&&rn.current&&i.scales),w=!!(sn.current&&Array.isArray(Pt)&&Pt.some(t=>t&&"object"==typeof t&&"highlight"===t.type)),k=v||w;if(k||fn.current){const t=sa(e,ze,Ye,g);if(t&&(t.clearRect(-Ye.left,-Ye.top,ze[0],ze[1]),v&&rn.current&&function(t,e,n,i,o,r,s){if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,l=e.xPx??e.x;t.save();const u="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=u.stroke||s.crosshair,t.lineWidth=u.strokeWidth||1,t.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?l:e.x,0),t.lineTo(c?l:e.x,i),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 a)null!=e.valuePx&&(t.beginPath(),t.arc(l,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.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,rn.current,qe,He,"object"==typeof Ge?Ge:{},sn.current,m),w&&sn.current&&Array.isArray(Pt))){const e=Pt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){if(!n)return;const r="group"in n?n.group:void 0;if(void 0!==r)for(const n of e){if("line"!==n.type)continue;if(n.group!==r)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.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||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=e.opacity??1,t.stroke(),t.restore()}}(t,i.scene,sn.current,e,m)}fn.current=k}u&&t&&t.setAttribute("aria-label",ks(i.scene,n+" chart"));const S=Pe.current;if(Pe.current=S&&s&&!h,S&&i.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!Je||t(Je.x.domain()[0])!==t(i.scales.x.domain()[0])||t(Je.x.domain()[1])!==t(i.scales.x.domain()[1])||t(Je.y.domain()[0])!==t(i.scales.y.domain()[0])||t(Je.y.domain()[1])!==t(i.scales.y.domain()[1])||Je.x.range()[0]!==i.scales.x.range()[0]||Je.x.range()[1]!==i.scales.x.range()[1]||Je.y.range()[0]!==i.scales.y.range()[0]||Je.y.range()[1]!==i.scales.y.range()[1])&&tn(i.scales),de){const t=i.getData(),e="function"==typeof a?a:t=>t[a||"x"],n="function"==typeof c?c:t=>t[c||"y"];Pn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),In(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((zt&&zt.length>0||we)&&(h||s))||!h&&33>o-Qe.current||(Ze(t=>t+1),Qe.current=o),re?.showBadge&&wn(!!b),(s||null!=i.activeTransition||y.pending)&&We()},os({hydrated:Te,wasHydratingFromSSR:Re,storeRef:Rn,dirtyRef:Pe,renderFnRef:Oe,cancelRender:je,cleanup:()=>$n.current?.clear()}),et(()=>{Pe.current=!0,We()},[n,qe,He,pt,N,Gt,O,Ut,We]),function(t,e,n,i,o,r){const s=Si("fresh");ki(()=>{if(!t)return;const a=setInterval(()=>{const a=e.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Pi(t,c-a.lastIngestTime);l.band===s.current&&l.isStale===o||(s.current=l.band,l.isStale!==o&&r(l.isStale),n.current=!0,i())},1e3);return()=>clearInterval(a)},[t,o,i])}(re,Rn,Pe,We,vn,wn);const Jn=nt(()=>{if(bt||At)return;const t=Rn.current;return t?.xIsDate&&Je?ha(Je.x.domain()):void 0},[bt,At,Je]),ti=bt||At||Jn,ei=Ge&&cn?_t?_t(cn):Xa(Ha,{hover:cn}):null,ni=ei?Xa(qs,{x:cn.x,y:cn.y,containerWidth:qe,containerHeight:He,margin:Ye,className:"stream-frame-tooltip",children:ei}):null,ii=Gn.current,oi=Xa(Ws,{active:Xn.current>=0,hoverPoint:cn,margin:Ye,size:ze,shape:ii?.shape,width:ii?.w,height:ii?.h}),ri=la(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),si=la(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),ui=ri.key,di=si.key,hi=function(t,e,n){return i=>{if(!i||!n||!t.fn&&!e.fn)return i;let o=!1;const r=i.map(n=>{const i=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!i&&!r)return n;o=!0;const s={...n};return i&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return o?r:i}}(ri,si,zt&&zt.length>0||!1);if(Xr||!Te&&Re){const t=Rn.current;t&&o&&(t.ingest({inserts:Xe,bounded:!0}),t.computeScene({width:qe,height:He}));const e=t?.scene??[],n=t?.scales??null,i=en(Vt,n),r=en(Gt,n),s=ti||(()=>{if(t?.xIsDate&&n)return ha(n.x.domain())})();return Ga("div",{ref:$e,className:"stream-xy-frame"+(F?" "+F:""),role:"img","aria-label":ge||("string"==typeof Zt?Zt:"XY chart"),style:{position:"relative",width:D?"100%":ze[0],height:E?"100%":ze[1]},children:[Xa(Es,{summary:me}),Ga("svg",{xmlns:"http://www.w3.org/2000/svg",width:ze[0],height:ze[1],style:{position:"absolute",left:0,top:0},children:[Xa("g",{transform:`translate(${Ye.left},${Ye.top})`,children:r}),Ga("g",{transform:`translate(${Ye.left},${Ye.top})`,children:[N&&Xa("rect",{x:0,y:0,width:qe,height:He,fill:N}),Kt&&n&&Kt.map((t,i)=>Xa(Q.Fragment,{children:t(e,n,{width:qe,height:He})},"svgpre-"+i)),e.map((t,e)=>qr(t,e,Me)).filter(Boolean)]})]}),Xa(Tr,{width:qe,height:He,totalWidth:ze[0],totalHeight:ze[1],margin:Ye,scales:n,showAxes:pt,axes:yt,xLabel:gt,yLabel:mt,yLabelRight:xt,xFormat:s,yFormat:vt||Mt,axisExtent:St,showGrid:Bt,title:Zt,legend:Ft,legendHoverBehavior:Nt,legendClickBehavior:Ot,legendHighlightedCategory:Wt,legendIsolatedCategories:jt,legendPosition:Yt,legendLayout:qt,foregroundGraphics:xn(i,Sn(Rn.current?.customLayoutOverlays,Ae??null)),marginalGraphics:de,xValues:[],yValues:[],annotations:zt,autoPlaceAnnotations:Dt,svgAnnotationRules:Et,annotationFrame:0,xAccessor:ui,yAccessor:di,annotationData:hi(t?.getData()),pointNodes:fa(t?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:xe,linkedCrosshairSourceId:ve})]})}return Ga("div",{ref:$e,className:"stream-xy-frame"+(F?" "+F:""),role:"group","aria-label":ge||("string"==typeof Zt?Zt:"XY chart"),tabIndex:0,style:{position:"relative",width:D?"100%":ze[0],height:E?"100%":ze[1],overflow:"visible",touchAction:Ka(Jt)},onKeyDown:Un,children:[ye&&Xa(Bs,{tableId:Fe}),ye&&Xa(Ds,{scene:Rn.current?.scene??[],chartType:n+" chart",tableId:Fe,chartTitle:"string"==typeof Zt?Zt:void 0}),Xa(Es,{summary:me}),Xa(Fs,{hoverPoint:cn}),Ga("div",{role:"img","aria-label":ge||("string"==typeof Zt?Zt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Ge?Kn:void 0,onMouseMove:Ge?Zn:void 0,onPointerLeave:Ge?jn:void 0,onMouseLeave:Ge?jn:void 0,onPointerDown:Ge||Ct?Qn:void 0,onClick:Ct?qn:void 0,children:[on&&Xa("svg",{style:{position:"absolute",left:0,top:0,width:ze[0],height:ze[1],pointerEvents:"none"},children:Xa("g",{transform:`translate(${Ye.left},${Ye.top})`,children:on})}),Xa(_r,{width:qe,height:He,totalWidth:ze[0],totalHeight:ze[1],margin:Ye,scales:Je,showAxes:pt,axes:yt,showGrid:Bt,xFormat:ti,yFormat:vt||Mt,axisExtent:St}),Xa("canvas",{ref:Ve,"aria-label":ks(Rn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),Xa("canvas",{ref:Ue,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Xa(Tr,{width:qe,height:He,totalWidth:ze[0],totalHeight:ze[1],margin:Ye,scales:Je,showAxes:pt,axes:yt,xLabel:gt,yLabel:mt,yLabelRight:xt,xFormat:ti,yFormat:vt||Mt,axisExtent:St,showGrid:Bt,title:Zt,legend:Ft,legendHoverBehavior:Nt,legendClickBehavior:Ot,legendHighlightedCategory:Wt,legendIsolatedCategories:jt,legendPosition:Yt,legendLayout:qt,foregroundGraphics:xn(nn,Sn(Rn.current?.customLayoutOverlays,Ae??null)),marginalGraphics:de,xValues:kn,yValues:_n,annotations:zt,autoPlaceAnnotations:Dt,svgAnnotationRules:Et,annotationFrame:Ke,xAccessor:ui,yAccessor:di,annotationData:hi(Rn.current?.getData()),pointNodes:fa(Rn.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==N&&!Gt,linkedCrosshairName:xe,linkedCrosshairSourceId:ve}),(Jt||te)&&Xa(wt,{width:qe,height:He,totalWidth:ze[0],totalHeight:ze[1],margin:Ye,dimension:Jt?.dimension??"xy",scales:Je,onBrush:te??(()=>{}),binSize:v,snap:Jt?.snap,binBoundaries:Jt?.binBoundaries??("bar"===n?Rn.current?.getBinBoundaries():void 0),snapDuring:Jt?.snapDuring,streaming:"streaming"===i}),re?.showBadge&&Xa(Ii,{isStale:vn,position:re.badgePosition}),oi,ni]})]})}));Za.displayName="StreamXYFrame";var Qa=Za;import{useMemo as Ja,useCallback as tc,useState as ec,useId as nc,useEffect as ic,useRef as oc}from"react";import{createContext as rc,useContext as sc,useMemo as ac}from"react";import{jsx as cc}from"react/jsx-runtime";var lc=rc(null);function uc(){return sc(lc)}import{createContext as dc,useContext as hc,useEffect as fc,useId as pc,useLayoutEffect as yc,useMemo as gc,useRef as mc,useState as xc,useCallback as bc}from"react";function vc(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function wc(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function kc(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}var[Sc,Ac]=Tt(t=>({selections:new Map,setClause(e,n){t(t=>{const i=t.selections.get(e),o=i?.clauses.get(n.clientId);if(o&&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,i]of n){const n=e.fields[t];if(!n||!kc(i,n))return!1}return!0}(o,n))return{};const r=new Map(t.selections),s=wc(r,e),a=new Map(s.clauses);return a.set(n.clientId,n),r.set(e,{...s,clauses:a}),{selections:r}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i||!i.clauses.has(n))return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,{...i,clauses:r}),{selections:o}})},setResolution(e,n){t(t=>{const i=t.selections.get(e);if(i?.resolution===n)return{};const o=new Map(t.selections),r=wc(o,e);return o.set(e,{...r,resolution:n}),{selections:o}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const i=new Map(t.selections);return i.set(e,{...n,clauses:new Map}),{selections:i}})}})),[Mc,Pc]=Tt(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}))}}));import{useId as _c,useMemo as Ic,useCallback as Cc}from"react";function Tc(t){const e=_c(),n=t.clientId||e,{name:i}=t,o=Ac(t=>t.selections.get(i)),r=Ac(t=>t.setClause),s=Ac(t=>t.clearClause),a=Ic(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Ic(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(vc(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:Cc(t=>{const e={};let o=!1;for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)},o=!0;o&&r(i,{clientId:n,type:"point",fields:e})},[n,i,r]),selectInterval:Cc(t=>{const e={};let o=!1;for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i},o=!0;o&&r(i,{clientId:n,type:"interval",fields:e})},[n,i,r]),clear:Cc(()=>{s(i,n)},[s,i,n]),clientId:n}}import{jsx as Rc,jsxs as Lc}from"react/jsx-runtime";var $c=dc(!1);dc(!1);var zc=dc(null),Dc="undefined"==typeof window?fc:yc;import*as Ec from"react";var Bc={light:Dt,dark:Et,"high-contrast":Bt,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"}};import{jsx as Fc,jsxs as Nc}from"react/jsx-runtime";function Oc(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function Wc(t,e,n){const i=t.xValue??e?.[n];if(null==i)return null;const o=Number(i);return Number.isFinite(o)?o:null}function jc(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?{...e,xValue:t.xValue}:e||{}}function Yc(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}Ec.createContext(void 0);var qc={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Hc(t,e={}){const n=e.mobileSemantics?.interaction,i="number"==typeof n?.targetSize?n.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,o="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,r=!!n||void 0!==i,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!o&&!r)return qc;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??i??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Xc(){const t=Ot(t=>t.theme),e=t?.colors?.categorical;return e&&e.length>0?e:void 0}function Gc({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:r,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=nc(),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}(e,n),f="series"===h?.mode?[h.seriesField||l||n[0]].filter(t=>!!t):h?.fields||n||[],p=Tc({name:t?.name||"__unused__",fields:f}),y=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:s}=Tc({name:e,fields:n});return{onHover:Cc(t=>{if(!t)return void s();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(e)&&r(e)},[n,r,s,e]),predicate:i,isActive:o}}({name:h?.name||"hover",fields:f}),g=Pc(t=>t.pushObservation),m=t?{isActive:p.isActive,predicate:p.predicate}:null,[x,b]=ec(null),v=oc(!1),w=l||n[0],k=Ja(()=>{if(!c||null==x||!w)return null;const t=x,e=w;return{isActive:!0,predicate:n=>("string"==typeof n[e]?n[e]:(n[e]??"")+"")===t}},[c,x,w]),S=tc(t=>{const n=!t&&v.current&&!!u?.enabled&&u.tapToLockTooltip;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===h?.mode&&h.xField){const n=Wc(t,e,h.xField);null!=n&&function(t,e,n){const i=cr.positions.get(t);i?.locked||i&&i.xValue===e&&i.sourceId===n||(cr={positions:new Map(cr.positions).set(t,{xValue:e,sourceId:n})},ur())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(e)}else"x-position"!==h?.mode||n||dr(h.name||"hover",d),"x-position"===h?.mode||n||y.onHover(null);if(c&&w)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=e?.[w];b(null!=n?n+"":null)}else n||b(null);if(o||g){const e={timestamp:Date.now(),chartType:r||"unknown",chartId:s};if(t){const n=jc(t),i={...e,type:"hover",datum:n||{},x:t.x??0,y:t.y??0};o&&o(i),g&&g(i)}else{const t={...e,type:"hover-end"};o&&o(t),g&&g(t)}}},[e,y,h,d,o,r,s,g,c,w,u]),A=tc((n=!0)=>{v.current=!1,e&&"x-position"!==h?.mode&&y.onHover(null),t&&u?.tapToSelect&&p.clear(),n&&c&&b(null),"x-position"===h?.mode&&(hr(h.name||"hover",d),dr(h.name||"hover",d))},[e,h,y,t,u,p,c,d]),M=tc(n=>{const i=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),l=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]);const e=Wc(n,t,h.xField);null!=e&&function(t,e,n){const i=cr.positions.get(t);if(i?.locked){const e=new Map(cr.positions);return e.delete(t),cr={positions:e},ur(),!1}cr={positions:new Map(cr.positions).set(t,{xValue:e,sourceId:n,locked:!0})},ur()}(h.name||"hover",e,d)}if(i)if(n){v.current=!0;const i=jc(n);if(e&&"x-position"!==h?.mode&&y.onHover(i),t&&u?.tapToSelect&&f.length>0){const t={};for(const e of f){const n=i[e];void 0!==n&&(t[e]=[n])}Yc(t)&&p.selectPoints(t)}if(c&&w){const t=i?.[w];b(null!=t?t+"":null)}}else l&&A();if(n||l){if(n&&a){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]),a(t,{x:n.x??0,y:n.y??0})}if(o||g){const t={timestamp:Date.now(),chartType:r||"unknown",chartId:s};if(n){const e=jc(n),i={...t,type:"click",datum:e||{},x:n.x??0,y:n.y??0};o&&o(i),g&&g(i)}else{const e={...t,type:"click-end"};o&&o(e),g&&g(e)}}}},[a,o,g,r,s,h,d,u,e,y,t,p,f,c,w,A]);return ic(()=>{if(!u?.enabled||"undefined"==typeof document)return;const t=t=>{"Escape"===t.key&&v.current&&A()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u?.enabled,A]),ic(()=>()=>{v.current&&A(!1)},[A]),ic(()=>{if("x-position"!==h?.mode)return;const t=h.name||"hover";return()=>{hr(t,d),dr(t,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:d}}function Vc({data:t,colorBy:e,colorScale:n,showLegend:i,legendPosition:o="right",userMargin:r,defaults:s={top:50,bottom:60,left:70,right:40},categories:a}){const c=hc($c),l=null!==hc(zc),u=void 0!==i?i:!c&&!!e,d=!!e&&(u||l),h=Ja(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const i of t){const t="function"==typeof e?e(i):i[e];null!=t&&n.add(t+"")}return Array.from(n)},[a,e,t,d]);!function(t){const e=hc(zc),n=pc(),i=function(t){const e=new Set,n=[];for(const i of t)e.has(i)||(e.add(i),n.push(i));return n}(t),o=mc([]);(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})(o.current,i)||(o.current=i);const r=o.current;Dc(()=>{if(e)return()=>e.unregisterCategories(n)},[e,n]),Dc(()=>{e&&e.registerCategories(n,r)},[e,n,r])}(l&&e?h:[]);const f=Ja(()=>{if(!u||!e)return;const i=function({data:t,colorBy:e,colorScale:n,getColor:i,strokeColor:o,strokeWidth:r,categories:s}){return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==o&&(n.stroke=o),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((o,r)=>{const s=t.find("function"==typeof e?t=>e(t)===o:t=>t[e]===o),a=s?i(s,e,n):n?n(o):k[r%k.length];return{label:o+"",color:a}}),label:""}]}}({data:t,colorBy:e,colorScale:n,getColor:A,categories:h});return 0!==i.legendGroups.reduce((t,e)=>t+e.items.length,0)?i:void 0},[u,e,t,n,h]),p=Ja(()=>{const t="number"==typeof r?{top:r,bottom:r,left:r,right:r}:r??{},e=e=>{const n=t[e];return"number"==typeof n?n:s[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},i=e=>"number"==typeof t[e];return f&&("right"===o&&!i("right")&&110>n.right?n.right=110:"left"===o&&!i("left")&&110>n.left?n.left=110:"top"===o&&!i("top")&&50>n.top?n.top=50:"bottom"===o&&!i("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,r,f,o]);return{legend:f,margin:p,legendPosition:o}}var Uc={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Kc(t,e,n){const i=Uc[t||"primary"],o=t&&"primary"!==t||!n?.width?i.width:n.width,r=t&&"primary"!==t||!n?.height?i.height:n.height,s=function(t,e,n=t.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:t,matches:[]};const i=n.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:n}=t,i=e.width,o=e.height,r=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),s=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof n.minWidth&&n.minWidth>i||"number"==typeof n.maxWidth&&i>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof r||n.minAspectRatio>r)||"number"==typeof n.maxAspectRatio&&("number"!=typeof r||r>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(t.rule,e)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:i.reduce((t,e)=>function(t,e){const n={...t,...e};for(const i of["margin","frameProps","mobileSemantics","style"])Oc(t[i])&&Oc(e[i])&&(n[i]={...t[i],...e[i]});return"string"==typeof t.className&&"string"==typeof e.className&&(n.className=`${t.className} ${e.className}`),n}(t,e.rule.transform),t),matches:i}}({...e,mode:t},{width:e.width??o,height:e.height??r}).props,a=s.mode||t,c=Uc[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:Zc(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:Hc(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function Zc(t,e,n){if(!1!==e)return t;const i={...t};return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}import*as Qc from"react";import{jsx as Jc,jsxs as tl}from"react/jsx-runtime";function el({componentName:t,message:e,diagnosticHint:n,width:i,height:o}){return Jc("div",{role:"alert",style:{width:i,height:Math.max(o,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:tl("div",{style:{textAlign:"center",maxWidth:400},children:[Jc("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),Jc("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:e}),n&&Jc("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:n})]})})}import{jsx as nl}from"react/jsx-runtime";var il=class extends Qc.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){this.props.onError?.(t,e)}render(){if(this.state.error){const{fallback:t}=this.props,e=this.state.error;return"function"==typeof t?t(e):void 0!==t?t:nl(el,{componentName:"ChartErrorBoundary",message:e.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as ol}from"react/jsx-runtime";function rl({componentName:t,width:e,height:n,children:i}){return ol(il,{fallback:i=>ol(el,{componentName:t,message:i.message,width:e,height:n}),children:i})}"undefined"!=typeof process&&process;var sl={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"},al={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function cl(t,e,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?ol("div",{style:{...sl,width:e,height:n},children:i||"No data available"}):null}function ll(t,e,n,i){if(!t)return null;if(!1===i)return null;if(null!=i)return ol("div",{style:{width:e,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(r+s)-s))/2);return ol("div",{style:{width:e,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(t,n)=>ol("div",{className:"semiotic-loading-bar",style:{...al,position:"absolute",top:a+n*(r+s),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2}},n))})}import{useCallback as ul,useMemo as dl,useState as hl}from"react";import{useMemo as fl}from"react";import{jsx as pl,jsxs as yl}from"react/jsx-runtime";function gl(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 ml(t,e,n,i){if(!t.length)return[];const o=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,c=null,l=[];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;o.length>t;t++){const r=o[t],p=e(r),y=n(r),g=i(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 n=y-c.a-(g-c.b);if(0!==n){const i=Math.max(0,Math.min(1,(c.b-c.a)/n));t=c.x+i*(p-c.x),e=c.a+i*(y-c.a)}else t=c.x,e=c.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;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(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=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(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}var xl=G(function(t,e){const n=V(null),i=Kc(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{data:o,margin:r,className:s,xFormat:a,yFormat:c,xAccessor:l="x",seriesAAccessor:u="a",seriesBAccessor:d="b",seriesALabel:h="A",seriesBLabel:f="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:y="var(--semiotic-info, #2563eb)",showLines:g=!0,lineWidth:m=1.5,showPoints:x=!1,pointRadius:b=3,curve:v="linear",areaOpacity:w=.6,gradientFill:S,tooltip:A,annotations:M,xExtent:_,yExtent:C,frameProps:T={},selection:R,linkedHover:L,onObservation:$,onClick:z,hoverHighlight:D,chartId:E,loading:B,loadingContent:F,emptyContent:O,legendInteraction:W,legendPosition:j,pointIdAccessor:G,windowSize:Q}=t,{width:J,height:tt,enableHover:et,showGrid:nt,showLegend:it,title:ot,description:rt,summary:st,accessibleTable:at,xLabel:ct,yLabel:lt}=i,ut=X(()=>"function"==typeof l?t=>gl(l(t)):t=>gl(t[l]),[l]),dt=X(()=>"function"==typeof u?t=>gl(u(t)):t=>gl(t[u]),[u]),ht=X(()=>"function"==typeof d?t=>gl(d(t)):t=>gl(t[d]),[d]),[ft,pt]=U([]),yt=V([]),gt=null==o,mt=X(()=>I(gt?ft:o),[gt,ft,o]),xt=X(()=>ml(mt,ut,dt,ht),[mt,ut,dt,ht]),bt=X(()=>g?function(t,e,n,i){if(!t.length)return[];const o=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of o){const o=e(t),s=n(t),a=i(t);Number.isFinite(s)&&r.push({__x:o,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:o,__y:a,__diffSegment:"line-B"})}return r}(mt,ut,dt,ht):[],[g,mt,ut,dt,ht]),vt=X(()=>[...xt,...bt],[xt,bt]),wt=X(()=>{const t=new Set;for(const e of xt)t.add(e.__diffSegment);return Array.from(t)},[xt]);K(e,()=>{const t=t=>{const e=Q&&t.length>Q?t.slice(t.length-Q):t;yt.current=e,pt(e)},e=G?"function"==typeof G?G:t=>t[G]:null;return{push:e=>t([...yt.current,e]),pushMany:e=>t([...yt.current,...e]),remove:n=>{if(!e)return[];const i=Array.isArray(n)?n:[n],o=[],r=[];for(const t of yt.current)i.includes(e(t))?o.push(t):r.push(t);return t(r),o},update:(n,i)=>{if(!e)return[];const o=Array.isArray(n)?n:[n],r=[],s=yt.current.map(t=>{if(o.includes(e(t))){const e=i(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>gt?yt.current:mt,getScales:()=>n.current?.getScales()??null}},[gt,mt,G,Q]);const kt=function(t){const{data:e,rawData:n,colorBy:i,colorScheme:o,legendInteraction:r,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,userMargin:y,marginDefaults:g,onClick:m,hoverHighlight:x,mobileInteraction:b,mobileSemantics:v,loading:w,loadingContent:S,emptyContent:A,width:M,height:_}=t,C=void 0===n,T=dl(()=>I(e),[e]),[R,L]=hl([]),$=ul(t=>{L(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),z="string"==typeof t.colorBy?t.colorBy:void 0,D=dl(()=>Hc(b,{width:M,mobileSemantics:v}),[b,M,v]),{activeSelectionHook:E,hoverSelectionHook:B,customHoverBehavior:F,customClickBehavior:N,crosshairSourceId:O}=Gc({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:m,hoverHighlight:x,colorByField:z,mobileInteraction:D}),W=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(c,O),j=function(t,e,n){const i=uc(),o=Xc();return Ja(()=>{if(!e)return;const r=i??void 0,s=n??(o&&o.length>0?o:void 0)??"category10";if(0!==t.length){if("function"==typeof e){const n=Array.from(new Set(t.map(t=>e(t)+"")));if(r&&Yc(r)){const t=P(n.map(t=>({_cat:t})),"_cat",s);return e=>r[e]||t(e)}return P(n.map(t=>({_cat:t})),"_cat",s)}if(r&&Yc(r)){const n=P(t,e,s);return t=>r[t]||n(t)}return P(t,e,s)}if(r&&Yc(r)){const t=P([{_:"a"}],"_",s);return e=>r[e]||t(e)}},[t,e,n,i,o])}(T,i,o),Y=dl(()=>{if(!i)return[];const t=new Set;for(const e of T){const n="function"==typeof i?i(e):e[i];null!=n&&t.add(n+"")}return Array.from(t)},[T,i]),q=dl(()=>C&&R.length>0?R:Y,[C,R,Y]),H=function(t,e,n){const[i,o]=ec(null),[r,s]=ec(new Set),a=Ja(()=>new Set,[]),c=tc(e=>{"highlight"===t&&o(e?e.label:null)},[t]),l=tc(e=>{"isolate"===t&&s(t=>{const i=new Set(t);return i.has(e.label)?i.delete(e.label):i.add(e.label),i.size===n.length?new Set:i})},[t,n.length]),u=Ja(()=>{if(!t||"none"===t||!e)return null;const n="string"==typeof e?e:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(n?t[n]:"function"==typeof e?e(t):null)===i}:"isolate"===t&&r.size>0?{isActive:!0,predicate:t=>{const i=n?t[n]:"function"==typeof e?e(t):null;return r.has(i)}}:null},[t,e,i,r]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?r:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}(r,i,q),X=dl(()=>B||(H.legendSelectionHook?H.legendSelectionHook:E),[B,H.legendSelectionHook,E]),G=function(t){const e=Ot(t=>t.theme.colors.selectionOpacity);return fl(()=>{if(void 0!==t||void 0!==e)return{name:t?.name??"",...t,unselectedOpacity:t?.unselectedOpacity??e}},[t,e])}(a),V=Xc(),U=uc(),K=dl(()=>{if(j)return j;if(!i||0===q.length)return;const t=Array.isArray(o)&&o.length>0||"string"==typeof o&&o.length>0?o:V&&V.length>0?V:k,e="__streamCat",n=P(q.map(t=>({[e]:t})),e,t);return t=>U?.[t]||n(t)||"#999"},[j,i,q,o,V,U]),{legend:Z,margin:Q,legendPosition:J}=Vc({data:T,colorBy:i,colorScale:K,showLegend:p,legendPosition:s,userMargin:y,defaults:g,categories:q}),tt=dl(()=>{const t={};return Z&&(t.legend=Z,t.legendPosition=J),r&&"none"!==r&&(t.legendHoverBehavior=H.onLegendHover,t.legendClickBehavior=H.onLegendClick,t.legendHighlightedCategory=H.highlightedCategory,t.legendIsolatedCategories=H.isolatedCategories),C&&i&&(t.legendCategoryAccessor=i,t.onCategoriesChange=$),t},[Z,J,r,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,C,i,$]),et=Array.isArray(n)?I(n):n,nt=ll(w,M,_,S),it=nt?null:cl(et,M,_,A);return{data:T,colorScale:j,allCategories:q,legendState:H,effectiveSelectionHook:X,activeSelectionHook:E,customHoverBehavior:F,customClickBehavior:N,mobileInteraction:D,legend:Z,margin:Q,legendPosition:J,earlyReturn:nt||it||null,legendBehaviorProps:tt,crosshairProps:W,resolvedSelection:G}}({data:mt,rawData:o,colorBy:"__diffWinner",colorScheme:[p,y],legendInteraction:W,legendPosition:j,selection:R,linkedHover:L,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:$,onClick:z,hoverHighlight:D,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"DifferenceChart",chartId:E,showLegend:it,userMargin:r,marginDefaults:i.marginDefaults,loading:B,loadingContent:F,emptyContent:O,width:J,height:tt}),St=X(()=>{if(!1!==it)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:h,color:p},{label:f,color:y}]}]}},[it,h,f,p,y]),At=Z(t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?p:y,stroke:"none",fillOpacity:w}},[p,y,w]),Mt=Z(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?p:y,strokeWidth:m,fill:"none"}),[p,y,m]),Pt=Z(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?p:y,r:b}),[p,y,b]),_t=Z(t=>{const e=t.data,n=t.allSeries,i=t.xValue??e?.__x;let o=e?.__valA,r=e?.__valB;if(n&&n.length>0){const t=n.find(t=>"line-A"===t.group),e=n.find(t=>"line-B"===t.group);null!=t?.value&&Number.isFinite(t.value)&&(o=t.value),null!=e?.value&&Number.isFinite(e.value)&&(r=e.value)}if(null!=i&&(null==o||null==r)){const t=mt.find(t=>ut(t)===i);t&&(null==o&&(o=dt(t)),null==r&&(r=ht(t)))}const s=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",c=a&&null!=i?a(i):null!=i?i+"":"";return yl("div",{className:"semiotic-tooltip",style:N,children:[c&&pl("div",{style:{fontWeight:600,marginBottom:4},children:c}),yl("div",{style:{display:"flex",alignItems:"center",gap:6},children:[pl("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),yl("span",{children:[h,": ",s(o)]})]}),yl("div",{style:{display:"flex",alignItems:"center",gap:6},children:[pl("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),yl("span",{children:[f,": ",s(r)]})]}),null!=o&&null!=r&&Number.isFinite(o)&&Number.isFinite(r)&&yl("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(o-r)]})]})},[mt,ut,dt,ht,a,p,y,h,f]),It="multi"===A,Ct=X(()=>!1===A?()=>null:It?_t:Y(A)||_t,[A,It,_t]);if(kt.earlyReturn)return kt.earlyReturn;const Tt={chartType:"mixed",data:vt,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:wt,curve:v,areaStyle:At,lineStyle:Mt,...x&&{pointStyle:Pt},size:[J,tt],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:kt.margin,showAxes:i.showAxes,xLabel:ct,yLabel:lt,xFormat:a,yFormat:c,enableHover:et,showGrid:nt,...S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S},...St&&{legend:St,legendPosition:kt.legendPosition},...q({title:ot,description:rt,summary:st,accessibleTable:at,className:s,animate:t.animate,axisExtent:t.axisExtent,autoPlaceAnnotations:t.autoPlaceAnnotations}),tooltipContent:Ct,...It&&{tooltipMode:"multi"},...H({linkedHover:L,selection:R,onObservation:$,onClick:z,hoverHighlight:D,mobileInteraction:kt.mobileInteraction,customHoverBehavior:kt.customHoverBehavior,customClickBehavior:kt.customClickBehavior}),...M&&M.length>0&&{annotations:M},..._&&{xExtent:_},...C&&{yExtent:C},...kt.crosshairProps,...T};return pl(rl,{componentName:"DifferenceChart",width:J,height:tt,children:pl(Qa,{ref:n,...Tt})})});function bl(t,e,n){return"function"==typeof t?t(n):n[t||e]}function vl(t){return t instanceof Date?t.getTime():Number(t)}function wl(t,e){return f(1===e?.5:t/(e-1))}"function"==typeof xl&&(xl.displayName="DifferenceChart");var kl={frameType:"xy",buildProps:(t,e,n,i,o)=>{const r=o.xAccessor||"x",s=o.seriesAAccessor||"a",a=o.seriesBAccessor||"b",c=t=>vl(bl(r,"x",t)),l=t=>vl(bl(s,"a",t)),u=t=>vl(bl(a,"b",t)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",f=o.areaOpacity??.6,p=o.lineWidth??1.5,y=!1!==o.showLines,g=ml(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),n=l(t),i=u(t);Number.isFinite(n)&&m.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(i)&&m.push({__x:e,__y:i,__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")?d:h,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:o.curve||"linear",...i}}},Sl={frameType:"xy",buildProps:(t,e,n,i,o)=>{const r=e||o.areaBy,s="string"==typeof r&&Array.isArray(t)?P(t,r,n):void 0;return{chartType:"stackedarea",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:r,colorScheme:n,normalize:o.normalize,stackOrder:o.stackOrder,lineStyle:null==o.areaOpacity?void 0:t=>{const e=null==r?void 0:A(t,r,s),n=o.showLine??!0;return{fill:o.color??e,stroke:n?o.stroke??e:"none",...n?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:o.areaOpacity,...null==o.opacity?{}:{opacity:o.opacity}}},...i}}},Al={frameType:"xy",buildProps:(t,n,i,o,r)=>{const s=r.xCenter,a=r.yCenter,c=r.quadrants,l=r.centerlineStyle||{},u=!1!==r.showQuadrantLabels,d=r.quadrantLabelSize??12,h=l.stroke||"#999",f=l.strokeWidth??1,p=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,y=e.createElement,g=c?[(t,n,i)=>{if(!n?.x||!n?.y)return null;const o=i.width,r=i.height,l=null!=s?n.x(s):o/2,g=null!=a?n.y(a):r/2;if(null!=s&&!Number.isFinite(l))return null;if(null!=a&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(o,l)),x=Math.max(0,Math.min(r,g)),b=[{c:c.topLeft,x:0,y:0,w:m,h:x},{c:c.topRight,x:m,y:0,w:o-m,h:x},{c:c.bottomLeft,x:0,y:x,w:m,h:r-x},{c:c.bottomRight,x:m,y:x,w:o-m,h:r-x}],v=u?[y("text",{key:"ltl",x:8,y:8+d,fill:c.topLeft.color,fontWeight:600,fontSize:d,opacity:.5},c.topLeft.label),y("text",{key:"ltr",x:o-8,y:8+d,fill:c.topRight.color,fontWeight:600,fontSize:d,opacity:.5,textAnchor:"end"},c.topRight.label),y("text",{key:"lbl",x:8,y:r-8,fill:c.bottomLeft.color,fontWeight:600,fontSize:d,opacity:.5},c.bottomLeft.label),y("text",{key:"lbr",x:o-8,y:r-8,fill:c.bottomRight.color,fontWeight:600,fontSize:d,opacity:.5,textAnchor:"end"},c.bottomRight.label)]:[];return y(e.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:r,stroke:h,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:o,y2:x,stroke:h,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:n,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:i,pointStyle:r.pointStyle,...o,...g&&{svgPreRenderers:g}}}},Ml={frameType:"xy",buildProps:(t,e,n,i,o)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",i=e.yAccessor||"y",o=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:vl(bl(e.orderAccessor,"order",t))-vl(bl(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of o){if(null==t||"object"!=typeof t)continue;const e=vl(bl(n,"x",t)),o=vl(bl(i,"y",t));Number.isFinite(e)&&Number.isFinite(o)&&s++}let a=0;for(const t of o){if(null==t||"object"!=typeof t)continue;const e=vl(bl(n,"x",t)),o=vl(bl(i,"y",t));Number.isFinite(e)&&Number.isFinite(o)&&r.set(t,{idx:a++,total:s})}return{data:o,orderMap:r}}(t,o),s=o.pointRadius??4;return{chartType:"line",data:r.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:o.lineStyle||{stroke:o.stroke||"#6366f1",strokeWidth:o.strokeWidth??s,opacity:o.opacity},pointStyle:t=>{const e=r.orderMap.get(t),n=e?.idx??0,i=e?.total??1;return{fill:i>0?wl(n,i):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...i}}};function Pl(t){return Math.max(0,Math.min(1,t))}function _l(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 Il(t,e,n){const i=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Cl(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Pl(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 i=Pl(e);if(n[0].offset>=i)return n[0].color;if(i>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],o=n[t+1];if(e.offset>i||i>o.offset)continue;const r=o.offset-e.offset,s=r>0?(i-e.offset)/r:0,a=_l(e.color),c=_l(o.color);if(!a||!c)return.5>s?e.color:o.color;const[l,u,d]=a,[h,f,p]=c;return Il(l+(h-l)*s,u+(f-u)*s,d+(p-d)*s)}return n[n.length-1].color}function Tl(t,e,n){return null==n?`${t}-${e}`:`${t}-${e}-${n}`}var Rl={frameType:"ordinal",buildProps:(t,e,n,i,o)=>{const r=o.min??0,s=o.max??100,a=o.sweep??240,c=o.arcWidth??.3,l=180+(360-a)/2,u=o.thresholds||[{value:s,color:o.color||"#4e79a7"}],d=i.gradientFill,h=function(t){const{min:e,max:n,value:i,thresholds:o,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,d=n-e||1,h=(Math.max(e,Math.min(n,i))-e)/d;let f=o&&o.length>0?[...o].sort((t,e)=>t.value-e.value):[{value:n,color:r||"#007bff"}];f=f.map(t=>({...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 p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?h:1,e=Tl("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)),n=Math.max(1,Math.min(e,Math.round(t*e))),i=[];for(let e=0;n>e;e++)i.push(Cl(l.colorStops,t*(e+.5)/n));const o=Tl("fill",0);y.push({category:o,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),g.set(o,{fill:i[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const i=f[n],o=(i.value-t)/d,r=(t-e)/d,c=(i.value-e)/d,l=Math.max(0,(a?Math.min(h,c):c)-r),u=a?Math.max(0,o-l):0;if(l>0){const t=Tl("fill",n);y.push({category:t,value:l,_zone:i.label||"Zone "+(n+1),_isFill:!0}),g.set(t,{fill:i.color})}if(u>0){const t=Tl("bg",n);y.push({category:t,value:u,_zone:i.label||"Zone "+(n+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=i.value}}if(c&&o&&o.length>0)for(const t of o)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)=>g.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:r,max:s,value:o.value,thresholds:u,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:!1!==o.fillZones,showScaleLabels:!1!==o.showScaleLabels,gradientFill:d&&"object"==typeof d&&"colorStops"in d?d:void 0}),f=i.margin||{top:20,right:20,bottom:30,left:40},[p,y]=i.size||[300,300];return{chartType:"donut",data:h.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:h.pieceStyle,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...i,showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...h.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:o.value,startAngleDeg:l,thresholds:u}}}};import{scaleTime as Ll}from"d3-scale";function $l(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 zl(t,e,n){const i=e.incoming[t.id],o=e.outgoing[t.id],r=[];for(const t of i)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of o)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)=>t.time-e.time||(s[t.kind]??99)-(s[e.kind]??99))},c=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,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,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 p=[];let y=0,g=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?y:g);if(n>0){const e="top"===t.side?"bot":"top",i=Math.min(n,"top"===e?y:g);if(i>0){const o=f(t.time);p.push({time:o,delta:-i,kind:"transfer-out",side:e}),p.push({time:o,delta:+i,kind:"transfer-in",side:t.side}),"top"===e?y-=i:g-=i,"top"===t.side?y+=i:g+=i,n-=i}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?y+=n:g+=n)}"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 P=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let _=null;for(const t of o)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===_||_>t.systemInTime)&&(_=t.systemInTime);let I=null;for(const t of i)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===I||t.systemOutTime>I)&&(I=t.systemOutTime);if(A.length>0){const t=A[A.length-1],e=Math.max(null!=P?P:-1/0,null!=I?I:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&A.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=A[0],i=Math.min(null!=l?l:1/0,null!=_?_:1/0);Number.isFinite(i)&&n.t>i&&n.topMass+n.botMass>0&&A.unshift({t:i,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function Dl(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function El(t,e){return t.map(t=>({t:Dl(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Bl(t,e,n){const i=t.value*n;if("out"===t.kind){const o=t.sideMassBefore*n;if("top"===t.side){const t=e-o;return[t,t+i]}const r=e+o;return[r-i,r]}const o=t.sideMassAfter*n;if("top"===t.side){const t=e-o;return[t,t+i]}const r=e+o;return[r-i,r]}function Fl(t,e){let n=0;for(let i=0;e.length>i;i++)for(let o=i+1;e.length>o;o++){const r=e[i],s=e[o];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 Nl(t,e){let n=0;for(const i of e)n+=Math.abs(t[i.source]-t[i.target])*(i.value||1);return n}function Ol(t,e){return 1e3*Fl(t,e)+Nl(t,e)}function Wl(t,e){return{slots:t.map(t=>({peak:{...t.peak},occupants:t.occupants.slice()})),map:{...e}}}function jl(t,e,n){t.length>8||n.length>40?(function(t,e,n,i=6){const o=t.length;if(1>=o)return;let r=Wl(t,e),s=Ol(e,n);for(let a=0;i>a;a++){const i=Array(o).fill(0),a=Array(o).fill(0);for(const t of n){const n=e[t.source],o=e[t.target];i[n]+=o*(t.value||1),a[n]+=t.value||1,i[o]+=n*(t.value||1),a[o]+=t.value||1}const c=Array.from({length:o},(t,e)=>e).sort((t,e)=>(a[t]>0?i[t]/a[t]:t)-(a[e]>0?i[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 d=Ol(e,n);if(s>d)s=d,r=Wl(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,i=6){const o=t.length;if(1>=o)return;let r=Ol(e,n);for(let s=0;i>s;s++){let i=!1;for(let s=0;o-1>s;s++){const o=t[s];t[s]=t[s+1],t[s+1]=o;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Ol(e,n);if(r>a)r=a,i=!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(!i)break}}(t,e,n,6)):function(t,e,n){const i=t.length;if(1>=i)return;const o={...e},r=Object.keys(o),s=Array.from({length:i},(t,e)=>e),a=s.slice(),c={...o};let l=s.slice(),u=1/0;const d=()=>{for(const t of r)c[t]=a[o[t]];const t=Ol(c,n);u>t&&(u=t,l=s.slice())},h=(t,e)=>{const n=s[t],i=s[e];s[t]=i,s[e]=n,a[n]=e,a[i]=t};d();const f=Array(i).fill(0);let p=0;for(;i>p;)p>f[p]?(h(p%2==0?0:f[p],p),d(),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,n)}function Yl(t,e,n,i,o){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=o,d={},h={};for(const e of t)d[e.id]=n[e.id].topPeak||0,h[e.id]=n[e.id].botPeak||0;const f="half"===u,p={};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 o=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of i.outgoing[e.id]){o>t.startTime&&(o=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&o>t.systemInTime&&(o=t.systemInTime);const e=f?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of i.incoming[e.id]){const e=f?(t.startTime+t.endTime)/2:t.startTime;o>e&&(o=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(o)?o:null,end:Number.isFinite(r)?r:null}}const y={},g=[];if("reuse"===c){const n=new Map;for(const e of t)n.set(e.id,0);const o=new Map;for(const e of t)o.set(e.id,0);for(const t of e)o.set(t.target,(o.get(t.target)??0)+1);const r=[];for(const e of t)0===(o.get(e.id)??0)&&r.push(e.id);for(;r.length;){const t=r.shift();for(const e of i.outgoing[t]??[]){const i=(n.get(t)??0)+1;i>(n.get(e.target)??0)&&n.set(e.target,i),o.set(e.target,o.get(e.target)-1),0===o.get(e.target)&&r.push(e.target)}}const s=[...t].filter(t=>null!==p[t.id].start).sort((t,e)=>{const i=n.get(t.id)??0,o=n.get(e.id)??0;return i!==o?i-o: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 n=-1;for(let t=0;g.length>t;t++){const i=g[t].occupants[g[t].occupants.length-1];if(null===e.start||void 0===i||e.start>=i.end){n=t;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:t.id,end:e?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,d[t.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,h[t.id]),y[t.id]=n}}else t.forEach((t,e)=>{g.push({occupants:[{id:t.id,end:p[t.id]?.end??-1/0}],peak:{topPeak:d[t.id],botPeak:h[t.id]}}),y[t.id]=e});let m=null,x=null,b=null,v=null;const w=()=>{m=Fl(y,e),b=Nl(y,e)},k=()=>{x=Fl(y,e),v=Nl(y,e)};"crossing-min"===l?(w(),jl(g,y,e),k()):"inside-out"===l?(w(),function(t,e){const n=t.length;if(1>=n)return;const i=t=>t.peak.topPeak+t.peak.botPeak,o=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>i(e.slot)-i(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=o[0].idx;let a=s-1,c=s+1;for(let t=1;o.length>t;t++)t%2==1&&n>c||0>a?r[c++]=o[t].idx:r[a--]=o[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(),jl(g,y,e),function(t,e,n){const i=t.length;if(1>=i)return;const o=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((i-1)/2);let s=Ol(e,n);for(const{slot:a}of o){const o=t.indexOf(a);if(0>o)continue;const c=r;if(o===c)continue;const l=t[o];t.splice(o,1),t.splice(c,0,l);const u=new Map;for(let t=0;i>t;t++)u.set(t,t);if(c>o){for(let t=o+1;c>=t;t++)u.set(t,t-1);u.set(o,c)}else{for(let t=c;o>t;t++)u.set(t,t+1);u.set(o,c)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=Ol(e,n);if(d>s){const n=t[c];t.splice(c,1),t.splice(o,0,n);const r=new Map;for(let t=0;i>t;t++)r.set(t,t);if(o>c){for(let t=c+1;o>=t;t++)r.set(t,t-1);r.set(c,o)}else{for(let t=o;c>t;t++)r.set(t,t+1);r.set(c,o)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(g,y,e),k());const S=g.map(t=>{const e=new Map;for(const i of t.occupants){const t=n[i.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])}),A=(t,e)=>{let n={top:0,bot:0};for(const[i,o]of t){if(i>e)break;n=o}return n},M=[];for(let t=0;g.length-1>t;t++){const e=S[t],n=S[t+1],i=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let o=0;for(const t of i){const i=A(e,t),r=A(n,t);i.bot+r.top>o&&(o=i.bot+r.top)}M.push(o)}const P=[];let _=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&P.push(_);for(let t=1;g.length>t;t++)_+=M[t-1]*a+s,P.push(_);if(g.length>0&&(_+=g[g.length-1].peak.botPeak*a+s),_>r){const t=r/_;for(let e=0;P.length>e;e++)P[e]*=t}const I=0===g.length?0:g[0].peak.topPeak+M.reduce((t,e)=>t+e,0)+g[g.length-1].peak.botPeak,C={};for(const e of t)C[e.id]=P[y[e.id]];return{effectiveSlotsHeight:I,centerlines:C,laneLifetime:p,slots:g,slotByNode:y,slotCenter:P,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function ql(t){const{sx:e,sTop:n,sBot:i,tx:o,tTop:r,tBot:s,cp1X:a,cp2X:c}=t,l=(n+i)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${c},${r} ${o},${r}`,`L${o},${s}`,`C${c},${s} ${a},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(i-n)/2}}}function Hl(t){const{nodes:e,edges:n,domain:i,plotW:o,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=t,u=function(t,e,n){const i=[],o=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]||i.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]||i.push({kind:"invalid-node-time",id:e.id}));for(const t of e)o.has(t.source)||i.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),o.has(t.target)||i.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||i.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||i.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):i.push({kind:"invalid-edge-time",id:t.id});return i}(e,n,i),d=Ll().domain(i).range([0,o]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(t,e,n){const{plotH:i,pairing:o="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,c=function(t,e){const n={},i={};for(const e of t)n[e.id]=[],i[e.id]=[];for(const t of e)i[t.source]&&i[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:i}}(t,e),l=function(t,e,n,i="value"){const o="temporal"===i?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===i?(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 i of t){const t=i[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(t);o.edges.push(i),o.total+=i.value,o.earliestStart=Math.min(o.earliestStart,i.startTime),o.latestEnd=Math.max(o.latestEnd,i.endTime)}const s=[...n.values()];s.sort("temporal"===i?(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:o);return s};for(const e of t){const t=n.outgoing[e.id],i=n.incoming[e.id];if(0===i.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(i,"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(i,"source"),n=a(t,"target"),o=Math.max(e.length,n.length);for(let t=0;o>t;t++){const i=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=i;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=i}}}return s}(t,e,c,o);let u={};for(const e of t)u[e.id]=zl(e,c,l);const d=Yl(t,e,u,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),h=new Set;for(const t of e){const e=d.slotByNode[t.source],n=d.slotByNode[t.target];if(void 0===e||void 0===n)continue;const i=l.get(t.id);e!==n?e>n?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(h.add(t.id),i.sourceSide="bot",i.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],i=new Set(t.map(t=>l.get(t.id).sourceSide)),o=new Set(n.map(t=>l.get(t.id).targetSide));if(1===i.size&&n.length>0){const t=[...i][0];for(const e of n)d.slotByNode[e.source]===d.slotByNode[e.target]&&(l.get(e.id).targetSide=t)}if(1===o.size&&t.length>0){const e=[...o][0];for(const n of t)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.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 i=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===l.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===l.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},o=(t,e)=>{const o=i(),r="top"===t?o.outTop-o.inTop:o.outBot-o.inBot,s="top"===e?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),c=n.filter(e=>!h.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=n.length+1;for(;r-- >0&&(o("top","bot")||o("bot","top")););}u={};for(const e of t)u[e.id]=zl(e,c,l);const f=Yl(t,e,u,c,{plotH:i,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*i/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(i-y*(f.slots.length+1))/p):1,m=Yl(t,e,u,c,{plotH:i,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,n,{plotH:r,...l}),{centerlines:f,nodeData:p,valueScale:y}=h,g=[],m=[];e.forEach((t,e)=>{const o=p[t.id];if(!o||0===o.samples.length)return;const r=function(t,e,n,i,o){if(0===t.length)return null;const r=El(t,o),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let c=`M${i(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)c+=` L${i(r[t].t)},${s(t)}`;c+=` L${i(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)c+=` L${i(r[t].t)},${a(t)}`;return c+" Z"}(o.samples,f[t.id],y,d,i);if(!r)return;const s=El(o.samples,i),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,n,i,o){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],c=El(r.samples,o),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],d=i(l.t),h=i(u.t),f=t=>i(Dl(t,o)),p=[],y=(t,e,n,i)=>`M${t},${e} L${n},${e} L${n},${i} L${t},${i} 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),i=f(n.startTime),o=e-20,r=Math.max(d,o);if(i>r){const[n,c]=Bl(t,a,s);p.push({pathD:y(r,n,i,c),x0:o,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),i=f(n.endTime),o=e+20,r=Math.min(h,o);if(r>i){const[n,c]=Bl(t,a,s);p.push({pathD:y(i,n,r,c),x0:e,x1:o,from:1,to:0})}}}}return p}(t.id,n,h,d,i);g.push({id:t.id,pathD:r,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:t.__raw??t,labelX:d(a.t)-4,labelY:l,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),n.forEach(t=>{const e=p[t.source]?.localAttachments.get(t.id),n=p[t.target]?.localAttachments.get(t.id);if(!e||!n)return;const o=x.get(t.source)??0,r=c(t.source,o),l=function(t,e,n,i,o,r,s,a){const c=o,l=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(l(t.time)),d=r(l(n.time)),h=t.value*c,f=n.value*c,p=t.sideMassBefore*c,y=n.sideMassAfter*c;let g,m,x,b;"top"===t.side?(g=e-p,m=g+h):(m=e+p,g=m-h),"top"===n.side?(x=i-y,b=x+f):(b=i+y,x=b-f);const v="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(e,f[t.source],n,f[t.target],y,d,s,i),{pathD:u,bezier:h}=ql(l);m.push({id:t.id,pathD:u,fill:r,opacity:a,rawDatum:t.__raw??t,bezier:h})}),{layout:h,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:d}}var Xl=t=>{const{bands:e=[],ribbons:n=[],showLabels:i=!0}=t.config,o=[];for(const t of n)o.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 n=t.gradientStubs[e];o.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 e)o.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=i?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:o,labels:r}},Gl={frameType:"network",buildProps:(t,e,n,i,o)=>{const{edgeWidth:r,edgeColor:s,edgeOpacity:a}=o;return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:e,colorScheme:n,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle??(void 0!==r||void 0!==s||void 0!==a?t=>{const e=t?.data||t;let n=1;if("number"==typeof r)n=r;else if("function"==typeof r)n=r(e);else if("string"==typeof r){const t=e?.[r],i="number"==typeof t?t:Number(t);n=Number.isFinite(i)&&i>0?i:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),...i}}},Vl={frameType:"network",buildProps:(t,e,n,i,o)=>{const r=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),s=o.sourceAccessor||"source",a=o.targetAccessor||"target",c=o.valueAccessor||"value",l=o.nodeIdAccessor||"id",u=o.startTimeAccessor||"startTime",d=o.endTimeAccessor||"endTime",h=o.systemInTimeAccessor,f=o.systemOutTimeAccessor,p=o.xExtentAccessor||"xExtent",y=o.edgeIdAccessor||"id",g=(t,e)=>"function"==typeof t?t(e):e[t],m=Array.isArray(o.edges)?o.edges:[],x=Array.isArray(o.nodes)?o.nodes:[],b=x.length>0?x:function(t,e,n,i){const o=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof i?i(t):t[i];o.add(e),o.add(r)}),Array.from(o).map(t=>({id:t}))}(0,m,s,a),v=[r(o.domain?.[0]),r(o.domain?.[1])],w=b.map(t=>{const e=g(l,t)+"",n=g(p,t),i={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=r(n[0]),e=r(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(i.xExtent=[t,e])}return i}),k=m.map((t,e)=>{const n=g(y,t),i={id:null!=n?n+"":`${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(d,t)),__raw:t};if(h){const e=r(g(h,t));Number.isFinite(e)&&(i.systemInTime=e)}if(f){const e=r(g(f,t));Number.isFinite(e)&&(i.systemOutTime=e)}return i}),[S,M]=i.size??[600,400],_={top:20,right:20,bottom:20,left:20,...i.margin},I=i.legendPosition??"right";i.showLegend&&("right"===I?_.right=Math.max(_.right,100):"left"===I?_.left=Math.max(_.left,100):"bottom"===I?_.bottom=Math.max(_.bottom,70):"top"===I&&(_.top=Math.max(_.top,40)));const C=_,T=S-C.left-C.right,R=M-C.top-C.bottom,L=Array.isArray(n)?n:null,$=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],z="function"==typeof e?e:null,D=z?b.map(t=>({_cat:z(t)})):b,E=z?"_cat":"string"==typeof e?e:void 0,B=E?P(D,E,n):null,F=new Map;for(const t of w)F.set(t.id,t.__raw);const{layoutConfig:N,issues:O}=Hl({nodes:w,edges:k,domain:v,plotW:T,plotH:R,ribbonLane:o.ribbonLane||"both",edgeOpacity:"number"==typeof o.edgeOpacity?o.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&F.has(t)){const n=F.get(t);return z?A({_cat:z(n)},"_cat",B??void 0):A(n,e,B??void 0)}const i=L||$;return i[n%i.length]},layoutOpts:{pairing:o.pairing||"temporal",packing:o.packing||"reuse",laneOrder:o.laneOrder||"crossing-min",lifetimeMode:o.lifetimeMode||"half"}});if(O.length>0){const t=O.map($l).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Xl,layoutConfig:N,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:e,colorScheme:n,...i,margin:C}}},Ul={frameType:"geo",buildProps:(t,e,n,i,o)=>{const r=(Array.isArray(t)?t:null)||o.flows||[],s=o.nodeIdAccessor||"id",a=o.valueAccessor||"value",c=o.xAccessor||"lon",l=o.yAccessor||"lat",u="function"==typeof c?c:t=>t[c],d="function"==typeof l?l:t=>t[l],h=(o.nodes||[]).map(t=>({...t,x:u(t),y:d(t)})),f=new Map;for(const t of h)f.set(t[s]+"",t);const p=o.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+""),n=f.get(t.target+"");return e&&n?{...t,coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?P(g.map(t=>({[m]:p(t)})),m,n||"category10"):P(g,p,n||"category10"):null,b=t=>p&&x?A(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,M]=o.edgeWidthRange??[1,8],_=M-S,I=o.edgeOpacity??.6,C=o.edgeLinecap??"round";return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(t?.[a]),n=Number.isFinite(e)?e:v,i=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*_;return{stroke:b(t),strokeWidth:i,strokeLinecap:C,opacity:I,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}};function Kl(t){const[e,n]=t;return{width:e,height:n,plot:{x:32,y:24,width:Math.max(80,e-64),height:Math.max(80,n-58)}}}function Zl(t){const e=(t??"")+"";if(!e)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let i=0;for(let t=0;e.length>t;t+=1)i=31*i+e.charCodeAt(t)>>>0;return n[i%n.length]}function Ql(t,e="#4e79a7"){return n=>{const i=n.datum,o=i&&t?"function"==typeof t?t(i,0):i[t]:void 0;return{fill:null==o?e:Zl(o),stroke:"#111827",strokeWidth:1,opacity:.9}}}function Jl(t,e,n,i){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:n},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...i}}}function tu(t,e,n){return"function"==typeof n?n(t,e):t[n]}function eu(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 nu(t,e,n){return Math.max(e,Math.min(n,t))}function iu(t,e){const n=eu(t);return null!=n&&n>0?n:e}function ou(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function ru(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}}import{scaleLinear as su}from"d3-scale";function au(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 cu={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},lu=1e-9,uu=.005;function du(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function hu(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 fu(t,e,n){return Math.max(e,Math.min(n,t))}function pu(t){return 0>t?-1:1}function yu(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,n=t.shape.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}function gu(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,n=e.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}const n=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-n,minY:Math.min(e.y1,e.y2)-n,maxX:Math.max(e.x1,e.x2)+n,maxY:Math.max(e.y1,e.y2)+n}}function mu(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function xu(t,e,n,i,o,r,s,a){const c=o-t,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=r-e,d=(i+a)/2-Math.abs(u);return d>0?d>l?{nx:pu(c),ny:0,penetration:l}:{nx:0,ny:pu(u),penetration:d}:null}function bu(t,e,n,i,o,r,s){const a=r/2,c=s/2;let l=t-fu(t,i-a,i+a),u=e-fu(e,o-c,o+c);const d=l*l+u*u;if(d>n*n)return null;if(lu>=d){const r=Math.abs(t-(i-a)),s=Math.abs(t-(i+a)),d=Math.abs(e-(o-c)),h=Math.abs(e-(o+c)),f=Math.min(r,s,d,h);return f===r?(l=-1,u=0,{nx:l,ny:u,penetration:n+r}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:n+s}):f===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function vu(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,n,i,o,r){const s=i-t,a=o-e,c=n+r,l=s*s+a*a;if(l>=c*c)return null;if(lu>=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 xu(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 n=bu(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?bu(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function wu(t,e){const n=e.shape;return"aabb"===n.type?"circle"===t.shape.type?bu(t.x,t.y,t.shape.radius,n.x,n.y,n.width,n.height):xu(n.x,n.y,n.width,n.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,n,i,o,r,s,a=0){const c=r-i,l=s-o,u=c*c+l*l,d=u>lu?fu(((t-i)*c+(e-o)*l)/u,0,1):0,h=n+a/2,f=t-(i+c*d),p=e-(o+l*d),y=f*f+p*p;if(y>=h*h)return null;if(lu>=y){const t=Math.sqrt(u);return t>lu?{nx:-l/t,ny:c/t,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-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,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function ku(t,e){return`${t}\0${e}`}function Su(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function Au(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:du(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function Mu(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 Pu(t){return{id:t.id,shape:hu(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:Mu(t.bodyFilter),index:t.index}}function _u(t,e){return!!e?.some(e=>Object.is(t,e))}function Iu(t,e){const n=t.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(e);const i=function(t,e){if(!e)return;let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}(e,n.property);return!("equals"in n&&!Object.is(i,n.equals)||"notEquals"in n&&Object.is(i,n.notEquals)||n.oneOf&&!_u(i,n.oneOf)||n.notOneOf&&_u(i,n.notOneOf))}var Cu=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={...cu,...t},this.random=au(this.options.seed)}init(t={}){this.options={...cu,...t},this.random=au(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(lu,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:du(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))Su(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:hu(e.shape),bodyFilter:Mu(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,n){const i=this.bodies.get(t);i&&(i.vx+=e/i.mass,i.vy+=n/i.mass,this.wake(i))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const n=this.sortedBodies();for(const t of n)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const i=this.options.maxVelocity;for(const t of n)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,i>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>i){const n=i/e;t.vx*=n,t.vy*=n}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const o=this.bodyPairKeys(n),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(n,o,0===t),this.resolveColliders(n,r,0===t);this.updateSensors(n),this.updateSleeping(n,e)}settle(t=1200,e=this.options.fixedDt){let n=0;for(;t>n&&!this.allSleeping();)this.step(e),n+=1;return n}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:du(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Su)}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(Au),colliders:this.sortedColliders().map(Pu),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=au(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=Au(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=Pu(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 n=this.bodies.get(e.bodyId);if(!n||n.sleeping)continue;const i="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!i)continue;const o=i.x-n.x,r=i.y-n.y,s=Math.sqrt(o*o+r*r);if(lu>=s)continue;const a=o/s,c=r/s,l=(s-e.restLength)*e.stiffness+((("vx"in i?i.vx:0)-n.vx)*a+(("vy"in i?i.vy:0)-n.vy)*c)*e.damping;n.vx+=l*a*t/n.mass,n.vy+=l*c*t/n.mass}}resolveBodyPairs(t,e,n){for(const i of e){const[e,o]=i.split(":").map(Number),r=t[e],s=t[o];if(!r||!s)continue;const a=vu(r,s);a&&(this.resolveDynamicCollision(r,s,a),n&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),n=new Map;for(let i=0;t.length>i;i+=1){if(!1===t[i].bodyCollisions)continue;const o=yu(t[i]),r=Math.floor(o.minX/e),s=Math.floor(o.maxX/e),a=Math.floor(o.minY/e),c=Math.floor(o.maxY/e);for(let t=r;s>=t;t+=1)for(let e=a;c>=e;e+=1){const o=`${t}:${e}`,r=n.get(o);r?r.push(i):n.set(o,[i])}}const i=new Set;for(const e of Array.from(n.keys()).sort()){const o=n.get(e)??[];o.sort((t,e)=>t-e);for(let e=0;o.length>e;e+=1)for(let n=e+1;o.length>n;n+=1){const r=o[e],s=o[n];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&mu(yu(t[r]),yu(t[s]))&&i.add(`${r}:${s}`)}}return Array.from(i).sort((t,e)=>{const[n,i]=t.split(":").map(Number),[o,r]=e.split(":").map(Number);return n===o?i-r:n-o})}resolveDynamicCollision(t,e,n){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const i=t.sleeping?0:1/t.mass,o=e.sleeping?0:1/e.mass,r=i+o;if(lu>=r)return;const s=Math.max(0,n.penetration-uu)/r;t.x-=n.nx*s*i,t.y-=n.ny*s*i,e.x+=n.nx*s*o,e.y+=n.ny*s*o;const a=(e.vx-t.vx)*n.nx+(e.vy-t.vy)*n.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*n.nx,d=l*n.ny;t.vx-=u*i,t.vy-=d*i,e.vx+=u*o,e.vy+=d*o,this.applyFriction(t,e,n,l,i,o),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,n,i,o,r){const s=-n.ny,a=n.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=o+r;if(lu>=Math.abs(c)||lu>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),d=fu(-c/l,-i*u,i*u),h=d*s,f=d*a;t.vx-=h*o,t.vy-=f*o,e.vx+=h*r,e.vy+=f*r}resolveColliders(t,e,n){for(const i of t)for(const t of e){if(!Iu(t,i))continue;if(!mu(yu(i),gu(t)))continue;const e=wu(i,t);e&&(this.resolveStaticCollision(i,t,e),this.supportedThisStep.add(i.id),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,n){t.x+=n.nx*Math.max(0,n.penetration-uu),t.y+=n.ny*Math.max(0,n.penetration-uu);const i=t.vx*n.nx+t.vy*n.ny;if(0>i){const o=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+o)*i*n.nx,t.vy-=(1+o)*i*n.ny;const r=-n.ny,s=n.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,n=this.sortedColliders().filter(t=>t.sensor);for(const i of t){const t=yu(i);for(const o of n){if(!Iu(o,i))continue;if(!mu(t,gu(o)))continue;if(!wu(i,o))continue;const n=ku(o.id,i.id);e.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:o.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:n,bodyId:i}=Su(t);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:n})}this.activeSensors=e}updateSleeping(t,e){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of t)Math.sqrt(i.vx*i.vx+i.vy*i.vy)>=this.options.sleepSpeed||Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY))>=this.options.sleepSpeed*e||n&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=e,i.sleeping||this.options.sleepAfter>i.sleepTime||(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},Tu=class{constructor(t={}){this.id="builtin",this.capabilities={...(new Cu).capabilities,engine:"builtin"},this.world=new Cu(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,n){this.world.applyImpulse(t,e,n)}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 Ru(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new Tu(t)}(e)}var Lu=["binId","targetBin","category","windowIndex","lane","group"];function $u(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 n=e-t.mean;t.mean+=n/t.count,t.m2+=n*(e-t.mean)}function zu(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 Du(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 Eu(t,e){if(null!=t[e])return t[e];const n=t.datum;return n&&"object"==typeof n?n[e]:void 0}function Bu(t,e,n){return"function"==typeof t?t(e,n):"string"==typeof t?Eu(e,t):void 0}function Fu(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Nu(t){const e=zu(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:zu(t.x),y:zu(t.y),value:e}}var Ou=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 n=Fu(Bu(this.config.binAccessor,t,e))??function(t){for(const e of Lu){const n=Fu(Eu(t,e));if(n)return n}return"sediment"}(t),i=Fu(Bu(this.config.labelAccessor,t,e))??n,o=function(t,e,n){if("number"==typeof t)return t;const i="function"==typeof t?t(e,n):"string"==typeof t?Eu(e,t):1,o="number"==typeof i?i:Number(i);return Number.isFinite(o)?o:1}(this.config.valueAccessor,t,e),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:i,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(n,s)),s.label=i,s.lastBodyId=t.id,s.lastDatum=t.datum,$u(s.x,t.x),$u(s.y,t.y),$u(s.value,o),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),Nu(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Nu)}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:Du(e.x),y:Du(e.y),value:Du(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 Wu(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var ju={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},Yu={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function qu(t={},e=Yu){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 Hu(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function Xu(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 Gu(t,e){if(null!=t[e])return t[e];const n=t.datum;return n&&"object"==typeof n?n[e]:void 0}function Vu(t){return{...Hu(t),sequence:t.sequence,spawnAt:t.spawnAt}}function Uu(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 Ku(t){return!1!==t&&{...t}}function Zu(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function Qu(t){return{...t,gravity:{...t.gravity}}}function Ju(t,e,n,i){if("circle"===t.shape.type){const o=t.x-e,r=t.y-n,s=t.shape.radius+i,a=o*o+r*r;return a>s*s?null:a}const o=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),r=Math.max(Math.abs(n-t.y)-t.shape.height/2,0),s=o*o+r*r;return s>i*i?null:s}function td(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function ed(t,e={}){const{idPrefix:n="plot",includeFloor:i=!0,includeCeiling:o=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,d=t.y+t.height/2;return i&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),o&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),r&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:d,width:a,height:t.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:d,width:a,height:t.height+2*c}}),l}function nd(t){const{idPrefix:e="bin",count:n,domainStart:i,domainStep:o,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?n:n-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&n>t)continue;const s=r(i+t*o);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let t=0;n>t;t+=1){const n=i+t*o,s=n+o;if(s>=d)continue;const a=r(n),l=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}import{quadtree as id}from"d3-quadtree";var od=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,n,i,o,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=i-l,d=i+l,h=o-l,f=o+l;return s.visit((t,e,s,l,p)=>{if(u>l||e>d||h>p||s>f)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=Ju(t,i,o,Math.max(0,r));null!=e&&(c>e||e===c&&n.indexOf(t.id)>n.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 n=t.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=n.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=id().x(t=>t.x).y(t=>t.y).addAll(n),this.revision=e,this.tree)}},rd=["data","scene-geometry","data-paint","accessibility","evidence"],sd=["scene-geometry","data-paint","accessibility","evidence"],ad=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],cd=["overlay","accessibility","evidence"],ld=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function ud(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&ld.every(n=>t[n]===e[n])}function dd(t,e,n,i){return t||!e?"paused":n||!i?"running":"settled"}var hd=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new od,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new on,this.simulationState="settled",this.visible=!0;const{bodyBudget:e,colliders:n,engine:i,kernel:o,observation:r,sediment:s,...a}=t;this.config={...ju,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=i,this.observation=qu(r),this.sediment=new Ou(s??!1),this.world=Ru(i,{fixedDt:this.config.fixedDt,...o}),n&&this.world.setColliders(Uu(n))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(n=>"kernel"===n?!ud(t.kernel,e.kernel):t[n]!==e[n])}(t,this.configInput),{colliders:n,bodyBudget:i,engine:o,kernel:r,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),o&&o!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=o,this.world=Ru(o,t.options),this.world.restore(t),this.revision+=1}if(r&&!ud(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=qu(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(Uu(n)),this.revision+=1),this.configInput={...this.configInput,...t},this.updateResults.record({kind:"config",keys:e},e.length?ad:[])}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(Uu(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},ad)}enqueue(t,e){const n=Array.isArray(t)?t:[t],i=e?function(t,e={}){const n=Xu(e.startAt)??0,i=e.pacing??"immediate";if("arrival"===i){const i=t.map((t,n)=>function(t,e,n){return"function"==typeof n?Xu(n(t,e)):"string"==typeof n?Xu(Gu(t,n)):Xu(t.spawnAt)??Xu(Gu(t,"arrivalTime"))??Xu(Gu(t,"timestamp"))??Xu(Gu(t,"time"))??Xu(Gu(t,"eventTime"))}(t,n,e.timeAccessor)),o=i.filter(t=>null!=t),r=o.length>0?Math.min(...o):0,s=Xu(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const o=i[e],s=null==o?0:Math.max(0,o-r);return{...Hu(t),spawnAt:n+s/a}})}if("object"==typeof i){const e=Xu(i.ratePerSec);if(e&&e>0)return t.map((t,i)=>({...Hu(t),spawnAt:n+i/e}))}return t.map(t=>({...Hu(t),spawnAt:n}))}(n,{...e,startAt:e.startAt??this.elapsedSeconds}):n;for(const t of i)this.queue.push({...Hu(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Zu),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?rd:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(Hu(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},rd)}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"},rd)}tick(t){const e=this.revision,n=[],i=[],o=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,n,i,o,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(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);i.push(...l.evicted),o.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||n.length>0||i.length>0||o.length>0||r.length>0)&&(this.revision+=1);const d=this.result(u,n,i,o,r,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?n.length||i.length||o.length?rd:sd:[]),d}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const n=this.world.settle(t,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==e?sd:[]),n}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,n=[],i=[],o=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,n,i,o,r,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(n,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);i.push(...c.evicted),o.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||n.length>0||i.length>0||o.length>0||r.length>0)&&(this.revision+=1);const u=this.result(l,n,i,o,r,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==e?n.length||i.length||o.length?rd:sd:[]),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:n=0,binWidth:i=24,gap:o=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*(i+o);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:n-l,width:i,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,n)}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:n,chartId:i,...o}=t,r={...o,timestamp:e??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?cd:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?cd:[])}remove(t){const e=new Set(t),n=new Set(this.liveBodyOrder),i=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 o=t.filter(t=>n.has(t)||i.has(t));return o.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:o,count:o.length},o.length?rd:[]),o}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},sd),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},sd)}applyImpulse(t,e,n){this.world.applyImpulse(t,e,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},sd)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,n,i)=>t.applyImpulse(e,n,i),clear:()=>t.clear(),hitTest:(e,n,i)=>t.hitTest(e,n,i),pause:()=>t.setPaused(!0),push:(e,n)=>t.enqueue(e,n),pushMany:(e,n)=>t.enqueue(e,n),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:Ku(this.bodyBudget),config:{...this.config,kernel:Qu(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Vu),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:Ku(t.bodyBudget??{}),kernel:Qu(t.world.options)},this.bodyBudget=Ku(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(Vu).sort(Zu),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??dd(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"},ad)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,e),t.push(n.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 n=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:n?.datum??t.datum,x:n?.x??t.x,y:n?.y??t.y},e)}result(t,e,n,i,o,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:o,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:i,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,n){if(0===e.length)return;const i=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=i.get(t.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.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,n){const i=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===i.size&&0===e.size)return i;const o=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:i,bodyId:r}=td(e),s=n.observation.sensors[i],a=o.get(r);n.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:s?.binId??i})};for(const t of Array.from(i).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())i.has(t)||r("exit",t);return i}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const n of t)e.has(td(n).bodyId)&&t.delete(n)}(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)),n=Math.max(0,Math.floor(t.queuedBodies??0)),i=e+n,o=Wu(t.bodyLimit),r=Wu(t.engineMaxBodiesHint),s=function(t,e,n){if(!1===n)return;const i=Wu(n?.warnAt);return null!=i?i:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(o,r,t.options),a=null==o?0:Math.max(0,e-o),c=a>0?"overflow":null==s||s>i?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:o,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:i,queuedBodies:n,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 n=`${e.state}:${e.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,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=dd(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(e===this.simulationState)return;const n=this.simulationState;this.simulationState=e,function(t,e,n){n.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||n.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:e,previousSimulationState:t})}(n,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 n=this.liveBodyOrder.length-e;if(0>=n)return{evicted:[],sedimented:[]};const i=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,n);if(0===i.length)return{evicted:[],sedimented:[]};const o=this.absorbSediment(i,t);this.world.remove(i);const r=new Set(i);return this.liveBodyOrder=this.liveBodyOrder.filter(t=>!r.has(t)),this.removeActiveSensorPairsForBodies(r),{evicted:i,sedimented:o}}absorbSediment(t,e){const n=new Map(this.world.readState().map(t=>[t.id,t])),i=[];for(const o of t){const t=n.get(o);if(!t)continue;const r=this.sediment.add(t);r&&(i.push(o),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:o,datum:t.datum,x:t.x,y:t.y,binId:r.id,count:r.count,total:r.total},e))}return i}sleepingFirstEvictionOrder(){const t=new Map(this.world.readState().map(t=>[t.id,t.sleeping])),e=[],n=[];for(const i of this.liveBodyOrder)t.get(i)?e.push(i):n.push(i);return[...e,...n]}};import{scaleLinear as fd}from"d3-scale";function pd(t){const{count:e,idPrefix:n,wallThickness:i,xScale:o,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:`${n}-wall-${e}`,shape:{type:"aabb",x:o(e),y:c+l/2,width:i,height:l}}})}import{scaleLinear as yd}from"d3-scale";function gd(t){if(Array.isArray(t)&&t.length>=2){const e=eu(t[0]),n=eu(t[1]);return null!=e&&null!=n?{x:e,y:n}:null}if(t&&"object"==typeof t){const e=t,n=eu(e.x),i=eu(e.y);return null!=n&&null!=i?{x:n,y:i}:null}return null}function md(t){return Array.isArray(t)?t.map(gd).filter(t=>null!=t):[]}function xd(t,e,n){return"normalized"===n?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:nu(t.x,e.plot.x,e.plot.x+e.plot.width),y:nu(t.y,e.plot.y,e.plot.y+e.plot.height)}}function bd(t){let e=0;for(let n=1;t.length>n;n+=1)e+=Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y);return e}function vd(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const n=nu(e,0,1)*bd(t);let i=0;for(let e=1;t.length>e;e+=1){const o=t[e-1],r=t[e],s=Math.hypot(r.x-o.x,r.y-o.y);if(s>0){if(i+s>=n){const t=(n-i)/s;return{x:o.x+(r.x-o.x)*t,y:o.y+(r.y-o.y)*t}}i+=s}}return{...t[t.length-1]}}function wd(t,e){const n=vd(t,Math.max(0,e-.02)),i=vd(t,Math.min(1,e+.02)),o=i.x-n.x,r=i.y-n.y,s=Math.hypot(o,r)||1;return{x:o/s,y:r/s}}function kd(t,e,n){return Math.max(e,Math.min(n,t))}function Sd(t,e,n,i,o,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:n,x2:i,y2:o,thickness:r.thickness??8}}}function Ad(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,n=t.y,i=t.width,o=t.height,{type:"aabb",x:e,y:n,width:i,height:o}),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,n,i,o}function Md(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ad({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Pd(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 _d(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=t.size,i=Kl(n),o=nu(t.ballRadius??6,2,18),r=t.seed??1,s=ru(r),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,d=t.workAccessor,h=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",n=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height)),o=t.padX??46,r=t.padY??72,s=o,a=n-o,c=r,l=i-Math.max(24,Math.round(.45*r)),u=(c+l)/2,d=Math.max(1,l-c),h=kd(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=kd(d*h+p,.06*d,.5*d),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=kd(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),P=a-s;let _=s;const I=S.map((t,e)=>{const n=_,i=e===S.length-1?a:_+(t.share??1)/M*P;return _=i,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:n,x1:i,x:(n+i)/2,width:i-n,y:u,height:d}}),C=I[A],T=C.x0,R=C.x1,L=(t,n)=>{if("lane"===e)return"top"===n?c:l;if("funnel"===e){const e=kd((t-s)/Math.max(1,a-s),0,1);return"top"===n?c+(m-c)*e:l+(x-l)*e}if(T>=t){const e=kd((t-s)/Math.max(1,T-s),0,1);return"top"===n?c+(m-c)*e:l+(x-l)*e}if(R>=t)return"top"===n?m:x;const i=kd((t-R)/Math.max(1,a-R),0,1);return"top"===n?m+(c-m)*i:x+(l-x)*i},$=I.map(t=>{const e=Math.min(L(t.x0,"top"),L(t.x1,"top")),n=Math.max(L(t.x0,"bottom"),L(t.x1,"bottom"));return{...t,y:(e+n)/2,height:Math.max(1,n-e)}}),z={thickness:k,friction:v,restitution:w},D=[];"lane"===e?D.push(Sd(b+"-top",s,c,a,c,z),Sd(b+"-bottom",s,l,a,l,z),Sd(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Sd(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)})):"funnel"===e?D.push(Sd(b+"-top",s,c,a,m,z),Sd(b+"-bottom",s,l,a,x,z),Sd(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Sd(b+"-right",a,m,a,x,{...z,thickness:Math.max(6,k)})):D.push(Sd(b+"-left-top",s,c,T,m,z),Sd(b+"-left-bottom",s,l,T,x,z),Sd(b+"-center-top",T,m,R,m,z),Sd(b+"-center-bottom",T,x,R,x,z),Sd(b+"-right-top",R,m,a,c,z),Sd(b+"-right-bottom",R,x,a,l,z),Sd(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Sd(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)}));const E=t.membraneDampingScale??.5,B=s,F=Math.max(1,("bowtie"===e?T:a)-B),N=(t.membranes??[]).map(t=>{const e=B+kd(t.offset,0,1)*F,n=t.width??18+18*t.cost,i=d-16,o=u+.25*(t.wobble??0);return{...t,x:e,y:o,width:n,height:i}}),O=!1===t.includeMembraneRegions?[]:N.map(t=>function(t){const e=t.dampingScale??.5,n=t.energyScale??1,i=kd(t.cost,0,2);return{...Ad({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:i,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i*e,energyDelta:-i*n}}({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??E,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:n,height:i,padX:o,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:T,centerRight:R,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:$,membranes:N,colliders:D,regionEffects:O,boundaryY:L}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,i.plot.x),padY:Math.max(36,i.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 n={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{...Ad({...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"}}({...n,kind:t.kind??"sink",force:Pd(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return i={...n,kind:t.kind??"force-field",force:Pd(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Ad({...i,kind:i.kind??"force-field",attributes:{primitive:"portal",targetStage:i.targetStage,..."object"==typeof i.attributes&&i.attributes?i.attributes:{}}}),force:i.force,impulseOnEnter:i.impulseOnEnter,damping:i.damping??.08}}var i;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{...Ad({...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}}({...n,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Pd(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...n.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,n=t.baseDamping??.08,i=t.dampingPerUnit??.12,o=t.energyPerUnit??0;return{...Ad({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:n+e*i,energyDelta:o?-e*o:void 0,force:t.force}}({...n,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:Pd(t.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Md({...n,kind:t.kind??"force-field",force:Pd(t.force,14),damping:t.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(t){return{...Ad({...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}}({...n,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Md({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 P=[];t.data.forEach((t,e)=>{const n=(a?tu(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",i=(tu(t,e,c)??w)+"",r=b.has(i)?i:w;M.set(r,(M.get(r)??0)+1);const s=l?(tu(t,e,l)??"")+"":void 0,f=s&&u?(tu(t,e,u)??s)+"":s,p=d?eu(tu(t,e,d))??1:1,y=h?eu(tu(t,e,h)):null,g=nu(null!=y&&y>0?y:o,2,18);P.push({datum:t,id:n,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const _=new Map,I=new Map;for(const t of P){if(!t.groupId)continue;const e=_.get(t.groupId)??[];e.push(t.id),_.set(t.groupId,e),t.groupLabel&&I.set(t.groupId,t.groupLabel)}const C=nu(t.groupAnchorAlong??.55,.15,.9),T=x.left+(x.right-x.left)*C,R=Array.from(_.keys()),L=R.map((t,n)=>{const i=_.get(t)??[],o=R.length>1?x.topY+28+n/Math.max(1,R.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,n=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:n,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:n},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:I.get(t)??t,bodyIds:i,anchor:{x:T,y:o},x:T,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),$=function(t,e){const n=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],i=e.filter(t=>!n.has(t)),o=e.length-i.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+(n.has(e)?a(e):0),0),u=t.completion?.threshold,d="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?o>0:"threshold"===r?l>=(d??c):0===i.length),absorbed:o,total:e.length,absorbedValue:l,totalValue:c,threshold:d,missing:i}})}(L,P.filter(t=>S.has(t.stageId)).map(t=>t.id)),z=new Map(L.map(t=>[t.id,t])),D=P.map((t,e)=>{const n=v.get(t.stageId)??k,i=n.x+(s()-.5)*Math.min(24,.2*n.width),o=x.boundaryY(i,"top")+t.radius+10,r=x.boundaryY(i,"bottom")-t.radius-10,a=r>o?o+s()*Math.max(1,r-o):x.midY,c=g?i:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:i,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}}}),E={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},B=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),F=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:E,initialSpawns:D,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:B,metadata:{kind:"process-flow",plot:i.plot,volume:x,stages:F,groups:L,groupCompletion:$,regionEffects:A}}}import{forwardRef as Id,useCallback as Cd,useMemo as Td,useRef as Rd}from"react";import{scaleLinear as Ld}from"d3-scale";function $d(t,e,n){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=v[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function zd(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&M(n,t)||"#4e79a7":e=>{if(n){const t=M(n,e);if(t)return t}let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return t[Math.abs(i)%t.length]??"#4e79a7"}}import*as Dd from"react";import{forwardRef as Ed,memo as Bd,useCallback as Fd,useEffect as Nd,useImperativeHandle as Od,useId as Wd,useRef as jd}from"react";var Yd={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},qd={names:["--semiotic-border","--surface-3"],fallback:"#334155"},Hd={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},Xd={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},Gd={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},Vd={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},Ud={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},Kd={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},Zd={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},Qd={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function Jd(t,e){const n=t.canvas;if("function"!=typeof getComputedStyle||!n)return e.fallback;const i=getComputedStyle(n);for(const n of e.names){const e=i.getPropertyValue(n).trim();if(e)return Hn(t,e)??e}return e.fallback}function th(t,e){const n=Math.max(0,Math.min(1,e)),i=t.trim(),o=i.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(o){const[,t,e,i]=o;return th(`#${t}${t}${e}${e}${i}${i}`,n)}const r=i.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(r){const[,t,e,i]=r;return`rgba(${parseInt(t,16)}, ${parseInt(e,16)}, ${parseInt(i,16)}, ${n})`}const s=i.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(s)return`rgba(${s[1]}, ${n})`;const a=i.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return a?`rgba(${a[1]}, ${n})`:i}import*as eh from"react";import{scaleLinear as nh}from"d3-scale";import{Fragment as ih,jsx as oh,jsxs as rh}from"react/jsx-runtime";function sh(t){return"circle"===t.shape.type?t.shape.radius:Math.max(t.shape.width,t.shape.height)/2}function ah(t){const{width:e,height:n,totalWidth:i,totalHeight:o,margin:r,title:s,legend:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:f,pointNodes:p=[],annotations:y,autoPlaceAnnotations:g,svgAnnotationRules:m,children:x}=t,b=eh.useMemo(()=>function(t){return t?.length?t.map(t=>null!=t.pointId||null==t.bodyId?t:{...t,pointId:t.bodyId+""}):t}(y),[y]),v=eh.useMemo(()=>function(t){const{width:e,height:n,pointNodes:i=[],data:o}=t;return{scales:{x:nh().domain([0,Math.max(1,e)]).range([0,Math.max(1,e)]),y:nh().domain([0,Math.max(1,n)]).range([0,Math.max(1,n)])},width:e,height:n,frameType:"network",pointNodes:i,data:o,xAccessor:"x",yAccessor:"y"}}({width:e,height:n,pointNodes:p}),[n,p,e]),w=eh.useMemo(()=>b&&g?sr({annotations:b,context:v,..."object"==typeof g?g:{}}):b,[v,g,b]),k=eh.useMemo(()=>Wo(),[]),S=w?Oo(w.filter(t=>"widget"!==t.type),k,m,v):null,A=!0===w?.some(t=>"widget"===t.type&&!0===t._annotationDeferred);return rh(ih,{children:[A?oh("style",{children:Ro},"physics-annotation-disclosure-style"):null,rh("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[rh("g",{transform:`translate(${r.left},${r.top})`,children:[S,x]}),s&&"string"==typeof s?oh("text",{x:i/2,y:16,textAnchor:"middle",fontWeight:600,fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?oh("foreignObject",{x:0,y:0,width:i,height:Math.max(r.top,28),children:s}):null,a?Hi({legend:a,totalWidth:i,totalHeight:o,margin:r,legendPosition:h,legendLayout:f,title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}function ch(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function lh(t,e){const n="sensor"===t.physics?e.sensorThickness:e.barrierThickness;return Math.max(0,ch(t.thickness)??ch(n)??ch(e.thickness)??4)}var uh=2500;function dh(t){return"function"==typeof t}function hh(t){return void 0===t||!1===t||!dh(t.binAccessor)&&!dh(t.labelAccessor)&&!dh(t.valueAccessor)}function fh(t){if(void 0!==t){if(!1===t)return!1;if(!hh(t))throw new TypeError("Physics worker sediment config only supports string or numeric accessors");return{binAccessor:"string"==typeof t.binAccessor?t.binAccessor:void 0,labelAccessor:"string"==typeof t.labelAccessor?t.labelAccessor:void 0,valueAccessor:"string"==typeof t.valueAccessor||"number"==typeof t.valueAccessor?t.valueAccessor:void 0,retainBodyIds:t.retainBodyIds}}}function ph(t){if(t)return{chartId:t.chartId,chartType:t.chartType,sensors:t.sensors}}function yh(t){return function(t){return!dh(t?.timeAccessor)}(t)}function gh(t={}){if(t.engine)throw new TypeError("Physics workers use the built-in kernel adapter");const{engine:e,observation:n,sediment:i,...o}=t;return{...o,observation:ph(n),sediment:fh(i)}}function mh(){if("undefined"!=typeof DOMException)return new DOMException("Physics worker request aborted","AbortError");const t=Error("Physics worker request aborted");return t.name="AbortError",t}var xh=class{constructor(t=function(){const t="string"==typeof import.meta.url&&import.meta.url?new URL("./physicsWorker.js",import.meta.url):function(t){if("undefined"!=typeof __filename){const e=__filename.replace(/\\/g,"/"),n=e.startsWith("/")?e:"/"+e;return new URL("./"+t,"file:"+n)}throw Error("Cannot resolve module worker asset: "+t)}("physicsWorker.js");return new Worker(t,{type:"module",name:"semiotic-physics"})}()){this.nextRequestId=1,this.pending=new Map,this.worker=t,this.worker.onmessage=t=>{const e=t.data,n=this.pending.get(e.requestId);n&&(this.pending.delete(e.requestId),n.cleanup(),e.ok?n.resolve(e.payload):n.reject(function(t){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),e}(e)))},this.worker.onerror=t=>{this.rejectAll(Error(t.message||"Physics worker failed")),this.worker.terminate()}}request(t,e){if(e?.aborted)return Promise.reject(mh());const n=this.nextRequestId;this.nextRequestId+=1;const i={command:t,requestId:n};return new Promise((t,o)=>{const r=()=>{this.pending.delete(n),e?.removeEventListener("abort",r),o(mh())},s=()=>e?.removeEventListener("abort",r);this.pending.set(n,{cleanup:s,reject:o,resolve:t}),e?.addEventListener("abort",r,{once:!0});try{this.worker.postMessage(i)}catch(t){this.pending.delete(n),s(),o(t)}})}async init(t,e,n,i){if(!yh(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const o=await this.request({type:"init",config:gh(t),initialSpawns:e,initialSpawnPacing:n},i);if("frame"!==o.type)throw Error("Physics worker returned a non-frame init response");return o.frame}async restore(t,e){const n=await this.request({type:"restore",snapshot:t},e);if("frame"!==n.type)throw Error("Physics worker returned a non-frame restore response");return n.frame}async initFromSnapshot(t,e,n){const i=await this.request({type:"init",config:gh(t),snapshot:e},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame init response");return i.frame}async enqueue(t,e,n){if(!yh(e))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const i=await this.request({type:"enqueue",spawns:t,pacing:e},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame enqueue response");return i.frame}async tick(t,e){const n=await this.request({type:"tick",deltaSeconds:t},e);if("frame"!==n.type)throw Error("Physics worker returned a non-frame tick response");return n.frame}async settle(t,e){const n=await this.request({type:"settle",maxSteps:t},e);if("frame"!==n.type)throw Error("Physics worker returned a non-frame settle response");return n.frame}async snapshot(t){const e=await this.request({type:"snapshot"},t);if("snapshot"!==e.type)throw Error("Physics worker returned a non-snapshot response");return e.snapshot}async remove(t,e){const n=await this.request({type:"remove",ids:t},e);if("removed"!==n.type)throw Error("Physics worker returned a non-remove response");return{frame:n.frame,removed:n.removed}}terminate(){this.rejectAll(Error("Physics worker terminated")),this.worker.terminate()}rejectAll(t){for(const[e,n]of this.pending)this.pending.delete(e),n.cleanup(),n.reject(t)}};import*as bh from"react-dom/server";function vh(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 wh={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function kh(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 Sh(t,e){const n="function"==typeof e?e(t):e;return{...wh,...n??{}}}function Ah(t,e={}){return t.map(t=>function(t,e={}){const n=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),i={label:e.getBodyLabel?.(t)??kh(t)},o={style:Sh(t,e.bodyStyle),datum:n,accessibleDatum:n,accessibility:i,_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,...o}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...o}}(t,e))}import{jsx as Mh,jsxs as Ph}from"react/jsx-runtime";function _h(t,e={}){const{width:n=640,height:i=360,title:o,description:r,background:s,className:a,idPrefix:c="physics",...l}=e,u=function(t,e={}){const n=t.settle(e.maxSteps),i=t.readBodies(),o=t.snapshot(),r=Ah(i,e),s=function(t,e={}){const n=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),i=n.filter(t=>t.sleeping).length;return{bodyCount:n.length,sleepingCount:i,settled:"settled"===t.simulationState&&0===t.queue.length&&i===n.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:vh(e.projectionRows)}}(o,{bodies:i,projectionRows:e.projectionRows,stepsRun:n});return{snapshot:o,bodies:i,sceneNodes:r,evidence:s,stepsRun:n}}(t,l),d=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(c),h=o?d+"-title":void 0,f=r?d+"-desc":void 0,p=[h,f].filter(Boolean).join(" ")||void 0;return{svg:bh.renderToStaticMarkup(Ph("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:n,height:i,viewBox:`0 0 ${n} ${i}`,role:"img","aria-labelledby":p,children:[o&&Mh("title",{id:h,children:o}),r&&Mh("desc",{id:f,children:r}),s&&"transparent"!==s?Mh("rect",{x:0,y:0,width:n,height:i,fill:s}):null,Mh("g",{id:d+"-data-area",children:u.sceneNodes.map((t,e)=>qr(t,e,d))})]})),scene:u,evidence:u.evidence}}function Ih(t,e){if("function"==typeof e){const n=e(t);return Number.isFinite(n)&&n>0?Number(n):1}const n=t.datum;if(e&&n&&"object"==typeof n){const t=Number(n[e]);if(Number.isFinite(t)&&t>0)return t}const i=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(i)&&i>0?i:1}function Ch(t,e){if("function"==typeof e){const n=e(t);if(null!=n&&(n+"").length>0)return n+""}else if(e){const n=Rh(t.datum,e),i=Rh(t,e),o=n??i;if(null!=o&&(o+"").length>0)return o+""}return t.id}function Th(t,e){if(0===t.length)return 0;if(1===t.length)return t[0];const n=Math.max(0,Math.min(1,e))*(t.length-1),i=Math.floor(n);return t[i]+(t[Math.ceil(n)]-t[i])*(n-i)}function Rh(t,e){if(!e)return;let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}function Lh(t,e){if(!e)return!0;if("function"==typeof e)return e(t);const n=Rh(t,e.property);return!("equals"in e&&!Object.is(n,e.equals)||"notEquals"in e&&Object.is(n,e.notEquals)||e.oneOf&&!e.oneOf.some(t=>Object.is(n,t))||e.notOneOf&&e.notOneOf.some(t=>Object.is(n,t)))}function $h(t){const e=t.regionId,n=Math.max(0,t.unitsPerSecond),i=t.queueLayout??"lane",o=t.queueSlotSpacing??14,r=t.queueStiffness??.35,s=Number.isFinite(t.maxQueue)?Math.max(0,Math.floor(Number(t.maxQueue))):1/0,a=Math.max(.25,t.metricWindowSeconds??30),c=Math.max(1/60,t.snapshotIntervalSeconds??.25),l=t.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,p=new Map,y=new Map,g=new Map,m=[];let x=0,b=new Map,v=new Map,w=0,k=0,S=0,A=null,M=0,P=0,_=0,I=0,C=0,T=0,R=0,L=0,$=0,z=0,D=0,E=0,B=-1,F=!1;function N(t,n){const i=n(t);return!!i&&i.activeRegionIds.includes(e)}function O(){E+=1}function W(t){return{bodyId:t.bodyId,jobId:t.jobId,visitId:t.visitId,visit:t.visit,regionId:e,work:t.total,queuedAt:t.queuedAt}}function j(n,i,o,r){const s={bodyId:n.id,jobId:i.jobId,visitId:i.visitId,visit:i.visit,remaining:i.work,total:i.work,queuedAt:i.queuedAt,sequence:r};return u.set(i.jobId,s),g.delete(n.id),y.set(n.id,i.jobId),P+=1,_+=i.work,O(),function(n,i,o){const r=W(i);t.onQueued?.(n,r),o.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:e,work:i.total,jobId:i.jobId,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,queueDepth:u.size})}(n,s,o),s}function Y(t){if(u.size>=s||0===d.size)return;const e=Array.from(d.values()).sort((t,e)=>t.sequence-e.sequence);for(const n of e){if(u.size>=s)break;const e=p.get(n.jobId);e&&h.has(n.jobId)?(d.delete(n.jobId),g.delete(n.bodyId),j(e,n,t,n.sequence)):d.delete(n.jobId)}}function q(){let t=0;for(const e of u.values())t+=e.remaining;return t}function H(){$=Math.max($,u.size),z=Math.max(z,q())}function X(){const t=S-a,e=Math.max(0,Math.min(a,S-(A??S)));let i=0,o=0,r=0,s=0,c=0;for(const e of m){if(t>e.end)continue;i+=e.arrivals,o+=e.arrivalWork,r+=e.completions,s+=e.completedWork;const n=e.end-e.start;c+=n>0&&t>e.start?e.processedWork*Math.min(1,Math.max(0,e.end-t)/n):e.processedWork}const l=e>0?o/e:0;return{seconds:e,arrivals:i,arrivalWork:o,completions:r,completedWork:s,processedWork:c,arrivalsPerSecond:e>0?i/e:0,throughputPerSecond:e>0?r/e:0,utilization:e>0&&n>0?Math.max(0,Math.min(1,c/(n*e))):0,pressure:n>0?l/n:0}}return{id:t.id??"capacity-queue:"+e,continuous:!1!==t.continuous,tick:i=>{const o=i.controls.readBodies(),r=new Map,P=new Map;for(const e of o){if(r.set(e.id,e),!N(e.id,i.getRegionState))continue;if(!Lh(e,t.bodyFilter))continue;const n=Ch(e,t.jobKey),o=P.get(n)??[];o.push(e),P.set(n,o)}const _=Number.isFinite(i.dt)?Math.max(0,i.dt):0;if(!F){const t=Number.isFinite(i.elapsed)?Math.max(0,i.elapsed):_;S=Math.max(0,t-_),F=!0}const $=S,z=$+_;S=z,A=null==A?$:Math.min(A,$);const E={start:$,end:z,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},q=new Map;for(const[t,e]of P){const n=h.get(t)?.bodyId,i=e.find(t=>t.id===n)??e[0];q.set(t,i),p.set(t,i)}for(const[n,o]of h){if(q.has(n))continue;const s=u.get(n),a=r.get(o.bodyId)??p.get(n);if(s){u.delete(n),y.delete(s.bodyId),R+=1,L+=s.remaining,O();const r={...W(s),abandonedAt:S,remainingWork:s.remaining,queueSeconds:Math.max(0,S-s.queuedAt)};a&&t.onAbandoned?.(a,r),i.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:o.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:e,work:s.total,remainingWork:s.remaining,jobId:n,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:S,queueSeconds:r.queueSeconds,queueDepth:u.size})}d.delete(n),g.delete(o.bodyId),h.delete(n),p.delete(n)}for(const[n,o]of q){if(h.has(n))continue;const r=(f.get(n)??0)+1;f.set(n,r);const a=Ih(o,t.unitAccessor),c={bodyId:o.id,jobId:n,visitId:`${e}:${n}:${r}`,visit:r,regionId:e,work:a,queuedAt:S};h.set(n,c),M+=1,E.arrivals+=1,E.arrivalWork+=a;const l=x++;if(s>u.size)j(o,c,i,l);else{const s={...c,blockedAt:S,sequence:l};d.set(n,s),g.set(o.id,n),T+=1,O(),t.onBlocked?.(o,s),i.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:e,work:a,jobId:n,visitId:c.visitId,visit:r,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}Y(i),H();const X=Array.from(u.values()).sort((t,e)=>t.sequence-e.sequence);let G=n*_;for(const n of X){if(0>=G)break;const o=Math.min(n.remaining,G);if(n.remaining-=o,G-=o,I+=o,E.processedWork+=o,n.remaining>1e-6)continue;u.delete(n.jobId),y.delete(n.bodyId),k+=1,C+=n.total,E.completions+=1,E.completedWork+=n.total;const s=Math.max(0,S-n.queuedAt);D+=s,O();const a=r.get(n.bodyId);if(!a)continue;i.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...W(n),completedAt:S,queueSeconds:s};t.onProcessed?.(a,c),i.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:e,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:S,queueSeconds:s,queueDepth:u.size})}Y(i),H(),function(){const t=Array.from(u.values()).sort((t,e)=>t.sequence-e.sequence);b=new Map(t.map((t,e)=>[t.bodyId,e]));const e=Array.from(d.values()).sort((t,e)=>t.sequence-e.sequence);v=new Map(e.map((t,e)=>[t.bodyId,e])),w=t.length}(),function(t){(t.end>t.start||t.arrivals>0||t.completions>0||t.processedWork>0)&&m.push(t);const e=S-a;for(;m.length>0&&e>m[0].end;)m.shift()}(E);const V=Math.floor(S/c);V!==B&&(B=V,O())},getSnapshot:()=>{const t=q(),i=function(){let t=0;for(const e of d.values())t+=e.work;return t}(),o=u.size,r=Array.from(u.values()).map(t=>Math.max(0,S-t.queuedAt)).sort((t,e)=>t-e),s=r.reduce((t,e)=>t+e,0);return{regionId:e,queueDepth:o,processedCount:k,unitsPerSecond:n,remainingWork:t,meanRemainingWork:o>0?t/o:0,waitingWork:t+i,blockedDepth:d.size,blockedWork:i,arrivalCount:M,admittedCount:P,admittedWork:_,processedWork:I,completedWork:C,blockedCount:T,abandonedCount:R,abandonedWork:L,peakQueueDepth:$,peakRemainingWork:z,queueAge:{count:r.length,meanSeconds:r.length>0?s/r.length:0,p50Seconds:Th(r,.5),p95Seconds:Th(r,.95),oldestSeconds:r.at(-1)??0},meanCompletedQueueSeconds:k>0?D/k:0,window:X(),simulatedAt:S,metricRevision:E}},bodyForce:t=>{if("none"===i)return null;const n=y.get(t.body.id),s=g.get(t.body.id),a=n?u.get(n):void 0,c=s?d.get(s):void 0;if(!a&&!c)return null;const l=a?b.get(t.body.id):v.get(t.body.id);if(null==l)return null;let h;const f=t.regions;if(f)for(let t=0;f.length>t;t+=1)if(f[t].id===e){const e=f[t].shape;e&&"aabb"===e.type&&(h=e);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*o))-t.body.x)*r,y:(h.y-(l-((c?d.size:w)-1)/2)*o/Math.max(1,Math.sqrt(c?d.size:w))-t.body.y)*r*.85}:{x:8*-Math.sign(t.body.vx||1),y:0}}}}function zh(t,e){return t||e?{x:(t?.x??0)+(e?.x??0),y:(t?.y??0)+(e?.y??0)}:null}import{useEffect as Dh,useRef as Eh}from"react";function Bh(){return"undefined"==typeof document||!document.hidden}function Fh(t,e,n){const i=n.fill??"#4e79a7",o=n.stroke,r=n.strokeWidth??0,s=n.opacity??1,a=n.fillOpacity??1,c=function(t,e){const n=e.mark;if(n)return n;const i=t.datum,o=i?.__physicsMark??i?.mark;return"circle"===o||"halo"===o||"faceted"===o||"pill"===o||"diamond"===o||"square"===o?o:"circle"===t.shape.type?"circle":"square"}(e,n),l="circle"===e.shape.type?n.r??e.shape.radius:Math.max(e.shape.width,e.shape.height)/2;if(t.save(),t.globalAlpha*=s,t.beginPath(),"pill"===c||"square"===c||"aabb"===e.shape.type){const n="pill"===c?2.4*l:"aabb"===e.shape.type?e.shape.width:1.7*l,i="pill"===c?1.35*l:"aabb"===e.shape.type?e.shape.height:1.7*l,o=e.x-n/2,r=e.y-i/2,s="pill"===c?i/2:Math.min(4,n/4);t.moveTo(o+s,r),t.arcTo(o+n,r,o+n,r+i,s),t.arcTo(o+n,r+i,o,r+i,s),t.arcTo(o,r+i,o,r,s),t.arcTo(o,r,o+n,r,s),t.closePath()}else if("diamond"===c)t.moveTo(e.x,e.y-l),t.lineTo(e.x+l,e.y),t.lineTo(e.x,e.y+l),t.lineTo(e.x-l,e.y),t.closePath();else if("faceted"===c){const n=6;for(let i=0;n>i;i+=1){const o=2*Math.PI*i/n-Math.PI/2,r=e.x+Math.cos(o)*l,s=e.y+Math.sin(o)*l;0===i?t.moveTo(r,s):t.lineTo(r,s)}t.closePath()}else t.arc(e.x,e.y,l,0,2*Math.PI);i&&(t.save(),t.globalAlpha*=a,t.fillStyle=i,t.fill(),t.restore()),"halo"===c&&(t.beginPath(),t.arc(e.x,e.y,1.35*l,0,2*Math.PI),t.strokeStyle=o??i,t.lineWidth=Math.max(1.5,r||1.5),t.globalAlpha*=.55,t.stroke(),t.globalAlpha/=.55),o&&r>0&&(t.strokeStyle=o,t.lineWidth=r,n.strokeDasharray&&t.setLineDash(n.strokeDasharray.split(/[,\s]+/).map(t=>Number(t)).filter(t=>Number.isFinite(t))),t.stroke()),t.restore()}function Nh(t){return"circle"===t.shape.type?t.shape.radius:Math.max(t.shape.width,t.shape.height)/2}function Oh(t){return t.sensorId??"stream-region-"+t.id}function Wh(t){const e=Oh(t),n={bodyFilter:t.bodyFilter,friction:t.friction,restitution:t.restitution};if("boundary"===t.collider&&"aabb"===t.shape.type){const i=t.colliderThickness??8,o=t.shape.x-t.shape.width/2,r=t.shape.x+t.shape.width/2,s=t.shape.y-t.shape.height/2,a=t.shape.y+t.shape.height/2;return[{...n,id:e+"-top",shape:{type:"segment",x1:o,y1:s,x2:r,y2:s,thickness:i}},{...n,id:e+"-right",shape:{type:"segment",x1:r,y1:s,x2:r,y2:a,thickness:i}},{...n,id:e+"-bottom",shape:{type:"segment",x1:r,y1:a,x2:o,y2:a,thickness:i}},{...n,id:e+"-left",shape:{type:"segment",x1:o,y1:a,x2:o,y2:s,thickness:i}}]}return t.collider?[{...n,id:e+"-collider",shape:t.shape}]:[]}function jh(t){if(t)return{activeRegionIds:Array.from(t.activeRegionIds),regionIds:Array.from(t.regionIds),charges:{...t.charges},attributes:{...t.attributes},energy:t.energy}}function Yh(t,e){const n="function"==typeof t?t(e):t;if(!n)return null;const i=Number(n.x??0),o=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(o)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(o)?o:0}:null}function qh(t){if(!1===t.semanticItem)return null;const e=t.shape,n=t.semanticItem??{},i="aabb"===e.type?{id:t.id,label:t.label??t.id,description:t.description,group:t.kind??"region",x:e.x,y:e.y,width:e.width,height:e.height}:{id:t.id,label:t.label??t.id,description:t.description,group:t.kind??"region",x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,pathData:`M ${e.x1} ${e.y1} L ${e.x2} ${e.y2}`};return{...i,...n,id:n.id??i.id}}function Hh(t){return t.some(t=>null!=t.force||null!=t.damping||null!=t.impulseOnEnter||null!=t.impulseOnExit)}function Xh(t,e){const n="function"==typeof t?t(e):t;if(!n)return null;const i=Number(n.x??0),o=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(o)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(o)?o:0}:null}var Gh=[];function Vh(t){const e=t.store.controls(),n=t.store.snapshot(),i=Math.max(0,t.result.steps*(n.config.fixedDt||1/60)),o=function(t,e,n,i){const o=Number.isFinite(i)?Math.max(0,i):0;if(0>=o||!Hh(e))return!1;const r=new Map(e.map(t=>[t.id,t])),s=t.readBodies();let a=!1;for(const e of s){const i=n.get(e.id);if(!i||!i.activeRegionIds.size)continue;const s=jh(i);if(s)for(const n of i.activeRegionIds){const i=r.get(n);if(!i)continue;const c=Yh(i.force,{body:e,region:i,regionState:s}),l=Number(i.damping??0),u=(c?.x??0)*o-(Number.isFinite(l)?e.vx*l*o:0),d=(c?.y??0)*o-(Number.isFinite(l)?e.vy*l*o:0);(u||d)&&(t.applyImpulse(e.id,u,d),a=!0)}}return a}(e,t.regionEffects,t.regionState,i),r=function(t,e,n,i,o,r){const s=Number.isFinite(r)?Math.max(0,r):0;if(0>=s||!e)return!1;const a=new Map(n.map(t=>[t.id,t])),c=t.readBodies();let l=!1;for(let n=0;c.length>n;n+=1){const r=c[n],u=i.get(r.id),d=jh(u);let h=Gh;if(u&&u.activeRegionIds.size>0){const t=[];for(const e of u.activeRegionIds){const n=a.get(e);n&&t.push(n)}h=t}const f=Xh(e,{body:r,bodies:c,index:n,regionState:d,regions:h,simulationState:o});if(!f)continue;const p=(f.x??0)*s,y=(f.y??0)*s;(p||y)&&(t.applyImpulse(r.id,p,y),l=!0)}return l}(e,t.bodyForces,t.regionEffects,t.regionState,n.simulationState,i);return t.composed&&t.composed.onTick(t.result,e,{dt:i,elapsed:t.result.elapsedSeconds,getRegionState:e=>jh(t.regionState.get(e))}),t.onTick?.(t.result,e),{regionEffectsApplied:o,bodyForcesApplied:r,snapshot:n}}function Uh(t,e,n,i,o,r,s,a,c,l){const u=function(t,e){return!!e?.isActive&&(e.predicate?.(t)??!0)}(t,o),d={selected:u,simulationState:e,regionState:r,regions:s},h="function"==typeof n?n(t,d):n,f=s.reduce((e,n)=>n.bodyStyle?{...e,..."function"==typeof n.bodyStyle?n.bodyStyle(t,d):n.bodyStyle}:e,{}),p=u?"function"==typeof i?i(t,d):i:void 0;return{fill:l?.color??a,stroke:l?.stroke??c,strokeWidth:l?.strokeWidth??1,opacity:l?.opacity??.9,...h,...f,...p}}import*as Kh from"react";import{jsx as Zh,jsxs as Qh}from"react/jsx-runtime";var Jh={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},tf="semiotic-accessible-data-table",ef=tf+" semiotic-accessible-data-table-hidden",nf=tf+" semiotic-accessible-data-table-visible",of={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"},rf={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},sf={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)"},af={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},cf={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))"},lf={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},uf={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},df={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 hf(t){return null==t?null:"string"==typeof t||"number"==typeof t||"boolean"==typeof t?t+"":null}function ff(t){return{__semioticHoverData:!0,body:t,data:t.datum??t,id:t.id,type:"body",x:t.x,y:t.y}}function pf(t){if("circle"===t.shape.type){const e=Math.max(4,2*t.shape.radius);return{height:e,shape:"circle",width:e}}return{height:t.shape.height,shape:"rect",width:t.shape.width}}function yf(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t+""}return t.id}function gf(t){const e=mf(t.datum??t);return e.length?e.map(([t,e])=>`${t}: ${e}`).join(", "):"Physics body "+t.id}function mf(t){return t&&"object"==typeof t?Object.entries(t).map(([t,e])=>{if(t.startsWith("_"))return null;const n=hf(e);return null==n?null:[t,n]}).filter(t=>null!=t).slice(0,8):[]}function xf({hover:t}){const e=mf(t.data);return Qh("div",{className:"semiotic-tooltip",style:N,children:[Zh("div",{style:{fontWeight:700,marginBottom:e.length?4:0},children:t.id}),e.map(([t,e])=>Qh("div",{children:[Qh("span",{style:{opacity:.72},children:[t,": "]}),Zh("span",{children:e})]},t))]})}function bf(t){return t.datum&&"object"==typeof t.datum?Object.entries(t.datum).map(([t,e])=>{const n=hf(e);return null==n?null:`${t}: ${n}`}).filter(t=>null!=t).slice(0,8).join(", "):""}function vf(t){const e=[`${t.length} semantic item${1===t.length?"":"s"}.`],n=new Map;for(const e of t)e.group&&n.set(e.group,(n.get(e.group)??0)+1);return n.size&&e.push(Array.from(n).map(([t,e])=>`${t}: ${e}`).join(", ")),e.join(" ")}function wf(t){const{chartTitle:e,items:n,tableId:i}=t,[o,r]=Kh.useState(!1),[s,a]=Kh.useState(5),c=ys(),l=c?.visible??!1,u=o||l,d=Kh.useRef(null),h="Data summary for "+(e??"physics chart");Kh.useEffect(()=>{u||a(5)},[u]);const f=Kh.useCallback(t=>{t.target===t.currentTarget&&(o||l||r(!0))},[o,l]),p=Kh.useCallback(t=>{l||d.current?.contains(t.relatedTarget)||r(!1)},[l]);if(!n.length)return Zh("span",{id:i,tabIndex:-1,style:Jh});if(!u)return Zh("div",{id:i,className:ef,role:"region","aria-label":h,tabIndex:-1,style:Jh,onFocus:f,children:Qh("button",{type:"button",onClick:()=>r(!0),children:["View data summary (",n.length," semantic items)"]})});const y=Math.min(s,n.length),g=n.slice(0,y),m=n.length-y;return Qh("div",{ref:d,id:i,className:nf,role:"region","aria-label":h,tabIndex:-1,onBlur:p,style:of,children:[Zh("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),r(!1)},style:sf,children:"×"}),Zh("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:rf,children:vf(n)}),Qh("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(e??"physics chart"),style:af,children:[Zh("caption",{className:"semiotic-accessible-data-table-caption",style:uf,children:m>0?`First ${y} of ${n.length} semantic items`:`All ${n.length} semantic items`}),Zh("thead",{children:Qh("tr",{children:[Zh("th",{scope:"col",style:cf,children:"Item"}),Zh("th",{scope:"col",style:cf,children:"Description"}),Zh("th",{scope:"col",style:cf,children:"Group"}),Zh("th",{scope:"col",style:cf,children:"Position"}),Zh("th",{scope:"col",style:cf,children:"Data"})]})}),Zh("tbody",{children:g.map((t,e)=>Qh("tr",{children:[Zh("th",{scope:"row",style:lf,children:t.label}),Zh("td",{style:lf,children:t.description??t.label}),Zh("td",{style:lf,children:t.group??""}),Qh("td",{style:lf,children:[Math.round(t.x),", ",Math.round(t.y)]}),Zh("td",{style:lf,children:bf(t)})]},t.id??`${t.label}-${e}`))})]}),m>0?Qh("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(t=>t+25),style:df,children:["Show ",Math.min(25,m)," more"," ",1===m?"row":"rows"," (",m," remaining)"]}):null]})}xf.ownsChrome=!0;import{jsx as kf,jsxs as Sf}from"react/jsx-runtime";var Af=[640,360],Mf={top:0,right:0,bottom:0,left:0},Pf=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function _f(t,e,n){const i=new hd(t);return e?.length&&i.enqueue(e,n),i}var If="StreamPhysicsFrame";function Cf(){return"undefined"!=typeof performance?performance.now():Date.now()}var Tf=Bd(Ed(function(t,e){const{accessibleTable:n=!0,annotations:i,autoPlaceAnnotations:o,background:r,backgroundGraphics:s,bodySemanticItemLimit:a=200,bodySemanticItems:c=!1,bodySemanticUpdateMs:l=200,bodyForces:u,bodyStyle:d,chartId:h,className:f,frameScheduler:p,clock:y,color:g,config:m,controllers:x,continuous:b=!1,description:v,emphasis:w,chartMode:k,enableHover:S=!0,foregroundGraphics:A,hoverRadius:M=16,initialSpawns:P,initialSpawnPacing:_,legend:I,legendClickBehavior:C,legendHighlightedCategory:T,legendHoverBehavior:R,legendIsolatedCategories:L,legendLayout:$,legendPosition:z,margin:D,onClick:E,onObservation:B,onRegionEvent:F,onSimulationExecutionChange:N,onBodyHover:O,onBodyPointerDown:W,onSemanticItemActivate:j,onSemanticItemFocus:Y,onTick:q,opacity:H,paused:X=!1,regionEffects:G=[],responsiveHeight:V,responsiveWidth:U,selectedBodyStyle:K={stroke:"#111827",strokeWidth:2,opacity:1},selection:Z,semanticItems:Q=[],simulationExecution:J="auto",size:tt=Af,stroke:et,strokeWidth:nt,summary:it,suspendWhenHidden:ot=!0,svgAnnotationRules:rt,title:st,tooltipContent:at,workerBodyThreshold:ct=uh,renderBody:lt,beforePaint:ut,afterPaint:dt}=t,ht=Dd.useMemo(()=>({color:g,stroke:et,strokeWidth:nt,opacity:H}),[g,H,et,nt]),ft=jd(B);ft.current=B;const pt=jd(h);pt.current=h;const yt=jd(new Map),gt=jd(G);gt.current=G;const mt=jd(u);mt.current=u;const xt=jd(q);xt.current=q;const bt=Dd.useMemo(()=>function(t){if(!t?.length)return null;const e=t.slice(),n=e.some(t=>!1!==t.continuous);return{controllers:e,continuous:n,onTick:(t,n,i)=>{const o={result:t,controls:n,dt:i.dt,elapsed:i.elapsed,getRegionState:i.getRegionState};for(const t of e)t.tick(o)},bodyForce:t=>{let n=null;for(const i of e)i.bodyForce&&(n=zh(n,i.bodyForce(t)));return n}}}(x),[x]),vt=jd(bt);vt.current=bt;const wt=b||!!bt?.continuous,kt=jd(wt);kt.current=wt;const St=Dd.useMemo(()=>{if(!u&&!bt?.bodyForce)return u;if(!bt?.bodyForce)return u;if(!u)return bt.bodyForce;const t=bt.bodyForce;return e=>{const n="function"==typeof u?u(e):u,i="function"==typeof t?t(e):t;return n||i?{x:(n?.x??0)+(i?.x??0),y:(n?.y??0)+(i?.y??0)}:null}},[u,bt]);mt.current=St;const At=Dd.useMemo(()=>new Map(G.map(t=>[Oh(t),t])),[G]),Mt=Dd.useMemo(()=>new Map(G.map(t=>[t.id,t])),[G]),Pt=Dd.useMemo(()=>G.map(qh).filter(t=>null!=t),[G]),[_t,It]=Dd.useState([]),Ct=Dd.useMemo(()=>_t.length||Pt.length?[...Q,..._t,...Pt]:Q,[_t,Pt,Q]),Tt=Dd.useMemo(()=>Hh(G),[G]),Rt=!!St,Lt=jd(null),$t=jd(y??Cf);$t.current=y??Cf;const zt=Fd((t,e,n)=>{const i=Lt.current;if(!i||!n)return!1;const o=i.readBodies().find(e=>e.id===t),r=jh(yt.current.get(t));if(!o||!r)return!1;const s=Yh(n,{body:o,region:e,regionState:r});return!(!s||!s.x&&!s.y||(i.applyImpulse(t,s.x??0,s.y??0),0))},[]),Dt=Fd((t,e,n)=>{if(!n.bodyId)return;const i=jh(yt.current.get(n.bodyId));if(!i)return;const o={bodyId:n.bodyId,datum:n.datum,observation:n,region:e,regionState:i,type:t};"region-enter"===t?e.onEnter?.(o):e.onExit?.(o),F?.(o)},[F]),Et=Fd(t=>{const e=t.sensorId?At.get(t.sensorId):void 0;if(!e||!t.bodyId)return;const n=function(t,e){let n=t.get(e);return n||(n={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},t.set(e,n)),n}(yt.current,t.bodyId),i=Lt.current?.readBodies().find(e=>e.id===t.bodyId),o=jh(n),r=i&&o?{body:i,region:e,regionState:o}:null;if("physics-proximity-enter"===t.type){if(n.activeRegionIds.add(e.id),n.regionIds.add(e.id),n.energy+=e.energyDelta??0,r){!function(t,e,n){const i="function"==typeof t.attributes?t.attributes(e):t.attributes;i&&(n.attributes={...n.attributes,...i})}(e,r,n);const t=function(t,e){return void 0!==t.charge?"function"==typeof t.charge?t.charge(e):t.charge:"charge-gate"===t.kind?1:void 0}(e,r);void 0!==t&&(n.charges[e.id]=t)}zt(t.bodyId,e,e.impulseOnEnter),Dt("region-enter",e,t)}else"physics-proximity-exit"===t.type&&(n.activeRegionIds.delete(e.id),zt(t.bodyId,e,e.impulseOnExit),Dt("region-exit",e,t))},[zt,Dt,At]),Bt=Dd.useMemo(()=>{if(!i?.length)return[];const t=i.filter(t=>"barrier"===t.physics||"sensor"===t.physics);return t.length?function(t=[],e={}){const n=e.idPrefix?e.idPrefix+"-":"",i=[];for(const o of t){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;const t=o.axis??e.defaultAxis??"x",r=lh(o,e),s=o.colliderId??`${n}${o.id}`;let a;if("x"===t){const t=ch(o.x),n=ch(o.y1)??ch(e.plotBounds?.y)??ch(o.y),i=ch(o.y2)??(e.plotBounds?e.plotBounds.y+e.plotBounds.height:void 0)??ch(o.y);if(null==t||null==n||null==i)continue;a={type:"segment",x1:t,y1:n,x2:t,y2:i,thickness:r}}else{const t=ch(o.y),n=ch(o.x1)??ch(e.plotBounds?.x)??ch(o.x),i=ch(o.x2)??(e.plotBounds?e.plotBounds.x+e.plotBounds.width:void 0)??ch(o.x);if(null==t||null==n||null==i)continue;a={type:"segment",x1:n,y1:t,x2:i,y2:t,thickness:r}}i.push({id:s,shape:a,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==e.barrierRestitution?{}:{restitution:ch(o.restitution)??ch(e.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==e.barrierFriction?{}:{friction:ch(o.friction)??ch(e.barrierFriction)}})}return i}(t,{idPrefix:h?h+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:tt?.[0]??Af[0],height:tt?.[1]??Af[1]}}):[]},[i,h,tt]),Ft=Dd.useMemo(()=>{const t=G.flatMap(t=>[{id:Oh(t),sensor:!0,shape:t.shape,bodyFilter:t.bodyFilter,friction:t.friction,restitution:t.restitution},...Wh(t)]),e=Object.fromEntries(G.map(t=>[Oh(t),{binId:t.binId??t.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),n=m?.observation,i=G.length>0;return i||t.length>0||Bt.length>0||null!=h||n?{...m,colliders:[...m?.colliders??[],...t,...Bt],observation:{...n,chartId:h??n?.chartId,chartType:n?.chartType??If,sensors:{...n?.sensors??{},...e},onObservation:t=>{i&&Et(t),n?.onObservation?.(t)}}}:m},[Bt,h,m,Et,G]);if(!Lt.current){const t=_f(Ft,P,_);t.setPaused(X),ot&&t.setVisible(Bh()),Lt.current=t}const Nt=jd(null),Ot=jd(-1),Wt=jd(null),jt=jd(!0),Yt=jd(""),qt=Wd().replace(/:/g,""),Ht=jd(!1),Xt=jd(!1),Gt=jd(0),Vt=jd(!1),Ut=jd(null),Kt=jd(!1),Zt=ra({sizeProp:tt,responsiveWidth:U,responsiveHeight:V,userMargin:D,marginDefault:Mf,foregroundGraphics:A,backgroundGraphics:s,frameScheduler:p}),{margin:Qt,rafRef:Jt,reducedMotionRef:te,renderFnRef:ee,cancelRender:ne,resolvedBackground:ie,resolvedForeground:oe,responsiveRef:re,scheduleRender:se,size:ae}=Zt,ce=Jr(),le=is(),[ue,de]=Dd.useState(null),[he,fe]=Dd.useState(null),pe=jd(null),ye=jd(0),ge=jd(new Map),me=qt+"-physics-live",xe=Fd((t,e,n=!1)=>{if(!c)return void It(t=>t.length?[]:t);const i=$t.current();if(!n&&l>0&&l>i-ye.current)return;ye.current=i;const o=function(t,e,n,i){if(!n)return[];const o=Math.max(0,Math.floor(i));if(!o)return[];const r=[];for(let i=0;t.length>i&&o>r.length;i+=1){const o=t[i],s="function"==typeof n?n(o,{index:i,simulationState:e}):void 0;if(!1===s)continue;const a=pf(o);r.push({datum:o.datum??o,description:gf(o),group:"body",label:yf(o),...a,...s??{},bodyId:s?.bodyId??o.id,id:s?.id??"body:"+o.id,x:s?.x??o.x,y:s?.y??o.y})}return r}(t,e,c,a);It(t=>function(t,e){if(t.length!==e.length)return!0;for(let n=0;t.length>n;n+=1){const i=t[n],o=e[n];if(i.id!==o.id||i.label!==o.label||i.description!==o.description||i.group!==o.group||i.bodyId!==o.bodyId||Math.round(i.x)!==Math.round(o.x)||Math.round(i.y)!==Math.round(o.y))return!0}return!1}(t,o)?o:t)},[a,c,l]),be=Fd(t=>{if(!Ct.length)return;const e=Math.max(0,Math.min(t,Ct.length-1));Ot.current=e;const n=Ct[e];if(pe.current=n.bodyId??null,de(n),Y?.(n),n.bodyId&&Lt.current){const t=Lt.current.readBodies().find(t=>t.id===n.bodyId);if(t){const e=ff(t);fe(e),O?.(t,e)}}},[Ct,O,Y]),ve=Fd(()=>{Ot.current=-1,pe.current=null,de(null),Y?.(null)},[Y]),we=Fd((t,e)=>{const n=ft.current;if(!n)return;const i=$t.current();n("hover"!==t&&"click"!==t?{type:t,timestamp:i,chartType:If,chartId:pt.current}:{type:t,datum:e?.datum??{},x:e?.x??0,y:e?.y??0,timestamp:i,chartType:If,chartId:pt.current})},[]),ke=Fd(()=>{fe(t=>t?(O?.(null,null),we("hover-end"),null):t)},[we,O]),Se=Fd(t=>{if(!S||!Lt.current)return;const e=t.currentTarget.getBoundingClientRect(),n=Lt.current.hitTest(t.clientX-e.left,t.clientY-e.top,M);if(!n)return void ke();const i=ff(n);fe(t=>t&&t.id===i.id&&t.x===i.x&&t.y===i.y?t:(O?.(n,i),we("hover",{datum:n.datum,x:n.x,y:n.y}),i))},[ke,we,S,M,O]),Ae=Fd(t=>{ve();const e=Lt.current,n=t.currentTarget.getBoundingClientRect(),i=t.clientX-n.left,o=t.clientY-n.top,r=e?e.hitTest(i,o,Math.max(16,M)):null;W?.(r,t),r?(we("click",{datum:r.datum,x:r.x,y:r.y}),E?.(r.datum??null,{x:r.x,y:r.y,body:r})):(we("click-end"),E?.(null,{x:i,y:o,body:null}),ke())},[ke,ve,we,M,W,E]);Nd(()=>{if(!Ct.length)return void ve();const t=Ot.current;if(Ct.length>t){if(t>=0){const e=Ct[t];if(pe.current=e.bodyId??null,de(t=>null!=t&&t.id===e.id&&Math.round(t.x)===Math.round(e.x)&&Math.round(t.y)===Math.round(e.y)?t:e),e.bodyId&&Lt.current){const t=Lt.current.readBodies().find(t=>t.id===e.bodyId);if(t){const e=ff(t);fe(t=>t?.id===e.id&&Math.round(t.x)===Math.round(e.x)&&Math.round(t.y)===Math.round(e.y)?t:e)}}}}else be(Ct.length-1)},[Ct,ve,be]),Nd(()=>{S||ke()},[ke,S]);const Me=Fd(t=>{if(!Ct.length)return;if("Escape"===t.key)return t.preventDefault(),void ve();if(("Enter"===t.key||" "===t.key)&&Ot.current>=0)return t.preventDefault(),void j?.(Ct[Ot.current]);if(!Pf.has(t.key))return;t.preventDefault();const e=Ot.current;if(0>e)return void be(0);const n=Math.max(1,Math.floor(.1*Ct.length));let i=e;"Home"===t.key?i=0:"End"===t.key?i=Ct.length-1:"PageDown"===t.key?i=Math.min(Ct.length-1,e+n):"PageUp"===t.key?i=Math.max(0,e-n):"ArrowRight"===t.key||"ArrowDown"===t.key?i=Math.min(Ct.length-1,e+1):"ArrowLeft"!==t.key&&"ArrowUp"!==t.key||(i=Math.max(0,e-1)),be(i)},[ve,be,j,Ct]),[Pe,_e]=Dd.useState([]),Ie=jd(0),Ce=!!i?.length&&i.some(t=>null!=t.pointId||null!=t.bodyId||"latest"===t.anchor),Te=Fd(()=>{const t=Nt.current,e=Lt.current;if(!t||!e)return;const n=aa(),i=sa(t,ae,Qt,n);if(!i)return;const o=function(t){const e=Jd(t,Vd),n=Jd(t,Hd),i=Jd(t,Qd),o=Jd(t,Ud),r=Jd(t,qd),s=Jd(t,Yd),a=Jd(t,Kd),c=Jd(t,Zd),l=Jd(t,Xd),u=Jd(t,Gd);return{annotationBackground:th(s,.94),annotationStroke:r,annotationText:a,background:s,border:r,closedWindowFill:th(n,.08),closedWindowStroke:th(n,.55),danger:n,focus:l,grid:u,gutterFill:th(c,.14),lateFill:i,openWindowFill:th(e,.07),openWindowStroke:th(e,.3),primary:e,selectedFill:i,selectedStroke:l,success:o,text:a,textSecondary:c,warning:i}}(i);i.clearRect(-Qt.left,-Qt.top,ae[0],ae[1]),s||"transparent"===r||(i.fillStyle=r??o.background,i.fillRect(-Qt.left,-Qt.top,ae[0],ae[1]));const a=e.snapshot(),c=e.readBodies();if(xe(c,a.simulationState),Ce){const t=$t.current();if(t-Ie.current>=100){Ie.current=t;const e=function(t){return t.map(t=>({pointId:t.id,x:t.x,y:t.y,r:Math.max(1,sh(t))}))}(c);_e(t=>t.length===e.length&&t.every((t,n)=>t.pointId===e[n].pointId&&Math.round(t.x)===Math.round(e[n].x)&&Math.round(t.y)===Math.round(e[n].y))?t:e)}}ut&&(i.save(),ut(i,c),i.restore());for(const t of c){const e=yt.current.get(t.id),n=e?Array.from(e.activeRegionIds).map(t=>Mt.get(t)).filter(t=>null!=t):[],r=Uh(t,a.simulationState,d,K,Z,jh(e),n,o.primary,o.text,ht);lt?(i.save(),lt(i,t,r),i.restore()):Fh(i,t,r)}dt&&(i.save(),dt(i,c),i.restore()),function(t,e,n){let i=!1;for(const[o,r]of e){const s=Math.min(1,Math.max(0,(n-r.startedAt)/r.durationMs));if(s>=1){e.delete(o);continue}i=!0;const a=1-Math.pow(1-s,3),{body:c}=r,l=r.radius+28*a,u=1-s;t.save(),t.globalAlpha*=u,t.strokeStyle=r.color,t.fillStyle=r.color,t.lineWidth=2.4*u+.4,t.beginPath(),t.arc(c.x,c.y,l,0,2*Math.PI),t.stroke(),t.globalAlpha*=.18,t.beginPath(),t.arc(c.x,c.y,.52*l,0,2*Math.PI),t.fill(),t.restore(),t.save(),t.globalAlpha*=u,t.strokeStyle=r.color,t.lineWidth=1.8;for(let e=0;8>e;e+=1){const n=e*(Math.PI/4)+1.4*s,i=r.radius+5+12*a,o=r.radius+12+34*a;t.beginPath(),t.moveTo(c.x+Math.cos(n)*i,c.y+Math.sin(n)*i),t.lineTo(c.x+Math.cos(n)*o,c.y+Math.sin(n)*o),t.stroke()}t.restore()}}(i,ge.current,$t.current()),jt.current=!1},[dt,r,s,ut,d,Qt,Ce,Mt,lt,K,Z,ht,xe,ae]),Re=Fd((t,e)=>{const n=Lt.current,i=`${J}:${t}:${e??""}`;Yt.current!==i&&(Yt.current=i,N?.({execution:t,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:e,requested:J}))},[N,J]),Le=Fd((t,e=!0)=>{Gt.current+=1,Ht.current=!1,Vt.current=!1,Kt.current=!1,Ut.current?.terminate(),Ut.current=null,e&&Re("sync",t)},[Re]),$e=Fd(()=>ce?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Tt?"runtime region effects require sync":Rt?"body forces require sync":bt?"physics controllers require sync":function(t){return!t||!t.engine&&hh(t.sediment)&&(!(e=t.colliders)||e.every(t=>{const e=t.bodyFilter;return!e||"function"!=typeof e}));var e}(Ft??{})?yh(_)?Xt.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[Ft,bt,Rt,Tt,ce,_]),ze=Fd(()=>{const t=Lt.current,e=$e();if(!t||e)return{reason:e,useWorker:!1};const n=t.liveBodyCount(),i=t.queueSize(),o=function(t,e,n=0,i=uh){return"sync"!==t&&("worker"===t||e+n>=i)}(J,n,i,ct);return{reason:o?"worker"===J?"forced worker":"body threshold":"below threshold",useWorker:o}},[J,ct,$e]),De=Fd(t=>{const e=Lt.current;return e&&t.snapshot?(e.restore(t.snapshot),jt.current=!0,e):e},[]),Ee=Fd((t,e=!0)=>{const n=De(t);if(!n)return;e&&q?.(t.result,n.controls()),Te();const i=n.snapshot();!t.result.shouldContinue&&ge.current.size<=0||i.paused||!i.visible||te.current||se()},[De,q,Te,te,se]),Be=Fd(t=>{Xt.current=!0,Le("worker failed: "+((t instanceof Error?t.message:t+"")||"unknown error"))},[Le]),Fe=Fd(()=>{const t=Lt.current;if(!t)return!1;const e=ze();if(!e.useWorker)return Ht.current||Kt.current?Le(e.reason??"sync fallback"):Re("sync",e.reason??"sync"),!1;if(Ht.current||Kt.current)return!0;const n=Ut.current??new xh;Ut.current=n,Kt.current=!0;const i=Gt.current+1;return Gt.current=i,n.initFromSnapshot(Ft??{},t.snapshot()).then(t=>{if(Gt.current!==i)return;Kt.current=!1,Ht.current=!0,Xt.current=!1,De(t),Re("worker",e.reason??"worker"),Te();const n=Lt.current?.snapshot();t.result.shouldContinue&&n&&!n.paused&&n.visible&&!te.current&&(Wt.current=null,se())}).catch(t=>{Gt.current===i&&Be(t)}),!0},[De,Ft,Be,Te,te,Re,se,Le,ze]),Ne=Fd(t=>"frame"===t.type||"removed"===t.type?t.frame:null,[]),Oe=Fd((t,e=!0)=>{const n=Ut.current;if(!n||!Ht.current)return;const i=Gt.current;n.request(t).then(t=>{if(Gt.current!==i)return;const n=Ne(t);n&&Ee(n,e)}).catch(Be)},[Ee,Ne,Be]),We=Fd(()=>{const t=Lt.current;if(!t)return;const e=Fe(),n=t.snapshot(),i=wt||Rt||Tt||!!bt;n.paused||!n.visible||!t.hasPendingWork()&&!i||te.current?ee.current():e&&Kt.current||(Wt.current=null,se())},[bt,wt,Rt,Tt,te,ee,se,Fe]),je=Fd(()=>{ne(),Jt.current=null;const t=Lt.current;if(!t)return;if(Ht.current&&Ut.current){if(Vt.current)return;let e=0;if(!te.current){const t=$t.current();e=null!==Wt.current?(t-Wt.current)/1e3:0,Wt.current=t}const n=Ut.current,i=Gt.current;return Vt.current=!0,void(te.current?n.settle():n.tick(e)).then(t=>{Vt.current=!1,Gt.current===i&&Ee(t)}).catch(n=>{if(Vt.current=!1,Gt.current!==i)return;Be(n);const o=te.current?t.settleWithObservations():t.tick(e);Vh({store:t,result:o,regionEffects:gt.current,regionState:yt.current,bodyForces:mt.current,composed:vt.current,onTick:xt.current}),Te()})}let e;if(te.current)e=t.settleWithObservations();else{const n=$t.current(),i=null!==Wt.current?(n-Wt.current)/1e3:0;Wt.current=n,e=t.tick(i)}const n=vt.current,{regionEffectsApplied:i,bodyForcesApplied:o,snapshot:r}=Vh({store:t,result:e,regionEffects:gt.current,regionState:yt.current,bodyForces:mt.current,composed:n,onTick:xt.current});Te(),(kt.current||e.shouldContinue||i||o||n||ge.current.size>0)&&!r.paused&&r.visible&&!te.current&&se()},[Ee,Be,Te,ne,se,te,Jt]);ee.current=je,os({hydrated:ce,wasHydratingFromSSR:le,storeRef:Lt,dirtyRef:jt,renderFnRef:ee,cancelRender:ne}),Nd(()=>{Xt.current=!1,(Ht.current||Kt.current)&&Le("config changed",!1),Lt.current?.updateConfig(Ft??{}),We()},[Ft,Le]),Nd(()=>{Xt.current=!1,We()},[ce,J,ct]),function({cancelRender:t,lastFrameTimeRef:e,paused:n,postWorkerCommand:i,requestRender:o,storeRef:r,suspendWhenHidden:s}){const a=Eh(i);a.current=i;const c=Eh(o);c.current=o,Dh(()=>{const i=r.current;i&&(i.setPaused(n),n&&(e.current=null,t()),a.current({type:"setPaused",paused:n},!1),c.current())},[t,n]),Dh(()=>{if(!s||"undefined"==typeof document)return;const n=()=>{const n=r.current;if(!n)return;const i=Bh();n.setVisible(i),i||(e.current=null,t()),a.current({type:"setVisible",visible:i},!1),c.current()};return n(),document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[t,s])}({cancelRender:ne,lastFrameTimeRef:Wt,paused:X,postWorkerCommand:Oe,requestRender:We,storeRef:Lt,suspendWhenHidden:ot}),Nd(()=>()=>Le("unmount",!1),[Le]),Nd(()=>{Te()},[Te]),Od(e,()=>({...Lt.current.controls(),applyImpulse:(t,e,n)=>{Lt.current.applyImpulse(t,e,n),Oe({type:"applyImpulse",id:t,ix:e,iy:n}),We()},clear:()=>{Lt.current.clear(),yt.current.clear(),ge.current.clear(),Oe({type:"clear"}),We()},clearRegionState:t=>{t?yt.current.delete(t):yt.current.clear(),We()},getData:()=>Lt.current.readBodies(),getRegionState:t=>t?jh(yt.current.get(t)):function(t){const e={};return t.forEach((t,n)=>{const i=jh(t);i&&(e[n]=i)}),e}(yt.current),getStore:()=>Lt.current,pause:()=>{Lt.current.setPaused(!0),Oe({type:"setPaused",paused:!0},!1),We()},push:(t,e)=>{Lt.current.enqueue(t,e),yh(e)?Oe({type:"enqueue",spawns:[t],pacing:e}):(Ht.current||Kt.current)&&Le("spawn pacing is not worker-cloneable"),We()},pushMany:(t,e)=>{Lt.current.enqueue(t,e),yh(e)?Oe({type:"enqueue",spawns:t,pacing:e}):(Ht.current||Kt.current)&&Le("spawn pacing is not worker-cloneable"),We()},popBodies:(t,e={})=>{const n=Lt.current,i=new Map(n.readBodies().map(t=>[t.id,t])),o=n.remove(t),r=$t.current();for(const t of o){const n=i.get(t);n&&(yt.current.delete(t),ge.current.set(t,{body:n,color:e.color??"#f59e0b",durationMs:Math.max(120,e.durationMs??520),radius:e.radius??Nh(n),startedAt:r}),pe.current===t&&(pe.current=null,de(null)),fe(e=>e?.id===t?null:e))}return o.length&&(Oe({type:"remove",ids:o}),We()),o},remove:t=>{const e=Lt.current.remove(t);for(const e of t)yt.current.delete(e);return Oe({type:"remove",ids:t}),We(),e},restore:t=>{Lt.current.restore(t),yt.current.clear(),ge.current.clear(),Oe({type:"restore",snapshot:t},!1),We()},resume:()=>{Lt.current.setPaused(!1),Oe({type:"setPaused",paused:!1},!1),We()},settle:t=>{const e=Lt.current.settle(t);return Oe({type:"settle",maxSteps:t}),We(),e},settleWithObservations:t=>{const e=Lt.current.settleWithObservations(t);return Oe({type:"settle",maxSteps:t}),We(),e},step:t=>{const e=Lt.current,n=e.tick(t);return Vh({store:e,result:n,regionEffects:gt.current,regionState:yt.current,bodyForces:mt.current,composed:vt.current,onTick:xt.current}),Oe({type:"tick",deltaSeconds:t}),Te(),n}}),[Te,Oe,We,Le]);const Ye=Xr||!ce&&le,qe=["stream-physics-frame",k?"stream-physics-frame--mode-"+k:null,w?"stream-physics-frame--emphasis-"+w:null,f].filter(Boolean).join(" "),He=v??("string"==typeof st?st:void 0)??"Physics chart",Xe=qt+"-physics-table",Ge=Math.max(1,ae[0]-Qt.left-Qt.right),Ve=Math.max(1,ae[1]-Qt.top-Qt.bottom),Ue=S&&he?at?at(he):kf(xf,{hover:he}):null,Ke=Ue&&he?kf(qs,{x:he.x-Qt.left,y:he.y-Qt.top,containerWidth:Math.max(1,ae[0]-Qt.left-Qt.right),containerHeight:Math.max(1,ae[1]-Qt.top-Qt.bottom),margin:Qt,className:"stream-physics-tooltip",children:Ue}):null;if(Ye){const t=Lt.current??_f(Ft,P,_),e="string"==typeof st?st:void 0,{svg:n}=_h(t,{width:ae[0],height:ae[1],title:e,description:v,background:"transparent"===r?void 0:r,className:"stream-physics-frame__svg",idPrefix:"physics-"+qt});return Sf("div",{ref:re,className:qe,"data-semiotic-mode":k,role:"img","aria-label":He,style:{width:ae[0],height:ae[1]},children:[kf(Es,{summary:it}),kf("div",{dangerouslySetInnerHTML:{__html:n}})]})}return Sf("div",{ref:re,className:qe,"data-semiotic-mode":k,role:"group","aria-label":He,"aria-describedby":ue?me:void 0,tabIndex:0,style:{position:"relative",width:ae[0],height:ae[1]},onKeyDown:Me,children:[n?kf(Bs,{tableId:Xe}):null,n?kf(wf,{chartTitle:"string"==typeof st?st:He,items:Ct,tableId:Xe}):null,kf(Es,{summary:it}),kf(Fs,{hoverPoint:he}),kf("div",{id:me,"aria-live":"polite","aria-atomic":"true",style:Jh,children:ue?ue.description??ue.label:""}),Sf("div",{role:"img","aria-label":He,style:{position:"relative",width:"100%",height:"100%"},children:[ie,kf("canvas",{ref:Nt,width:ae[0],height:ae[1],"aria-hidden":"true",onPointerDown:Ae,onPointerMove:S?Se:void 0,onPointerLeave:S?ke:void 0}),oe,kf(ah,{width:Ge,height:Ve,totalWidth:ae[0],totalHeight:ae[1],margin:Qt,title:st,legend:I,legendPosition:z,legendLayout:$,legendHoverBehavior:R,legendClickBehavior:C,legendHighlightedCategory:T,legendIsolatedCategories:L,pointNodes:Pe,annotations:i,autoPlaceAnnotations:o,svgAnnotationRules:rt}),kf(Ws,{active:null!=ue,hoverPoint:ue?{x:ue.x,y:ue.y}:null,margin:Qt,size:ae,shape:ue?.shape,width:ue?.width,height:ue?.height,pathData:ue?.pathData}),Ke]})]})}));Tf.displayName="StreamPhysicsFrame";var Rf=Tf;import{useImperativeHandle as Lf,useRef as $f}from"react";function zf(t,e){if(!e?.length)return[t];const n=e.filter(e=>{if(e.id===t||e.id.startsWith(t+"-"))return!0;const n=e.datum;return!(!n||"object"!=typeof n||null==n.id)&&n.id+""===t}).map(t=>t.id);return n.length?n:[t]}function Df(t,e,n){if("function"==typeof n)return n(t,e)+"";if("string"==typeof n){const e=t[n];if(null!=e)return e+""}return null!=t&&"object"==typeof t&&"id"in t&&null!=t.id?t.id+"":"physics-row-"+e}function Ef(t,e){const n=t?.getData().find(t=>t.id===e),i=n?.datum;if(i&&"object"==typeof i)return i}import{useMemo as Bf}from"react";import{Fragment as Ff,jsx as Nf,jsxs as Of}from"react/jsx-runtime";var Wf=new Set(["sample","mechanical"]);function jf(t,e,n){const i=n?.hasSimulationMode?function(t){const e=t=>"string"==typeof t&&Wf.has(t);return t.simulationMode?{chartMode:e(t.mode)?void 0:t.mode,simulationMode:t.simulationMode}:e(t.mode)?{chartMode:void 0,simulationMode:t.mode}:{chartMode:t.mode,simulationMode:"sample"}}({mode:t.mode,simulationMode:t.simulationMode}):{chartMode:"sample"===t.mode||"mechanical"===t.mode?void 0:t.mode,simulationMode:"sample"},o=Kc(i.chartMode,{width:t.width,height:t.height,enableHover:t.enableHover,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:e[0],height:e[1]}),r=t.size?.[0],s=t.size?.[1],a=e[0],c=e[1],l=Bf(()=>{return t=[a,c],(null!=r&&null!=s?[r,s]:void 0)??[o.width??t[0],o.height??t[1]];var t},[c,a,o.height,o.width,s,r]),u=o.compactMode?"sparkline"===i.chartMode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0};const d=t.showProjection??!o.compactMode,h=t.showChrome??!o.compactMode,f=Xf(t.tooltip,void 0),p=void 0!==f.enableHover?f.enableHover:o.enableHover,y=o.compactMode?o.title:o.title??t.title,g=[t.className,i.chartMode&&"primary"!==i.chartMode?"semiotic-physics--"+i.chartMode:null].filter(Boolean).join(" ")||void 0;return{chartMode:i.chartMode,simulationMode:i.simulationMode,resolved:o,chartSize:l,margin:u,showProjection:d,showChrome:h,enableHover:p,title:y,description:o.description??t.description,summary:o.summary??t.summary,accessibleTable:o.accessibleTable??t.accessibleTable,className:g,compactMode:o.compactMode,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics}}function Yf(t){const[e,n]=t.size;return ll(t.loading,e,n,t.loadingContent)||cl(t.data,e,n,t.emptyContent)}function qf(t,e,n){return Nf(rl,{componentName:t,width:e[0],height:e[1],children:n})}function Hf(t,e){return t?e?n=>Of(Ff,{children:["function"==typeof t?t(n):t,"function"==typeof e?e(n):e]}):t:e}function Xf(t,e){return!1===t?{enableHover:!1}:{enableHover:e?.enableHover,tooltipContent:Y(t)||e?.tooltipContent}}function Gf(t,e,n,i){return{accessibleTable:i?.accessibleTable??t.accessibleTable??e?.accessibleTable,annotations:t.annotations??e?.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations??e?.autoPlaceAnnotations,background:t.background??e?.background,chartId:t.chartId??e?.chartId,chartMode:i?.chartMode??e?.chartMode,className:i?.className??t.className??e?.className,color:t.color??e?.color,description:i?.description??t.description??e?.description,emphasis:t.emphasis??e?.emphasis,enableHover:i?.enableHover??e?.enableHover,hoverRadius:t.hoverRadius??e?.hoverRadius,legend:t.legend??e?.legend,legendLayout:t.legendLayout??e?.legendLayout,legendPosition:t.legendPosition??e?.legendPosition,margin:i?.margin??e?.margin,onClick:null!=t.onClick?(e,n)=>{t.onClick?.(e,{x:n.x,y:n.y})}:e?.onClick,onObservation:t.onObservation??e?.onObservation,opacity:t.opacity??e?.opacity,semanticItems:e?.semanticItems??n,stroke:t.stroke??e?.stroke,strokeWidth:t.strokeWidth??e?.strokeWidth,summary:i?.summary??t.summary??e?.summary,svgAnnotationRules:t.svgAnnotationRules??e?.svgAnnotationRules,title:i?.title??t.title??e?.title}}import{jsx as Vf}from"react/jsx-runtime";function Uf(t,e){const n=e.config??{},i=(e.sensors??[]).map(t=>({...t,sensor:!0})),o=[...e.colliders??[],...i],r=[...t.colliders??[],...n.colliders??[],...o];return{...t,...n,observation:{...t.observation,...n.observation},...r.length>0&&{colliders:r}}}function Kf(t){const e=function(t,e,n){const i=t?.observation;return{...t,observation:{...i,chartId:e??i?.chartId??"physics-custom",chartType:i?.chartType??"PhysicsCustomChart",onObservation:n??i?.onObservation}}}(t.config,t.chartId,t.onObservation),n=$d(t.colorScheme,t.themeCategorical,s),i=Kl(t.size),o={data:t.data,scales:{x:Ld().domain(t.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:Ld().domain(t.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:t.semantic,categorical:[...n]},resolveColor:zd(n,t.colorScheme),config:t.layoutConfig??{},world:new hd(e)},r=t.skipLayout?{}:t.layout(o)??{},a=function(t,e){if(!e?.length)return t;const n=new Map;for(const t of e){const{bodyId:e,...i}=t,o=n.get(e)??[];o.push(i),n.set(e,o)}return t.map(t=>{const e=n.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Uf(e,r),context:o,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:a,result:r}}Id(function(t,e){const{chartId:n,color:i,colorBy:o,colorScheme:r,config:s,controllers:a,data:c,emptyContent:l,frameProps:u={},layout:d,layoutConfig:h,loading:f,loadingContent:p,onObservation:y,opacity:g,paused:m,spawnDatum:x,stroke:b,strokeWidth:v,title:w,xExtent:k,yExtent:S}=t,A=jf(t,[700,380]),{chartSize:M,className:P,title:_,chartMode:C,margin:T,enableHover:R,description:L,summary:$,accessibleTable:z}=A,D=Rd(null),E=Rd(null),B=Rd(""),F=Yf({data:c,emptyContent:l,loading:f,loadingContent:p,size:M}),N=null!=F,O=Td(()=>I(c??[]),[c]),W=Ot(t=>t.theme),j=Td(()=>Lt(W)??{},[W]),Y=W?.colors?.categorical??Dt.colors.categorical,q=Td(()=>[M[0],M[1],O.length,O.map((t,e)=>(t.id??e)+"").join("|"),k?.join(",")??"",S?.join(",")??""].join("::"),[M,O,k,S]),H=Td(()=>Kf({chartId:n,colorScheme:r,config:s,data:O,layout:d,layoutConfig:h,onObservation:y,semantic:j,skipLayout:N,size:M,themeCategorical:Y,xExtent:k,yExtent:S}),[n,M,r,s,d,h,y,O,j,N,Y,k,S]);B.current===q&&null!=E.current||(B.current=q,E.current=H.initialSpawns);const X=E.current,G=Td(()=>{const t=[...H.result.controllers??[],...a??[],...u.controllers??[]];return t.length?t:void 0},[u.controllers,a,H.result.controllers]),V=Td(()=>{const t=[...H.result.regionEffects??[],...u.regionEffects??[]];return t.length?t:void 0},[u.regionEffects,H.result.regionEffects]),U=Cd(t=>{const e=t.datum,n=e&&o?function(t,e,n){return"function"==typeof n?n(t,0):t[n]}(e,0,o)+"":t.id;return{fill:i??H.context.resolveColor(n,e),stroke:b??"#111827",strokeWidth:v??1,opacity:g??.9}},[i,o,g,H.context,b,v]);!function(t,e){const{frameRef:n,spawnDatum:i,seedRows:o,idAccessor:r,bodyIdsForSeed:s,seedSpawns:a}=e,c=$f(new Map),l=$f(new Map),u=$f(""),d=o?o.map((t,e)=>Df(t,e,r)).join("\0"):"";if(d!==u.current&&(u.current=d,o))for(let t=0;o.length>t;t+=1){const e=o[t],n=Df(e,t,r);c.current.set(n,e),l.current.set(n,s?.(e,n,t)??zf(n,a))}Lf(t,()=>{const t=c.current,e=l.current;function o(t,e){const n=i(t,e);return{datumId:n.datumId||Df(t,e,r),spawns:n.spawns.map(t=>({...t,spawnAt:void 0}))}}function s(i){const o=[];for(const{datum:n,result:r}of i)t.set(r.datumId,n),e.set(r.datumId,r.spawns.map(t=>t.id)),o.push(...r.spawns);if(!o.length)return;const r=n.current;r?(r.pushMany(o),r.step(0)):"production"!==process.env.NODE_ENV&&console.warn("[semiotic/physics] push() called before the physics frame mounted (loading/empty early-return). Omit data for push mode and ensure the chart is mounted.")}function a(i){const o=t.get(i);if(o)return o;const r=e.get(i)??[i];for(const o of r){const r=Ef(n.current,o);if(r)return t.set(i,r),e.has(i)||e.set(i,[o]),r}}return{push:e=>{s([{datum:e,result:o(e,t.size)}])},pushMany:e=>{const n=t.size;s(e.map((t,e)=>({datum:t,result:o(t,n+e)})))},remove:i=>{const o=Array.isArray(i)?i:[i],r=[],s=[];for(const n of o){const i=a(n);i&&r.push(i),t.delete(n),s.push(...e.get(n)??[n]),e.delete(n)}return s.length&&n.current?.remove(s),r},update:(i,r)=>{const c=Array.isArray(i)?i:[i],l=[];for(const i of c){const c=a(i);if(!c)continue;l.push(c);const u=e.get(i)??[i];n.current?.remove(u),t.delete(i),e.delete(i);const d=r(c);s([{datum:d,result:o(d,t.size)}])}return l},clear:()=>{t.clear(),e.clear(),u.current="",n.current?.clear()},getData:()=>{const e=n.current;if(!e)return Array.from(t.values());const i=e.getData().map(t=>t.datum).filter(t=>!!t&&"object"==typeof t);return i.length?i:Array.from(t.values())},getScales:()=>null,getCustomLayout:()=>n.current?.snapshot()??null,popBodies:(t,e)=>n.current?.popBodies(t,e)??[]}},[s,n,r,i])}(e,{frameRef:D,spawnDatum:Cd((t,e)=>{const i=t;if(x)return function(t,e,n){return Array.isArray(n)?{datumId:(t.id??n[0]?.id??"physics-custom-"+e)+"",spawns:n}:"spawns"in n?n:{datumId:(t.id??n.id??"physics-custom-"+e)+"",spawns:[n]}}(t,e,x(i,e,H.context));const o=Kf({chartId:n,colorScheme:r,config:s,data:[i],layout:d,layoutConfig:h,onObservation:y,semantic:j,size:M,themeCategorical:Y,xExtent:k,yExtent:S}),a=o.initialSpawns.length?o.initialSpawns:[{id:(t.id??"physics-custom-"+e)+"",x:o.context.dimensions.plot.x+o.context.dimensions.plot.width/2,y:o.context.dimensions.plot.y+12,mass:1,shape:{type:"circle",radius:5},datum:t}];return{datumId:(t.id??a[0].id)+"",spawns:a}},[n,M,r,s,x,d,h,y,H.context,j,Y,k,S]),seedRows:O,seedSpawns:X});const K=Cd((t,e)=>{u.onBodyPointerDown?.(t,e)},[u]);if(F)return F;const Z=Xf(t.tooltip,u),Q=Gf(t,u,H.result.semanticItems,{chartMode:C,className:P,title:_??w,description:L,summary:$,accessibleTable:z,enableHover:R,margin:T});return qf("PhysicsCustomChart",M,Vf(Rf,{...u,...Z,...Q,ref:D,backgroundGraphics:Hf(u.backgroundGraphics,H.result.backgroundOverlays),bodyForces:H.result.bodyForces??u.bodyForces,bodyStyle:H.result.bodyStyle??u.bodyStyle??U,config:H.config,controllers:G,foregroundGraphics:Hf(u.foregroundGraphics,H.result.overlays),initialSpawnPacing:H.initialSpawnPacing,initialSpawns:X,onBodyPointerDown:K,paused:m,regionEffects:V,responsiveHeight:t.responsiveHeight,responsiveWidth:t.responsiveWidth,selectedBodyStyle:H.result.selectedBodyStyle??u.selectedBodyStyle,size:M}))}).displayName="PhysicsCustomChart";import{forwardRef as Zf,useCallback as Qf,useEffect as Jf,useImperativeHandle as tp,useMemo as ep,useRef as np,useState as ip}from"react";var op="gauntlet-core",rp="gauntlet-positive",sp="gauntlet-negative";function ap(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 cp(t,e,n,i){return n?"function"==typeof n?n(t,e):t[n]??i:i}function lp(t){return t?.label??t?.id??"property"}function up(t){return`gauntlet:${t}:core`}function dp(t,e){return`gauntlet:${t}:positive:${e}`}function hp(t,e,n){return`gauntlet:${t}:negative:${e}:${n}`}function fp(t,e,n,i){const o=Math.max(2,n+2),r=80+o,s=i.floorY-o;return{x:Math.max(32+o,Math.min(i.width-30-4-o,t)),y:Math.max(r,Math.min(s,e))}}function pp(t,e,n){const[i,o]=t,r=Math.round(.48*o),s=o-36,a=(e??[]).filter(t=>!1!==t.enabled),c=Math.max(1,a.length),l=.22*i,u=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:s-n,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*i))})),graveyardX:Math.round(.84*i),graveyardY:s-4,height:o,routeY:r,socketX:Math.round(.92*i),startX:d,width:i}}function yp(t){return{graveyardX:t.graveyardX,graveyardY:t.graveyardY,routeY:t.routeY,socketX:t.socketX,socketY:t.routeY-4,startX:t.startX,startY:t.routeY}}function gp(t,e,n,i){const o=yp(n),r=i?.(t,e,n)??{};return{...o,...r,startY:r.startY??r.routeY??o.startY,socketY:r.socketY??r.routeY??o.socketY,graveyardY:r.graveyardY??o.graveyardY}}function mp(t,e){const n=[...t].sort((t,e)=>t.localeCompare(e)),i=Math.max(0,n.indexOf(e));return{angle:.82*-Math.PI+(n.length>1?i/(n.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function xp(t,e,n){const i=t.activePositiveIds.reduce((t,n)=>t+(e.get(n)?.value??1),0),o=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(n.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*r-1.2*t.delay-5*o))}function bp(t,e,n,i,o){const r=cp(t,e,n.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=i.map(t=>t.id),a=[...cp(t,e,n.positiveAccessor,s)],c=[...cp(t,e,n.negativeAccessor,[])].filter(t=>o.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...cp(t,e,n.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(cp(t,e,n.startTimeAccessor,0))||0),stage:"project filed",viability:cp(t,e,n.initialViability,100)}}function vp(t,e,n,i,o,r,s){const a=i.startX,c=i.startY+(i.startY===n.routeY?38*e:0),l=s?.(t,e,n,i)??{},u={__gauntlet:!0,kind:op,projectId:t.id,sourceDatum:t.datum},d=[{...l,id:up(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}],h=fp(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,n);d[0].x=h.x,d[0].y=h.y;for(const e of t.activePositiveIds){const i=o.get(e);if(!i)continue;const r=mp(t.activePositiveIds,e),s=i.radius??10,a=fp(h.x+Math.cos(r.angle)*r.radius,h.y+Math.sin(r.angle)*r.radius,s,n);d.push({id:dp(t.id,e),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:rp,projectId:t.id,property:i,sourceDatum:t.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:up(t.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...i.spring??{}}]})}return t.negativeIds.forEach((e,i)=>{const o=r.get(e);o&&d.push(wp(t,o,i,h.x,h.y,n,l.spawnAt??t.startedAt))}),d}function wp(t,e,n,i,o,r,s){const a=e.radius??7.2,c=fp(i-12+n%4*12,o+54+12*Math.floor(n/4),a,r);return{id:hp(t.id,e.id,n),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:sp,projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:up(t.id)},stiffness:.62,damping:.92,restLength:52+n%4*3,...e.spring??{}}]}}function kp(t){return t?Array.isArray(t)?[...t]:Object.entries(t).flatMap(([t,e])=>Array.from({length:Math.max(0,Math.round(Number(e)||0))},()=>t)):[]}function Sp(t,e){return e?Array.isArray(e)?[...e]:e.ids?[...e.ids]:e.candidates?e.candidates.filter(e=>t.includes(e)).slice(0,e.count??1):[]:[]}function Ap(t,e){return Sp(t.activePositiveIds,e.popPositive)}function Mp(t,e){const n=Sp(t.negativeIds,e.popNegative);if(!n.length)return[];const i=new Map;for(const t of n)i.set(t,(i.get(t)??0)+1);const o=[];return t.negativeIds.forEach((t,e)=>{const n=i.get(t)??0;n>0&&(o.push({propertyId:t,index:e}),i.set(t,n-1))}),o}function Pp(t,e,n){if(e.when&&!e.when(n))return t;let i={...t};const o=Ap(i,e);o.length&&(i={...i,activePositiveIds:i.activePositiveIds.filter(t=>!o.includes(t)),poppedPositiveIds:Array.from(new Set([...i.poppedPositiveIds,...o]))});const r=Mp(i,e);if(r.length){const t=new Set(r.map(t=>t.index));i={...i,negativeIds:i.negativeIds.filter((e,n)=>!t.has(n)),poppedNegativeIds:[...i.poppedNegativeIds,...r.map(t=>t.propertyId)]}}const s=kp(e.addPositive);s.length&&(i={...i,activePositiveIds:Array.from(new Set([...i.activePositiveIds,...s])),missingPositiveIds:i.missingPositiveIds.filter(t=>!s.includes(t))});const a=kp(e.addNegative);if(a.length&&(i={...i,negativeIds:[...i.negativeIds,...a]}),e.delayDelta&&(i={...i,delay:i.delay+e.delayDelta}),e.metricsDelta){const t={...i.metrics};for(const[n,i]of Object.entries(e.metricsDelta))t[n]=Number(t[n]??0)+i;i={...i,metrics:t}}return e.viabilityDelta&&(i={...i,viability:i.viability+e.viabilityDelta}),e.stage&&(i={...i,stage:e.stage}),e.outcome&&(i={...i,outcome:e.outcome}),i}function _p(t,e){return{id:t.id,label:t.label??t.id,summary:t.summary??e.find(t=>t.summary)?.summary,time:t.time}}function Ip(t,e){return t.eventsApplied.includes(e.id)?t:{...t,eventsApplied:[...t.eventsApplied,e.id],eventHistory:[...t.eventHistory??[],e],lastEvent:e,stage:e.label??t.stage}}function Cp(t,e){const n=t.datum;return!(!n?.__gauntlet||n.projectId!==e||n.kind!==sp)}function Tp(t){const e=t.id.slice(t.id.lastIndexOf(":")+1),n=Number(e);return Number.isFinite(n)?n:-1}import{jsx as Rp,jsxs as Lp}from"react/jsx-runtime";function $p(t){const e=t.data;return e?.__gauntlet?Lp("div",{className:"semiotic-tooltip",style:{background:"var(--semiotic-tooltip-bg, rgba(15, 23, 42, 0.94))",color:"var(--semiotic-tooltip-text, #f8fafc)",padding:"8px 12px",borderRadius:6,boxShadow:"var(--semiotic-tooltip-shadow, 0 8px 24px rgba(0,0,0,0.35))",maxWidth:280},children:[Rp("strong",{children:e.kind===op?"string"==typeof e.sourceDatum?.label?e.sourceDatum.label:e.projectId:lp(e.property)}),Rp("div",{children:e.kind===rp?"Positive property":e.kind===sp?"Negative property":"Project core"})]}):null}function zp(t,e,n){const i=e.datum;if(!i?.__gauntlet)return;const o="circle"===e.shape.type?e.shape.radius:8;if(t.save(),t.translate(e.x,e.y),i.kind===op)t.fillStyle=Dp(t,n.fill,"#0f766e"),t.strokeStyle=Dp(t,n.stroke,"#f8fafc"),t.lineWidth=2.4,t.beginPath(),t.arc(0,0,o,0,2*Math.PI),t.fill(),t.stroke();else{const e=i.property;t.fillStyle=Dp(t,n.fill??e?.color,"#38bdf8"),t.strokeStyle=Dp(t,n.stroke,"#0f172a"),t.lineWidth=1.1,t.beginPath(),i.kind===sp?t.rect(-o,-o,2*o,2*o):t.arc(0,0,o,0,2*Math.PI),t.fill(),t.stroke(),t.fillStyle=Dp(t,"var(--semiotic-background, #07111f)","#07111f"),t.font=`900 ${i.kind===sp?9:8}px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(e?.short??e?.id?.slice(0,1).toUpperCase()??"?",0,.5)}t.restore()}function Dp(t,e,n){if("string"!=typeof e)return n;if("function"!=typeof getComputedStyle||!t.canvas)return e||n;const i=e.startsWith("var(")?e.match(/var\((--[^,\s)]+)/)?.[1]:e.startsWith("--")?e:null;return i?getComputedStyle(t.canvas).getPropertyValue(i).trim()||n:e||n}function Ep({layout:t,states:e}){return Lp("svg",{"aria-hidden":"true",viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Rp("path",{d:`M ${t.startX-42} ${t.routeY} C ${.24*t.width} ${t.routeY-70}, ${.42*t.width} ${t.routeY+78}, ${.58*t.width} ${t.routeY} S ${.78*t.width} ${t.routeY-82}, ${t.socketX+36} ${t.routeY}`,fill:"none",stroke:"var(--semiotic-accent, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),Rp("line",{x1:Math.round(.06*t.width),x2:Math.round(.94*t.width),y1:t.crashY,y2:t.crashY,stroke:"var(--semiotic-negative, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),Rp("text",{x:Math.round(.07*t.width),y:t.crashY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),t.gates.map(e=>Lp("g",{children:[Rp("rect",{x:e.x-e.width/2,y:Math.max(80,t.routeY-180),width:e.width,height:Math.min(360,t.height-170),rx:12,fill:e.color??"var(--semiotic-accent, #38bdf8)",fillOpacity:.1,stroke:e.color??"var(--semiotic-accent, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),Rp("text",{x:e.x,y:Math.max(64,t.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:e.label??e.id})]},e.id)),Lp("g",{children:[Rp("rect",{x:t.socketX-52,y:t.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-positive, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-positive, #22c55e)",strokeWidth:1.5}),Rp("text",{x:t.socketX,y:t.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),Lp("g",{children:[Rp("rect",{x:t.graveyardX-82,y:t.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-negative, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-negative, #ef4444)",strokeOpacity:.7}),Rp("text",{x:t.graveyardX,y:t.graveyardY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),Rp("text",{x:t.graveyardX,y:t.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:e.some(t=>t.killed)?"lift shut off":"too heavy or too small"})]})]})}function Bp(t){const e=t.datum;return!!e?.__gauntlet&&(e.kind===op?{label:e.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${lp(e.property)} ${e.kind===rp?"positive":"negative"} property`,group:e.kind===rp?"positive property":"negative property",description:`${lp(e.property)} attached to ${e.projectId}.`})}function Fp({states:t,layout:e}){const n=function(t){return t.map(t=>({label:t.id,value:Math.max(0,Number(t.viability)||0),outcome:t.outcome||t.stage||"in-process"}))}(t);if(!n.length)return null;const i=Math.max(1,...n.map(t=>t.value)),o=Math.max(40,(e.width-80)/n.length);return Lp("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Rp("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),n.map((t,e)=>{const n=40+e*o,r=Math.max(2,t.value/i*28),s=/kill|crash|block|grave/i.test(t.outcome);return Lp("g",{children:[Rp("rect",{x:n+.18*o,y:28-r+22,width:Math.max(10,.45*o),height:r,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),Rp("text",{x:n+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:t.label})]},t.label)})]})}import{jsx as Np}from"react/jsx-runtime";import{createElement as Op}from"react";var Wp=[];function jp(t){return t.map(t=>({...t,spawnAt:void 0}))}Zf(function(t,e){const{bodyGroups:n,coreBody:i,coreForceMode:o="route",crashDetection:r=!0,crashOffset:s=30,data:a,emptyContent:c,events:l,frameProps:u={},gates:d,initialSpawnPacing:h,loading:f,loadingContent:p,negativeProperties:y,onCapacityChange:g,onClick:m,onStateChange:x,outcome:b,paused:v,positiveProperties:w=Wp,projectPlacement:k,responsiveHeight:S,responsiveWidth:A,showTethers:M=!0,terminalBehavior:P="outcome",viability:_}=t,C=np(null),T=ep(()=>({idAccessor:t.idAccessor,initialViability:t.initialViability,metricsAccessor:t.metricsAccessor,negativeAccessor:t.negativeAccessor,positiveAccessor:t.positiveAccessor,startTimeAccessor:t.startTimeAccessor}),[t.idAccessor,t.initialViability,t.metricsAccessor,t.negativeAccessor,t.positiveAccessor,t.startTimeAccessor]),R=jf(t,[900,520]),{chartSize:L,showProjection:$,showChrome:z,className:D,title:E,chartMode:B,margin:F,enableHover:N,description:O,summary:W,accessibleTable:j}=R,Y=Yf({data:a,emptyContent:c,loading:f,loadingContent:p,size:L}),q=ep(()=>I(a??[]),[a]),H=ep(()=>q.map((t,e)=>cp(t,e,T.idAccessor,null!=t.id?t.id+"":"project-"+e)+"").join("|"),[q,T.idAccessor]),X=ep(()=>new Map(w.map(t=>[t.id,t])),[w]),G=ep(()=>new Map(y.map(t=>[t.id,t])),[y]),V=ep(()=>pp(L,d,s),[L,s,d]),U=ep(()=>new Map(V.gates.map(t=>[t.id,t])),[V.gates]),K=ep(()=>V.gates.map(t=>({kind:"force-field",damping:.035,force:{x:12,y:0},semanticItem:!1,...t.regionEffect,id:"gauntlet-gate-"+t.id,label:t.label??t.id,description:t.description,bodyFilter:t.capacity?{property:"datum.kind",equals:op}:t.regionEffect?.bodyFilter,shape:{type:"aabb",x:t.x,y:V.routeY,width:t.capacity?t.capacity.sensorWidth??Math.max(96,6*t.width):Math.max(t.width,54),height:Math.min(360,V.height-170)}})),[V.gates,V.height,V.routeY]),[Z,Q]=ip(()=>q.map((t,e)=>{const n=bp(t,e,T,w,G);return{...n,viability:_?.(n,{negativeProperties:G,positiveProperties:X})??xp(n,X,G)}})),J=np(Z),tt=np(0),et=np(new Map),nt=np([]),it=np(g);it.current=g;const ot=ep(()=>function(t){const{dataKey:e,gates:n,statesRef:i,processedGateVisitsRef:o}=t;return n.flatMap(t=>t.capacity&&t.capacity.unitsPerSecond>0?[$h({id:`gauntlet-capacity-${e}-${t.id}`,regionId:"gauntlet-gate-"+t.id,unitsPerSecond:t.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:op},maxQueue:t.capacity.maxQueue,queueLayout:t.capacity.queueLayout,queueSlotSpacing:t.capacity.queueSlotSpacing,queueStiffness:t.capacity.queueStiffness??24,releaseImpulse:{x:36,y:0},unitAccessor:e=>{const n=e.datum,o=n?.sourceDatum,r=t.capacity?.unitAccessor,s=i.current.find(t=>t.id===n?.projectId);let a;"function"==typeof r?a=s?r(s):void 0:r&&(a=o?.[r]);const c=Number(a??o?.reviewWork??o?.work??s?.metrics.reviewWork??o?.points);return Number.isFinite(c)&&c>0?c:1},onProcessed:e=>{const n=e.datum;if(!n?.projectId)return;const i=`${n.projectId}:${t.id}`;o.current.set(i,(o.current.get(i)??0)+1)}})]:[])}({dataKey:H,gates:V.gates,statesRef:J,processedGateVisitsRef:et}),[H,V.gates]),rt=ep(()=>[...ot,...u.controllers??[]],[ot,u.controllers]),st=np(q);st.current=q;const at=np(x);at.current=x;const ct=np({negativeById:G,positiveById:X,positiveProperties:w,stateAccessors:T,viability:_});ct.current={negativeById:G,positiveById:X,positiveProperties:w,stateAccessors:T,viability:_};const lt=Qf((t,e,n=0)=>{const i=ct.current,o=bp(t,e,i.stateAccessors,i.positiveProperties,i.negativeById);return i.stateAccessors.startTimeAccessor||(o.startedAt=Math.max(0,n)),{...o,viability:i.viability?.(o,{negativeProperties:i.negativeById,positiveProperties:i.positiveById})??xp(o,i.positiveById,i.negativeById)}},[]);Jf(()=>{et.current.clear(),nt.current=[];const t=st.current.map((t,e)=>lt(t,e));J.current=t,Q(t)},[lt,H]),Jf(()=>{J.current=Z,at.current?.(Z)},[Z]);const ut=Qf(t=>[...("function"==typeof l?l(t,V):l)??[]].sort((t,e)=>t.time-e.time),[l,V]),dt=Qf((t,e,n)=>{if(!e.gateId||!U.get(e.gateId)?.capacity)return!0;const i=Number(e.gateVisit),o=Number.isFinite(i)&&i>0?Math.floor(i):n.filter(t=>t.gateId===e.gateId).findIndex(t=>t.id===e.id)+1;return o>0&&(et.current.get(`${t.id}:${e.gateId}`)??0)>=o},[U]),ht=Qf(()=>{if(!ot.length)return;const t=ot.flatMap(t=>{const e=t.getSnapshot?.();return e?[e]:[]});var e,n;(e=nt.current).length===(n=t).length&&e.every((t,e)=>{const i=n[e];return!!i&&t.regionId===i.regionId&&t.queueDepth===i.queueDepth&&t.blockedDepth===i.blockedDepth&&t.processedCount===i.processedCount&&t.metricRevision===i.metricRevision})||(nt.current=t,it.current?.(t))},[ot]),ft=ep(()=>Z.flatMap((t,e)=>{const n=gp(t,e,V,k);return vp(t,e,V,n,X,G,i)}),[i,V,G,X,k,Z]),pt=Qf((t,e)=>{let n=!1;const i=J.current.map(i=>{if(i.id!==t)return i;const o=e(i);return n=n||o!==i,o});n&&(J.current=i,Q(i))},[]);tp(e,()=>function(t){const{statesRef:e,setStates:n,elapsedRef:i,frameRef:o,layout:r,projectPlacement:s,positiveById:a,negativeById:c,coreBody:l,createState:u}=t;return{push:t=>{const d=u(t,e.current.length,i.current),h=gp(d,e.current.length,r,s),f=vp(d,e.current.length,r,h,a,c,l),p=[...e.current,d];e.current=p,n(p),o.current?.pushMany(f),o.current?.step(0)},pushMany:t=>{const d=[...e.current],h=[],f=i.current;t.forEach(t=>{const e=u(t,d.length,f),n=gp(e,d.length,r,s);h.push(...vp(e,d.length,r,n,a,c,l)),d.push(e)}),e.current=d,n(d),h.length&&o.current?.pushMany(h),o.current?.step(0)},remove:t=>{const i=Array.isArray(t)?t:[t],r=[],s=[];for(const t of i){const n=e.current.find(e=>e.id===t);n&&(r.push(n.datum),s.push(up(n.id),...n.activePositiveIds.map(t=>dp(n.id,t))),n.negativeIds.forEach((t,e)=>{s.push(hp(n.id,t,e))}))}return e.current=e.current.filter(t=>!i.includes(t.id)),n(e.current),o.current?.remove(s),r},update:(t,d)=>{const h=Array.isArray(t)?t:[t],f=[];for(const t of h){const n=e.current.find(e=>e.id===t);if(!n)continue;const h=e.current.findIndex(e=>e.id===t);f.push(n.datum);const p=d(n.datum),y=u(p,0>h?e.current.length:h,n.startedAt??i.current),g=gp(y,0>h?e.current.length:h,r,s);o.current?.remove([up(n.id),...n.activePositiveIds.map(t=>dp(n.id,t)),...n.negativeIds.map((t,e)=>hp(n.id,t,e))]),o.current?.pushMany(vp(y,0>h?e.current.length:h,r,g,a,c,l)),e.current=e.current.map(e=>e.id===t?y:e)}return n(e.current),f},clear:()=>{e.current=[],n([]),o.current?.clear()},getData:()=>e.current.map(t=>t.datum),getScales:()=>null,getCustomLayout:()=>o.current?.snapshot()??null,popBodies:(t,e)=>o.current?.popBodies(t,e)??[]}}({statesRef:J,setStates:Q,elapsedRef:tt,frameRef:C,layout:V,projectPlacement:k,positiveById:X,negativeById:G,coreBody:i,createState:lt}),[i,lt,V,G,X,k]);const yt=Qf((t,e,n)=>{!function(t){const{project:e,effect:n,controls:i,layout:o,positiveById:r,negativeById:s,coreBody:a,popBodies:c}=t,l=i.readBodies().find(t=>t.id===up(e.id)),u=i.readBodies(),d=l?.x??o.startX,h=l?.y??o.routeY,f=function(t,e){let n=-1;for(const i of e)Cp(i,t.id)&&(n=Math.max(n,Tp(i)));return Math.max(t.negativeIds.length,n+1)}(e,u),p=kp(n.addNegative).flatMap((t,n)=>{const i=s.get(t);return i?[wp(e,i,f+n,d,h,o)]:[]}),y=kp(n.addPositive).flatMap(t=>{if(!r.get(t)||e.activePositiveIds.includes(t))return[];const n={...yp(o),routeY:h,socketY:h,startX:d,startY:h};return vp({...e,activePositiveIds:[t],negativeIds:[]},0,o,n,r,s,a).filter(t=>t.id.includes(":positive:"))});(p.length||y.length)&&i.pushMany([...p,...y]);const g=Ap(e,n);for(const t of g){const n=r.get(t);c([dp(e.id,t)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3})}const m=Mp(e,n),x=function(t,e,n){const i=e.filter(e=>Cp(e,t.id)).sort((t,e)=>Tp(t)-Tp(e)||t.id.localeCompare(e.id)),o=new Set;return n.map(e=>{const n=i.find(t=>!o.has(t.id)&&t.datum.property?.id===e.propertyId);return n?(o.add(n.id),n.id):hp(t.id,e.propertyId,e.index)})}(e,u,m);m.forEach((t,e)=>{const n=s.get(t.propertyId);c([x[e]],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??7)+3})})}({project:t,effect:e,controls:n,layout:V,positiveById:X,negativeById:G,coreBody:i,popBodies:(t,e)=>C.current?.popBodies(t,e)})},[i,V,G,X]),gt=Qf(({body:t,bodies:e})=>function(t){const{body:e,bodies:n,layout:i,states:o,projectPlacement:r,positiveById:s,negativeById:a,projectEvents:c,gateById:l,coreForceMode:u,terminalBehavior:d,elapsed:h}=t,f=e.datum;if(!f?.__gauntlet)return null;const p=o.findIndex(t=>t.id===f.projectId),y=0>p?void 0:o[p];if(!y)return null;const g=gp(y,p,i,r),m=n.find(t=>t.id===up(y.id)),x=y.negativeIds.reduce((t,e)=>t+(a.get(e)?.load??1),0),b=y.killed?0:58;if(f.kind!==op){if(!m)return null;let t;const o=f.property;if(o?.target){const r=n.filter(t=>{const e=t.datum;return e?.__gauntlet&&e.projectId===y.id&&e.kind===f.kind}).sort((t,e)=>(t.id+"").localeCompare(e.id+"")),s=Math.max(0,r.findIndex(t=>t.id===e.id));t=o.target({body:e,bodies:n,core:m,index:s,layout:i,placement:g,project:y})??{x:m.x,y:m.y}}else if(f.kind===rp&&f.property){const e=mp(y.activePositiveIds,f.property.id);t={x:m.x+Math.cos(e.angle)*e.radius,y:m.y+Math.sin(e.angle)*e.radius-2}}else{const i=n.filter(t=>t.datum?.kind===sp&&t.datum.projectId===y.id).sort((t,e)=>(t.id+"").localeCompare(e.id+"")),o=Math.max(0,i.findIndex(t=>t.id===e.id)),r=Math.floor(o/4);t={x:m.x+18*(o%4-(Math.min(4,i.length-4*r)-1)/2),y:m.y+54+13*r}}const r="circle"===e.shape.type?e.shape.radius:8;t=fp(t.x,t.y,r,i);const s=fp(e.x,e.y,r,i);if(Math.abs(s.x-e.x)>.5||Math.abs(s.y-e.y)>.5)return{x:48*(s.x-e.x)-6*e.vx,y:48*(s.y-e.y)-6*e.vy};const a=f.kind!==rp||y.killed?0:3.2*(o?.buoyancy??o?.value??1),c=f.kind===sp?{x:.22*(o?.pull?.x??-8),y:.22*(o?.pull?.y??22)}:{x:0,y:0};return{x:28*(t.x-e.x)-3*(e.vx-m.vx)+c.x+.01*b,y:28*(t.y-e.y)-3*(e.vy-m.vy)+c.y-a}}if(y.killed)return{x:44*((y.crashX??y.metrics.lastX??e.x)-e.x)-9*e.vx,y:160+12*x-1.6*e.vy};const v=c(y),w=function(t,e,n,i,o,r,s){if(e.killed)return{x:e.metrics.lastX??i.graveyardX,y:i.graveyardY};const a=o[o.length-1];if(!a)return{x:i.socketX,y:i.routeY};const c=o.find(n=>t>=n.time&&!e.eventsApplied.includes(n.id)&&!(!n.gateId||!r.get(n.gateId)?.capacity)),l=c?Math.min(t,c.time):t,u="built"===e.outcome||"built_diminished"===e.outcome;if(l>a.time+.85){if("hold-last"===s){const t=a.gateId?r.get(a.gateId):void 0;return{x:a.routeX??t?.x??i.socketX,y:a.routeY??i.routeY}}return u?{x:i.socketX,y:i.socketY}:{x:i.graveyardX,y:i.graveyardY-14}}const d=.85*e.delay+12*e.negativeIds.length+8*(e.poppedPositiveIds.length+e.missingPositiveIds.length),h=[{time:0,x:i.startX,y:i.startY},...o.map(t=>{const e=t.gateId?r.get(t.gateId):void 0;return{time:t.time,x:t.routeX??e?.x??i.startX,y:t.routeY??i.routeY+.28*Math.min(180,d)}})].sort((t,e)=>t.time-e.time);let f=h[0],p=h[h.length-1];for(let t=1;h.length>t;t+=1){if(h[t].time>=l){p=h[t];break}f=h[t]}const y=Math.max(0,Math.min(1,(l-f.time)/Math.max(.1,p.time-f.time))),g=y*y*(3-2*y);return{x:f.x+(p.x-f.x)*g,y:f.y+(p.y-f.y)*g+7*Math.sin(2.6*l)}}(Math.max(0,h-(y.startedAt??0)),y,0,g,v,l,d),k=y.activePositiveIds.reduce((t,e)=>t+(s.get(e)?.buoyancy??s.get(e)?.value??1),0);return"net"===u?{x:15*(w.x-e.x)-1.8*e.vx+.18*b,y:1.25*(g.routeY-e.y)-1.4*e.vy+32*(x-k)}:{x:15*(w.x-e.x)-1.8*e.vx+.18*b,y:15*(w.y-e.y)-1.8*e.vy+13*x-2.2*k}}({body:t,bodies:e,layout:V,states:J.current,projectPlacement:k,positiveById:X,negativeById:G,projectEvents:ut,gateById:U,coreForceMode:o,terminalBehavior:P,elapsed:tt.current}),[o,U,V,G,X,ut,k,P]),mt=Qf((t,e)=>{!function(t,e,n){const{frameProps:i,elapsedRef:o,statesRef:r,crashDetection:s,layout:a,projectEvents:c,gateById:l,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:f,positiveById:p,negativeById:y,outcome:g,reportCapacity:m}=n;i.onTick?.(t,e),o.current=t.elapsedSeconds??e.snapshot().elapsedSeconds,m();for(const t of r.current){const n=e.readBodies().find(e=>e.id===up(t.id));if(!n)continue;if(s&&!t.killed&&n.y+("circle"===n.shape.type?n.shape.radius:28)>=a.crashY){e.readBodies().forEach(n=>{const i=n.datum;i?.__gauntlet&&i.projectId===t.id&&e.applyImpulse(n.id,-n.vx*n.mass,0)}),h(t.id,t=>{const e={appliedAt:Math.max(0,o.current-(t.startedAt??0)),id:"gauntlet-crash-line",label:"Crash Line",summary:"The project hit the crash threshold; lift and forward motion shut off.",time:Math.max(0,o.current-(t.startedAt??0))};return{...t,crashX:n.x,eventHistory:[...t.eventHistory??[],e],killed:!0,lastEvent:e,metrics:{...t.metrics,lastX:n.x},outcome:"bad_design_crash",stage:"Crash Line",viability:Math.min(0,t.viability)}});continue}if(t.killed)continue;const i=Math.max(0,o.current-(t.startedAt??0)),r=c(t),m=r.filter(e=>i>=e.time&&!t.eventsApplied.includes(e.id)&&u(t,e,r));let x=t;for(const n of m){const o=n.gateId?l.get(n.gateId):void 0,r=n.effects??[];for(const t of r){const i={event:n,gate:o,negativeProperties:y,positiveProperties:p,project:x};t.when&&!t.when(i)||(d(x,t,e),x=Pp(x,t,i))}const s={..._p(n,r),appliedAt:i};x=Ip(x,s),h(t.id,t=>{let e=Ip(t,s);if(e===t)return t;for(const t of r)e=Pp(e,t,{event:n,gate:o,negativeProperties:y,positiveProperties:p,project:e});const i=f?.(e,{negativeProperties:y,positiveProperties:p})??xp(e,p,y);return e={...e,viability:i},n.final&&(e={...e,outcome:n.outcome??g?.(e,{layout:a,negativeProperties:y,positiveProperties:p})??(e.viability>20?"built":"approved_not_built")}),e})}}}(t,e,{frameProps:u,elapsedRef:tt,statesRef:J,crashDetection:r,layout:V,projectEvents:ut,gateById:U,capacityEventReady:dt,addBodiesForEffect:yt,updateProjectState:pt,viability:_,positiveById:X,negativeById:G,outcome:b,reportCapacity:ht})},[yt,dt,r,u,U,V,G,b,X,ut,ht,pt,_]),xt=Qf((t,e)=>{const n="function"==typeof u.bodyStyle?u.bodyStyle(t,e):u.bodyStyle,i=t.datum;return i?.__gauntlet?{fill:i.kind===op?"var(--semiotic-accent, #0f766e)":i.property?.color??"var(--semiotic-accent, #38bdf8)",stroke:i.kind===op?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[u]),bt=ep(()=>"function"==typeof n?n(Z,V):n??[],[n,V,Z]),vt=ep(()=>bt.flatMap(t=>{if(!1===t.semanticItem)return[];const e=t.semanticItem??{},n={id:t.id,label:t.label??t.id,description:t.description,datum:t.datum,group:t.group??t.state??"body group",x:t.x??0,y:t.y??0,width:t.width,height:t.height};return[{...n,...e,id:e.id??n.id}]}),[bt]),wt=ep(()=>$?function(t,e){if(!t.length)return[];const n=Math.max(40,(e.width-80)/t.length);return t.map((t,e)=>{const i=`${t.id}: viability ${Math.round(t.viability)}, ${t.outcome||t.stage}`;return{id:"gauntlet-projection-"+t.id,label:i,description:i,datum:t,x:40+(e+.5)*n,y:28,shape:"rect",width:Math.max(16,.55*n),height:22,group:"settled projection"}})}(Z,V):[],[V,$,Z]),kt=ep(()=>[...wt,...vt],[vt,wt]),St=Qf((t,e)=>{u.onBodyPointerDown?.(t,e)},[u]),At=Qf((t,e)=>{m&&m(t&&"object"==typeof t&&t.__gauntlet?t.sourceDatum:t,{x:e.x,y:e.y})},[m]);if(Y)return Y;const Mt=Xf(t.tooltip,u),Pt=Gf(t,u,kt,{chartMode:B,className:D,title:E,description:O,summary:W,accessibleTable:j,enableHover:N,margin:F}),_t=$?Np(Fp,{states:Z,layout:V}):void 0,It=Hf(z?Np(Ep,{layout:V,states:Z}):void 0,u.backgroundGraphics),Ct=Hf(_t,u.foregroundGraphics),Tt=u.renderBody??zp,Rt=Mt.tooltipContent??$p;return qf("GauntletChart",L,Op(Rf,{...u,...Mt,...Pt,key:`${L[0]}x${L[1]}:${H}`,ref:C,accessibleTable:t.accessibleTable??u.accessibleTable,backgroundGraphics:It,bodyForces:gt,bodySemanticItems:u.bodySemanticItems??Bp,bodyStyle:xt,beforePaint:(t,e)=>{u.beforePaint?.(t,e),M&&function(t,e){const n=new Map(e.filter(t=>t.datum?.kind===op).map(t=>[t.datum.projectId,t]));t.save(),t.lineWidth=1.1,t.setLineDash([3,4]);for(const i of e){const e=i.datum;if(!e?.__gauntlet||e.kind===op)continue;const o=n.get(e.projectId);o&&(t.globalAlpha=e.kind===sp?.24:.36,t.strokeStyle=e.kind===sp?"#d94a45":"#7a8794",t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(i.x,i.y),t.stroke())}t.restore()}(t,e)},onClick:m?At:Pt.onClick,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7,...u.config?.kernel??{}},colliders:[...ap(V),...u.config?.colliders??[]]},controllers:rt,enableHover:Mt.enableHover??!0,foregroundGraphics:Ct,hoverRadius:t.hoverRadius??u.hoverRadius??18,initialSpawns:ft,initialSpawnPacing:h,onBodyPointerDown:St,onTick:mt,paused:v,regionEffects:[...K,...u.regionEffects??[]],renderBody:Tt,responsiveHeight:S,responsiveWidth:A,size:L,tooltipContent:Rt}))}).displayName="GauntletChart";var Yp={Sparkline:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e,...i,showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:o.lineStyle,...i})},AreaChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"area",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||e,colorAccessor:e,colorScheme:n,...i})},DifferenceChart:kl,StackedAreaChart:Sl,Scatterplot:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,colorScheme:n,...i})},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"candlestick",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...i})},BubbleChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:n,...i})},ConnectedScatterplot:Ml,QuadrantChart:Al,Heatmap:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"heatmap",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,colorScheme:n||o.colorScheme||"blues",showValues:o.showValues,cellBorderColor:o.cellBorderColor,...i})},XYCustomChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>({chartType:"custom",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,colorScheme:n,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...i,showAxes:i.showAxes??!1})},BarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:o.sort??!1,colorAccessor:e,colorScheme:n,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...i})},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:e||o.stackBy,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...i})},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"clusterbar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:e||o.groupBy,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...i})},PieChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"pie",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:e||o.categoryAccessor,colorScheme:n,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...i})},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"donut",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",innerRadius:o.innerRadius||60,colorAccessor:e||o.categoryAccessor,colorScheme:n,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...i})},Histogram:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"histogram",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal",bins:o.bins,colorAccessor:e,colorScheme:n,...i})},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"boxplot",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorScheme:n,...i})},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"violin",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,colorScheme:n,...i})},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"swarm",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:n,...i})},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"point",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:n,...i,showGrid:i.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"swimlane",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:e||o.subcategoryAccessor,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",...i})},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"ridgeline",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,amplitude:o.amplitude,...i})},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.levelAccessor||"level",colorAccessor:e||o.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===o.orientation?"vertical":"horizontal",...i})},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{const r="vertical"===o.orientation;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:e||o.categoryAccessor,categoryAccessor:o.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:n,...i}}},GaugeChart:Rl,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>({chartType:"custom",data:t,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:e,colorScheme:n,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...i,showAxes:i.showAxes??!1})},ForceDirectedGraph:Gl,NetworkCustomChart:{frameType:"network",buildProps:(t,e,n,i,o)=>({chartType:"force",nodes:o.nodes||t||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:e,colorScheme:n,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...i})},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>({chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:e,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle,colorScheme:n,...i})},ProcessSankey:Vl,ChordDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>({chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:e,edgeColorBy:o.edgeColorBy,colorScheme:n,...i})},TreeDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>({chartType:"cluster"===o.layout?"cluster":"tree",data:t,childrenAccessor:o.childrenAccessor,colorBy:e,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,colorScheme:n,...i})},Treemap:{frameType:"network",buildProps:(t,e,n,i,o)=>({chartType:"treemap",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:n,...i})},CirclePack:{frameType:"network",buildProps:(t,e,n,i,o)=>({chartType:"circlepack",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,colorScheme:n,...i})},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,i,o)=>({areas:o.areas,projection:o.projection||"equalEarth",areaStyle:o.areaStyle,valueAccessor:o.valueAccessor,colorScheme:n||"blues",graticule:o.graticule,fitPadding:o.fitPadding,...i})},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,i,o)=>({points:t||o.points,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle,sizeBy:o.sizeBy,colorBy:e,colorScheme:n,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...i})},FlowMap:Ul,GeoCustomChart:{frameType:"geo",buildProps:(t,e,n,i,o)=>({points:o.points||t||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:e,colorScheme:n,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[600,400],s=o.bins??21,a=o.seed??1,c=Math.max(1,Math.round(o.pegRows??s-1)),l="mechanical"===o.mode,u=l?function(t){const e=Math.max(2,Math.round(t.bins)),n=Math.max(1,Math.round(t.pegRows??e-1)),i=Math.max(1,Math.round(t.count??Math.max(64,4*e))),o=nu(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=ru(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:i},(t,e)=>{let i=0;for(let t=0;n>t;t+=1)r()<o&&(i+=1);const a=n/2;return{id:`${s}-${e}`,value:i,mechanical:!0,pegRows:n,branchProbability:o,pathRights:i,side:a>i?"left":i>a?"right":"center"}})}({bins:s,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:c,seed:a}):Array.isArray(t)?t:[],d=function(t){const{data:e,valueAccessor:n,bins:i,ballRadius:o,seed:r,size:s,valueExtent:a}=t,c=Kl(s),l=e.map((t,e)=>eu(tu(t,e,n))).filter(t=>null!=t),u=function(t){if(!t)return;const e=eu(t[0]),n=eu(t[1]);return null!=e&&null!=n?e>n?[n,e]:[e,n]:void 0}(a),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),f=h===d?1:h-d,p=su().domain([0,i]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:i},()=>0),g=[];e.forEach((t,e)=>{const r=eu(tu(t,e,n));if(null==r)return;const s=Math.max(0,Math.min(i-1,Math.floor((r-d)/f*i)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:c.plot.y+o+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...t,value:r,bin:s}})});const m=c.plot.y+c.plot.height;return{config:Jl(r,[...ed({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...nd({idPrefix:"galton-bin",count:i,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:i,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:o.valueAccessor||"value",bins:s,ballRadius:o.ballRadius??4,seed:a,size:r,valueExtent:l?[0,c]:void 0});return{...i,config:d.config,initialSpawns:jp(d.initialSpawns),projectionRows:d.projectionRows,bodyStyle:Ql(e||o.colorBy||(l?"side":void 0))}}},EventDropChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[600,400],s=function(t){const{data:e,timeAccessor:n,arrivalAccessor:i,windows:o,watermark:r,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=t,d=Kl(c),h=e.map((t,e)=>eu(tu(t,e,n))).filter(t=>null!=t),f=eu(l?.[0]),p=eu(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):y+o.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/o.size)*o.size,v=Math.max(1,Math.ceil((x-b+o.size)/o.size)),w=h.length?Math.max(...h):0,k="function"==typeof r?r(w):eu(r?.value)??w-(r?.delay??o.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>b+(e+1)*o.size>k?t:t+1,0))),A=function(t,e){const n=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:n,height:t.plot.height},windowPlot:{x:t.plot.x+n,y:t.plot.y,width:Math.max(40,t.plot.width-n),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(d,s),M=b+v*o.size,P=fd().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),_=Array.from({length:v},()=>({value:0,secondary:0})),I=[];e.forEach((t,e)=>{const r=eu(tu(t,e,n));if(null==r)return;const a=eu(tu(t,e,i))??r,c=Math.max(0,Math.min(v-1,Math.floor((r-b)/o.size))),l=k>=b+(c+1)*o.size;_[c].value+=l?0:1,_[c].secondary+=l?1:0,I.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,P(r))),y:d.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 C=d.plot.y+d.plot.height,T=function(t,e){const n=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!n)return[];const i=t.windowStart,o=t.windowStart+t.windowCount*t.windowSize,r=fd().domain([i,o]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+n*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;n>e;e+=1){const n=t.windowStart+e*t.windowSize,i=n+t.windowSize,o=r(n),s=r(i);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:o,y1:l(o),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:o.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Jl(a,[...ed({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...pd({idPrefix:"eventdrop-window",count:v,xScale:t=>P(b+t*o.size),yTop:A.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?T[0]?.y1:T[t-1]?.y2??T[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:C,wallThickness:6}),...T.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:I,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:_.map((t,e)=>({label:`${b+e*o.size}-${b+(e+1)*o.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:T,lateCount:_.reduce((t,e)=>t+e.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:o.size,windowStart:b}}}({data:Array.isArray(t)?t:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??5,seed:o.seed??1,size:r,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...i,config:s.config,initialSpawns:jp(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Ql(e||o.colorBy)}}},PhysicsPileChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[600,400],s="mechanical"===o.mode,a=function(t){const{data:e,categoryAccessor:n,valueAccessor:i,unitValue:o,ballRadius:r,seed:s,size:a}=t,c=iu(o,1),l=Kl(a),u=[],d=new Map,h=new Map,f=[];function p(t){let e=d.get(t);return null==e&&(e=u.length,u.push(t),d.set(t,e)),e}e.forEach((t,e)=>{p((tu(t,e,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(t,e,n){const i=t.width/Math.max(1,e),o=Math.max(2,2*n),r=Math.min(.7*i,Math.max(3.2*o,o+8)),s=Math.max(1,Math.floor(r/o));return{laneWidth:i,tubeWidth:r,ballDiameter:o,perRow:s,centerX:e=>t.x+(e+.5)*i,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*o}}(l.plot,y,r),m=Math.max(0,g.tubeWidth/2-r-1),x=u.map(()=>[]);e.forEach((t,e)=>{const o=(tu(t,e,n)??"unknown")+"",s=p(o),a=i?eu(tu(t,e,i)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let n=0;u>n;n+=1){const i=h.get(o)??0,a=g.perRow>1?((g.perRow>1?i%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(o,i+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${n}`,x:d+a,y:l.plot.y+r+2,vx:(n%3-1)*r/2,vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,category:o,unitIndex:n}})}});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=[...ed({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 n of[-1,1])w.push({id:`pile-tube-${t}-${0>n?"l":"r"}`,shape:{type:"aabb",x:e+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:Jl(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:h.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),n=e.length?e:["Intake"],i=Math.max(n.length,Math.round(t.count??Math.max(48,12*n.length))),o=iu(t.unitValue,1),r=ru(t.seed??1),s=t.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*r()),c=a.reduce((t,e)=>t+e,0)||1,l=i-n.length,u=a.map(t=>t/c*l),d=u.map(t=>1+Math.floor(t));let h=i-d.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;h>0;t=(t+1)%f.length)d[f[t].index]+=1,h-=1;return n.map((t,e)=>({id:`${s}-${e}`,category:t,value:d[e]*o,mechanical:!0,unitCount:d[e],unitValue:o,share:d[e]/i}))}({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(t)?t:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(s?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??5,seed:o.seed??1,size:r});return{...i,config:a.config,initialSpawns:jp(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:Ql(e||o.colorBy||(s?"category":void 0))}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[600,360],s=function(t){const{data:e,xAccessor:n,groupAccessor:i,radiusAccessor:o,pointRadius:r,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,d=Kl(a),h=ru(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=eu(tu(t,e,n));if(null==s)return;const a=i?(tu(t,e,i)??"All")+"":"All",c=o?eu(tu(t,e,o)):null,l=nu(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?eu(c[0]):null,x=c?eu(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=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,P=yd().domain([w,k]).range([A,M]),_=Math.max(1,p.length),I=d.plot.y+Math.max(28,3*S),C=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-I),T=t=>{const e=y.get(t)??0;return 1===_?d.plot.y+.54*d.plot.height:I+e/(_-1)*C},R=new Map,L=f.map((t,e)=>{R.set(t.group,(R.get(t.group)??0)+1);const n=P(t.value),i=T(t.group),o=(h()-.5)*t.radius*1.6,r=(h()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?n+o:nu(n+(e%9-4)*t.radius*2.5,A,M),y:u?i+r:d.plot.y-18-e%12*t.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:n,targetY:i},springs:[{target:{type:"point",x:n,y:i},restLength:0,stiffness:34,damping:5.5}]}});return{config:Jl(s,ed({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.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:L,projectionRows:p.map(t=>({label:t,value:R.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(t=>({label:t,y:T(t),count:R.get(t)??0})),plot:d.plot}}}({data:Array.isArray(t)?t:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:r,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...i,config:s.config,initialSpawns:jp(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Ql(e||o.colorBy||o.groupAccessor)}}},ProcessFlowChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[900,420],s=Array.isArray(o.stages)?o.stages:[],a=_d({data:Array.isArray(t)?t:[],stages:s,size:r,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),c=a.metadata;return{...i,config:a.config,initialSpawns:jp(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:Ql(e||o.colorBy||o.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[900,520],s=function(t){const e=pp(t.size??[900,520],t.gates,t.crashOffset??30),n=t.positiveProperties??[],i=new Map(n.map(t=>[t.id,t])),o=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=bp(e,s,r,n,o);return{...a,viability:t.viability?.(a,{negativeProperties:o,positiveProperties:i})??xp(a,i,o)}}).flatMap((n,r)=>{const s=gp(n,r,e,t.projectPlacement);return vp(n,r,e,s,i,o,t.coreBody)});return{layout:e,initialSpawns:s,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:ap(e)}}}({data:Array.isArray(t)?t:[],size:r,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...i,config:s.config,initialSpawns:jp(s.initialSpawns),projectionRows:[],bodyStyle:Ql(e||o.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:n,links:i,maxParticles:o,nodeIdAccessor:r,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=Kl(y),v=ru(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 n=(tu(t,e,r)??t.id??e)+"",i=eu(tu(t,e,s)),o=eu(tu(t,e,a));if(null!=i&&null!=o){const t={x:i,y:o};w.set(n,t),S.push(t)}k.set(n,(t.label??t.name??n)+"")});const M=[];i.forEach((t,e)=>{const n=A(tu(t,e,g)),i=A(tu(t,e,m)),o=Math.max(0,eu(tu(t,e,x))??0),r=md(d?tu(t,e,d):void 0),s=r.length?r:md(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${n}-${i}-${e}`)+"",link:t,index:e,source:n,target:i,throughput:o,rawPath:s})});const P=(I=S,"normalized"===(_=e)||"pixels"===_?_:I.length>0&&I.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var _,I;const C=new Map;for(const[t,e]of w)C.set(t,xd(e,b,P));const T=[];for(const t of M){let e=t.rawPath.map(t=>xd(t,b,P));if(2>e.length){const n=C.get(t.source),i=C.get(t.target);n&&i&&(e=[n,i])}else C.has(t.source)||C.set(t.source,e[0]),C.has(t.target)||C.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),T.push({...t,path:e,packetCount:0}))}const R=iu(u,.12),L=Math.max(1,Math.round(o)),$=T.map(t=>Math.max(1,Math.round(t.throughput*R))),z=$.reduce((t,e)=>t+e,0),D=z>L?L/z:1;T.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor($[e]*D))});let E=T.reduce((t,e)=>t+e.packetCount,0);for(;E>L;){const t=T.reduce((t,e,n)=>e.packetCount>1&&(-1===t||e.packetCount>T[t].packetCount)?n:t,-1);if(-1===t)break;T[t].packetCount-=1,E-=1}const B=new Map,F=new Map,N=[],O=iu(n,90),W=iu(l,4);T.forEach((t,e)=>{B.set(t.target,(B.get(t.target)??0)+t.throughput),F.set(t.source,(F.get(t.source)??0)+t.throughput);const n=bd(t.path);for(let i=0;t.packetCount>i;i+=1){const o=(i+.5)/t.packetCount,r=f?o:nu(.12+.84*o+.04*(v()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*v())),a=vd(t.path,s),c=vd(t.path,r),l=wd(t.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*W*1.5;N.push({id:`${t.id}-packet-${i}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*O+10*(v()-.5),vy:f?0:l.y*O+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+i/32,shape:{type:"circle",radius:W},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:i,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:n,flowRouteId:t.id,flowSpeed:O,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*W,stiffness:26,damping:4.25}]:void 0})}});const j=Math.max(18,5*W),Y=Array.from(C,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+ou(t),point:e})),q=Y.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:j,height:j}})),H=Object.fromEntries(Y.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),X=Jl(p,[...ed({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*W),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});X.bodyLimit=L,X.eviction="oldest",X.observation={...X.observation,sensors:H};const G=Array.from(C,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+ou(t),incoming:B.get(t)??0,outgoing:F.get(t)??0})),V=T.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:X,initialSpawns:N,projectionRows:G.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:P,particleCount:N.length,totalThroughput:T.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:G,links:V}}}({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(t)?t:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:r});return{...i,config:s.config,initialSpawns:jp(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Ql(e||o.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(t,e,n,i,o)=>{const r=i.size??[700,380],s=Kf({chartId:o.chartId,colorScheme:n,config:o.config,data:Array.isArray(t)?t:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Lt(Dt)??{},size:r,themeCategorical:Dt.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...i,config:s.config,initialSpawns:jp(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Ql(e||o.colorBy)}}}};function qp(t){if(!t)return Dt;if("string"==typeof t){if("light"===t)return Dt;if("dark"===t)return Et;if("high-contrast"===t)return Bt;return Bc[t]||Dt}const e="dark"===t.mode?Et:Dt;return $t({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}},tooltip:{...e.tooltip,...t.tooltip||{}}})}function Hp(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 Xp(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function Gp(t){if(!t||2>t.length)return;const e=Xp(t[0]),n=Xp(t[t.length-1]);return null!==e&&null!==n?[e,n]:void 0}function Vp(t){const{count:e,byType:n}=function(t){const e={};for(const n of t){const t="string"==typeof n?.type&&n.type.length>0?n.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),i=0===e,o=[...t.extraWarnings??[]];return i&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),{component:"",frameType:t.frameType,status:i?"empty":"ok",empty:i,markCount:e,markCountByType:n,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:o}}import*as Up from"react";import*as Kp from"react-dom/server";import{scaleOrdinal as Zp}from"d3-scale";import{jsx as Qp,jsxs as Jp}from"react/jsx-runtime";function ty(t){return"left"===t?"start":"right"===t?"end":t??"start"}function ey(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function ny(t,e,n,i){const o=ey(i);return e+n+Math.ceil(t.length*o*.58)}function iy(t){const{categories:e,theme:n,position:i="right",totalWidth:o,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),u=Math.max(0,a?.itemGap??8),d=Math.max(c,a?.rowHeight??20),h=c+l,f=Math.min(2,c/2),p="top"===i||"bottom"===i,y=Math.max(c,o-s.left-s.right),g=Math.max(d,r-s.top-s.bottom),m=e.map(t=>ny(t,c,l,n));if(p){const t=Math.max(c,a?.maxWidth??y),n=[];let i=0,o=0;m.forEach((e,r)=>{const s=0===o?e:o+u+e;o>0&&s>t?(n.push({start:i,end:r,width:o}),i=r,o=e):o=s}),e.length>0&&n.push({start:i,end:e.length,width:o});const r=ty(a?.align),s=[];return n.forEach((n,i)=>{let o="center"===r?Math.max(0,(t-n.width)/2):"end"===r?Math.max(0,t-n.width):0;for(let t=n.start;n.end>t;t++)s.push({category:e[t],width:m[t],x:o,y:i*d}),o+=m[t]+u}),{items:s,width:Math.max(0,...n.map(t=>t.width)),height:n.length*d,swatchSize:c,labelOffset:h,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/d)),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*d})),width:v*x+Math.max(0,v-1)*u,height:Math.min(e.length,b)*d,swatchSize:c,labelOffset:h,swatchRadius:f}}function oy(t){const{legendGroups:e,theme:n,position:i="right",totalWidth:o,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),u=Math.max(0,a?.itemGap??8),d=Math.max(c,a?.rowHeight??20),h=c+l,f=Math.min(2,c/2),p=Math.max(12,ey(n)),y="top"===i||"bottom"===i,g=Math.max(c,o-s.left-s.right),m=Math.max(d,r-s.top-s.bottom);if(y){const i=Math.max(c,a?.maxWidth??g),o=ty(a?.align);let r=0,s=0;const l=[];for(const o of e){const e=o.items.map(t=>t.label),u=iy({...t,categories:e,legendLayout:{...a,maxWidth:Math.max(c,i-p-8),align:"start"}}),d=o.label?p:0,h=o.label?ny(o.label,0,0,n):0,f=d>0?d+8:0,y=f+u.width,g=Math.max(u.height,h);l.push({group:o,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,d=u>i?0:"center"===o?Math.max(0,(i-u)/2):"end"===o?Math.max(0,i-u):0;return{groups:l.map(t=>({...t,x:t.x+d})),width:u,height:s,swatchSize:c,labelOffset:h,swatchRadius:f}}let x=0,b=0;const v=[];for(const t of e){const e=t.items.map(t=>t.label).map(t=>ny(t,c,l,n)),i=Math.max(0,...e),o=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(d,m-x)/d)))),r=Math.max(1,Math.ceil(t.items.length/o)),s=t.items.map((t,n)=>({category:t.label,width:e[n],x:Math.floor(n/o)*(i+u),y:n%o*d})),a=r*i+Math.max(0,r-1)*u,h=Math.min(t.items.length,o)*d,f=t.label?ny(t.label,0,0,n):0,y=t.label?p+8:0,g=y+h+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:h,swatchRadius:f}}function ry(t){const e="top"===t.position||"bottom"===t.position,n=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??n,200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function sy(t){const{categories:e,colorScheme:n,theme:i,position:o="right",totalWidth:r,totalHeight:a,margin:c,hasTitle:l=!1}=t;if(!e||0===e.length)return null;const u=function(t,e,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>M(t,e)??"#999"}const i=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:s;return Zp().domain(t).range(i)}(e,n,i),d="top"===o||"bottom"===o,h=iy(t);let f,p;if("left"===o?(f=Math.max(4,c.left-h.width-10),p=c.top):"top"===o?(f=c.left,p=l?32:8):"bottom"===o?(f=c.left,p=Math.min(a-c.bottom+38,a-h.height-2)):(f=Math.min(r-h.width-4,r-c.right+10),p=c.top),d){const t=h.items.map((t,e)=>Jp("g",{transform:`translate(${t.x},${t.y})`,children:[Qp("rect",{width:h.swatchSize,height:h.swatchSize,fill:u(t.category),rx:h.swatchRadius}),Qp("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:ey(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:t.category})]},"legend-"+e));return Qp("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,children:t})}const y=h.items.map((t,e)=>Jp("g",{transform:`translate(${t.x},${t.y})`,children:[Qp("rect",{width:h.swatchSize,height:h.swatchSize,fill:u(t.category),rx:h.swatchRadius}),Qp("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:ey(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:t.category})]},"legend-"+e));return Qp("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,children:y})}function ay(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],i=new Set;for(const e of t){const t=n(e);null!=t&&i.add(t+"")}return Array.from(i)}import{jsx as cy,jsxs as ly}from"react/jsx-runtime";function uy(t,e){return t.color||e.colors.annotation||e.colors.text}function dy(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 hy(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 fy(t){const{annotations:e}=t;if(!e||0===e.length)return null;const n=t.autoPlaceAnnotations?sr({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,i=[];for(let e=0;n.length>e;e++){const o=py(n[e],e,t);o&&i.push({node:o,annotation:n[e]})}const o=Eo(i);return o.length>0?cy("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function py(t,e,n){const{scales:i,layout:o,theme:r,xAccessor:s,yAccessor:a}=n;switch(t.type){case"y-threshold":{const s=t.value;if(null==s)return null;const a=uy(t,r),c=t.label,l=t.labelPosition||"right",u=t.strokeDasharray||"6,4",d=t.strokeWidth??1.5;if("horizontal"===n.projection&&i.r){const n=i.r(s);return null==n?null:ly("g",{opacity:t.opacity,children:[cy("line",{x1:n,y1:0,x2:n,y2:o.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&cy("text",{x:n+4,y:12,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,children:c})]},"ann-ythresh-"+e)}const h=i.y?i.y(s):i.r?i.r(s):null;return null==h?null:ly("g",{children:[cy("line",{x1:0,y1:h,x2:o.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&cy("text",{x:"left"===l?4:"center"===l?o.width/2:o.width-4,y:h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,children:c})]},"ann-ythresh-"+e)}case"x-threshold":{const n=t.value;if(null==n||!i.x)return null;const s=i.x(n);if(null==s)return null;const a=uy(t,r),c=t.label,l=t.labelPosition||"top";return ly("g",{opacity:t.opacity,children:[cy("line",{x1:s,y1:0,x2:s,y2:o.height,stroke:a,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),c&&cy("text",{x:s>.6*o.width?s-4:s+4,y:"bottom"===l?o.height-4:"center"===l?o.height/2:12,textAnchor:s>.6*o.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,stroke:r.colors.background,strokeWidth:3,paintOrder:"stroke",children:c})]},"ann-xthresh-"+e)}case"band":{const n=null!=t.y0&&i.y?i.y(t.y0):null,s=null!=t.y1&&i.y?i.y(t.y1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=t.fill||uy(t,r);return ly("g",{opacity:t.opacity,children:[cy("rect",{x:0,y:a,width:o.width,height:c,fill:l,fillOpacity:t.fillOpacity??.1}),t.label&&cy("text",{x:o.width-4,y:Math.max(a,0)+13,textAnchor:"end",fontSize:r.typography.tickSize,fill:t.color||uy(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",stroke:r.colors.background,strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-band-"+e)}case"x-band":{const n=null!=t.x0&&i.x?i.x(t.x0):null,s=null!=t.x1&&i.x?i.x(t.x1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=t.fill||uy(t,r);return ly("g",{opacity:t.opacity,children:[cy("rect",{x:a,y:0,width:c,height:o.height,fill:l,fillOpacity:t.fillOpacity??.1}),t.label&&cy("text",{x:a+4,y:13,textAnchor:"start",fontSize:r.typography.tickSize,fill:t.color||uy(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",stroke:r.colors.background,strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-xband-"+e)}case"category-highlight":{if(!t.category||!i.o)return null;const s=i.o(t.category);if(null==s)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=uy(t,r),l=t.opacity??.1;return cy("rect","horizontal"===n.projection?{x:0,y:s,width:o.width,height:a,fill:c,opacity:l}:{x:s,y:0,width:a,height:o.height,fill:c,opacity:l},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:o}=function(t,e,n,i){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:dy(t,e,n),y:hy(t,e,i)}}(t,i,s,a);if(null==n||null==o)return null;const c="text"===t.type,l=t.dx??(c?0:30),u=t.dy??(c?0:-30),d=t.color||r.colors.text;if(!c){const i="callout"===t.type?"callout-circle":t.type,r="callout-circle"===i?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===i?{width:t.width,height:t.height}:void 0;return cy(lo,{noteData:{x:n,y:o,dx:l,dy:u,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:i,...r?{subject:r}:{},connector:t.connector||{end:"arrow"},color:d,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return cy("g",{children:cy("text",{x:n+l,y:o+u,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||r.typography.labelSize,fill:d,fontFamily:r.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}import{jsx as yy,jsxs as gy}from"react/jsx-runtime";function my(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function xy(t,e){if(0===e.categories.length)return;const n=e.position||"right",i=function(t){const{width:e,height:n,swatchSize:i}=iy(t);return{width:e,height:n,swatchSize:i}}({categories:e.categories,colorScheme:e.colorScheme,theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout});"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 by(t,e){const n=e.position||"right",i={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},o=ji(e.legend)?function(t){const{width:e,height:n,swatchSize:i}=oy(t);return{width:e,height:n,swatchSize:i}}({...i,legendGroups:e.legend.legendGroups}):Yi(e.legend)?ry({...i,gradient:e.legend.gradient}):null;o&&("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 vy(t,e){const n={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 ji(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var e;const n=oy(t),i="top"===t.position||"bottom"===t.position,o=t.theme.colors.grid||t.theme.colors.textSecondary;let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-n.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-n.height-2)):(r=Math.min(t.totalWidth-n.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=n.groups.flatMap((e,r)=>{const{group:s}=e,a=s.type??"fill",c=[];if(s.label&&c.push(Qp("text",i?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:ey(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label}:{x:e.x,y:e.y+ey(t.theme),fontSize:ey(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label},"legend-group-label-"+r)),c.push(...e.items.map((i,o)=>{const c=s.items[o],l=s.styleFn(c,o),u="function"==typeof a?a(c):"line"===a?Qp("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:l}):Qp("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:l});return Jp("g",{transform:`translate(${e.x+e.itemOffsetX+i.x},${e.y+e.itemOffsetY+i.y})`,children:[u,Qp("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:ey(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:i.category})]},`legend-${r}-${o}`)})),!i&&n.groups.length-1>r)c.push(Qp("line",{x1:0,y1:e.y+e.height-6,x2:n.width,y2:e.y+e.height-6,stroke:o},"legend-group-separator-"+r));else if(i&&n.groups.length-1>r){const t=e.x+e.width+6;c.push(Qp("line",{x1:t,y1:0,x2:t,y2:n.height,stroke:o},"legend-group-separator-"+r))}return c});return Qp("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...n,legendGroups:t.legendGroups}):Yi(t)?function(t){const e=ry(t),n="top"===t.position||"bottom"===t.position,i=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",o=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,i)=>{const o=i/16;return Qp("stop",{offset:100*o+"%",stopColor:t.gradient.colorFn(n?t.gradient.domain[0]+o*(t.gradient.domain[1]-t.gradient.domain[0]):t.gradient.domain[1]-o*(t.gradient.domain[1]-t.gradient.domain[0]))},i)});if(n){const n=12,c=t.gradient.label?0:void 0,l=t.gradient.label?8:0;return Jp("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,children:[Qp("defs",{children:Qp("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),t.gradient.label&&Qp("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}),Qp("rect",{x:0,y:l,width:e.width,height:n,fill:`url(#${i})`,rx:2}),Qp("text",{x:0,y:l+n+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:o(t.gradient.domain[0])}),Qp("text",{x:e.width,y:l+n+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:o(t.gradient.domain[1])})]})}const c=t.gradient.label?-6:void 0;return Jp("g",{className:"semiotic-legend",transform:`translate(${r},${s+(t.gradient.label?12:0)})`,children:[Qp("defs",{children:Qp("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),t.gradient.label&&Qp("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}),Qp("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),Qp("text",{x:19,y:10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:o(t.gradient.domain[1])}),Qp("text",{x:19,y:100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:o(t.gradient.domain[0])})]})}({...n,gradient:t.gradient}):null}function wy(t){return Math.round(100*t)/100+""}function ky(t,e){const n=Hp(e.theme),i=e.idPrefix?e.idPrefix+"-":"",o="string"==typeof e.title?e.title:void 0,r=o?i+"semiotic-title":void 0,s=e.description?i+"semiotic-desc":void 0,a=[r,s].filter(Boolean).join(" ")||void 0;return gy("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":a,style:{fontFamily:n.fontFamily},children:[o&&yy("title",{id:r,children:o}),e.description&&yy("desc",{id:s,children:e.description}),e.defs&&yy("defs",{children:e.defs}),e.background&&"transparent"!==e.background&&yy("rect",{x:0,y:0,width:e.width,height:e.height,fill:e.background}),yy("g",{id:i+"data-area",transform:e.innerTransform,children:t}),o&&yy("text",{id:i+"chart-title",x:e.width/2,y:16,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:o}),e.legend&&yy("g",{id:i+"legend",children:e.legend}),e.outerElements]})}import{Fragment as Sy,jsx as Ay,jsxs as My}from"react/jsx-runtime";function Py(t,e){const n=qp(t.theme),i=t.size||[500,300],o={top:20,right:20,bottom:30,left:40,...t.margin},r=I(t.data),s=t.showLegend?ay(r,t.colorAccessor||t.groupAccessor):[],a=t.legendPosition;ji(t.legend)||Yi(t.legend)?by(o,{legend:t.legend,theme:n,position:a||"right",size:i,hasTitle:!!t.title,legendLayout:t.legendLayout}):t.showLegend&&s.length>0&&xy(o,{categories:s,colorScheme:t.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!t.title,legendLayout:t.legendLayout});const c=i[0]-o.left-o.right,l=i[1]-o.top-o.bottom,u="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),d=t.colorScheme||n.colors.categorical,h={chartType:t.chartType,windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:u?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:u?void 0:t.xAccessor,yAccessor:u?void 0:t.yAccessor,timeAccessor:u?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:n.colors.categorical,themeSemantic:Lt(n),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:o,layoutSelection:t.layoutSelection,barColors:t.barColors},f=new hn(h);if(t.data&&f.ingest({inserts:r,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return e&&(e.evidence=Vp({frameType:"xy",width:i[0],height:i[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),Kp.renderToStaticMarkup(ky(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${o.left},${o.top})`,innerWidth:c,innerHeight:l,idPrefix:t._idPrefix}));e&&(e.evidence=Vp({frameType:"xy",width:i[0],height:i[1],marks:f.scene,title:t.title,description:t.description,annotations:t.annotations,xDomain:Gp(f.scales.x?.domain?.()),yDomain:Gp(f.scales.y?.domain?.()),legendItems:s.length>0?s.length:void 0}));const p=t._idPrefix,y=t.showGrid?function(t,e,n,i){const{grid:o}=Hp(n),r=i?i+"-":"",s=t.x.ticks(5),a=t.y.ticks(5);return gy("g",{id:r+"grid",className:"semiotic-grid",opacity:.8,children:[s.map((n,i)=>{const r=t.x(n);return yy("line",{x1:r,y1:0,x2:r,y2:e.height,stroke:o,strokeWidth:.5},"gx-"+i)}),a.map((n,i)=>{const r=t.y(n);return yy("line",{x1:0,y1:r,x2:e.width,y2:r,stroke:o,strokeWidth:.5},"gy-"+i)})]})}(f.scales,{width:c,height:l},n,p):null,g=f.scene.map((t,e)=>qr(t,e,p)).filter(Boolean),m=!1!==t.showAxes?function(t,e,n,i,o){const r=Hp(i),s=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(n.xFormat||n.tickFormatTime||wy)(e)})),a=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(n.yFormat||n.tickFormatValue||wy)(e)}));return gy("g",{id:(o?o+"-":"")+"axes",className:"stream-axes",children:[yy("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:r.border,strokeWidth:1}),s.map((t,n)=>gy("g",{transform:`translate(${t.pixel},${e.height})`,children:[yy("line",{y2:5,stroke:r.border,strokeWidth:1}),yy("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"xtick-"+n)),n.xLabel&&yy("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:n.xLabel}),yy("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:r.border,strokeWidth:1}),a.map((t,e)=>gy("g",{transform:`translate(0,${t.pixel})`,children:[yy("line",{x2:-5,stroke:r.border,strokeWidth:1}),yy("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"ytick-"+e)),n.yLabel&&yy("text",{x:15-(n.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${e.height/2})`,children:n.yLabel})]})}(f.scales,{width:c,height:l},t,n,p):null,x=t.annotations?fy({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:c,height:l},theme:n,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:p}):null,b=t.svgPreRenderers&&f.scales?t.svgPreRenderers.map((t,e)=>{try{return Ay(Up.Fragment,{children:t(f.scene,f.scales,{width:c,height:l})},"pre-"+e)}catch{return null}}).filter(Boolean):null,v=t.showLegend?0===s.length?null:sy({categories:s,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:o,hasTitle:!!t.title,legendLayout:t.legendLayout}):null,w=Up.isValidElement(t.legend)?t.legend:vy(t.legend,{theme:n,position:t.legendPosition||"right",size:i,margin:o,hasTitle:!!t.title,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||v;return Kp.renderToStaticMarkup(ky(My(Sy,{children:[t.backgroundGraphics,b,y,g,m,x,t.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${o.left},${o.top})`,innerWidth:c,innerHeight:l,legend:w,idPrefix:t._idPrefix}))}import*as _y from"react";import*as Iy from"react-dom/server";import{scaleBand as Cy,scaleLinear as Ty}from"d3-scale";function Ry(t){const e=t.getSymbol;if(!e)return null;const n=t.config.symbolMap,i=new Map;let o=0;return t=>{const r=e(t)+"",s=n?.[r];if(s)return s;let a=i.get(r);return a||(a=Le[o%Le.length],o++,i.set(r,a)),a}}function Ly(t,e,n,i,o,r,s){t.push(e?{type:"symbol",x:i,y:o,size:Math.PI*r*r,symbolType:e(n),style:s,datum:n}:{type:"point",x:i,y:o,r:r,style:s,datum:n})}function $y(t,e){const{columns:n,config:i,resolvePieceStyle:o}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(n),h=d.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!h&&d.length>1&&(i.cornerRadius??0)>0;for(let t=0;d.length>t;t++){const e=d[t],n=e.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:e.pctStart,h=c+u*l,p=c+(u+("number"==typeof n?._pct?n._pct:e.pct))*l,y=o(e.pieceData[0],e.name),g=0===t,m=t===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:y,datum:n?._nonInteractive?null:e.pieceData,category:e.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),r.push(x)}return r}import{quantile as zy}from"d3-array";function Dy(t){const e=t.length,n=t[0],i=t[e-1];return{n:e,min:n,q1:zy(t,.25)??n,median:zy(t,.5)??(n+i)/2,q3:zy(t,.75)??i,max:i,mean:t.reduce((t,e)=>t+e,0)/e}}import{scaleLinear as Ey}from"d3-scale";var By={bar:function(t,e){const{scales:n,columns:i,config:o,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,f=o.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(i))for(const n of e.pieceData){const e=s(n);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(i)){const e=new Map;for(const n of t.pieceData){const t=s?s(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t);i.total+=r(n),i.pieces.push(n)}let n=0;if(f)for(const t of e.values())n+=Math.abs(t.total);let i=0,o=0;for(const r of p){const l=e.get(r);if(!l)continue;let p=l.total;f&&n>0&&(p/=n);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(d){const e=c(0>p?o:i+p),n=0>p?c(o+p)-c(o):c(i)-c(i+p);u.push(he(t.x,e,t.width,Math.abs(n),y,g,r)),0>p?o+=p:i+=p}else if(h){const e=c(0>p?o+p:i),n=0>p?c(o)-c(o+p):c(i+p)-c(i);u.push(he(e,t.x,Math.abs(n),t.width,y,g,r)),0>p?o+=p:i+=p}}}const y="vertical"===l,g=o.roundedTop&&o.roundedTop>0?Math.max(0,o.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",o.gradientFill&&(t.fillGradient=o.gradientFill)}if(g>0){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const n=e.datum?.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=>(t.datum?.__aggregateValue??0)>=0),n=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),n.length>0&&(n.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:n,columns:i,config:o,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],f=new Set;for(const t of Object.values(i))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const p=h.length||1;for(const t of Object.values(i)){const e=t.width/p,n=.2*e,i=e-n,o=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";o.has(t)||o.set(t,[]),o.get(t).push(e)}for(let s=0;h.length>s;s++){const l=o.get(h[s])||[];for(const o of l){const l=r(o),f=a(o,h[s]);if(d){const r=t.x+s*e+n/2,a=c(0),d=c(l);u.push(he(r,Math.min(a,d),i,Math.abs(a-d),f,o,h[s]))}else{const r=t.x+s*e+n/2,a=c(0),d=c(l);u.push(he(Math.min(a,d),r,Math.abs(d-a),i,f,o,h[s]))}}}}const y=o.roundedTop&&o.roundedTop>0?Math.max(0,o.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",o.gradientFill&&(t.fillGradient=o.gradientFill)}return u},point:function(t,e){const{scales:n,columns:i,getR:o,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=r.length>0,f=Ry(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(i))for(const e of t.pieceData){const n=e.__rIndex??0,i=e.__rValue??o(e),c=h&&r[n]||a,g=s(e,t.name),m=g.r||5;let x,b;if(d){const e=y+(t.pctStart+t.pct/2)*p,n=c(i);x=Math.cos(e)*n,b=Math.sin(e)*n}else u?(x=t.middle,b=c(i)):(x=c(i),b=t.middle);Ly(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:n,columns:i,getR:o,resolvePieceStyle:r}=t,{r:s,projection:a}=n,c=[],l="vertical"===a,u=Ry(t);for(const t of Object.values(i)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const i=t.pieceData[n],a=o(i),d=r(i,t.name),h=d.r||4,f=(7919*n%100/100-.5)*e*.8;Ly(c,u,i,l?t.middle+f:s(a),l?s(a):t.middle+f,h,d)}}return c},pie:$y,donut:$y,boxplot:function(t,e){const{scales:n,columns:i,config:o,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=n,l=[],u="vertical"===c,d=!1!==o.showOutliers;for(const e of Object.values(i)){const n=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===n.length)continue;const i=n[0],o=n[n.length-1],c=zy(n,.25)??i,h=zy(n,.5)??(i+o)/2,f=zy(n,.75)??o,p=f-c,y=c-1.5*p,g=f+1.5*p,m=n.find(t=>t>=y)??i,x=[...n].reverse().find(t=>g>=t)??o,b=s(e.pieceData[0],e.name),v=[];if(d)for(const t of e.pieceData){const n=r(t);if(y>n||n>g){const i=u?e.middle:a(n),o=u?a(n):e.middle;v.push({px:i,py:o,value:n,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(h),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:c,median:h,q3:f,max:x,mean:n.reduce((t,e)=>t+e,0)/n.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),d)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:n,columns:i,config:o,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=n,l=[],u="vertical"===c,d=o.bins||20,h=!1!==o.showIQR;for(const t of Object.values(i)){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 n=e[0],i=e[e.length-1],o=(i-n)/d||1,c=Array(d).fill(0);for(const t of e)c[Math.min(Math.floor((t-n)/o),d-1)]++;const f=Ui(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(n)}`;for(let e=0;d>e;e++){const i=a(n+(e+.5)*o);y+=` L ${t.middle+c[e]/f*p} ${i}`}y+=` L ${t.middle} ${a(i)}`;for(let e=d-1;e>=0;e--){const i=a(n+(e+.5)*o);y+=` L ${t.middle-c[e]/f*p} ${i}`}y+=" Z"}else{y=`M ${a(n)} ${t.middle}`;for(let e=0;d>e;e++)y+=` L ${a(n+(e+.5)*o)} ${t.middle-c[e]/f*p}`;y+=` L ${a(i)} ${t.middle}`;for(let e=d-1;e>=0;e--)y+=` L ${a(n+(e+.5)*o)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(h&&e.length>=4){const o=zy(e,.25)??n,r=zy(e,.5)??(n+i)/2,s=zy(e,.75)??i;m={q1Pos:a(o),medianPos:a(r),q3Pos:a(s),centerPos:t.middle,isVertical:u}}const x=u?{x:t.x,y:Math.min(a(i),a(n)),width:t.width,height:Math.abs(a(i)-a(n))}:{x:Math.min(a(n),a(i)),y:t.x,width:Math.abs(a(i)-a(n)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:Dy(e),style:g,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:n,columns:i,config:o,getR:r,resolveSummaryStyle:s}=t,{r:a}=n,c=[],l=o.bins||25,u=o.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[n,i]=Vi(e),o=null!=h&&isFinite(h)?h:n,d=null!=f&&isFinite(f)?f:i,p=(d-o)/l||1,y=Array(l).fill(0);for(const t of e)o>t||t>d||y[Math.min(Math.floor((t-o)/p),l-1)]++;const g=e.length,m=Ui(y,1),x=s(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===y[e])continue;const n=(u?y[e]/g:y[e]/m)*t.width*.9,i=a(o+e*p),r=a(o+(e+1)*p);c.push(he(Math.min(i,r),t.x+t.width-n,Math.abs(r-i),n,x,{bin:e,count:y[e],range:[o+e*p,o+(e+1)*p],category:t.name},t.name))}}return c},ridgeline:function(t,e){const{scales:n,columns:i,config:o,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=n,l=[],u=o.bins||20,d="horizontal"===c,h=o.amplitude||1.5;for(const t of Object.values(i)){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 n=e[0],i=e[e.length-1],o=(i-n)/u||1,c=Array(u).fill(0);for(const t of e)n>t||t>i||c[Math.min(Math.floor((t-n)/o),u-1)]++;const f=Ui(c,1),p=s(t.pieceData[0],t.name),y=t.width*h;let g;if(d){const e=t.x+t.width;g=`M ${a(n)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(n+(t+.5)*o)} ${e-c[t]/f*y}`;g+=` L ${a(i)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(n)}`;for(let t=0;u>t;t++){const i=a(n+(t+.5)*o);g+=` L ${e+c[t]/f*y} ${i}`}g+=` L ${e} ${a(i)} Z`}const m=d?{x:Math.min(a(n),a(i)),y:t.x,width:Math.abs(a(i)-a(n)),height:t.width}:{x:t.x,y:Math.min(a(i),a(n)),width:t.width,height:Math.abs(a(i)-a(n))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:Dy(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:n,columns:i,getRawRange:o,resolvePieceStyle:r}=t,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const t of Object.values(i))for(const e of t.pieceData){const n=o(e);if(!n)continue;const[i,a]=n,u=r(e,t.name);if(l){const n=s(Math.min(i,a)),o=s(Math.max(i,a));c.push(he(n,t.x,o-n,t.width,u,e,t.name))}else{const n=s(Math.max(i,a)),o=s(Math.min(i,a));c.push(he(t.x,n,t.width,o-n,u,e,t.name))}}return c},funnel:function(t,e){const{columns:n,getR:i,getStack:o,resolvePieceStyle:r}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>n[t]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const t of l)for(const e of t.pieceData){const t=o?o(e):"_default";d.has(t)||(d.add(t),u.push(t))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let n=0;for(const r of t.pieceData){const t=o?o(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=i(r);s.total+=a,s.pieces.push(r),n+=a}f.push({col:t,groups:e,stepTotal:n}),h||n>p&&(p=n)}if(h)for(const t of f){let e=0,n=0;for(let i=0;u.length>i;i++){const o=t.groups.get(u[i]);o&&(i%2==0?e+=o.total:n+=o.total)}const i=Math.max(e,n);i>p&&(p=i)}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=h?.95*a:.9*e.width,x=Ey().domain([0,p]).range([0,m]),b=t.config.connectorOpacity??.3;let v=new Map;for(let e=0;f.length>e;e++){const n=f[e],i=n.col,o=0===e,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(h){let t=0;for(const e of u){const i=n.groups.get(e);i&&(t+=x(i.total))}let e=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=h%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:i.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(he(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const t=n.stepTotal,e=x(t),l=a-e/2,h=u[0],f="_default"!==h,y=n.groups.get(h)?.pieces[0]??i.pieceData[0],b=f?h:i.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:i.name,__funnelIsFirstStep:o,category:f?h:i.name};c&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(he(l,p,e,d,v,k,b)),m.set(h,{x:l,y:p,w:e,h:d})}if(e>0&&v.size>0){const e=h?u:[u[0]];for(const o of e){const e=v.get(o),a=m.get(o);if(!e||!a)continue;const c=(()=>{const t=n.groups.get(o);return r(t?t.pieces[0]:i.pieceData[0],"_default"===o?i.name:o)})(),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:n.groups.get(o)?.pieces[0]??i.pieceData[0],category:"_default"===o?i.name:o};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:n,getR:i,getStack:o,resolvePieceStyle:r,scales:s}=t,a=[],c=s.o.domain().map(t=>n[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=o?o(e):"_default";u.has(t)||(u.add(t),l.push(t))}const d=l.length>1&&"_default"!==l[0],h=[];for(const t of c){const e=new Map;let n=0;for(const r of t.pieceData){const t=o?o(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=i(r);s.total+=a,s.pieces.push(r),n+=a}h.push({col:t,groups:e,stepTotal:n})}const f=new Map;for(const t of l){const e=h[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let t=0;h.length>t;t++){const e=h[t],n=e.col,i=0===t,o=t>0?h[t-1]:null,s=n.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const h=l[t],y=e.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=o?.groups.get(h),v=i?0:Math.max(0,(b?.total??g)-g),w=n.x+t*s+c/2,k=p(g),S=p(0)-k,A=r(y.pieces[0],d?h:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(he(w,k,u,S,A,M,d?h:n.name)),v>0){const t=p(g+v),e=k-t,i={...A},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};a.push(he(w,t,u,e,i,o,d?h:n.name))}}}return a},swimlane:function(t,e){const{scales:n,columns:i,getR:o,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:c}=n,l=[],u="horizontal"===c,d=t.config.gradientFill,h=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,[n,o]=a.range(),r=Math.min(n,o),s=Math.abs(o-n);for(const n of Object.values(i)){const i={fill:t,opacity:e},o=u?he(r,n.x,s,n.width,i,null,"__track__"):he(n.x,r,n.width,s,i,null,"__track__");l.push(o)}}const p=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=l.length;for(const n of t.pieceData){const i=Math.abs(o(n));if(0===i)continue;const c=r?r(n):t.name,f=s(n,c);let p;if(u){const o=a(e),r=a(e+i);p=he(o,t.x,r-o,t.width,f,n,c)}else{const o=a(e+i),r=a(e);p=he(t.x,o,t.width,r-o,f,n,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),e+=i}if(p>0&&l.length>n){const t=l.slice(n),e=t[0],i=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(e.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},Fy=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ny=["scene-style","data-paint","accessibility","evidence"],Oy=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Wy=new Set(["accessorRevision","axisExtent","categoryAccessor","chartType","extentPadding","groupBy","multiAxis","normalize","oAccessor","oExtent","oSort","rAccessor","rExtent","runtimeMode","stackBy","timeAccessor","valueAccessor"]),jy=new Set(["barColors","colorScheme","connectorStyle","pieceStyle","summaryStyle","themeCategorical","themeDiverging","themeSemantic","themeSequential"]),Yy=class{constructor(){this.tracker=new on}get last(){return this.tracker.last}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Fy)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Ny):this.recordNoop("restyle")}recordConfig(t){if(0===t.length)return this.tracker.record({kind:"config",keys:t},[]);const e=new Set(Oy);return t.some(t=>Wy.has(t))&&e.add("domain"),t.some(t=>jy.has(t))&&e.add("scene-style"),this.tracker.record({kind:"config",keys:t},e)}};import{quadtree as qy}from"d3-quadtree";var Hy=class{constructor(t){this.rExtent=new jt,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Yy,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.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 Wt(t.windowSize),this.getO=Xt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>qt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new jt)):(this.getR=qt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Xt(t.stackBy),this.getGroup=Xt(t.groupBy),this.getColor=Xt(t.colorAccessor),this.getSymbol=Xt(t.symbolAccessor),this.getConnector=Xt(t.connectorAccessor),this.getDataId=Xt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new Wt(t.windowSize))}syncPulseTimestampBuffer(){var t,e,n,i;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,n=this.timestampBuffer,i=te(),t?null!=n&&n.capacity===e.capacity&&n.size===e.size?n:Ze(e,i):null)}ingest(t){const e=te();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(),Ke(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const n of t.inserts)Qe(this.buffer,n,this.timestampBuffer,e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=Qe(this.buffer,n,this.timestampBuffer,e);this.categories.add(this.getO(n)),this.pushValueExtent(n),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 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,i=this.scales,o=this.multiScales,r=this.columns;if(0===n.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(n,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(d){f=Cy().domain(c).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,i=e.innerRadius||0;p=Ty().domain(l).range([i,n])}else u?(f=Cy().domain(c).range([0,t.height]).padding(h),p=Ty().domain(l).range([0,t.width])):(f=Cy().domain(c).range([0,t.width]).padding(h),p=Ty().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((i,o)=>{const r=this.rExtents[o];r.dirty&&r.recalculate(n,i);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?Ty().domain([s,a]).range([0,t.width]):Ty().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,n)=>({...t,__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),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=i,this.multiScales=o,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,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,i="auto"===e?void 0:e;let o=null;if(n){o=new Set;for(const e of t)o.add(this.getO(e))}const r=o?Array.from(this.categories).filter(t=>o.has(t)):Array.from(this.categories);if(n&&void 0===i){const t=Math.max(50,3*o.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;o.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===i)return r;if("function"==typeof i)return r.sort(i);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"===i?(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:n,projection:i,normalize:o,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=t,f=s;if("radial"===i&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&d&&o)p=0,y=1;else if("bar"===n&&d){const t=new Map,n=new Map;for(const i of e){const e=l(i),o=u(i);0>o?n.set(e,(n.get(e)||0)+o):t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e);for(const t of n.values())p>t&&(p=t)}else if("bar"===n){const t=new Map;for(const n of e){const e=l(n),i=u(n);t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===n){const t=new Map;for(const n of e){const e=l(n),i=Math.abs(u(n));t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===n||"bar-funnel"===n)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=h[0],e=h[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"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const t=y-p,e=t>0?t*f:1,i=g&&!a&&0===p,o=g&&!a&&0===y||"swimlane"===n;null!=r?.[0]||i||(p-=e),null!=r?.[1]||o||(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,n,i,o){return function(t){const{data:e,oExtent:n,oScale:i,projection:o,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 d=0;if("radial"===o)for(const t of e)d+=Math.abs(c(t));let h=null;if(s&&"radial"!==o){h=new Map;let t=0;for(const e of n){const n=u.get(e)||[];let i;i="string"==typeof s?n.reduce((t,e)=>t+(Number(e[s])||0),0):s(n),h.set(e,i),t+=i}const e=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*n.length;if(t>0)for(const[n,i]of h)h.set(n,i/t*e)}let f=0,p=0;for(const t of n){const e=u.get(t)||[],n=e.reduce((t,e)=>t+Math.abs(c(e)),0),o=d>0?n/d:0;let r,s;h?(r=p,s=h.get(t)||i.bandwidth(),p+=s+i.padding()*i.step()):(r=i(t)??0,s=i.bandwidth()),l[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:i.padding()*i.step(),pieceData:e,pct:o,pctStart:f},f+=o}return l}({data:t,oExtent:e,oScale:n,projection:i,layout:o,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.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];if(this.config.customLayout){const n=this.buildLayoutContext(t,e);let i;try{i=this.config.customLayout(n)}catch(t){const e=null!==this.lastCustomLayoutResult,n=We("ordinal",t,e,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.onLayoutError?.(n)}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=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const o=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of o)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(o,this.config.layoutSelection??null)}return Fe({label:"ordinal customLayout",nodes:o,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),o}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),i=By[this.config.chartType];let o=i?i(n,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:n,config:i,getConnector:o,getO:r}=t;if(!o||!n)return[];const s=[],{projection:a}=n,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=o(e);if(!n)continue;let i,s;"point"===t.type?(i=t.x,s=t.y):(i=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:i,y:s,datum:e,category:r(e)})}const l=n.o.domain(),u=i.connectorStyle;for(const[e,n]of c)if(n.length>=2){n.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;n.length-1>i;i++){const o=n[i],r=n[i+1],a="function"==typeof u?u(o.datum):u||{stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:a,datum:o.datum,group:e})}}return s}(n,o);o=[...t,...o]}return o}buildLayoutContext(t,e){const n=this.config,i=n.layoutMargin??{top:0,right:0,bottom:0,left:0},o=$d(n.colorScheme,n.themeCategorical,k),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:i,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:n.themeSemantic??{},categorical:[...o]},resolveColor:zd(o,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(t,e);return n&&!n.fill&&e?{...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||k,i=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,i),i}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?ee(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=ne(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 n="function"==typeof e,i=n?null:e||"category",o=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[i],c=o.get(a);c?c.push(r):o.set(a,[r])}return o}(t,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:e},e}rebuildPointQuadtree(){const t=function(t){let e=0,n=0;for(const i of t)"point"===i.type&&(e++,i.r>n&&(n=i.r));if(500>=e)return{quadtree:null,maxRadius:n};const i=Array(e);let o=0;for(const e of t)"point"===e.type&&(i[o++]=e);return{maxRadius:n,quadtree:qy().x(t=>t.x).y(t=>t.y).addAll(i)}}(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 n=e.length;if(1>=n)return;const i=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=i.get(e.datum);if(null==t)continue;const o=this.computeDecayOpacity(t,n);e.style={...e.style,opacity:(e.style?.opacity??1)*o}}}applyPulse(t,e,n=te()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,n,i,o,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 i=0;for(const s of o(e)??[]){const e=n.get(s);null!=e&&(i=Math.max(i,ie(t,e,r)))}c=oe(l,i,s)||c;continue}if(null==l.datum)continue;const e=i.get(l.datum);if(null==e)continue;const u=n.get(e);c=oe(l,null==u?0:ie(t,u,r),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),n)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&re(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(te())}synthesizeIntroPositions(){this.prevPositionMap.clear();const t=new Map,e=this.scales?.r(0)??0,n="horizontal"!==this.scales?.projection;let i;for(let o=0;this.scene.length>o;o++){const r=this.scene[o],s=this.getNodeKey(r,t);s&&("rect"===r.type?this.prevPositionMap.set(s,n?{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===i&&(i=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:i,endAngle:i,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,i=e.get(n)||0;return e.set(n,i+1),`${n}:${i}`}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 n=this.scene[e],i=this.getNodeKey(n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.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 n=new Set,i=new Map;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],r=this.getNodeKey(o,i);if(!r)continue;o._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===o.type)s?(n.add(r),o._targetOpacity=o.style.opacity??1,(s.x!==o.x||s.y!==o.y||void 0!==s.r&&s.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=s.x,o.y=s.y,void 0!==s.r&&(o.r=s.r),e=!0)):(o._targetOpacity=o.style.opacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},e=!0);else if("rect"===o.type)s?(n.add(r),o._targetOpacity=o.style.opacity??1,s.x===o.x&&s.y===o.y&&s.w===o.w&&s.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=s.x,o.y=s.y,o.w=s.w??o.w,o.h=s.h??o.h,e=!0)):(o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},e=!0);else if("wedge"===o.type)if(s)n.add(r),o._targetOpacity=o.style.opacity??1,s.startAngle===o.startAngle&&s.endAngle===o.endAngle||(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=s.startAngle,o.endAngle=s.endAngle,e=!0);else{o._targetOpacity=o.style.opacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;const t=o.startAngle;o.startAngle=t,o.endAngle=t,o.style={...o.style,opacity:0},this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:t,endAngle:t,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),e=!0}}this.exitNodes=[];for(const[t,i]of this.prevPositionMap)if(!n.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((i.startAngle??0)+(i.endAngle??0))/2,n={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}e=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),e&&(this.activeTransition={startTime:te(),duration:t})}advanceTransition(t){if(!this.activeTransition)return!1;const e=Qt(t,this.activeTransition),n=Zt(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 i=this.prevPositionMap.get(e);t.style.opacity=Jt(i?i.opacity??1:0,t._targetOpacity,n)}const i=this.prevPositionMap.get(e);void 0!==t._targetX&&i&&(t.x=Jt(i.x,t._targetX,n),t.y=Jt(i.y,t._targetY,n)),void 0!==t._targetR&&void 0!==i?.r&&(t.r=Jt(i.r,t._targetR,n))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style.opacity=Jt(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=Jt(i.x,t._targetX,n),t.y=Jt(i.y,t._targetY,n),void 0!==i.w&&(t.w=Jt(i.w,t._targetW,n),t.h=Jt(i.h,t._targetH,n))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style={...t.style,opacity:Jt(i?i.opacity??1:0,t._targetOpacity,n)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=Jt(i.startAngle,t._targetStartAngle,n),t.endAngle=Jt(i.endAngle,t._targetEndAngle,n))}}}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()}getLastUpdateResult(){return this.updateResults.last}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Kt(t),n=this.getDataId,i=t=>e.has(n(t));Je(this.buffer,this.timestampBuffer,i);const o=this.buffer.remove(i);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const t of o)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime=te(),this.updateResults.recordData("remove",o.length),o}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=Kt(t),i=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(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)),o.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime=te(),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._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){const n=this._customRestyle;if(n)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},o=n(i,e);i.style=o?{...t,...o}: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},n=Object.keys(t).filter(n=>t[n]!==e[n]);"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&&!Yt(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!Yt(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!Yt(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in t||"oAccessor"in t)&&(Yt(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=Xt(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let o=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,n=e.valueAccessor||e.rAccessor,i=Array.isArray(t)?t:[t],r=Array.isArray(n)?n:[n];if(o=i.length!==r.length||i.some((t,e)=>!Yt(t,r[e])),o){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>qt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new jt)):(this.getR=qt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!Yt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?Xt(this.config.stackBy):void 0),"groupBy"in t&&!Yt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?Xt(this.config.groupBy):void 0),"colorAccessor"in t&&!Yt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Xt(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!Yt(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Xt(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!Yt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Xt(this.config.connectorAccessor):void 0),(i||o||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};import{jsx as Xy,jsxs as Gy}from"react/jsx-runtime";import{Fragment as Vy,jsx as Uy,jsxs as Ky}from"react/jsx-runtime";function Zy(t,e){const n=qp(t.theme),i=t.size||[500,400],o={top:20,right:20,bottom:30,left:40,...t.margin},r=I(t.data),s=t.showLegend?ay(r,t.colorAccessor||t.stackBy||t.groupBy):[],a=t.legendPosition;ji(t.legend)||Yi(t.legend)?by(o,{legend:t.legend,theme:n,position:a||"right",size:i,hasTitle:!!t.title,legendLayout:t.legendLayout}):t.showLegend&&s.length>0&&xy(o,{categories:s,colorScheme:t.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!t.title,legendLayout:t.legendLayout});const c=i[0]-o.left-o.right,l=i[1]-o.top-o.bottom,u=t.projection||"vertical",d="radial"===u,h={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:u,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||n.colors.categorical,themeCategorical:n.colors.categorical,themeSemantic:Lt(n),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:o,layoutSelection:t.layoutSelection,barColors:t.barColors},f=new Hy(h);if(t.data&&f.ingest({inserts:r,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return e&&(e.evidence=Vp({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),Iy.renderToStaticMarkup(ky(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${o.left},${o.top})`,innerWidth:c,innerHeight:l,idPrefix:t._idPrefix}));if(e){const n=f.scales.o?.domain?.();e.evidence=Vp({frameType:"ordinal",width:i[0],height:i[1],marks:f.scene,title:t.title,description:t.description,annotations:t.annotations,yDomain:Gp(f.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0})}const p=t._idPrefix,y=t.showGrid?function(t,e,n,i){const o=t.scales;if(!o||"radial"===o.projection)return null;const{grid:r}=Hp(n),s=i?i+"-":"",a="vertical"===o.projection,c=o.r.ticks(5);return yy("g",a?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,n)=>{const i=o.r(t);return yy("line",{x1:0,y1:i,x2:e.width,y2:i,stroke:r,strokeWidth:.5},"gr-"+n)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,n)=>{const i=o.r(t);return yy("line",{x1:i,y1:0,x2:i,y2:e.height,stroke:r,strokeWidth:.5},"gr-"+n)})})}(f,{width:c,height:l},n,p):null;let g=null;if(f.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 n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let i=0;for(let t=0;n.length>t;t++)i=31*i+n.charCodeAt(t)|0;return"c"+(i>>>0).toString(36)}(t),i=new Set;for(const t of f.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&i.add("string"==typeof t.style.fill?t.style.fill:"#666");g=Array.from(i).map((t,i)=>function(t){const{id:e,background:n="transparent",stroke:i="#000",lineWidth:o=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return Gy("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&Xy("rect",{width:a,height:a,fill:n}),Xy("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:o}),Xy("line",{x1:r,y1:0,x2:r,y2:a,stroke:i,strokeWidth:o})]},e)}({id:`funnel-hatch-${e}-${i}`,background:t,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const o=new Map;Array.from(i).forEach((t,n)=>o.set(t,`funnel-hatch-${e}-${n}`));for(const t of f.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&(t.style={...t.style,fill:`url(#${o.get("string"==typeof t.style.fill?t.style.fill:"#666")})`})}const m=f.scene.map((t,e)=>Hr(t,e,p)).filter(Boolean),x=!1!==t.showAxes?function(t,e,n,i,o){const r=t.scales;if(!r)return null;if("radial"===r.projection)return null;const s=Hp(i),a="vertical"===r.projection,c=n.categoryFormat||n.oFormat,l=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,d=n.valueLabel||n.rLabel,h=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||wy)(t)}));return Ky("g",a?{id:(o?o+"-":"")+"axes",className:"ordinal-axes",children:[Uy("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),h.map((t,n)=>Ky("g",{transform:`translate(${t.pixel},${e.height})`,children:[Uy("line",{y2:5,stroke:s.border,strokeWidth:1}),Uy("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+n)),u&&Uy("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),Uy("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,e)=>Ky("g",{transform:`translate(0,${t.pixel})`,children:[Uy("line",{x2:-5,stroke:s.border,strokeWidth:1}),Uy("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),d&&Uy("text",{x:15-(n.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${e.height/2})`,children:d})]}:{id:(o?o+"-":"")+"axes",className:"ordinal-axes",children:[Uy("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,n)=>Ky("g",{transform:`translate(${t.pixel},${e.height})`,children:[Uy("line",{y2:5,stroke:s.border,strokeWidth:1}),Uy("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+n)),d&&Uy("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:d}),Uy("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),h.map((t,e)=>Ky("g",{transform:`translate(0,${t.pixel})`,children:[Uy("line",{x2:-5,stroke:s.border,strokeWidth:1}),Uy("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),u&&Uy("text",{x:15-(n.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${e.height/2})`,children:u})]})}(f,{width:c,height:l},t,n,p):null,b=t.annotations?fy({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:c,height:l},theme:n,projection:u,idPrefix:p}):null,v=t.showLegend?0===s.length?null:sy({categories:s,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:o,hasTitle:!!t.title,legendLayout:t.legendLayout}):null,w=_y.isValidElement(t.legend)?t.legend:vy(t.legend,{theme:n,position:t.legendPosition||"right",size:i,margin:o,hasTitle:!!t.title,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||v,k=d?o.left+c/2:o.left,S=d?o.top+l/2:o.top;return Iy.renderToStaticMarkup(ky(Ky(Vy,{children:[t.backgroundGraphics,y,m,x,b,t.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${k},${S})`,innerWidth:c,innerHeight:l,legend:w,defs:g,idPrefix:t._idPrefix}))}import*as Qy from"react";import*as Jy from"react-dom/server";function tg(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function eg(t,e){var n,i=[],o=[],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,i,d=!1;for(o.push(t),r[t]=!0,e=0;a[t].length>e;e++)(i=a[t][e])===n?(u(n,o),d=!0):r[i]||(d=l(i));if(d)c(t);else for(e=0;a[t].length>e;e++){var h=s[i=a[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,n){var o=[].concat(n).concat(t);e?e(o):i.push(o)}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,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)n[c]=-1,i[c]=0,o[c]=!1,r[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(e){var c=[e],l=[e];for(n[e]=i[e]=u,o[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>n[y]){n[y]=i[y]=u,o[y]=!0,u+=1,c.push(y),l.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>s[y]||a[e].push(s[y])}r[e]=p}else{if(i[e]===n[e]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(o[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=d.length,b===e){c.length=p;break}}d.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];h.push(v)}l.pop()}}}for(c=0;e>c;++c)0>n[c]&&f(c);for(c=0;h.length>c;c++){var p=h[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]);h[c]=l}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)r>o[s][a]&&(r=o[s][a],n=s);var c=o[n];return!!c&&{leastVertex:r,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=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(n),n+=1}else n=h}return e?void 0:i}function ng(t){return t.y0-t.y1>0?"up":"down"}function ig(t,e){return e(t.source)==e(t.target)}function og(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 rg(t){return t.target.x0-t.source.x1}function sg(t,e){var n=cg(t),i=rg(e)/Math.tan(n);return"up"==ng(t)?t.y1-i:t.y1+i}function ag(t,e){var n=cg(t),i=rg(e)/Math.tan(n);return"up"==ng(t)?t.y1+i:t.y1-i}function cg(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function lg(t,e){return e(t)}function ug(t){return hg(t.source)}function dg(t){return hg(t.target)}function hg(t){return(t.y0+t.y1)/2}function fg(t){return t.virtual?0:t.value}function pg(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!ig(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!ig(t,e)?i+1:i}),n+i}function yg(t){return t.target.depth}function gg(t,e){return t.sourceLinks.length?t.depth:e-1}function mg(t,e){return t.y0-e.y0}function xg(t,e){return e.y0-t.y0}function bg(t,e){return t.y1-e.y1}function vg(t,e){return e.y1-t.y1}function wg(t,e){return Sg(t.source,e.source)||t.index-e.index}function kg(t,e){return Sg(t.target,e.target)||t.index-e.index}function Sg(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ag(t,e){return Mg(t)==Mg(e)?"bottom"==t.circularLinkType?xg(t,e):mg(t,e):Mg(e)-Mg(t)}function Mg(t){return t.target.column-t.source.column}function Pg(t,e){return _g(t)==_g(e)}function _g(t){return t.y0-t.y1>0?"up":"down"}import{min as Ig}from"d3-array";function Cg(t,e,n,i,o){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=Ig(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}),Tg(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Tg(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+i,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,ig(t,e)&&og(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+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-o-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?xg:mg);var u=0;l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+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?vg:bg),u=0,l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+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-o-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,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function Tg(t,e,n){t.sort(Ag);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(ig(t,e)&&og(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Rg(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=c>r?c:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function Rg(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as Lg,max as $g,sum as zg,mean as Dg,group as Eg,groups as Bg}from"d3-array";function Fg(t){return function(){return t}}function Ng(t){return t.index}function Og(t){return t.nodes}function Wg(t){return t.links}function jg(t,e,n){var i=Bg(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var a=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=hg(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=hg(t.target)*e,i+=e}}),i>0?o/i:NaN);a.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=a.get(t),i=a.get(e),o=n.bc,r=i.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(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?pg(e,n)-pg(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.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==pg(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function Yg(t,e,n,i,o,r){var s=Bg(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,n),u();function l(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&pg(o,n)>0){var c=Dg(o.sourceLinks,dg),l=Dg(o.targetLinks,ug),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-hg(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=Dg(o.sourceLinks,dg),f=Dg(o.targetLinks,ug),p=((h&&f?(h+f)/2:h||f)-hg(o))*e;o.y0+=p,o.y1+=p}})})}function u(){s.forEach(function(n){var r,s,a,c=t.y0,l=n.length;for(n.sort(e||Sg),a=0;l>a;++a)(s=c-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+i;if((s=c-i-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=n[a]).y1+o-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function qg(t){t.nodes.forEach(function(t){t.sourceLinks.sort(kg),t.targetLinks.sort(wg)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function Hg(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=Ng,c=gg,l=void 0,u=32,d=2,h=Og,f=Wg;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.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 Eg(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 i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=tg(n,i)),"object"!=typeof o&&(o=t.target=tg(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,a=r.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=eg(i);c.sort(function(t,e){return t.length-e.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||l[i]&&l[i][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++)})}(h,l),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){lg(t,e)!=lg(o.source,e)&&lg(t,e)!=lg(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),ig(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(zg(t.sourceLinks,fg),zg(t.targetLinks,fg)),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)})})}(h),function(t,e,n){var i,o,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(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,l,c);var f=r;if(null!==s){var p=Bg(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=$g(p,function(t){return t.length});y>1&&(f=Math.max(1,(i-e)*s/(y-1)))}(function(t,e,n){var i=Bg(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 o=Lg(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/zg(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=$g(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})})(h,f,o),jg(h,l,a),Yg(h,l,a,f,f,u),qg(h),Cg(h,a,d,10,8),jg(h,l,a),Yg(h,l,a,f,f,u),qg(h),Cg(h,a,d,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 i=n.links.filter(function(n){return lg(n.source,e)==lg(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Pg(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=sg(e,t);return t.y1-n}if(e.target.column>t.target.column)return sg(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;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return lg(n.target,e)==lg(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Pg(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=ag(e,t);return t.y0-n}if(e.source.column>t.source.column)return ag(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;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){let i=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=Lg(e,function(t){return t.y0}),s=$g(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1)}),n.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=i(t.y0)-t.y0;t.y0=i(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})})}}(h),Cg(h,a,d,10,8)}(p),p}return p.update=function(t){return qg(t),Cg(t,a,d,10,8),t},p.nodeWidth=function(t){return arguments.length?(o=+t,p):o},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?(h="function"==typeof t?t:Fg(t),p):h},p.links=function(t){return arguments.length?(f="function"==typeof t?t:Fg(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Fg(t),p):a},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Fg(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?(d=+t,p):d},p.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],p):[[t,e],[n,i]]},p.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],p):[n-t,i-e]},p}import{interpolateNumber as Xg}from"d3-interpolate";import{line as Gg,curveLinearClosed as Vg}from"d3-shape";var Ug=t=>{let e,n,i,o,r,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=Xg(r,s),c=a(.5),l=a(.5),`M${e},${r}C${e},${c} ${n},${l} ${n},${s}L${i},${s}C${i},${l} ${o},${c} ${o},${r}Z`;const u=t.sankeyWidth/2,d=Xg(t.source.x1,t.target.x0),{pathD:h}=ql({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:d(.5),cp2X:d(.5)});return h};function Kg(t){const e=t.sankeyWidth/2,n=(t._circularWidth??t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const n=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-n))),c=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${n},${o-e}L${n+a},${o-e}L${n+a},${o+e}L${n},${o+e}ZM${r},${s-e}L${r-c},${s-e}L${r-c},${s+e}L${r},${s+e}Z`}const o=i.sourceX,r=i.sourceY,s=i.targetX,a=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${o},${r-d*e}L${c},${r-d*e}L${c+n},${r-d*e+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${a-d*e+d*h}L${l-n+h},${a-d*e}L${s},${a-d*e}L${s},${a+d*e}L${l+n},${a+d*e}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${r+d*e}L${o},${r+d*e}Z`}var Zg=new Set,Qg=new WeakMap;function Jg(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Qg.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Qg.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Zg.has(t)||(Zg.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,i)}});return n.set(e,i),i}var tm={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(yg))-1:0},justify:gg};function em(t){return"string"==typeof t?t:t.id}var nm={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const o="vertical"===n.orientation?"down":"right",r=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.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 d;d="down"===o?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const h=Hg().extent(d).links(u).nodes(l).nodeAlign(tm[r]||gg).nodeId(t=>t.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of l)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(i._circularWidth??i.width??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>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,a=i[0],c=i[1];if(r>0&&s>0&&(0>t||0>n||e>a||o>c)){const e=Math.min(a/r,c/s),i=-t*e+(a-r*e)/2,o=-n*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of u)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,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 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=em(t.source),n=em(t.target),i=p.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=t.width??0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=o;const r=f.get(e),s=f.get(n);r&&(i.source=r),s&&(i.target=s)}}},buildScene(t,e,n,i){const o="vertical"===n.orientation?"down":"right",r=n.nodeStyle,a=n.edgeStyle,c=n.edgeOpacity??.5,l=n.edgeColorBy||"source",u=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:s,d=new Map;t.forEach((t,e)=>{d.set(t.id,u[e%u.length])});const h=[],f=[],p=[],y=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 i=r?r(Jg(e,"nodeStyle")):{},s={fill:i.fill||d.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};y.set(e.id,("string"==typeof s.fill?s.fill:null)||d.get(e.id)||"#4d430c"),h.push("down"===o?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:s,datum:e,id:e.id,label:e.id})}const g=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of g){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(t)||o:"target"===l?y.get(i.id)||d.get(i.id)||o:y.get(e.id)||d.get(e.id)||o;const r=a?a(Jg(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),a=r.fill||o;f.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:a,fillOpacity:r.fillOpacity??c,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),f.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:a,fillOpacity:r.fillOpacity??c,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let s;(s=t.circular&&t.circularPathData?Kg(t):Ug(t),s)&&f.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:{fill:r.fill||o,fillOpacity:r.fillOpacity??c,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity},datum:t})}if(!1!==n.showLabels){const e=(m=n.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const s=e?e(n):n.id;if(!s)continue;let a,c,l;"down"===o?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(i[0]/2>n.x0+t/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+r/2),p.push({x:a,y:c,text:s+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:h,sceneEdges:f,labels:p}}};import{forceSimulation as im,forceCenter as om,forceX as rm,forceY as sm,forceLink as am,forceManyBody as cm,forceCollide as lm}from"d3-force";import{scaleLinear as um}from"d3-scale";var dm={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const o=n.forceStrength??.1,r=i[0]/2,s=i[1]/2,a=n.__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),n=a?.get(e.id);t?c++:n?(e.x=n.x,e.y=n.y,c++):l.push(e)}const u=c>0&&.3>=(t.length>0?l.length/t.length:1);if(u){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of l){const i=hm(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=fm(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=fm(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=r+i*Math.cos(n),t.y=s+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=r+t*Math.cos(o),i.y=s+t*Math.sin(o)}}}const d=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),h=pm(n.nodeSize,n.nodeSizeRange,t),f=t=>h(t);if(d>0){const n=new Map,i=new Map;for(const e of t)n.set(e.id,0),i.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;n.set(e,(n.get(e)??0)+1),n.set(i,(n.get(i)??0)+1)}const a=am().strength(t=>{const e=t.weight,i="string"==typeof t.target?t.target:t.target.id,r=Math.max(1,Math.min(n.get("string"==typeof t.source?t.source:t.source.id)??1,n.get(i)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*o/(.1*r))}).distance(t=>{const e="string"==typeof t.source?i.get(t.source):t.source,n="string"==typeof t.target?i.get(t.target):t.target,o=(e?f(e):0)+(n?f(n):0)+12;return Math.max(40,o)}).id(t=>t.id),c=im().force("charge",cm().strength(t=>{const e=n.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",lm(t=>f(t)+3).strength(.9).iterations(2)).force("center",om(r,s).strength(.8)).force("x",rm(r).strength(.06)).force("y",sm(s).strength(.06));if(c.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}));a.links(t),c.force("link",a)}u?c.alpha(.3):.1>c.alpha()&&c.alpha(1),c.stop();for(let t=0;d>t;++t)c.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(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[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,n,i){const o=n.nodeStyle,r=n.edgeStyle,a=pm(n.nodeSize,n.nodeSizeRange,t),c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:s,l=new Map;t.forEach((t,e)=>{l.set(t.id,c[e%c.length])});const u=[],d=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=a(Jg(e,"nodeSize")),i=o?o(Jg(e,"nodeStyle")):{},r={fill:i.fill||l.get(e.id)||n.themeSemantic?.primary||"#007bff",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity};u.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:f.get(t.source),i="object"==typeof t.target?t.target:f.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=r?r(Jg(t,"edgeStyle")):{};d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:t})}if(!1!==n.showLabels){const e=(p=n.nodeLabel)?"function"==typeof p?p:t=>t[p]||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 i=a(Jg(n,"nodeSize"));h.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:u,sceneEdges:d,labels:h}}};function hm(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.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||i.push({x:t.x,y:t.y})}}return i}function fm(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 pm(t,e,n){if(n.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 i=e||[5,20],o=[];for(const e of n){const n=e.data?.[t];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>i[0];const[r,s]=Vi(o);if(r===s)return()=>(i[0]+i[1])/2;const a=um().domain([r,s]).range(i).clamp(!0);return e=>{const n=e.data?.[t];return null==n||"number"!=typeof n?i[0]:a(n)}}import{chord as ym,ribbon as gm}from"d3-chord";import{arc as mm}from"d3-shape";var xm=s,bm={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,c=a-r,l=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>t[h]??1:t=>t.value??1;var h;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,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);y[n][i]=o}const g=ym().padAngle(o);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=mm().innerRadius(c).outerRadius(a);for(const e of x){const n=t[e.index],i=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+l,n.y=i[1]+u,n.__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,n=v.get("string"==typeof t.source?t.source:t.source.id),i=v.get(e);n&&(t.source=n),i&&(t.target=i)}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 n=t[e.source.index].id,i=t[e.target.index].id,o=w.get(`${n}\0${i}`)||w.get(`${i}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,i){const{groupWidth:o=20,edgeOpacity:r=.5}=n,s=Math.min(i[0],i[1])/2,a=s-o,c=i[0]/2,l=i[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:xm,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=gm().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let o;o=u?u(Jg(n,"nodeStyle")).fill||p.get(n.id)||f[e%f.length]:p.get(n.id)||f[e%f.length];const r=u?u(Jg(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:{fill:o,stroke:r.stroke||"black",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=y(e);if(!i)continue;const o=vm(i,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Jg(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===h&&n?s=p.get(n.id)||s:e&&(s=p.get(e.id)||s)}const a=d?d(Jg(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,i=s+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*i,y:l+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function vm(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}import{hierarchy as wm,tree as km,cluster as Sm,treemap as Am,pack as Mm,partition as Pm,treemapBinary as _m}from"d3-hierarchy";var Im=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Cm(t){const[e,n,i]=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*i>150?"#222":"#fff"}function Tm(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Rm(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 Lm(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Im}function $m(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 zm(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}var Dm={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;if(!o)return;const r=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=wm(o,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,d]=i;switch(r){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=km();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(l,n,u,d);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=Sm();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(l,n,u,d);break;case"treemap":!function(t,e,n,i){const o=e.padding??4,r=e.paddingTop??0,s=Am().size([n,i]).tile(_m).padding(o);r>0&&s.paddingTop(r),s(t)}(l,n,u,d);break;case"circlepack":!function(t,e,n,i){const o=e.padding??4;Mm().size([n,i]).padding(o)(t)}(l,n,u,d);break;case"partition":!function(t,e,n,i){Pm().size([n,i]).padding(e.padding??1)(t)}(l,n,u,d)}const h=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;h.length>e;e++){const i=h[e],o={id:Tm(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===r||"cluster"===r?Em(o,i,n):"treemap"===r||"partition"===r?Bm(o,i):"circlepack"===r&&Fm(o,i),o.__hierarchyNode=i,t.push(o),f.set(i,o)}if("tree"===r||"cluster"===r)for(const t of h)if(t.parent){const n=f.get(t.parent),i=f.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=i[0]/2,h=i[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const e of t){let t=e.x,i=e.y;u&&(t+=d,i+=h);const r=o(Jg(e,"nodeStyle"));let a=r.fill||$m(n);if(n.colorByDepth&&void 0!==e.depth){const t=Lm(n);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:i,r:f,style:{fill:a,stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=n.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,c=i.x,f=i.y;u&&(o+=d,s+=h,c+=d,f+=h);const p=zm(o,s,c,f,l),g=r(Jg(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:t})}if(!1!==n.showLabels){const e=Rm(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const t=s-d,e=a-h,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=a+e/n*10,r=0>t?"end":"start"):(i=s,o=a-12,r="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(i=s-f-6,r="end"):(i=s+f+6,r="start"),o=a):(i=s,o=a+f+14,r="middle");c.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){const o=[],r=[];for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const s=i(Jg(n,"nodeStyle"));let a=s.fill||$m(e);if(e.colorByDepth&&void 0!==n.depth){const t=Lm(e);a=t[n.depth%t.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Rm(e.nodeLabel),o=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"===o&&!l)continue;if("parent"===o&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let d=i(Jg(a,"nodeStyle")).fill||$m(e);if(e.colorByDepth&&void 0!==a.depth){const t=Lm(e);d=t[a.depth%t.length]}const h="string"==typeof d?Cm(d):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:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:r}}(t,n,0,o);case"circlepack":return function(t,e,n,i){const o=[],r=[];for(const n of t){const t=n.__radius??5;if(0>=t)continue;const r=i(Jg(n,"nodeStyle"));let s=r.fill||$m(e);if(e.colorByDepth&&void 0!==n.depth){const t=Lm(e);s=t[n.depth%t.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Rm(e.nodeLabel);for(const o of t){const t=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>t)continue;const a=!(o.data?.children&&o.data.children.length>0);let c=i(Jg(o,"nodeStyle")).fill||$m(e);if(e.colorByDepth&&void 0!==o.depth){const t=Lm(e);c=t[o.depth%t.length]}if(a){const n="string"==typeof c?Cm(c):e.themeSemantic?.text??"#000";r.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else r.push({x:o.x,y:o.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:o,sceneEdges:[],labels:r}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Em(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 Bm(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 Fm(t,e){const n=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-n,t.x1=e.x+n,t.y0=e.y-n,t.y1=e.y+n,t.width=2*n,t.height=2*n,t.__radius=n}import{pie as Nm}from"d3-shape";function Om(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var Wm={sankey:nm,force:dm,chord:bm,tree:Dm,cluster:Dm,treemap:Dm,circlepack:Dm,partition:Dm,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){const r=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(n.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=Om(n);h.metaMap.clear(),i.length=0,o.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));i.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}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,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:n,depth:y,data:e,parentId:n},M=g?f/u(A)*S:f*S,P=Nm().value(t=>{const e=r(t)?.length;return e?4:1}).sort(null)(w),_=d(A);for(let e=0;w.length>e;e++){const r=(P[e].startAngle+P[e].endAngle)/2,a=w[e],u=p(s(a)),d=c+M*Math.sin(r),f=l+M*Math.cos(r)*_;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:r,depth:y,parentId:n,eccentricity:_}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(a,u,d,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){const o=n.nodeStyle,r=n.nodeSize,s="number"==typeof r?()=>r:"function"==typeof r?r:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const e=Om(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.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:i}]of o)for(let o=0;r>o;o++){const a=o/r*Math.PI*2,l=(o+1)/r*Math.PI*2;c.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*i,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(Jg(e,"nodeSize")),i=o?o(Jg(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:i.fill||n.themeSemantic?.primary||"#6366f1",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.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),n="object"==typeof t.target?t.target:u.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&c.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=s(Jg(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e?n.data?.[e]??n.id:n.id;l.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){const n=Om(e),i=e.orbitSpeed??.25,o=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())-n.startTime)/1e3,s=i*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=n.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=a.get(t.parentId);if(!i)continue;const c=t.angle+r*s*o({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(c),e.y=i.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,n),!0)}};import{Fragment as jm,jsxs as Ym}from"react/jsx-runtime";function qm(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var Hm=new Set(["tree","cluster","treemap","circlepack","partition"]);function Xm(t,e){const n=qp(t.theme),i=t.chartType||"force",o=()=>Vp({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],a={top:20,right:20,bottom:20,left:20,...t.margin},c=t.showLegend?(()=>{const e="string"==typeof(n=t.colorBy)||"function"==typeof n?t.colorBy:void 0;var n;if(!e)return[];const i=I(t.nodes||[]);if(i.length>0)return ay(i,e);const o=Array.isArray(t.edges)?I(t.edges):[];if(0===o.length)return[];const r=qm(t.sourceAccessor,"source"),s=qm(t.targetAccessor,"target");return ay(Array.from(new Set(o.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[],l=t.legendPosition;ji(t.legend)||Yi(t.legend)?by(a,{legend:t.legend,theme:n,position:l||"right",size:r,hasTitle:!!t.title,legendLayout:t.legendLayout}):t.showLegend&&c.length>0&&xy(a,{categories:c,colorScheme:t.colorScheme,theme:n,position:l||"right",size:r,hasTitle:!!t.title,legendLayout:t.legendLayout});const u=r[0]-a.left-a.right,d=r[1]-a.top-a.bottom,h=function(t){return Wm[t]}(i);if(!h&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const f={chartType:i,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||n.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(Hm.has(i)){const i=t.data||t.edges;if(!i||Array.isArray(i))return e&&(e.evidence=o()),Jy.renderToStaticMarkup(ky(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:n,innerTransform:`translate(${a.left},${a.top})`,innerWidth:u,innerHeight:d,idPrefix:t._idPrefix}));f.__hierarchyRoot=i,p=[],y=[]}else{const i=I(t.nodes||[]),s=Array.isArray(t.edges)?I(t.edges):[];if(0===i.length&&0===s.length)return e&&(e.evidence=o()),Jy.renderToStaticMarkup(ky(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:n,innerTransform:`translate(${a.left},${a.top})`,innerWidth:u,innerHeight:d,idPrefix:t._idPrefix}));if(y=function(t,e){const n=qm(e.sourceAccessor,"source"),i=qm(e.targetAccessor,"target"),o=qm(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:i(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(s,f),0===i.length&&y.length>0){const t=new Set;for(const e of y){const n=my(e.source),i=my(e.target);n&&t.add(n),i&&t.add(i)}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 n=qm(e.nodeIDAccessor,"id");return t.map(t=>({id:n(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}))}(i,f)}let g=[],m=[],x=[],b=null;if(f.customNetworkLayout){const t=f.colorScheme,e=$d(t,n.colors.categorical,s),i=zd(e,t),o={nodes:p,edges:y,dimensions:{width:u,height:d,plot:{x:0,y:0,width:u,height:d}},theme:{semantic:n.colors,categorical:[...e]},resolveColor:i,config:f.layoutConfig??{}},r=f.customNetworkLayout(o);g=r.sceneNodes??[],m=r.sceneEdges??[],x=r.labels??[],b=r.overlays??null}else if(h){h.computeLayout(p,y,f,[u,d]);const t=h.buildScene(p,y,f,[u,d]);g=t.sceneNodes,m=t.sceneEdges,x=t.labels}const v=Hp(n);for(const t of x)t.fill||(t.fill=v.text);e&&(e.evidence=Vp({frameType:"network",width:r[0],height:r[1],marks:[...g.map(t=>({type:"node:"+(t.type??"node")})),...m.map(t=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,nodeCount:g.length,edgeCount:m.length}));const w=m.map((t,e)=>function(t,e){switch(t.type){case"line":return Br("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 n=t;return Br("path",{d:n.pathD,fill:Or(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"ribbon":{const n=t;return Br("path",{d:n.pathD,fill:Or(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"curved":{const n=t;return Br("path",{d:n.pathD,fill:Or(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+e)}default:return null}}(t,e)).filter(Boolean),k=g.map((t,e)=>function(t,e){switch(t.type){case"circle":{const n=t;return Br("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:Or(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+e)}case"rect":{const n=t;return Br("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Or(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+e)}case"arc":{const n=t,i=Lr().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Nr)||"";return Br("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:Or(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+e)}case"symbol":{const n=t,i=$e(n.symbolType,n.size,n.path);return Br("path",{d:i,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Or(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+e)}case"glyph":return jr(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e)).filter(Boolean),S=x.map((t,e)=>function(t,e){return Br("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),A=t.annotations?fy({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{},layout:{width:u,height:d},theme:n,idPrefix:t._idPrefix}):null,M=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;if(!e)return[];const o=ay(p.length>0?p.map(t=>t.data||{id:t.id}):Array.from(new Set(y.flatMap(t=>[my(t.source),my(t.target)]).filter(Boolean))).map(t=>({id:t})),e);return 0===o.length?null:sy({categories:o,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:a,hasTitle:!!t.title,legendLayout:t.legendLayout})})():null,P=Qy.isValidElement(t.legend)?t.legend:vy(t.legend,{theme:n,position:t.legendPosition||"right",size:r,margin:a,hasTitle:!!t.title,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||M;return Jy.renderToStaticMarkup(ky(Ym(jm,{children:[t.backgroundGraphics,w,k,S,A,t.foregroundGraphics,b]}),{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${a.left},${a.top})`,innerWidth:u,innerHeight:d,legend:P,idPrefix:t._idPrefix}))}import*as Gm from"react";import*as Vm from"react-dom/server";import{geoPath as Um,geoGraticule as Km,geoDistance as Zm,geoInterpolate as Qm}from"d3-geo";import{quadtree as Jm}from"d3-quadtree";import{geoMercator as tx,geoEqualEarth as ex,geoAlbersUsa as nx,geoOrthographic as ix,geoNaturalEarth1 as ox,geoEquirectangular as rx}from"d3-geo";var sx={mercator:tx,equalEarth:ex,albersUsa:nx,orthographic:ix,naturalEarth:ox,equirectangular:rx};function ax(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function cx(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function lx(t,e,n){return t?"function"==typeof t?{...n,...t(e)}:{...n,...t}:{...n}}function ux(t,e){if(2>t.length)return[t];const n=.4*e,i=[];let o=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>o.length||i.push(o),o=[r]):o.push(r)}return 2>o.length||i.push(o),i}function dx(t,e,n=24){const i=e[0]-t[0],o=e[1]-t[1],r=Math.sqrt(i*i+o*o);if(0===r)return[t,e];const s=-o/r,a=i/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,d=[];for(let i=0;n>=i;i++){const o=i/n,r=1-o;d.push([r*r*t[0]+2*r*o*l+o*o*e[0],r*r*t[1]+2*r*o*u+o*o*e[1]])}return d}function hx(t,e){if(2>t.length)return t;const n=e/2+1,i=[];for(let e=0;t.length>e;e++){const o=t[e];let r,s;0===e?(r=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(r=o[0]-t[e-1][0],s=o[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;i.push([o[0]+s/a*n,o[1]+-r/a*n])}return i}function fx(t,e,n,i,o){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=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}import{scaleLinear as px}from"d3-scale";var yx=class t{constructor(t){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._stylePaintPending=!1,this.config=t}updateConfig(t){this.config={...this.config,...t},"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null)}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 Wt(t),this.timestampBuffer=new Wt(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=te();Qe(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e}pushMany(t){this.pointBuffer||this.initStreaming();const e=te();for(const n of t)Qe(this.pointBuffer,n,this.timestampBuffer,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],i=new Set(Array.isArray(t)?t:[t]),o=[];return this.lineData=this.lineData.filter(t=>!i.has(n(t)+"")||(o.push(t),!1)),o.length>0&&this.version++,o}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],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(n(t)+"");Je(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!i.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.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++}setLayoutSelection(t){this.config.layoutSelection=t}consumeStylePaintPending(){const t=this._stylePaintPending;return this._stylePaintPending=!1,t}restyleScene(t){const e=this._customRestyle;if(e){for(const n of this.scene){const i=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...i,...o}:i}this._stylePaintPending=!0}}computeScene(t){const{config:e}=this,n=this.projection,i=this.geoPath,o=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return ex();if("string"==typeof t){const e=sx[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),ex())}if("object"==typeof t&&"type"in t){const e=sx[t.type],n=e?e():ex();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=Um(this.projection),this.fitProjection(t),this.geoPath=Um(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=n,this.geoPath=i,this.scales=o,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,n=t.height/2,i=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,n=this.config,i=[...this.areas],o=ax(n.xAccessor,"lon"),r=ax(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[o(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=cx(n.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[o(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==i.length){if(n.projectionExtent){const[[i,o],[r,s]]=n.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,o],[r,o],[r,s],[i,s],[i,o]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const i=n.fitPadding??0,o=Math.min(t.width,t.height);e.scale(o/2-o*i),e.translate([t.width/2,t.height/2])}else{const o={type:"FeatureCollection",features:i},r=n.fitPadding??0;1>r||"undefined"==typeof process||"production"===process.env.NODE_ENV||console.warn(`[semiotic] fitPadding=${r} looks like pixels, but it's a fraction of the plot (0–0.5). A value >= 1 collapses the projection off-canvas — use e.g. 0.06.`);const s=t.width*r,a=t.height*r;e.fitExtent([[s,a],[t.width-s,t.height-a]],o)}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;if(!n)return;const i=this.geoPath,o=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;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=Um(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._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;if(!n)return;const i=this.geoPath,o=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Um(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._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;if(!n||!n.rotate)return;const i=this.geoPath,o=this.scales,r=[...n.rotate()];n.rotate(t),this.geoPath=Um(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._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(r),this.geoPath=i,this.scales=o):(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,n=0;for(const t of this.scene)"point"===t.type&&(n++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const i=Array(n);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=Jm().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,n=this.projection,i=this.geoPath,o=ax(e.xAccessor,"lon"),r=ax(e.yAccessor,"lat");if(e.customLayout&&this.scales){const n=e.layoutMargin??{top:0,right:0,bottom:0,left:0},i=$d(e.colorScheme,e.themeCategorical,k),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:n,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...i]},resolveColor:zd(i,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(o)}catch(t){const n=null!==this.lastCustomLayoutResult,i=We("geo",t,n,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return n?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 Fe({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap;const s=[],a=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),c=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),l=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const n=!0===e.graticule?{}:e.graticule,o=Km();n.step&&o.step(n.step);const r=i(o())||"";r&&s.push({type:"geoarea",pathData:r,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:n.stroke||"#e0e0e0",strokeWidth:n.strokeWidth||.5,strokeDasharray:n.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const n=i(t);if(!n)continue;const o=i.centroid(t),r=i.bounds(t),c=i.area(t),l=lx(e.areaStyle,t,a);s.push({type:"geoarea",pathData:n,centroid:o,bounds:r,screenArea:c,style:l,datum:t,interactive:!0})}const u=cx(e.lineDataAccessor);for(const i of this.lineData){const a=u(i);if(!a||2>a.length)continue;let l=[];if("geo"===e.lineType){const t=Array(a.length);for(let e=0;a.length>e;e++)t[e]=[o(a[e]),r(a[e])];for(let e=0;t.length-1>e;e++){const i=t[e],o=t[e+1],r=Zm(i,o)||0,s=Math.max(2,Math.ceil(r/(Math.PI/180))),a=Qm(i,o);for(let t=0;s>=t;t++){if(e>0&&0===t)continue;const i=n(a(t/s));null!=i&&l.push(i)}}}else for(let t=0;a.length>t;t++){const e=a[t],i=n([o(e),r(e)]);null!=i&&l.push(i)}if(2>l.length)continue;const d=lx(e.lineStyle,i,c),h="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==a.length||2>l.length||"arc"!==e.flowStyle?2!==a.length||2>l.length||"offset"!==e.flowStyle||(l="geo"===e.lineType?hx(l,h):fx(l[0],l[l.length-1],0,0,h)):l=dx(l[0],l[l.length-1]);const f=ux(l,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const e={type:"line",path:t,style:{...d,_edgeFade:!0},datum:i};s.push(e)}else s.push({type:"line",path:2>l.length&&f[0]||l,style:d,datum:i})}const d=this.getPoints(),h=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,f=n.clipAngle?n.clipAngle()??0:0,p=f>0?f*Math.PI/180:null,y=n.rotate?n.rotate():[0,0,0],g="function"==typeof n.center?n.center():[0,0],m=[(g[0]??0)-y[0],(g[1]??0)-y[1]];for(let t=0;d.length>t;t++){const i=d[t],a=o(i),c=r(i);if(null!=p&&Zm([a,c],m)>p)continue;const u=n([a,c]);if(!u)continue;const f=e.pointStyle?e.pointStyle(i):{...l},y={type:"point",x:u[0],y:u[1],r:f.r||4,style:f,datum:i,pointId:h?h(i)+"":void 0};s.push(y)}return s}applyCartogramTransform(t,e){const n=function(t,e,n,i){const o=t.filter(t=>"point"===t.type);if(2>o.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=o.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,d=Ui(o.map(t=>t.datum?a(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),h=Math.min(n.width,n.height)/2,f=px().domain([0,d]).range([0,h]);i>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 n=t[e];"geoarea"===n.type&&n.interactive&&t.splice(e,1)}for(const t of o){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-u,t.x-l),n=Math.sqrt((t.x-l)**2+(t.y-u)**2),i=a(t.datum),o=n+((isFinite(i)?f(i):n)-n)*r;t.x=l+Math.cos(e)*o,t.y=u+Math.sin(e)*o}const p=n.width/2,y=n.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const t of o)t.x+=g,t.y+=m;const x={cx:p,cy:y,maxCost:d,availableRadius:h},b=t.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==e.lineMode){const t=new Map;for(const e of o)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const n=e.datum?.source,i=e.datum?.target;if(n&&i){const o=t.get(n+""),r=t.get(i+"");o&&r&&(e.path=[o,r])}}}return x}(this.scene,t,e,this.areas.length);n&&(this.cartogramLayout=n)}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 i=0;n.length>i;i++){const o=ee(t,i,e);n[i]._decayOpacity=o,n[i].style={...n[i].style,opacity:o}}}applyPulse(){const t=this.config.pulse;if(!t||!this.timestampBuffer)return;const e=te(),n=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray();for(let o=0;n.length>o&&i.length>o;o++){const r=ie(t,i[o],e);r>0&&(n[o]._pulseIntensity=r,n[o]._pulseColor=t.color||"rgba(255,255,255,0.6)",n[o]._pulseGlowRadius=t.glowRadius??4)}}get hasActivePulses(){return re(this.config.pulse??{},this.timestampBuffer)}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const n=new Map;for(const e of t)"point"===e.type&&e.pointId&&n.set(e.pointId,[e.x,e.y]);const i=this.scene.filter(t=>"point"===t.type);let o=!1;for(const t of i)if(t.pointId){const e=n.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)&&(o=!0))}for(const t of i)t.pointId&&!n.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:te(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=Qt(t,this.activeTransition),n=Zt(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Jt(t.x,t._targetX,n),t.y=Jt(e,t._targetY,n)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*n})}if(e>=1){for(const t of i)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}};yx.QUADTREE_THRESHOLD=500;var gx=yx;import{Fragment as mx,jsxs as xx}from"react/jsx-runtime";function bx(t,e){const n=qp(t.theme),i=t.size||[t.width||600,t.height||400],o={top:10,right:10,bottom:10,left:10,...t.margin},r=Array.isArray(t.areas)?I(t.areas):t.areas,s=I(t.points),a=I(t.lines),c=t.showLegend?(()=>{const e="string"==typeof(n=t.colorBy)||"function"==typeof n?t.colorBy:void 0;var n;return ay(s.length>0?s:Array.isArray(r)&&r.length>0?"string"==typeof e?r.map(t=>({...t.properties||{},...t})):r:[],e)})():[],l=t.legendPosition;ji(t.legend)||Yi(t.legend)?by(o,{legend:t.legend,theme:n,position:l||"right",size:i,hasTitle:!!t.title,legendLayout:t.legendLayout}):t.showLegend&&c.length>0&&xy(o,{categories:c,colorScheme:t.colorScheme,theme:n,position:l||"right",size:i,hasTitle:!!t.title,legendLayout:t.legendLayout});const u=i[0]-(o.left??0)-(o.right??0),d=i[1]-(o.top??0)-(o.bottom??0),h={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:o,themeCategorical:n.colors.categorical,themeSemantic:Lt(n)},f=new gx(h);if(r){if("string"==typeof r)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${r}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${r}')\` before calling renderGeoToStaticSVG.`);f.setAreas(r)}if(t.points&&f.setPoints(s),t.lines&&f.setLines(a),f.computeScene({width:u,height:d}),e&&(e.evidence=Vp({frameType:"geo",width:i[0],height:i[1],marks:f.scene,title:t.title,description:t.description,annotations:t.annotations,legendItems:c.length>0?c.length:void 0})),0===f.scene.length){const e=t.backgroundGraphics||t.foregroundGraphics||t.annotations||f.customLayoutOverlays?xx(mx,{children:[t.backgroundGraphics,t.annotations?fy({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([t,e])=>f.scales.projectedPoint(t,e):void 0},layout:{width:u,height:d},theme:n,idPrefix:t._idPrefix}):null,t.foregroundGraphics,f.customLayoutOverlays]}):null;return Vm.renderToStaticMarkup(ky(e,{width:i[0],height:i[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:u,innerHeight:d,idPrefix:t._idPrefix}))}const p=f.scene.map((t,e)=>function(t,e){switch(t.type){case"geoarea":{const n=t;return n.pathData?Br("path",{d:n.pathData,fill:Or(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1},"geoarea-"+e):null}case"point":{const n=t;return Br("circle",{cx:n.x,cy:n.y,r:n.r,fill:Or(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1},"point-"+e)}case"line":{const n=t;if(2>n.path.length)return null;const i="M"+n.path.map(t=>`${t[0]},${t[1]}`).join("L");return Br("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+e)}case"glyph":return jr(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(t,e)).filter(Boolean),y=t.annotations?fy({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([t,e])=>f.scales.projectedPoint(t,e):void 0},layout:{width:u,height:d},theme:n,idPrefix:t._idPrefix}):null,g=t.showLegend?0===c.length?null:sy({categories:c,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:o,hasTitle:!!t.title,legendLayout:t.legendLayout}):null,m=Gm.isValidElement(t.legend)?t.legend:vy(t.legend,{theme:n,position:t.legendPosition||"right",size:i,margin:o,hasTitle:!!t.title,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||g;return Vm.renderToStaticMarkup(ky(xx(mx,{children:[t.backgroundGraphics,p,y,t.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:u,innerHeight:d,legend:m,idPrefix:t._idPrefix}))}function vx(t,e){const n=t.size??[t.width??600,t.height??400],i=new hd(t.config);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&i.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const o=_h(i,{...t,width:n[0],height:n[1],idPrefix:t.idPrefix??t._idPrefix??"physics"});return e&&(e.evidence=Vp({frameType:"physics",width:n[0],height:n[1],marks:o.scene.sceneNodes,title:t.title,description:t.description,annotations:[],extraWarnings:0===o.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),o.svg}import{Fragment as wx,jsx as kx,jsxs as Sx}from"react/jsx-runtime";function Ax(t,e){switch(t){case"xy":return Py(e);case"ordinal":return Zy(e);case"network":return Xm(e);case"geo":return bx(e);case"physics":return vx(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Mx(t){return Py(t)}function Px(t){return Zy(t)}function _x(t){return Xm(t)}function Ix(t){return bx(t)}var Cx=["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 Tx(t,e,n){return Lx(t,e).svg}function Rx(t,e,n){const i={},{svg:o,frameType:r}=Lx(t,e,0,i),s=i.evidence??Vp({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:o,evidence:s}}function Lx(e,n,i,o){const{data:r,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:d,showGrid:h,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=n,w=[s,a],k={...v.frameProps||{},...function(t,e){const n={};for(const i of e)void 0!==t[i]&&(n[i]=t[i]);return n}(v,Cx),theme:c,title:l,description:u,showLegend:d,showGrid:h,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=Yp[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const A=S.buildProps(r,x,m,k,v);let M=(0,{xy:Py,ordinal:Zy,network:Xm,geo:bx,physics:vx}[S.frameType])(A,o);if("GaugeChart"===e&&A.__gauge){const e=A.__gauge,n=k.margin||{top:20,right:20,bottom:30,left:40},i=(s||300)-n.left-n.right,o=(a||300)-n.top-n.bottom,r=Math.min(i,o)/2*.85,l=n.left+i/2,u=n.top+o/2,d=(e.startAngleDeg+(e.gMax===e.gMin?0:(Math.max(e.gMin,Math.min(e.gMax,e.value??e.gMin))-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,h=qp(c).colors.text,f=t.renderToStaticMarkup(Sx(wx,{children:[kx("line",{x1:l,y1:u,x2:l+r*Math.cos(d),y2:u+r*Math.sin(d),stroke:h,strokeWidth:2.5,strokeLinecap:"round"}),kx("circle",{cx:l,cy:u,r:4,fill:h})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}async function $x(t,e,n={}){const{format:i="png",scale:o=1,background:r}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?Ax(t,e):Tx(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*o}).resize(Math.round(c*o),Math.round(l*o));return"jpeg"===i?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function zx(e,n={}){const{title:i,subtitle:o,theme:r,width:s=1200,height:a,layout:c={},background:l}=n,u=Hp(qp(r)),d=c.columns||2,h=c.gap??16;let f=0;i&&(f+=30),o&&(f+=20),f>0&&(f+=10);const p=Math.floor((s-h-h*(d-1))/d),y=[];let g=0,m=f+h,x=0;for(const t of e){const e=Math.min(t.colSpan||1,d),n=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0),y.push({chart:t,x:h/2+g*(p+h),y:m,w:p*e+h*(e-1),h:n}),x=Math.max(x,n),g+=e}const b=a||m+x+h,v=y.map((t,e)=>{const{chart:n,x:i,y:o,w:s,h:a}=t,c={...n.props,width:s,height:a,theme:r,_idPrefix:"chart-"+e};let l;return l=n.component?Tx(n.component,c):n.frameType?Ax(n.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,kx("g",{transform:`translate(${i},${o})`,children:kx("foreignObject",{width:s,height:a,children:kx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+e)});return t.renderToStaticMarkup(Sx("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":i||"Dashboard",style:{fontFamily:u.fontFamily},children:[i&&kx("title",{children:i}),l&&kx("rect",{x:0,y:0,width:s,height:b,fill:l}),i&&kx("text",{x:s/2,y:24,textAnchor:"middle",fontSize:u.titleSize+4,fontWeight:"bold",fill:u.text,fontFamily:u.fontFamily,children:i}),o&&kx("text",{x:s/2,y:i?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}import*as Dx from"react-dom/server";import{Fragment as Ex,jsx as Bx,jsxs as Fx}from"react/jsx-runtime";function Nx(t,e,n,i={}){const{stepSize:o,windowSize:r,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=n.width||600,p=n.height||400,y=qp(n.theme),g={...n,...a&&{xExtent:a},...c&&{yExtent:c}};if(!e||0===e.length)return[];const m=o||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={top:20,right:20,bottom:30,left:40,...n.margin},w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let i=0;x.length>i;i++){const o=x[i],s=e.slice(r?Math.max(0,o-r):0,o),a={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}},c=new Hy(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(Hx(c.scene,f,p,y,g))}else for(let i=0;x.length>i;i++){const o=x[i],s=e.slice(r?Math.max(0,o-r):0,o),m={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:c,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},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new hn(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(qx(b.scene,f,p,y,g,v)),l>0&&i>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(qx(b.scene,f,p,y,g,v))}}return S}function Ox(t,e,n={}){return e.map(e=>{try{return Tx(t,{...n,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})}function Wx(t,e,n){const i=e.size??[e.width??600,e.height??400],o=qp(e.theme),r=Hp(o),s=e.background||o.colors.background,a=e.idPrefix??"physics-gif",c=e.title?`${a}-title-${n}`:void 0,l=e.description?`${a}-desc-${n}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=Ah(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),h=Fx("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:r.fontFamily},children:[e.title&&Bx("title",{id:c,children:e.title}),e.description&&Bx("desc",{id:l,children:e.description}),s&&"transparent"!==s?Bx("rect",{x:0,y:0,width:i[0],height:i[1],fill:s}):null,Bx("g",{id:`${a}-frame-${n}`,children:d.map((t,e)=>qr(t,e,`${a}-${n}`))})]});return Dx.renderToStaticMarkup(h)}function jx(t,e={}){const{fps:n=12,frameCount:i,durationSeconds:o=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,n)/l)),d=i??Math.max(1,Math.ceil(o*Math.max(1,n))),h=c?{...t,background:c}:t,f=new hd(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push(Wx(f,h,0)));d>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(Wx(f,h,p.length))}return p}function Yx(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function qx(t,e,n,i,o,r){const s=Hp(i),a={top:20,right:20,bottom:30,left:40,...o.margin},c=e-a.left-a.right,l=n-a.top-a.bottom,u=Yx(o,i),d=t.map((t,e)=>qr(t,e)).filter(Boolean),h=function(t,e,n,i,o,r){if(!t||0===t.length)return null;const s=Hp(i),a=[];for(let i=0;t.length>i;i++){const c=t[i];if("y-threshold"===c.type&&null!=c.value){let t=null;if(r)t=r(c.value);else if(o){const[e,i]=o,r=i-e;if(0===r)continue;t=n-(c.value-e)/r*n}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push(Fx("g",{children:[Bx("line",{x1:0,y1:t,x2:e,y2:t,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&Bx("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:t-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?Bx(Ex,{children:a}):null}(o.annotations,c,l,i,o.yExtent,r?.y),f="string"==typeof o.title?o.title:void 0,p="string"==typeof o.description?o.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return Dx.renderToStaticMarkup(Fx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:n,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&Bx("title",{id:y,children:f}),p&&Bx("desc",{id:g,children:p}),u&&Bx("rect",{x:0,y:0,width:e,height:n,fill:u}),Fx("g",{transform:`translate(${a.left},${a.top})`,children:[h,d]}),f&&Bx("text",{x:e/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]}))}function Hx(t,e,n,i,o){const r=Hp(i),s={top:20,right:20,bottom:30,left:40,...o.margin},a="radial"===o.projection,c=a?s.left+(e-s.left-s.right)/2:s.left,l=a?s.top+(n-s.top-s.bottom)/2:s.top,u=Yx(o,i),d=t.map((t,e)=>Hr(t,e)).filter(Boolean),h="string"==typeof o.title?o.title:void 0,f="string"==typeof o.description?o.description:void 0,p=h?"semiotic-title":void 0,y=f?"semiotic-desc":void 0,g=[p,y].filter(Boolean).join(" ")||void 0;return Dx.renderToStaticMarkup(Fx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:n,role:"img","aria-labelledby":g,style:{fontFamily:r.fontFamily},children:[h&&Bx("title",{id:p,children:h}),f&&Bx("desc",{id:y,children:f}),u&&Bx("rect",{x:0,y:0,width:e,height:n,fill:u}),Bx("g",{transform:`translate(${c},${l})`,children:d}),h&&Bx("text",{x:e/2,y:16,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:h})]}))}async function Xx(t,e,n,i={}){const{fps:o=12,loop:r=!0,scale:s=1,background:a}=i,c=n.width||600,l=n.height||400,u=Nx(t,e,a?{...n,background:a}:n,i);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Vx(u,c,l,{fps:o,loop:r,scale:s})}async function Gx(t,e={}){const{fps:n=12,loop:i=!0,scale:o=1}=e,r=t.size??[t.width??600,t.height??400],s=jx(t,e);if(0===s.length)throw Error("No physics frames generated");return Vx(s,r[0],r[1],{fps:n,loop:i,scale:o})}async function Vx(t,e,n,i={}){const{fps:o=12,loop:r=!0,scale:s=1}=i,a=Math.round(e*s),c=Math.round(n*s);let l,u,d,h;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);u=e.GIFEncoder??e.default?.GIFEncoder??e.default?.default?.GIFEncoder,d=e.quantize??e.default?.quantize??e.default?.default?.quantize,h=e.applyPalette??e.default?.applyPalette??e.default?.default?.applyPalette}catch{throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const f=Math.round(1e3/o),p=u();for(let e=0;t.length>e;e++){const n=t[e],i=await l(Buffer.from(n),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),u=d(o,256),y=h(o,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}export{Nx as generateFrameSVGs,Ox as generateFrameSequence,jx as generatePhysicsFrameSVGs,Tx as renderChart,Rx as renderChartWithEvidence,zx as renderDashboard,Ix as renderGeoToStaticSVG,_x as renderNetworkToStaticSVG,Px as renderOrdinalToStaticSVG,Gx as renderPhysicsToAnimatedGif,Xx as renderToAnimatedGif,$x as renderToImage,Ax as renderToStaticSVG,Mx as renderXYToStaticSVG,qp as resolveTheme,Hp as themeStyles};
|