semiotic 3.8.0 → 3.8.2
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 +14 -9
- package/README.md +56 -55
- package/ai/behaviorContracts.cjs +9 -0
- package/ai/dist/mcp-server.js +240 -30
- package/ai/schema.json +616 -42
- package/ai/surface-manifest.json +3 -2
- package/ai/system-prompt.md +7 -3
- package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
- package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
- package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
- package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
- package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
- package/dist/chunk-chunk-27HVVXS6.module.min.js +1 -0
- package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
- package/dist/chunk-chunk-2UN3ANRN.module.min.js +2 -0
- package/dist/chunk-chunk-2VUEY5TH.module.min.js +1 -0
- package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
- package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
- package/dist/chunk-chunk-5WEFWNUW.module.min.js +2 -0
- package/dist/chunk-chunk-6F6GEAQU.module.min.js +1 -0
- package/dist/chunk-chunk-7LHMKRKE.module.min.js +2 -0
- package/dist/chunk-chunk-BHYTYMY2.module.min.js +2 -0
- package/dist/chunk-chunk-C6EJ4IOD.module.min.js +2 -0
- package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
- package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
- package/dist/chunk-chunk-CYIML3AV.module.min.js +2 -0
- package/dist/chunk-chunk-DNY43POY.module.min.js +1 -0
- package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
- package/dist/chunk-chunk-E7MIQX7D.module.min.js +2 -0
- package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
- package/dist/chunk-chunk-ES4DCG3L.module.min.js +1 -0
- package/dist/chunk-chunk-FAKO3RGQ.module.min.js +2 -0
- package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
- package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
- package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
- package/dist/chunk-chunk-H4PPRW6N.module.min.js +1 -0
- package/dist/chunk-chunk-IFYPMWKY.module.min.js +1 -0
- package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
- package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
- package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
- package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
- package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
- package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
- package/dist/chunk-chunk-L6D3I3V7.module.min.js +2 -0
- package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
- package/dist/chunk-chunk-NO4MCQVD.module.min.js +1 -0
- package/dist/chunk-chunk-ODUZEEBH.module.min.js +2 -0
- package/dist/chunk-chunk-P6UBCMSQ.module.min.js +2 -0
- package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
- package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
- package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
- package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
- package/dist/chunk-chunk-RH5TSQPH.module.min.js +1 -0
- package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
- package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
- package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
- package/dist/chunk-chunk-STZFFTAN.module.min.js +2 -0
- package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
- package/dist/chunk-chunk-T27ZEV6A.module.min.js +1 -0
- package/dist/chunk-chunk-U3AGQ5EF.module.min.js +2 -0
- package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
- package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
- package/dist/chunk-chunk-W3DB2MN4.module.min.js +2 -0
- package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
- package/dist/chunk-chunk-WDIN4LRC.module.min.js +1 -0
- package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
- package/dist/chunk-chunk-XOYX77KF.module.min.js +2 -0
- package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
- package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
- package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
- package/dist/chunk-chunk-Z5KXAVQD.module.min.js +2 -0
- package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
- package/dist/chunk-chunk-ZLKRTF5N.module.min.js +2 -0
- package/dist/chunk-chunk-ZTNVDWAK.module.min.js +2 -0
- package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
- package/dist/components/AccessibleNavTree.d.ts +7 -1
- package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
- package/dist/components/ai/useNavigationSync.d.ts +17 -2
- package/dist/components/chartContainerMobile.d.ts +9 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
- package/dist/components/charts/geo/DistanceCartogram.d.ts +14 -2
- package/dist/components/charts/geo/FlowMap.d.ts +10 -6
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +14 -2
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +9 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +11 -0
- package/dist/components/charts/network/SankeyDiagram.d.ts +9 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +21 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +11 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +11 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +7 -0
- package/dist/components/charts/physics/EventDropChart.d.ts +7 -0
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +8 -0
- package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +4 -25
- package/dist/components/charts/physics/PhysicsPileChart.d.ts +7 -0
- package/dist/components/charts/physics/physicsChartShared.d.ts +17 -1
- package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
- package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
- package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
- package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
- package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +3 -3
- package/dist/components/charts/shared/datumTypes.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +2 -0
- package/dist/components/charts/shared/formatUtils.d.ts +3 -3
- package/dist/components/charts/shared/hatchFill.d.ts +87 -0
- package/dist/components/charts/shared/hooks.d.ts +7 -6
- package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
- package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
- package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
- package/dist/components/charts/shared/sparseArray.d.ts +1 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +6 -4
- package/dist/components/charts/shared/styleRules.d.ts +205 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
- package/dist/components/charts/shared/types.d.ts +9 -6
- package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
- package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
- package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +24 -1
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
- package/dist/components/charts/shared/validateChartData.d.ts +7 -5
- package/dist/components/charts/shared/validationMap.d.ts +11 -2
- package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
- package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
- package/dist/components/charts/value/targetPresentation.d.ts +22 -0
- package/dist/components/charts/value/types.d.ts +5 -6
- package/dist/components/charts/xy/AreaChart.d.ts +8 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
- package/dist/components/charts/xy/Heatmap.d.ts +2 -2
- package/dist/components/charts/xy/LineChart.d.ts +11 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +7 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +10 -0
- package/dist/components/charts/xy/StackedAreaChart.d.ts +7 -0
- package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
- package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
- package/dist/components/controls/SentenceFilter.d.ts +97 -0
- package/dist/components/data/fromVegaLite.d.ts +19 -9
- package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
- package/dist/components/semiotic-ai.d.ts +3 -1
- package/dist/components/semiotic-controls.d.ts +2 -0
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +4 -0
- package/dist/components/semiotic-ordinal.d.ts +6 -0
- package/dist/components/semiotic-physics.d.ts +4 -0
- package/dist/components/semiotic-rough.d.ts +4 -0
- package/dist/components/semiotic-utils-core.d.ts +4 -0
- package/dist/components/semiotic-xy.d.ts +4 -0
- package/dist/components/semiotic.d.ts +9 -1
- package/dist/components/server/optionalImageTypes.d.ts +37 -0
- package/dist/components/server/serverChartConfigShared.d.ts +9 -5
- package/dist/components/server/serverChartConfigs.d.ts +4 -4
- package/dist/components/server/staticAnnotations.d.ts +6 -3
- package/dist/components/server/staticLegend.d.ts +1 -1
- package/dist/components/server/staticNetwork.d.ts +4 -4
- package/dist/components/server/staticSVGChrome.d.ts +5 -4
- package/dist/components/store/ObservationStore.d.ts +21 -1
- package/dist/components/stream/AccessibleDataTable.d.ts +4 -10
- package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
- package/dist/components/stream/CanvasHitTester.d.ts +4 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
- package/dist/components/stream/FrameRuntime.d.ts +57 -0
- package/dist/components/stream/GeoParticlePool.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +43 -12
- package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
- package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
- package/dist/components/stream/NetworkPipelineStore.d.ts +24 -21
- package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +6 -0
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
- package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
- package/dist/components/stream/OrdinalPipelineStore.d.ts +13 -13
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
- package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
- package/dist/components/stream/ParticlePool.d.ts +1 -1
- package/dist/components/stream/PipelineStore.d.ts +12 -16
- package/dist/components/stream/SVGOverlay.d.ts +6 -0
- package/dist/components/stream/SceneGraph.d.ts +3 -3
- package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
- package/dist/components/stream/accessorUtils.d.ts +2 -2
- package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
- package/dist/components/stream/frameGraphics.d.ts +4 -0
- package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
- package/dist/components/stream/geoPipelineHelpers.d.ts +3 -3
- package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
- package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
- package/dist/components/stream/geoTypes.d.ts +48 -15
- package/dist/components/stream/hitTestUtils.d.ts +2 -2
- package/dist/components/stream/hoverUtils.d.ts +4 -2
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +1 -0
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
- package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
- package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
- package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
- package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
- package/dist/components/stream/networkFrameObservations.d.ts +15 -0
- package/dist/components/stream/networkFramePaint.d.ts +11 -2
- package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +2 -2
- package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
- package/dist/components/stream/networkTypes.d.ts +37 -56
- package/dist/components/stream/ordinalCanvasRenderers.d.ts +2 -2
- package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +20 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
- package/dist/components/stream/ordinalTypes.d.ts +30 -3
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +2 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +6 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +21 -6
- package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
- package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
- package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +19 -1
- package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +3 -1
- package/dist/components/stream/pipelineConfig.d.ts +4 -2
- package/dist/components/stream/pipelineDecay.d.ts +2 -2
- package/dist/components/stream/pipelinePulse.d.ts +2 -2
- package/dist/components/stream/pipelineStoreUpdateResults.d.ts +23 -2
- package/dist/components/stream/pipelineTransitions.d.ts +1 -1
- package/dist/components/stream/pipelineUpdateContract.d.ts +7 -0
- package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
- package/dist/components/stream/renderBackend.d.ts +27 -0
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
- package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
- package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
- package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
- package/dist/components/stream/sceneRevisionDiagnostics.d.ts +31 -4
- package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
- package/dist/components/stream/streamThemeTypes.d.ts +14 -0
- package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
- package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
- package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
- package/dist/components/stream/titleLayout.d.ts +31 -0
- package/dist/components/stream/types.d.ts +30 -65
- package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
- package/dist/components/stream/useFrame.d.ts +23 -0
- package/dist/components/stream/useLegendCategoryEmission.d.ts +3 -3
- package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
- package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
- package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +6 -5
- package/dist/controls.min.js +1 -1
- package/dist/controls.module.min.js +1 -1
- package/dist/forceLayoutWorker.js +1 -1
- 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 -1
- package/dist/physics-matter.module.min.js +1 -1
- package/dist/physics-rapier.min.js +1 -1
- package/dist/physics-rapier.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -0
- package/dist/rough.module.min.js +1 -0
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +3 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-controls.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.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +4 -0
- package/dist/semiotic-ordinal.d.ts +6 -0
- package/dist/semiotic-physics.d.ts +4 -0
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-realtime-react.min.js +1 -1
- package/dist/semiotic-realtime-react.module.min.js +1 -1
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes-react.min.js +1 -1
- package/dist/semiotic-recipes-react.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-rough.d.ts +4 -0
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-themes-core.min.js +1 -1
- package/dist/semiotic-themes-core.module.min.js +1 -1
- package/dist/semiotic-themes-react.min.js +1 -1
- package/dist/semiotic-themes-react.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils-core.d.ts +4 -0
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils-react.min.js +1 -1
- package/dist/semiotic-utils-react.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +4 -0
- package/dist/semiotic.d.ts +9 -1
- 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/test-utils/capturedFrameProps.d.ts +67 -0
- package/dist/test-utils/frameMock.d.ts +12 -9
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +29 -10
- package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
- package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
- package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
- package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
- package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import{useRef as e,useState as n,useEffect as r,useMemo as o,useCallback as i,useImperativeHandle as s,useId as a,forwardRef as l,memo as c}from"react";import{useRef as u,useEffect as h,useMemo as d}from"react";import{select as f}from"d3-selection";import{brush as y,brushX as p,brushY as g}from"d3-brush";import*as m from"react";import{jsx as x,jsxs as v}from"react/jsx-runtime";function b(t,e,n,r){const[o,i]=[Math.min(...e),Math.max(...e)],s=(i-o)/20;let[a,l]=t;if(r)0>n?a=Math.max(o,a-s):l=Math.min(i,l+s);else{const t=l-a;a=Math.max(o,Math.min(i-t,a+n*s)),l=a+t}return[a,l]}function k(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r+1>>1;e[o]>t?r=o-1:n=o}return e[n]}function w(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o]?n=o+1:r=o}return e[n]}function A({width:t,height:e,totalWidth:n,totalHeight:r,margin:o,dimension:i,scales:s,onBrush:a,binSize:l,snap:c,binBoundaries:A,snapDuring:S,streaming:_}){const M=u(null),P=u(null),C=u(a);C.current=a;const T=u(s);T.current=s;const L=d(()=>A?[...A].sort((t,e)=>t-e):void 0,[A]),N=u(L);N.current=L;const D=u(!1),E=u(null),R=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 r=m.useId().replace(/:/g,""),o=m.useRef(n);return o.current=n,{description:e,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":t,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:m.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"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:t=>{const e=T.current,n=P.current;if(!e||!n||!M.current)return;const r=f(M.current).select(".brush-g");if("clear"===t.type)return D.current=!0,r.call(n.move,null),D.current=!1,E.current=null,void C.current(null);const o=e.x.domain(),s=e.y.domain(),a=E.current;let l=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],c=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===t.direction||"right"===t.direction,h="left"===t.direction||"down"===t.direction?-1:1;if(u&&"y"!==i&&(l=b(l,o,h,t.resize)),u||"x"===i||(c=b(c,s,h,t.resize)),u&&"y"===i||!u&&"x"===i)return;const d={x:l,y:c};D.current=!0,r.call(n.move,"x"===i?[e.x(l[0]),e.x(l[1])]:"y"===i?[e.y(c[1]),e.y(c[0])]:[[e.x(l[0]),e.y(c[1])],[e.x(l[1]),e.y(c[0])]]),D.current=!1,E.current=d,C.current(d)}});return h(()=>{if(!M.current)return;const n=f(M.current).select(".brush-g"),r="x"===i?p():"y"===i?g():y();return r.extent([[0,0],[t,e]]),r.on("brush end",o=>{if(D.current)return;const s=T.current;if(!s)return;if(!o.selection)return E.current=null,void C.current(null);let a,u;if("x"===i){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"===i){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,r]]=o.selection;a=[s.x.invert(t),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(e)]}if("bin"===c&&"y"!==i&&("end"===o.type||"brush"===o.type&&S)){const t=N.current;t&&t.length>0?a=function(t,e){return 0===e.length?t:[k(t[0],e),w(t[1],e)]}(a,t):l&&l>0&&(a=[Math.floor(a[0]/l)*l,Math.ceil(a[1]/l)*l]);const e=s.x(a[0]),c=s.x(a[1]);if(D.current=!0,"x"===i)n.call(r.move,[e,c]);else if("xy"===i){const t=o.selection;n.call(r.move,[[e,t[0][1]],[c,t[1][1]]])}D.current=!1}const h={x:a,y:u};E.current=h,C.current(h)}),n.call(r),P.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),P.current=null}},[t,e,i,c,l,S]),h(()=>{if(!(_&&s&&P.current&&E.current))return;if(!M.current)return;if("y"===i)return;const t=E.current,e=s.x.domain()[0],n=f(M.current).select(".brush-g");if(e>=t.x[1])return D.current=!0,n.call(P.current.move,null),D.current=!1,E.current=null,void C.current(null);let r=t.x[0],o=!1;if(e>t.x[0]){if(r=e,"bin"===c){const t=N.current;t&&t.length>0?r=w(e,t):l&&l>0&&(r=Math.ceil(e/l)*l)}if(r>=t.x[1])return D.current=!0,n.call(P.current.move,null),D.current=!1,E.current=null,void C.current(null);o=!0}const a=s.x(r),u=s.x(t.x[1]);if(D.current=!0,"x"===i)n.call(P.current.move,[a,u]);else{const e=s.y(t.y[1]),r=s.y(t.y[0]);n.call(P.current.move,[[a,e],[u,r]])}if(D.current=!1,o){const e={x:[r,t.x[1]],y:t.y};E.current=e,C.current(e)}},[s,_,i,c,l]),v("svg",{ref:M,width:n,height:r,...R.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[x("title",{children:R.svgProps["aria-label"]}),x("desc",{id:R.descriptionId,children:R.description}),x("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}var S=Object.freeze([]);function _(t){if(!t)return S;let e=!1;for(let n=0;t.length>n;n++){const r=t[n];if(null==r||"object"!=typeof r){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}var M=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=_(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 r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=_(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 r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,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 r=t[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),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 P,useCallback as C,useContext as T,useMemo as L,useRef as N,useSyncExternalStore as D}from"react";import{jsx as E}from"react/jsx-runtime";function R(t){let e=null;const n=()=>(e||(e=P(null)),e),r=I(t);return[function({children:e,initialState:r}){const o=N(r),i=L(()=>I(t,o.current),[]),s=n();return E(s.Provider,{value:i,children:e})},(t,e)=>{const o=n(),i=T(o)??r,s=N(t);s.current=t;const a=N({hasValue:!1,value:void 0}),l=C(()=>{const t=s.current(i.getState()),n=a.current;return n.hasValue&&e&&e(n.value,t)?n.value:(a.current={hasValue:!0,value:t},t)},[i,e]),c=C(()=>s.current(i.getState()),[i]);return D(i.subscribe,l,c)}]}function I(t,e){const n=new Set;let r={...t(function(t){const e=t(r);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){r={...r,...e};for(const t of n)t()}}),...e??{}};return{getState:()=>r,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function z(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){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:W}}),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 W=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],F={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}},O={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}},Y={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:W,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 B(t,e){if("light"===e)return F;if("dark"===e)return O;if("high-contrast"===e)return Y;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?O:F;return $({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return $({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[j,H]=R(t=>({theme:F,setTheme(e){t(t=>({theme:B(t.theme,e)}))}})),X=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,r=[];e.length>t&&(n=e.length-t,r=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 r}update(t,e){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,s=this.buffer[i];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(t),this.buffer[i]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(r=>{t(r)?n.push(r):e.push(r)}),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}},G=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 V(t,e){return t===e}function q(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function U(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function K(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var Q=/^\d{4}-\d{1,2}$/;function Z(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=Q.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function J(t){return t instanceof Date?t.getTime():"string"==typeof t?Z(t):+t}function tt(t){return new Set(Array.isArray(t)?t:[t])}import{scaleOrdinal as et}from"d3-scale";function nt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function rt(t,e,n){const r=t=>t.toString(16).padStart(2,"0");return`#${r(t)}${r(e)}${r(n)}`}function ot(t){const e=t.map(nt),n=e.length-1;return t=>{if(0>=t){const[t,n,r]=e[0];return rt(t,n,r)}if(t>=1){const[t,r,o]=e[n];return rt(t,r,o)}const r=t*n,o=Math.floor(r),i=r-o,[s,a,l]=e[o],[c,u,h]=e[o+1];return rt(Math.round(s+(c-s)*i),Math.round(a+(u-a)*i),Math.round(l+(h-l)*i))}}var it=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],st=ot(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),at=ot(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),lt=ot(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ct=ot(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ut=ot(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ht=ot(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),dt=ot(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ft=ot(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),yt=ot(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),pt=ot(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),gt=ot(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),mt=ot(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),xt={blues:st,reds:at,greens:lt,viridis:dt,oranges:ct,purples:ut,greys:ht,plasma:ft,inferno:yt,magma:pt,cividis:gt,turbo:mt};ot(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),ot(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),ot(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),ot(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),ot(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),ot(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),ot(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var vt={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"],...xt},bt=it,kt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function wt(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 At(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function St(t,e){return Math.min((t-e.startTime)/e.duration,1)}function _t(t,e,n){return t+(e-t)*n}function Mt(){return"undefined"!=typeof performance?performance.now():Date.now()}var Pt={fresh:1,aging:1.5,stale:3};function Ct(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"}function Tt(t,e,n){if(null!=t)return"function"==typeof t?t(e,n):"object"==typeof t&&null!==t&&"constant"in t?t.constant:e[t]}function Lt(t){const{data:e,encoding:n}=t,r=[],o=new Map;return e.forEach((t,e)=>{const i=Tt(n.id,t,e);if(null==i||""===i)throw Error(`[semiotic] Motion encoding row ${e} resolved an empty id.`);const s=i+"";if(o.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=Tt(n.process?.group,t,e),l=Tt(n.process?.stage,t,e),c=Tt(n.accessible?.group,t,e)??(null!=a?a+"":null!=l?l+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=Tt(n.evidence?.[r],t,e);const h={id:s,datum:t,time:{arrival:Tt(n.time?.arrival,t,e),basis:n.time?.basis,unit:n.time?.unit},placement:{x:Tt(n.placement?.x,t,e),y:Tt(n.placement?.y,t,e),lane:Tt(n.placement?.lane,t,e),space:n.placement?.space},kinematics:{velocityX:Tt(n.kinematics?.velocityX,t,e),velocityY:Tt(n.kinematics?.velocityY,t,e),space:n.kinematics?.space},process:{group:a,stage:l,target:Tt(n.process?.target,t,e),work:Tt(n.process?.work,t,e)},evidence:u,accessible:{description:Tt(n.accessible?.description,t,e),group:c,label:Tt(n.accessible?.label,t,e)??s}};r.push(h),o.set(s,h)}),{rows:r,byId:o}}function Nt(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 r=t.halfLife??t.extent/2;return e+Math.pow(.5,n/(r>0?r:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-n/t.extent))*(1-e)}function Dt(t,e){const n=Number.isFinite(t)?t:0,r=Number.isFinite(e)?e:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function Et(t,e,n){return Number.isFinite(n)&&n>0?Dt((e.x-t.x)/n,(e.y-t.y)/n):Dt(0,0)}function Rt(t,e,n){if(1>=n)return 1;const r=n-1;return Nt({age:r-e,extent:r,type:t.type,halfLife:t.halfLife??n/2,threshold:t.stepThreshold??.5*n,minOpacity:t.minOpacity??.1})}function It(t){const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return e}function zt(t,e,n){const r=t.duration??500,o=n-e;return r>o?1-o/r:0}function $t(t,e,n,r){let o=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,o=!0),t._pulseColor!==n&&(t._pulseColor=n,o=!0),t._pulseGlowRadius!==r&&(t._pulseGlowRadius=r,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 Wt(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),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}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 Ft(t,e,n,r,o,i){const s=[];for(const o of t){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&s.push({px:e.x(t),py:e.y(i),rawY:i,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:i}}function Ot(t,e,n,r,o,i,s,a){const l=[];for(const i of t){const t=n(i),s=r(i);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(i):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:i,datum:t,group:s}}function Yt(t,e,n,r){const o=new Map;if("silhouette"===r)for(const r of t){let t=0;for(const o of e)t+=n(o,r)||0;o.set(r,-t/2)}else if("wiggle"===r){t.length>0&&o.set(t[0],0);for(let r=1;t.length>r;r++){const i=t[r-1],s=t[r];let a=0,l=0,c=0;for(const t of e){const e=n(t,s)||0;a+=(2*c+e)*(e-(n(t,i)||0)),l+=e,c+=e}const u=o.get(i)??0;o.set(s,u-(l>0?a/(2*l):0))}if(t.length>0){let r=0;for(const i of t){let t=0;for(const r of e)t+=n(r,i)||0;r+=(o.get(i)??0)+t/2}const i=r/t.length;for(const e of t)o.set(e,(o.get(e)??0)-i)}}else for(const e of t)o.set(e,0);return o}function Bt(t,e,n,r,o,i,s){const a=n(t),l=r(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:i,datum:t};return void 0!==s&&(c.pointId=s),c}function jt(t,e,n,r,o,i,s,a){const l=n(t),c=r(t);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(l),y:e.y(c),size:o,symbolType:i,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function Ht(t,e,n,r,o,i,s){return{type:"rect",x:t,y:e,w:n,h:r,style:o,datum:i,group:s}}function Xt(t,e,n,r,o,i,s){const a={type:"heatcell",x:t,y:e,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Gt(t,e,n,r){return"function"==typeof e.style?e.style(r||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,r)}function Vt(t,e,n,r){if(!t.scales)return null;const o=[],i=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=r.getTop(n),a=r.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]),i.push([l,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:Gt(t,r,n,e[0]),datum:e,group:n,interactive:r.interactive}}function qt(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const r of t)r.perSeries?e.push(r):n.push(r);return{perSeries:e,aggregate:n}}function Ut(t,e,n){const r=[];for(const o of n){const n=Vt(t,e,"__ribbon_aggregate",o);n&&r.push(n)}return r}function Kt(t,e,n,r){const o=[];for(const i of r){const r=Vt(t,e,n,i);r&&o.push(r)}return o}function Qt(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const r of e){if("band"!==r.kind)continue;const e=r.getTop(t),o=r.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 Zt(t,e,n,r){if(!t.config.pointStyle)return;const o=r??t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const i of r.data){let r=t.config.pointStyle(i);!r.fill&&e&&(r={...r,fill:e});const s=r.r??3,a=t.getPointId?t.getPointId(i)+"":void 0,l=Bt(i,t.scales,t.getX,o,s,r,a);l&&n.push(l)}}}var Jt={topOpacity:.8,bottomOpacity:.05};function te(t){if(t)return!0===t?Jt:"colorStops"in t?t:{topOpacity:t.topOpacity??Jt.topOpacity,bottomOpacity:t.bottomOpacity??Jt.bottomOpacity}}import{symbol as ee,symbolCircle as ne,symbolCross as re,symbolDiamond as oe,symbolSquare as ie,symbolStar as se,symbolTriangle as ae,symbolWye as le}from"d3-shape";var ce={circle:ne,square:ie,triangle:ae,diamond:oe,star:se,cross:re,wye:le},ue=["circle","triangle","diamond","star","square","chevron","cross","wye"];function he(t,e,n){if(n)return n;const r=t??"circle";return"chevron"===r?function(t){const e=1.5*de(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):ee(ce[r]??ne,Math.max(1,e))()??""}function de(t){return Math.sqrt(Math.max(1,t)/Math.PI)}var fe=new Map;function ye(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){const r=Math.max(1,Math.floor(t.config.heatmapXBins??20)),o=Math.max(1,Math.floor(t.config.heatmapYBins??20)),i=t.config.heatmapAggregation??"count",s=q(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,l]=t.scales.x.domain(),[c,u]=t.scales.y.domain(),h=(l-a||1)/r,d=(u-c||1)/o,f=r*o;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;e.length>n;n++){const i=e[n],l=t.getX(i),u=t.getY(i);if(!isFinite(l)||!isFinite(u))continue;const f=Math.min(Math.floor((l-a)/h),r-1),g=Math.min(Math.floor((u-c)/d),o-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const x=s(i);p[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===y[t])continue;let e;switch(i){case"sum":e=p[t];break;case"mean":e=p[t]/y[t];break;default:e=y[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,v=n.width/r,b=n.height/o,k=t.config.showValues,w=t.config.heatmapValueFormat,A=[];for(let t=0;o>t;t++){const e=t*r;for(let n=0;r>n;n++){const r=e+n;if(0===y[r])continue;let s;switch(i){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const l=(s-g)/x;A.push(Xt(n*v,(o-1-t)*b,v,b,`rgb(${220-(180*l+.5)|0},${220-(100*l+.5)|0},${255-(50*l+.5)|0})`,{xi:n,yi:t,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:c+(t+.5)*d,agg:i},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(t,e,n);if(0===e.length)return[];const r=q(t.config.valueAccessor,"value"),o=U(t.config.xAccessor,"x"),i=U(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],r=o(n),u=i(n);l[t]=r,c[t]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(t=>"number"==typeof t&&!isNaN(t)),p=f.every(t=>"number"==typeof t&&!isNaN(t));if(y){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[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 g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),v=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(l[t]),i=a.get(c[t]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=v.get(d);let y;void 0!==f?y=f:(y=b++,v.set(d,y)),g[y]=d,m[y]=h,x[y]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in xt?t:"blues";let n=fe.get(e);if(n)return n;n=Array(256);const r=(o=e)&&xt[o]||st;var o;for(let t=0;256>t;t++)n[t]=r(t/255);return fe.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/h,P=t.config.showValues,C=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const n=g[t],r=n%u;T.push(Xt(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((e-k)*S+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return T}function pe(t,e,n,r,o){const i=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/r)*r;let c=i.get(l);if(c||(c={start:l,end:l+r,total:0,categories:new Map},i.set(l,c)),c.total+=a,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return i}function ge(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:r,warned:o}=t;me(r)&&0===n.length&&xe(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)&&xe(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 me(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(me))}function xe(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function ve(t,e,n,r){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),i="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:i,message:`Semiotic ${t} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function be(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function ke(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,r=be(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=q(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=r(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e+o:e},getBottom:t=>{const e=r(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:be(t.y1Accessor,"y1"),getBottom:be(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as we,scaleLog as Ae,scaleSymlog as Se,scaleTime as _e}from"d3-scale";function Me(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Pe(t,e,n){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return Ae().domain(t).range(n).clamp(!0)}return"symlog"===t?Se().domain(e).range(n):"time"===t?_e().domain([new Date(e[0]),new Date(e[1])]).range(n):we().domain(e).range(n)}function Ce(t,e,n,r){const o=t.push(e);return n&&n.push(r),o}var Te={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 Le(t,e){const n={...t};for(const t of e)n[Te[t]]++;return n}function Ne(t,e,n){const r=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:r,revisions:Le(n,r)}}var De=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=Ne({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(t,e){const n=Ne(t,e,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},Ee=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Re=["scene-style","data-paint","accessibility","evidence"],Ie=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),ze=class{constructor(){this.tracker=new De}get last(){return this.tracker.last}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Ee)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Re):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=>Ie.has(t))&&n.add("scene-style"),n}(t,n):[])}};import{quadtree as $e}from"d3-quadtree";var We=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,r=0;for(const t of e)"point"===t.type&&(n++,t.r>r&&(r=t.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const t of e)"point"===t.type&&(o[i++]=t);this.tree=$e().x(t=>t.x).y(t=>t.y).addAll(o)}},Fe=class t{constructor(t){if(this.xExtent=new G,this.yExtent=new G,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 ze,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 We,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let l=!1;const c=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=c.get(n);if(null==e)continue;a=!0;const s=r.get(e);if(null==s)continue;const l=zt(t,s,i);l>o&&(o=l)}a&&(l=$t(n,o,s)||l);continue}const e=c.get(n.datum);if(null==e)continue;const o=r.get(e);l=$t(n,null==o?0:zt(t,o,i),s,a)||l}return l}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),n),this._stylePaintPending=!1,this.config=t,this.buffer=new X(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=q(t.timeAccessor||t.xAccessor,"time"),this.getY=q(t.valueAccessor||t.yAccessor,"value")):(this.getX=q(t.xAccessor,"x"),this.getY=q(t.yAccessor,"y")),this.getGroup=K(t.groupAccessor),this.getCategory=K(t.categoryAccessor),this.getSize=t.sizeAccessor?q(t.sizeAccessor,"size"):void 0,this.getColor=K(t.colorAccessor),this.getSymbol=K(t.symbolAccessor),this.getY0=t.y0Accessor?q(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=ke(t),this.getPointId=K(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?q(t.openAccessor,"open"):void 0,this.getHigh=q(t.highAccessor,"high"),this.getLow=q(t.lowAccessor,"low"),this.getClose=n?q(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new X(t.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(t,e){const n=new X(t.capacity);return t.forEach(()=>n.push(e)),n}(this.buffer,Mt())):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),r=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}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),r=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}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=Mt();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?q(this.config.timeAccessor||this.config.xAccessor,"time"):q(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(e):e[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(Z(r));if(this.xIsDate=o||i,i){const t="string"==typeof n?n:void 0;this.getX=t?e=>J(e[t]):t=>J(n(t))}}o=this.timestampBuffer,(r=t.totalSize||t.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),o&&r>o.capacity&&o.resize(r));for(const n of t.inserts)Ce(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=Ce(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))}var n,r,o;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,r=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 i=this.getBufferArray(),s=this.yExtent.extent;let a=Me(this.xExtent.extent,e.xExtent),l=Me(s,e.yExtent);const c=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!c&&n.size>0){const t=function(t){const{config:e,groups:n,getX:r,getY:o}=t,i="exact"===e.axisExtent;if(e.normalize){const n=[0,i?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,l=new Set;let c=0;const u=new Map,h=new Map;for(const t of n){const e=new Map;let n=0;for(const i of t.data){const t=r(i),s=o(i);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),l.add(t),n+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>c&&(c=a)}a.set(t.key,e),h.set(t.key,n)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let y,p;if("input"===d)y=n.map(t=>t.key);else if("insideOut"===d){const t=[...n].map(t=>t.key).sort((t,e)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(t,e)}),e=[],r=[];let o=0,i=0;for(const n of t)i>o?(e.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);y=[...r.reverse(),...e]}else y="asc"===d?n.map(t=>t.key).sort((t,e)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(t,e)}):"desc"===d?n.map(t=>t.key).sort((t,e)=>{const n=(h.get(e)??0)-(h.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(l).sort((t,e)=>t-e),n=Yt(t,y,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let r=1/0,o=-1/0;for(const e of t){const t=n.get(e)??0,i=u.get(e)??0;r>t&&(r=t),t+i>o&&(o=t+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,c=i?0:s>0?s*e.extentPadding:1;p=[r-c,o+c]}else if("diverging"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),[n,r]=function(t,e,n){let r=0,o=0;for(const i of t){let t=0,s=0;for(const r of e){const e=n(r,i)||0;0>e?s+=e:t+=e}r>s&&(r=s),t>o&&(o=t)}return[r,o]}(t,y,(t,e)=>a.get(t)?.get(e)||0),o=r-n,s=i?0:o>0?o*e.extentPadding:1;p=[n-s,r+s]}else p=[0,c+(i?0:c>0?c*e.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:e,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!c&&n.size>0?l=function(t,e,n,r,o,i,s){const[,a]=function(t,e,n,r,o){const i=pe(t,e,n,r,o);if(0===i.size)return[0,0];let s=0;for(const t of i.values())t.total>s&&(s=t.total);return[0,s]}(t,e,n,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!c&&n.size>0?l=function(t,e,n,r){const[o,i]=function(t,e){let n=0,r=0,o=0;for(const i of t){const t=e(i);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(t,e),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,e.extentPadding,h):c||l[0]===1/0||(l=function(t,e,n){if(!n.length)return t;let[r,o]=t;for(const t of e)for(const e of n){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(l,i,this.resolvedRibbons),l=function(t,e){const n=t[1]-t[0],r=e.exactMode?0:n>0?n*e.extentPadding:1,o=[null!=e.userMin?t[0]:t[0]-r,null!=e.userMax?t[1]:t[1]+r];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}(l,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));l=function(t,e,n){if(!e||n)return t;const r=e[0],o=e[1];return null==r&&null==o?t:[null!=r?r:t[0],null!=o?o:t[1]]}(l,e.yExtent,!!c),({xDomain:a,yDomain:l}=function(t,e,n){let r=t,o=e;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const t=Date.now();r=[t-864e5,t]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,l,e.xScaleType)),this.scales=function(t){const{config:e,layout:n,xDomain:r,yDomain:o}=t,i="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){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:we().domain(r).range(t),y:Pe(e.yScaleType,o,[n.height-s,s])}}const t="down"===e.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Pe(e.yScaleType,o,[s,n.width-s]),y:we().domain(r).range(t)}}var a;return{x:Pe(e.xScaleType,r,[s,n.width-s]),y:Pe(e.yScaleType,o,[n.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,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=d,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.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 r of t.path)r[0]*=e,r[1]*=n;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=n;for(const r of t.bottomPath)r[0]*=e,r[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 r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Pe,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,r,i[0]>i[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.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const o={data:e,scales:r,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??kt},resolveColor:(t,e)=>{const r=this.resolveGroupColor(t);if(r)return r;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 i;try{i=n.customLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,r=ve("xy",t,e,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{n.onLayoutError?.(r)}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 s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.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 ge({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:r,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),r=[],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:i}=qt(t.ribbons);if(i.length>0&&r.push(...Ut(t,e,i)),o.length>0)for(const e of n)r.push(...Kt(t,e.data,e.key,o))}for(const e of n){const n=t.resolveLineStyle(e.key,e.data[0]),i=Ft(e.data,t.scales,t.getX,t.getY,n,e.key);o&&o.length>0&&(i.colorThresholds=o),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),r.push(i)}return Zt(t,n,r),r}(o,e);case"area":return function(t,e){const n=t.groupData(e),r=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:i}=qt(t.ribbons);if(i.length>0&&r.push(...Ut(t,e,i)),o.length>0)for(const e of n)r.push(...Kt(t,e.data,e.key,o))}const o=t.scales.y.domain()[0],i=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=Ot(e.data,t.scales,t.getX,t.getY,o,n,e.key,i),a=te(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),r.push(s)}return Zt(t,n,r),r}(o,e);case"mixed":return function(t,e){const n=t.groupData(e),r=[],o=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:i}=qt(t.ribbons);if(i.length>0&&r.push(...Ut(t,e,i)),o.length>0)for(const e of n)r.push(...Kt(t,e.data,e.key,o))}const i=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=Ot(e.data,t.scales,t.getX,t.getY,i,n,e.key,s),a=te(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),r.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Ft(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),r.push(o)}return Zt(t,n,r),r}(o,e);case"stackedarea":return function(t,e){const n=t.groupData(e),r=t.config.stackOrder??"key",o=()=>n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const e=new Map;for(const r of n){let n=0;for(const e of r.data){const r=t.getX(e),o=t.getY(e);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}e.set(r.key,n)}const o=(t,e)=>e>t?-1:t>e?1:0;if("asc"===r)n.sort((t,n)=>{const r=(e.get(t.key)??0)-(e.get(n.key)??0);return 0!==r?r:o(t.key,n.key)});else if("desc"===r)n.sort((t,n)=>{const r=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==r?r:o(t.key,n.key)});else{const t=[...n].sort((t,n)=>{const r=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==r?r:o(t.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of t)a>s?(r.push(n),s+=e.get(n.key)??0):(i.push(n),a+=e.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();const i=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:l}=function(t,e,n,r,o,i,s,a="zero"){const l=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&l.add(e)}const c=Array.from(l).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),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&t.set(e,(t.get(e)||0)+i)}u.set(e.key,t)}let h;if(i){h=new Map;for(const e of c){let n=0;for(const r of t)n+=u.get(r.key)?.get(e)||0;h.set(e,n||1)}}const d=Yt(c,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!i,y=[],p=new Map,g=new Map,m=new Map,x=new Map;for(const t of c)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const n of t){const t=u.get(n.key),r=new Map;let a=[],l=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(t.curve=s),y.push(t)}a=[],l=[]};for(const n of c){const o=t.has(n);let s,c,u=o?t.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),c=s+u,m.set(n,c)):(s=x.get(n),c=s+u,x.set(n,c)):(s=g.get(n),c=s+u,g.set(n,c));const y=e.x(n);l.push([y,e.y(s)]),a.push([y,e.y(c)]),r.set(n,c)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,i,s),c=a;if(t.config.pointStyle){const e=new WeakMap;for(const r of n){const n=l.get(r.key);if(n)for(const o of r.data){const r=t.getX(o),i=t.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||e.set(o,n.get(r))}}const r=n=>e.get(n)??t.getY(n);Zt(t,n,c,r)}return c}(o,e);case"scatter":case"bubble":return function(t,e){const n=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let i=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 r of n)t>r&&(t=r),r>e&&(e=r);i=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",l=t.getSymbol,c=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=c?.[t];if(e)return e;let n=u.get(t);return n||(n=ue[h%ue.length],h++,u.set(t,n)),n};for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:a,opacity:.8},c=e.r||r;if(i&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(c=i(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(l){const r=d(l(o)+""),i=jt(o,t.scales,t.getX,t.getY,Math.PI*c*c,r,e,u);i&&n.push(i)}else{const r=Bt(o,t.scales,t.getX,t.getY,c,e,u);r&&n.push(r)}}return n}(o,e);case"heatmap":return ye(o,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const n=pe(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=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):[],i=new Set(o),s=Array.from(e).filter(t=>!i.has(t)).sort(),a=o.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 o=[],i=t.scales,[s,a]=i.x.domain(),l=t.config.barStyle,c=t.config.themeSemantic?.primary,u=l?.gap,h="number"!=typeof u||0>u?1:u,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.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=i.x(n),y=i.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,x=Math.max(p-g,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const s of r){const r=e.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(Ht(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||l?.fill||c||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:r},s)),n+=r}}else{const t=i.y(0),n=i.y(e.total);o.push(Ht(m,Math.min(t,n),x,Math.abs(t-n),{fill:l?.fill||c||"#007bff",...d},{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=[],r=t.config.swarmStyle||{},o=r.radius??3,i=r.fill??t.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,l=r.strokeWidth;for(const r of e){const e=t.getX(r),c=t.getY(r);if(null==c||Number.isNaN(c))continue;const u=t.scales.x(e),h=t.scales.y(c);let d=i;if(t.getCategory){const e=t.getCategory(r);d=t.config.barColors?.[e]||d}const{r:f,...y}=t.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:l,...y},datum:r};t.getPointId&&(p.pointId=t.getPointId(r)+""),n.push(p)}return n}(o,e);case"waterfall":return function(t,e,n){const r=[],o=t.scales,i=t.config.waterfallStyle,s=e.filter(e=>{const n=t.getY(e),r=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??t.config.themeSemantic?.success??"#28a745",l=i?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",c=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=i?.opacity;let f=0;for(let e=0;s.length>e;e++){const y=s[e],p=t.getX(y),g=t.getY(y),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-p:e>0?p-t.getX(s[e-1]):0;const v=o.x(p),b=0!==x?o.x(p+x):v+n.width/10,k=Math.min(v,b)+c/2,w=Math.max(v,b)-c/2-k;if(0>=w){f=m;continue}const A=o.y(f),S=o.y(m),_=Math.min(A,S),M=Math.abs(A-S),P={fill:0>g?l:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),r.push(Ht(k,_,w,M,P,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(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 r=[],o=t.config.candlestickStyle||{},i=o.rangeColor||"#6366f1",s=n?i:o.upColor||"#28a745",a=n?i:o.downColor||"#dc3545",l=n?i:o.wickColor||"#333",c=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 h=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let e=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(t.scales.x(u[n])-t.scales.x(u[n-1]));r>0&&e>r&&(e=r)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const o of e){const e=t.getX(o);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(o),u=t.getLow(o);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const d=n?i:t.getOpen(o),f=n?u:t.getClose(o);if(!n&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const y=f>=d,p={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(i),lowY:t.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:l,wickWidth:c,isUp:y,datum:o};n&&(p.isRange=!0),r.push(p)}return r}(o,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,n,r){const o=t.boundsStyle;return"function"==typeof o?o(n||{},e):o&&"object"==typeof o?o:{fill:r(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?Rt(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=It(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,n,r=It(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 i=Array(e.length);let s=!1;for(let n=0;e.length>n;n++){const a=r.get(e[n]);null!=a?(i[n]=Rt(t,a,o),1>i[n]&&(s=!0)):i[n]=1}s&&(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 s=Array(i);let a=!1;for(let n=0;e.length>n;n++){const i=r.get(e[n]);null!=i?(s[n]=Rt(t,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of e){const e=r.get(n);if(null!=e){const n=Rt(t,e,o);s>n&&(s=n)}}if(1>s){const t=Array(i);t.fill(s),n._decayOpacities=t}}continue}const e=r.get(n.datum);if(null==e)continue;const i=Rt(t,e,o);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(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&&function(t,e,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const r=t.duration??500,o=e.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(Mt())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,r){n.clear(),r.clear();for(let o=0;e.length>o;o++){const i=e[o],s=Wt(t,i,o);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(s,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(s,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.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],r=Wt(this.transitionContext,n,e);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:t,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(t=>[t[0],t[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{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,r,o){if(0===r.size&&0===o.size)return n;const i=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,l=new Set;for(let e=0;n.scene.length>e;e++){const i=n.scene[e],c=Wt(t,i,e);if(!c)continue;if(i._transitionKey=c,"line"===i.type||"area"===i.type){const t=o.get(c);if(t){if(l.add(c),"line"===i.type&&t.path&&t.path.length===i.path.length){i._targetPath=i.path.map(t=>[t[0],t[1]]),i._prevPath=t.path;for(let e=0;i.path.length>e;e++)i.path[e]=[t.path[e][0],t.path[e][1]];s=!0}else if("area"===i.type&&t.topPath&&t.bottomPath&&t.topPath.length===i.topPath.length&&t.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(t=>[t[0],t[1]]),i._targetBottomPath=i.bottomPath.map(t=>[t[0],t[1]]),i._prevTopPath=t.topPath,i._prevBottomPath=t.bottomPath;for(let e=0;i.topPath.length>e;e++)i.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;i.bottomPath.length>e;e++)i.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];s=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=t.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},s=!0;continue}const u=r.get(c);if("point"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("glyph"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("rect"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("heatcell"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,s=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},s=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){a.add(c);const t={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(i._targetX=t.x,i._targetOpenY=t.openY,i._targetCloseY=t.closeY,i._targetHighY=t.highY,i._targetLowY=t.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,s=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},s=!0}for(const[t,e]of o)if(!l.has(t))if(t.startsWith("l:")&&e.path){const r={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(r),s=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={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(r),s=!0}for(const[t,e]of r)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 r=e.openY??e.y;n.exitNodes.push({type:"candlestick",x:e.x,openY:r,closeY:e.closeY??r,highY:e.highY??r,lowY:e.lowY??r,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:Mt(),duration:i}),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,r){if(!n.activeTransition)return!1;const o=St(t,n.activeTransition),i=At(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?r.get(e):void 0;t.style.opacity=_t(n?n.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==t._targetR&&void 0!==n.r&&(t.r=_t(n.r,t._targetR,i))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style.opacity=_t(n?n.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==t._targetR&&void 0!==n.r&&(t.size=_t(n.r,t._targetR,i))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style.opacity=_t(n?n.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==n.w&&(t.w=_t(n.w,t._targetW,i)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,i))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style={...t.style||{},opacity:_t(n?n.opacity??1:0,t._targetOpacity,i)}}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==n.w&&(t.w=_t(n.w,t._targetW,i)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,i))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style={...t.style||{},opacity:_t(n?n.opacity??1:0,t._targetOpacity,i)}}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),void 0!==n.openY&&(t.openY=_t(n.openY,t._targetOpenY,i)),void 0!==n.closeY&&(t.closeY=_t(n.closeY,t._targetCloseY,i)),void 0!==n.highY&&(t.highY=_t(n.highY,t._targetHighY,i)),void 0!==n.lowY&&(t.lowY=_t(n.lowY,t._targetLowY,i))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:_t(t._startOpacity??0,t._targetOpacity,i)}),void 0!==t._introClipFraction&&(t._introClipFraction=i);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=_t(e[r][0],n[r][0],i),t.path[r][1]=_t(e[r][1],n[r][1],i)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:_t(t._startOpacity??0,t._targetOpacity,i)}),void 0!==t._introClipFraction&&(t._introClipFraction=i);const e=t._prevTopPath,n=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=_t(e[n][0],r[n][0],i),t.topPath[n][1]=_t(e[n][1],r[n][1],i);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=_t(n[e][0],o[e][0],i),t.bottomPath[e][1]=_t(n[e][1],o[e][1],i)}}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,r){if(r&&r.version===n&&r.group===e&&r.data===t)return{result:r.result,cache:r};let o;if(e){const n=new Map;for(const r of t){const t=e(r);n.has(t)||n.set(t,[]),n.get(t).push(r)}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,r,o){if(o&&o.version===r)return{map:o.map,cache:o};const i=new Set;if(e)for(const n of t){const t=e(n);t&&i.add(t)}const s=Array.from(i).sort(),a=s.join("\0");if(o&&o.key===a){const t={...o,version:r};return{map:t.map,cache:t}}const l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||kt,c=new Map;for(let t=0;s.length>t;t++)c.set(s[t],l[t%l.length]);return{map:c,cache:{key:a,map:c,version:r}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,e}resolveLineStyle(t,e){return function(t,e,n,r){const o=t.lineStyle;if("function"==typeof o){const t=o(n||{},e);if(t&&!t.stroke&&e){const n=r(e);if(n)return{...t,stroke:n}}return t}const i=t.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(e)||i||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,n,r){if(t.areaStyle){const o=t.areaStyle(n||{});if(o&&!o.fill&&e){const t=r(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=r(e);if(n)return{...t,fill:n,stroke:t.stroke||n}}return t}const i=t.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(e)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:n,groupColorCounter:r}=function(t){const{group:e,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=t;let{groupColorCounter:s}=t;if(n){const t=n.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=r.get(e);if(a)return{color:a,groupColorCounter:s};const l=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||kt;if(0===l.length)return{color:null,groupColorCounter:s};const c=l[s%l.length];if(s++,r.set(e,c),r.size>o){const t=r.keys().next().value;void 0!==t&&r.delete(t)}return{color:c,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=r,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=tt(t),n=this.getPointId,r=t=>e.has(n(t));!function(t,e,n){if(!e||0===e.size)return;const r=new Set;if(t.forEach((t,e)=>{n(t)&&r.add(e)}),0===r.size)return;const o=e.toArray();e.clear();for(let t=0;o.length>t;t++)r.has(t)||e.push(o[t])}(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);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=Mt(),this.updateResults.recordData("remove",o.length),o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=tt(t),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(r(t))&&o.add(e)});const i=this.buffer.update(t=>n.has(r(t)),e);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const t of i)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=Mt(),this.updateResults.recordData("update",i.length),i}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 r of t){const t=this._baseStyles.get(r)??r.style??{},o=n(r,e);r.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 r=!1,o=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const i="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(i||"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=i||!V(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),l=i||!V(n,s);(a||l)&&(t?(this.getX=q(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=q(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=q(this.config.xAccessor,"x"),this.getY=q(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=ke(this.config)),r=!0,o=!0)}if("groupAccessor"in t&&!V(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?K(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in t&&!V(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?K(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in t&&!V(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?q(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in t&&!V(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?K(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in t&&!V(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?K(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in t&&!V(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?q(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in t&&!V(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=ke(this.config),r=!0,o=!0),"pointIdAccessor"in t&&!V(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?K(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in t&&!V(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!V(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!V(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!V(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?q(this.config.openAccessor,"open"):void 0,this.getHigh=q(this.config.highAccessor,"high"),this.getLow=q(this.config.lowAccessor,"low"),this.getClose=e?q(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,r=!0,o=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const o of n)if(t[o]!==e[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,r,o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Fe.GROUP_COLOR_MAP_CAP=1e3;var Oe=Fe,Ye={sceneGeometry:0,layout:0,domain:0},Be="production"!==process.env.NODE_ENV,je={revisions:Ye,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},He=class{constructor(){this.lastConsumed=Ye,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(t,e){if(!Be)return je;const n=function(t){const{domain:e,layout:n,sceneGeometry:r}=t.revisions;return{domain:e,layout:n,sceneGeometry:r}}(t),r=function(t){return`${t.sceneGeometry}|${t.layout}|${t.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:t.changed.has("scene-geometry")||t.changed.has("layout")||t.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!e&&o&&this.lastUnconsumedWarning!==r}}afterCompute(t,e,n){if(Be){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 Xe from"react";function Ge(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:Xe.createElement(Xe.Fragment,null,...e)}import*as Ve from"react";import{jsx as qe}from"react/jsx-runtime";var Ue=Ve.createContext(null);function Ke({value:t,children:e}){return qe(Ue.Provider,{value:t,children:e})}function Qe(t,e){return null!=t?qe(Ke,{value:e,children:t}):t}import{useEffect as Ze,useRef as Je}from"react";function tn(t,e,n,r){Ze(()=>{t.current?.updateConfig(e),n.current=!0,r()},[e,r,t,n])}function en(t,e,n,r){const o=Je(null);Ze(()=>{const i=t.current;if(!i)return;const s=e??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[e,r,t,n])}function nn(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 rn(t,e=30){return Math.max((t??4)+5,12,e)}function on(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function sn(t,e){const n=on(t);if(!n)return!1;const r=on(e);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function an(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}var ln=[40,40],cn=[.5,.5];function un(t,e){const[n,r]=t.viewBox??ln,[o,i]=t.anchor??cn,s=r>0?r:1,a=Math.max(0,e)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-o*l,offsetY:-i*c}}function hn(t,e,n,r){if("none"!==t)return"color"===t||null==t?e??r:"accent"===t?n:t}var dn=null;function fn(t){if("undefined"==typeof Path2D)return null;dn||(dn=new Map);const e=dn.get(t);if(e)return e;const n=new Path2D(t);return dn.size>1024&&dn.clear(),dn.set(t,n),n}function yn(t,e,n=0,r="horizontal"){const[o,i]=t.viewBox??ln,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function pn(t,e){const n=un(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 gn(t,e,n,r,o,i=t=>t){for(const s of e.parts){const e=fn(s.d);if(!e)continue;const a=s.opacity??1,l=t.globalAlpha;1!==a&&(t.globalAlpha=l*a);const c=o?"none"===s.fill?void 0:o:hn(s.fill,n,r);c&&(t.fillStyle=i(c),t.fill(e));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:hn(s.stroke??"none",n,r);u&&(t.strokeStyle=i(u),t.lineWidth=s.strokeWidth??1,t.lineCap=s.strokeLinecap??"butt",t.lineJoin=s.strokeLinejoin??"miter",t.stroke(e)),1!==a&&(t.globalAlpha=l)}}function mn(t,e,n,r,o,i=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(r,o+5,12),c=e-l,u=e+l,h=n-l,d=n+l;let f=null,y=1/0;return t.visit((t,o,l,p,g)=>{if(o>u||c>p||l>d||h>g)return!0;if(!t.length){let o=t;do{const t=o.data,l=i(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);rn(a(t),r)>=u&&y>u&&(f=t,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}var xn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,vn=new WeakMap,bn=0,kn=!1,wn=null,An=null;function Sn(t,e){if(!e)return e;const n=xn.exec(e);if(!n)return e;const r=t.canvas;if(!r)return n[2]?.trim()||e;!function(){if(kn)return;if("undefined"==typeof window||"undefined"==typeof document)return;kn=!0;const t=()=>{bn++};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{wn=window.matchMedia("(prefers-color-scheme: dark)"),An=t,"function"==typeof wn.addEventListener?wn.addEventListener("change",An):"function"==typeof wn.addListener&&wn.addListener(An)}catch{}}();let o=vn.get(r);o&&o.version===bn||(o={version:bn,map:new Map},vn.set(r,o));const i=o.map.get(e);if(void 0!==i)return i;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||e;return o.map.set(e,s),s}import{curveMonotoneX as _n,curveMonotoneY as Mn,curveCardinal as Pn,curveCatmullRom as Cn,curveStep as Tn,curveStepBefore as Ln,curveStepAfter as Nn,curveBasis as Dn,curveNatural as En}from"d3-shape";function Rn(t){switch(t){case"monotoneX":return _n;case"monotoneY":return Mn;case"cardinal":return Pn;case"catmullRom":return Cn;case"step":return Tn;case"stepBefore":return Ln;case"stepAfter":return Nn;case"basis":return Dn;case"natural":return En;default:return null}}function In(t,e,n){return null==e?n:"string"!=typeof e?e:Sn(t,e)||n}function zn(t,e,n,r,o,i,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(r,o,i,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)),h=t.createLinearGradient(r,o,i,s),[d,f,y]=function(t,e){const n=t.fillStyle,r="#010203";try{t.fillStyle=r,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()===r&&e.trim().toLowerCase()!==r)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 i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(t,n);return h.addColorStop(0,`rgba(${d},${f},${y},${c})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function $n(t,e,n,r,o,i){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,r,o,i);for(const t of s)a.addColorStop(t.offset,t.color);return a}import{line as Wn}from"d3-shape";var Fn=new WeakMap;function On(t,e){const n=Rn(e);if(!n)return t;const r=Fn.get(t);if(r)return r;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const r=[];let o=null;const i={moveTo(t,e){o=[t,e],r.push([t,e])},lineTo(t,e){o=[t,e],r.push([t,e])},bezierCurveTo(t,e,i,s,a,l){if(!o)return o=[a,l],void r.push([a,l]);const[c,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*c+3*d*d*h*t+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*e+3*d*h*h*s+h*h*h*l])}o=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,i){o=[n,i],r.push([n,i])}};return Wn().x(t=>t[0]).y(t=>t[1]).curve(e).context(i)(t),r}(t,n);return Fn.set(t,o),o}function Yn(t,e,n,r=30,o,i=0){let s=null;if(o){const t=mn(o,e,n,r,i);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const i of t){let t=null;switch(i.type){case"point":if(o)break;t=jn(i,e,n,r);break;case"symbol":t=Hn(i,e,n,r);break;case"glyph":t=Xn(i,e,n,r);break;case"line":t=Gn(i,e,n,r);break;case"rect":if(null==i.datum)break;t=qn(i,e,n);break;case"heatcell":t=Un(i,e,n);break;case"area":if(!1===i.interactive)break;t=Qn(i,e,n);break;case"candlestick":t=Kn(i,e,n)}t&&r>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Bn(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const r=Zn(t,e);if(0>r)return null;if(Math.abs(t[r][0]-e)>n)return null;let o=r,i=r;r>0&&t[r][0]>=e?(o=r-1,i=r):t.length-1>r&&(o=r,i=r+1);const[s,a]=t[o],[l,c]=t[i];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function jn(t,e,n,r=30){const o=e-t.x,i=n-t.y,s=Math.sqrt(o*o+i*i);return s>rn(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Hn(t,e,n,r=30){const o=e-t.x,i=n-t.y,s=Math.sqrt(o*o+i*i);return s>rn(de(t.size),r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Xn(t,e,n,r=30){if(null==t.datum)return null;const o=pn(t.glyph,t.size),i=t.x+o.centerDx,s=t.y+o.centerDy,a=e-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>rn(o.radius,r)?null:{node:t,datum:t.datum,x:i,y:s,distance:c}}function Gn(t,e,n,r=30){if(0===t.path.length)return null;const o=Zn(t.path,e);if(0>o)return null;const[i,s]=t.path[o];let a;if(t.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(t.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=t.path[o],[a,l]=t.path[o+1],c=Vn(e,n,i,s,a,l);r>c&&(r=c)}a=r}else{const t=e-i,r=n-s;a=Math.sqrt(t*t+r*r)}const l=t.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,r)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:s,distance:a}}function Vn(t,e,n,r,o,i){const s=o-n,a=i-r,l=s*s+a*a;if(0===l)return Math.sqrt((t-n)**2+(e-r)**2);let c=((t-n)*s+(e-r)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((t-(n+c*s))**2+(e-(r+c*a))**2)}function qn(t,e,n){const r=nn(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Un(t,e,n){const r=nn(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Kn(t,e,n){const r=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,i=e-t.x,s=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function Qn(t,e,n){if(0===t.topPath.length)return null;const r=Zn(t.topPath,e);if(0>r)return null;const[o,i]=t.topPath[r],s=e-o,a=n-i,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:o,y:i,distance:l}}function Zn(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o][0]?n=o+1:r=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Jn(t){const e=new Map;for(const n of t){const t=n.group??"_default";let r=e.get(t);r||(r=[],e.set(t,r)),r.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 r=e.get(t),o=e.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(e.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const o=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=r[t].datum?.id;null!=e&&o.set(e+"",t)}return{flat:r,groups:n,byGroup:e,idToIdx:o}}function tr(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)),r=t.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function er(t,e,n){const{group:r,indexInGroup:o}=e,i=n.byGroup.get(r);switch(t){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?nr(n,n.groups[t+1],i[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?nr(n,n.groups[t-1],i[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}}function nr(t,e,n){const r=t.byGroup.get(e);let o=0,i=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);i>e&&(i=e,o=t)}return r[o]._flatIndex}function rr(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function or(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}import{useEffect as ir,useRef as sr}from"react";var ar={fresh:1,aging:.7,stale:.45,expired:.25},lr={alpha:1,band:"fresh",isStale:!1};function cr(t,e){if(!t||0>=e)return lr;const n=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},o=Ct(e,n,t.thresholds);return{alpha:{...ar,...t.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return e>n?{alpha:t.dimOpacity??.5,band:"stale",isStale:!0}:lr}function ur(t,e,n,r,o,i){const s=sr("fresh");ir(()=>{if(!t)return;const a=setInterval(()=>{const a=e.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=cr(t,l-a.lastIngestTime);c.band===s.current&&c.isStale===o||(s.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[t,o,r])}import{jsx as hr}from"react/jsx-runtime";function dr({isStale:t,position:e}){return hr("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 fr,useRef as yr,useEffect as pr}from"react";import*as gr from"react";import{jsx as mr,jsxs as xr}from"react/jsx-runtime";var vr={fill:(t,e)=>mr("rect",{style:t,width:e,height:e}),line:(t,e)=>mr("line",{style:t,x1:0,y1:0,x2:e,y2:e})};function br(t,e,n,r,o){let i;return i="function"==typeof n?n(t):(0,vr[n])(r(t,e),o),i}function kr({swatchSize:t}){return mr("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 wr(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}var Ar=(t,e,n,r,o,i,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:f}=t,y=[];let p=0;const g=!(!e&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:x,labelGap:v,rowHeight:b}=u;return f.forEach((t,c)=>{const u=br(t,c,h,d,x),k=wr(t,r,o),w=o&&o.size>0&&o.has(t.label);y.push(xr("g",{transform:`translate(0,${p})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&c===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&null!=r&&t.label===r||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=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:g?e=>{l(a,c),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.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:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&mr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+v+2+7*t.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&mr(kr,{swatchSize:x}),mr("text",{y:x/2,x:x+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+c)),p+=b}),y};function Sr({config:t,orientation:e="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=t,a=s||(t=>Math.round(100*t)/100+""),l="grad-legend-"+gr.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),s=Math.max(0,(n-e)/2),c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(mr("stop",{offset:100*e+"%",stopColor:r(o[0]+e*(o[1]-o[0]))},t))}return xr("g",{"aria-label":i||"Gradient legend",children:[mr("defs",{children:mr("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&mr("text",{x:s+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),mr("rect",{x:s,y:0,width:e,height:t,fill:`url(#${l})`,rx:2}),mr("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),mr("text",{x:s+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(mr("stop",{offset:100*e+"%",stopColor:r(o[1]-e*(o[1]-o[0]))},t))}return xr("g",{"aria-label":i||"Gradient legend",children:[i&&mr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),mr("defs",{children:mr("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),mr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),mr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),mr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function _r(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:h}=t,d=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}}(h),[f,y]=gr.useState(0),[p,g]=gr.useState(0),m=gr.useCallback((t,e)=>{y(t),g(e)},[]),x="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{let h=24;const d=[];return t.forEach((t,f)=>{h+=5,d.push(mr("line",{stroke:"gray",x1:0,y1:h,x2:e,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,t.label&&(h+=16,d.push(mr("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),h+=8),d.push(mr("g",{className:"legend-item",transform:`translate(0,${h})`,children:Ar(t,n,r,o,i,s,a,f,l,c,u)},"legend-group-"+f)),h+=t.items.length*u.rowHeight+8}),d})({legendGroups:e||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:t,height:e,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:h})=>{let d=0;const f=[];t.forEach((t,e)=>{let y=0;t.label&&(y+=16);const p=((t,e,n,r,o,i,s,a,l,c,u,h)=>{const{type:d="fill",styleFn:f,items:y}=t,p=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:v,align:b}=u,k=!(!e&&!n),w="isolate"===c||void 0===c&&null!=o,A=y.map(t=>g+m+7*t.label.length),S=[];let _=0,M=0;A.forEach((t,e)=>{const n=0===M?t:M+x+t;h&&h>0&&M>0&&n>h?(S.push({start:_,end:e,width:M}),_=e,M=t):M=n}),y.length>0&&S.push({start:_,end:y.length,width:M}),S.forEach((t,c)=>{let u="center"===b?Math.max(0,((h??t.width)-t.width)/2):"end"===b?Math.max(0,(h??t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=y[h],b=br(t,h,d,f,g),S=wr(t,r,o),_=o&&o.size>0&&o.has(t.label);p.push(xr("g",{transform:`translate(${u},${c*v})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?_||!1:void 0,"aria-current":k&&!w&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;l(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:k?e=>{l(a,h),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&mr("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"}),b,_&&mr(kr,{swatchSize:g}),mr("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-"+h)),u+=A[h]+x}});const P=Math.max(0,...S.map(t=>t.width)),C=S.length;return{items:p,offset:P,totalRows:C,totalHeight:C*v}})(t,r,o,i,s,a,l,e,c,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:t.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const o=t[r];o.label&&(g.push(mr("text",{transform:`translate(${p},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-"+r)),p+=16),g.push(mr("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,t[r+1]&&g.push(mr("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||e)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),mr("g",{children:g})})({legendGroups:e||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),v=!(!n&&!r);return xr("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&mr("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function Mr(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}import{jsx as Pr}from"react/jsx-runtime";function Cr(t){const{legend:e,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=t;if(!e)return null;const f="top"===i||"bottom"===i,y=!!a,p=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,x;return"left"===i?(m=Math.max(4,o.left-g-10),x=o.top):"top"===i?(m=o.left,x=y?32:8):"bottom"===i?(m=o.left,x=r-o.bottom+38):(m=n-o.right+10,x=o.top),Pr("g",{transform:`translate(${m}, ${x})`,children:(v=e,"object"==typeof v&&null!==v&&"gradient"in v?Pr(Sr,{config:e.gradient,orientation:f?"horizontal":"vertical",width:g}):Mr(e)?Pr(_r,{legendGroups:e.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):e)});var v}import{useMemo as Tr}from"react";import{bin as Lr}from"d3-array";function Nr(t){let e=1/0,n=-1/0;for(const r of t)e>r&&(e=r),r>n&&(n=r);return[e,n]}import{jsx as Dr,jsxs as Er}from"react/jsx-runtime";function Rr(t){return"string"==typeof t?{type:t}:t}function Ir({orient:t,config:e,values:n,scale:r,size:o,length:i}){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,l=Tr(()=>{if(0===n.length)return null;const e=r.domain(),l=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 r=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],i=e[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(e[0],r-1.5*s),whiskerHigh:Math.min(e[n-1],i+1.5*s)}}(n);if(!e)return null;const{q1:o,median:i,q3:c,whiskerLow:u,whiskerHigh:h}=e,d=Math.min(.5*l,20),f=(l-d)/2+4;if(a){const e=r(o),n=r(c),a=r(i),l=r(u),y=r(h),p="top"===t?-1:1,g=0;return Er("g",{"data-testid":"marginal-boxplot-"+t,children:[Dr("line",{x1:l,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:l,y1:g+p*f,x2:l,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("rect",{x:Math.min(e,n),y:"top"===t?g-f-d:g+f,width:Math.abs(n-e),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Dr("line",{x1:a,y1:"top"===t?g-f-d:g+f,x2:a,y2:"top"===t?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const e=r(o),n=r(c),a=r(i),l=r(u),y=r(h),p="left"===t?-1:1,g=0;return Er("g",{"data-testid":"marginal-boxplot-"+t,children:[Dr("line",{x1:g+p*(f+d/2),y1:l,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:g+p*f,y1:l,x2:g+p*(f+d),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("rect",{x:"left"===t?g-f-d:g+f,y:Math.min(e,n),width:d,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Dr("line",{x1:"left"===t?g-f-d:g+f,y1:a,x2:"left"===t?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const c=Lr().domain(e).thresholds(s.bins)(n);if(0===c.length)return null;const u=function(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}(c.map(t=>t.length));if(0===u)return null;if("histogram"===s.type)return Dr("g",{"data-testid":"marginal-histogram-"+t,children:c.map((e,n)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/u*l;if(a){const i=r(e.x0),a=r(e.x1)-r(e.x0);return Dr("rect",{x:i,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 i=r(e.x0),a=r(e.x1)-r(e.x0);return Dr("rect",{x:"left"===t?-4-o:4,y:Math.min(i,i+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=l/2+4,n=[];for(const o of c){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(l/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===t?-(e-i):e-i}`:`${"left"===t?-(e-i):e-i},${s}`)}for(let o=c.length-1;o>=0;o--){const i=c[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(l/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${h}`)}return Dr("g",{"data-testid":"marginal-violin-"+t,children:Dr("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!=c[0].x0?r(c[0].x0):0;e.push(`M${o},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);e.push(`L${i},${"top"===t?-o-4:o+4}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;e.push(`L${s},${n}`),e.push("Z")}else{const n=0,o=null!=c[0].x0?r(c[0].x0):0;e.push(`M${n},${o}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);e.push(`L${"left"===t?-o-4:o+4},${i}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;e.push(`L${n},${s}`),e.push("Z")}return Dr("g",{"data-testid":"marginal-ridgeline-"+t,children:Dr("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,o,i,t,a,4]);return l?Dr("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:l}):null}import*as zr from"react";import{jsx as $r,jsxs as Wr}from"react/jsx-runtime";function Fr(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let s="";for(const t of o)s&&s.length+1+t.length>r?(i.push(s),s=t):s=s?`${s} ${t}`:t;return s&&i.push(s),i}function Or(t,e,n,r){return"curly"===t?r?`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`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Yr(t,e,n,r){if(!t)return $r("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=t;if(!o&&!i)return $r("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,y=i?c?[i]:Fr(i,l):[],p=o?c?[o]:Fr(o,l):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push($r("foreignObject",{className:"annotation-note-html",x:"end"===d?g-l:"middle"===d?g-l/2:g,y:-16,width:l,height:Math.max(f,(y.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:Wr("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&$r("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&$r("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(x.push($r("text",{className:"annotation-note-title",fill:v,textAnchor:d,fontWeight:"bold",children:y.map((t,e)=>$r("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=y.length*f),p.length>0&&x.push($r("text",{className:"annotation-note-label",fill:v,textAnchor:d,y:m,children:p.map((t,e)=>$r("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let b=null;if((i||o)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(l,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=$r("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=$r("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),Wr("g",{className:"annotation-note",transform:`translate(${e},${n})`,children:[$r("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:x}),b]})}function Br(t,e,n,r,o){const i=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&i.push($r("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,r=e?.height||0;(t>0||r>0)&&i.push($r("rect",{width:t,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&i.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,s=o||0;if(void 0!==e?.x){const r=(e.x||0)-t;i.push($r("line",{x1:r,y1:(e.y1||0)-s,x2:r,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const r=(e.y||0)-s;i.push($r("line",{x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?i.push($r("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||i.push($r("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",r=e?.width??e?.height;void 0!==r&&i.push($r("path",{d:Or(t,r,e?.depth||30,void 0===e?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return $r("g",{className:"annotation-subject",children:i})}function jr(t,e,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=t-o,c=e-i;if(0!==s||0!==c){const t=Math.abs(s),e=Math.abs(c),u=n/2,h=r/2,d=t*h>e*u?u/t:h/e;a=o+s*d,l=i+c*d}}}else if("bracket"===o&&i){const t=i.width,e=i.height,n=i.depth||30;void 0!==t?(a=t/2,l=n):void 0!==e&&(a=n,l=e/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((t-a)**2+(e-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(e-l,t-a);if(i){const r=(a+t)/2,i=(l+e)/2,h=-(e-l)/c,d=(t-a)/c,f=(n?.curve??.25)*c,y=r+h*f,p=i+d*f;s.push($r("path",{className:"connector-curve",d:`M${a},${l}Q${y},${p} ${t},${e}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-l,y-a)}else s.push($r("line",{x1:a,y1:l,x2:t,y2:e,stroke:o},"connector-line"));if("arrow"===n?.end){const t=10,e=16/180*Math.PI;s.push($r("path",{d:`M${a},${l}L${a+t*Math.cos(u+e)},${l+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${l+t*Math.sin(u-e)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return $r("g",{className:"annotation-connector",children:s})}function Hr(t){const{x:e=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,v=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-x),null!=s&&(w=s-v);const A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const t=c.depth||30;w=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;k=t+(0>t?-5:5),w=c.height/2}return Wr("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${v})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&jr(k,w,l,h,A,c),!b.has("subject")&&Br(A,c,h,x,v),!b.has("note")&&Yr(a,k,w,h)]})}function Xr(t){const{noteData:e}=t,{screenCoordinates:n}=e,r="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),i=n.map((n,i)=>{const s=Object.assign({},e,{note:0===i?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:o});return $r(Hr,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return $r("g",{children:i})}const i=e.note||{title:"none",label:e.label},s=`${i.label}-${i.title}-${e.i}`;return $r(Hr,{"data-testid":"semiotic-annotation",events:o,...e,type:r},s)}import{packEnclose as Gr}from"d3-hierarchy";import{area as Vr,curveLinear as qr,curveMonotoneX as Ur,curveMonotoneY as Kr,curveStep as Qr,curveStepAfter as Zr,curveStepBefore as Jr,curveBasis as to,curveCardinal as eo,curveCatmullRom as no}from"d3-shape";import ro from"regression";function oo(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 io(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 so(t){return null==t?null:t+""}function ao(t,e,n){return e.stickyPositionCache?.set(t,n),n}function lo(t,e,n){const r=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===t.pointId)return ao(e,n,{x:o.x,y:o.y})}const r=function(t){const e=t.data;if(!e||0===e.length)return null;const n=e[e.length-1],r=t.scales?.x??t.scales?.time,o=t.scales?.y??t.scales?.value;if(!r||!o)return null;const i=n[t.xAccessor||"x"],s=n[t.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?ao(e,n,r):null}if("semantic"===r){const r=function(t,e,n){const r=function(t){return so(t.provenance?.stableId??t.stableId)}(t);if(!r)return null;const o=n.pointNodes?.find(t=>so(t.pointId)===r);if(o)return ao(e,n,{x:o.x,y:o.y});const i=n.data?.find(t=>function(t){return so(t.stableId??t.id??t.provenance?.stableId)}(t)===r);if(!i)return null;const s=oo(i,n),a=io(i,n);return null==s||null==a?null:ao(e,n,{x:s,y:a})}(t,e,n);if(r)return r}let o=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(o=e.x,i=e.y)}if(null!=o&&null!=i||(o=oo(t,n),i=io(t,n)),null!=o&&null!=i)return ao(e,n,{x:o,y:i});if("sticky"===r){const t=n.stickyPositionCache?.get(e);if(t)return t}return null}function co(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}import{jsx as uo}from"react/jsx-runtime";var ho={secondary:0,primary:3},fo=".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 yo(t){return!0===t?._annotationDeferred}function po(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function go(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function mo(t){return Math.max(.72,.95-.06*t)}import{jsx as xo,jsxs as vo}from"react/jsx-runtime";var bo={linear:qr,monotoneX:Ur,monotoneY:Kr,step:Qr,stepAfter:Zr,stepBefore:Jr,basis:to,cardinal:eo,catmullRom:no};function ko(t,e,n,r){const o=[];return t.forEach((t,i)=>{let s;if(n){const o=n(t,i,r);s=null!=o?o:e(t,i,r)}else s=e(t,i,r);s&&o.push({node:s,annotation:t})}),function(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:go(t.annotation),readingOrder:null,rank:1};var n}),n=e.some(t=>null!=t.emphasis||null!=t.confidence),r=t.some(t=>yo(t.annotation)),o=t.some(t=>null!=po(t.annotation)),i=t.some(t=>"layer"===po(t.annotation));if(!n&&!r&&!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=ho[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:n,emphasis:r,readingOrder:o}=t,i=yo(e.annotation);let s=e.node;if("primary"===r||"secondary"===r||null!=o){const t=null==r&&null!=o;s=uo("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:mo(o),"data-annotation-reading-order":o}:{},children:e.node},"annotation-emphasis-"+n)}const a=po(e.annotation);return a&&(s=uo("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=uo("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(uo("style",{children:fo},"annotation-disclosure-style")),i&&a.unshift(uo("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}(o)}function wo(t){return function(t,e,n){switch(t.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const r=lo(t,e,n);if(!r)return null;const{x:o,y:i}=r;if(!co(o,i,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 xo(Xr,{noteData:{x:o,y:i,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 r=oo(null!=t.value?{...t,x:t.value}:t,n);if(null==r)return null;const o=t.color||"#f97316",i=t.labelPosition||"top";let s;s="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12;const a=r>.6*(n.width||0),l=a?r-4:r+4,c=a?"end":"start";return vo("g",{opacity:t.opacity,children:[xo("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&xo("text",{x:l,y:s,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"y-threshold":{const r=io(null!=t.value?{...t,y:t.value}:t,n);if(null==r)return null;const o=t.color||"#f97316",i=t.labelPosition||"right";let s,a;return"left"===i?(s=4,a="start"):"center"===i?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),vo("g",{opacity:t.opacity,children:[xo("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&xo("text",{x:s,y:r-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 r=(t.coordinates||[]).map(t=>({x:oo({...t,type:"point"},n),y:io({...t,type:"point"},n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=Gr(r),i=t.padding||10;return vo("g",{children:[xo("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&xo("text",{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+e)}case"rect-enclose":{const r=(t.coordinates||[]).map(t=>({x:oo({...t,type:"point"},n),y:io({...t,type:"point"},n)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=t.padding||10,i=r.map(t=>t.x),s=r.map(t=>t.y),[a,l]=Nr(i),[c,u]=Nr(s),h=a-o,d=l+o,f=c-o;return vo("g",{children:[xo("rect",{x:h,y:f,width:d-h,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&&xo("text",{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+e)}case"highlight":{const r=n.data||[],o="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],i={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return xo("g",{children:o.map((e,r)=>{const o=oo(e,n),s=io(e,n);if(null==o||null==s)return null;const a="function"==typeof t.r?t.r(e):t.r||6,l="function"==typeof t.style?t.style(e):t.style||i;return xo("circle",{cx:o,cy:s,r:a,...l},"hl-"+r)})},"ann-"+e)}case"bracket":{const r=oo(t,n),o=io(t,n);return xo(Xr,{noteData:{x:r??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 r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,l=s?o:null,c=s?i:null;let u;const h=[],d=new Map;if(s&&l&&c){for(const t of r){const e=t[l];if(null==e)continue;const n=e+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=r.map(t=>{const e=t[l],n=t[c];if(null==e||null==n)return null;const r=d.get(e+"");return null!=r?[r,+n]:null}).filter(t=>null!==t)}else u=r.map(t=>[t[o],t[i]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,y=n.scales?.y??n.scales?.value;if(!f||!y)return null;const p=t=>e=>{const n=Math.max(0,Math.floor(e)),r=Math.min(h.length-1,n+1),o=e-n,i=t(h[n]);return i+(t(h[r])-i)*o},g=f,m=y;let x;if(s)if(a){const t=p(m);x=(e,n)=>[g(n),t(e)]}else{const t=p(g);x=(e,n)=>[t(e),m(n)]}else x=(t,e)=>[g(t),m(e)];const v=t.method||"linear";let b;b="loess"===v?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),o=r.map(t=>t[0]),i=r.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],r=o.map(t=>Math.abs(t-e)),l=r.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:r[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*o[t],d+=e*i[t],f+=e*o[t]*o[t],y+=e*o[t]*i[t])}if(0===u){a.push([e,i[t]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([e,d/u]);else{const t=(u*y-h*d)/p;a.push([e,(d-t*h)/u+t*e])}}return a}(u,t.bandwidth??.3):("polynomial"===v?ro.polynomial(u,{order:t.order||2}):ro.linear(u)).points;const k=b.map(([t,e])=>{const[n,r]=x(t,e);return`${n},${r}`}).join(" "),w=t.color||"#6366f1",A=b[b.length-1],[S,_]=x(A[0],A[1]);return vo("g",{children:[xo("polyline",{points:k,fill:"none",stroke:w,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&xo("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:t.label})]},"ann-"+e)}case"band":{const r=n.scales?.y??n.scales?.value,o=r?.(t.y0)??0,i=r?.(t.y1)??(n.height||0);return vo("g",{opacity:t.opacity,children:[xo("rect",{x:0,y:Math.min(o,i),width:n.width||0,height:Math.abs(i-o),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&xo("text",{x:(n.width||0)-4,y:Math.max(Math.min(o,i),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 r=n.scales?.x??n.scales?.time,o=null!=t.x0&&r?r(t.x0):null,i=null!=t.x1&&r?r(t.x1):null;return null==o||null==i?null:vo("g",{opacity:t.opacity,children:[xo("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:n.height||0,fill:t.fill||t.color||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity??.1}),t.label&&xo("text",{x:Math.min(o,i)+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 r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!i||!s)return null;const a=t.upperAccessor||"upperBounds",l=t.lowerAccessor||"lowerBounds",c=t.filter,u=r.filter(t=>null!=t[a]&&null!=t[l]&&!(c&&!c(t))).sort((t,e)=>t[o]-e[o]);if(2>u.length)return null;const h=bo[n.curve||"linear"]||qr,d=Vr().x(t=>i(t[o])).y0(t=>s(t[l])).y1(t=>s(t[a])).curve(h)(u);if(!d)return null;const f=t.fill||"#6366f1";return vo("g",{children:[xo("path",{d:d,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&u.length>0&&xo("text",{x:i(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 r=n.data||[];if(2>r.length)return null;const o=n.yAccessor||"y",i=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!i||!s)return null;const a=r.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const l=a.reduce((t,e)=>t+e,0)/a.length,c=a.reduce((t,e)=>t+(e-l)**2,0)/a.length,u=Math.sqrt(c),h=t.threshold??2,d=l-h*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=t.fillOpacity??.1,g=t.anomalyColor||"#ef4444",m=t.anomalyRadius??6,x=s(l+h*u),v=s(d),b=r.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-l)>h*u});return vo("g",{children:[f&&xo("rect",{x:0,y:Math.min(x,v),width:n.width||0,height:Math.abs(v-x),fill:y,fillOpacity:p}),b.map((t,e)=>{const r=oo(t,n),o=io(t,n);return null==r||null==o?null:xo("circle",{cx:r,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+e)}),t.label&&xo("text",{x:(n.width||0)-4,y:Math.min(x,v)-4,textAnchor:"end",fill:y,fontSize:11,children:t.label})]},"ann-"+e)}case"forecast":{const r=n.data||[];if(3>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",s=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!s||!a)return null;const l=r.map(t=>[t[o],t[i]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>l.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=ro.polynomial(l,{order:t.order||2}).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}else{const t=l.length;let e=0,n=0,r=0,o=0;for(const[t,i]of l)e+=t,n+=i,r+=t*t,o+=t*i;const i=t*r-e*e;if(1e-12>Math.abs(i))return null;const s=(t*o-e*n)/i,a=(n-s*e)/t;c=t=>a+s*t}const u=l.length,h=l.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=l.reduce((t,e)=>t+e[0],0)/u,y=l.reduce((t,e)=>t+(e[0]-f)**2,0),p=t.confidence??.95,g=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=t.steps??5,x=l[u-1][0],v=(x-l[0][0])/Math.max(u-1,1),b=[];for(let t=1;m>=t;t++)b.push(x+t*v);const k=[];for(const t of b){const e=c(t),n=d*Math.sqrt(1+1/u+(y>0?(t-f)**2/y:0))*g;k.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const w=`M${k.map(t=>`${s(t.x)},${a(t.yUpper)}`).join(" L")} L${k.slice().reverse().map(t=>`${s(t.x)},${a(t.yLower)}`).join(" L")} Z`,A=k.map(t=>`${s(t.x)},${a(t.yCenter)}`).join(" "),S=`${s(x)},${a(c(x))}`,_=t.strokeColor||"#6366f1";return vo("g",{children:[xo("path",{d:w,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),xo("polyline",{points:`${S} ${A}`,fill:"none",stroke:_,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&k.length>0&&xo("text",{x:s(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:_,fontSize:11,children:t.label})]},"ann-"+e)}case"widget":{let r,o;if(null!=t.px&&null!=t.py)r=t.px,o=t.py;else{const i=lo(t,e,n);if(!i)return null;r=i.x,o=i.y}if(!co(r,o,n))return null;const i=t.width??32,s=t.height??32;return xo("foreignObject",{x:r+(t.dx??0)-i/2,y:o+(t.dy??0)-s/2,width:i,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:xo("div",{style:{width:i,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:t.content??xo("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"})})},"ann-"+e)}case"text":{const r=lo(t,e,n);if(!r)return null;const{x:o,y:i}=r,s=o+(t.dx||0),a=i+(t.dy||0),l=t.color||"var(--semiotic-text, #333)",c=xo("text",{x:s,y:a,fill:l,fontSize:t.fontSize||11,opacity:t.opacity,strokeDasharray:t.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label});return!0!==t._redundantConnector?zr.cloneElement(c,{key:"ann-text-"+e}):vo("g",{opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:[xo("line",{x1:o,y1:i,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),zr.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+e)}case"category-highlight":{const r=t.category;if(null==r)return null;const o=t=>"function"==typeof t&&"function"==typeof t.bandwidth,i=n.scales?.o,s=n.scales?.x,a=n.scales?.y,l=o(i)?i:o(s)?s:o(a)?a:null;if(!l)return null;const c=l(r+"");if(null==c)return null;const u=l.bandwidth(),h=t.color||"var(--semiotic-primary, #4589ff)",d=t.opacity??.15,f=t.label;return vo("g",(n.projection?"vertical"===n.projection:l===s)?{children:[xo("rect",{x:c,y:0,width:u,height:n.height||0,fill:h,fillOpacity:d}),f&&xo("text",{x:c+u/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]}:{children:[xo("rect",{x:0,y:c,width:n.width||0,height:u,fill:h,fillOpacity:d}),f&&xo("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+e)}default:return null}}}var Ao=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function So(t){return!!t&&"object"==typeof t&&Ao.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}function _o(t){return"primary"===t?.emphasis||!0===t?.defensive}function Mo(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 Po(t){let e;const n=t?.emphasis;e="primary"===n?100:"secondary"===n?10:50;const r=t?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(e+=15*Math.max(0,Math.min(1,r))),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 Co=32,To=6,Lo=4,No=8,Do=72;var Eo={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Ro(t){if(!Io(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 Io(t){return So(t)}function zo(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),r=t.split(/\s+/).filter(Boolean),o=[];let i="";for(const t of r)i&&i.length+t.length+1>n?(o.push(i),i=t):i=i?`${i} ${t}`:t;return i&&o.push(i),o}function $o(t,e,n,r,o){const i=t+n,s=e+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function Wo(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Fo(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 Oo(t,e,n,r,o,i,s,a){const l=Wo(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,r){const o=Math.max(0,r-t.x),i=Math.max(0,r-t.y);return(o+Math.max(0,t.x+t.width-(e-r)))*t.height+(i+Math.max(0,t.y+t.height-(n-r)))*t.width}(l,o,i,a);for(const t of n)c+=12*Fo(l,t);for(const t of r)c+=4*Fo(l,t);return c}function Yo(t){const{annotations:e,context:n,defaultOffset:r=Co,notePadding:o=To,markPadding:i=Lo,edgePadding:s=No,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:c=Do,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=t,m=n.width||0,x=n.height||0,v="object"==typeof y?y:{},b=v.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==v.preferShortText?e.map(Ro):e,A=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,S=h||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),_=k&&!f?v.responsive??{minWidth:b}:f,M=k&&!p?v.cohesion:p;if(0===w.length||0>=m||0>=x)return w.slice();const P=[],C=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,i);let T=!1;const L=w.map((t,e)=>{if(!Io(t))return t;const i=function(t,e,n){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=t.pointId??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 o=t.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const t=o[0],e=o[1];if("number"==typeof t&&"number"==typeof e){const n=i([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?lo(t,e,n):{x:t.x,y:t.y}}(t,e,n);if(!i)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=[...zo("string"==typeof t.title?t.title:void 0,e),...zo("string"==typeof t.label?t.label:void 0,e)],r=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*r)+10),height:Math.max(18,16*n.length+6)}}(t);if(a&&("number"==typeof(h=t).dx||"number"==typeof h.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return P.push(Wo($o(i.x,i.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),o)),t}var h;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(r)){const e=Oo($o(i.x,i.y,t.dx,t.dy,u),t,P,C,m,x,o,s);f>e&&(d=t,f=e)}if(!d)return t;const y=Wo($o(i.x,i.y,d.dx,d.dy,u),o);P.push(y);const p=Math.hypot(d.dx,d.dy),g=l&&p>=c&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return T=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),N=T?L:w.slice();let D=N;if(d){let t=!1;const e=N.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});D=t?e:N}{let t=!1;const e=D.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?Eo[e.source]??e.source:null,r="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!n&&!r)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof t.label?t.label:"";return i.includes(`(${o})`)?t:{...t,label:i?`${i} (${o})`:`(${o})`}}(e);return n!==e&&(t=!0),n});D=t?e:D}const E=new Set;if(A){const t="object"==typeof A?A:{},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??Mo(m,x,t))*e))},{deferred:r}=function(t){const{annotations:e,width:n,height:r}=t,o=Math.max(0,t.minVisible??1),i=Mo(n,r,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(n=t,So(n))};var n}),a=s.filter(t=>t.note);if(0===a.length||i>=a.length)return{visible:e.slice(),deferred:[],budget:i};const l=a.filter(t=>_o(t.annotation)),c=a.filter(t=>!_o(t.annotation)).sort((t,e)=>Po(e.annotation)-Po(t.annotation)||t.index-e.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),h=new Set([...l.map(t=>t.index),...c.slice(0,u).map(t=>t.index)]),d=[],f=[];for(const{annotation:t,index:e,note:n}of s)!n||h.has(e)?d.push(t):f.push(t);return{visible:d,deferred:f,budget:i}}({annotations:D,width:m,height:x,...n});for(const t of r)E.add(t)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const t of D)Io(t)&&"secondary"===t.emphasis&&E.add(t);if(E.size>0)for(const t of D)!0===t?.defensive&&E.delete(t);let R;return R=0===E.size?D:S?D.map(t=>E.has(t)?{...t,_annotationDeferred:!0}:t):D.filter(t=>!E.has(t)),M?function(t,e){let n=!1;const r=t.map(t=>Io(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,{...t,cohesion:e}):t);return n?r:t}(R,M):R}import{useSyncExternalStore as Bo}from"react";var jo={positions:new Map},Ho=new Set;function Xo(){for(const t of Ho)t()}function Go(t,e){const n=jo.positions.get(t);if(n?.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(jo.positions);r.delete(t),jo={positions:r},Xo()}function Vo(t,e){const n=jo.positions.get(t);if(!n?.locked)return;if(e&&n.sourceId!==e)return;const r=new Map(jo.positions);r.delete(t),jo={positions:r},Xo()}function qo(){return jo}function Uo(t){return Ho.add(t),()=>Ho.delete(t)}var Ko={positions:new Map};function Qo(){return()=>{}}function Zo(){return Ko}function Jo(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>e||s===a)return i?[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]=i?new Date(n):n}return c}(t,e):t.ticks(e)}import{Fragment as ti,jsx as ei,jsxs as ni}from"react/jsx-runtime";function ri(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function oi(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function ii(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const r of t)e>r.pixel&&(e=r.pixel),r.pixel>n&&(n=r.pixel);return{min:e,max:n}}function si(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function ai(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,o="left"===t?-1:1,i=Math.ceil(e/8);let s="M0,"+r;for(let t=0;i>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${r+4*o}`,s+=`L${Math.min(n,e)},${r}`}return s}{const r="bottom"===t?0:e,o="bottom"===t?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let t=0;i>t;t++){const e=8*(t+1);s+=`L${r+4*o},${Math.min(8*t+4,n)}`,s+=`L${r},${Math.min(e,n)}`}return s}}function li(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:h,axisExtent:d}=t,f=fr(()=>{if(!s)return[];const t=l?.find(t=>"bottom"===t.orient),n=t?.tickFormat||u||ci,r=Math.max(2,Math.floor(e/70)),o=t?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=t?.tickValues??Jo(s.x,i,d),c=a.map(t=>t.valueOf()),h=a.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,c)})),f=h.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 ui(h,Math.max(55,f+8))},[s,l,u,e,d]),y=fr(()=>{if(!s)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||h||ci,r=Math.max(2,Math.floor(n/30)),o=t?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return ui((t?.tickValues??Jo(s.y,i,d)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[s,l,h,n,d]),p=c&&s,g=a&&s;if(!p&&!g)return null;const m=l?.find(t=>"bottom"===t.orient),x=l?.find(t=>"left"===t.orient),v=g&&(!m||!1!==m.baseline),b=g&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,w=x?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return ei("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:ni("g",{transform:`translate(${i.left},${i.top})`,children:[p&&(()=>{const t=si(l?.find(t=>"bottom"===t.orient)?.gridStyle),r=si(l?.find(t=>"left"===t.orient)?.gridStyle);return ni("g",{className:"stream-grid",children:[f.map((e,r)=>ei("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+r)),y.map((t,n)=>ei("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),v&&!k&&ei("line",{x1:0,y1:n,x2:e,y2:n,stroke:A,strokeWidth:1}),k&&ei("path",{d:ai("bottom",e,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&ei("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&ei("path",{d:ai("left",e,n),fill:"none",stroke:A,strokeWidth:1})]})})}function ci(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function ui(t,e){if(2>=t.length)return t;const n=[t[0]];for(let r=1;t.length-1>r;r++)e>Math.abs(t[r].pixel-n[n.length-1].pixel)||n.push(t[r]);const r=t[t.length-1];return e>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function hi(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,xLabel:c,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:P,annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,xAccessor:N,yAccessor:D,annotationData:E,pointNodes:R,curve:I,underlayRendered:z,canvasObscuresUnderlay:$=!0,linkedCrosshairName:W,linkedCrosshairSourceId:F,children:O}=t,Y=fr(()=>{if(!a||!s)return[];const t=l?.find(t=>"bottom"===t.orient),n=t?.tickFormat||d||ci,r=Math.max(2,Math.floor(e/70)),o=t?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),c=t?.tickValues??Jo(s.x,i,y),u=c.map(t=>t.valueOf()),h=c.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,u)})),f=h.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),p=t?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=ui(h,p);if(g.length>1&&(g=g.filter((t,e)=>0===e||t.label+""!=g[e-1].label+"")),t?.includeMax&&g.length>0&&"exact"!==y&&!t?.tickValues){const t=s.x.domain()[1],e=s.x(t),r=g[g.length-1].pixel;if(Math.abs(e-r)>1){const o=n(t,g.length,u);p>e-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:t,pixel:e,label:o})}}return g},[a,s,l,d,e,y]),B=fr(()=>{if(!a||!s)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||f||ci,r=Math.max(2,Math.floor(n/30)),o=t?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let c=ui((t?.tickValues??Jo(s.y,i,y)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22);if(c.length>1&&(c=c.filter((t,e)=>0===e||t.label+""!=c[e-1].label+"")),t?.includeMax&&c.length>0&&"exact"!==y&&!t?.tickValues){const t=s.y.domain()[1],n=s.y(t),r=c[c.length-1].pixel;if(Math.abs(n-r)>1){const o=e(t);22>Math.abs(n-r)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:t,pixel:n,label:o})}}return c},[a,s,l,f,n,y]),j=fr(()=>{if(!a||!s)return[];const t=l?.find(t=>"right"===t.orient);if(!t)return[];const e=t.tickFormat||f||ci,r=Math.max(2,Math.floor(n/30)),o=t.ticks??5;return ui((t.tickValues??Jo(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[a,s,l,f,n,y]),H=yr(new Map),X=yr(C?.length??0),G=C?.length??0;X.current!==G&&(X.current=G,H.current=new Map);const V=fr(()=>{if(!C||0===C.length)return null;const t=wo(),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:N,yAccessor:D,width:e,height:n,data:E,frameType:"xy",pointNodes:R,curve:I,stickyPositionCache:H.current};return ko(T?Yo({annotations:C,context:r,..."object"==typeof T?T:{}}):C,t,L,r)},[C,T,L,e,n,N,D,E,s,R,I]),q=function(t){const e=Bo(t?Uo:Qo,t?qo:Zo,t?qo:Zo);return t?e.positions.get(t)??null:null}(W);return pr(()=>{if(!q?.locked||!W)return;const t=t=>{"Escape"===t.key&&Vo(W)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[q?.locked,W]),a||g||m||S||_||V&&V.length>0||p||O||q?ni("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[ei("title",{children:"string"==typeof g?g:"XY Chart"}),ei("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),ni("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&(!z||$)&&(()=>{const t=si(l?.find(t=>"bottom"===t.orient)?.gridStyle),r=si(l?.find(t=>"left"===t.orient)?.gridStyle);return ni("g",{className:"stream-grid",children:[Y.map((e,r)=>ei("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+r)),B.map((t,n)=>ei("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const t=l?.find(t=>"left"===t.orient),r=l?.find(t=>"bottom"===t.orient),o=!t||!1!==t.baseline,s=!r||!1!==r.baseline,a=t?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=t?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!r?.autoRotate&&Y.length>1&&(()=>{const t=e/Math.max(Y.length-1,1);return Y.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),v=x?12:18,b=n+(x?58:40),k={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=r?.tickAnchor,_=t?.tickAnchor,M=ii(Y),P=ii(B);return ni("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[ni("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!z||$)&&s&&!d&&ei("line",{x1:0,y1:n,x2:e,y2:n,stroke:p,strokeWidth:1}),(!z||$)&&d&&ei("path",{d:ai("bottom",e,n),fill:"none",stroke:p,strokeWidth:1}),Y.map((t,e)=>{const r=!!f&&("function"==typeof f?f(t.value,e):sn(t.value,e>0?Y[e-1].value:void 0));return ni("g",{transform:`translate(${t.pixel},${n})`,children:[ei("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ei("text",{y:v,textAnchor:x?"end":ri(S,t.pixel===M.min,t.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:x?"rotate(-45)":void 0,children:t.label}):ei("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:ei("div",{style:{textAlign:"center",userSelect:"none",...k},children:t.label})})]},"xtick-"+e)}),c&&ei("text",{x:e/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:c})]}),ni("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!z||$)&&o&&!a&&ei("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!z||$)&&a&&ei("path",{d:ai("left",e,n),fill:"none",stroke:p,strokeWidth:1}),B.map((t,e)=>{const n=!!y&&("function"==typeof y?y(t.value,e):sn(t.value,e>0?B[e-1].value:void 0));return ni("g",{transform:`translate(0,${t.pixel})`,children:[ei("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ei("text",{x:-8,textAnchor:"end",dominantBaseline:oi(_,t.pixel===P.min,t.pixel===P.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:t.label}):ei("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:ei("div",{style:{textAlign:"right",userSelect:"none",...k},children:t.label})})]},"ytick-"+e)}),(()=>{const e=t?.label||u;return e?ei("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:e}):null})()]}),(()=>{const t=l?.find(t=>"right"===t.orient);if(!t||0===j.length)return null;const r=!1!==t.baseline,o=t.landmarkTicks,s=t.label||h,a=t.tickAnchor,c=ii(j);return ni("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&ei("line",{x1:e,y1:0,x2:e,y2:n,stroke:p,strokeWidth:1}),j.map((t,n)=>{const r=!!o&&("function"==typeof o?o(t.value,n):sn(t.value,n>0?j[n-1].value:void 0));return ni("g",{transform:`translate(${e},${t.pixel})`,children:[ei("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ei("text",{x:8,textAnchor:"start",dominantBaseline:oi(a,t.pixel===c.min,t.pixel===c.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:t.label}):ei("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:ei("div",{style:{textAlign:"left",userSelect:"none",...k},children:t.label})})]},"ytick-r-"+n)}),s&&ei("text",{x:e+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${e+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),V,_&&s&&M&&P&&ni(ti,{children:[_.top&&ei("g",{transform:"translate(0, 0)",children:ei(Ir,{orient:"top",config:Rr(_.top),values:M,scale:s.x,size:i.top,length:e})}),_.bottom&&ei("g",{transform:`translate(0, ${n})`,children:ei(Ir,{orient:"bottom",config:Rr(_.bottom),values:M,scale:s.x,size:i.bottom,length:e})}),_.left&&ei("g",{transform:"translate(0, 0)",children:ei(Ir,{orient:"left",config:Rr(_.left),values:P,scale:s.y,size:i.left,length:n})}),_.right&&ei("g",{transform:`translate(${e}, 0)`,children:ei(Ir,{orient:"right",config:Rr(_.right),values:P,scale:s.y,size:i.right,length:n})})]}),S,q&&q.sourceId!==F&&s?.x&&(()=>{const t=s.x(q.xValue);if(null==t||0>t||t>e)return null;const r=q.locked;return ei("line",{x1:t,y1:0,x2:t,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),O]}),g&&ei("text",{x:r/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}),Cr({legend:m,totalWidth:r,totalHeight:o,margin:i,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}import*as di from"react";import{arc as fi}from"d3-shape";function yi(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}import{jsx as pi,jsxs as gi}from"react/jsx-runtime";var mi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function xi(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function vi(t,e,n,r){const o=t.glyph;if(!o?.parts?.length||0>=t.size)return null;const i=un(o,t.size);if(0>=i.scale)return null;const s=`translate(${e},${n})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),l=yn(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),c=l?function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(r+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>o.parts.map((n,r)=>{const o=e?"none"===n.fill?void 0:e:hn(n.fill,a,t.accent),i=e?n.stroke&&"none"!==n.stroke?e:void 0:hn(n.stroke??"none",a,t.accent);return o||i?pi("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return gi("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&pi("clipPath",{id:c,children:pi("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&t.ghostColor?pi("g",{children:h(t.ghostColor)}):null,l&&c?pi("g",{clipPath:`url(#${c})`,children:h()}):h()]},r)}var bi="undefined"==typeof window||"undefined"==typeof document;import{useEffect as ki,useLayoutEffect as wi,useRef as Ai,useState as Si,useSyncExternalStore as _i}from"react";var Mi="undefined"!=typeof window?wi:ki;function Pi(){const[t,e]=Si(!1);return Mi(()=>{e(!0)},[]),t}var Ci=()=>()=>{},Ti=()=>!1,Li=()=>!0;function Ni(){const t=_i(Ci,Ti,Li);return Ai(t).current}function Di(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=t;Mi(()=>{e&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),i.current()},[e,n]);const l=Ai(a);l.current=a,ki(()=>()=>l.current?.(),[])}import{useRef as Ei}from"react";function Ri(t){const e=Ei(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return zi(t,e);if(!$i(t)||!$i(e))return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(e,r))return!1;const n=t[r],o=e[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!zi(n,o))return!1}else{if(!$i(n)||!$i(o))return!1;if(!Ii(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}function Ii(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(e,r))return!1;if(!Object.is(t[r],e[r]))return!1}return!0}function zi(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 $i(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}function Wi(t,e){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:l}=e;if("transparent"===n)return!1;if(r)return!1;const c=n||(o&&"transparent"!==o?o:"")||null;if(!c)return!1;const u=Sn(t,c);return!!u&&(t.fillStyle=u,t.fillRect(i,s,a,l),!0)}var Fi={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 Oi(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],r=n[2],o=n[3];return`#${t}${t}${r}${r}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}import*as Yi from"react";import*as Bi from"react";import{jsx as ji}from"react/jsx-runtime";var Hi=Bi.createContext(null);function Xi(){return Bi.useContext(Hi)}function Gi(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,r]of Object.entries(t))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(e[n]=r):"string"==typeof r?e[n]=r:"boolean"==typeof r?e[n]=r+"":r instanceof Date&&(e[n]=r.toISOString().slice(0,10)));return e}function Vi(t){return t&&"object"==typeof t?t:{}}function qi(t){return Vi(t.accessibility).tableFields??t.accessibleDatum??t.datum}import{jsx as Ui,jsxs as Ki}from"react/jsx-runtime";var Qi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Zi(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 r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=i.indexOf(t),r=i.indexOf(e);return(-1===n?999:n)-(-1===r?999:r)});for(const t of s)r.push(`${n[t]} ${o[t]||t}`);return`${e}, ${r.join(", ")}`}function Ji(t,e,n){const r=[];return t>0&&r.push(t+" nodes"),e>0&&r.push(e+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var ts=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},es="semiotic-accessible-data-table",ns=es+" semiotic-accessible-data-table-hidden",rs=es+" semiotic-accessible-data-table-visible",os=rs+" semiotic-accessible-data-table-network",is={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"},ss={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},as={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)"},ls={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},cs={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))"},us={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},hs={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ds={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 fs({scene:t,chartType:e,tableId:n,chartTitle:r}){const[o,i]=Yi.useState(!1),[s,a]=Yi.useState(5),l=Xi(),c=l?.visible??!1,u=o||c,h=Yi.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${e} ${n}`:"Data summary for "+e;Yi.useEffect(()=>{u||a(5)},[u]);const f=Yi.useCallback(t=>{t.target===t.currentTarget&&(o||c||i(!0))},[o,c]),y=Yi.useCallback(t=>{c||h.current?.contains(t.relatedTarget)||i(!1)},[c]);if(!t||0===t.length)return n?Ui("span",{id:n,tabIndex:-1,style:Qi}):null;if(!u)return Ui("div",{id:n,className:ns,tabIndex:-1,onFocus:f,style:Qi,role:"region","aria-label":d,children:Ki("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",t.length," elements)"]})});const p=function(t){const e=[];if(!Array.isArray(t))return e;const n=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const r of t)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;e.push({label:"Point",values:Gi(qi(r))});break;case"line":case"area":{const t=qi(r),n=Array.isArray(t)?t:[],o="line"===r.type?"Line point":"Area point";for(const t of n)e.push({label:o,values:Gi(t)});break}case"rect":{const t=qi(r),n=null!=t&&"object"==typeof t?t:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Gi(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),e.push({label:"Bar",values:s});break}case"heatcell":{const t=Gi(qi(r));null==t.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(t.value=r.value),e.push({label:"Cell",values:t});break}case"wedge":{const t=qi(r),n=Gi(t);if(null==n.category){const e=Vi(t),r=e.category??e.label;null!=r&&(n.category=r+"")}e.push({label:"Wedge",values:n});break}case"circle":e.push({label:"Node",values:Gi(qi(r))});break;case"arc":e.push({label:"Arc",values:Gi(qi(r))});break;case"candlestick":e.push({label:"Candlestick",values:Gi(qi(r))});break;case"geoarea":{const t=Vi(qi(r)),n=Gi(t);if(null==n.name){const e=Vi(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 r of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[r];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],i=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),i+=n;n.push({name:r,count:e.length,numeric:!0,min:t,max:o,mean:i/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:r,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(p),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${ts(t.min)} to ${ts(t.max)}, mean ${ts(t.mean)}.`);else{const e=t.uniqueValues,r=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${r}.`)}return n.join(" ")}(p.length,g),x=Math.min(s,p.length),v=p.slice(0,x),b=p.length-x,k=new Set;for(const t of v)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return Ki("div",{ref:h,id:n,className:rs,tabIndex:-1,onBlur:y,style:is,role:"region","aria-label":d,children:[Ui("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:as,children:"×"}),Ui("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ss,children:m}),Ki("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+e,style:ls,children:[Ui("caption",{className:"semiotic-accessible-data-table-caption",style:hs,children:b>0?`First ${x} of ${p.length} data points`:`All ${p.length} data points`}),Ui("thead",{children:Ki("tr",{children:[Ui("th",{style:cs,children:"type"}),w.map(t=>Ui("th",{style:cs,children:t},t))]})}),Ui("tbody",{children:v.map((t,e)=>Ki("tr",{children:[Ui("td",{style:us,children:t.label}),w.map(e=>{return Ui("td",{style:us,children:(n=t.values[e],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":ts(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},e);var n})]},e))})]}),b>0&&Ki("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(t=>t+25),style:ds,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function ys({nodes:t,edges:e,chartType:n,tableId:r,chartTitle:o}){const[i,s]=Yi.useState(!1),[a,l]=Yi.useState(5),c=Xi(),u=c?.visible??!1,h=i||u,d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Yi.useRef(null);Yi.useEffect(()=>{h||l(5)},[h]);const y=Yi.useCallback(t=>{t.target===t.currentTarget&&(i||u||s(!0))},[i,u]),p=Yi.useCallback(t=>{u||f.current?.contains(t.relatedTarget)||s(!1)},[u]);if(!t||0===t.length)return r?Ui("span",{id:r,tabIndex:-1,style:Qi}):null;if(!h)return Ui("div",{id:r,className:ns,tabIndex:-1,onFocus:y,style:Qi,role:"region","aria-label":d,children:Ki("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",t.length," nodes, ",e.length," edges)"]})});const g=Array.isArray(t)?t:[],m=Array.isArray(e)?e:[],x=new Map,v=new Map,b=new Map,k=new Map;for(const t of m){if(!t||"object"!=typeof t)continue;const e=t.datum??t,n="object"==typeof e.source?e.source?.id:e.source,r="object"==typeof e.target?e.target?.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";v.set(t,(v.get(t)??0)+1),k.set(t,(k.get(t)??0)+o)}if(null!=r&&""!==r){const t=r+"";x.set(t,(x.get(t)??0)+1),b.set(t,(b.get(t)??0)+o)}}const w=[];for(let t=0;g.length>t;t++){const e=g[t];if(!e||"object"!=typeof e)continue;const n=e.datum?.id??e.id,r=null!=n?n+"":"node-"+t,o=x.get(r)??0,i=v.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((t,e)=>e.degree-t.degree);let A=0,S=0;if(w.length>0){let t=0;for(const e of w)t+=e.degree,e.degree>S&&(S=e.degree);A=t/w.length}const _=m.some(t=>{const e=t?.datum??t;return"number"==typeof e?.value&&Number.isFinite(e.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${ts(A)}, max degree: ${S}.`);const P=Math.min(a,w.length),C=w.slice(0,P),T=w.length-P;return Ki("div",{ref:f,id:r,className:os,tabIndex:-1,onBlur:p,style:is,role:"region","aria-label":d,children:[Ui("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:as,children:"×"}),Ui("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ss,children:M.join(" ")}),Ki("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:ls,children:[Ui("caption",{className:"semiotic-accessible-data-table-caption",style:hs,children:T>0?`Top ${P} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),Ui("thead",{children:Ki("tr",{children:[Ui("th",{style:cs,children:"id"}),Ui("th",{style:cs,children:"degree"}),Ui("th",{style:cs,children:"in"}),Ui("th",{style:cs,children:"out"}),_&&Ui("th",{style:cs,children:"w. degree"}),_&&Ui("th",{style:cs,children:"w. in"}),_&&Ui("th",{style:cs,children:"w. out"})]})}),Ui("tbody",{children:C.map((t,e)=>Ki("tr",{children:[Ui("td",{style:us,children:t.id}),Ui("td",{style:us,children:t.degree}),Ui("td",{style:us,children:t.inDeg}),Ui("td",{style:us,children:t.outDeg}),_&&Ui("td",{style:us,children:ts(t.wDegree)}),_&&Ui("td",{style:us,children:ts(t.wInDeg)}),_&&Ui("td",{style:us,children:ts(t.wOutDeg)})]},e))})]}),T>0&&Ki("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(t=>t+25),style:ds,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function ps({summary:t}){return t?Ui("div",{role:"note",style:Qi,children:t}):null}function gs({tableId:t}){return Ui("a",{href:"#"+t,style:Qi,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,Qi)},children:"Skip to data table"})}function ms({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 Ui("div",{"aria-live":"polite","aria-atomic":"true",style:Qi,children:e})}import{jsx as xs}from"react/jsx-runtime";var vs="var(--semiotic-focus, #005fcc)";function bs({active:t,hoverPoint:e,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!t||!e)return null;const l=e.x+n.left,c=e.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const t=Math.max(i,4),e=Math.max(s,4);u=xs("rect",{x:l-t/2-3,y:c-e/2-3,width:t+6,height:e+6,rx:3,fill:"none",stroke:vs,strokeWidth:2,strokeDasharray:"4,2"})}else u=xs("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:vs,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:vs,strokeWidth:2,strokeDasharray:"4,2"});else u=xs("g",{transform:`translate(${n.left},${n.top})`,children:xs("path",{d:a,fill:"none",stroke:vs,strokeWidth:2.5,strokeDasharray:"6,3"})});return xs("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as ks from"react";function ws(t,e){return"touch"===e?Math.max(t,24):t}function As(t){return Array.isArray(t)?t[0]:t}function Ss(t,e,n,r){return{data:As(t),x:e,y:n,__semioticHoverData:!0,...r}}var _s=["name","label","title"],Ms=["type","kind","category","group","class","status","role","shape"],Ps=["value","amount","total","count","weight","score"],Cs=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 Ts(t,e){for(const n of e){const e=t.find(t=>t.lower===n);if(e)return e}}function Ls(t,e={}){if(!t||"object"!=typeof t)return{entries:[]};const n=e.maxEntries??6,r=!1!==e.skipPositional,o=[];for(const[e,n]of Object.entries(t)){if(e.startsWith("_"))continue;if("data"===e)continue;if(r&&Cs.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 i=o.findIndex(t=>_s.includes(t.lower));const s=i>=0;0>i&&(i=o.findIndex(t=>"id"===t.lower)),0>i&&(i=o.findIndex(t=>"string"==typeof t.value));const a=0>i?void 0:o[i];let l=o.filter((t,e)=>e!==i);s&&(l=l.filter(t=>"id"!==t.lower));const c=Ts(l,Ms),u=Ts(l,Ps),h=new Set(Ms),d=new Set(Ps),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const t of l){if(f.length>=n)break;t!==c&&t!==u&&(h.has(t.lower)||d.has(t.lower)||f.push({key:t.key,value:t.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}import{jsx as Ns,jsxs as Ds}from"react/jsx-runtime";var Es={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"};import{jsx as Rs}from"react/jsx-runtime";function Is({x:t,y:e,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(t)&&Number.isFinite(e),c=ks.useRef(null),[u,h]=ks.useState(null);ks.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[i,s,n,r]);let d;d=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-e?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>e?"4px":"calc(-100% - 4px)"})`;const f=function(t){if(!ks.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 r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),y=f?null:Es;return l?Rs("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:o.left+t,top:o.top+e,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}import*as zs from"react";import{useCallback as $s,useEffect as Ws,useLayoutEffect as Fs,useMemo as Os,useRef as Ys}from"react";import{useState as Bs,useEffect as js}from"react";import{useRef as Hs,useState as Xs,useEffect as Gs}from"react";var Vs="undefined"==typeof window?Ws:Fs,qs={requestAnimationFrame:t=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(t),cancelAnimationFrame:t=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(t)};function Us(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Ks(t){const e=function(){const[t,e]=Bs(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return js(()=>{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=Ys(e);n.current=e;const[r,o]=function(t,e,n){const r=Hs(null),[o,i]=Xs(null);return Gs(()=>{if(!e&&!n)return;const t=r.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;i(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[r,[e&&o?o.w:t[0],n&&o?o.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),i=Os(()=>({...t.marginDefault,...t.userMargin}),[t.marginDefault,t.userMargin]),s=o[0]-i.left-i.right,a=o[1]-i.top-i.bottom,l=Us(t.foregroundGraphics,o,i),c=Us(t.backgroundGraphics,o,i),u=H(t=>t.theme),{transition:h,introEnabled:d}=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-"+zs.useId(),y=Ys(null),p=Ys(t.frameScheduler??qs);p.current=t.frameScheduler??qs;const g=Ys(null),m=Ys(!1),x=Ys(()=>{}),v=$s(()=>{if(null!==y.current||m.current)return;const t=p.current;let e=!1,n=!1;const r=t.requestAnimationFrame(()=>{e=!0;const t=!n;t&&(m.current=!0),y.current=null,g.current=null;try{x.current()}finally{t&&(m.current=!1)}});n=!0,e||(y.current=r,g.current=t)},[]),b=$s(()=>{null!==y.current&&((g.current??p.current).cancelAnimationFrame(y.current),y.current=null,g.current=null)},[]);Ws(()=>()=>{b()},[b]);const k=Ys(()=>{}),w=Ys(()=>{}),A=Ys(null),S=Ys(null),_=Ys(null),M=$s(()=>{const t=A.current;A.current=null,t&&k.current(t)},[]),P=$s(t=>{if(A.current={clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType},null===S.current){const t=p.current;let e=!1;const n=t.requestAnimationFrame(()=>{e=!0,S.current=null,_.current=null,M()});e||(S.current=n,_.current=t)}},[M]),C=$s(()=>{A.current=null,null!==S.current&&((_.current??p.current).cancelAnimationFrame(S.current),S.current=null,_.current=null),w.current()},[]);Ws(()=>()=>{A.current=null,null!==S.current&&((_.current??p.current).cancelAnimationFrame(S.current),S.current=null,_.current=null)},[]);const T=t.themeDirtyRef;return Vs(()=>{T&&(bn++,T.current=!0,v())},[u,v,T]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,resolvedForeground:l,resolvedBackground:c,currentTheme:u,transition:h,introEnabled:d,tableId:f,rafRef:y,renderFnRef:x,scheduleRender:v,cancelRender:b,hoverHandlerRef:k,hoverLeaveRef:w,onPointerMove:P,onPointerLeave:C}}function Qs(t,e,n,r){const o=t.getContext("2d");if(!o)return null;const i=Math.round(e[0]*r),s=Math.round(e[1]*r),a=i/e[0],l=s/e[1],c=e[0]+"px",u=e[1]+"px";return t.style.width!==c&&(t.style.width=c),t.style.height!==u&&(t.style.height=u),t.width===i&&t.height===s||(t.width=i,t.height=s),o.setTransform(a,0,0,l,0,0),o.translate(n.left,n.top),o}function Zs(){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 Js}from"react";function ta(t,e,n,r){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:r,fn:e}:{key:void 0,fn:null}}var ea=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],na=3156e7;function ra(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")}`}:na>e?t=>{const e=new Date(t);return`${ea[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*na>e?t=>{const e=new Date(t);return`${ea[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}function oa(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:de(n.size)});else if("glyph"===n.type){const t=pn(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 ia}from"d3-shape";function sa(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}function aa(t,e,n,r,o,i){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],r=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=i;for(let n=0;e.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;l>r&&(i*=r/l),l>a-r&&(i*=(a-r)/l),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}var la=(t,e,n,r)=>{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,r.width*n,r.height),t.clip());const o=e.style.stroke||"#007bff",i=Sn(t,o)||o,s=e.style.strokeWidth||2,a=e.colorThresholds,l=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){aa(t,e.path,i,s,e.style.opacity??1,e.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const c=Rn(e.curve),u=a&&a.length>0&&l&&l.length===e.path.length,h=e._decayOpacities;if(h&&h.length===e.path.length&&!u){t.strokeStyle=i;const n=e.style.opacity??1;for(let r=0;e.path.length-1>r;r++)t.globalAlpha=.5*(h[r]+h[r+1])*n,t.beginPath(),t.moveTo(e.path[r][0],e.path[r][1]),t.lineTo(e.path[r+1][0],e.path[r+1][1]),t.stroke()}else if(u){let n=function(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),h=!0},r=function(){h&&(t.stroke(),h=!1)},o=null,s=null,c=null,u=null,h=!1;for(let h=0;e.path.length>h;h++){const[d,f]=e.path[h],y=l[h],p=sa(y,a,i);if(null!==o&&null!==u&&null!==c){if(p===u)t.lineTo(d,f);else{const e=[];for(const t of a){const n=t.value;(c>n||n>y)&&(n>c||y>n)||c===n||y===n||e.push({t:(n-c)/(y-c)})}e.sort((t,e)=>t.t-e.t);for(const l of e){const e=o+(d-o)*l.t,u=s+(f-s)*l.t,h=sa(c+(y-c)*Math.min(l.t+1e-4,1),a,i);t.lineTo(e,u),r(),n(h,e,u)}t.lineTo(d,f)}o=d,s=f,c=y,u=p}else n(p,d,f),o=d,s=f,c=y,u=p}r()}else{t.beginPath();const n=e.strokeGradient&&e.path.length>=2?$n(t,e.strokeGradient,e.path[0][0],0,e.path[e.path.length-1][0],0):null;if(t.strokeStyle=n||i,c)ia().x(t=>t[0]).y(t=>t[1]).curve(c).context(t)(e.path);else{const[n,r]=e.path[0];t.moveTo(n,r);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=In(t,e.style.fill,e.style.fill),c&&!u)ia().x(t=>t[0]).y(t=>t[1]).curve(c).context(t)(e.path);else{const[n,r]=e.path[0];t.moveTo(n,r);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],r.height),t.lineTo(n,r.height),t.closePath(),t.fill()}void 0!==n&&1>n&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ca(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ua(t,e,n=.3){ca(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 ha(t,e,n=.6){if(!ca(e))return;const r=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,o=e.cx??e.x??0,i=e.cy??e.y??0;t.beginPath(),t.arc(o,i,r,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 da(t,e,n,r=.35){ca(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",n?t.fill(n):t.fill())}import{area as fa,line as ya}from"d3-shape";function pa(t,e){const n=Rn(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 r=fa().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),r(e.topPath)}}var ga=(t,e,n,r)=>{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,r.width*o,r.height),t.clip());const i=In(t,e.style.fill,"#4e79a7"),s=e._decayOpacities;if(s&&s.length===e.topPath.length){const n=e.style.fillOpacity??.7;t.fillStyle=i;for(let r=0;e.topPath.length-1>r;r++)t.globalAlpha=.5*(s[r]+s[r+1])*n,t.beginPath(),t.moveTo(e.topPath[r][0],e.topPath[r][1]),t.lineTo(e.topPath[r+1][0],e.topPath[r+1][1]),t.lineTo(e.bottomPath[r+1][0],e.bottomPath[r+1][1]),t.lineTo(e.bottomPath[r][0],e.bottomPath[r][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Sn(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(pa(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 r=-1/0;for(const t of e.bottomPath)t[1]>r&&(r=t[1]);const o=zn(t,e.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);t.fillStyle=o||i,t.globalAlpha=a}else t.globalAlpha=(e.style.fillOpacity??.7)*a,t.fillStyle=i;if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(pa(t,e),da(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a;const n=e.strokeGradient&&e.topPath.length>=2?$n(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const r=Rn(e.curve);if(t.beginPath(),r)ya().x(t=>t[0]).y(t=>t[1]).curve(r).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}},ma=(t,e,n,r)=>{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=In(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=In(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),ha(t,n)}finally{t.restore()}}},xa=new Map;function va(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let n=xa.get(e);return n||(n=new Path2D(he(t.symbolType,t.size)),xa.size>256&&xa.clear(),xa.set(e,n)),n}catch{return null}}var ba=(t,e)=>{const n=t.globalAlpha;for(const r of e){if("symbol"!==r.type)continue;const e=r;if(0>=e.size)continue;const o=va(e);if(!o)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const i=(e.style.opacity??1)*(e._decayOpacity??1);e.style.fill&&(t.globalAlpha=n*i*(e.style.fillOpacity??1),t.fillStyle=In(t,e.style.fill,"#4e79a7"),t.fill(o)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*i,t.strokeStyle=In(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth??1,t.stroke(o)),t.restore()}t.globalAlpha=n};function ka(t,e,n,r,o){if(0>=e.size)return;const i=e.glyph;if(!i||!i.parts?.length)return;const s=un(i,e.size);if(0>=s.scale)return;const a=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=a)return;const l=e=>{const n=In(t,e,e);return"string"==typeof n?n:e},c=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(n,r),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=yn(i,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");u&&e.ghostColor&&gn(t,i,c,e.accent,e.ghostColor,l),u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),gn(t,i,c,e.accent,void 0,l),t.restore()}function wa(t,e){const{x:n,y:r,w:o,h:i}=e,{tl:s,tr:a,br:l,bl:c}=function(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,r=t=>Math.max(0,Math.min(t??0,n));return{tl:r(e.tl),tr:r(e.tr),br:r(e.br),bl:r(e.bl)}}(e);t.beginPath(),t.moveTo(n+s,r),t.lineTo(n+o-a,r),a>0&&t.arcTo(n+o,r,n+o,r+a,a),t.lineTo(n+o,r+i-l),l>0&&t.arcTo(n+o,r+i,n+o-l,r+i,l),t.lineTo(n+c,r+i),c>0&&t.arcTo(n,r+i,n,r+i-c,c),t.lineTo(n,r+s),s>0&&t.arcTo(n,r,n+s,r,s),t.closePath()}function Aa(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 Sa=(t,e,n,r)=>{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)_a(t,e);else if(e.cornerRadii&&yi(e.cornerRadii)){const n=In(t,e.style.fill,Sn(t,"var(--semiotic-primary, #007bff)")),r=Aa(e),o=e.fillGradient&&"string"==typeof n?zn(t,e.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;t.fillStyle=o||n,wa(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=In(t,e.style.fill,Sn(t,"var(--semiotic-primary, #007bff)")),r=Aa(e),o=e.fillGradient&&"string"==typeof n?zn(t,e.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;t.fillStyle=o||n;const i=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-i,a),t.arcTo(s+l,a,s+l,a+i,i),t.lineTo(s+l,a+c-i),t.arcTo(s+l,a+c,s+l-i,a+c,i),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+i,a),t.arcTo(s,a,s,a+i,i),t.lineTo(s,a+c-i),t.arcTo(s,a+c,s+i,a+c,i),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-i),t.arcTo(s+l,a+c,s+l-i,a+c,i),t.lineTo(s+i,a+c),t.arcTo(s,a+c,s,a+c-i,i);break;default:t.moveTo(s,a+c),t.lineTo(s,a+i),t.arcTo(s,a,s+i,a,i),t.lineTo(s+l-i,a),t.arcTo(s+l,a,s+l,a+i,i),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=In(t,e.style.fill,Sn(t,"var(--semiotic-primary, #007bff)")),r=Aa(e),o=e.fillGradient&&"string"==typeof n?zn(t,e.fillGradient,n,r.x0,r.y0,r.x1,r.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=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ua(t,e),t.globalAlpha=1}};function _a(t,e){const n=e.style.icon,r=e.style.iconPadding||2,o=Math.min(e.w,e.h)-r;if(0>=o)return;const i=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),i){const i=o+r,s=e.x+(e.w-o)/2;for(let r=e.y+e.h-o;r>=e.y-o;r-=i)t.drawImage(n,s,r,o,o)}else{const i=o+r,s=e.y+(e.h-o)/2;for(let r=e.x;e.x+e.w>r;r+=i)t.drawImage(n,r,s,o,o)}t.restore()}function Ma(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>128?"#000":"#fff"}function Pa(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var Ca=(t,e,n,r)=>{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=Sn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ua(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):Pa(e.value),r=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,i=e.y+e.h/2;t.fillStyle=Ma(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,i)}}}finally{t.restore()}},Ta=(t,e,n,r)=>{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 i=Sn(t,e.wickColor)||e.wickColor,s=60>r.height,a=s?Math.max(e.wickWidth,2):e.wickWidth,l=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=i,t.lineWidth=a,t.stroke()};if(s||l(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*r.height));t.fillStyle=i,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),r=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,i=Sn(t,o)||o;t.fillStyle=i,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1)),t.strokeStyle=i,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1))}s&&l(),t.restore()}},La={line:[ga,la,ma],area:[ga,ma],stackedarea:[ga,ma],scatter:[ma,ba],bubble:[ma,ba],heatmap:[Ca],bar:[Sa],swarm:[ma],waterfall:[(t,e,n,r)=>{Sa(t,e);const o=e.filter(t=>"rect"===t.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){t.save(),t.strokeStyle=Sn(t,s)||s,t.lineWidth=i?._connectorWidth??1,t.setLineDash([]);for(let e=0;o.length-1>e;e++){const r=o[e],i=o[e+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const l=n.y(s.cumEnd),c=r.x+r.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[Ta],mixed:[ga,la,ma],custom:[ga,Sa,Ca,la,ma,ba,(t,e)=>{const n=t.globalAlpha;for(const r of e)"glyph"===r.type&&ka(t,r,r.x,r.y,n);t.globalAlpha=n},Ta]};import{jsx as Na,jsxs as Da}from"react/jsx-runtime";import{jsx as Ea,jsxs as Ra}from"react/jsx-runtime";function Ia(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function za({hover:t}){const e=t.data??{},n=e.y??e.value,r=e.x??e.time;if(void 0===n&&void 0===r){const t=Ls(e);if(null!=t.title||t.entries.length>0)return Ra("div",{className:"semiotic-tooltip",style:Es,children:[null!=t.title&&Ea("div",{style:{fontWeight:600,marginBottom:t.entries.length?2:0},children:t.title+""}),t.entries.map(t=>Ra("div",{style:{opacity:.7,fontSize:11},children:[t.key,":"," ",Ea("span",{style:{fontWeight:600},children:Ia(t.value)})]},t.key))]})}return Ra("div",{className:"semiotic-tooltip",style:Es,children:[Ea("div",{style:{fontWeight:600,marginBottom:2},children:Ia(n)}),Ea("div",{style:{opacity:.7,fontSize:11},children:Ia(r)})]})}za.ownsChrome=!0;import{jsx as $a,jsxs as Wa}from"react/jsx-runtime";var Fa={top:20,right:20,bottom:30,left:40},Oa=Fi;function Ya(t){if(t)return"x"===t.dimension?"pan-y":"y"===t.dimension?"pan-x":"none"}var Ba=c(l(function(l,c){const{chartType:u,runtimeMode:h,data:d,chunkThreshold:f,chunkSize:y,xAccessor:p,yAccessor:g,accessorRevision:m,colorAccessor:x,sizeAccessor:v,symbolAccessor:b,symbolMap:k,groupAccessor:w,lineDataAccessor:S,curve:P,normalize:C,baseline:T,stackOrder:L,binSize:N,valueAccessor:D,arrowOfTime:E="right",windowMode:R="sliding",windowSize:I=200,timeAccessor:$,xExtent:W,yExtent:F,extentPadding:O=.1,scalePadding:Y,sizeRange:B,size:j=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,lineStyle:U,pointStyle:K,areaStyle:Q,barStyle:Z,waterfallStyle:J,swarmStyle:tt,barColors:et,colorScheme:nt,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,band:st,gradientFill:at,lineGradient:lt,areaGroups:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:ft,candlestickStyle:yt,showAxes:pt=!0,axes:gt,xLabel:mt,yLabel:xt,yLabelRight:vt,xFormat:bt,yFormat:kt,axisExtent:wt,tickFormatTime:At,tickFormatValue:St,hoverAnnotation:_t,tooltipContent:Mt,customHoverBehavior:Pt,customClickBehavior:Ct,enableHover:Tt,hoverRadius:Lt=30,tooltipMode:Nt,annotations:Dt,autoPlaceAnnotations:Et,svgAnnotationRules:Rt,showGrid:It,legend:zt,legendHoverBehavior:$t,legendClickBehavior:Wt,legendHighlightedCategory:Ft,legendIsolatedCategories:Ot,legendPosition:Yt,legendLayout:Bt,legendCategoryAccessor:jt,onCategoriesChange:Ht,backgroundGraphics:Xt,foregroundGraphics:Gt,canvasPreRenderers:Vt,svgPreRenderers:qt,title:Ut,categoryAccessor:Kt,brush:Zt,onBrush:Jt,decay:te,pulse:ee,transition:ne,animate:re,staleness:oe,heatmapAggregation:ie,heatmapXBins:se,heatmapYBins:ae,showValues:le,heatmapValueFormat:ce,marginalGraphics:ue,pointIdAccessor:de,xScaleType:fe,yScaleType:ye,accessibleTable:pe=!0,description:ge,summary:me,linkedCrosshairName:xe,linkedCrosshairSourceId:ve,customLayout:be,onLayoutError:ke,layoutConfig:we,layoutSelection:Ae}=l,Se=a().replace(/:/g,""),_e=e(!1),Me=e({w:-1,h:-1}),Pe=e(!1),Ce=Ks({sizeProp:j,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:Fa,animate:re,transitionProp:ne,themeDirtyRef:_e}),Te=Pi(),Le=Ni(),{reducedMotionRef:Ne,responsiveRef:De,size:Ee,currentTheme:Re,transition:Ie,introEnabled:ze,tableId:$e,rafRef:We,renderFnRef:Fe,scheduleRender:Ye,cancelRender:Be}=Ce;let je=Ce.margin;if(ue){const t=60,e={...Ce.margin};ue.top&&t>e.top&&(e.top=t),ue.bottom&&t>e.bottom&&(e.bottom=t),ue.left&&t>e.left&&(e.left=t),ue.right&&t>e.right&&(e.right=t),je=e}const Xe=Ee[0]-je.left-je.right,Ve=Ee[1]-je.top-je.bottom,qe=o(()=>_(d),[d]),Ue=_t??Tt,Ke=e(null),Ze=e(null),[Je,nn]=n(0),rn=e(0),[on,sn]=n(null),an=(t,e)=>"function"==typeof t?t({size:Ee,margin:je,scales:e}):t,ln=an(Gt,on),cn=an(Xt,on),un=e(null),hn=e(null),dn=e(void 0),[fn,yn]=n(null),gn=e(Oa.primary),mn=e(function(){let t=-1,e=Fi;return{resolve(n){if(!n)return Fi;const r=bn;return r===t||(e=function(t){if(!t)return Fi;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),i=e.getPropertyValue("--semiotic-primary").trim(),s=r||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||i?{axisStroke:l||Fi.axisStroke,tickText:s||Fi.tickText,crosshair:s?Oi(s,"66"):Fi.crosshair,hoverFill:c?Oi(c,"4D"):Fi.hoverFill,hoverStroke:s?Oi(s,"99"):Fi.hoverStroke,pointRing:c||Fi.pointRing,primary:i||Fi.primary,background:c||Fi.background}:Fi}(n),t=r),e},invalidate(){t=-1}}}()),xn=e(!1),vn=e(new He),kn=e([]),wn=e(jt),An=e(Ht);wn.current=jt,An.current=Ht;const[Sn,_n]=n(!1),[Mn,Pn]=n([]),[Cn,Tn]=n([]),Ln="streaming"===h||["bar","swarm","waterfall"].includes(u),Nn=Ri(o(()=>({chartType:u,runtimeMode:Ln?"streaming":"bounded",windowSize:I,windowMode:R,arrowOfTime:Ln?E:"right",extentPadding:O,scalePadding:Y,axisExtent:wt,xAccessor:p,yAccessor:g,accessorRevision:m,timeAccessor:Ln?$:void 0,valueAccessor:D,colorAccessor:x,sizeAccessor:v,symbolAccessor:b,symbolMap:k,groupAccessor:w||(S?"_lineGroup":void 0),categoryAccessor:Kt,lineDataAccessor:S,xScaleType:fe,yScaleType:ye,xExtent:W,yExtent:F,sizeRange:B,binSize:N,normalize:C,baseline:T,stackOrder:L,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,band:st,gradientFill:!0===at?{topOpacity:.8,bottomOpacity:.05}:!1===at?void 0:at,areaGroups:ct?new Set(ct):void 0,lineGradient:lt,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:ft,candlestickStyle:yt,lineStyle:U,pointStyle:K,areaStyle:Q,swarmStyle:tt,waterfallStyle:J,colorScheme:nt,barColors:et,barStyle:Z,annotations:Dt,decay:te,pulse:ee,transition:Ie,introAnimation:ze,staleness:oe,heatmapAggregation:ie,heatmapXBins:se,heatmapYBins:ae,showValues:le,heatmapValueFormat:ce,pointIdAccessor:de,curve:P,themeCategorical:Re?.colors?.categorical,themeSemantic:z(Re),themeSequential:Re?.colors?.sequential,themeDiverging:Re?.colors?.diverging,customLayout:be,onLayoutError:ke,layoutConfig:we,layoutMargin:je}),[u,I,R,E,O,Y,wt,p,g,m,$,D,fe,ye,x,v,b,k,w,Kt,S,W,F,B,N,C,T,L,rt,ot,it,st,at,lt,ct,ut,ht,dt,ft,yt,U,K,Q,tt,J,Z,nt,et,Dt,te,ee,Ie?.duration,Ie?.easing,ze,oe,ie,se,ae,le,ce,Ln,de,P,Re,be,ke,we,je])),Dn=e(null);Dn.current||(Dn.current=new Oe(Nn));const En=function(t,e,n,r){return Js(()=>{const o=e.current,i=n.current;if(!i||!o)return;const s=function(t,e){if(!e)return[];const n=new Set,r=[];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 i=t+"";n.has(i)||(n.add(i),r.push(i))}return r}(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,r.current)||(r.current=s,i(s))},[e,n,r,t])}(Dn,wn,An,kn);tn(Dn,Nn,_e,Ye),en(Dn,Ae,_e,Ye);const Rn=e(null);Rn.current||(Rn.current=new M(t=>{const e=Dn.current;e&&e.ingest(t)&&(_e.current=!0,Ye())},{chunkThreshold:f,chunkSize:y})),r(()=>{Rn.current?.updateChunkOptions({chunkThreshold:f,chunkSize:y})},[f,y]);const In=i(t=>{Rn.current?.push(t)},[]),zn=i(t=>{Rn.current?.pushMany(t)},[]),$n=i(()=>{Rn.current?.clear(),Dn.current?.clear(),_e.current=!0,Ye()},[Ye]);s(c,()=>({push:In,pushMany:zn,remove:t=>{Rn.current?.flush();const e=Dn.current?.remove(t)??[];return e.length>0&&(un.current&&e.some(t=>t===un.current?.data)&&(un.current=null,yn(null)),_e.current=!0,Ye()),e},update:(t,e)=>{Rn.current?.flush();const n=Dn.current?.update(t,e)??[];return n.length>0&&(_e.current=!0,Ye()),n},clear:$n,getData:()=>(Rn.current?.flush(),Dn.current?.getData()??[]),getScales:()=>Dn.current?.scales??null,getExtents:()=>Dn.current?.getExtents()??null,getCustomLayout:()=>Dn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Dn.current?.lastCustomLayoutFailure??null}),[In,zn,$n,Ye]),r(()=>{if(d){if(S&&qe.length>0&&"object"==typeof qe[0]&&null!==qe[0]){const t="string"==typeof S?S:"coordinates";if(Array.isArray(qe[0][t])){const e=[];for(const n of qe){const r=n[t];if(Array.isArray(r)){const t=n.label||n.id||n.key;if(null!=t)for(const n of r)e.push({...n,_lineGroup:t});else for(const t of r)e.push(t)}}return void Rn.current?.setBoundedData(e)}}Rn.current?.setBoundedData(qe)}},[d,qe,S]);const{hoverHandlerRef:Wn,hoverLeaveRef:Fn,onPointerMove:jn,onPointerLeave:Hn}=Ce;Wn.current=t=>{if(!Ue)return;const e=Ke.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-je.left,o=t.clientY-n.top-je.top;if(0>r||r>Xe||0>o||o>Ve)return void(un.current&&(un.current=null,hn.current=null,yn(null),Pt&&(Pt(null),_e.current=!0),Ye()));const i=Dn.current;if(!i||0===i.scene.length)return;const s=ws(Lt,t.pointerType),a=Yn(i.scene,r,o,s,i.quadtree,i.maxPointRadius),l="multi"===Nt,c=()=>{un.current&&(un.current=null,hn.current=null,yn(null),Pt&&Pt(null),Ye())};if(!a&&!l)return void c();const h=l||!a?r:a.x,d=l||!a?o:a.y,f=a?.datum?Qt(a.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=Ss(f,h,d,null!=g?{xValue:g,xPx:h}:void 0);if(l&&i.scene.length>0&&i.scales){const t=function(t,e,n=30){const r=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const i=Bn(On(t.path,t.curve),e,n);if(null===i)continue;const s=Zn(t.path,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:i,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 i=On(t.topPath,t.curve),s=On(t.bottomPath,t.curve),a=Bn(i,e,n);if(null===a)continue;const l=Bn(s,e,n),c=Zn(t.topPath,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0: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 r}(i.scene,h,Math.max(s,Xe));if(t.length>0){const e=i.scales.y.invert,n=gn.current,r=y?y(h):h;if(a)m.xValue=r,m.xPx=h;else{const t={xValue:r};"string"==typeof p&&(t[p]=r),m=Ss(t,h,d,{xValue:r,xPx:h})}m.allSeries=t.map(t=>{const r=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===u&&null!=o?r-o:r,valuePx:t.y,color:t.color||n,datum:Qt(t.datum,i.resolvedRibbons)}})}}a||m.allSeries?.length?(un.current=m,hn.current=a?.node??null,yn(m),Pt&&(Pt(m),_e.current=!0),Ye()):c()},Fn.current=()=>{un.current&&(un.current=null,hn.current=null,yn(null),Pt&&(Pt(null),_e.current=!0),Ye())};const Xn=e(()=>{});Xn.current=t=>{if(!Ct)return;const e=Ke.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-je.left,o=t.clientY-n.top-je.top;if(0>r||r>Xe||0>o||o>Ve)return void Ct(null);const i=Dn.current;if(!i||0===i.scene.length)return void Ct(null);const s=ws(Lt,dn.current),a=Yn(i.scene,r,o,s,i.quadtree,i.maxPointRadius);if(!a)return void Ct(null);const l=a.datum||{},c=i.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;Ct(Ss(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const Gn=i(t=>Xn.current(t),[]),Vn=e(-1),qn=e(null),Un=e(null),Kn=i(t=>{const e=Dn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(Un.current&&Un.current.version===n)r=Un.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=pn(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,r=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.path.length>n&&r.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const t=n,r=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.topPath.length>n&&r.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:r[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;r=Jn(t),Un.current={version:n,graph:r}}const o=Vn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Vn.current=0;const n=r.flat[0];qn.current={shape:n.shape,w:n.w,h:n.h};const o=or({...n,datum:Qt(n.datum,e.resolvedRibbons)});return un.current=o,yn(o),Pt&&Pt(o),void Ye()}const i=tr(r,o),s=er(t.key,i,r);if(null===s)return;if(t.preventDefault(),0>s)return Vn.current=-1,qn.current=null,un.current=null,hn.current=null,yn(null),Pt&&Pt(null),void Ye();Vn.current=s;const a=r.flat[s];qn.current={shape:a.shape,w:a.w,h:a.h};const l=or({...a,datum:Qt(a.datum,e.resolvedRibbons)});un.current=l,yn(l),Pt&&Pt(l),Ye()},[Pt,Ye]),Qn=i(t=>{dn.current=t.pointerType,Vn.current=-1,qn.current=null,jn(t)},[jn]),nr=i(t=>{dn.current="mouse",Vn.current=-1,qn.current=null,jn({clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"})},[jn]),rr=i(t=>{dn.current=t.pointerType},[]);Fe.current=()=>{We.current=null;const t=Ke.current,e=Ze.current;if(!t||!e)return;const n=Dn.current;if(!n)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=n.advanceTransition(Ne.current?r+1e6:r),i=!Ne.current&&o,s=Me.current.w!==Xe||Me.current.h!==Ve,a=_e.current||o||s,l=n.consumeStylePaintPending();let c=!1;const h=n.getLastUpdateResult(),d=vn.current.beforeCompute(h,i);!a||i&&!s||(n.computeScene({width:Xe,height:Ve}),Me.current={w:Xe,h:Ve},c=!0,En()),vn.current.afterCompute(d,c,s);const f=function(t,e,n,r){const o=r.current,i=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&t.hasActivePulsesAt(e),a=!(n||i||!s&&!o)&&t.refreshPulse(e);return r.current=s,{changed:a,pending:s}}(n,r,c,Pe),y=Zs(),m=mn.current.resolve(t);gn.current=m.primary;const x=cr(oe,n.lastIngestTime>0?r-n.lastIngestTime:0),v=oe&&x.isStale;if(a||l||f.changed){const e=Qs(t,Ee,je,y);if(e){if(e.clearRect(-je.left,-je.top,Ee[0],Ee[1]),oe&&1>x.alpha&&(e.globalAlpha=x.alpha),Wi(e,{background:q,hasBackgroundGraphics:!!Xt,themeBackground:m.background,x:-je.left,y:-je.top,width:Ee[0],height:Ee[1]}),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Xe,Ve),e.clip()),Vt&&n.scales)for(const t of Vt)e.save(),t(e,n.scene,n.scales,{width:Xe,height:Ve}),e.restore();const t=be?La.custom:La[u];if(t&&n.scales)for(const r of t)r(e,n.scene,n.scales,{width:Xe,height:Ve});e.restore(),oe&&1>x.alpha&&(e.globalAlpha=1)}}const b=!!(Ue&&un.current&&n.scales),k=!!(hn.current&&Array.isArray(_t)&&_t.some(t=>t&&"object"==typeof t&&"highlight"===t.type)),w=b||k;if(w||xn.current){const t=Qs(e,Ee,je,y);if(t&&(t.clearRect(-je.left,-je.top,Ee[0],Ee[1]),b&&un.current&&function(t,e,n,r,o,i,s){if(!1===o.crosshair)return;const a=e.allSeries,l=a&&a.length>0,c=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(l?c:e.x,0),t.lineTo(l?c:e.x,r),t.stroke(),l||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),l){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(c,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}(i)||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,un.current,Xe,Ve,"object"==typeof Ue?Ue:{},hn.current,m),k&&hn.current&&Array.isArray(_t))){const e=_t.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,r,o){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of e){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.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,n.scene,hn.current,e,m)}xn.current=w}a&&t&&t.setAttribute("aria-label",Zi(n.scene,u+" chart"));const A=_e.current;if(_e.current=A&&i&&!c,A&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!on||t(on.x.domain()[0])!==t(n.scales.x.domain()[0])||t(on.x.domain()[1])!==t(n.scales.x.domain()[1])||t(on.y.domain()[0])!==t(n.scales.y.domain()[0])||t(on.y.domain()[1])!==t(n.scales.y.domain()[1])||on.x.range()[0]!==n.scales.x.range()[0]||on.x.range()[1]!==n.scales.x.range()[1]||on.y.range()[0]!==n.scales.y.range()[0]||on.y.range()[1]!==n.scales.y.range()[1])&&sn(n.scales),ue){const t=n.getData(),e="function"==typeof p?p:t=>t[p||"x"],r="function"==typeof g?g:t=>t[g||"y"];Pn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Tn(t.map(t=>r(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Dt&&Dt.length>0||be)&&(c||i))||!c&&33>r-rn.current||(nn(t=>t+1),rn.current=r),oe?.showBadge&&_n(!!v),(i||null!=n.activeTransition||f.pending)&&Ye()},Di({hydrated:Te,wasHydratingFromSSR:Le,storeRef:Dn,dirtyRef:_e,renderFnRef:Fe,cancelRender:Be,cleanup:()=>Rn.current?.clear()}),r(()=>{_e.current=!0,Ye()},[u,Xe,Ve,pt,q,Xt,U,Vt,Ye]),ur(oe,Dn,_e,Ye,Sn,_n);const ir=o(()=>{if(bt||At)return;const t=Dn.current;return t?.xIsDate&&on?ra(on.x.domain()):void 0},[bt,At,on]),sr=bt||At||ir,ar=Ue&&fn?Mt?Mt(fn):$a(za,{hover:fn}):null,lr=ar?$a(Is,{x:fn.x,y:fn.y,containerWidth:Xe,containerHeight:Ve,margin:je,className:"stream-frame-tooltip",children:ar}):null,hr=qn.current,fr=$a(bs,{active:Vn.current>=0,hoverPoint:fn,margin:je,size:Ee,shape:hr?.shape,width:hr?.w,height:hr?.h}),yr=ta(p,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),pr=ta(g,D,"__semiotic_resolvedY","__semiotic_resolvedValue"),gr=yr.key,mr=pr.key,xr=function(t,e,n){return r=>{if(!r||!n||!t.fn&&!e.fn)return r;let o=!1;const i=r.map(n=>{const r=t.fn&&t.key&&!(t.key in n),i=e.fn&&e.key&&!(e.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[t.key]=t.fn(n)),i&&(s[e.key]=e.fn(n)),s});return o?i:r}}(yr,pr,Dt&&Dt.length>0||!1);if(bi||!Te&&Le){const e=Dn.current;e&&d&&(e.ingest({inserts:qe,bounded:!0}),e.computeScene({width:Xe,height:Ve}));const n=e?.scene??[],r=e?.scales??null,o=an(Gt,r),i=an(Xt,r),s=sr||(()=>{if(e?.xIsDate&&r)return ra(r.x.domain())})();return Wa("div",{ref:De,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":ge||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:H?"100%":Ee[0],height:X?"100%":Ee[1]},children:[$a(ps,{summary:me}),Wa("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[$a("g",{transform:`translate(${je.left},${je.top})`,children:i}),Wa("g",{transform:`translate(${je.left},${je.top})`,children:[q&&$a("rect",{x:0,y:0,width:Xe,height:Ve,fill:q}),qt&&r&&qt.map((e,o)=>$a(t.Fragment,{children:e(n,r,{width:Xe,height:Ve})},"svgpre-"+o)),n.map((t,e)=>function(t,e,n){switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const r="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return pi("path",{d:r,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 r=t;if(0===r.topPath.length)return null;const o=`M${r.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(r.clipRect){const t=`${n?n+"-":""}area-clip-${e}`;return gi("g",{children:[pi("defs",{children:pi("clipPath",{id:t,children:pi("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})}),pi("path",{d:o,fill:xi(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+e)}return pi("path",{d:o,fill:xi(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+e)}case"point":{const n=t;return pi("circle",{cx:n.x,cy:n.y,r:n.r,fill:xi(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+e)}case"symbol":return function(t,e){const n=he(t.symbolType,t.size,t.path);return pi("path",{d:n,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?xi(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},"symbol-"+e)}(t,e);case"glyph":return vi(t,t.x,t.y,`${n??""}glyph-${t.pointId??e}`);case"rect":{const n=t;return pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:xi(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),[r,o,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]}(n.fill),s=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return gi("g",{children:[pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),pi("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 pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+e)}case"candlestick":{const n=t,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return gi("g",{children:[pi("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),pi("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+e)}default:return null}}(t,e,Se)).filter(Boolean)]})]}),$a(hi,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,scales:r,showAxes:pt,axes:gt,xLabel:mt,yLabel:xt,yLabelRight:vt,xFormat:s,yFormat:kt||St,axisExtent:wt,showGrid:It,title:Ut,legend:zt,legendHoverBehavior:$t,legendClickBehavior:Wt,legendHighlightedCategory:Ft,legendIsolatedCategories:Ot,legendPosition:Yt,legendLayout:Bt,foregroundGraphics:Ge(o,Qe(Dn.current?.customLayoutOverlays,Ae??null)),marginalGraphics:ue,xValues:[],yValues:[],annotations:Dt,autoPlaceAnnotations:Et,svgAnnotationRules:Rt,annotationFrame:0,xAccessor:gr,yAccessor:mr,annotationData:xr(e?.getData()),pointNodes:oa(e?.scene),curve:"string"==typeof P?P:void 0,linkedCrosshairName:xe,linkedCrosshairSourceId:ve})]})}return Wa("div",{ref:De,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":ge||("string"==typeof Ut?Ut:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Ee[0],height:X?"100%":Ee[1],overflow:"visible",touchAction:Ya(Zt)},onKeyDown:Kn,children:[pe&&$a(gs,{tableId:$e}),pe&&$a(fs,{scene:Dn.current?.scene??[],chartType:u+" chart",tableId:$e,chartTitle:"string"==typeof Ut?Ut:void 0}),$a(ps,{summary:me}),$a(ms,{hoverPoint:fn}),Wa("div",{role:"img","aria-label":ge||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Ue?Qn:void 0,onMouseMove:Ue?nr:void 0,onPointerLeave:Ue?Hn:void 0,onMouseLeave:Ue?Hn:void 0,onPointerDown:Ue||Ct?rr:void 0,onClick:Ct?Gn:void 0,children:[cn&&$a("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:$a("g",{transform:`translate(${je.left},${je.top})`,children:cn})}),$a(li,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,scales:on,showAxes:pt,axes:gt,showGrid:It,xFormat:sr,yFormat:kt||St,axisExtent:wt}),$a("canvas",{ref:Ke,"aria-label":Zi(Dn.current?.scene??[],u+" chart"),style:{position:"absolute",left:0,top:0}}),$a("canvas",{ref:Ze,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),$a(hi,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,scales:on,showAxes:pt,axes:gt,xLabel:mt,yLabel:xt,yLabelRight:vt,xFormat:sr,yFormat:kt||St,axisExtent:wt,showGrid:It,title:Ut,legend:zt,legendHoverBehavior:$t,legendClickBehavior:Wt,legendHighlightedCategory:Ft,legendIsolatedCategories:Ot,legendPosition:Yt,legendLayout:Bt,foregroundGraphics:Ge(ln,Qe(Dn.current?.customLayoutOverlays,Ae??null)),marginalGraphics:ue,xValues:Mn,yValues:Cn,annotations:Dt,autoPlaceAnnotations:Et,svgAnnotationRules:Rt,annotationFrame:Je,xAccessor:gr,yAccessor:mr,annotationData:xr(Dn.current?.getData()),pointNodes:oa(Dn.current?.scene),curve:"string"==typeof P?P:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==q&&!Xt,linkedCrosshairName:xe,linkedCrosshairSourceId:ve}),(Zt||Jt)&&$a(A,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,dimension:Zt?.dimension??"xy",scales:on,onBrush:Jt??(()=>{}),binSize:N,snap:Zt?.snap,binBoundaries:Zt?.binBoundaries??("bar"===u?Dn.current?.getBinBoundaries():void 0),snapDuring:Zt?.snapDuring,streaming:"streaming"===h}),oe?.showBadge&&$a(dr,{isStale:Sn,position:oe.badgePosition}),fr,lr]})]})}));Ba.displayName="StreamXYFrame";var ja=Ba;import{useRef as Ha,useState as Xa,useEffect as Ga,useMemo as Va,useCallback as qa,useImperativeHandle as Ua,forwardRef as Ka,memo as Qa}from"react";var Za={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ja={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},tl=class{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=t*e*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?el(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}};function el(t,e,n,r){if(t.circular&&t.segments)return void function(t,e,n,r,o){const i=t.length,s=e*i,a=Math.min(Math.floor(s),i-1),l=s-a,[c,u,h,d]=t[a];nl(c,u,h,d,l,o);const f=d.x-c.x,y=d.y-c.y,p=Math.sqrt(f*f+y*y);if(p>.001){const t=f/p;o.x+=-y/p*n*r*2,o.y+=t*n*r*2}}(t.segments,e,n,t.halfWidth,r);if(!t.points)return r.x=0,void(r.y=0);const[o,i,s,a]=t.points;nl(o,i,s,a,e,r);const l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const e=l/u;r.x+=-c/u*n*t.halfWidth*2,r.y+=e*n*t.halfWidth*2}}function nl(t,e,n,r,o,i){const s=1-o,a=s*s,l=a*s,c=o*o,u=c*o;i.x=l*t.x+3*a*o*e.x+3*s*c*n.x+u*r.x,i.y=l*t.y+3*a*o*e.y+3*s*c*n.y+u*r.y}function rl(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function ol(t,e){var n,r=[],o=[],i=[],s={},a=[];function l(t){i[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],i[e]&&l(e)})}function c(t){var e,r,h=!1;for(o.push(t),i[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,o),h=!0):i[r]||(h=c(r));if(h)l(t);else for(e=0;a[t].length>e;e++){var d=s[r=a[t][e]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(t,n){var o=[].concat(n).concat(t);e?e(o):r.push(o)}function h(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,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),o=Array(e),i=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,s[l]=-1,a[l]=[];var c,u=0,h=[],d=[];function f(e){var l=[e],c=[e];for(n[e]=r[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>i[e]){for(var y=i[e];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(r[e]=0|Math.min(r[e],r[p])),0>s[p]||a[e].push(s[p])}i[e]=y}else{if(r[e]===n[e]){var g=[],m=[],x=0;for(y=l.length-1;y>=0;--y){var v=l[y];if(o[v]=!1,g.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){l.length=y;break}}h.push(g);var b=Array(x);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--x]=m[y][k];d.push(b)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;d.length>l;l++){var y=d[l];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&c.push(y[p]);d[l]=c}}return{components:h,adjacencyList:d}}(t),o=r.components.filter(function(t){return t.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var l=o[n];return!!l&&{leastVertex:i,adjList:t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})})}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];i[+g]=!1,s[g]={}}c(n),n+=1}else n=d}return e?void 0:r}function il(t){return t.y0-t.y1>0?"up":"down"}function sl(t,e){return e(t.source)==e(t.target)}function al(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 ll(t){return t.target.x0-t.source.x1}function cl(t,e){var n=hl(t),r=ll(e)/Math.tan(n);return"up"==il(t)?t.y1-r:t.y1+r}function ul(t,e){var n=hl(t),r=ll(e)/Math.tan(n);return"up"==il(t)?t.y1+r:t.y1-r}function hl(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function dl(t,e){return e(t)}function fl(t){return pl(t.source)}function yl(t){return pl(t.target)}function pl(t){return(t.y0+t.y1)/2}function gl(t){return t.virtual?0:t.value}function ml(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!sl(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!sl(t,e)?r+1:r}),n+r}function xl(t){return t.target.depth}function vl(t,e){return t.sourceLinks.length?t.depth:e-1}function bl(t,e){return t.y0-e.y0}function kl(t,e){return e.y0-t.y0}function wl(t,e){return t.y1-e.y1}function Al(t,e){return e.y1-t.y1}function Sl(t,e){return Ml(t.source,e.source)||t.index-e.index}function _l(t,e){return Ml(t.target,e.target)||t.index-e.index}function Ml(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Pl(t,e){return Cl(t)==Cl(e)?"bottom"==t.circularLinkType?kl(t,e):bl(t,e):Cl(e)-Cl(t)}function Cl(t){return t.target.column-t.source.column}function Tl(t,e){return Ll(t)==Ll(e)}function Ll(t){return t.y0-t.y1>0?"up":"down"}import{min as Nl}from"d3-array";function Dl(t,e,n,r,o){let i=t;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=Nl(i.links,function(t){return t.source.y0});i.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=i.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}),El(i.links.filter(function(t){return"top"==t.circularLinkType}),e,n),El(i.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),i.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,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,sl(t,e)&&al(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+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=i.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?kl:bl);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=i.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Al:wl),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(i.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,r=t.target.x0,o=t.y1,i=(e+r)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(t)}),i}function El(t,e,n){t.sort(Pl);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var i=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(sl(t,e)&&al(t))t.circularPathData.verticalBuffer=i+t._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Rl(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=l>i?l:i}}t.circularPathData.verticalBuffer=i+t._circularWidth/2}}),t}function Rl(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as Il,max as zl,sum as $l,mean as Wl,group as Fl,groups as Ol}from"d3-array";function Yl(t){return function(){return t}}function Bl(t){return t.index}function jl(t){return t.nodes}function Hl(t){return t.links}function Xl(t,e,n){var r=Ol(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,i){var s=o.length;if(e)o.sort(e);else if(i>0){var a=new Map;o.forEach(function(t,e){var n,r,o,i=(r=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=pl(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=pl(t.target)*e,r+=e}}),r>0?o/r:NaN);a.set(t,{bc:i,idx:e})}),o.sort(function(t,e){var n=a.get(t),r=a.get(e),o=n.bc,i=r.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(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?ml(e,n)-ml(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==r.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==ml(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 Gl(t,e,n,r,o,i){var s=Ol(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=i;l>0;--l)c(a*=.99,n),u();function c(e,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&ml(o,n)>0){var l=Wl(o.sourceLinks,yl),c=Wl(o.targetLinks,fl),u=l&&c?(l+c)/2:l||c;if(u){var h=(u-pl(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==r-1&&1==i)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 d=Wl(o.sourceLinks,yl),f=Wl(o.targetLinks,fl),y=((d&&f?(d+f)/2:d||f)-pl(o))*e;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var i,s,a,l=t.y0,c=n.length;for(n.sort(e||Ml),a=0;c>a;++a)(s=l-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),l=i.y1+r;if((s=l-r-t.y1)>0)for(l=i.y0-=s,i.y1-=s,a=c-2;a>=0;--a)(s=(i=n[a]).y1+o-l)>0&&(i.y0-=s,i.y1-=s),l=i.y0})}}function Vl(t){t.nodes.forEach(function(t){t.sourceLinks.sort(_l),t.targetLinks.sort(Sl)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=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 ql(){var t=0,e=0,n=1,r=1,o=24,i=8,s=null,a=Bl,l=vl,c=void 0,u=32,h=2,d=jl,f=Hl;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=n,d.y1=r,d.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 Fl(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 r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=rl(n,r)),"object"!=typeof o&&(o=t.target=rl(n,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(d,a),function(t,e){var n=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var i=t.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var l=ol(r);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,r=t.source.index;e===r||c[r]&&c[r][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++)})}(d,c),function(t,e){var n=0,r=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:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,t.nodes.forEach(function(t){dl(t,e)!=dl(o.source,e)&&dl(t,e)!=dl(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),sl(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max($l(t.sourceLinks,gl),$l(t.targetLinks,gl)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,n){var r,o,i;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(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.depth=i,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.height=i,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,i):t.column})}(d,c,l);var f=i;if(null!==s){var y=Ol(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=zl(y,function(t){return t.length});p>1&&(f=Math.max(1,(r-e)*s/(p-1)))}(function(t,e,n){var r=Ol(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=Il(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/$l(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var i=zl(t.nodes,function(t){return t.column});t.nodes.forEach(i>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/i),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,o),Xl(d,c,a),Gl(d,c,a,f,f,u),Vl(d),Dl(d,a,h,10,8),Xl(d,c,a),Gl(d,c,a,f,f,u),Vl(d),Dl(d,a,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return dl(n.source,e)==dl(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Tl(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=cl(e,t);return t.y1-n}if(e.target.column>t.target.column)return cl(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 i=t.y0;r.forEach(function(t){t.y0=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return dl(n.target,e)==dl(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Tl(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=ul(e,t);return t.y0-n}if(e.source.column>t.source.column)return ul(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 i=t.y0;r.forEach(function(t){t.y1=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(e){return(e-i)/(s-i)*(t.y1-t.y0)+t.y0};var i=Il(e,function(t){return t.y0}),s=zl(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-i);1>a?(e.forEach(function(t){t.y0=r(t.y0),t.y1=r(t.y1)}),n.forEach(function(t){t.y0=r(t.y0),t.y1=r(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=r(t.y0)-t.y0;t.y0=r(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})})}}(d),Dl(d,a,h,10,8)}(y),y}return y.update=function(t){return Vl(t),Dl(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(i=+t,y):i},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:Yl(t),y):d},y.links=function(t){return arguments.length?(f="function"==typeof t?t:Yl(t),y):f},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Yl(t),y):a},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:Yl(t),y):l},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[t,e],[n,r]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],r=+o[1],y):[n-t,r-e]},y}import{interpolateNumber as Ul}from"d3-interpolate";import{line as Kl,curveLinearClosed as Ql}from"d3-shape";var Zl=t=>{let e,n,r,o,i,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,i=t.source.x1,s=t.target.x0,a=Ul(i,s),l=a(.5),c=a(.5),`M${e},${i}C${e},${l} ${n},${c} ${n},${s}L${r},${s}C${r},${c} ${o},${l} ${o},${i}Z`;const u=t.sankeyWidth/2,h=Ul(t.source.x1,t.target.x0),{pathD:d}=function(t){const{sx:e,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:l}=t,c=(n+r)/2,u=(i+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${i} ${o},${i}`,`L${o},${s}`,`C${l},${s} ${a},${r} ${e},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function Jl(t){const e=t.sankeyWidth/2,n=(t._circularWidth??t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.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*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-e}L${n+a},${o-e}L${n+a},${o+e}L${n},${o+e}ZM${i},${s-e}L${i-l},${s-e}L${i-l},${s+e}L${i},${s+e}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*e}L${l},${i-h*e}L${l+n},${i-h*e+h*d}L${l+n},${u+h*n-h*d}L${l+n-d},${u+h*n}L${c-n+d},${u+h*n}L${c-n},${u+h*n-h*d}L${c-n},${a-h*e+h*d}L${c-n+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${c+n},${a+h*e}L${c+n},${u-h*n}L${l-n},${u-h*n}L${l-n},${i+h*e}L${o},${i+h*e}Z`}var tc=new Set,ec=new WeakMap;function nc(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=ec.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,ec.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;tc.has(t)||(tc.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,r)}});return n.set(e,r),r}var rc={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(xl))-1:0},justify:vl};function oc(t){return"string"==typeof t?t:t.id}var ic={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=ql().extent(h).links(u).nodes(c).nodeAlign(rc[i]||vl).nodeId(t=>t.id).nodeWidth(s).iterations(l);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const r of c)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;t>i.leftFullExtent-s&&(t=i.leftFullExtent-s),i.rightFullExtent+s>e&&(e=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=e-t,s=o-n,a=r[0],l=r[1];if(i>0&&s>0&&(0>t||0>n||e>a||o>l)){const e=Math.min(a/i,l/s),r=-t*e+(a-i*e)/2,o=-n*e+(l-s*e)/2;for(const t of c)t.x0=t.x0*e+r,t.x1=t.x1*e+r,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+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,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 c){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 y=new Map;for(const t of e)y.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=oc(t.source),n=oc(t.target),r=y.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(r){r.y0=t.y0,r.y1=t.y1,r.sankeyWidth=t.width??0,r.circular=!!t.circular,r.circularPathData=t.circularPathData,r._circularWidth=t._circularWidth,r._circularStub=t._circularStub,r.path=t.path,r.circularLinkType=t.circularLinkType,r.direction=o;const i=f.get(e),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(t,e,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:it,u=new Map;t.forEach((t,e)=>{u.set(t.id,c[e%c.length])});const h=[],d=[],f=[],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 r=i?i(nc(e,"nodeStyle")):{},s={fill:r.fill||u.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(e.id,("string"==typeof s.fill?s.fill:null)||u.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 p=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of p){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(t)||o:"target"===l?y.get(r.id)||u.get(r.id)||o:y.get(e.id)||u.get(e.id)||o;const i=s?s(nc(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=i.fill||o;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+r},${e.sourceY-n}L${e.sourceX+r},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+r}}),d.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:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let c;(c=t.circular&&t.circularPathData?Jl(t):Zl(t),c)&&d.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:t})}if(!1!==n.showLabels){const e=(g=n.nodeLabel)?"function"==typeof g?g:t=>t[g]||t.id:null;for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const s=e?e(n):n.id;if(!s)continue;let a,l,c;"down"===o?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+t/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:a,y:l,text:s+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}};import{forceSimulation as sc,forceCenter as ac,forceX as lc,forceY as cc,forceLink as uc,forceManyBody as hc,forceCollide as dc}from"d3-force";import{scaleLinear as fc}from"d3-scale";var yc={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=n.__previousPositions;let l=0;const c=[];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?l++:n?(e.x=n.x,e.y=n.y,l++):c.push(e)}const u=l>0&&.3>=(t.length>0?c.length/t.length:1);if(u){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of c){const r=pc(t.id,e,n);if(r.length>0){let e=0,n=0;for(const t of r)e+=t.x,n+=t.y;const o=gc(t.id),i=o%360*(Math.PI/180),s=10+o%20;t.x=e/r.length+s*Math.cos(i),t.y=n/r.length+s*Math.sin(i)}else{const e=gc(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=i+r*Math.cos(n),t.y=s+r*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const r=t[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(n+.5),o=n*e;r.x=i+t*Math.cos(o),r.y=s+t*Math.sin(o)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),d=mc(n.nodeSize,n.nodeSizeRange,t),f=t=>d(t);if(h>0){const n=new Map,r=new Map;for(const e of t)n.set(e.id,0),r.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,r="string"==typeof t.target?t.target:t.target.id;n.set(e,(n.get(e)??0)+1),n.set(r,(n.get(r)??0)+1)}const a=uc().strength(t=>{const e=t.weight,r="string"==typeof t.target?t.target:t.target.id,i=Math.max(1,Math.min(n.get("string"==typeof t.source?t.source:t.source.id)??1,n.get(r)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*o/(.1*i))}).distance(t=>{const e="string"==typeof t.source?r.get(t.source):t.source,n="string"==typeof t.target?r.get(t.target):t.target,o=(e?f(e):0)+(n?f(n):0)+12;return Math.max(40,o)}).id(t=>t.id),l=sc().force("charge",hc().strength(t=>{const e=n.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",dc(t=>f(t)+3).strength(.9).iterations(2)).force("center",ac(i,s).strength(.8)).force("x",lc(i).strength(.06)).force("y",cc(s).strength(.06));if(l.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));a.links(t),l.force("link",a)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let t=0;h>t;++t)l.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=y.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=y.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=mc(n.nodeSize,n.nodeSizeRange,t),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:it,l=new Map;t.forEach((t,e)=>{l.set(t.id,a[e%a.length])});const c=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(nc(e,"nodeSize")),r=o?o(nc(e,"nodeStyle")):{},i={fill:r.fill||l.get(e.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:d.get(t.source),r="object"==typeof t.target?t.target:d.get(t.target);if(!e||!r)continue;if(null==e.x||null==e.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(nc(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.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=(f=n.nodeLabel)?"function"==typeof f?f:t=>t[f]||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 r=s(nc(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:h}}};function pc(t,e,n){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=i:i===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function gc(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 mc(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 r=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()=>r[0];const[i,s]=Nr(o);if(i===s)return()=>(r[0]+r[1])/2;const a=fc().domain([i,s]).range(r).clamp(!0);return e=>{const n=e.data?.[t];return null==n||"number"!=typeof n?r[0]:a(n)}}import{chord as xc,ribbon as vc}from"d3-chord";import{arc as bc}from"d3-shape";var kc=it,wc={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,l=a-i,c=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,p=Array.from({length:y},()=>Array.from({length:y},()=>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),r=f.get(e);if(void 0===n||void 0===r)continue;const o=h(t);p[n][r]=o}const g=xc().padAngle(o);s&&g.sortGroups(s);const m=g(p),x=m.groups,v=bc().innerRadius(l).outerRadius(a);for(const e of x){const n=t[e.index],r=v.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);n&&(t.source=n),r&&(t.target=r)}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,r=t[e.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:kc,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const p=vc().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.__arcData;if(!r)continue;let o;o=u?u(nc(n,"nodeStyle")).fill||y.get(n.id)||f[e%f.length]:y.get(n.id)||f[e%f.length];const i=u?u(nc(n,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const r=p(e);if(!r)continue;const o=Ac(r,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(nc(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===d&&n?s=y.get(n.id)||s:e&&(s=y.get(e.id)||s)}const a=h?h(nc(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==n.showLabels){const e=(v=n.nodeLabel)?"function"==typeof v?v:t=>t[v]||t.id:null,r=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 i=(t.startAngle+t.endAngle)/2,s=i-Math.PI/2;x.push({x:l+Math.cos(s)*r,y:c+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Ac(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let i=0;for(;r.length>i;){const t=r[i];if("M"===t||"L"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;3>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;2>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+e+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===t||"z"===t?(o.push(t),i++):(o.push(r[i]),i++)}return o.join(" ")}import{hierarchy as Sc,tree as _c,cluster as Mc,treemap as Pc,pack as Cc,partition as Tc,treemapBinary as Lc}from"d3-hierarchy";var Nc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Dc(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>150?"#222":"#fff"}function Ec(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Rc(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 Ic(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Nc}function zc(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 $c(t,e,n,r,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${n},${r}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${n},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${r}`}}var Wc={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,c=Sc(o,s);c.sum(l),c.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=r;switch(i){case"tree":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=_c();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,h);break;case"cluster":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=Mc();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,h);break;case"treemap":!function(t,e,n,r){const o=e.padding??4,i=e.paddingTop??0,s=Pc().size([n,r]).tile(Lc).padding(o);i>0&&s.paddingTop(i),s(t)}(c,n,u,h);break;case"circlepack":!function(t,e,n,r){const o=e.padding??4;Cc().size([n,r]).padding(o)(t)}(c,n,u,h);break;case"partition":!function(t,e,n,r){Tc().size([n,r]).padding(e.padding??1)(t)}(c,n,u,h)}const d=c.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const r=d[e],o={id:Ec(r,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Fc(o,r,n):"treemap"===i||"partition"===i?Oc(o,r):"circlepack"===i&&Yc(o,r),o.__hierarchyNode=r,t.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const t of d)if(t.parent){const n=f.get(t.parent),r=f.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,o,i){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const e of t){let t=e.x,r=e.y;u&&(t+=h,r+=d);const i=o(nc(e,"nodeStyle"));let a=i.fill||zc(n);if(n.colorByDepth&&void 0!==e.depth){const t=Ic(n);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const p=n.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let o=e.x,s=e.y,l=r.x,f=r.y;u&&(o+=h,s+=d,l+=h,f+=d);const y=$c(o,s,l,f,c),g=i(nc(t,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:t})}if(!1!==n.showLabels){const e=Rc(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,n=Math.sqrt(t*t+e*e);n>0?(r=s+t/n*10,o=a+e/n*10,i=0>t?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");l.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(t,e,n,r,o,i);case"treemap":case"partition":return function(t,e,n,r){const o=[],i=[];for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const s=r(nc(n,"nodeStyle"));let a=s.fill||zc(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ic(e);a=t[n.depth%t.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:t,h:i,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=Rc(e.nodeLabel),o=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,l=a.y1-a.y0;if(0>=t||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>t||(c?16:14)>l)continue;let h=r(nc(a,"nodeStyle")).fill||zc(e);if(e.colorByDepth&&void 0!==a.depth){const t=Ic(e);h=t[a.depth%t.length]}const d="string"==typeof h?Dc(h):e.themeSemantic?.text??"#000";i.push(c?{x:a.x0+t/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(t,n,0,o);case"circlepack":return function(t,e,n,r){const o=[],i=[];for(const n of t){const t=n.__radius??5;if(0>=t)continue;const i=r(nc(n,"nodeStyle"));let s=i.fill||zc(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ic(e);s=t[n.depth%t.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:t,style:{fill:s,stroke:i.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Rc(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 l=r(nc(o,"nodeStyle")).fill||zc(e);if(e.colorByDepth&&void 0!==o.depth){const t=Ic(e);l=t[o.depth%t.length]}if(a){const n="string"==typeof l?Dc(l):e.themeSemantic?.text??"#000";i.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 i.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:i}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Fc(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(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 Oc(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Yc(t,e){const 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 Bc}from"d3-shape";function jc(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var Hc={sankey:ic,force:yc,chord:wc,tree:Wc,cluster:Wc,treemap:Wc,circlepack:Wc,partition:Wc,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;o&&function(t,e,n,r,o){const i=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),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,h="number"==typeof c?()=>c:c,d=jc(n);d.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function y(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const p=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=y(s(t));r.push({id:x,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,l,c,f,p,g){const m=i(e);if(!m?.length)return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=a[Math.min(k,a.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=a[Math.min(x,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,S={id:n,depth:p,data:e,parentId:n},_=g?f/u(S)*A:f*A,M=Bc().value(t=>{const e=i(t)?.length;return e?4:1}).sort(null)(k),P=h(S);for(let e=0;k.length>e;e++){const i=(M[e].startAngle+M[e].endAngle)/2,a=k[e],u=y(s(a)),h=l+_*Math.sin(i),f=c+_*Math.cos(i)*P;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:_,angle:i,depth:p,parentId:n,eccentricity:P}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(a,u,h,f,_,p+1,!0)}w+=b}}(t,x,p,g,m,1,!1)}(o,r,n,t,e)},buildScene(t,e,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const e=jc(n),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.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 i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*r,x2:t+n*Math.sin(c),y2:e+n*Math.cos(c)*r,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(nc(e,"nodeSize")),r=o?o(nc(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.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&&l.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(nc(n,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(n):e?n.data?.[e]??n.id:n.id;c.push({x:n.x,y:n.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){const n=jc(e),r=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),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(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 r=a.get(t.parentId);if(!r)continue;const l=t.angle+i*s*o({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=r.x+t.ring*Math.sin(l),e.y=r.y+t.ring*Math.cos(l)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)}};function Xc(t){return Hc[t]}function Gc(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&wt(n,t)||"#4e79a7":e=>{if(n){const t=wt(n,e);if(t)return t}let r=0;for(let t=0;e.length>t;t++)r=31*r+e.charCodeAt(t)|0;return t[Math.abs(r)%t.length]??"#4e79a7"}}import{quadtree as Vc}from"d3-quadtree";function qc(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Uc(t){if(!t||"object"!=typeof t)return!1;const e=t;if("boolean"!=typeof e.circular)return!1;if("number"!=typeof e.halfWidth||!Number.isFinite(e.halfWidth))return!1;if(e.circular){if(!Array.isArray(e.segments)||0===e.segments.length)return!1;for(const t of e.segments)if(!Kc(t))return!1;return!0}return Kc(e.points)}function Kc(t){if(!Array.isArray(t)||4!==t.length)return!1;for(const e of t){if(!e||"object"!=typeof e)return!1;const t=e;if("number"!=typeof t.x||!Number.isFinite(t.x))return!1;if("number"!=typeof t.y||!Number.isFinite(t.y))return!1}return!0}import{interpolateNumber as Qc}from"d3-interpolate";var Zc="rgba(34, 197, 94, 0.7)",Jc=2e3,tu=class t{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this._stylePaintPending=!1,this.config=t,this.tensionConfig={...Za,...t.tensionConfig},t.showParticles&&("sankey"===t.chartType||t.customNetworkLayout)&&(this.particlePool=new tl(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),void 0===t.layoutSelection&&null!=e.layoutSelection&&(t.layoutSelection=e.layoutSelection),this.config=t,this.tensionConfig={...Za,...t.tensionConfig},!t.showParticles||"sankey"!==t.chartType&&!t.customNetworkLayout||this.particlePool||(this.particlePool=new tl(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,l="function"==typeof o?o:t=>t[o],c="function"==typeof i?i:t=>t[i],u="function"==typeof s?s:t=>t[s],h="function"==typeof a?a:t=>t[a]??1;this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,{...qc(t),data:e})}for(let t=0;e.length>t;t++){const n=e[t],r=c(n)+"",o=u(n)+"",i=h(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...qc(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...qc(o),data:n});const l=`${r}\0${o}\0${t}`,d={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&Uc(n.bezier)&&(d.bezier=n.bezier),this.edges.set(l,d)}r?.deferLayout||this.runLayout(n)}applyForceLayoutPositions(t,e){for(const[e,n]of Object.entries(t)){const t=this.nodes.get(e);t&&(t.x=n.x,t.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(e)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,o=0===this.nodes.size;let i=!1;const s=Mt();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(e)||(this.nodes.set(e,qc(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,qc(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(e,n),l=this.edges.get(a);let c=!1;return l?(l.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(t){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const e=Xc(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!e.hierarchical)return;if(this.prepareForRelayout(),e.supportsStreaming&&!e.hierarchical){const t=new Map;for(const e of n)void 0!==e._prevX0?t.set(e.id,{x:(e._prevX0??0)+((e._prevX1??0)-(e._prevX0??0))/2,y:(e._prevY0??0)+((e._prevY1??0)-(e._prevY0??0))/2}):0===e.x&&0===e.y||t.set(e.id,{x:e.x,y:e.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(e.computeLayout(n,r,this.config,t),this.config.__previousPositions=void 0,e.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of n)this.nodes.set(t.id,t);for(let t=0;r.length>t;t++){const e=r[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||o.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:Mt(),duration:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:Mt(),duration:s});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const t=new Set(this.nodes.keys()),e=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of t)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)t.has(e)||this.removedNodes.add(e);for(const t of e)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)e.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=Mt()),this.previousNodeIds=t,this.previousEdgeKeys=e}setLayoutSelection(t){this.config.layoutSelection=t}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const t of this.sceneNodes)this._baseStyles.set(t,t.style);for(const t of this.sceneEdges)this._baseStyles.set(t,t.style)}consumeStylePaintPending(){const t=this._stylePaintPending;return this._stylePaintPending=!1,t}restyleScene(t){if(this._customRestyle){const e=this._customRestyle;for(const n of this.sceneNodes){const r=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...r,...o}:r}}if(this._customRestyleEdge){const e=this._customRestyleEdge;for(const n of this.sceneEdges){const r=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...r,...o}:r}}this._stylePaintPending=!0}buildScene(t){if(this.config.customNetworkLayout){const e=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),r=function(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=vt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}(this.config.colorScheme,this.config.themeCategorical,it),o={nodes:e,edges:n,dimensions:{width:t[0],height:t[1],plot:{x:0,y:0,width:t[0],height:t[1]}},theme:{semantic:this.config.themeSemantic??{},categorical:[...r]},resolveColor:Gc(r,this.config.colorScheme),config:this.config.layoutConfig??{},selection:this.config.layoutSelection??null};let i;try{i=this.config.customNetworkLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,n=ve("network",t,e,this.layoutVersion);this.lastCustomLayoutFailure=n,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{this.config.onLayoutError?.(n)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return void(e||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++))}return this.sceneNodes=i.sceneNodes??[],this.sceneEdges=i.sceneEdges??[],this.labels=i.labels??[],this.customLayoutOverlays=i.overlays??null,this.customLayoutHtmlMarks=i.htmlMarks??[],this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=i.restyle,this._customRestyleEdge=i.restyleEdge,this.hasCustomRestyle=!(!i.restyle&&!i.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(this.config.layoutSelection??null)),void ge({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const e=Xc(this.config.chartType);if(!e)return void this._sceneNodesRevision++;const n=e.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=e.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=e.buildScene(n,r,this.config,t);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,this._sceneNodesRevision++}rebuildNodeQuadtree(){let e=0,n=0;for(const t of this.sceneNodes)"circle"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxNodeRadius=n,t.QUADTREE_THRESHOLD>=e)return void(this._nodeQuadtree=null);const r=Array(e);let o=0;for(const t of this.sceneNodes)"circle"===t.type&&(r[o++]=t);this._nodeQuadtree=Vc().x(t=>t.cx).y(t=>t.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const t=Xc(this.config.chartType);return!!t?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Xc(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,t,e)}cancelIntroAnimation(){this.transition=null;for(const t of this.nodes.values())t._prevX0=void 0,t._prevX1=void 0,t._prevY0=void 0,t._prevY1=void 0;for(const t of this.edges.values())t._prevY0=void 0,t._prevY1=void 0,t._prevSankeyWidth=void 0,t._introFromZero=!1}advanceTransition(t){if(!this.transition)return!1;const e=St(t,this.transition),n=At(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=_t(t._prevX0,t._targetX0,n),t.x1=_t(t._prevX1,t._targetX1,n),t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n),t.sankeyWidth=_t(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=t?.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){!function(t,e,n=.5){const r="string"==typeof t.source?e.get(t.source):t.source,o="string"==typeof t.target?e.get(t.target):t.target;!r||!o||(t.bezier=t.circular&&t.circularPathData?function(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let r;r="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],i=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+i/3,y:e.y+s/3},{x:e.x+2*i/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}(t):function(t,e,n,r=.5){const o=(t.sankeyWidth||1)/2;if("down"===t.direction){const i=e.x1,s=n.x0,a=Qc(i,s);return{circular:!1,points:[{x:t.y0,y:i},{x:t.y0,y:a(r)},{x:t.y1,y:a(1-r)},{x:t.y1,y:s}],halfWidth:o}}const i=e.x1,s=n.x0,a=Qc(i,s);return{circular:!1,points:[{x:i,y:t.y0},{x:a(r),y:t.y0},{x:a(1-r),y:t.y1},{x:s,y:t.y1}],halfWidth:o}}(t,r,o,n))}(t,this.nodes,.5)}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){!function(t){const e=t.pulse;if(!e)return;const n=e.duration??500,r=e.color??"rgba(255,255,255,0.6)",o=e.glowRadius??4,{now:i}=t;for(const e of t.sceneNodes){const s=e.id;if(!s)continue;const a=t.nodeTimestamps.get(s);if(!a)continue;const l=i-a;n>l&&(e._pulseIntensity=1-l/n,e._pulseColor=r,e._pulseGlowRadius=o)}for(const e of t.sceneEdges){const o=e.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const l=t.edgeTimestamps.get(`${s}\0${a}`);if(!l)continue;const c=i-l;n>c&&(e._pulseIntensity=1-c/n,e._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:t})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(t){const e=t.decay;if(!e)return;const n=t.nodeTimestamps.size;if(1>=n)return;if(!t.cache.sortedNodes){t.cache.sortedNodes=Array.from(t.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]);const e=new Map;for(let n=0;t.cache.sortedNodes.length>n;n++)e.set(t.cache.sortedNodes[n][0],n);t.cache.ageMap=e}const r=t.cache.ageMap;for(const o of t.sceneNodes){const t=o.id;if(!t)continue;const i=r.get(t);if(void 0===i)continue;const s=Rt(e,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(t){!function(t){for(const e of t.sceneNodes)e._pulseColor===Zc&&(e._pulseIntensity=0,e._pulseColor=void 0,e._pulseGlowRadius=void 0);if(0===t.addedNodes.size)return;const e=t.now-t.lastTopologyChangeTime;if(e>=Jc)return;const n=1-e/Jc;for(const e of t.sceneNodes){const r=e.id;r&&t.addedNodes.has(r)&&(e._pulseIntensity=Math.max(e._pulseIntensity??0,n),e._pulseColor=Zc,e._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:t})}get hasActiveTopologyDiff(){return function(t,e,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==t.size&&Jc>n-e}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(t){!function(t){const e=t.thresholds;if(!e)return;const n=e.warningColor??"#f59e0b",r=e.criticalColor??"#ef4444",o=!1!==e.pulse;for(const i of t.sceneNodes){const s=i.id;if(!s)continue;const a=t.nodes.get(s);if(!a)continue;const l=e.metric(a);let c=null;void 0===e.critical||e.critical>l?void 0===e.warning||e.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(t.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:t})}get hasActiveThresholds(){return function(t,e){if(!e)return!1;for(const n of t){const t=e.metric(n);if(void 0!==e.warning&&t>=e.warning||void 0!==e.critical&&t>=e.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(t){const e=t.pulse;if(!e||0===t.lastIngestTime)return!1;const n=t.now??("undefined"!=typeof performance?performance.now():Date.now());return(e.duration??500)>n-t.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){const n=this.nodes.get(t);if(!n)return null;const r=n.data?{...n.data}:{};return n.data=e(n.data??{}),this.layoutVersion++,this.lastIngestTime=Mt(),r}updateEdge(t,e,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?t=>t[r]:t=>t.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===t&&("string"==typeof r.target?r.target:r.target.id)===e){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const t=o(r.data);null!=t&&(r.value=Number(t))}return i.length>0&&(this.layoutVersion++,this.lastIngestTime=Mt()),i}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,this.lastIngestTime=Mt(),!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof e?e:t=>t?.[e];for(const[e,o]of this.edges)o.data&&r(o.data)===t&&n.push(e)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(r);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&(this.layoutVersion++,this.lastIngestTime=Mt()),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear()}};tu.QUADTREE_THRESHOLD=500;var eu=tu;import*as nu from"react";import{Fragment as ru,jsx as ou,jsxs as iu}from"react/jsx-runtime";function su(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,autoPlaceAnnotations:x,svgAnnotationRules:v}=t,b=nu.useMemo(()=>{const t=(g||[]).flatMap(t=>{const e=function(t){if("glyph"===t.type&&t.glyph&&"number"==typeof t.size){const e=t.cx??t.x,n=t.cy??t.y;if("number"!=typeof e||"number"!=typeof n)return null;const r=pn(t.glyph,t.size);return{x:e+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const e=t.cx??(null!=t.x&&null!=t.w?t.x+t.w/2:t.x),n=t.cy??(null!=t.y&&null!=t.h?t.y+t.h/2:t.y);return"number"!=typeof e||"number"!=typeof n?null:{x:e,y:n,r:"number"==typeof t.r?Math.max(1,t.r):"number"==typeof t.outerR?Math.max(1,t.outerR):"number"==typeof t.size?Math.max(1,de(t.size)):Math.max(1,t.w??0,t.h??0)/2}}(t),n=function(t){const e=t.id??t.datum?.id??t.datum?.data?.id??t.datum?.data?.name;return null==e?void 0:e+""}(t);return e?[{pointId:n,...e}]:[]});return{scales:null,width:e,height:n,frameType:"network",pointNodes:t,sceneNodes:g}},[n,g,e]),k=nu.useMemo(()=>m&&x?Yo({annotations:m,context:b,..."object"==typeof x?x:{}}):m,[m,x,b]),w=nu.useMemo(()=>wo(),[]),A=k?ko(k.filter(t=>"widget"!==t.type),w,v,b):null,S=!0===k?.some(t=>"widget"===t.type&&!0===t._annotationDeferred);return iu(ru,{children:[S&&ou("style",{children:fo},"annotation-widget-disclosure-style"),iu("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[ou("title",{children:"string"==typeof a?a:"Network Chart"}),ou("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),iu("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((t,e)=>ou("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+e)),A,p]}),a&&"string"==typeof a?ou("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?ou("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,Cr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),k?.filter(t=>"widget"===t.type&&t.nodeId&&g).map((t,e)=>{const n=!0===t._annotationDeferred,r=g.find(e=>e.id===t.nodeId||e.datum?.id===t.nodeId||e.datum?.data?.id===t.nodeId||e.datum?.data?.name===t.nodeId);if(!r)return null;const o=t.width??32,s=t.height??32;return ou("div",{className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0))+(t.dx??0)-o/2,top:i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0))+(t.dy??-16)-s/2,width:o,height:s,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:t.content??ou("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"})},"widget-"+e)})]})}su.displayName="NetworkSVGOverlay";import*as au from"react";import{jsx as lu}from"react/jsx-runtime";var cu={position:"absolute",top:0,left:0,pointerEvents:"none"};function uu({marks:t,margin:e,selection:n=null,overscan:r=400}){const o=au.useRef(null),i=function(t,e,n){const[r,o]=au.useState(null);return au.useLayoutEffect(()=>{const t=e.current,n=function(t){let e=t?.parentElement??null;for(;e;){const{overflow:t,overflowX:n,overflowY:r}=window.getComputedStyle(e);if(/(auto|scroll|overlay)/.test(`${t} ${r} ${n}`))return e;e=e.parentElement}return null}(t);if(!t||!n)return void o(null);let r=0;const i=()=>{r=0;const e=n.getBoundingClientRect(),i=t.getBoundingClientRect();o(0!==e.width&&0!==e.height?{scroll:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[e,t,n]),au.useMemo(()=>{if(!t||!r)return t;const{scroll:e,originX:o,originY:i}=r,s=e.left-n,a=e.right+n,l=e.top-n,c=e.bottom+n;return t.filter(t=>{const e=o+t.x,n=i+t.y;return!(s>e+t.width||e>a||l>n+t.height||n>c)})},[t,r,n])}(t,o,r);if(!t||0===t.length)return null;const s=lu("div",{className:"semiotic-network-html-marks",ref:o,style:{...cu,transform:`translate(${e.left}px, ${e.top}px)`},children:(i??t).map(t=>lu("div",{className:"semiotic-network-html-mark","data-mark-id":t.id,style:{position:"absolute",transform:`translate(${t.x}px, ${t.y}px)`,width:t.width,height:t.height,pointerEvents:"none"},children:t.content},t.id))});return null!=n?lu(Ke,{value:n,children:s}):s}import{jsx as hu}from"react/jsx-runtime";"undefined"!=typeof process&&process;var du={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"},fu={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function yu(t,e,n,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?hu("div",{style:{...du,width:e,height:n},children:r||"No data available"}):null}function pu(t,e,n,r){if(!t)return null;if(!1===r)return null;if(null!=r)return hu("div",{style:{width:e,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return hu("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)=>hu("div",{className:"semiotic-loading-bar",style:{...fu,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function gu(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function mu(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const t=Error("Force layout aborted");return t.name="AbortError",t}var xu=class{constructor(t=function(){const t="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.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)}("forceLayoutWorker.js");return new Worker(t,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=t,this.worker.onmessage=t=>{const e=t.data,n=e.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),e.error){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),void r.reject(t)}r.resolve({positions:e.positions??{}})}},this.worker.onerror=t=>{this.rejectAll(Error(t.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(t,e){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(e?.aborted)return Promise.reject(mu());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:t};return new Promise((t,o)=>{const i=()=>{this.pending.delete(n),e?.removeEventListener("abort",i),o(mu())},s=()=>e?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:t}),e?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(t){this.pending.delete(n),s(),o(t instanceof Error?t:Error(t+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(t){for(const e of this.pending.values())e.cleanup(),e.reject(t);this.pending.clear()}},vu=null;import{jsx as bu,jsxs as ku}from"react/jsx-runtime";var wu=/^(value|amount|total|count|weight|score)$/i;function Au({data:t}){if("edge"===t.nodeOrEdge){const e=t.data;return e?ku("div",{className:"semiotic-tooltip",style:Es,children:[ku("div",{style:{fontWeight:600},children:["object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target]}),null!=e.value&&ku("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]})]}):null}const e=t.data;if(!e)return null;const n=e.__hierarchyNode;if(n){const t=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??e.id;null!=n&&t.unshift(n+""),r=r.parent}t.length>1&&t.shift();const o=t.length-1;return ku("div",{className:"semiotic-tooltip",style:Es,children:[bu("div",{children:t.map((t,e)=>ku("span",{children:[e>0&&bu("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),e===o?bu("strong",{children:t}):bu("span",{style:{opacity:.7},children:t})]},e))}),null!=e.value&&e.value>0&&bu("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof e.value?e.value.toLocaleString():e.value+""})]})}const r=(e.sourceLinks?.length||0)+(e.targetLinks?.length||0),o=(e.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(e.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0),i=Ls(e.data??e),s=null!=i.title?i.title+"":e.id,a=i.entries.some(t=>wu.test(t.key));return ku("div",{className:"semiotic-tooltip",style:Es,children:[bu("div",{style:{fontWeight:600},children:s}),i.entries.map(t=>{return ku("div",{style:{marginTop:4,opacity:.8},children:[t.key,": ",(e=t.value,null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+"")]},t.key);var e}),!a&&null!=e.value&&e.value>0&&ku("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]}),r>0&&ku("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Su(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function _u(t,e){if(!e.pathD)return;t.save();const n=Su(e);if(e.style.fill&&"none"!==e.style.fill){const r=e._gradient;if(r){const n=t.createLinearGradient(r.x0,0,r.x1,0),o=e.style.fillOpacity??e.style.opacity??.5,i="string"==typeof e.style.fill?e.style.fill:"#999",s=Sn(t,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),t.fillStyle=n,t.globalAlpha=o}else t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.globalAlpha=e.style.fillOpacity??e.style.opacity??.5;t.fill(n)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??.5,t.globalAlpha=.5*(e.style.opacity??1),t.stroke(n)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(n)),t.restore()}function Mu(t,e){t.save();const n=e.style.stroke||"#999";t.strokeStyle=Sn(t,n)||n,t.lineWidth=e.style.strokeWidth??1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(e.style.strokeWidth??1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Pu(t,e){if(!e.pathD)return;t.save();const n=Su(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.globalAlpha=e.style.fillOpacity??e.style.opacity??.5,t.fill(n)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??.5,t.globalAlpha=.3*(e.style.opacity??1),t.stroke(n)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(n)),t.restore()}function Cu(t,e){if(!e.pathD)return;t.save();const n=Su(e),r=e.style.stroke||"#999";t.strokeStyle=Sn(t,r)||r,t.lineWidth=e.style.strokeWidth??1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(n),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.globalAlpha=e.style.fillOpacity??.1,t.fill(n)),t.restore()}Au.ownsChrome=!0;var Tu=new Map;function Lu(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let n=Tu.get(e);return n||(n=new Path2D(he(t.symbolType,t.size)),Tu.size>256&&Tu.clear(),Tu.set(e,n)),n}catch{return null}}function Nu(t){const{sceneNodes:e,nodes:n,nodeColorMap:r,colorScheme:o}=t;for(const t of e)t.id&&"string"==typeof t.style?.fill&&r.set(t.id,t.style.fill);const i=Array.isArray(o)?o:bt,s=Array.from(n);for(let t=0;s.length>t;t++){const e=s[t];r.has(e.id)||r.set(e.id,i[t%i.length])}return s.length}function Du(t,e,n,r=30){switch(t.type){case"circle":return function(t,e,n,r=30){const o=e-t.cx,i=n-t.cy,s=Math.sqrt(o*o+i*i);return s>rn(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,r);case"rect":return function(t,e,n){const r=nn(e,n,t);return r.hit?{type:"node",datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);if(t.innerR-2>i||i>t.outerR+2)return null;const s=an(Math.atan2(o,r)),a=an(t.startAngle),l=an(t.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);case"symbol":return function(t,e,n,r=30){const o=e-t.cx,i=n-t.cy,s=Math.sqrt(o*o+i*i);return s>rn(de(t.size),r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,r);case"glyph":return function(t,e,n,r=30){if(null==t.datum)return null;const o=pn(t.glyph,t.size),i=t.cx+o.centerDx,s=t.cy+o.centerDy,a=e-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>rn(o.radius,r)?null:{type:"node",datum:t.datum,x:i,y:s,distance:c}}(t,e,n,r);default:return null}}var Eu=null,Ru=null;function Iu(){return Ru||((Eu=document.createElement("canvas")).width=1,Eu.height=1,Ru=Eu.getContext("2d")),Ru}function zu(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch{return null}}function $u(t,e,n){switch(t.type){case"bezier":return function(t,e,n){if(!t.pathD)return null;const r=zu(t),o=Iu();if(!r||!o)return null;try{if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,e,n);if(o.lineWidth=i,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch{}return null}(t,e,n);case"line":return function(t,e,n){const r=t.x2-t.x1,o=t.y2-t.y1,i=r*r+o*o;if(0===i)return null;let s=((e-t.x1)*r+(n-t.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=t.x1+s*r,l=t.y1+s*o,c=Math.sqrt((e-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:t.datum,x:a,y:l,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const r=zu(t),o=Iu();if(!r||!o)return null;try{if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,e,n);if(o.lineWidth=i,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch{}return null}(t,e,n);default:return null}}function Wu(t){const{clientX:e,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:h=30}=t,d=e-r.left-o.left,f=n-r.top-o.top;if(0>d||d>i||0>f||f>s)return{kind:"miss-outside"};const y=function(t,e,n,r,o=30,i,s=0){let a=null,l=o,c=1/0;if(i){const t=mn(i,n,r,o,s,t=>t.cx,t=>t.cy,t=>t.r);t&&(a={type:"node",datum:t.node.datum,x:t.node.cx,y:t.node.cy,distance:t.distance},l=t.distance)}for(const e of t){if(i&&"circle"===e.type)continue;const t=Du(e,n,r,o);if(t)if("rect"===e.type){const n=e.w*e.h;c>n&&(a=t,c=n)}else l>t.distance&&(a=t,l=t.distance)}if(a)return a;for(const t of e){if(!1===t.interactive)continue;const e=$u(t,n,r);e&&l>e.distance&&(a=e,l=e.distance)}return a}(a,l,d,f,h,c,u);return y?{kind:"hit",hover:Ss(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}import{jsx as Fu,jsxs as Ou}from"react/jsx-runtime";var Yu={top:20,right:80,bottom:20,left:80},Bu={top:40,right:40,bottom:40,left:40},ju=new Set(["chord","force","circlepack","orbit"]),Hu=[800,600],Xu=Qa(Ka(function(t,e){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:x=300,forceStrength:v=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:w,padAngle:A=.01,groupWidth:S=20,sortGroups:M,edgeSort:P,treeOrientation:C="vertical",edgeType:T="curve",padding:L,paddingTop:N,tensionConfig:D,showParticles:E=!1,particleStyle:R,nodeStyle:I,edgeStyle:$,colorBy:W,colorScheme:F="category10",edgeColorBy:O="source",edgeOpacity:Y=.5,colorByDepth:B=!1,nodeSize:j=8,nodeSizeRange:H=[5,20],nodeLabel:X,showLabels:G=!0,labelMode:V,size:q=Hu,responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,enableHover:tt=!0,tooltipContent:et,customHoverBehavior:nt,customClickBehavior:rt,onObservation:ot,chartId:it,onTopologyChange:st,annotations:at,autoPlaceAnnotations:lt,svgAnnotationRules:ct,legend:ut,legendPosition:ht,legendLayout:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:pt,legendIsolatedCategories:gt,title:mt,foregroundGraphics:xt,backgroundGraphics:vt,decay:kt,pulse:wt,transition:At,animate:St,staleness:_t,thresholds:Mt,accessibleTable:Pt=!0,description:Ct,summary:Tt,orbitMode:Lt,orbitSize:Nt,orbitSpeed:Dt,orbitRevolution:Et,orbitRevolutionStyle:Rt,orbitEccentricity:It,orbitShowRings:zt,orbitAnimated:$t,customNetworkLayout:Wt,onLayoutError:Ft,layoutConfig:Ot,layoutSelection:Yt}=t,Bt=ju.has(n)?Bu:Yu,jt=Ha(!0),Ht=Ks({sizeProp:q,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:Bt,foregroundGraphics:xt,backgroundGraphics:vt,animate:St,transitionProp:At,themeDirtyRef:jt}),{reducedMotionRef:Xt,responsiveRef:Gt,size:Vt,margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,resolvedForeground:Qt,resolvedBackground:Zt,transition:Jt,introEnabled:te,tableId:ee,rafRef:ne,renderFnRef:re,scheduleRender:oe,cancelRender:ie,currentTheme:se}=Ht,ae=Pi(),le=Ni(),ce=Va(()=>_(r),[r]),ue=Va(()=>Array.isArray(o)?_(o):o,[o]),de=Va(()=>({...Za,...D}),[D]),fe=Va(()=>({...Ja,...R}),[R]),ye=Va(()=>{return{chartType:(t={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:P,treeOrientation:C,edgeType:T,padding:L,paddingTop:N,tensionConfig:de,showParticles:E,particleStyle:fe,nodeStyle:I,edgeStyle:$,nodeLabel:X,showLabels:G,labelMode:V,colorBy:W,colorScheme:F,edgeColorBy:O,edgeOpacity:Y,colorByDepth:B,nodeSize:j,nodeSizeRange:H,decay:kt,pulse:wt,transition:Jt,introAnimation:te,staleness:_t,thresholds:Mt,orbitMode:Lt,orbitSize:Nt,orbitSpeed:Dt,orbitRevolution:Et,orbitRevolutionStyle:Rt,orbitEccentricity:It,orbitShowRings:zt,orbitAnimated:$t,customNetworkLayout:Wt,onLayoutError:Ft,layoutConfig:Ot,currentTheme:se}).chartType,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,edgeIdAccessor:t.edgeIdAccessor,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,tensionConfig:t.tensionConfig,showParticles:t.showParticles,particleStyle:t.particleStyle,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,labelMode:t.labelMode,colorBy:t.colorBy,colorScheme:t.colorScheme,themeCategorical:t.currentTheme?.colors?.categorical,themeSemantic:z(t.currentTheme),edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,decay:t.decay,pulse:t.pulse,transition:t.transition,introAnimation:t.introAnimation,staleness:t.staleness,thresholds:t.thresholds,orbitMode:t.orbitMode,orbitSize:t.orbitSize,orbitSpeed:t.orbitSpeed,orbitRevolution:t.orbitRevolution,orbitRevolutionStyle:t.orbitRevolutionStyle,orbitEccentricity:t.orbitEccentricity,orbitShowRings:t.orbitShowRings,orbitAnimated:t.orbitAnimated,customNetworkLayout:t.customNetworkLayout,onLayoutError:t.onLayoutError,layoutConfig:t.layoutConfig};var t},[n,a,l,c,u,d,f,y,p,g,m,x,v,A,S,M,P,C,T,L,N,de,E,fe,I,$,X,G,V,W,F,O,Y,B,j,H,kt,wt,Jt?.duration,Jt?.easing,te,_t,Mt,Lt,Nt,Dt,Et,Rt,It,zt,$t,se,Wt,Ft,Ot]),pe=Ri(ye),ge=Ri({chartType:(me={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:P,treeOrientation:C,edgeType:T,padding:L,paddingTop:N,tensionConfig:de,customNetworkLayout:Wt,orbitMode:Lt,orbitSize:Nt,orbitEccentricity:It}).chartType,nodeIDAccessor:me.nodeIDAccessor,sourceAccessor:me.sourceAccessor,targetAccessor:me.targetAccessor,valueAccessor:me.valueAccessor,edgeIdAccessor:me.edgeIdAccessor,childrenAccessor:me.childrenAccessor,hierarchySum:me.hierarchySum,orientation:me.orientation,nodeAlign:me.nodeAlign,nodePaddingRatio:me.nodePaddingRatio,nodeWidth:me.nodeWidth,iterations:me.iterations,forceStrength:me.forceStrength,padAngle:me.padAngle,groupWidth:me.groupWidth,sortGroups:me.sortGroups,edgeSort:me.edgeSort,treeOrientation:me.treeOrientation,edgeType:me.edgeType,padding:me.padding,paddingTop:me.paddingTop,tensionConfig:me.tensionConfig,customNetworkLayout:me.customNetworkLayout,orbitMode:me.orbitMode,orbitSize:me.orbitSize,orbitEccentricity:me.orbitEccentricity});var me;const xe=Ha(null),ve=Ha(0),be=Ha(0),ke=Ha(!1),we=Ha(null);we.current||(we.current=new eu(pe));const[Ae,Se]=Xa(null),[_e,Me]=Xa(0),[Pe,Ce]=Xa(0),[Te,Le]=Xa(!1),[Ne,De]=Xa(!1),Ee=Ha(0),Re=Ha(null),Ie=Ha(!1),ze=Ha(w);ze.current=w;const $e=Ha(pe);$e.current=pe;const We=Ha(null),Fe=Ha(new Map),Oe=Ha(0),Ye=qa(t=>function(t){const{node:e,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=t;if("function"==typeof n)return n(e)+"";if("string"==typeof n&&e.data){const t=e.data[n];if(void 0!==t){if(!o.has(t+"")){const e=Array.isArray(r)?r:bt;o.set(t+"",e[i.current++%e.length])}return o.get(t+"")}}if(o.has(e.id))return o.get(e.id);const s=Array.isArray(r)?r:bt,a=n?s[i.current++%s.length]:s[0];return o.set(e.id,a),a}({node:t,colorBy:W,colorScheme:F,nodeColorMap:Fe.current,colorIndexRef:Oe}),[W,F]),Be=(je=se,je?.colors?.border||je?.colors?.secondary||je?.colors?.primary||"#999");var je;const He=qa(t=>function(t,e){return t?"object"==typeof t?t:e?.get(t)??null:null}(t,we.current?.nodes),[]),Xe=qa(t=>function(t){const{edge:e,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=t;if("function"==typeof n)return n(e);const s=o(e.source),a=o(e.target);return"target"===n&&a?r(a):s?r(s):i}({edge:t,edgeColorBy:O,getNodeColor:Ye,resolveEndpoint:He,fallback:Be}),[O,Ye,Be,He]),Ve=qa(t=>function(t){const{edge:e,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:l}=t;if("function"==typeof n){const t=a(e.source);return t?n(e,t):l}if(!o)return i(e);const c=r,u=a(e.source),h=a(e.target);return"target"===c&&h?s(h):u?s(u):l}({edge:t,particleStyleColor:fe.color,particleColorBy:fe.colorBy,hasExplicitParticleColorBy:!!R?.colorBy,getEdgeColor:Xe,getNodeColor:Ye,resolveEndpoint:He,fallback:Be}),[R?.colorBy,fe.color,fe.colorBy,Ye,Xe,Be,He]),qe=("sankey"===n||!!Wt)&&E||!!wt||(we.current?.isAnimating??!1);tn(we,pe,jt,oe),en(we,Yt,jt,oe),Ga(()=>{const t=we.current;t&&(t.buildScene([Ut,Kt]),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),jt.current=!0,oe())},[se,Ut,Kt,oe]);const Ue=qa(()=>{const t=we.current;if(t&&(t.runLayout([Ut,Kt]),t.buildScene([Ut,Kt]),jt.current=!0,Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),Me(t.layoutVersion),st)){const{nodes:e,edges:n}=t.getLayoutData();st(e,n)}},[Ut,Kt,st,F]),Ke=qa(t=>{if(null==t||"object"!=typeof t)return;const e=we.current;e&&(e.ingestEdge(t)&&Ue(),oe())},[Ue,oe]),Ze=qa(t=>{const e=we.current;if(!e)return;let n=!1;for(const r of t)null!=r&&"object"==typeof r&&e.ingestEdge(r)&&(n=!0);n&&Ue(),oe()},[Ue,oe]),Je=qa(()=>{we.current?.clear(),Fe.current.clear(),Oe.current=0,Me(we.current?.layoutVersion??0),Se(null),We.current=null,jt.current=!0,oe()},[oe]),nn=qa(()=>{const t=we.current;t&&(t.tension+=999,Ue(),oe())},[Ue,oe]);Ua(e,()=>({push:Ke,pushMany:Ze,removeNode:t=>{const e=we.current?.removeNode(t)??!1;if(e){const e=We.current?.data?"function"==typeof a?a(We.current.data):We.current.data[a]:void 0;We.current&&"node"===We.current.nodeOrEdge&&e===t&&(We.current=null,Se(null)),Fe.current.delete(t),Ue(),jt.current=!0,oe()}return e},removeEdge:(t,e)=>{const n=we.current?.removeEdge(t,e)??!1;if(n){if(We.current&&"edge"===We.current.nodeOrEdge){const n=We.current.data;let r;r=void 0!==e?("object"==typeof n?.source?n.source.id:n?.source)===t&&("object"==typeof n?.target?n.target.id:n?.target)===e:!h||!n||("function"==typeof h?h:t=>t?.[h])(n)===t,r&&(We.current=null,Se(null))}Ue(),jt.current=!0,oe()}return n},updateNode:(t,e)=>{const n=we.current?.updateNode(t,e)??null;return n&&(jt.current=!0,oe()),n},updateEdge:(t,e,n)=>{const r=we.current?.updateEdge(t,e,n)??[];return r.length>0&&(Ue(),jt.current=!0,oe()),r},clear:Je,getTopology:()=>we.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>we.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>we.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const t=we.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:nn,getTension:()=>we.current?.tension??0}),[Ke,Ze,Je,nn,Ue,oe]);const rn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),on=rn?i||(Array.isArray(o)?void 0:o):void 0;Ga(()=>{const t=we.current;if(!t)return;const e=++Ee.current;if(Re.current?.abort(),Re.current=null,rn&&on)t.ingestHierarchy(on,[Ut,Kt]),t.buildScene([Ut,Kt]),De(!1),ze.current?.("ready"),jt.current=!0,oe();else{const i=ce,s=Array.isArray(ue)?ue:[];if(0===i.length&&0===s.length)return null==r&&null==o||0>=t.nodes.size&&0>=t.edges.size||Je(),De(!1),void ze.current?.("ready");const a=[Ut,Kt],l="force"===n&&!Wt&&gu()&&function(t,e,n,r,o=4e4){return"sync"!==t&&("worker"===t||r*(e+n)>=o)}(b,i.length,s.length,x);if(l&&le&&!Ie.current&&t.sceneNodes.length>0)return Ie.current=!0,De(!1),ze.current?.("ready"),jt.current=!0,void oe();if(l){const n=new AbortController;Re.current=n;const r=t._lastPositionSnapshot;t.ingestBounded(i,s,a,{deferLayout:!0});const o=t.getLayoutData(),l=function(t,e,n,r,o){const i=mc(n.nodeSize,n.nodeSizeRange,t);return{kind:"frame",nodes:t.map(t=>{const e=o?.get(t.id);return{id:t.id,x:0!==t.x||0!==t.y?t.x:e?.x??0,y:0!==t.x||0!==t.y?t.y:e?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:t.value,__forceRadius:i(t)}}),edges:e.map(t=>{const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,r=t.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:t.value;return{source:e,target:n,value:t.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength},size:r}}(o.nodes,o.edges,$e.current,a,r);return De(!0),ze.current?.("pending"),function(t,e){return gu()?e?.aborted?Promise.reject(mu()):(vu&&!vu.isDead||(vu=new xu),vu).request(t,e):Promise.reject(Error("Web Workers are unavailable"))}(l,n.signal).then(({positions:n})=>{e===Ee.current&&(t.applyForceLayoutPositions(n,a),t.buildScene(a),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),De(!1),ze.current?.("ready"),Me(t.layoutVersion),jt.current=!0,oe())}).catch(n=>{"AbortError"!==n.name&&e===Ee.current&&(t.runLayout(a),t.buildScene(a),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),De(!1),ze.current?.("error"),Me(t.layoutVersion),jt.current=!0,oe())}),()=>n.abort()}t.ingestBounded(i,s,a),t.buildScene(a),De(!1),ze.current?.("ready"),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),jt.current=!0,oe()}},[ce,ue,r,o,i,on,rn,Ut,Kt,ge,b,x,le,n,Wt,oe,Je,F]),Ga(()=>{s&&s.length>0&&Ze(s)},[]);const sn=qa(t=>{if(nt&&nt(t),ot){const e=Date.now();ot(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:it}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:it})}},[nt,ot,it]),an=qa(t=>{if(rt&&rt(t),ot){const e=Date.now();ot(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:it}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:it})}},[rt,ot,it]),{hoverHandlerRef:ln,hoverLeaveRef:cn,onPointerMove:un,onPointerLeave:hn}=Ht,dn=()=>!Wt||(we.current?.hasCustomRestyle??!1);ln.current=t=>{if(!tt)return;const e=dn(),n=xe.current;if(!n)return;const r=we.current;if(!r)return;const o=Wu({clientX:t.clientX,clientY:t.clientY,canvasRect:n.getBoundingClientRect(),margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(We.current=o.hover,Se(o.hover),sn&&(sn(o.hover),e&&(jt.current=!0)),e&&oe()):We.current&&(We.current=null,Se(null),sn&&(sn(null),e&&(jt.current=!0)),e&&oe())},cn.current=()=>{if(We.current){const t=dn();We.current=null,Se(null),sn&&(sn(null),t&&(jt.current=!0)),t&&oe()}};const fn=Ha(()=>{});fn.current=t=>{if(!rt&&!ot)return;const e=xe.current;if(!e)return;const n=we.current;if(!n)return;const r=Wu({clientX:t.clientX,clientY:t.clientY,canvasRect:e.getBoundingClientRect(),margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?an(r.hover):"miss"===r.kind&&an(null)};const yn=qa(t=>fn.current(t),[]),gn=Ha(-1),mn=Ha(null),xn=Ha(-1),vn=qa(t=>{const e=we.current;if(!e)return;const n=function(t){const e=[];for(const n of t)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;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.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const t=pn(n.glyph,n.size);e.push({x:n.cx+t.centerDx,y:n.cy+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:n.datum?.id??"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const r=Jn(n),o=gn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),gn.current=0,xn.current=-1;const e=r.flat[0];mn.current={shape:e.shape,w:e.w,h:e.h};const n=Ss(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return We.current=n,Se(n),sn&&(sn(n),jt.current=!0),void oe()}const i=tr(r,o),s=function(t,e,n,r,o){const i=n.flat[e.flatIndex];if(!i)return er(t,e,n);const s=i.datum?.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(t,e,n){let r=null,o=1/0;for(let i=0;t.flat.length>i;i++){const s=t.flat[i];if(s===e)continue;const a=s.x-e.x,l=s.y-e.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up")??e.flatIndex;return r!==e.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return e.flatIndex;const t=function(t,e){const n=t+"",r=[];for(const t of e){const e=t.datum??t,o=rr(e.source),i=rr(e.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===t.length)return e.flatIndex;const i=n.idToIdx.get(t[(o.current+1)%t.length])??-1;return 0>i?e.flatIndex:(o.current=-1,i)}default:{const r=er(t,e,n);return null!==r&&r!==e.flatIndex&&(o.current=-1),r}}}(t.key,i,r,e.sceneEdges??[],xn);if(null===s)return;if(t.preventDefault(),0>s)return gn.current=-1,mn.current=null,xn.current=-1,We.current=null,Se(null),sn&&(sn(null),jt.current=!0),void oe();gn.current=s;const a=r.flat[s];mn.current={shape:a.shape,w:a.w,h:a.h};const l={data:a.datum||{},x:a.x,y:a.y,__semioticHoverData:!0,nodeOrEdge:"node"};We.current=l,Se(l),sn&&(sn(l),jt.current=!0),oe()},[sn,oe]),bn=qa(t=>{gn.current=-1,mn.current=null,un(t)},[un]);re.current=()=>{ne.current=null;const t=xe.current;if(!t)return;const e=we.current;e&&function(t){const{canvas:e,store:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,background:a,dirtyRef:l,lastFrameTimeRef:c,reducedMotion:u,showParticles:h,isContinuous:d,animate:f,decay:y,pulse:p,thresholds:g,staleness:m,particleStyle:x,getParticleColor:v,pendingAnnotationFrameRef:b,lastAnnotationFrameTimeRef:k,setAnnotationFrame:w,scheduleNextFrame:A}=t,S=e.getContext("2d");if(!S)return;const _=performance.now(),M=c.current?Math.min((_-c.current)/1e3,.1):.016;c.current=_;const P=n.advanceTransition(u?_+1e6:_),C=!u&&P,T=!u&&n.tickAnimation([i,s],M),L=l.current;(P||L||T)&&n.buildScene([i,s]);const N=h&&!u&&!!n.particlePool,D=!!((E={dirtyOrRebuilt:L,transitioning:C,animationTicked:T,continuous:N||d,liveEncoding:!!y||!!p||!!g||!1!==f&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||E.transitioning||E.animationTicked||E.continuous||E.liveEncoding||E.forced);var E;const R=!!m&&n.lastIngestTime>0&&_-n.lastIngestTime>(m?.threshold??5e3);if(D){if(!Qs(e,r,o,Zs()))return;if(S.clearRect(-o.left,-o.top,r[0],r[1]),Wi(S,{background:a,width:i,height:s}),y&&n.applyDecay(),p&&n.applyPulse(_),g&&n.applyThresholds(_),!1!==f&&n.applyTopologyDiff(_),R&&(S.globalAlpha=m?.dimOpacity??.5),function(t,e){for(const n of e)switch(n.type){case"bezier":_u(t,n);break;case"line":Mu(t,n);break;case"ribbon":Pu(t,n);break;case"curved":Cu(t,n)}}(S,n.sceneEdges),function(t,e){for(const n of e){if("rect"!==n.type)continue;const e=n;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(e.style.opacity??1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.globalAlpha=e.style.opacity??1,t.strokeRect(e.x,e.y,e.w,e.h)),ua(t,e),t.restore())}}(S,n.sceneNodes),function(t,e){for(const n of e){if("circle"!==n.type)continue;const e=n;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(e.style.opacity??1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.globalAlpha=e.style.opacity??1,t.stroke()),ha(t,e),t.restore())}}(S,n.sceneNodes),function(t,e){for(const n of e){if("arc"!==n.type)continue;const e=n;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(e.style.opacity??1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.globalAlpha=e.style.opacity??1,t.stroke()),t.restore()}}(S,n.sceneNodes),function(t,e){const n=t.globalAlpha;for(const r of e){if("symbol"!==r.type)continue;const e=r;if(0>=e.size)continue;const o=Lu(e);if(!o)continue;t.save(),t.translate(e.cx,e.cy),e.rotation&&t.rotate(e.rotation);const i=e.style.opacity??1;e.style.fill&&(t.globalAlpha=n*i*(e.style.fillOpacity??1),t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.fill(o)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*i,t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.stroke(o)),t.restore()}}(S,n.sceneNodes),function(t,e){const n=t.globalAlpha;for(const r of e)"glyph"===r.type&&ka(t,r,r.cx,r.cy,n);t.globalAlpha=n}(S,n.sceneNodes),N&&!R){const t=n.edgesArray;if(t.length>0){!function(t,e,n,r){const o=r.spawnRate??.1,i=r.maxPerEdge??50;for(let r=0;e.length>r;r++){const s=e[r];if(!s.bezier)continue;if(t.countForEdge(r)>=i)continue;const a=s.value*o*n*(s.bezier.circular?.3:1),l=Math.floor(a),c=a-l;let u=l;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(r)<i;e++)t.spawn(r)}}(n.particlePool,t,M,x);const e=.5*(x.speedMultiplier??1);let r;if(x.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}n.particlePool.step(M,e,t,r),function(t,e,n,r,o){const i=r.radius??3;t.globalAlpha=r.opacity??.7;for(let s=0;e.particles.length>s;s++){const a=e.particles[s];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),t.fillStyle=Sn(t,c)||c,t.beginPath(),t.arc(a.x,a.y,i,0,2*Math.PI),t.fill()}t.globalAlpha=1}(S,n.particlePool,t,x,v)}}R&&(S.globalAlpha=1)}l.current=!1,(L||C||T)&&e.setAttribute("aria-label",Ji(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const I=L||C||T||b.current;I&&_-k.current>=33?(w(t=>t+1),k.current=_,b.current=!1):b.current=!!I,(d||C||null!=n.transition||T||n.hasActivePulses||n.hasActiveThresholds||!1!==f&&n.hasActiveTopologyDiff||b.current)&&A()}({canvas:t,store:e,size:Vt,margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,background:J,dirtyRef:jt,lastFrameTimeRef:ve,reducedMotion:!!Xt.current,showParticles:E,isContinuous:qe,animate:St,decay:kt,pulse:wt,thresholds:Mt,staleness:_t,particleStyle:fe,getParticleColor:Ve,pendingAnnotationFrameRef:ke,lastAnnotationFrameTimeRef:be,setAnnotationFrame:Ce,scheduleNextFrame:()=>{oe()}})},Di({hydrated:ae,wasHydratingFromSSR:le,storeRef:we,dirtyRef:jt,renderFnRef:re,cancelRender:ie}),Ga(()=>{jt.current=!0,oe()},[n,Ut,Kt,J,oe]),ur(_t,we,jt,oe,Te,Le);const kn=tt&&Ae?Fu(Is,{x:Ae.x,y:Ae.y,containerWidth:Ut,containerHeight:Kt,margin:qt,className:"stream-network-tooltip",zIndex:2,children:et?et(Ae):Fu(Au,{data:Ae})}):null;if(bi||!ae&&le){const t=we.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),r=e?i||(Array.isArray(o)?void 0:o):void 0;if(e&&r)t.ingestHierarchy(r,[Ut,Kt]),t.buildScene([Ut,Kt]);else{const e=ce,n=Array.isArray(ue)?ue:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[Ut,Kt]),t.buildScene([Ut,Kt]))}}const e=t?.sceneNodes??[],r=t?.sceneEdges??[],s=t?.labels??[];return Ou("div",{ref:Gt,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":Ct||("string"==typeof mt?mt:"Network chart"),style:{position:"relative",width:U?"100%":Vt[0],height:K?"100%":Vt[1]},children:[Fu(ps,{summary:Tt}),Ou("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vt[0],height:Vt[1],style:{position:"absolute",left:0,top:0},children:[Zt&&Fu("g",{transform:`translate(${qt.left},${qt.top})`,children:Zt}),Ou("g",{transform:`translate(${qt.left},${qt.top})`,children:[J&&Fu("rect",{x:0,y:0,width:Ut,height:Kt,fill:J}),r.map((t,e)=>function(t,e){switch(t.type){case"line":return pi("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 pi("path",{d:n.pathD,fill:xi(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 pi("path",{d:n.pathD,fill:xi(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 pi("path",{d:n.pathD,fill:xi(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),e.map((t,e)=>function(t,e){switch(t.type){case"circle":{const n=t;return pi("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+e)}case"rect":{const n=t;return pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+e)}case"arc":{const n=t,r=fi().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(mi)||"";return pi("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+e)}case"symbol":{const n=t,r=he(n.symbolType,n.size,n.path);return pi("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?xi(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+e)}case"glyph":return vi(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e)).filter(Boolean),s.map((t,e)=>function(t,e){return pi("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)]})]}),Fu(su,{width:Ut,height:Kt,totalWidth:Vt[0],totalHeight:Vt[1],margin:qt,labels:s,sceneNodes:e,title:mt,legend:ut,legendPosition:ht,legendLayout:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:pt,legendIsolatedCategories:gt,foregroundGraphics:Ge(Qt,Qe(we.current?.customLayoutOverlays,Yt??null)),annotations:at,autoPlaceAnnotations:lt,svgAnnotationRules:ct,annotationFrame:0}),Fu(uu,{marks:t?.customLayoutHtmlMarks,margin:qt,selection:Yt??null})]})}const wn=we.current;return Ou("div",{ref:Gt,className:"stream-network-frame"+(Z?" "+Z:""),role:"group","aria-label":Ct||("string"==typeof mt?mt:"Network chart"),tabIndex:0,"aria-busy":Ne||void 0,style:{position:"relative",width:U?"100%":Vt[0],height:K?"100%":Vt[1],overflow:"visible"},onKeyDown:vn,children:[Pt&&Fu(gs,{tableId:ee}),Pt&&Fu(ys,{nodes:wn?.sceneNodes??[],edges:wn?.sceneEdges??[],chartType:"Network chart",tableId:ee,chartTitle:"string"==typeof mt?mt:void 0}),Fu(ps,{summary:Tt}),Fu(ms,{hoverPoint:Ae}),Ou("div",{role:"img","aria-label":Ct||("string"==typeof mt?mt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:tt?bn:void 0,onMouseLeave:tt?hn:void 0,onClick:rt||ot?yn:void 0,children:[Ne&&!1!==k&&Fu("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:pu(!0,Vt[0],Vt[1],k)}),Zt&&Fu("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:Vt[0],height:Vt[1],pointerEvents:"none",overflow:"visible"},children:Fu("g",{transform:`translate(${qt.left},${qt.top})`,children:Zt})}),Fu("canvas",{ref:xe,"aria-label":Ji(wn?.sceneNodes?.length??0,wn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Fu(su,{width:Ut,height:Kt,totalWidth:Vt[0],totalHeight:Vt[1],margin:qt,labels:wn?.labels||[],sceneNodes:wn?.sceneNodes,title:mt,legend:ut,legendPosition:ht,legendLayout:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:pt,legendIsolatedCategories:gt,foregroundGraphics:Ge(Qt,Qe(we.current?.customLayoutOverlays,Yt??null)),annotations:at,autoPlaceAnnotations:lt,svgAnnotationRules:ct,annotationFrame:Pe}),Fu(uu,{marks:wn?.customLayoutHtmlMarks,margin:qt,selection:Yt??null}),Fu(bs,{active:gn.current>=0,hoverPoint:Ae,margin:qt,size:Vt,shape:mn.current?.shape,width:mn.current?.w,height:mn.current?.h}),kn,_t?.showBadge&&Fu(dr,{isStale:Te,position:_t.badgePosition})]})]})}));Xu.displayName="StreamNetworkFrame";var Gu=Xu,Vu=class t{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(t){if(!Number.isFinite(t))return;this._count+=1;const e=t-this._mean;this._mean+=e/this._count,this._m2+=e*(t-this._mean),this._min>t&&(this._min=t),t>this._max&&(this._max=t)}merge(t){if(0===t._count)return;if(0===this._count)return this._count=t._count,this._mean=t._mean,this._m2=t._m2,this._min=t._min,void(this._max=t._max);const e=this._count+t._count,n=t._mean-this._mean;this._mean+=n*t._count/e,this._m2+=t._m2+n*n*this._count*t._count/e,this._count=e,this._min>t._min&&(this._min=t._min),t._max>this._max&&(this._max=t._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const e=new t;return e._count=this._count,e._mean=this._mean,e._m2=this._m2,e._min=this._min,e._max=this._max,e}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},qu=class{constructor(t){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=t.window??"tumbling",this.size=t.size;const e=t.hop??t.size;this.hop=e>0&&t.size>=e?e:t.size,this.gap=t.gap??t.size,this.retain=null!=t.retain&&t.retain>0?t.retain:1/0}push(t,e){Number.isFinite(t)&&Number.isFinite(e)&&(t>this.latest&&(this.latest=t),"session"===this.type?this.pushSession(t,e):this.pushFixed(t,e),this.prune())}pushFixed(t,e){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(t/this.size)*this.size,e);const n=this.hop,r=Math.floor(t/n);for(let o=Math.floor((t-this.size)/n)+1;r>=o;o++)this.bump(o*n,e)}bump(t,e){let n=this.windows.get(t);n||(n=new Vu,this.windows.set(t,n)),n.push(e)}pushSession(t,e){const n=this.gap,r=new Vu;r.push(e);let o=t,i=t;const s=[],a={start:o,end:i,stats:r};for(const e of this.sessions)t-n>e.end||e.start>t+n?s.push(e):(a.stats.merge(e.stats),o>e.start&&(o=e.start),e.end>i&&(i=e.end));a.start=o,a.end=i,s.push(a),s.sort((t,e)=>t.start-e.start),this.sessions=s}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const t=[...this.windows.keys()].sort((t,e)=>t-e),e=t.length-this.retain;for(let n=0;e>n;n++)this.windows.delete(t[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const t=[];for(const[e,n]of this.windows){const r=e+this.size;t.push(this.row(e,r,n,r>this.latest))}return t.sort((t,e)=>t.start-e.start),t}emitSessions(){return this.sessions.map(t=>this.row(t.start,t.end,t.stats,this.gap>this.latest-t.end))}row(t,e,n,r){return{start:t,end:e,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Uu(t,e){switch(e){case"sum":return t.sum;case"min":return t.min;case"max":return t.max;case"count":return t.count;default:return t.mean}}function Ku(t,e,n,r=1){if("none"===e)return null;if("minmax"===e)return[t.min,t.max];const o=Uu(t,n),i=t.stddev*r;return[o-i,o+i]}var Qu={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Zu=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Ju(t){if("number"==typeof t)return Number.isFinite(t)&&t>0?t:null;if("string"!=typeof t)return null;const e=t.trim();if(""===e)return null;Zu.lastIndex=0;let n,r=0,o=0;for(;null!==(n=Zu.exec(e));){const t=parseFloat(n[1]),e=Qu[n[2]];if(null==e||!Number.isFinite(t))return null;r+=t*e,o+=n[0].length}return o!==e.length?null:r>0?r:null}var th=class{constructor(t){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=t.lateness>0?t.lateness:0,this.getTime=t.getTime,this.latePolicy=t.latePolicy??"drop"}push(t){const e=this.getTime(t);if(!Number.isFinite(e))return{released:[t],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>e?(this._lateCount+=1,n.push(t),"drop"===this.latePolicy?{released:[],late:n}:{released:[t],late:n}):(e>this._watermark&&(this._watermark=e),this.held.push(t),{released:this.drain(),late:n})}drain(){const t=this._watermark-this.lateness;if(0===this.held.length)return[];const e=[],n=[];for(const r of this.held)this.getTime(r)>t?n.push(r):e.push(r);return this.held=n,e.sort((t,e)=>this.getTime(t)-this.getTime(e)),e}flush(){const t=this.held;return this.held=[],t.sort((t,e)=>this.getTime(t)-this.getTime(e)),t}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as eh,useImperativeHandle as nh,forwardRef as rh,useCallback as oh,useState as ih,useEffect as sh}from"react";import{useMemo as ah,useCallback as lh,useState as ch,useId as uh,useEffect as hh,useRef as dh}from"react";function fh(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function yh(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function ph(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[gh,mh]=R(t=>({selections:new Map,setClause(e,n){t(t=>{const r=t.selections.get(e),o=r?.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,r]of n){const n=e.fields[t];if(!n||!ph(r,n))return!1}return!0}(o,n))return{};const i=new Map(t.selections),s=yh(i,e),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(e,{...s,clauses:a}),{selections:i}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r||!r.clauses.has(n))return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,{...r,clauses:i}),{selections:o}})},setResolution(e,n){t(t=>{const r=t.selections.get(e);if(r?.resolution===n)return{};const o=new Map(t.selections),i=yh(o,e);return o.set(e,{...i,resolution:n}),{selections:o}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const r=new Map(t.selections);return r.set(e,{...n,clauses:new Map}),{selections:r}})}})),[xh,vh]=R(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 bh,useMemo as kh,useCallback as wh}from"react";function Ah(t){const e=bh(),n=t.clientId||e,{name:r}=t,o=mh(t=>t.selections.get(r)),i=mh(t=>t.setClause),s=mh(t=>t.clearClause),a=kh(()=>!!o&&o.clauses.size>0,[o]);return{predicate:kh(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(fh(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:wh(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:e})},[n,r,i]),selectInterval:wh(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:e})},[n,r,i]),clear:wh(()=>{s(r,n)},[s,r,n]),clientId:n}}function Sh(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function _h(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function Mh(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function Ph(t,e,n){const r=t.xValue??e?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function Ch(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||{}}var Th={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Lh(t,e={}){const n=e.mobileSemantics?.interaction,r="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,i=!!n||void 0!==r,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!o&&!i)return Th;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Nh({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const h=uh(),d=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"===d?.mode?[d.seriesField||c||n[0]].filter(t=>!!t):d?.fields||n||[],y=Ah({name:t?.name||"__unused__",fields:f}),p=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:o,selectPoints:i,clear:s}=Ah({name:e,fields:n});return{onHover:wh(t=>{if(!t)return void s();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}_h(e)&&i(e)},[n,i,s,e]),predicate:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=vh(t=>t.pushObservation),m=t?{isActive:y.isActive,predicate:y.predicate}:null,[x,v]=ch(null),b=dh(!1),k=c||n[0],w=ah(()=>{if(!l||null==x||!k)return null;const t=x,e=k;return{isActive:!0,predicate:n=>("string"==typeof n[e]?n[e]:(n[e]??"")+"")===t}},[l,x,k]),A=lh(t=>{const n=!t&&b.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"===d?.mode&&d.xField){const n=Ph(t,e,d.xField);null!=n&&function(t,e,n){const r=jo.positions.get(t);r?.locked||r&&r.xValue===e&&r.sourceId===n||(jo={positions:new Map(jo.positions).set(t,{xValue:e,sourceId:n})},Xo())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(e)}else"x-position"!==d?.mode||n||Go(d.name||"hover",h),"x-position"===d?.mode||n||p.onHover(null);if(l&&k)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=e?.[k];v(null!=n?n+"":null)}else n||v(null);if(o||g){const e={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(t){const n=Ch(t),r={...e,type:"hover",datum:n||{},x:t.x??0,y:t.y??0};o&&o(r),g&&g(r)}else{const t={...e,type:"hover-end"};o&&o(t),g&&g(t)}}},[e,p,d,h,o,i,s,g,l,k,u]),S=lh((n=!0)=>{b.current=!1,e&&"x-position"!==d?.mode&&p.onHover(null),t&&u?.tapToSelect&&y.clear(),n&&l&&v(null),"x-position"===d?.mode&&(Vo(d.name||"hover",h),Go(d.name||"hover",h))},[e,d,p,t,u,y,l,h]),_=lh(n=>{const r=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),c=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]);const e=Ph(n,t,d.xField);null!=e&&function(t,e,n){const r=jo.positions.get(t);if(r?.locked){const e=new Map(jo.positions);return e.delete(t),jo={positions:e},Xo(),!1}jo={positions:new Map(jo.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Xo()}(d.name||"hover",e,h)}if(r)if(n){b.current=!0;const r=Ch(n);if(e&&"x-position"!==d?.mode&&p.onHover(r),t&&u?.tapToSelect&&f.length>0){const t={};for(const e of f){const n=r[e];void 0!==n&&(t[e]=[n])}(function(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(t)&&y.selectPoints(t)}if(l&&k){const t=r?.[k];v(null!=t?t+"":null)}}else c&&S();if(n||c){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:i||"unknown",chartId:s};if(n){const e=Ch(n),r={...t,type:"click",datum:e||{},x:n.x??0,y:n.y??0};o&&o(r),g&&g(r)}else{const e={...t,type:"click-end"};o&&o(e),g&&g(e)}}}},[a,o,g,i,s,d,h,u,e,p,t,y,f,l,k,S]);return hh(()=>{if(!u?.enabled||"undefined"==typeof document)return;const t=t=>{"Escape"===t.key&&b.current&&S()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u?.enabled,S]),hh(()=>()=>{b.current&&S(!1)},[S]),hh(()=>{if("x-position"!==d?.mode)return;const t=d.name||"hover";return()=>{Vo(t,h),Go(t,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:m,hoverSelectionHook:w,customHoverBehavior:A,customClickBehavior:_,crosshairSourceId:h}}var Dh={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 Eh(t,e,n){const r=Dh[t||"primary"],o=t&&"primary"!==t||!n?.width?r.width:n.width,i=t&&"primary"!==t||!n?.height?r.height:n.height,s=function(t,e,n=t.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:t,matches:[]};const r=n.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:n}=t,r=e.width,o=e.height,i=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>r||"number"==typeof n.maxWidth&&r>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 i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>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:r.reduce((t,e)=>function(t,e){const n={...t,...e};for(const r of["margin","frameProps","mobileSemantics","style"])Mh(t[r])&&Mh(e[r])&&(n[r]={...t[r],...e[r]});return"string"==typeof t.className&&"string"==typeof e.className&&(n.className=`${t.className} ${e.className}`),n}(t,e.rule.transform),t),matches:r}}({...e,mode:t},{width:e.width??o,height:e.height??i}).props,a=s.mode||t,l=Dh[a||"primary"],c="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?l.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?l.height:n.height),showAxes:s.showAxes??l.showAxes,showGrid:s.showGrid??l.showGrid,enableHover:s.enableHover??(!!s.linkedHover||l.enableHover),showLegend:s.showLegend??l.showLegend,showLabels:s.showLabels??l.showLabels,title:c?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:c?void 0:s.xLabel,yLabel:c?void 0:s.yLabel,categoryLabel:c?void 0:s.categoryLabel,valueLabel:c?void 0:s.valueLabel,marginDefaults:Rh(l.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:c,mobileInteraction:Lh(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function Rh(t,e,n){if(!1!==e)return t;const r={...t};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{jsx as Ih,jsxs as zh}from"react/jsx-runtime";var $h={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},Wh={opacity:.7,marginRight:4};function Fh(t,e,n){if(null!=t)return"function"==typeof e?e(t):t["string"==typeof e?e:n]}function Oh(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function Yh(t={}){const{timeAccessor:e,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=t;return t=>{const i=t?.data??null,s=Fh(i,e,"time"),a=Fh(i,n,"value");return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[zh("span",{style:Wh,children:[r,":"]}),Oh(s)]}),zh("div",{children:[zh("span",{style:Wh,children:[o,":"]}),Oh(a)]})]})}}function Bh(t,e){return null!=t?t:Math.max(e?.length??0,200)}var jh="time",Hh="value",Xh="__aggLower",Gh="__aggUpper",Vh="__aggPartial",qh="count",Uh="__aggStart",Kh="__aggEnd";function Qh(t,e){const n=e.stat??"mean",r=e.band??"none",o=e.sigma??1;return t.emit().map(t=>{const e={[jh]:(t.start+t.end)/2,[Hh]:Uu(t,n),[qh]:t.count,[Vh]:t.partial,[Uh]:t.start,[Kh]:t.end},i=Ku(t,r,n,o);return i&&(e[Xh]=i[0],e[Gh]=i[1]),e})}function Zh(t){const{linkedHover:e,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=t,f={},y=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(a||e||r||o||s)&&(f.customHoverBehavior=u),h&&(l||(d?r||o||e:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(e||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}import{jsx as Jh}from"react/jsx-runtime";function td(t,e,n){const r="function"==typeof e?e(t):t[e??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isFinite(o)?o:null}var ed=rh(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:x,background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,transition:N,linkedHover:D,selection:E,onObservation:R,chartId:I,loading:z,loadingContent:$,emptyContent:W,emphasis:F,legendPosition:O,aggregate:Y,eventTime:B}=t,j=n.showAxes,H=n.enableHover,X=o??n.marginDefaults,G=r??[n.width,n.height],V=b??k??Yh({timeAccessor:u,valueAccessor:h}),q=eh(null),{customHoverBehavior:U}=Nh({selection:E,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:I}),K=oh(t=>{w&&w(t),U(t)},[w,U]),Q=null!=Y,[Z,J]=ih([]),tt=eh(null),et=eh(Y);et.current=Y;const nt=eh(Q);nt.current=Q;const rt=eh(Z);rt.current=Z;const ot=eh({timeAccessor:u,valueAccessor:h});ot.current={timeAccessor:u,valueAccessor:h},sh(()=>{if(!Q)return void(tt.current=null);const t=et.current,e=function(t){const e=t.window??"tumbling",n=Ju("session"===e?t.gap??t.size:t.size);if(null==n)return null;const r=null!=t.hop?Ju(t.hop):void 0,o=null!=t.gap?Ju(t.gap):void 0;return new qu({window:e,size:n,hop:r??void 0,gap:o??void 0,retain:t.retain})}(t);if(tt.current=e,e&&c){const{timeAccessor:t,valueAccessor:n}=ot.current;for(const r of c){const o=td(r,t,"time"),i=td(r,n,"value");null!=o&&null!=i&&e.push(o,i)}}J(e?Qh(e,t):[])},[Q?[Y.window??"tumbling",Y.size,Y.hop??"",Y.gap??"",Y.retain??""].join("|"):"",Q,c]),sh(()=>{Q&&tt.current&&J(Qh(tt.current,et.current))},[Y?.stat,Y?.band,Y?.sigma]);const it=oh(t=>{const e=tt.current,n=et.current;if(!e||!n)return;const{timeAccessor:r,valueAccessor:o}=ot.current;for(const n of t){const t=td(n,r,"time"),i=td(n,o,"value");null!=t&&null!=i&&e.push(t,i)}J(Qh(e,n))},[]),st=null!=B,at=eh(null),lt=eh(B);lt.current=B;const ct=eh(st);ct.current=st;const ut=eh(R);ut.current=R;const ht=eh(I);ht.current=I,sh(()=>{at.current=st?function(t){const e=Ju(t.lateness);return null==e?null:new th({lateness:e,getTime:t=>td(t,ot.current.timeAccessor,"time")??NaN,latePolicy:t.latePolicy??"drop"})}(lt.current):null},[st?`${B.lateness}|${B.latePolicy??"drop"}`:"",st]);const dt=oh(t=>{0!==t.length&&(nt.current?it(t):q.current?.pushMany(t))},[it]),ft=oh(t=>{const e=at.current;if(!ct.current||!e)return void dt(t);const n=[];for(const r of t){const t=e.push(r);if(t.released.length&&n.push(...t.released),t.late.length){const n=ut.current;if(n){const{timeAccessor:r}=ot.current,o=lt.current?.latePolicy??"drop";for(const i of t.late)n({type:"late-data",datum:i,eventTime:td(i,r,"time")??NaN,watermark:e.watermark,policy:o,lateCount:e.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:ht.current})}}}dt(n)},[dt]);nh(e,()=>({push:t=>ft([t]),pushMany:t=>ft(t),remove:t=>nt.current?[]:q.current?.remove(t)??[],update:(t,e)=>nt.current?[]:q.current?.update(t,e)??[],clear:()=>{at.current?.clear(),nt.current?(tt.current?.clear(),J([])):q.current?.clear()},getData:()=>nt.current?rt.current:q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[ft]);const yt=pu(z,G[0],G[1],$),pt=yt?null:yu(Q?void 0:c,G[0],G[1],W),gt={stroke:p,strokeWidth:g,strokeDasharray:m};null!=x&&(gt.opacity=x);const mt=Bh(l,c),xt=Q?Z:c,vt=Q?jh:u,bt=Q?Hh:h,kt=Q&&Y&&"none"!==(Y.band??"none")?{y0Accessor:Xh,y1Accessor:Gh,perSeries:!1}:void 0;return yt||pt||Jh(ja,{ref:q,chartType:"line",runtimeMode:"streaming",size:G,margin:X,className:F?`${i||""} semiotic-emphasis-${F}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,Y?.retain??Math.max(Z.length,600)):mt,data:xt,timeAccessor:vt,valueAccessor:bt,xExtent:d,yExtent:f,extentPadding:y,band:kt,lineStyle:gt,showAxes:j,background:v,hoverAnnotation:H,tooltipContent:V,...Zh({linkedHover:D,selection:E,onObservation:R,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,transition:N,pointIdAccessor:t.pointIdAccessor,legendPosition:O})});ed.displayName="RealtimeLineChart";import{useRef as nd,useImperativeHandle as rd,forwardRef as od,useCallback as id,useMemo as sd}from"react";import{jsx as ad}from"react/jsx-runtime";function ld(t,e,n){const r="function"==typeof e?e(t):t[e??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}var cd=od(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,showAxes:t.showAxes,enableHover:null!=t.enableHover?!!t.enableHover:void 0,linkedHover:t.linkedHover,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{binSize:r,size:o,margin:i,className:s,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:x,fill:v,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:P,annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,linkedHover:E,selection:R,decay:I,pulse:z,staleness:$,transition:W,onObservation:F,chartId:O,loading:Y,loadingContent:B,emptyContent:j,emphasis:H,legendPosition:X,brush:G,onBrush:V,linkedBrush:q}=t,U=n.showAxes,K=n.enableHover,Q=i??n.marginDefaults,Z=o??[n.width,n.height],J=_??M??function(t={}){const{timeAccessor:e,valueAccessor:n}=t;return t=>{const r=t?.data??null;if(null==r?.binStart||null==r?.binEnd){const t=Fh(r,e,"time"),o=Fh(r,n,"value");return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[Ih("span",{style:Wh,children:"x:"}),Oh(t)]}),zh("div",{children:[Ih("span",{style:Wh,children:"y:"}),Oh(o)]})]})}return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[Ih("span",{style:Wh,children:"range:"}),Oh(r.binStart),"–",Oh(r.binEnd)]}),null!=r.total&&zh("div",{children:[Ih("span",{style:Wh,children:"count:"}),Oh(r.total)]}),null!=r.category&&zh("div",{children:[Ih("span",{style:Wh,children:"category:"}),Oh(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),tt=nd(null),{customHoverBehavior:et}=Nh({selection:R,linkedHover:E,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:O}),nt=id(t=>{P&&P(t),et(t)},[P,et]),rt=!0===G?{dimension:"x",snap:"bin"}:"x"===G?{dimension:"x"}:"object"==typeof G?G:void 0,ot=(it=q)?"string"==typeof it?{name:it}:it:null;var it;const st="string"==typeof h?h:"time",at=function(t){const{name:e,xField:n,yField:r}=t,{predicate:o,isActive:i,selectInterval:s,clear:a}=Ah({name:e,fields:[n,r].filter(Boolean)}),l=n&&r?"xyBrush":n?"xBrush":"yBrush",c=wh(t=>{if(!t)return void a();const e={};"xyBrush"===l&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),r&&(e[r]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===l&&Sh(t)?n&&(e[n]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]):"yBrush"===l&&Sh(t)&&r&&(e[r]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]),_h(e)&&s(e)},[l,n,r,s,a]);return{brushInteraction:kh(()=>({brush:l,during:c,end:c}),[l,c]),predicate:o,isActive:i,clear:a}}({name:ot?.name||"__unused_hist_brush__",xField:ot?.xField||st,...ot?.yField?{yField:ot.yField}:{}}),lt=nd(at.brushInteraction);lt.current=at.brushInteraction;const ct=id(t=>{if(V&&V(t),F&&F(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}),ot){const e=lt.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[V,F,O,ot]);rd(e,()=>({push:t=>tt.current?.push(t),pushMany:t=>tt.current?.pushMany(t),remove:t=>tt.current?.remove(t)??[],update:(t,e)=>tt.current?.update(t,e)??[],clear:()=>tt.current?.clear(),getData:()=>tt.current?.getData()??[],getScales:()=>tt.current?.getScales()??null}),[]);const ut=pu(Y,Z[0],Z[1],B),ht=ut?null:yu(u,Z[0],Z[1],j),dt={};null!=v&&(dt.fill=v),null!=b&&(dt.stroke=b),null!=k&&(dt.strokeWidth=k),null!=w&&(dt.opacity=w),null!=A&&(dt.gap=A);const ft=H?`${s||""} semiotic-emphasis-${H}`.trim():s,yt=Bh(c,u),pt=sd(()=>"down"!==f?p:function({data:t,valueAccessor:e,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!t||0===t.length)return;const s=new Map;for(const o of t){const t=ld(o,n,"time"),i=ld(o,e,"value");if(null==t||null==i)continue;const a=Math.floor(t/r)*r;s.set(a,(s.get(a)??0)+i)}let a=0;for(const t of s.values())t>a&&(a=t);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ut||ht||ad(ja,{ref:tt,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:ft,arrowOfTime:a,windowMode:l,windowSize:yt,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pt,extentPadding:g,binSize:r,categoryAccessor:m,barColors:x,barStyle:dt,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...Zh({linkedHover:E,selection:R,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:nt}),annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,decay:I,pulse:z,staleness:$,transition:W,pointIdAccessor:t.pointIdAccessor,legendPosition:X,brush:rt||(q?{dimension:"x"}:void 0),onBrush:rt||q?ct:void 0})});function ud(t){return ad(cd,{...t,windowMode:"growing"})}cd.displayName="RealtimeHistogram",ud.displayName="TemporalHistogram";import{useRef as hd,useImperativeHandle as dd,forwardRef as fd,useCallback as yd}from"react";import{jsx as pd}from"react/jsx-runtime";var gd=fd(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:x,fill:v,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:P,annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,linkedHover:E,selection:R,onObservation:I,chartId:z,loading:$,loadingContent:W,emptyContent:F,emphasis:O,legendPosition:Y}=t,B=n.showAxes,j=n.enableHover,H=o??n.marginDefaults,X=r??[n.width,n.height],G=_??M??Yh({timeAccessor:u,valueAccessor:h}),V=hd(null),{customHoverBehavior:q}=Nh({selection:R,linkedHover:E,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:z}),U=yd(t=>{P&&P(t),q(t)},[P,q]);dd(e,()=>({push:t=>V.current?.push(t),pushMany:t=>V.current?.pushMany(t),remove:t=>V.current?.remove(t)??[],update:(t,e)=>V.current?.update(t,e)??[],clear:()=>V.current?.clear(),getData:()=>V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[]);const K=pu($,X[0],X[1],W),Q=K?null:yu(c,X[0],X[1],F),Z={};null!=x&&(Z.radius=x),null!=v&&(Z.fill=v),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,tt=O?`${i||""} semiotic-emphasis-${O}`.trim():i,et=Bh(l,c);return K||Q||pd(ja,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:tt,arrowOfTime:s,windowMode:a,windowSize:et,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:B,background:S,hoverAnnotation:j,tooltipContent:G,...Zh({linkedHover:E,selection:R,onObservation:I,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});gd.displayName="RealtimeSwarmChart";import{useRef as md,useImperativeHandle as xd,forwardRef as vd,useCallback as bd}from"react";import{jsx as kd}from"react/jsx-runtime";var wd=vd(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:x,gap:v,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:P,autoPlaceAnnotations:C,svgAnnotationRules:T,tickFormatTime:L,tickFormatValue:N,linkedHover:D,selection:E,onObservation:R,chartId:I,loading:z,loadingContent:$,emptyContent:W,emphasis:F,legendPosition:O}=t,Y=n.showAxes,B=n.enableHover,j=o??n.marginDefaults,H=r??[n.width,n.height],X=S??_??function(t={}){const{timeAccessor:e,valueAccessor:n}=t;return t=>{const r=t?.data??null,o=Fh(r,e,"time"),i=r?.delta??Fh(r,n,"value"),s=r?.cumEnd,a="number"==typeof i?0>i?Oh(i):"+"+Oh(i):Oh(i);return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[Ih("span",{style:Wh,children:"x:"}),Oh(o)]}),zh("div",{children:[Ih("span",{style:Wh,children:"Δ:"}),a]}),null!=s&&zh("div",{children:[Ih("span",{style:Wh,children:"total:"}),Oh(s)]})]})}}({timeAccessor:u,valueAccessor:h}),G=md(null),{customHoverBehavior:V}=Nh({selection:E,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:I}),q=bd(t=>{M&&M(t),V(t)},[M,V]);xd(e,()=>({push:t=>G.current?.push(t),pushMany:t=>G.current?.pushMany(t),remove:t=>G.current?.remove(t)??[],update:(t,e)=>G.current?.update(t,e)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const U=pu(z,H[0],H[1],$),K=U?null:yu(c,H[0],H[1],W),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=x&&(Q.connectorWidth=x),null!=v&&(Q.gap=v),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=F?`${i||""} semiotic-emphasis-${F}`.trim():i,J=Bh(l,c);return U||K||kd(ja,{ref:G,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:j,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:Y,background:A,hoverAnnotation:B,tooltipContent:X,...Zh({linkedHover:D,selection:E,onObservation:R,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:q}),annotations:P,autoPlaceAnnotations:C,svgAnnotationRules:T,tickFormatTime:L,tickFormatValue:N,legendPosition:O,pointIdAccessor:t.pointIdAccessor})});wd.displayName="RealtimeWaterfallChart";import{useRef as Ad,useImperativeHandle as Sd,forwardRef as _d,useCallback as Md}from"react";import{jsx as Pd}from"react/jsx-runtime";var Cd=_d(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:x="count",background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,linkedHover:N,selection:D,onObservation:E,chartId:R,loading:I,loadingContent:z,emptyContent:$,emphasis:W,legendPosition:F}=t,O=n.showAxes,Y=n.enableHover,B=o??n.marginDefaults,j=r??[n.width,n.height],H=b??k??function(t={}){const{timeAccessor:e,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=t;return t=>{const i=t?.data??null,s=i?.xCenter??Fh(i,e,"time"),a=i?.yCenter??Fh(i,n,"value"),l=i?.count,c=i?.sum,u=i?.value,h=i?.agg??"count";return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[zh("span",{style:Wh,children:[r,":"]}),Oh(s)]}),zh("div",{children:[zh("span",{style:Wh,children:[o,":"]}),Oh(a)]}),null!=l&&zh("div",{children:[Ih("span",{style:Wh,children:"count:"}),Oh(l)]}),"sum"===h&&null!=c&&zh("div",{children:[Ih("span",{style:Wh,children:"sum:"}),Oh(c)]}),"mean"===h&&null!=u&&zh("div",{children:[Ih("span",{style:Wh,children:"mean:"}),Oh(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=Ad(null),{customHoverBehavior:G}=Nh({selection:D,linkedHover:N,unwrapData:!0,onObservation:E,chartType:"RealtimeHeatmap",chartId:R}),V=Md(t=>{w&&w(t),G(t)},[w,G]);Sd(e,()=>({push:t=>X.current?.push(t),pushMany:t=>X.current?.pushMany(t),remove:t=>X.current?.remove(t)??[],update:(t,e)=>X.current?.update(t,e)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const q=pu(I,j[0],j[1],z),U=q?null:yu(c,j[0],j[1],$),K=W?`${i||""} semiotic-emphasis-${W}`.trim():i,Q=Bh(l,c);return q||U||Pd(ja,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:j,margin:B,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:x,showAxes:O,background:v,hoverAnnotation:Y,tooltipContent:H,...Zh({linkedHover:N,selection:D,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,legendPosition:F,pointIdAccessor:t.pointIdAccessor})});Cd.displayName="RealtimeHeatmap";export{Pt as DEFAULT_LIFECYCLE_THRESHOLDS,G as IncrementalExtent,Cd as RealtimeHeatmap,cd as RealtimeHistogram,ed as RealtimeLineChart,gd as RealtimeSwarmChart,wd as RealtimeWaterfallChart,th as ReorderBuffer,X as RingBuffer,Vu as RunningStats,Gu as StreamNetworkFrame,ja as StreamXYFrame,ud as TemporalHistogram,qu as WindowAccumulator,Ku as bandBounds,Ct as bandFromAge,Lt as compileMotionEncoding,Et as deriveMotionVector,Nt as opacityFromAge,Ju as parseWindowDuration,Tt as resolveMotionAccessor,Dt as resolveMotionVector,Uu as statValue};
|
|
1
|
+
import{getHitRadius as e,hitTestRect as t,isTimeLandmark as n,normalizeAngle as o}from"./chunk-chunk-CP3EN6KZ.module.min.js";import{CustomLayoutSelectionProvider as r,canUseForceWorker as s,createFrameForceWorkerRequest as i,runForceLayoutWorker as a,shouldUseForceWorker as l,wrapWithCustomLayoutSelection as c}from"./chunk-chunk-RH5TSQPH.module.min.js";import{AccessibleDataTable as u,AriaLiveTooltip as d,CanvasFrameBackground as h,FlippingTooltip as f,FocusRing as p,NetworkAccessibleDataTable as y,SceneRevisionDiagnosticsObserver as g,ScreenReaderSummary as m,SkipToTableLink as v,buildColorStopGradient as x,buildLinearFillGradient as b,computeCanvasAriaLabel as k,computeNetworkAriaLabel as w,createDefaultAnnotationRules as A,getDevicePixelRatio as S,prepareCanvas as _,renderAnnotationPass as T,renderEmptyState as C,renderLegendFromConfig as P,renderLoadingState as R,resolveCanvasFill as M,resolveCurveFactory as N,runSceneBuild as I,useFrame as D,useFrameCanvasHost as E,useHydration as W,useSceneRevisionDiagnostics as z,useWasHydratingFromSSR as B}from"./chunk-chunk-6F6GEAQU.module.min.js";import{annotationActivationProps as L,buildHoverData as O,defaultTooltipStyle as H,getPointerHitRadius as F,isAnnotationActivationTarget as j,smartTooltipEntries as $,useAnnotationActivationOptions as Y}from"./chunk-chunk-255KDHW5.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import{PipelineStore as X,attachUpdateResultStore as V,compileMotionEncoding as G,computeDecayOpacity as q,createCustomLayoutFailureDiagnostic as U,deriveMotionVector as Q,enrichDatumWithBand as K,getLayoutPlugin as J,opacityFromAge as Z,paintSceneWithBackend as ee,renderSceneWithBackend as te,resolveMotionAccessor as ne,resolveMotionVector as oe,ticksForMode as re,warnCustomLayoutDiagnostics as se}from"./chunk-chunk-T27ZEV6A.module.min.js";import{IncrementalExtent as ie,RingBuffer as ae}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-H4PPRW6N.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as le,DEFAULT_COLORS as ce,TITLE_BASELINE as ue,buildResolveColor as de,clampCornerRadii as he,computeEasing as fe,computeRawProgress as pe,emitClickObservations as ye,emitHoverObservations as ge,filterSparseArray as me,hasAnyCornerRadius as ve,isInteractiveKeyboardTarget as xe,isServerEnvironment as be,lerp as ke,networkLabelToSVG as we,networkSceneEdgeToSVG as Ae,networkSceneNodeToSVG as Se,normalizeLinkedBrush as _e,now as Te,observationInputType as Ce,resolveCustomLayoutPalette as Pe,unlockCrosshair as Re,useBrushSelection as Me,useChartMode as Ne,useChartSelection as Ie,useCrosshairPosition as De,xySceneNodeToSVG as Ee}from"./chunk-chunk-ES4DCG3L.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{DEFAULT_LIFECYCLE_THRESHOLDS as We,bandFromAge as ze}from"./chunk-chunk-2WVCH4PL.module.min.js";import{UpdateResultTracker as Be,annotationLayout as Le,drawGlyphParts as Oe,glyphFractionClipRect as He,glyphHitGeometry as Fe,glyphPlacement as je,schemeCategory10 as $e,symbolPathString as Ye,symbolRadius as Xe}from"./chunk-chunk-NO4MCQVD.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as Ve}from"./chunk-chunk-JJ2OOIET.module.min.js";import{getCSSColorCacheVersion as Ge,resolveCSSColor as qe}from"./chunk-chunk-QRIBHZYW.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{resolveThemeSemanticColors as Ue}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Qe from"react";import{useRef as Ke,useState as Je,useEffect as Ze,useMemo as et,useCallback as tt,useImperativeHandle as nt,useId as ot,forwardRef as rt,memo as st}from"react";import*as it from"react";import{jsx as at}from"react/jsx-runtime";var lt=null,ct=null;function ut(e){const[t,n]=it.useState(()=>lt);return it.useEffect(()=>{if(t)return;let e=!1;return(lt?Promise.resolve(lt):(ct||(ct=import("./chunk-XYBrushOverlay-ECZJJLAJ.module.min.js").then(e=>lt=e.XYBrushOverlay)),ct)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?at(t,{...e}):null}var dt=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=me(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=me(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import*as ht from"react";function ft(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:ht.createElement(ht.Fragment,null,...t)}import{useEffect as pt,useRef as yt}from"react";function gt(e,t,n,o){pt(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}function mt(e,t,n,o){const r=yt(null);pt(()=>{const s=e.current;if(!s)return;const i=t??null;r.current!==i&&(r.current=i,s.setLayoutSelection(i),s.hasCustomRestyle?s.restyleScene(i):n.current=!0,o())},[t,o,e,n])}function vt(t,n,o,r,s,i=e=>e.x,a=e=>e.y,l=e=>e.r){const c=Math.max(r,s+5,12),u=n-c,d=n+c,h=o-c,f=o+c;let p=null,y=1/0;return t.visit((t,s,c,g,m)=>{if(s>d||u>g||c>f||h>m)return!0;if(!t.length){let s=t;do{const t=s.data,c=i(t)-n,u=a(t)-o,d=Math.sqrt(c*c+u*u);e(l(t),r)>=d&&y>d&&(p=t,y=d),s=s.next}while(s)}return!1}),p?{node:p,distance:y}:null}import{line as xt}from"d3-shape";var bt=new WeakMap;function kt(e,t){const n=N(t);if(!n)return e;const o=bt.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const s={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,s,i,a,l){if(!r)return r=[a,l],void o.push([a,l]);const[c,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*c+3*h*h*d*e+3*h*d*d*s+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*i+d*d*d*l])}r=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,s){r=[n,s],o.push([n,s])}};return xt().x(e=>e[0]).y(e=>e[1]).curve(t).context(s)(e),o}(e,n);return bt.set(e,r),r}function wt(e,t,n,o=30,r,s=0){let i=null;if(r){const e=vt(r,t,n,o,s);e&&(i={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const s of e){let e=null;switch(s.type){case"point":if(r)break;e=St(s,t,n,o);break;case"symbol":e=_t(s,t,n,o);break;case"glyph":e=Tt(s,t,n,o);break;case"line":e=Ct(s,t,n,o);break;case"rect":if(null==s.datum)break;e=Rt(s,t,n);break;case"heatcell":e=Mt(s,t,n);break;case"area":if(!1===s.interactive)break;e=It(s,t,n);break;case"candlestick":e=Nt(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function At(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=Dt(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,s=o;o>0&&e[o][0]>=t?(r=o-1,s=o):e.length-1>o&&(r=o,s=o+1);const[i,a]=e[r],[l,c]=e[s];return l===i?a:a+Math.max(0,Math.min(1,(t-i)/(l-i)))*(c-a)}function St(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function _t(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(Xe(t.size),r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function Tt(t,n,o,r=30){if(null==t.datum)return null;const s=Fe(t.glyph,t.size),i=t.x+s.centerDx,a=t.y+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{node:t,datum:t.datum,x:i,y:a,distance:u}}function Ct(e,t,n,o=30){if(0===e.path.length)return null;const r=Dt(e.path,t);if(0>r)return null;const[s,i]=e.path[r];let a;if(e.path.length>1){let o=1/0;const s=Math.max(0,r-1),i=Math.min(e.path.length-2,r);for(let r=s;i>=r;r++){const[s,i]=e.path[r],[a,l]=e.path[r+1],c=Pt(t,n,s,i,a,l);o>c&&(o=c)}a=o}else{const e=t-s,o=n-i;a=Math.sqrt(e*e+o*o)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:s,y:i,distance:a}}function Pt(e,t,n,o,r,s){const i=r-n,a=s-o,l=i*i+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-o)**2);let c=((e-n)*i+(t-o)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*i))**2+(t-(o+c*a))**2)}function Rt(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Mt(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Nt(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,s=t-e.x,i=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+i*i)}}return null}function It(e,t,n){if(0===e.topPath.length)return null;const o=Dt(e.topPath,t);if(0>o)return null;const[r,s]=e.topPath[o],i=t-r,a=n-s,l=Math.sqrt(i*i+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:s,distance:l}}function Dt(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as Et,useRef as Wt}from"react";var zt={fresh:1,aging:.7,stale:.45,expired:.25},Bt={alpha:1,band:"fresh",isStale:!1};function Lt(e,t){if(!e||0>=t)return Bt;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=ze(t,n,e.thresholds);return{alpha:{...zt,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Bt}function Ot(e,t,n,o,r,s){const i=Wt("fresh");Et(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Lt(e,l-a.lastIngestTime);c.band===i.current&&c.isStale===r||(i.current=c.band,c.isStale!==r&&s(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,s,n])}import{jsx as Ht}from"react/jsx-runtime";function Ft({isStale:e,position:t}){return Ht("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{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"})}import{useMemo as jt,useRef as $t,useEffect as Yt}from"react";import{useMemo as Xt}from"react";import{bin as Vt}from"d3-array";import{jsx as Gt,jsxs as qt}from"react/jsx-runtime";function Ut(e){return"string"==typeof e?{type:e}:e}function Qt({orient:e,config:t,values:n,scale:o,size:r,length:s}){const i=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,l=Xt(()=>{if(0===n.length)return null;const t=o.domain(),l=r-8;if("boxplot"===i.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],i=s-o;return{q1:o,median:r,q3:s,whiskerLow:Math.max(t[0],o-1.5*i),whiskerHigh:Math.min(t[n-1],s+1.5*i)}}(n);if(!t)return null;const{q1:r,median:s,q3:c,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*l,20),f=(l-h)/2+4;if(a){const t=o(r),n=o(c),a=o(s),l=o(u),p=o(d),y="top"===e?-1:1,g=0;return qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Gt("line",{x1:l,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:l,y1:g+y*f,x2:l,y2:g+y*(f+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Gt("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:i.fill,strokeWidth:2})]})}{const t=o(r),n=o(c),a=o(s),l=o(u),p=o(d),y="left"===e?-1:1,g=0;return qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Gt("line",{x1:g+y*(f+h/2),y1:l,x2:g+y*(f+h/2),y2:p,stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:g+y*f,y1:l,x2:g+y*(f+h),y2:l,stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Gt("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:i.fill,strokeWidth:2})]})}}const c=Vt().domain(t).thresholds(i.bins)(n);if(0===c.length)return null;const u=Ve(c.map(e=>e.length));if(0===u)return null;if("histogram"===i.type)return Gt("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*l;if(a){const s=o(t.x0),a=o(t.x1)-o(t.x0);return Gt("rect",{x:s,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}{const s=o(t.x0),a=o(t.x1)-o(t.x0);return Gt("rect",{x:"left"===e?-4-r:4,y:Math.min(s,s+a),width:r,height:Math.abs(a),fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}})});if("violin"===i.type){const t=l/2+4,n=[];for(const r of c){if(null==r.x0||null==r.x1)continue;const s=r.length/u*(l/2),i=o((r.x0+r.x1)/2);n.push(a?`${i},${"top"===e?-(t-s):t-s}`:`${"left"===e?-(t-s):t-s},${i}`)}for(let r=c.length-1;r>=0;r--){const s=c[r];if(null==s.x0||null==s.x1)continue;const i=s.length/u*(l/2),d=o((s.x0+s.x1)/2);n.push(a?`${d},${"top"===e?-(t+i):t+i}`:`${"left"===e?-(t+i):t+i},${d}`)}return Gt("g",{"data-testid":"marginal-violin-"+e,children:Gt("polygon",{points:n.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}if("ridgeline"===i.type){const t=[];if(a){const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${r},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${s},${"top"===e?-r-4:r+4}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${i},${n}`),t.push("Z")}else{const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${n},${r}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${s}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${n},${i}`),t.push("Z")}return Gt("g",{"data-testid":"marginal-ridgeline-"+e,children:Gt("path",{d:t.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}return null},[n,o,i,r,s,e,a,4]);return l?Gt("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}function Kt(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Jt(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Zt(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function en(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function tn(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,s=Math.ceil(t/8);let i="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);i+=`L${Math.min(8*e+4,t)},${o+4*r}`,i+=`L${Math.min(n,t)},${o}`}return i}const o="bottom"===e?0:t,r="bottom"===e?1:-1,s=Math.ceil(n/8);let i=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);i+=`L${o+4*r},${Math.min(8*e+4,n)}`,i+=`L${o},${Math.min(t,n)}`}return i}import{Fragment as nn,jsx as on,jsxs as rn}from"react/jsx-runtime";function sn(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,scales:i,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:d,axisExtent:h}=e,f=jt(()=>{if(!i)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||an,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??re(i.x,s,h),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:i.x(e),label:n(e,t,c)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return ln(d,Math.max(55,f+8))},[i,l,u,t,h]),p=jt(()=>{if(!i)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||d||an,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o);return ln((e?.tickValues??re(i.y,s,h)).map(e=>({value:e,pixel:i.y(e),label:t(e)})),22)},[i,l,d,n,h]),y=c&&i,g=a&&i;if(!y&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),v=l?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return on("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:rn("g",{transform:`translate(${s.left},${s.top})`,children:[y&&(()=>{const e=en(l?.find(e=>"bottom"===e.orient)?.gridStyle),o=en(l?.find(e=>"left"===e.orient)?.gridStyle);return rn("g",{className:"stream-grid",children:[f.map((t,o)=>on("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),p.map((e,n)=>on("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),x&&!k&&on("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&on("path",{d:tn("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&on("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&on("path",{d:tn("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function an(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function ln(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function cn(e){const{width:t,height:o,totalWidth:r,totalHeight:s,margin:i,scales:a,showAxes:l,axes:c,xLabel:u,yLabel:d,yLabelRight:h,xFormat:f,yFormat:p,axisExtent:y,showGrid:g,title:m,legend:v,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:k,legendIsolatedCategories:w,legendPosition:S="right",legendLayout:_,foregroundGraphics:C,marginalGraphics:R,xValues:M,yValues:N,annotations:I,onAnnotationActivate:D,onObservation:E,chartId:W,chartType:z,autoPlaceAnnotations:B,svgAnnotationRules:L,xAccessor:O,yAccessor:H,annotationData:F,pointNodes:j,curve:$,underlayRendered:X,canvasObscuresUnderlay:V=!0,linkedCrosshairName:G,linkedCrosshairSourceId:q,children:U}=e,Q=Y({onAnnotationActivate:D,onObservation:E,chartId:W,chartType:z}),K=jt(()=>{if(!l||!a)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||f||an,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,o),i=e?.tickValues??re(a.x,s,y),u=i.map(e=>e.valueOf()),d=i.map((e,t)=>({value:e,pixel:a.x(e),label:n(e,t,u)})),h=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),p=e?.autoRotate?Math.max(20,Math.min(h+8,55)):Math.max(55,h+8);let g=ln(d,p);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=a.x.domain()[1],t=a.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,u);p>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[l,a,c,f,t,y]),J=jt(()=>{if(!l||!a)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||p||an,n=Math.max(2,Math.floor(o/30)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,n);let i=ln((e?.tickValues??re(a.y,s,y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),e?.includeMax&&i.length>0&&"exact"!==y&&!e?.tickValues){const e=a.y.domain()[1],n=a.y(e),o=i[i.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:n,label:r})}}return i},[l,a,c,p,o,y]),Z=jt(()=>{if(!l||!a)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||p||an,n=Math.max(2,Math.floor(o/30)),r=e.ticks??5;return ln((e.tickValues??re(a.y,"exact"===y?Math.max(2,r):Math.min(r,n),y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[l,a,c,p,o,y]),ee=$t(new Map),te=$t(I?.length??0),ne=I?.length??0;te.current!==ne&&(te.current=ne,ee.current=new Map);const oe=jt(()=>{if(!I||0===I.length)return null;const e=A("xy",Q),n={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:H,width:t,height:o,data:F,frameType:"xy",pointNodes:j,curve:$,stickyPositionCache:ee.current},r=B?Le({annotations:I,context:n,..."object"==typeof B?B:{}}):I;return T(r,e,L,n)},[I,B,L,t,o,O,H,F,a,j,$,Q]),se=De(G);return Yt(()=>{if(!se?.locked||!G)return;const e=e=>{"Escape"===e.key&&Re(G)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[se?.locked,G]),l||m||v||C||R||oe&&oe.length>0||g||U||se?rn("svg",{role:"img",width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[on("title",{children:"string"==typeof m?m:"XY Chart"}),on("desc",{children:"string"==typeof m?m+" (XY data visualization)":"XY data visualization"}),rn("g",{transform:`translate(${i.left},${i.top})`,children:[g&&a&&(!X||V)&&(()=>{const e=en(c?.find(e=>"bottom"===e.orient)?.gridStyle),n=en(c?.find(e=>"left"===e.orient)?.gridStyle);return rn("g",{className:"stream-grid",children:[K.map((t,n)=>on("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+n)),J.map((e,o)=>on("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"ygrid-"+o))]})})(),l&&a&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,a=!r||!1!==r.baseline,l=e?.jaggedBase||!1,f=r?.jaggedBase||!1,p=r?.landmarkTicks,y=e?.landmarkTicks,g="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!r?.autoRotate&&K.length>1&&(()=>{const e=t/Math.max(K.length-1,1);return K.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,k=o+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},A={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},_=r?.tickAnchor,T=e?.tickAnchor,C=Zt(K),P=Zt(J);return rn("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[rn("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!X||V)&&a&&!f&&on("line",{x1:0,y1:o,x2:t,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&f&&on("path",{d:tn("bottom",t,o),fill:"none",stroke:g,strokeWidth:1}),K.map((e,t)=>{const r=!!p&&("function"==typeof p?p(e.value,t):n(e.value,t>0?K[t-1].value:void 0));return rn("g",{transform:`translate(${e.pixel},${o})`,children:[on("line",{y2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?on("text",{y:b,textAnchor:x?"end":Kt(_,e.pixel===C.min,e.pixel===C.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},transform:x?"rotate(-45)":void 0,children:e.label}):on("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:on("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),u&&on("text",{x:t/2,y:k,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:u})]}),rn("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!X||V)&&s&&!l&&on("line",{x1:0,y1:0,x2:0,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&l&&on("path",{d:tn("left",t,o),fill:"none",stroke:g,strokeWidth:1}),J.map((e,t)=>{const o=!!y&&("function"==typeof y?y(e.value,t):n(e.value,t>0?J[t-1].value:void 0));return rn("g",{transform:`translate(0,${e.pixel})`,children:[on("line",{x2:-5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?on("text",{x:-8,textAnchor:"end",dominantBaseline:Jt(T,e.pixel===P.min,e.pixel===P.max),fontWeight:o?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...o?A:w},children:e.label}):on("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:on("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||d;return t?on("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===Z.length)return null;const r=!1!==e.baseline,s=e.landmarkTicks,a=e.label||h,l=e.tickAnchor,u=Zt(Z);return rn("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&on("line",{x1:t,y1:0,x2:t,y2:o,stroke:g,strokeWidth:1}),Z.map((e,o)=>{const r=!!s&&("function"==typeof s?s(e.value,o):n(e.value,o>0?Z[o-1].value:void 0));return rn("g",{transform:`translate(${t},${e.pixel})`,children:[on("line",{x2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?on("text",{x:8,textAnchor:"start",dominantBaseline:Jt(l,e.pixel===u.min,e.pixel===u.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},children:e.label}):on("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:on("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+o)}),a&&on("text",{x:t+i.right-15,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(90, ${t+i.right-15}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:a})]})})()]})})(),oe,R&&a&&M&&N&&rn(nn,{children:[R.top&&on("g",{transform:"translate(0, 0)",children:on(Qt,{orient:"top",config:Ut(R.top),values:M,scale:a.x,size:i.top,length:t})}),R.bottom&&on("g",{transform:`translate(0, ${o})`,children:on(Qt,{orient:"bottom",config:Ut(R.bottom),values:M,scale:a.x,size:i.bottom,length:t})}),R.left&&on("g",{transform:"translate(0, 0)",children:on(Qt,{orient:"left",config:Ut(R.left),values:N,scale:a.y,size:i.left,length:o})}),R.right&&on("g",{transform:`translate(${t}, 0)`,children:on(Qt,{orient:"right",config:Ut(R.right),values:N,scale:a.y,size:i.right,length:o})})]}),C,se&&se.sourceId!==q&&a?.x&&(()=>{const e=a.x(se.xValue);if(null==e||0>e||e>t)return null;const n=se.locked;return on("line",{x1:e,y1:0,x2:e,y2:o,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"})})(),U]}),m&&"string"==typeof m?on("text",{x:r/2,y:ue,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?on("foreignObject",{x:0,y:0,width:r,height:i.top,children:m}):null,P({legend:v,totalWidth:r,totalHeight:s,margin:i,legendPosition:S,title:m,legendLayout:_,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:k,legendIsolatedCategories:w})]}):null}import{useRef as un}from"react";function dn(e){const t=un(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return fn(e,t);if(!pn(e)||!pn(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!fn(n,r))return!1}else{if(!pn(n)||!pn(r))return!1;if(!hn(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function hn(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function fn(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function pn(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function yn(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:s=0,y:i=0,width:a,height:l}=t;if("transparent"===n)return!1;if(o)return!1;const c=n||(r&&"transparent"!==r?r:"")||null;if(!c)return!1;const u=qe(e,c);return!!u&&(e.fillStyle=u,e.fillRect(s,i,a,l),!0)}var gn={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 mn(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}function vn(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}import{useCallback as xn,useRef as bn}from"react";function kn(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}var wn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],An=3156e7;function Sn(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:An>t?e=>{const t=new Date(e);return`${wn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*An>t?e=>{const t=new Date(e);return`${wn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function _n(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:Xe(n.size)});else if("glyph"===n.type){const e=Fe(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as Tn}from"d3-shape";function Cn(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Pn(e,t,n,o,r,s){if(2>t.length)return;const i=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];i.push(i[e-1]+Math.sqrt(n*n+o*o))}const a=i[i.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=s;for(let n=0;t.length-1>n;n++){const o=(i[n]+i[n+1])/2;let s=r;l>o&&(s*=o/l),l>a-o&&(s*=(a-o)/l),e.globalAlpha=Math.max(0,s),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var Rn=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",s=qe(e,r)||r,i=t.style.strokeWidth||2,a=t.colorThresholds,l=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=i,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Pn(e,t.path,s,i,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=N(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=s;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){let n=function(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),d=!0},o=function(){d&&(e.stroke(),d=!1)},r=null,i=null,c=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,f]=t.path[d],p=l[d],y=Cn(p,a,s);if(null!==r&&null!==u&&null!==c){if(y===u)e.lineTo(h,f);else{const t=[];for(const e of a){const n=e.value;(c>n||n>p)&&(n>c||p>n)||c===n||p===n||t.push({t:(n-c)/(p-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=r+(h-r)*l.t,u=i+(f-i)*l.t,d=Cn(c+(p-c)*Math.min(l.t+1e-4,1),a,s);e.lineTo(t,u),o(),n(d,t,u)}e.lineTo(h,f)}r=h,i=f,c=p,u=y}else n(y,h,f),r=h,i=f,c=p,u=y}o()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?x(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||s,c)Tn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=M(e,t.style.fill,t.style.fill),c&&!u)Tn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Mn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Nn(e,t,n=.3){Mn(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function In(e,t,n=.6){if(!Mn(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,s=t.cy??t.y??0;e.beginPath(),e.arc(r,s,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Dn(e,t,n,o=.35){Mn(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as En,line as Wn}from"d3-shape";function zn(e,t){const n=N(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=En().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}var Bn=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const s=M(e,t.style.fill,"#4e79a7"),i=t._decayOpacities;if(i&&i.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=s;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(i[o]+i[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(i[n]+i[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(zn(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=b(e,t.fillGradient,"string"==typeof s?s:"#4e79a7",0,n,0,o);e.fillStyle=r||s,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=s;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(zn(e,t),Dn(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?x(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=N(t.curve);if(e.beginPath(),o)Wn().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Ln=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=M(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=M(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),In(e,n)}finally{e.restore()}}},On=new Map;function Hn(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=On.get(t);return n||(n=new Path2D(Ye(e.symbolType,e.size)),On.size>256&&On.clear(),On.set(t,n)),n}catch{return null}}var Fn=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Hn(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=M(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=M(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function jn(e,t,n,o,r){if(0>=t.size)return;const s=t.glyph;if(!s||!s.parts?.length)return;const i=je(s,t.size);if(0>=i.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=M(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(i.offsetX,i.offsetY),e.scale(i.scale,i.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=He(s,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Oe(e,s,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Oe(e,s,c,t.accent,void 0,l),e.restore()}function $n(e,t){const{x:n,y:o,w:r,h:s}=t,{tl:i,tr:a,br:l,bl:c}=he(t);e.beginPath(),e.moveTo(n+i,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),e.lineTo(n+r,o+s-l),l>0&&e.arcTo(n+r,o+s,n+r-l,o+s,l),e.lineTo(n+c,o+s),c>0&&e.arcTo(n,o+s,n,o+s-c,c),e.lineTo(n,o+i),i>0&&e.arcTo(n,o,n+i,o,i),e.closePath()}function Yn(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var Xn=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Vn(e,t);else if(t.cornerRadii&&ve(t.cornerRadii)){const n=M(e,t.style.fill,qe(e,"var(--semiotic-primary, #007bff)")),o=Yn(t),r=t.fillGradient&&"string"==typeof n?b(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,$n(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=M(e,t.style.fill,qe(e,"var(--semiotic-primary, #007bff)")),o=Yn(t),r=t.fillGradient&&"string"==typeof n?b(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const s=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:i,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(i,a),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i,a+c);break;case"left":e.moveTo(i+l,a),e.lineTo(i+s,a),e.arcTo(i,a,i,a+s,s),e.lineTo(i,a+c-s),e.arcTo(i,a+c,i+s,a+c,s),e.lineTo(i+l,a+c);break;case"bottom":e.moveTo(i,a),e.lineTo(i+l,a),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i+s,a+c),e.arcTo(i,a+c,i,a+c-s,s);break;default:e.moveTo(i,a+c),e.lineTo(i,a+s),e.arcTo(i,a,i+s,a,s),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=M(e,t.style.fill,qe(e,"var(--semiotic-primary, #007bff)")),o=Yn(t),r=t.fillGradient&&"string"==typeof n?b(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Nn(e,t),e.globalAlpha=1}};function Vn(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=r+o,i=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=s)e.drawImage(n,i,o,r,r)}else{const s=r+o,i=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,i,r,r)}e.restore()}function Gn(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function qn(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Un=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=qe(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Nn(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):qn(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,s=t.y+t.h/2;e.fillStyle=Gn(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,s)}}}finally{e.restore()}},Qn=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const s=qe(e,t.wickColor)||t.wickColor,i=60>o.height,a=i?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=s,e.lineWidth=a,e.stroke()};if(i||l(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=s,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,s=qe(e,r)||r;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}i&&l(),e.restore()}},Kn={line:[Bn,Rn,Ln],area:[Bn,Ln],stackedarea:[Bn,Ln],scatter:[Ln,Fn],bubble:[Ln,Fn],heatmap:[Un],bar:[Xn],swarm:[Ln],waterfall:[(e,t,n,o)=>{Xn(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const s=r[0].datum,i=s?._connectorStroke;if(i){e.save(),e.strokeStyle=qe(e,i)||i,e.lineWidth=s?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],s=r[t+1],i=o.datum,a=s.datum;if(null==i?.cumEnd||null==a?.baseline)continue;const l=n.y(i.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Qn],mixed:[Bn,Rn,Ln],custom:[Bn,Xn,Un,Rn,Ln,Fn,(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&jn(e,o,o.x,o.y,n);e.globalAlpha=n},Qn]};import{jsx as Jn,jsxs as Zn}from"react/jsx-runtime";import{jsx as eo,jsxs as to}from"react/jsx-runtime";function no(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function oo({hover:e}){const t=e.data??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=$(t);if(null!=e.title||e.entries.length>0)return to("div",{className:"semiotic-tooltip",style:H,children:[null!=e.title&&eo("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>to("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",eo("span",{style:{fontWeight:600},children:no(e.value)})]},e.key))]})}return to("div",{className:"semiotic-tooltip",style:H,children:[eo("div",{style:{fontWeight:600,marginBottom:2},children:no(n)}),eo("div",{style:{opacity:.7,fontSize:11},children:no(o)})]})}oo.ownsChrome=!0;import{useCallback as ro}from"react";import{useCallback as so,useRef as io}from"react";function ao(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}function lo(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}function co(e,t,n){const{group:o,indexInGroup:r}=t,s=n.byGroup.get(o);switch(e){case"ArrowRight":return s.length-1>r?s[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?s[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?uo(n,n.groups[e+1],s[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?uo(n,n.groups[e-1],s[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.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}}function uo(e,t,n){const o=e.byGroup.get(t);let r=0,s=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);s>t&&(s=t,r=e)}return o[r]._flatIndex}function ho(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.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 e=Fe(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.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":t.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 t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function fo(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as po,jsxs as yo}from"react/jsx-runtime";var go={top:20,right:20,bottom:30,left:40},mo=gn;function vo(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var xo=st(rt(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:s,chunkSize:i,xAccessor:a,yAccessor:l,accessorRevision:y,colorAccessor:x,sizeAccessor:b,symbolAccessor:w,symbolMap:A,groupAccessor:T,lineDataAccessor:C,curve:P,normalize:R,baseline:M,stackOrder:N,binSize:I,valueAccessor:L,arrowOfTime:H="right",windowMode:$="sliding",windowSize:Y=200,timeAccessor:V,xExtent:G,yExtent:q,extentPadding:U=.1,scalePadding:Q,sizeRange:J,size:Z=[500,300],responsiveWidth:ne,responsiveHeight:oe,margin:re,className:se,background:ie,renderMode:ae,lineStyle:le,pointStyle:ce,areaStyle:ue,barStyle:de,waterfallStyle:he,swarmStyle:fe,barColors:pe,colorScheme:ve,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:_e,lineGradient:Te,areaGroups:Pe,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:De,showAxes:We=!0,axes:ze,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:He,yFormat:Fe,axisExtent:je,tickFormatTime:$e,tickFormatValue:Ye,hoverAnnotation:Xe,tooltipContent:Ve,customHoverBehavior:qe,customClickBehavior:rt,onObservation:st,annotationObservationCallback:it,chartId:at,enableHover:lt,hoverRadius:ct=30,tooltipMode:ht,annotations:pt,onAnnotationActivate:yt,autoPlaceAnnotations:vt,svgAnnotationRules:xt,showGrid:bt,legend:St,legendHoverBehavior:_t,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,legendCategoryAccessor:Nt,onCategoriesChange:It,backgroundGraphics:Et,foregroundGraphics:Wt,canvasPreRenderers:zt,svgPreRenderers:Bt,title:Ht,categoryAccessor:jt,brush:$t,onBrush:Yt,decay:Xt,pulse:Vt,transition:Gt,animate:qt,staleness:Ut,frameScheduler:Qt,clock:Kt,random:Jt,seed:Zt,paused:en=!1,suspendWhenHidden:tn=!0,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:an,heatmapValueFormat:ln,marginalGraphics:un,pointIdAccessor:hn,xScaleType:fn,yScaleType:pn,accessibleTable:wn=!0,description:An,summary:Tn,linkedCrosshairName:Cn,linkedCrosshairSourceId:Pn,customLayout:Rn,onLayoutError:Mn,layoutConfig:Nn,layoutSelection:In}=e,{customHoverBehavior:Dn,customClickBehavior:En,hasClickBehavior:Wn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:ro((t,s)=>{e?.(t,s),ge({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:s})},[o,r,e,n]),customClickBehavior:ro((e,s)=>{t?.(e,s),ye({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:s})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:qe,customClickBehavior:rt,onObservation:st,chartId:at,chartType:"StreamXYFrame"}),zn=ot().replace(/:/g,""),Bn=Ke(!1),Ln=Ke({w:-1,h:-1}),On=Ke(!1),Hn=D({sizeProp:Z,responsiveWidth:ne,responsiveHeight:oe,userMargin:re,marginDefault:go,title:Ht,legend:St,legendPosition:Rt,animate:qt,transitionProp:Gt,frameScheduler:Qt,clock:Kt,random:Jt,seed:Zt,paused:en,suspendWhenHidden:tn,themeDirtyRef:Bn}),Fn=W(),jn=B(),{reducedMotionRef:$n,responsiveRef:Yn,size:Xn,currentTheme:Vn,transition:Gn,introEnabled:qn,tableId:Un,rafRef:Qn,renderFnRef:Jn,scheduleRender:Zn,frameRuntime:eo}=Hn;let to=Hn.margin;if(un){const e=60,t={...Hn.margin};un.top&&e>t.top&&(t.top=e),un.bottom&&e>t.bottom&&(t.bottom=e),un.left&&e>t.left&&(t.left=e),un.right&&e>t.right&&(t.right=e),to=t}const no=Xn[0]-to.left-to.right,uo=Xn[1]-to.top-to.bottom,fo=et(()=>me(r),[r]),xo=Xe??lt,[bo,ko]=Je(0),wo=Ke(0),[Ao,So]=Je(null),_o=vn(Wt,Xn,to,Ao),To=vn(Et,Xn,to,Ao),Co=Ke(null),Po=Ke(null),Ro=Ke(void 0),[Mo,No]=Je(null),Io=Ke(mo.primary),Do=Ke(function(){let e=-1,t=gn;return{resolve(n){if(!n)return gn;const o=Ge();return o===e||(t=function(e){if(!e)return gn;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),s=t.getPropertyValue("--semiotic-primary").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=r||t.getPropertyValue("--surface-0").trim();return i||a||n||s?{axisStroke:l||gn.axisStroke,tickText:i||gn.tickText,crosshair:i?mn(i,"66"):gn.crosshair,hoverFill:c?mn(c,"4D"):gn.hoverFill,hoverStroke:i?mn(i,"99"):gn.hoverStroke,pointRing:c||gn.pointRing,primary:s||gn.primary,background:c||gn.background}:gn}(n),e=o),t},invalidate(){e=-1}}}()),Eo=Ke(!1),Wo=z("StreamXYFrame"),[zo,Bo]=Je(!1),[Lo,Oo]=Je([]),[Ho,Fo]=Je([]),jo="streaming"===o||["bar","swarm","waterfall"].includes(n),$o=dn(et(()=>({chartType:n,runtimeMode:jo?"streaming":"bounded",windowSize:Y,windowMode:$,arrowOfTime:jo?H:"right",extentPadding:U,scalePadding:Q,axisExtent:je,xAccessor:a,yAccessor:l,accessorRevision:y,timeAccessor:jo?V:void 0,valueAccessor:L,colorAccessor:x,sizeAccessor:b,symbolAccessor:w,symbolMap:A,groupAccessor:T||(C?"_lineGroup":void 0),categoryAccessor:jt,lineDataAccessor:C,xScaleType:fn,yScaleType:pn,xExtent:G,yExtent:q,sizeRange:J,binSize:I,normalize:R,baseline:M,stackOrder:N,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:!0===_e?{topOpacity:.8,bottomOpacity:.05}:!1===_e?void 0:_e,areaGroups:Pe?new Set(Pe):void 0,lineGradient:Te,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:De,lineStyle:le,pointStyle:ce,areaStyle:ue,swarmStyle:fe,waterfallStyle:he,colorScheme:ve,barColors:pe,barStyle:de,annotations:pt,decay:Xt,pulse:Vt,transition:Gn,introAnimation:qn,staleness:Ut,clock:eo.now,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:an,heatmapValueFormat:ln,pointIdAccessor:hn,curve:P,themeCategorical:Vn?.colors?.categorical,themeSemantic:Ue(Vn),themeSequential:Vn?.colors?.sequential,themeDiverging:Vn?.colors?.diverging,customLayout:Rn,onLayoutError:Mn,layoutConfig:Nn,layoutMargin:to}),[n,jo,Y,$,H,U,Q,je,a,l,y,V,L,x,b,w,A,T,C,jt,fn,pn,G,q,J,I,R,M,N,ke,we,Ae,Se,_e,Pe,Te,Re,Me,Ne,Ie,De,le,ce,ue,fe,he,ve,pe,de,pt,Xt,Vt,Gn,qn,Ut,eo.now,nn,on,rn,an,ln,hn,P,Vn,Rn,Mn,Nn,to])),Yo=Ke(null);Yo.current||(Yo.current=new X($o));const Xo=function(e,t,n,o){const r=bn({accessor:t,onChange:n,readData:o}),s=bn([]);return r.current={accessor:t,onChange:n,readData:o},xn(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const i=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const s=e+"";n.has(s)||(n.add(s),o.push(s))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i,s.current)||(s.current=i,n(i))},[e])}(Yo,Nt,It,e=>e.getData());gt(Yo,$o,Bn,Zn),mt(Yo,In,Bn,Zn);const Vo=Ke(null);Vo.current||(Vo.current=new dt(e=>{const t=Yo.current;t&&t.ingest(e)&&(Bn.current=!0,Zn())},{chunkThreshold:s,chunkSize:i})),Ze(()=>{Vo.current?.updateChunkOptions({chunkThreshold:s,chunkSize:i})},[s,i]);const Go=tt(e=>{Vo.current?.push(e)},[]),qo=tt(e=>{Vo.current?.pushMany(e)},[]),Uo=tt(()=>{Vo.current?.clear(),Yo.current?.clear(),Bn.current=!0,Zn()},[Zn]);nt(t,()=>({push:Go,pushMany:qo,remove:e=>{Vo.current?.flush();const t=Yo.current?.remove(e)??[];return t.length>0&&(Co.current&&t.some(e=>e===Co.current?.data)&&(Co.current=null,No(null)),Bn.current=!0,Zn()),t},update:(e,t)=>{Vo.current?.flush();const n=Yo.current?.update(e,t)??[];return n.length>0&&(Bn.current=!0,Zn()),n},clear:Uo,getData:()=>(Vo.current?.flush(),Yo.current?.getData()??[]),getScales:()=>Yo.current?.scales??null,getExtents:()=>Yo.current?.getExtents()??null,getCustomLayout:()=>Yo.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Yo.current?.lastCustomLayoutFailure??null}),[Go,qo,Uo,Zn]),Ze(()=>{if(r){if(C&&fo.length>0&&"object"==typeof fo[0]&&null!==fo[0]){const e="string"==typeof C?C:"coordinates";if(Array.isArray(fo[0][e])){const t=[];for(const n of fo){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void Vo.current?.setBoundedData(t)}}Vo.current?.setBoundedData(fo)}},[r,fo,C]);const{canvasRef:Qo,interactionCanvasRef:Ko}=E(Hn,{storeRef:Yo,dirtyRef:Bn,hydrated:Fn,wasHydratingFromSSR:jn,cleanup:()=>Vo.current?.clear(),canvasPaintDependencies:[n,no,uo,We,ie,Et,le,ae,zt,Zn]}),{hoverHandlerRef:Jo,hoverLeaveRef:Zo,onPointerMove:er,onPointerLeave:tr}=Hn;Jo.current=e=>{if(!xo)return;const t=Qo.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-to.left,s=e.clientY-o.top-to.top;if(0>r||r>no||0>s||s>uo)return void(Co.current&&(Co.current=null,Po.current=null,No(null),Dn&&(Dn(null),Bn.current=!0),Zn()));const i=Yo.current;if(!i||0===i.scene.length)return;const l=F(ct,e.pointerType),c=wt(i.scene,r,s,l,i.quadtree,i.maxPointRadius),u="multi"===ht,d=()=>{Co.current&&(Co.current=null,Po.current=null,No(null),Dn&&Dn(null),Zn())};if(!c&&!u)return void d();const h=u||!c?r:c.x,f=u||!c?s:c.y,p=c?.datum?K(c.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=O(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const s=At(kt(e.path,e.curve),t,n);if(null===s)continue;const i=Dt(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:e.path[i][0],y:s,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const s=kt(e.topPath,e.curve),i=kt(e.bottomPath,e.curve),a=At(s,t,n);if(null===a)continue;const l=At(i,t,n),c=Dt(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:l??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,h,Math.max(l,no));if(e.length>0){const t=i.scales.y.invert,o=Io.current,r=y?y(h):h;if(c)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=O(e,h,f,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,s=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=s?r-s:r,valuePx:e.y,color:e.color||o,datum:K(e.datum,i.resolvedRibbons)}})}}c||m.allSeries?.length?(Co.current=m,Po.current=c?.node??null,No(m),Dn&&(Dn(m),Bn.current=!0),Zn()):d()},Zo.current=()=>{Co.current&&(Co.current=null,Po.current=null,No(null),Dn&&(Dn(null),Bn.current=!0),Zn())};const nr=Ke(()=>{});nr.current=e=>{if(j(e.target))return;if(!En)return;const t=Qo.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-to.left,r=e.clientY-n.top-to.top;if(0>o||o>no||0>r||r>uo)return void En(null);const s=Yo.current;if(!s||0===s.scene.length)return void En(null);const i=F(ct,Ro.current),a=wt(s.scene,o,r,i,s.quadtree,s.maxPointRadius);if(!a)return void En(null);const l=a.datum||{},c=s.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;En(O(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:Ce(Ro.current)})};const or=tt(e=>nr.current(e),[]),{kbFocusIndexRef:rr,focusedNavPointRef:sr,onKeyDown:ir}=(ur={storeRef:Yo,hoverRef:Co,hoveredNodeRef:Po,setHoverPoint:No,customHoverBehavior:Dn,customClickBehavior:En,scheduleRender:Zn},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:s,scheduleRender:i,extractPoints:a,toHover:l}){const c=io(-1),u=io(null),d=io(null),h=so(h=>{if(xe(h))return;const f=e.current;if(!f)return;const p=()=>{c.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),i()};if(0===f.scene.length)return void(0>c.current||p());let y;if(d.current?.version===f.version)y=d.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>c.current||p());y=ao(e),d.current={version:f.version,graph:y}}let g=c.current;if(y.flat.length>g||(p(),g=-1),("Enter"===h.key||" "===h.key)&&g>=0)return h.preventDefault(),void s(l(y.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),c.current=0;const e=y.flat[0];u.current=e;const n=l(e,f);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void i()}const m=co(h.key,lo(y,g),y);if(null===m)return;if(h.preventDefault(),0>m)return void p();c.current=m;const v=y.flat[m];u.current=v;const x=l(v,f);t.current=x,o(x),r(x,{type:"focus",inputType:"keyboard"}),i()},[s,r,a,t,n,i,o,e,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:h}}({...ur,extractPoints:ho,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:K(e.datum,t.resolvedRibbons)})})),ar=tt(e=>{Ro.current=e.pointerType,rr.current=-1,sr.current=null,er(e)},[sr,rr,er]),lr=tt(e=>{Ro.current="mouse",rr.current=-1,sr.current=null,er({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[sr,rr,er]),cr=tt(e=>{Ro.current=e.pointerType},[]);var ur;Jn.current=()=>{if(Qn.current=null,!eo.isActive)return;const e=Qo.current,t=Ko.current;if(!e||!t)return;const o=Yo.current;if(!o)return;const r=eo.now(),s=o.advanceTransition($n.current?r+1e6:r),i=!$n.current&&s,c=Ln.current.w!==no||Ln.current.h!==uo,u=Bn.current||s||c,d=o.consumeStylePaintPending();let h=!1;const f=o.getLastUpdateResult(),p=Wo.current.beforeCompute(f,i);!u||i&&!c||(o.computeScene({width:no,height:uo}),Ln.current={w:no,h:uo},h=!0,Xo()),Wo.current.afterCompute(p,h,c);const y=function(e,t,n,o){const r=o.current,s=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,i=!s&&e.hasActivePulsesAt(t),a=!(n||s||!i&&!r)&&e.refreshPulse(t);return o.current=i,{changed:a,pending:i}}(o,r,h,On),g=S(),m=Do.current.resolve(e);Io.current=m.primary;const v=Lt(Ut,o.lastIngestTime>0?r-o.lastIngestTime:0),x=Ut&&v.isStale;if(u||d||y.changed){const t=_(e,Xn,to,g);if(t){if(t.clearRect(-to.left,-to.top,Xn[0],Xn[1]),Ut&&1>v.alpha&&(t.globalAlpha=v.alpha),yn(t,{background:ie,hasBackgroundGraphics:!!Et,themeBackground:m.background,x:-to.left,y:-to.top,width:Xn[0],height:Xn[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,no,uo),t.clip()),zt&&o.scales)for(const e of zt)t.save(),e(t,o.scene,o.scales,{width:no,height:uo}),t.restore();const e=Rn?Kn.custom:Kn[n];ee({context:t,nodes:o.scene,renderMode:ae,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:no,height:uo})}}),t.restore(),Ut&&1>v.alpha&&(t.globalAlpha=1)}}const b=!!(xo&&Co.current&&o.scales),w=!!(Po.current&&Array.isArray(Xe)&&Xe.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),A=b||w;if(A||Eo.current){const e=_(t,Xn,to,g);if(e&&(e.clearRect(-to.left,-to.top,Xn[0],Xn[1]),b&&Co.current&&function(e,t,n,o,r,s,i){if(!1===r.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||i.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(l?c:t.x,0),e.lineTo(l?c:t.x,o),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=i.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||i.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(s)||i.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=i.pointRing,e.lineWidth=2,e.stroke()}}(e,Co.current,no,uo,"object"==typeof xo?xo:{},Po.current,m),w&&Po.current&&Array.isArray(Xe))){const t=Xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,Po.current,t,m)}Eo.current=A}u&&e&&e.setAttribute("aria-label",k(o.scene,n+" chart"));const T=Bn.current;if(Bn.current=T&&i&&!h,T&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Ao||e(Ao.x.domain()[0])!==e(o.scales.x.domain()[0])||e(Ao.x.domain()[1])!==e(o.scales.x.domain()[1])||e(Ao.y.domain()[0])!==e(o.scales.y.domain()[0])||e(Ao.y.domain()[1])!==e(o.scales.y.domain()[1])||Ao.x.range()[0]!==o.scales.x.range()[0]||Ao.x.range()[1]!==o.scales.x.range()[1]||Ao.y.range()[0]!==o.scales.y.range()[0]||Ao.y.range()[1]!==o.scales.y.range()[1])&&So(o.scales),un){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];Oo(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Fo(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((pt&&pt.length>0||Rn)&&(h||i))||!h&&33>r-wo.current||(ko(e=>e+1),wo.current=r),Ut?.showBadge&&Bo(!!x),(i||null!=o.activeTransition||y.pending)&&Zn()},Ot(Ut,Yo,Bn,Zn,zo,Bo);const dr=et(()=>{if(He||$e)return;const e=Yo.current;return e?.xIsDate&&Ao?Sn(Ao.x.domain()):void 0},[He,$e,Ao]),hr=He||$e||dr,fr=xo&&Mo?Ve?Ve(Mo):po(oo,{hover:Mo}):null,pr=fr?po(f,{x:Mo.x,y:Mo.y,containerWidth:no,containerHeight:uo,margin:to,className:"stream-frame-tooltip",children:fr}):null,yr=sr.current,gr=po(p,{active:rr.current>=0,hoverPoint:Mo,margin:to,size:Xn,shape:yr?.shape,width:yr?.w,height:yr?.h}),mr=kn(a,V,"__semiotic_resolvedX","__semiotic_resolvedTime"),vr=kn(l,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),xr=mr.key,br=vr.key,kr=function(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const s=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),s=t.fn&&t.key&&!(t.key in n);if(!o&&!s)return n;r=!0;const i={...n};return o&&(i[e.key]=e.fn(n)),s&&(i[t.key]=t.fn(n)),i});return r?s:o}}(mr,vr,pt&&pt.length>0||!1);if(be||!Fn&&jn){const e=Yo.current;e&&r&&(e.ingest({inserts:fo,bounded:!0}),e.computeScene({width:no,height:uo}));const t=e?.scene??[],n=e?.scales??null,o=vn(Wt,Xn,to,n),s=vn(Et,Xn,to,n),i=hr||(()=>{if(e?.xIsDate&&n)return Sn(n.x.domain())})();return yo("div",{ref:Yn,className:"stream-xy-frame"+(se?" "+se:""),role:"img","aria-label":An||("string"==typeof Ht?Ht:"XY chart"),style:{position:"relative",width:ne?"100%":Xn[0],height:oe?"100%":Xn[1]},children:[po(m,{summary:Tn}),yo("svg",{xmlns:"http://www.w3.org/2000/svg",width:Xn[0],height:Xn[1],style:{position:"absolute",left:0,top:0},children:[po("g",{transform:`translate(${to.left},${to.top})`,children:s}),yo("g",{transform:`translate(${to.left},${to.top})`,children:[ie&&po("rect",{x:0,y:0,width:no,height:uo,fill:ie}),Bt&&n&&Bt.map((e,o)=>po(Qe.Fragment,{children:e(t,n,{width:no,height:uo})},"svgpre-"+o)),t.map((e,t)=>te({node:e,index:t,renderMode:ae,fallback:()=>Ee(e,t,zn)})).filter(Boolean)]})]}),po(cn,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,scales:n,showAxes:We,axes:ze,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:i,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Ht,legend:St,legendHoverBehavior:_t,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:ft(o,c(Yo.current?.customLayoutOverlays,In??null)),marginalGraphics:un,xValues:[],yValues:[],annotations:pt,onAnnotationActivate:yt,onObservation:it??st,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:vt,svgAnnotationRules:xt,annotationFrame:0,xAccessor:xr,yAccessor:br,annotationData:kr(Yo.current?.getData()),pointNodes:_n(Yo.current?.scene),curve:"string"==typeof P?P:void 0,linkedCrosshairName:Cn,linkedCrosshairSourceId:Pn})]})}return yo("div",{ref:Yn,className:"stream-xy-frame"+(se?" "+se:""),role:"group","aria-label":An||("string"==typeof Ht?Ht:"XY chart"),tabIndex:0,style:{position:"relative",width:ne?"100%":Xn[0],height:oe?"100%":Xn[1],overflow:"visible",touchAction:vo($t)},onKeyDown:ir,children:["production"!==process.env.NODE_ENV&&Yo.current&&po(g,{store:Yo.current,diagnostics:Wo.current}),wn&&po(v,{tableId:Un}),wn&&po(u,{scene:Yo.current?.scene??[],chartType:n+" chart",tableId:Un,chartTitle:"string"==typeof Ht?Ht:void 0}),po(m,{summary:Tn}),po(d,{hoverPoint:Mo}),yo("div",{role:"img","aria-label":An||("string"==typeof Ht?Ht:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:xo?ar:void 0,onMouseMove:xo?lr:void 0,onPointerLeave:xo?tr:void 0,onMouseLeave:xo?tr:void 0,onPointerDown:xo||Wn?cr:void 0,onClick:Wn?or:void 0,children:[po(h,{size:Xn,margin:to,children:To}),po(sn,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,scales:Ao,showAxes:We,axes:ze,showGrid:bt,xFormat:hr,yFormat:Fe||Ye,axisExtent:je}),po("canvas",{ref:Qo,"aria-label":k(Yo.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),po("canvas",{ref:Ko,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),po(cn,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,scales:Ao,showAxes:We,axes:ze,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:hr,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Ht,legend:St,legendHoverBehavior:_t,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:ft(_o,c(Yo.current?.customLayoutOverlays,In??null)),marginalGraphics:un,xValues:Lo,yValues:Ho,annotations:pt,onAnnotationActivate:yt,onObservation:it??st,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:vt,svgAnnotationRules:xt,annotationFrame:bo,xAccessor:xr,yAccessor:br,annotationData:kr(Yo.current?.getData()),pointNodes:_n(Yo.current?.scene),curve:"string"==typeof P?P:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==ie&&!Et,linkedCrosshairName:Cn,linkedCrosshairSourceId:Pn}),($t||Yt)&&po(ut,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,dimension:$t?.dimension??"xy",scales:Ao,onBrush:Yt??(()=>{}),binSize:I,snap:$t?.snap,binBoundaries:$t?.binBoundaries??("bar"===n?Yo.current?.getBinBoundaries():void 0),snapDuring:$t?.snapDuring,streaming:"streaming"===o}),Ut?.showBadge&&po(Ft,{isStale:zo,position:Ut.badgePosition}),gr,pr]})]})}));xo.displayName="StreamXYFrame";var bo=xo;import{useRef as ko,useState as wo,useEffect as Ao,useMemo as So,useCallback as _o,useImperativeHandle as To,forwardRef as Co,memo as Po}from"react";var Ro={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Mo={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},No=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const o=this.particles[n];return o.active=!0,o.t=0,o.offset=t()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const i=n[s.edgeIndex];i&&i.bezier?(s.t+=e*t*(o?o[s.edgeIndex]??1:1)*(i.bezier.circular?.3:1),1>s.t?Io(i.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function Io(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const s=e.length,i=t*s,a=Math.min(Math.floor(i),s-1),l=i-a,[c,u,d,h]=e[a];Do(c,u,d,h,l,r);const f=h.x-c.x,p=h.y-c.y,y=Math.sqrt(f*f+p*p);if(y>.001){const e=f/y;r.x+=-p/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,s,i,a]=e.points;Do(r,s,i,a,t,o);const l=a.x-r.x,c=a.y-r.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;o.x+=-c/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function Do(e,t,n,o,r,s){const i=1-r,a=i*i,l=a*i,c=r*r,u=c*r;s.x=l*e.x+3*a*r*t.x+3*i*c*n.x+u*o.x,s.y=l*e.y+3*a*r*t.y+3*i*c*n.y+u*o.y}import{quadtree as Eo}from"d3-quadtree";function Wo(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function zo(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Bo(e))return!1;return!0}return Bo(t.points)}function Bo(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as Lo}from"d3-interpolate";var Oo="rgba(34, 197, 94, 0.7)",Ho=2e3,Fo=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jo=["scene-style","data-paint","accessibility","evidence"],$o=(e,t)=>({retainedData:e,invalidations:t}),Yo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vo=["scene-geometry","data-paint","overlay","accessibility","evidence"],Go=["scene-style","data-paint","accessibility","evidence"],qo=["scene-geometry","data-paint","overlay","accessibility","evidence"],Uo=[],Qo={chartType:$o("rebuild",Yo),nodeIDAccessor:$o("rebuild",Yo),sourceAccessor:$o("rebuild",Yo),targetAccessor:$o("rebuild",Yo),valueAccessor:$o("rebuild",Yo),edgeIdAccessor:$o("rebuild",Yo),childrenAccessor:$o("rebuild",Yo),hierarchySum:$o("rebuild",Yo),orientation:$o("preserve",Xo),nodeAlign:$o("preserve",Xo),nodePaddingRatio:$o("preserve",Xo),nodeWidth:$o("preserve",Xo),edgeSort:$o("preserve",Xo),iterations:$o("preserve",Xo),forceStrength:$o("preserve",Xo),padAngle:$o("preserve",Xo),groupWidth:$o("preserve",Xo),sortGroups:$o("preserve",Xo),treeOrientation:$o("preserve",Xo),edgeType:$o("preserve",Xo),padding:$o("preserve",Xo),paddingTop:$o("preserve",Xo),orbitMode:$o("preserve",Xo),orbitSize:$o("preserve",Xo),orbitSpeed:$o("preserve",Xo),orbitRevolution:$o("preserve",Xo),orbitRevolutionStyle:$o("preserve",Xo),orbitEccentricity:$o("preserve",Xo),orbitShowRings:$o("preserve",Xo),orbitAnimated:$o("preserve",Xo),customNetworkLayout:$o("preserve",Xo),layoutConfig:$o("preserve",Xo),nodeSize:$o("preserve",Vo),nodeSizeRange:$o("preserve",Vo),colorByDepth:$o("preserve",Vo),nodeLabel:$o("preserve",qo),showLabels:$o("preserve",qo),labelMode:$o("preserve",qo),nodeStyle:$o("preserve",Go),edgeStyle:$o("preserve",Go),colorBy:$o("preserve",Go),colorScheme:$o("preserve",Go),themeCategorical:$o("preserve",Go),themeSemantic:$o("preserve",Go),edgeColorBy:$o("preserve",Go),edgeOpacity:$o("preserve",Go),showParticles:$o("preserve",Go),particleStyle:$o("preserve",Go),decay:$o("preserve",Go),pulse:$o("preserve",Go),thresholds:$o("preserve",Go),staleness:$o("preserve",Go),layoutSelection:$o("preserve",Go),clock:$o("preserve",Uo),random:$o("preserve",Uo),seed:$o("preserve",Uo),tensionConfig:$o("preserve",Uo),transition:$o("preserve",Uo),introAnimation:$o("preserve",Uo),onLayoutError:$o("preserve",Uo),__skipForceSimulation:$o("preserve",Uo),__hierarchyRoot:$o("preserve",Uo),__orbitState:$o("preserve",Uo),__previousPositions:$o("preserve",Uo)},Ko=$o("preserve",Xo),Jo=class{constructor(){this.tracker=new Be}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Fo)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},jo):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Qo[o]??Ko;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Zo=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Jo,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...Ro,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new No(2e3))}currentTime(){return this.config.clock?.()??Te()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const o=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...Ro,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new No(2e3)),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,o){const{nodeIDAccessor:r="id",sourceAccessor:s="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof r?r:e=>e[r],c="function"==typeof s?s:e=>e[s],u="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...Wo(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],o=c(n)+"",r=u(n)+"",s=d(n),i=null==s?NaN:Number(s),a=Number.isFinite(i)?i:1;this.nodes.has(o)||this.nodes.set(o,{...Wo(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...Wo(r),data:n});const l=`${o}\0${r}\0${e}`,h={source:o,target:r,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&zo(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}o?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,o){return this.ingestBounded(e,t,n,o),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let s=!1;const i=this.currentTime();this.lastIngestTime=i,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Wo(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,s=!0),this.nodes.has(n)||(this.nodes.set(n,Wo(n)),this.nodeTimestamps.set(n,i),this.tension+=this.tensionConfig.newNode,s=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;l?(l.value+=o,this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.newEdge,s=!0);const u=r||s||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=J(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,o,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;o.length>e;e++){const t=o[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const r=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||r.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=r,this.saveTargetPositions();const s=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),i=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&i>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i}}else s&&i>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:o,baseStyles:r,selection:s}){const i=!(!n&&!o);if(n)for(const t of e){const e=r.get(t)??t.style,o=n(t,s);t.style=o?{...e,...o}:e}if(o)for(const e of t){const t=r.get(e)??e.style,n=o(e,s);e.style=n?{...t,...n}:t}return i}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:o,edges:r,previousResult:s,revision:i}){const a=Pe(e.colorScheme,e.themeCategorical,$e),l={nodes:o,edges:r,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:de(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==s,o=U("network",t,n,i);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:o,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void se({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=J(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:r,sceneEdges:s,labels:i}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=s,this.labels=i,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const o=Array(t);let r=0;for(const e of this.sceneNodes)"circle"===e.type&&(o[r++]=e);this._nodeQuadtree=Eo().x(e=>e.cx).y(e=>e.cy).addAll(o)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=J(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=J(this.config.chartType);if(!n?.tick)return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=pe(e,this.transition),n=fe(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ke(e._prevX0,e._targetX0,n),e.x1=ke(e._prevX1,e._targetX1,n),e.y0=ke(e._prevY0,e._targetY0,n),e.y1=ke(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=ke(e._prevY0,e._targetY0,n),e.y1=ke(e._prevY1,e._targetY1,n),e.sankeyWidth=ke(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const o="string"==typeof e.source?t.get(e.source):e.source,r="string"==typeof e.target?t.get(e.target):e.target;!o||!r||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],s=n.x-t.x,i=n.y-t.y;r.push([t,{x:t.x+s/3,y:t.y+i/3},{x:t.x+2*s/3,y:t.y+2*i/3},n])}return{circular:!0,segments:r,halfWidth:t}}(e):function(e,t,n,o=.5){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const s=t.x1,i=n.x0,a=Lo(s,i);return{circular:!1,points:[{x:e.y0,y:s},{x:e.y0,y:a(o)},{x:e.y1,y:a(1-o)},{x:e.y1,y:i}],halfWidth:r}}const s=t.x1,i=n.x0,a=Lo(s,i);return{circular:!1,points:[{x:s,y:e.y0},{x:a(o),y:e.y0},{x:a(1-o),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}(e,o,r,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,o=t.color??"rgba(255,255,255,0.6)",r=t.glowRadius??4,{now:s}=e;for(const t of e.sceneNodes){const i=t.id;if(!i)continue;const a=e.nodeTimestamps.get(i);if(!a)continue;const l=s-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=o,t._pulseGlowRadius=r)}for(const t of e.sceneEdges){const r=t.datum;if(!r)continue;const i="object"==typeof r.source?r.source?.id:r.source,a="object"==typeof r.target?r.target?.id:r.target;if(!i||!a)continue;const l=e.edgeTimestamps.get(`${i}\0${a}`);if(!l)continue;const c=s-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=o)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const o=e.cache.ageMap;for(const r of e.sceneNodes){const e=r.id;if(!e)continue;const s=o.get(e);if(void 0===s)continue;const i=q(t,s,n);r.style={...r.style,opacity:(r.style?.opacity??1)*i}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===Oo&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=Ho)return;const n=1-t/Ho;for(const t of e.sceneNodes){const o=t.id;o&&e.addedNodes.has(o)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=Oo,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&Ho>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",o=t.criticalColor??"#ef4444",r=!1!==t.pulse;for(const s of e.sceneNodes){const i=s.id;if(!i)continue;const a=e.nodes.get(i);if(!a)continue;const l=t.metric(a);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=o,c&&(s.style={...s.style,fill:c},r&&(s._pulseIntensity=.6+.4*Math.sin(e.now/300),s._pulseColor=c,s._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const o=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),o}updateEdge(e,t,n){const o=this.config.valueAccessor,r="function"==typeof o?o:o?e=>e[o]:e=>e.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){s.push(o.data?{...o.data}:{}),o.data=n(o.data??{});const e=r(o.data);null!=e&&(o.value=Number(e))}return s.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",s.length)):this.updateResults.recordNoop("update"),s}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>e?.[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Zo.QUADTREE_THRESHOLD=500;var er=Zo;V(er);import*as tr from"react";import{Fragment as nr,jsx as or,jsxs as rr}from"react/jsx-runtime";function sr(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,labels:i,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:p,foregroundGraphics:y,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=e,_=Y({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k}),C=tr.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const o=Fe(e.glyph,e.size);return{x:t+o.centerDx,y:n+o.centerDy,r:Math.max(1,o.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Xe(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),R=tr.useMemo(()=>m&&w?Le({annotations:m,context:C,..."object"==typeof w?w:{}}):m,[m,w,C]),M=tr.useMemo(()=>A("network"),[]),N=R?T(R.filter(e=>"widget"!==e.type),M,S,C):null,I=!0===R?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return rr(nr,{children:[I&&or("style",{children:le},"annotation-widget-disclosure-style"),rr("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[or("title",{children:"string"==typeof a?a:"Network Chart"}),or("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),rr("g",{transform:`translate(${s.left},${s.top})`,children:[i.map((e,t)=>or("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),N,y]}),a&&"string"==typeof a?or("text",{x:o/2,y:ue,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?or("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,P({legend:l,totalWidth:o,totalHeight:r,margin:s,legendPosition:f,title:a,legendLayout:p,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),R?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,o=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!o)return null;const r=s.left+(o.cx??(null!=o.x&&null!=o.w?o.x+o.w/2:o.x??0)),i=s.top+(o.cy??(null!=o.y&&null!=o.h?o.y+o.h/2:o.y??0)),a=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??or("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return or("div",{...L(e,_),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:r+a-c/2,top:i+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}sr.displayName="NetworkSVGOverlay";import*as ir from"react";import{jsx as ar}from"react/jsx-runtime";var lr={position:"absolute",top:0,left:0,pointerEvents:"none"};function cr({marks:e,margin:t,selection:n=null,overscan:o=400}){const s=ir.useRef(null),i=function(e,t,n){const[o,r]=ir.useState(null);return ir.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:o}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${o} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void r(null);let o=0;const s=()=>{o=0;const t=n.getBoundingClientRect(),s=e.getBoundingClientRect();r(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:s.left,originY:s.top}:null)},i=()=>{0===o&&(o=window.requestAnimationFrame(s))};s(),n.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",i),a.disconnect()}},[t,e,n]),ir.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:s}=o,i=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=r+e.x,n=s+e.y;return!(i>t+e.width||t>a||l>n+e.height||n>c)})},[e,o,n])}(e,s,o);if(!e||0===e.length)return null;const a=ar("div",{className:"semiotic-network-html-marks",ref:s,style:{...lr,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>ar("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?ar(r,{value:n,children:a}):a}import{jsx as ur,jsxs as dr}from"react/jsx-runtime";function hr({props:e,store:t,responsiveRef:n,size:o,margin:r,adjustedWidth:s,adjustedHeight:i,resolvedBackground:a,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:f,className:p,description:y,title:g,responsiveWidth:v,responsiveHeight:x,summary:b,background:k,renderMode:w,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,layoutSelection:M,annotations:N,onAnnotationActivate:I,annotationObservationCallback:D,onObservation:E,chartId:W,autoPlaceAnnotations:z,svgAnnotationRules:B}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),n=e?f||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[s,i]),t.buildScene([s,i]);else{const e=me(d),n=Array.isArray(h)?me(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[s,i]),t.buildScene([s,i]))}}const L=t?.sceneNodes??[],O=t?.sceneEdges??[],H=t?.labels??[];return dr("div",{ref:n,className:"stream-network-frame"+(p?" "+p:""),role:"img","aria-label":y||("string"==typeof g?g:"Network chart"),style:{position:"relative",width:v?"100%":o[0],height:x?"100%":o[1]},children:[ur(m,{summary:b}),dr("svg",{xmlns:"http://www.w3.org/2000/svg",width:o[0],height:o[1],style:{position:"absolute",left:0,top:0},children:[a&&ur("g",{transform:`translate(${r.left},${r.top})`,children:a}),dr("g",{transform:`translate(${r.left},${r.top})`,children:[k&&ur("rect",{x:0,y:0,width:s,height:i,fill:k}),O.map((e,t)=>te({node:e,index:t,renderMode:w,fallback:()=>Ae(e,t)})).filter(Boolean),L.map((e,t)=>te({node:e,index:t,renderMode:w,fallback:()=>Se(e,t)})).filter(Boolean),H.map((e,t)=>we(e,t)).filter(Boolean)]})]}),ur(sr,{width:s,height:i,totalWidth:o[0],totalHeight:o[1],margin:r,labels:H,sceneNodes:L,title:g,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,foregroundGraphics:ft(l,c(t?.customLayoutOverlays,M??null)),annotations:N,onAnnotationActivate:I,onObservation:D??E,chartId:W,chartType:"StreamNetworkFrame",autoPlaceAnnotations:z,svgAnnotationRules:B,annotationFrame:0}),ur(cr,{marks:t?.customLayoutHtmlMarks,margin:r,selection:M??null})]})}import{jsx as fr,jsxs as pr}from"react/jsx-runtime";var yr=/^(value|amount|total|count|weight|score)$/i;function gr({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?pr("div",{className:"semiotic-tooltip",style:H,children:[pr("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&pr("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let o=n;for(;o;){const n=o.data?.name??o.data?.id??t.id;null!=n&&e.unshift(n+""),o=o.parent}e.length>1&&e.shift();const r=e.length-1;return pr("div",{className:"semiotic-tooltip",style:H,children:[fr("div",{children:e.map((e,t)=>pr("span",{children:[t>0&&fr("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?fr("strong",{children:e}):fr("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&fr("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const o=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),r=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),s=$(t.data??t),i=null!=s.title?s.title+"":t.id,a=s.entries.some(e=>yr.test(e.key));return pr("div",{className:"semiotic-tooltip",style:H,children:[fr("div",{style:{fontWeight:600},children:i}),s.entries.map(e=>{return pr("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&pr("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&pr("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function mr(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function vr(e,t){if(!t.pathD)return;e.save();const n=mr(t);if(t.style.fill&&"none"!==t.style.fill){const o=t._gradient;if(o){const n=e.createLinearGradient(o.x0,0,o.x1,0),r=t.style.fillOpacity??t.style.opacity??.5,s="string"==typeof t.style.fill?t.style.fill:"#999",i=qe(e,s)||s;n.addColorStop(0,1===o.from?i:"transparent"),n.addColorStop(1,1===o.to?i:"transparent"),e.fillStyle=n,e.globalAlpha=r}else e.fillStyle=M(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function xr(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=qe(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function br(e,t){if(!t.pathD)return;e.save();const n=mr(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function kr(e,t){if(!t.pathD)return;e.save();const n=mr(t),o=t.style.stroke||"#999";e.strokeStyle=qe(e,o)||o,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}gr.ownsChrome=!0;var wr=new Map;function Ar(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=wr.get(t);return n||(n=new Path2D(Ye(e.symbolType,e.size)),wr.size>256&&wr.clear(),wr.set(t,n)),n}catch{return null}}function Sr(e){const{sceneNodes:t,nodes:n,nodeColorMap:o,colorScheme:r}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&o.set(e.id,e.style.fill);const s=Array.isArray(r)?r:ce,i=Array.from(n);for(let e=0;i.length>e;e++){const t=i[e];o.has(t.id)||o.set(t.id,s[e%s.length])}return i.length}function _r(n,r,s,i=30){switch(n.type){case"circle":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"rect":return function(e,n,o){const r=t(n,o,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(n,r,s);case"arc":return function(e,t,n){const r=t-e.cx,s=n-e.cy,i=Math.sqrt(r*r+s*s);if(e.innerR-2>i||i>e.outerR+2)return null;const a=o(Math.atan2(s,r)),l=o(e.startAngle),c=o(e.endAngle);if(l>c?a>=l||c>=a:a>=l&&c>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(n,r,s);case"symbol":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(Xe(t.size),r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"glyph":return function(t,n,o,r=30){if(null==t.datum)return null;const s=Fe(t.glyph,t.size),i=t.cx+s.centerDx,a=t.cy+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{type:"node",datum:t.datum,x:i,y:a,distance:u}}(n,r,s,i);default:return null}}var Tr=null,Cr=null;function Pr(){return Cr||((Tr=document.createElement("canvas")).width=1,Tr.height=1,Cr=Tr.getContext("2d")),Cr}function Rr(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function Mr(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Rr(e),r=Pr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,s=o*o+r*r;if(0===s)return null;let i=((t-e.x1)*o+(n-e.y1)*r)/s;i=Math.max(0,Math.min(1,i));const a=e.x1+i*o,l=e.y1+i*r,c=Math.sqrt((t-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Rr(e),r=Pr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Nr(e){const{clientX:t,clientY:n,canvasRect:o,margin:r,adjustedWidth:s,adjustedHeight:i,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-o.left-r.left,f=n-o.top-r.top;if(0>h||h>s||0>f||f>i)return{kind:"miss-outside"};const p=function(e,t,n,o,r=30,s,i=0){let a=null,l=r,c=1/0;if(s){const e=vt(s,n,o,r,i,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(s&&"circle"===t.type)continue;const e=_r(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Mr(e,n,o);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,h,f,d,c,u);return p?{kind:"hit",hover:O(p.datum||{},p.x,p.y,{nodeOrEdge:p.type})}:{kind:"miss"}}import{useCallback as Ir}from"react";var Dr="StreamNetworkFrame";import{jsx as Er,jsxs as Wr}from"react/jsx-runtime";var zr={top:20,right:80,bottom:20,left:80},Br={top:40,right:40,bottom:40,left:40},Lr=new Set(["chord","force","circlepack","orbit"]),Or=[800,600],Hr=Po(Co(function(e,t){const{chartType:n,nodes:o,edges:r,data:u,initialEdges:x,nodeIDAccessor:b="id",sourceAccessor:k="source",targetAccessor:A="target",valueAccessor:T="value",edgeIdAccessor:C,childrenAccessor:P,hierarchySum:N,orientation:L="horizontal",nodeAlign:H="justify",nodePaddingRatio:F=.05,nodeWidth:$=15,iterations:Y=300,forceStrength:X=.1,layoutExecution:V="auto",layoutLoadingContent:G,onLayoutStateChange:q,padAngle:U=.01,groupWidth:Q=20,sortGroups:K,edgeSort:J,treeOrientation:Z="vertical",edgeType:te="curve",padding:ne,paddingTop:oe,tensionConfig:re,showParticles:se=!1,particleStyle:ie,renderMode:ae,nodeStyle:le,edgeStyle:ue,colorBy:de,colorScheme:he="category10",edgeColorBy:fe="source",edgeOpacity:pe=.5,colorByDepth:ve=!1,nodeSize:ke=8,nodeSizeRange:we=[5,20],nodeLabel:Ae,showLabels:Se=!0,labelMode:_e,size:Te=Or,responsiveWidth:Pe,responsiveHeight:Re,margin:Me,className:Ne,background:Ie,enableHover:De=!0,tooltipContent:Ee,customHoverBehavior:We,customClickBehavior:ze,onObservation:Be,annotationObservationCallback:Le,chartId:Oe,onTopologyChange:He,annotations:je,onAnnotationActivate:$e,autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,legend:Ve,legendPosition:Ge,legendLayout:Qe,legendHoverBehavior:Ke,legendClickBehavior:Je,legendHighlightedCategory:Ze,legendIsolatedCategories:et,title:tt,foregroundGraphics:nt,backgroundGraphics:ot,decay:rt,pulse:st,transition:it,animate:at,staleness:lt,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt=!1,suspendWhenHidden:yt=!0,thresholds:vt,accessibleTable:xt=!0,description:bt,summary:kt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,layoutSelection:Dt}=e,Et=Lr.has(n)?Br:zr,Wt=ko(!0),zt=D({sizeProp:Te,responsiveWidth:Pe,responsiveHeight:Re,userMargin:Me,marginDefault:Et,title:tt,legend:Ve,legendPosition:Ge,foregroundGraphics:nt,backgroundGraphics:ot,animate:at,transitionProp:it,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt,suspendWhenHidden:yt,themeDirtyRef:Wt}),{reducedMotionRef:Bt,responsiveRef:Lt,size:Ht,margin:jt,adjustedWidth:$t,adjustedHeight:Yt,resolvedForeground:Xt,resolvedBackground:Vt,transition:Gt,introEnabled:qt,tableId:Ut,rafRef:Qt,renderFnRef:Kt,scheduleRender:Jt,frameRuntime:Zt,currentTheme:en}=zt,tn=W(),nn=B(),on=So(()=>me(o),[o]),rn=So(()=>Array.isArray(r)?me(r):r,[r]),sn=So(()=>({...Ro,...re}),[re]),an=So(()=>({...Mo,...ie}),[ie]),ln=So(()=>{return{chartType:(e={chartType:n,clock:Zt.now,random:dt,seed:ht,nodeIDAccessor:b,sourceAccessor:k,targetAccessor:A,valueAccessor:T,edgeIdAccessor:C,childrenAccessor:P,hierarchySum:N,orientation:L,nodeAlign:H,nodePaddingRatio:F,nodeWidth:$,iterations:Y,forceStrength:X,padAngle:U,groupWidth:Q,sortGroups:K,edgeSort:J,treeOrientation:Z,edgeType:te,padding:ne,paddingTop:oe,tensionConfig:sn,showParticles:se,particleStyle:an,nodeStyle:le,edgeStyle:ue,nodeLabel:Ae,showLabels:Se,labelMode:_e,colorBy:de,colorScheme:he,edgeColorBy:fe,edgeOpacity:pe,colorByDepth:ve,nodeSize:ke,nodeSizeRange:we,decay:rt,pulse:st,transition:Gt,introAnimation:qt,staleness:lt,thresholds:vt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,currentTheme:en}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Ue(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,Zt.now,dt,ht,b,k,A,T,C,P,N,L,H,F,$,Y,X,U,Q,K,J,Z,te,ne,oe,sn,se,an,le,ue,Ae,Se,_e,de,he,fe,pe,ve,ke,we,rt,st,Gt,qt,lt,vt,wt,At,St,_t,Tt,Ct,Pt,Rt,Mt,Nt,It,en]),cn=dn(ln),un=dn({chartType:(hn={chartType:n,nodeIDAccessor:b,sourceAccessor:k,targetAccessor:A,valueAccessor:T,edgeIdAccessor:C,childrenAccessor:P,hierarchySum:N,orientation:L,nodeAlign:H,nodePaddingRatio:F,nodeWidth:$,iterations:Y,forceStrength:X,padAngle:U,groupWidth:Q,sortGroups:K,edgeSort:J,treeOrientation:Z,edgeType:te,padding:ne,paddingTop:oe,random:dt,seed:ht,tensionConfig:sn,customNetworkLayout:Mt,orbitMode:wt,orbitSize:At,orbitEccentricity:Ct}).chartType,nodeIDAccessor:hn.nodeIDAccessor,sourceAccessor:hn.sourceAccessor,targetAccessor:hn.targetAccessor,valueAccessor:hn.valueAccessor,edgeIdAccessor:hn.edgeIdAccessor,childrenAccessor:hn.childrenAccessor,hierarchySum:hn.hierarchySum,orientation:hn.orientation,nodeAlign:hn.nodeAlign,nodePaddingRatio:hn.nodePaddingRatio,nodeWidth:hn.nodeWidth,iterations:hn.iterations,forceStrength:hn.forceStrength,padAngle:hn.padAngle,groupWidth:hn.groupWidth,sortGroups:hn.sortGroups,edgeSort:hn.edgeSort,treeOrientation:hn.treeOrientation,edgeType:hn.edgeType,padding:hn.padding,paddingTop:hn.paddingTop,random:hn.random,seed:hn.seed,tensionConfig:hn.tensionConfig,customNetworkLayout:hn.customNetworkLayout,orbitMode:hn.orbitMode,orbitSize:hn.orbitSize,orbitEccentricity:hn.orbitEccentricity});var hn;const fn=ko(0),pn=ko(0),gn=ko(!1),mn=ko(null);mn.current||(mn.current=new er(cn));const vn=z("StreamNetworkFrame"),xn=_o((e,t,n=!1)=>I(vn.current,e,()=>e.buildScene(t),n),[vn]),[bn,kn]=wo(null),[wn,An]=wo(0),[Sn,_n]=wo(0),[Tn,Cn]=wo(!1),[Pn,Rn]=wo(!1),Mn=ko(0),Dn=ko(null),En=ko(!1),Wn=ko(q);Wn.current=q;const zn=ko(cn);zn.current=cn;const Bn=ko(null),Ln=ko(new Map),On=ko(0),Hn=_o(e=>function(e){const{node:t,colorBy:n,colorScheme:o,nodeColorMap:r,colorIndexRef:s}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!r.has(e+"")){const t=Array.isArray(o)?o:ce;r.set(e+"",t[s.current++%t.length])}return r.get(e+"")}}if(r.has(t.id))return r.get(t.id);const i=Array.isArray(o)?o:ce,a=n?i[s.current++%i.length]:i[0];return r.set(t.id,a),a}({node:e,colorBy:de,colorScheme:he,nodeColorMap:Ln.current,colorIndexRef:On}),[de,he]),Fn=($n=en,$n?.colors?.border||$n?.colors?.secondary||$n?.colors?.primary||"#999");var $n;const Yn=_o(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,mn.current?.nodes),[]),Xn=_o(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:o,resolveEndpoint:r,fallback:s}=e;if("function"==typeof n)return n(t);const i=r(t.source),a=r(t.target);return"target"===n&&a?o(a):i?o(i):s}({edge:e,edgeColorBy:fe,getNodeColor:Hn,resolveEndpoint:Yn,fallback:Fn}),[fe,Hn,Fn,Yn]),Vn=_o(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:o,hasExplicitParticleColorBy:r,getEdgeColor:s,getNodeColor:i,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!r)return s(t);const c=o,u=a(t.source),d=a(t.target);return"target"===c&&d?i(d):u?i(u):l}({edge:e,particleStyleColor:an.color,particleColorBy:an.colorBy,hasExplicitParticleColorBy:!!ie?.colorBy,getEdgeColor:Xn,getNodeColor:Hn,resolveEndpoint:Yn,fallback:Fn}),[ie?.colorBy,an.color,an.colorBy,Hn,Xn,Fn,Yn]),Gn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!Mt,se,!!st,mn.current?.isAnimating??!1);gt(mn,cn,Wt,Jt),mt(mn,Dt,Wt,Jt),Ao(()=>{const e=mn.current;e&&(xn(e,[$t,Yt]),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Wt.current=!0,Jt())},[en,$t,Yt,xn,Jt,he]);const qn=_o(()=>{const e=mn.current;if(e&&(e.runLayout([$t,Yt]),xn(e,[$t,Yt]),Wt.current=!0,On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),An(e.layoutVersion),He)){const{nodes:t,edges:n}=e.getLayoutData();He(t,n)}},[$t,Yt,xn,He,he]),Un=_o(e=>{if(null==e||"object"!=typeof e)return;const t=mn.current;t&&(t.ingestEdge(e)&&qn(),Jt())},[qn,Jt]),Qn=_o(e=>{const t=mn.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&qn(),Jt()},[qn,Jt]),Kn=_o(()=>{mn.current?.clear(),Ln.current.clear(),On.current=0,An(mn.current?.layoutVersion??0),kn(null),Bn.current=null,Wt.current=!0,Jt()},[Jt]),Jn=_o(()=>{const e=mn.current;e&&(e.tension+=999,qn(),Jt())},[qn,Jt]);To(t,()=>({push:Un,pushMany:Qn,removeNode:e=>{const t=mn.current?.removeNode(e)??!1;if(t){const t=Bn.current?.data?"function"==typeof b?b(Bn.current.data):Bn.current.data[b]:void 0;Bn.current&&"node"===Bn.current.nodeOrEdge&&t===e&&(Bn.current=null,kn(null)),Ln.current.delete(e),qn(),Wt.current=!0,Jt()}return t},removeEdge:(e,t)=>{const n=mn.current?.removeEdge(e,t)??!1;if(n){if(Bn.current&&"edge"===Bn.current.nodeOrEdge){const n=Bn.current.data;let o;o=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!C||!n||("function"==typeof C?C:e=>e?.[C])(n)===e,o&&(Bn.current=null,kn(null))}qn(),Wt.current=!0,Jt()}return n},updateNode:(e,t)=>{const n=mn.current?.updateNode(e,t)??null;return n&&(Wt.current=!0,Jt()),n},updateEdge:(e,t,n)=>{const o=mn.current?.updateEdge(e,t,n)??[];return o.length>0&&(qn(),Wt.current=!0,Jt()),o},clear:Kn,getTopology:()=>mn.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>mn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>mn.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=mn.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Jn,getTension:()=>mn.current?.tension??0}),[Un,Qn,Kn,Jn,b,qn,Jt,C]);const Zn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),eo=Zn?u||(Array.isArray(r)?void 0:r):void 0;Ao(()=>{const e=mn.current;if(!e)return;const t=++Mn.current;if(Dn.current?.abort(),Dn.current=null,Zn&&eo)e.ingestHierarchy(eo,[$t,Yt]),xn(e,[$t,Yt]),Rn(!1),Wn.current?.("ready"),Wt.current=!0,Jt();else{const c=on,u=Array.isArray(rn)?rn:[];if(0===c.length&&0===u.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||Kn(),Rn(!1),void Wn.current?.("ready");const d=[$t,Yt],h="force"===n&&!Mt&&s()&&!dt&&l(V,c.length,u.length,Y);if(h&&nn&&!En.current&&e.sceneNodes.length>0)return En.current=!0,Rn(!1),Wn.current?.("ready"),Wt.current=!0,void Jt();if(h){const n=new AbortController;Dn.current=n;const o=e._lastPositionSnapshot;e.ingestBounded(c,u,d,{deferLayout:!0});const r=e.getLayoutData(),s=i(r.nodes,r.edges,zn.current,d,o);return Rn(!0),Wn.current?.("pending"),a(s,n.signal).then(({positions:n})=>{t===Mn.current&&(e.applyForceLayoutPositions(n,d),xn(e,d),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Rn(!1),Wn.current?.("ready"),An(e.layoutVersion),Wt.current=!0,Jt())}).catch(n=>{"AbortError"!==n.name&&t===Mn.current&&(e.runLayout(d),xn(e,d),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Rn(!1),Wn.current?.("error"),An(e.layoutVersion),Wt.current=!0,Jt())}),()=>n.abort()}e.ingestBounded(c,u,d),xn(e,d),Rn(!1),Wn.current?.("ready"),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Wt.current=!0,Jt()}},[on,rn,o,r,u,eo,Zn,$t,Yt,un,V,Y,nn,n,Mt,dt,Jt,Kn,he,xn]),Ao(()=>{x&&x.length>0&&Qn(x)},[x,Qn]);const{customHoverBehavior:to,customClickBehavior:no}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:Ir((t,r)=>{e?.(t,r),ge({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Dr,chartId:o,context:r})},[e,n,o]),customClickBehavior:Ir((e,r)=>{t?.(e,r),ye({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Dr,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:We,customClickBehavior:ze,onObservation:Be,chartId:Oe}),{hoverHandlerRef:oo,hoverLeaveRef:ro,onPointerMove:so,onPointerLeave:io}=zt,uo=()=>!Mt||(mn.current?.hasCustomRestyle??!1);oo.current=e=>{if(!De)return;const t=uo(),n=bo.current;if(!n)return;const o=mn.current;if(!o)return;const r=Nr({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:jt,adjustedWidth:$t,adjustedHeight:Yt,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Bn.current=r.hover,kn(r.hover),to&&(to(r.hover),t&&(Wt.current=!0)),t&&Jt()):Bn.current&&(Bn.current=null,kn(null),to&&(to(null),t&&(Wt.current=!0)),t&&Jt())},ro.current=()=>{if(Bn.current){const e=uo();Bn.current=null,kn(null),to&&(to(null),e&&(Wt.current=!0)),e&&Jt()}};const ho=ko(()=>{});ho.current=e=>{if(j(e.target))return;if(!ze&&!Be)return;const t=bo.current;if(!t)return;const n=mn.current;if(!n)return;const o=Nr({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:jt,adjustedWidth:$t,adjustedHeight:Yt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?no(o.hover,{type:"activate",inputType:Ce(e.nativeEvent.pointerType)}):"miss"===o.kind&&no(null)};const po=_o(e=>ho.current(e),[]),yo=ko(-1),go=ko(null),mo=ko(-1),vo=_o(e=>{if(xe(e))return;const t=mn.current;if(!t)return;const n=()=>{yo.current=-1,go.current=null,mo.current=-1,Bn.current=null,kn(null),to&&(to(null),Wt.current=!0),Jt()},o=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.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.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=Fe(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===o.length)return void(0>yo.current||n());const r=ao(o);let s=yo.current;if(r.flat.length>s||(n(),s=-1)," "===e.key&&s>=0){e.preventDefault();const t=r.flat[s];return void no(O(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>s){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),yo.current=0,mo.current=-1;const t=r.flat[0];go.current={shape:t.shape,w:t.w,h:t.h};const n=O(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Bn.current=n,kn(n),to&&(to(n,{type:"focus",inputType:"keyboard"}),Wt.current=!0),void Jt()}const i=lo(r,s),a=function(e,t,n,o,r){const s=n.flat[t.flatIndex];if(!s)return co(e,t,n);const i=s.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=function(e,t,n){let o=null,r=1/0;for(let s=0;e.flat.length>s;s++){const i=e.flat[s];if(i===t)continue;const a=i.x-t.x,l=i.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;r>u&&(r=u,o=s)}return o}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==i)return t.flatIndex;const e=function(e,t){const n=e+"",o=[];for(const e of t){const t=e.datum??e,r=fo(t.source),s=fo(t.target),i=null!=r,a=null!=s;i&&r+""===n&&a?o.push(s+""):a&&s+""===n&&i&&o.push(r+"")}return o}(i,o);if(0===e.length)return t.flatIndex;const s=n.idToIdx.get(e[(r.current+1)%e.length])??-1;return 0>s?t.flatIndex:(r.current=-1,s)}default:{const o=co(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,i,r,t.sceneEdges??[],mo);if(null===a)return;if(e.preventDefault(),0>a)return void n();yo.current=a;const l=r.flat[a];go.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Bn.current=c,kn(c),to&&(to(c,{type:"focus",inputType:"keyboard"}),Wt.current=!0),Jt()},[no,to,Jt]),xo=_o(e=>{yo.current=-1,go.current=null,so(e)},[so]);Kt.current=()=>{if(Qt.current=null,!Zt.isActive)return;const e=bo.current;if(!e)return;const t=mn.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:s,adjustedWidth:i,adjustedHeight:a,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:f,random:p,reducedMotion:y,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:b,thresholds:k,staleness:A,particleStyle:T,getParticleColor:C,pendingAnnotationFrameRef:P,lastAnnotationFrameTimeRef:R,setAnnotationFrame:N,scheduleNextFrame:I}=e,D=t.getContext("2d");if(!D)return;const E=h.current?Math.min((f-h.current)/1e3,.1):.016;h.current=f;const W=n.advanceTransition(y?f+1e6:f),z=!y&&W,B=!y&&n.tickAnimation([i,a],E),L=d.current,O=o?.beforeCompute(n.getLastUpdateResult(),z),H=W||L||B;H&&n.buildScene([i,a]),O&&o?.afterCompute(O,H,!1);const F=g&&!y&&!!n.particlePool,j=!!(($={dirtyOrRebuilt:L,transitioning:z,animationTicked:B,continuous:F||m,liveEncoding:!!x||!!b||!!k||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||$.transitioning||$.animationTicked||$.continuous||$.liveEncoding||$.forced);var $;const Y=!!A&&n.lastIngestTime>0&&f-n.lastIngestTime>(A?.threshold??5e3);if(j){const e=S();if(!_(t,r,s,e))return;if(D.clearRect(-s.left,-s.top,r[0],r[1]),yn(D,{background:l,hasBackgroundGraphics:u,width:i,height:a}),x&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==v&&n.applyTopologyDiff(f),Y&&(D.globalAlpha=A?.dimOpacity??.5),ee({context:D,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":vr(e,n);break;case"line":xr(e,n);break;case"ribbon":br(e,n);break;case"curved":kr(e,n)}}(D,e)}),ee({context:D,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Nn(e,t),e.restore())}}(D,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),In(e,t),e.restore())}}(D,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(D,t),function(e,t){const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Ar(t);if(!r)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const s=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=M(e,t.style.fill,"#007bff"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}}(D,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&jn(e,o,o.cx,o.cy,n);e.globalAlpha=n}(D,t)}}),F&&!Y){const e=n.edgesArray;if(e.length>0){!function(e,t,n,o,r=Math.random){const s=o.spawnRate??.1,i=o.maxPerEdge??50;for(let o=0;t.length>o;o++){const a=t[o];if(!a.bezier)continue;if(e.countForEdge(o)>=i)continue;const l=a.value*s*n*(a.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;r()<u&&d++;for(let t=0;d>t&&e.countForEdge(o)<i;t++)e.spawn(o,r)}}(n.particlePool,e,E,T,p);const t=.5*(T.speedMultiplier??1);let o;if(T.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(E,t,e,o),function(e,t,n,o,r){const s=o.radius??3;e.globalAlpha=o.opacity??.7;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.color:r(l),e.fillStyle=qe(e,c)||c,e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}e.globalAlpha=1}(D,n.particlePool,e,T,C)}}Y&&(D.globalAlpha=1)}d.current=!1,(L||z||B)&&t.setAttribute("aria-label",w(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const X=L||z||B||P.current;X&&f-R.current>=33?(N(e=>e+1),R.current=f,P.current=!1):P.current=!!X,(m||z||null!=n.transition||B||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||P.current)&&I()}({canvas:e,store:t,sceneRevisionDiagnostics:vn.current,size:Ht,margin:jt,adjustedWidth:$t,adjustedHeight:Yt,background:Ie,renderMode:ae,hasBackgroundGraphics:!!ot,dirtyRef:Wt,lastFrameTimeRef:fn,now:Zt.now(),random:Zt.random,reducedMotion:!!Bt.current,showParticles:se,isContinuous:Gn,animate:at,decay:rt,pulse:st,thresholds:vt,staleness:lt,particleStyle:an,getParticleColor:Vn,pendingAnnotationFrameRef:gn,lastAnnotationFrameTimeRef:pn,setAnnotationFrame:_n,scheduleNextFrame:()=>{Jt()}})};const{canvasRef:bo}=E(zt,{hydrated:tn,wasHydratingFromSSR:nn,storeRef:mn,dirtyRef:Wt,canvasPaintDependencies:[n,$t,Yt,Ie,ot,ae,Jt]});Ot(lt,mn,Wt,Jt,Tn,Cn);const Co=De&&bn?Er(f,{x:bn.x,y:bn.y,containerWidth:$t,containerHeight:Yt,margin:jt,className:"stream-network-tooltip",zIndex:2,children:Ee?Ee(bn):Er(gr,{data:bn})}):null;if(be||!tn&&nn)return Er(hr,{props:e,store:mn.current,responsiveRef:Lt,size:Ht,margin:jt,adjustedWidth:$t,adjustedHeight:Yt,resolvedBackground:Vt,resolvedForeground:Xt});const Po=mn.current;return Wr("div",{ref:Lt,className:"stream-network-frame"+(Ne?" "+Ne:""),role:"group","aria-label":bt||("string"==typeof tt?tt:"Network chart"),tabIndex:0,"aria-busy":Pn||void 0,style:{position:"relative",width:Pe?"100%":Ht[0],height:Re?"100%":Ht[1],overflow:"visible"},onKeyDown:vo,children:["production"!==process.env.NODE_ENV&&mn.current&&Er(g,{store:mn.current,diagnostics:vn.current}),xt&&Er(v,{tableId:Ut}),xt&&Er(y,{nodes:Po?.sceneNodes??[],edges:Po?.sceneEdges??[],chartType:"Network chart",tableId:Ut,chartTitle:"string"==typeof tt?tt:void 0}),Er(m,{summary:kt}),Er(d,{hoverPoint:bn}),Wr("div",{role:"img","aria-label":bt||("string"==typeof tt?tt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:De?xo:void 0,onMouseLeave:De?io:void 0,onClick:ze||Be?po:void 0,children:[Pn&&!1!==G&&Er("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:R(!0,Ht[0],Ht[1],G)}),Er(h,{size:Ht,margin:jt,overflowVisible:!0,children:Vt}),Er("canvas",{ref:bo,"aria-label":w(Po?.sceneNodes?.length??0,Po?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Er(sr,{width:$t,height:Yt,totalWidth:Ht[0],totalHeight:Ht[1],margin:jt,labels:Po?.labels||[],sceneNodes:Po?.sceneNodes,title:tt,legend:Ve,legendPosition:Ge,legendLayout:Qe,legendHoverBehavior:Ke,legendClickBehavior:Je,legendHighlightedCategory:Ze,legendIsolatedCategories:et,foregroundGraphics:ft(Xt,c(mn.current?.customLayoutOverlays,Dt??null)),annotations:je,onAnnotationActivate:$e,onObservation:Le??Be,chartId:Oe,chartType:"StreamNetworkFrame",autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,annotationFrame:Sn}),Er(cr,{marks:Po?.customLayoutHtmlMarks,margin:jt,selection:Dt??null}),Er(p,{active:yo.current>=0,hoverPoint:bn,margin:jt,size:Ht,shape:go.current?.shape,width:go.current?.w,height:go.current?.h}),Co,lt?.showBadge&&Er(Ft,{isStale:Tn,position:lt.badgePosition})]})]})}));Hr.displayName="StreamNetworkFrame";var Fr=Hr,jr=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},$r=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new jr,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new jr;o.push(t);let r=e,s=e;const i=[],a={start:r,end:s,stats:o};for(const t of this.sessions)e-n>t.end||t.start>e+n?i.push(t):(a.stats.merge(t.stats),r>t.start&&(r=t.start),t.end>s&&(s=t.end));a.start=r,a.end=s,i.push(a),i.sort((e,t)=>e.start-t.start),this.sessions=i}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const o=t+this.size;e.push(this.row(t,o,n,o>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,o){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:o}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Yr(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function Xr(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=Yr(e,n),s=e.stddev*o;return[r-s,r+s]}var Vr={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Gr=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function qr(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Gr.lastIndex=0;let n,o=0,r=0;for(;null!==(n=Gr.exec(t));){const e=parseFloat(n[1]),t=Vr[n[2]];if(null==t||!Number.isFinite(e))return null;o+=e*t,r+=n[0].length}return r!==t.length?null:o>0?o:null}var Ur=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const o of this.held)this.getTime(o)>e?n.push(o):t.push(o);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Qr,useImperativeHandle as Kr,forwardRef as Jr,useCallback as Zr,useState as es,useEffect as ts}from"react";import{jsx as ns,jsxs as os}from"react/jsx-runtime";var rs={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},ss={opacity:.7,marginRight:4};function is(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function as(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function ls(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=is(s,t,"time"),a=is(s,n,"value");return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[os("span",{style:ss,children:[o,":"]}),as(i)]}),os("div",{children:[os("span",{style:ss,children:[r,":"]}),as(a)]})]})}}function cs(e,t){return null!=e?e:Math.max(t?.length??0,200)}var us="time",ds="value",hs="__aggLower",fs="__aggUpper",ps="__aggPartial",ys="count",gs="__aggStart",ms="__aggEnd";function vs(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[us]:(e.start+e.end)/2,[ds]:Yr(e,n),[ys]:e.count,[ps]:e.partial,[gs]:e.start,[ms]:e.end},s=Xr(e,o,n,r);return s&&(t[hs]=s[0],t[fs]=s[1]),t})}function xs(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:s,hoverHighlight:i,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};o&&(f.annotationObservationCallback=o);const p=c?.enabled?Math.max(s??30,Math.ceil((c.targetSize||44)/2),24):s;return(a||t||o||r||i)&&(f.customHoverBehavior=u),d&&(l||(h?o||r||t:o||r)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||i||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}import{jsx as bs}from"react/jsx-runtime";function ks(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();const r=Number(o);return Number.isFinite(r)?r:null}var ws=Jr(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:f,extentPadding:p,stroke:y="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,transition:D,linkedHover:E,selection:W,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j,aggregate:$,eventTime:Y}=e,X=n.showAxes,V=n.enableHover,G=r??n.marginDefaults,q=o??[n.width,n.height],U=b??k??ls({timeAccessor:u,valueAccessor:d}),Q=Qr(null),{customHoverBehavior:K}=Ie({selection:W,linkedHover:E,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:B}),J=Zr(e=>{w&&w(e),K(e)},[w,K]),Z=null!=$,[ee,te]=es([]),ne=Qr(null),oe=Qr($);oe.current=$;const re=Qr(Z);re.current=Z;const se=Qr(ee);se.current=ee;const ie=Qr({timeAccessor:u,valueAccessor:d});ie.current={timeAccessor:u,valueAccessor:d},ts(()=>{if(!Z)return void(ne.current=null);const e=oe.current,t=function(e){const t=e.window??"tumbling",n=qr("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?qr(e.hop):void 0,r=null!=e.gap?qr(e.gap):void 0;return new $r({window:t,size:n,hop:o??void 0,gap:r??void 0,retain:e.retain})}(e);if(ne.current=t,t&&c){const{timeAccessor:e,valueAccessor:n}=ie.current;for(const o of c){const r=ks(o,e,"time"),s=ks(o,n,"value");null!=r&&null!=s&&t.push(r,s)}}te(t?vs(t,e):[])},[Z?[$.window??"tumbling",$.size,$.hop??"",$.gap??"",$.retain??""].join("|"):"",Z,c]),ts(()=>{Z&&ne.current&&te(vs(ne.current,oe.current))},[$?.stat,$?.band,$?.sigma]);const ae=Zr(e=>{const t=ne.current,n=oe.current;if(!t||!n)return;const{timeAccessor:o,valueAccessor:r}=ie.current;for(const n of e){const e=ks(n,o,"time"),s=ks(n,r,"value");null!=e&&null!=s&&t.push(e,s)}te(vs(t,n))},[]),le=null!=Y,ce=Qr(null),ue=Qr(Y);ue.current=Y;const de=Qr(le);de.current=le;const he=Qr(z);he.current=z;const fe=Qr(B);fe.current=B,ts(()=>{ce.current=le?function(e){const t=qr(e.lateness);return null==t?null:new Ur({lateness:t,getTime:e=>ks(e,ie.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ue.current):null},[le?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",le]);const pe=Zr(e=>{0!==e.length&&(re.current?ae(e):Q.current?.pushMany(e))},[ae]),ye=Zr(e=>{const t=ce.current;if(!de.current||!t)return void pe(e);const n=[];for(const o of e){const e=t.push(o);if(e.released.length&&n.push(...e.released),e.late.length){const n=he.current;if(n){const{timeAccessor:o}=ie.current,r=ue.current?.latePolicy??"drop";for(const s of e.late)n({type:"late-data",datum:s,eventTime:ks(s,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:fe.current})}}}pe(n)},[pe]);Kr(t,()=>({push:e=>ye([e]),pushMany:e=>ye(e),remove:e=>re.current?[]:Q.current?.remove(e)??[],update:(e,t)=>re.current?[]:Q.current?.update(e,t)??[],clear:()=>{ce.current?.clear(),re.current?(ne.current?.clear(),te([])):Q.current?.clear()},getData:()=>re.current?se.current:Q.current?.getData()??[],getScales:()=>Q.current?.getScales()??null}),[ye]);const ge=R(L,q[0],q[1],O),me=ge?null:C(Z?void 0:c,q[0],q[1],H),ve={stroke:y,strokeWidth:g,strokeDasharray:m};null!=v&&(ve.opacity=v);const xe=cs(l,c),be=Z?ee:c,ke=Z?us:u,we=Z?ds:d,Ae=Z&&$&&"none"!==($.band??"none")?{y0Accessor:hs,y1Accessor:fs,perSeries:!1}:void 0;return ge||me||bs(bo,{ref:Q,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${s||""} semiotic-emphasis-${F}`.trim():s,arrowOfTime:i,windowMode:Z?"growing":a,windowSize:Z?Math.max(1,$?.retain??Math.max(ee.length,600)):xe,data:be,timeAccessor:ke,valueAccessor:we,xExtent:h,yExtent:f,extentPadding:p,band:Ae,lineStyle:ve,showAxes:X,background:x,hoverAnnotation:V,tooltipContent:U,...xs({linkedHover:E,selection:W,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:J}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,transition:D,pointIdAccessor:e.pointIdAccessor,legendPosition:j})});ws.displayName="RealtimeLineChart";import{useRef as As,useImperativeHandle as Ss,forwardRef as _s,useCallback as Ts,useMemo as Cs}from"react";import{jsx as Ps}from"react/jsx-runtime";function Rs(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const r=Number(o);return Number.isFinite(r)?r:null}var Ms=_s(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:o,size:r,margin:s,className:i,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:d,valueAccessor:h,direction:f="up",timeExtent:p,valueExtent:y,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:T,onHover:P,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,linkedHover:W,selection:z,decay:B,pulse:L,staleness:O,transition:H,onObservation:F,chartId:j,loading:$,loadingContent:Y,emptyContent:X,emphasis:V,legendPosition:G,brush:q,onBrush:U,linkedBrush:Q}=e,K=n.showAxes,J=n.enableHover,Z=s??n.marginDefaults,ee=r??[n.width,n.height],te=_??T??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null;if(null==o?.binStart||null==o?.binEnd){const e=is(o,t,"time"),r=is(o,n,"value");return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[ns("span",{style:ss,children:"x:"}),as(e)]}),os("div",{children:[ns("span",{style:ss,children:"y:"}),as(r)]})]})}return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[ns("span",{style:ss,children:"range:"}),as(o.binStart),"–",as(o.binEnd)]}),null!=o.total&&os("div",{children:[ns("span",{style:ss,children:"count:"}),as(o.total)]}),null!=o.category&&os("div",{children:[ns("span",{style:ss,children:"category:"}),as(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),ne=As(null),{customHoverBehavior:oe}=Ie({selection:z,linkedHover:W,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:j}),re=Ts(e=>{P&&P(e),oe(e)},[P,oe]),se=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,ie=_e(Q),ae="string"==typeof d?d:"time",le=Me({name:ie?.name||"__unused_hist_brush__",xField:ie?.xField||ae,...ie?.yField?{yField:ie.yField}:{}}),ce=As(le.brushInteraction);ce.current=le.brushInteraction;const ue=Ts(e=>{if(U&&U(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}),ie){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,F,j,ie]);Ss(t,()=>({push:e=>ne.current?.push(e),pushMany:e=>ne.current?.pushMany(e),remove:e=>ne.current?.remove(e)??[],update:(e,t)=>ne.current?.update(e,t)??[],clear:()=>ne.current?.clear(),getData:()=>ne.current?.getData()??[],getScales:()=>ne.current?.getScales()??null}),[]);const de=R($,ee[0],ee[1],Y),he=de?null:C(u,ee[0],ee[1],X),fe={};null!=x&&(fe.fill=x),null!=b&&(fe.stroke=b),null!=k&&(fe.strokeWidth=k),null!=w&&(fe.opacity=w),null!=A&&(fe.gap=A);const pe=V?`${i||""} semiotic-emphasis-${V}`.trim():i,ye=cs(c,u),ge=Cs(()=>"down"!==f?y:function({data:e,valueAccessor:t,timeAccessor:n,binSize:o,valueExtent:r,extentPadding:s}){if(r)return[r[1],r[0]];if(!e||0===e.length)return;const i=new Map;for(const r of e){const e=Rs(r,n,"time"),s=Rs(r,t,"value");if(null==e||null==s)continue;const a=Math.floor(e/o)*o;i.set(a,(i.get(a)??0)+s)}let a=0;for(const e of i.values())e>a&&(a=e);return[a>0?a+a*(s??.1):1,0]}({data:u,valueAccessor:h,timeAccessor:d,binSize:o,valueExtent:y,extentPadding:g}),[f,u,h,d,o,y,g]);return de||he||Ps(bo,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:Z,className:pe,arrowOfTime:a,windowMode:l,windowSize:ye,data:u,timeAccessor:d,valueAccessor:h,xExtent:p,yExtent:ge,extentPadding:g,binSize:o,categoryAccessor:m,barColors:v,barStyle:fe,showAxes:K,background:S,hoverAnnotation:J,tooltipContent:te,...xs({linkedHover:W,selection:z,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:re}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,decay:B,pulse:L,staleness:O,transition:H,pointIdAccessor:e.pointIdAccessor,legendPosition:G,brush:se||(Q?{dimension:"x"}:void 0),onBrush:se||Q?ue:void 0})});function Ns(e){return Ps(Ms,{...e,windowMode:"growing"})}Ms.displayName="RealtimeHistogram",Ns.displayName="TemporalHistogram";import{useRef as Is,useImperativeHandle as Ds,forwardRef as Es,useCallback as Ws}from"react";import{jsx as zs}from"react/jsx-runtime";var Bs=Es(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:f,yScaleType:p,extentPadding:y,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:T,onHover:P,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,linkedHover:W,selection:z,onObservation:B,chartId:L,loading:O,loadingContent:H,emptyContent:F,emphasis:j,legendPosition:$}=e,Y=n.showAxes,X=n.enableHover,V=r??n.marginDefaults,G=o??[n.width,n.height],q=_??T??ls({timeAccessor:u,valueAccessor:d}),U=Is(null),{customHoverBehavior:Q}=Ie({selection:z,linkedHover:W,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:L}),K=Ws(e=>{P&&P(e),Q(e)},[P,Q]);Ds(t,()=>({push:e=>U.current?.push(e),pushMany:e=>U.current?.pushMany(e),remove:e=>U.current?.remove(e)??[],update:(e,t)=>U.current?.update(e,t)??[],clear:()=>U.current?.clear(),getData:()=>U.current?.getData()??[],getScales:()=>U.current?.getScales()??null}),[]);const J=R(O,G[0],G[1],H),Z=J?null:C(c,G[0],G[1],F),ee={};null!=v&&(ee.radius=v),null!=x&&(ee.fill=x),null!=b&&(ee.opacity=b),null!=k&&(ee.stroke=k),null!=w&&(ee.strokeWidth=w);const te=A,ne=j?`${s||""} semiotic-emphasis-${j}`.trim():s,oe=cs(l,c);return J||Z||zs(bo,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:G,margin:V,className:ne,arrowOfTime:i,windowMode:a,windowSize:oe,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:f,yScaleType:p,extentPadding:y,categoryAccessor:g,barColors:m,swarmStyle:ee,pointStyle:te,showAxes:Y,background:S,hoverAnnotation:X,tooltipContent:q,...xs({linkedHover:W,selection:z,onObservation:B,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,legendPosition:$,pointIdAccessor:e.pointIdAccessor})});Bs.displayName="RealtimeSwarmChart";import{useRef as Ls,useImperativeHandle as Os,forwardRef as Hs,useCallback as Fs}from"react";import{jsx as js}from"react/jsx-runtime";var $s=Hs(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:f,extentPadding:p,positiveColor:y,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:T,annotations:P,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:D,linkedHover:E,selection:W,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j}=e,$=n.showAxes,Y=n.enableHover,X=r??n.marginDefaults,V=o??[n.width,n.height],G=S??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null,r=is(o,t,"time"),s=o?.delta??is(o,n,"value"),i=o?.cumEnd,a="number"==typeof s?0>s?as(s):"+"+as(s):as(s);return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[ns("span",{style:ss,children:"x:"}),as(r)]}),os("div",{children:[ns("span",{style:ss,children:"Δ:"}),a]}),null!=i&&os("div",{children:[ns("span",{style:ss,children:"total:"}),as(i)]})]})}}({timeAccessor:u,valueAccessor:d}),q=Ls(null),{customHoverBehavior:U}=Ie({selection:W,linkedHover:E,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:B}),Q=Fs(e=>{T&&T(e),U(e)},[T,U]);Os(t,()=>({push:e=>q.current?.push(e),pushMany:e=>q.current?.pushMany(e),remove:e=>q.current?.remove(e)??[],update:(e,t)=>q.current?.update(e,t)??[],clear:()=>q.current?.clear(),getData:()=>q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[]);const K=R(L,V[0],V[1],O),J=K?null:C(c,V[0],V[1],H),Z={};null!=y&&(Z.positiveColor=y),null!=g&&(Z.negativeColor=g),null!=m&&(Z.connectorStroke=m),null!=v&&(Z.connectorWidth=v),null!=x&&(Z.gap=x),null!=b&&(Z.stroke=b),null!=k&&(Z.strokeWidth=k),null!=w&&(Z.opacity=w);const ee=F?`${s||""} semiotic-emphasis-${F}`.trim():s,te=cs(l,c);return K||J||js(bo,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:X,className:ee,arrowOfTime:i,windowMode:a,windowSize:te,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:f,extentPadding:p,waterfallStyle:Z,showAxes:$,background:A,hoverAnnotation:Y,tooltipContent:G,...xs({linkedHover:E,selection:W,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:Q}),annotations:P,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:D,legendPosition:j,pointIdAccessor:e.pointIdAccessor})});$s.displayName="RealtimeWaterfallChart";import{useRef as Ys,useImperativeHandle as Xs,forwardRef as Vs,useCallback as Gs}from"react";import{jsx as qs}from"react/jsx-runtime";var Us=Vs(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:f,valueExtent:p,extentPadding:y,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,linkedHover:D,selection:E,onObservation:W,chartId:z,loading:B,loadingContent:L,emptyContent:O,emphasis:H,legendPosition:F}=e,j=n.showAxes,$=n.enableHover,Y=r??n.marginDefaults,X=o??[n.width,n.height],V=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=s?.xCenter??is(s,t,"time"),a=s?.yCenter??is(s,n,"value"),l=s?.count,c=s?.sum,u=s?.value,d=s?.agg??"count";return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[os("span",{style:ss,children:[o,":"]}),as(i)]}),os("div",{children:[os("span",{style:ss,children:[r,":"]}),as(a)]}),null!=l&&os("div",{children:[ns("span",{style:ss,children:"count:"}),as(l)]}),"sum"===d&&null!=c&&os("div",{children:[ns("span",{style:ss,children:"sum:"}),as(c)]}),"mean"===d&&null!=u&&os("div",{children:[ns("span",{style:ss,children:"mean:"}),as(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=Ys(null),{customHoverBehavior:q}=Ie({selection:E,linkedHover:D,unwrapData:!0,onObservation:W,chartType:"RealtimeHeatmap",chartId:z}),U=Gs(e=>{w&&w(e),q(e)},[w,q]);Xs(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const Q=R(B,X[0],X[1],L),K=Q?null:C(c,X[0],X[1],O),J=H?`${s||""} semiotic-emphasis-${H}`.trim():s,Z=cs(l,c);return Q||K||qs(bo,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:Y,className:J,arrowOfTime:i,windowMode:a,windowSize:Z,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:f,yExtent:p,extentPadding:y,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:j,background:x,hoverAnnotation:$,tooltipContent:V,...xs({linkedHover:D,selection:E,onObservation:W,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Us.displayName="RealtimeHeatmap";export{We as DEFAULT_LIFECYCLE_THRESHOLDS,ie as IncrementalExtent,Us as RealtimeHeatmap,Ms as RealtimeHistogram,ws as RealtimeLineChart,Bs as RealtimeSwarmChart,$s as RealtimeWaterfallChart,Ur as ReorderBuffer,ae as RingBuffer,jr as RunningStats,Fr as StreamNetworkFrame,bo as StreamXYFrame,Ns as TemporalHistogram,$r as WindowAccumulator,Xr as bandBounds,ze as bandFromAge,G as compileMotionEncoding,Q as deriveMotionVector,Z as opacityFromAge,qr as parseWindowDuration,ne as resolveMotionAccessor,oe as resolveMotionVector,Yr as statValue};
|