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
|
-
"use strict";var e,t=Object.create,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,o,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))s.call(e,c)||c===o||n(e,c,{get:()=>t[c],enumerable:!(a=i(t,c))||a.enumerable});return e},c=(e,i,r)=>(r=null!=e?t(o(e)):{},a(!i&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),l={};((e,t)=>{for(var i in t)n(e,i,{get:t[i],enumerable:!0})})(l,{generateFrameSVGs:()=>rg,generateFrameSequence:()=>og,generatePhysicsFrameSVGs:()=>ag,renderChart:()=>Zy,renderChartWithEvidence:()=>Qy,renderDashboard:()=>tg,renderGeoToStaticSVG:()=>Uy,renderNetworkToStaticSVG:()=>Vy,renderOrdinalToStaticSVG:()=>Xy,renderPhysicsToAnimatedGif:()=>hg,renderToAnimatedGif:()=>dg,renderToImage:()=>eg,renderToStaticSVG:()=>Hy,renderXYToStaticSVG:()=>Gy,resolveTheme:()=>Gh,themeStyles:()=>Xh}),module.exports=(e=l,a(n({},"__esModule",{value:!0}),e));var u=c(require("react-dom/server")),d=c(require("react")),h=require("d3-scale");function f(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function p(e,t,n){const i=e=>e.toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function y(e){const t=e.map(f),n=t.length-1;return e=>{if(0>=e){const[e,n,i]=t[0];return p(e,n,i)}if(e>=1){const[e,i,r]=t[n];return p(e,i,r)}const i=e*n,r=Math.floor(i),o=i-r,[s,a,c]=t[r],[l,u,d]=t[r+1];return p(Math.round(s+(l-s)*o),Math.round(a+(u-a)*o),Math.round(c+(d-c)*o))}}var g=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=y(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),x=y(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),b=y(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),v=y(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=y(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),k=y(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),S=y(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=y(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),M=y(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),P=y(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),_=y(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),j=y(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),C={blues:m,reds:x,greens:b,viridis:S,oranges:v,purples:w,greys:k,plasma:A,inferno:M,magma:P,cividis:_,turbo:j};y(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),y(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),y(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),y(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),y(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var I={category10:g,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...C},T=g,R=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],L=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function $(e,t,n){if("function"==typeof t){const i=t(e);return n&&i&&"string"==typeof i&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||L.has(t)}(i)?n(i):i}const i=e?.[t]+"";return n?n(i):T[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(i))%T.length]}function E(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function z(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>E(e,t)??"#999"}const i=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=i.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,h.scaleOrdinal)().domain(i).range(n).unknown("#999");const o=I[n]||I.category10;if(r&&"function"==typeof o){let e=-1/0;for(const t of i){const n=Number(t);n>e&&(e=n)}return t=>o(Number(t)/e)}{const e=Array.isArray(o)?o:T;return(0,h.scaleOrdinal)().domain(i).range(e).unknown("#999")}}var D=Object.freeze([]);function B(e){if(!e)return D;let t=!1;for(let n=0;e.length>n;n++){const i=e[n];if(null==i||"object"!=typeof i){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function F(e,t){return"touch"===t?Math.max(e,24):e}function N(e){return Array.isArray(e)?e[0]:e}function O(e,t,n,i){return{data:N(e),x:t,y:n,__semioticHoverData:!0,...i}}var W=["name","label","title"],q=["type","kind","category","group","class","status","role","shape"],Y=["value","amount","total","count","weight","score"],H=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 G(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}var X=require("react/jsx-runtime"),V={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function U(e,t){return"function"==typeof t?t(e):e[t]}function K(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Z(e={}){const{fields:t,title:n,format:i,style:r={},className:o=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=U(e,n);s=K(t,i)}if(t&&t.length>0)t.forEach(t=>{let n,r,o;"string"==typeof t?(n=t,r=t,o=i):(n=t.label,r=t.accessor||t.key||"",o=t.format||i);const s=U(e,r);a.push({label:n,value:K(s,o)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=K(e[n],i);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=K(e[t[0]],i))}}const c={...V,...r};return(0,X.jsxs)("div",{className:("semiotic-tooltip "+o).trim(),style:c,children:[s&&(0,X.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,X.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,X.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function Q(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=N(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data);const i=t(n);return null==i?null:(0,X.jsx)("div",{className:"semiotic-tooltip",style:V,children:i})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Z(e):Z())}}function J(e){const{title:t,description:n,summary:i,accessibleTable:r,className:o,animate:s,axisExtent:a,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),i&&(l.summary=i),void 0!==r&&(l.accessibleTable=r),o&&(l.className=o),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function ee(e){const{linkedHover:t,selection:n,onObservation:i,onClick:r,hoverRadius:o,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={},p=l?.enabled?Math.max(o??30,Math.ceil((l.targetSize||44)/2),24):o;return(a||t||i||r||s)&&(f.customHoverBehavior=u),d&&(c||(h?i||r||t:i||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}var te=require("react"),ne=c(require("react")),ie=require("react"),re=require("react"),oe=require("d3-selection"),se=require("d3-brush"),ae=c(require("react")),ce=require("react/jsx-runtime");function le(e,t,n,i){const[r,o]=[Math.min(...t),Math.max(...t)],s=(o-r)/20;let[a,c]=e;if(i)0>n?a=Math.max(r,a-s):c=Math.min(o,c+s);else{const e=c-a;a=Math.max(r,Math.min(o-e,a+n*s)),c=a+e}return[a,c]}function ue(e,t){let n=0,i=t.length-1;for(;i>n;){const r=n+i+1>>1;t[r]>e?i=r-1:n=r}return t[n]}function de(e,t){let n=0,i=t.length-1;for(;i>n;){const r=n+i>>1;e>t[r]?n=r+1:i=r}return t[n]}function he({width:e,height:t,totalWidth:n,totalHeight:i,margin:r,dimension:o,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:u,snapDuring:d,streaming:h}){const f=(0,re.useRef)(null),p=(0,re.useRef)(null),y=(0,re.useRef)(a);y.current=a;const g=(0,re.useRef)(s);g.current=s;const m=(0,re.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),x=(0,re.useRef)(m);x.current=m;const b=(0,re.useRef)(!1),v=(0,re.useRef)(null),w=function({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const i=ae.useId().replace(/:/g,""),r=ae.useRef(n);return r.current=n,{description:t,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:ae.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),r.current?.(t))},[])}}}({label:"xy"===o?"Two-dimensional data range brush":o.toUpperCase()+" data range brush",onAction:e=>{const t=g.current,n=p.current;if(!t||!n||!f.current)return;const i=(0,oe.select)(f.current).select(".brush-g");if("clear"===e.type)return b.current=!0,i.call(n.move,null),b.current=!1,v.current=null,void y.current(null);const r=t.x.domain(),s=t.y.domain(),a=v.current;let c=a?.x??[r[0]+.4*(r[1]-r[0]),r[0]+.6*(r[1]-r[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,d="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==o&&(c=le(c,r,d,e.resize)),u||"x"===o||(l=le(l,s,d,e.resize)),u&&"y"===o||!u&&"x"===o)return;const h={x:c,y:l};b.current=!0,i.call(n.move,"x"===o?[t.x(c[0]),t.x(c[1])]:"y"===o?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),b.current=!1,v.current=h,y.current(h)}});return(0,re.useEffect)(()=>{if(!f.current)return;const n=(0,oe.select)(f.current).select(".brush-g"),i="x"===o?(0,se.brushX)():"y"===o?(0,se.brushY)():(0,se.brush)();return i.extent([[0,0],[e,t]]),i.on("brush end",r=>{if(b.current)return;const s=g.current;if(!s)return;if(!r.selection)return v.current=null,void y.current(null);let a,u;if("x"===o){const[e,n]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===o){const[t,n]=r.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,i]]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(i),s.y.invert(t)]}if("bin"===l&&"y"!==o&&("end"===r.type||"brush"===r.type&&d)){const e=x.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[ue(e[0],t),de(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(b.current=!0,"x"===o)n.call(i.move,[t,l]);else if("xy"===o){const e=r.selection;n.call(i.move,[[t,e[0][1]],[l,e[1][1]]])}b.current=!1}const h={x:a,y:u};v.current=h,y.current(h)}),n.call(i),p.current=i,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),p.current=null}},[e,t,o,l,c,d]),(0,re.useEffect)(()=>{if(!(h&&s&&p.current&&v.current))return;if(!f.current)return;if("y"===o)return;const e=v.current,t=s.x.domain()[0],n=(0,oe.select)(f.current).select(".brush-g");if(t>=e.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===l){const e=x.current;e&&e.length>0?i=de(t,e):c&&c>0&&(i=Math.ceil(t/c)*c)}if(i>=e.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);r=!0}const a=s.x(i),u=s.x(e.x[1]);if(b.current=!0,"x"===o)n.call(p.current.move,[a,u]);else{const t=s.y(e.y[1]),i=s.y(e.y[0]);n.call(p.current.move,[[a,t],[u,i]])}if(b.current=!1,r){const t={x:[i,e.x[1]],y:e.y};v.current=t,y.current(t)}},[s,h,o,l,c]),(0,ce.jsxs)("svg",{ref:f,width:n,height:i,...w.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,ce.jsx)("title",{children:w.svgProps["aria-label"]}),(0,ce.jsx)("desc",{id:w.descriptionId,children:w.description}),(0,ce.jsx)("g",{className:"brush-g",transform:`translate(${r.left},${r.top})`})]})}var fe=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=B(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 i=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,i),bounded:!1}),t=i,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=B(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 i=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,i),bounded:!1}),t=i,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 i=e[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),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}},pe=require("react"),ye=require("react/jsx-runtime");function ge(e){let t=null;const n=()=>(t||(t=(0,pe.createContext)(null)),t),i=me(e);return[function({children:t,initialState:i}){const r=(0,pe.useRef)(i),o=(0,pe.useMemo)(()=>me(e,r.current),[]),s=n();return(0,ye.jsx)(s.Provider,{value:o,children:t})},(e,t)=>{const r=n(),o=(0,pe.useContext)(r)??i,s=(0,pe.useRef)(e);s.current=e;const a=(0,pe.useRef)({hasValue:!1,value:void 0}),c=(0,pe.useCallback)(()=>{const e=s.current(o.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[o,t]),l=(0,pe.useCallback)(()=>s.current(o.getState()),[o]);return(0,pe.useSyncExternalStore)(o.subscribe,c,l)}]}function me(e,t){const n=new Set;let i={...e(function(e){const t=e(i);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){i={...i,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>i,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function xe(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function be(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:ve}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var ve=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],we={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}},ke={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}},Se={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:ve,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 Ae(e,t){if("light"===t)return we;if("dark"===t)return ke;if("high-contrast"===t)return Se;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?ke:we;return be({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return be({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Me,Pe]=ge(e=>({theme:we,setTheme(t){e(e=>({theme:Ae(e.theme,t)}))}})),_e=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,i=[];t.length>e&&(n=t.length-e,i=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return i}update(e,t){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const o=(i+r)%this._capacity,s=this.buffer[o];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[o]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(i=>{e(i)?n.push(i):t.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);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}},je=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}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 Ce(e,t){return e===t}function Ie(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function Te(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Re(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Le=/^\d{4}-\d{1,2}$/;function $e(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Le.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const i=Date.parse(n);return Number.isFinite(i)?i:NaN}function Ee(e){return e instanceof Date?e.getTime():"string"==typeof e?$e(e):+e}function ze(e){return new Set(Array.isArray(e)?e:[e])}function De(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Be(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Fe(e,t,n){return e+(t-e)*n}function Ne(){return"undefined"!=typeof performance?performance.now():Date.now()}function Oe(e,t,n){if(1>=n)return 1;const i=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const i=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(i>0?i:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:i-t,extent:i,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function We(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function qe(e,t,n){const i=e.duration??500,r=n-t;return i>r?1-r/i:0}function Ye(e,t,n,i){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==i&&(e._pulseGlowRadius=i,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}function He(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const i=e.duration??500,r=t.peek();return null!=r&&i>n-r}function Ge(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),i=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Xe(e,t,n,i,r,o){const s=[];for(const r of e){const e=n(r),o=i(r);Number.isFinite(e)&&Number.isFinite(o)&&s.push({px:t.x(e),py:t.y(o),rawY:o,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:o}}function Ve(e,t,n,i,r,o,s,a){const c=[];for(const o of e){const e=n(o),s=i(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(o):r;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:e,group:s}}function Ue(e,t,n,i){const r=new Map;if("silhouette"===i)for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r.set(i,-e/2)}else if("wiggle"===i){e.length>0&&r.set(e[0],0);for(let i=1;e.length>i;i++){const o=e[i-1],s=e[i];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,o)||0)),c+=t,l+=t}const u=r.get(o)??0;r.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let i=0;for(const o of e){let e=0;for(const i of t)e+=n(i,o)||0;i+=(r.get(o)??0)+e/2}const o=i/e.length;for(const t of e)r.set(t,(r.get(t)??0)-o)}}else for(const t of e)r.set(t,0);return r}function Ke(e,t,n,i,r,o,s){const a=n(e),c=i(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:r,style:o,datum:e};return void 0!==s&&(l.pointId=s),l}function Ze(e,t,n,i,r,o,s,a){const c=n(e),l=i(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:r,symbolType:o,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Qe(e,t,n,i,r,o,s){return{type:"rect",x:e,y:t,w:n,h:i,style:r,datum:o,group:s}}function Je(e,t,n,i,r,o,s){const a={type:"heatcell",x:e,y:t,w:n,h:i,fill:r,datum:o};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function et(e,t,n,i){return"function"==typeof t.style?t.style(i||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,i)}function tt(e,t,n,i){if(!e.scales)return null;const r=[],o=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=i.getTop(n),a=i.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),o.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:et(e,i,n,t[0]),datum:t,group:n,interactive:i.interactive}}function nt(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const i of e)i.perSeries?t.push(i):n.push(i);return{perSeries:t,aggregate:n}}function it(e,t,n){const i=[];for(const r of n){const n=tt(e,t,"__ribbon_aggregate",r);n&&i.push(n)}return i}function rt(e,t,n,i){const r=[];for(const o of i){const i=tt(e,t,n,o);i&&r.push(i)}return r}function ot(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const i of t){if("band"!==i.kind)continue;const t=i.getTop(e),r=i.getBottom(e);Number.isFinite(r)&&Number.isFinite(t)&&n.push({y0:r,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function st(e,t,n,i){if(!e.config.pointStyle)return;const r=i??e.getY;for(const i of t){const t=e.resolveGroupColor(i.key);for(const o of i.data){let i=e.config.pointStyle(o);!i.fill&&t&&(i={...i,fill:t});const s=i.r??3,a=e.getPointId?e.getPointId(o)+"":void 0,c=Ke(o,e.scales,e.getX,r,s,i,a);c&&n.push(c)}}}var at={topOpacity:.8,bottomOpacity:.05};function ct(e){if(e)return!0===e?at:"colorStops"in e?e:{topOpacity:e.topOpacity??at.topOpacity,bottomOpacity:e.bottomOpacity??at.bottomOpacity}}var lt=require("d3-shape"),ut={circle:lt.symbolCircle,square:lt.symbolSquare,triangle:lt.symbolTriangle,diamond:lt.symbolDiamond,star:lt.symbolStar,cross:lt.symbolCross,wye:lt.symbolWye},dt=["circle","triangle","diamond","star","square","chevron","cross","wye"];function ht(e,t,n){if(n)return n;const i=e??"circle";return"chevron"===i?function(e){const t=1.5*ft(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,lt.symbol)(ut[i]??lt.symbolCircle,Math.max(1,t))()??""}function ft(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var pt=new Map;function yt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const i=Math.max(1,Math.floor(e.config.heatmapXBins??20)),r=Math.max(1,Math.floor(e.config.heatmapYBins??20)),o=e.config.heatmapAggregation??"count",s=Ie(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/i,h=(u-l||1)/r,f=i*r;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let n=0;t.length>n;n++){const o=t[n],c=e.getX(o),u=e.getY(o);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),i-1),g=Math.min(Math.floor((u-l)/h),r-1);if(0>f||0>g)continue;const m=g*i+f;p[m]++;const x=s(o);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(o){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,b=n.width/i,v=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let e=0;r>e;e++){const t=e*i;for(let n=0;i>n;n++){const i=t+n;if(0===p[i])continue;let s;switch(o){case"sum":s=y[i];break;case"mean":s=y[i]/p[i];break;default:s=p[i]}const c=(s-g)/x;S.push(Je(n*b,(r-1-e)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:p[i],sum:y[i],xCenter:a+(n+.5)*d,yCenter:l+(e+.5)*h,agg:o},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(e,t,n);if(0===t.length)return[];const i=Ie(e.config.valueAccessor,"value"),r=Te(e.config.xAccessor,"x"),o=Te(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],i=r(n),u=o(n);c[e]=i,l[e]=u,s.has(i)||s.set(i,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){h.sort((e,t)=>e-t),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){f.sort((e,t)=>e-t),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=new Map;let w=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),o=a.get(l[e]);if(void 0===r||void 0===o)continue;const d=i(n),h=o*u+r,f=v.get(h);let p;void 0!==f?p=f:(p=w++,v.set(h,p)),g[p]=h,x[p]=d,b[p]=n}let k=1/0,S=-1/0;for(let e=0;w>e;e++){const t=x[e];isFinite(t)&&(k>t&&(k=t),t>S&&(S=t))}if(!isFinite(k)||!isFinite(S))return[];const A=function(e){const t=e in C?e:"blues";let n=pt.get(t);if(n)return n;n=Array(256);const i=(r=t)&&C[r]||m;var r;for(let e=0;256>e;e++)n[e]=i(e/255);return pt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),M=255/(S-k||1),P=n.width/u,_=n.height/d,j=e.config.showValues,I=e.config.heatmapValueFormat,T=[];for(let e=0;w>e;e++){const t=x[e];if(!isFinite(t))continue;const n=g[e],i=n%u;T.push(Je(i*P,(d-1-(n-i)/u)*_,P,_,A[Math.min((t-k)*M+.5|0,255)],b[e],j?{value:t,showValues:!0,valueFormat:I}:void 0))}return T}function gt(e,t,n,i,r){const o=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/i)*i;let l=o.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},o.set(c,l)),l.total+=a,r){const e=r(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return o}function mt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:i,warned:r}=e;xt(i)&&0===n.length&&bt(r,"overlay-only",`[semiotic] ${t} 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(e=>null==e.datum)&&bt(r,"null-datums",`[semiotic] ${t} 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 xt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(xt))}function bt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function vt(e,t,n,i){const r=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),o="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:o,message:`Semiotic ${e} ${o} failed: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:i}}function wt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function kt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,i=wt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Ie(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=i(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t+r:t},getBottom:e=>{const t=i(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t-r:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:wt(e.y1Accessor,"y1"),getBottom:wt(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var St=require("d3-scale");function At(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Mt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,St.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,St.scaleSymlog)().domain(t).range(n):"time"===e?(0,St.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,St.scaleLinear)().domain(t).range(n)}function Pt(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function _t(e,t){const n=new _e(e.capacity);return e.forEach(()=>n.push(t)),n}function jt(e,t,n,i){const r=e.push(t);return n&&n.push(i),r}function Ct(e,t,n){if(!t||0===t.size)return;const i=new Set;if(e.forEach((e,t)=>{n(e)&&i.add(t)}),0===i.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)i.has(e)||t.push(r[e])}var It={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 Tt(e,t){const n={...e};for(const e of t)n[It[e]]++;return n}function Rt(e,t,n){const i=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:i,revisions:Tt(n,i)}}var Lt=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=Rt({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(e,t){const n=Rt(e,t,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},$t=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Et=["scene-style","data-paint","accessibility","evidence"],zt=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),Dt=class{constructor(){this.tracker=new Lt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},$t)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Et):this.recordNoop("restyle")}recordConfig(e,t,n){return this.tracker.record({kind:"config",keys:e},t?function(e,t){const n=new Set(["layout","scene-geometry","data-paint","overlay","accessibility","evidence"]);return t&&n.add("domain"),e.some(e=>zt.has(e))&&n.add("scene-style"),n}(e,n):[])}},Bt=require("d3-quadtree"),Ft=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(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,i=0;for(const e of t)"point"===e.type&&(n++,e.r>i&&(i=e.r));if(this.maxRadius=i,500>=n)return void(this.tree=null);const r=Array(n);let o=0;for(const e of t)"point"===e.type&&(r[o++]=e);this.tree=(0,Bt.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}},Nt=class e{constructor(e){if(this.xExtent=new je,this.yExtent=new je,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 Dt,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 Ft,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,i,r,o=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=r??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=i.get(t);if(null==s)continue;const c=qe(e,s,o);c>r&&(r=c)}a&&(c=Ye(n,r,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=i.get(t);c=Ye(n,null==r?0:qe(e,r,o),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this._stylePaintPending=!1,this.config=e,this.buffer=new _e(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Ie(e.timeAccessor||e.xAccessor,"time"),this.getY=Ie(e.valueAccessor||e.yAccessor,"value")):(this.getX=Ie(e.xAccessor,"x"),this.getY=Ie(e.yAccessor,"y")),this.getGroup=Re(e.groupAccessor),this.getCategory=Re(e.categoryAccessor),this.getSize=e.sizeAccessor?Ie(e.sizeAccessor,"size"):void 0,this.getColor=Re(e.colorAccessor),this.getSymbol=Re(e.symbolAccessor),this.getY0=e.y0Accessor?Ie(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=kt(e),this.getPointId=Re(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Ie(e.openAccessor,"open"):void 0,this.getHigh=Ie(e.highAccessor,"high"),this.getLow=Ie(e.lowAccessor,"low"),this.getClose=n?Ie(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new _e(e.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=_t(this.buffer,Ne())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=Ne();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?Ie(this.config.timeAccessor||this.config.xAccessor,"time"):Ie(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(t):t[n||"x"],r=i instanceof Date,o="string"==typeof i&&Number.isFinite($e(i));if(this.xIsDate=r||o,o){const e="string"==typeof n?n:void 0;this.getX=e?t=>Ee(t[e]):e=>Ee(n(e))}}Pt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)jt(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),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 ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=jt(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,i=this.scales,r=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const o=this.getBufferArray(),s=this.yExtent.extent;let a=At(this.xExtent.extent,t.xExtent),c=At(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:i,getY:r}=e,o="exact"===t.axisExtent;if(t.normalize){const n=[0,o?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,d=new Map;for(const e of n){const t=new Map;let n=0;for(const o of e.data){const e=i(o),s=r(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,n)}const h=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let p,y;if("input"===h)p=n.map(e=>e.key);else if("insideOut"===h){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}),t=[],i=[];let r=0,o=0;for(const n of e)o>r?(t.push(n),r+=d.get(n)??0):(i.push(n),o+=d.get(n)??0);p=[...i.reverse(),...t]}else p="asc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Ue(e,p,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let i=1/0,r=-1/0;for(const t of e){const e=n.get(t)??0,o=u.get(t)??0;i>e&&(i=e),e+o>r&&(r=e+o)}Number.isFinite(i)&&Number.isFinite(r)||(i=0,r=0);const s=r-i,l=o?0:s>0?s*t.extentPadding:1;y=[i-l,r+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,i]=function(e,t,n){let i=0,r=0;for(const o of e){let e=0,s=0;for(const i of t){const t=n(i,o)||0;0>t?s+=t:e+=t}i>s&&(i=s),e>r&&(r=e)}return[i,r]}(e,p,(e,t)=>a.get(e)?.get(t)||0),r=i-n,s=o?0:r>0?r*t.extentPadding:1;y=[n-s,i+s]}else y=[0,l+(o?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:t,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,i,r,o,s){const[,a]=function(e,t,n,i,r){const o=gt(e,t,n,i,r);if(0===o.size)return[0,0];let s=0;for(const e of o.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,i,r);return[0,s?a:a+a*o]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,i){const[r,o]=function(e,t){let n=0,i=0,r=0;for(const o of e){const e=t(o);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>i&&(i=r))}return[n,i]}(e,t),s=o-r,a=i?0:s>0?s*n:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,o+Math.abs(a))]}(n,this.getY,t.extentPadding,d):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[i,r]=e;for(const e of t)for(const t of n){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&(i>n&&(i=n),n>r&&(r=n)),Number.isFinite(o)&&(i>o&&(i=o),o>r&&(r=o))}return[i,r]}(c,o,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],i=t.exactMode?0:n>0?n*t.extentPadding:1,r=[null!=t.userMin?e[0]:e[0]-i,null!=t.userMax?e[1]:e[1]+i];return"log"!==t.yScaleType||r[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(r[0]=t.dataYDomain[0]/(1+t.extentPadding)),r}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const i=t[0],r=t[1];return null==i&&null==r?e:[null!=i?i:e[0],null!=r?r:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let i=e,r=t;if(i[0]===1/0||i[1]===-1/0)if("time"===n){const e=Date.now();i=[e-864e5,e]}else i=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:i,yDomain:r}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:i,yDomain:r}=e,o="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(o){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,St.scaleLinear)().domain(i).range(e),y:Mt(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Mt(t.yScaleType,r,[s,n.width-s]),y:(0,St.scaleLinear)().domain(i).range(e)}}var a;return{x:Mt(t.xScaleType,i,[s,n.width-s]),y:Mt(t.yScaleType,r,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.lastLayout=r):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=h,this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),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:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const i of e.path)i[0]*=t,i[1]*=n;break;case"area":for(const i of e.topPath)i[0]*=t,i[1]*=n;for(const i of e.bottomPath)i[0]*=t,i[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const i=this.scales.x.domain(),r=this.scales.y.domain(),o=this.scales.x.range(),s=this.scales.y.range(),a=Mt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,o[0]>o[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,r,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:i}=this;if(!i)return[];if(n.customLayout){const r={data:t,scales:i,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??R},resolveColor:(e,t)=>{const i=this.resolveGroupColor(e);if(i)return i;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let o;try{o=n.customLayout(r)}catch(e){const t=null!==this.lastCustomLayoutResult,i=vt("xy",e,t,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const s=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return mt({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===t.length)return[];const r={scales:i,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),i=[],r=e.config.annotations?.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),o=Xe(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(o.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),i.push(o)}return st(e,n,i),i}(r,t);case"area":return function(e,t){const n=e.groupData(t),i=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}const r=e.scales.y.domain()[0],o=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Ve(t.data,e.scales,e.getX,e.getY,r,n,t.key,o),a=ct(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),i.push(s)}return st(e,n,i),i}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),i=[],r=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}const o=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Ve(t.data,e.scales,e.getX,e.getY,o,n,t.key,s),a=ct(e.config.gradientFill);a&&(r.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=Xe(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}return st(e,n,i),i}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t),i=e.config.stackOrder??"key",r=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===i);else if("key"===i)r();else if("asc"===i||"desc"===i||"insideOut"===i){const t=new Map;for(const i of n){let n=0;for(const t of i.data){const i=e.getX(t),r=e.getY(t);Number.isFinite(i)&&Number.isFinite(r)&&(n+=r)}t.set(i.key,n)}const r=(e,t)=>t>e?-1:e>t?1:0;if("asc"===i)n.sort((e,n)=>{const i=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==i?i:r(e.key,n.key)});else if("desc"===i)n.sort((e,n)=>{const i=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==i?i:r(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const i=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==i?i:r(e.key,n.key)}),i=[],o=[];let s=0,a=0;for(const n of e)a>s?(i.push(n),s+=t.get(n.key)??0):(o.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...o.reverse(),...i)}}else r();const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,i,r,o,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),o=i(r);Number.isFinite(t)&&Number.isFinite(o)&&e.set(t,(e.get(t)||0)+o)}u.set(t.key,e)}let d;if(o){d=new Map;for(const t of l){let n=0;for(const i of e)n+=u.get(i.key)?.get(t)||0;d.set(t,n||1)}}const h=Ue(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!o,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const e of l)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),i=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),p.push(e)}a=[],c=[]};for(const n of l){const r=e.has(n);let s,l,u=r?e.get(n):0;if(o&&r&&(u/=d.get(n)),!r||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const p=t.x(n);c.push([p,t.y(s)]),a.push([p,t.y(l)]),i.set(n,l)}h(),y.set(n.key,i)}return{nodes:p,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const i of n){const n=c.get(i.key);if(n)for(const r of i.data){const i=e.getX(r),o=e.getY(r);null==i||Number.isNaN(i)||null==o||Number.isNaN(o)||!n.has(i)||t.set(r,n.get(i))}}const i=n=>t.get(n)??e.getY(n);st(e,n,l,i)}return l}(r,t);case"scatter":case"bubble":return function(e,t){const n=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let o=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const i of n)e>i&&(e=i),i>t&&(t=i);o=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=dt[d%dt.length],d++,u.set(e,n)),n};for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:a,opacity:.8},l=t.r||i;if(o&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(l=o(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(c){const i=h(c(r)+""),o=Ze(r,e.scales,e.getX,e.getY,Math.PI*l*l,i,t,u);o&&n.push(o)}else{const i=Ke(r,e.scales,e.getX,e.getY,l,t,u);i&&n.push(i)}}return n}(r,t);case"heatmap":return yt(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=gt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let i=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const r=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(r),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=r.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?i=e.barCategoryCache.order:(i=[...a,...s],e.barCategoryCache={key:c,order:i})}const r=[],o=e.scales,[s,a]=o.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=o.x(n),p=o.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(i&&t.categories.size>0){let n=0;for(const s of i){const i=t.categories.get(s)||0;if(0===i)continue;const a=o.y(n),u=o.y(n+i);r.push(Qe(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:i},s)),n+=i}}else{const e=o.y(0),n=o.y(t.total);r.push(Qe(m,Math.min(e,n),x,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...h},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:r,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],i=e.config.swarmStyle||{},r=i.radius??3,o=i.fill??e.config.themeSemantic?.primary??"#007bff",s=i.opacity??.7,a=i.stroke,c=i.strokeWidth;for(const i of t){const t=e.getX(i),l=e.getY(i);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),d=e.scales.y(l);let h=o;if(e.getCategory){const t=e.getCategory(i);h=e.config.barColors?.[t]||h}const{r:f,...p}=e.config.pointStyle?.(i)??{},y={type:"point",x:u,y:d,r:f??r,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...p},datum:i};e.getPointId&&(y.pointId=e.getPointId(i)+""),n.push(y)}return n}(r,t);case"waterfall":return function(e,t,n){const i=[],r=e.scales,o=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),i=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===s.length)return i;const a=o?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=o?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=o?.gap??1,u=o?.stroke,d=o?.strokeWidth,h=o?.opacity;let f=0;for(let t=0;s.length>t;t++){const p=s[t],y=e.getX(p),g=e.getY(p),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-y:t>0?y-e.getX(s[t-1]):0;const b=r.x(y),v=0!==x?r.x(y+x):b+n.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=r.y(f),A=r.y(m),M=Math.min(S,A),P=Math.abs(S-A),_={fill:0>g?c:a,stroke:u,strokeWidth:d};null!=h&&(_.opacity=h),i.push(Qe(w,M,k,P,_,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),f=m}return i}(r,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const i=[],r=e.config.candlestickStyle||{},o=r.rangeColor||"#6366f1",s=n?o:r.upColor||"#28a745",a=n?o:r.downColor||"#dc3545",c=n?o:r.wickColor||"#333",l=r.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let d=r.bodyWidth??0;if(null==r.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const i=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));i>0&&t>i&&(t=i)}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6;for(const r of t){const t=e.getX(r);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(r),u=e.getLow(r);if(null==o||Number.isNaN(o)||null==u||Number.isNaN(u))continue;const h=n?o:e.getOpen(r),f=n?u:e.getClose(r);if(!n&&[h,f].some(e=>null==e||Number.isNaN(e)))continue;const p=f>=h,y={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(h),closeY:e.scales.y(f),highY:e.scales.y(o),lowY:e.scales.y(u),bodyWidth:d,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:r};n&&(y.isRange=!0),i.push(y)}return i}(r,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,i){const r=e.boundsStyle;return"function"==typeof r?r(n||{},t):r&&"object"==typeof r?r:{fill:i(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Oe(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=We(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,i=We(n)){const r=n.length;if(r>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=i.get(t[n]);null!=a?(o[n]=Oe(e,a,r),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const s=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=i.get(t[n]);null!=o?(s[n]=Oe(e,o,r),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=i.get(n);if(null!=t){const n=Oe(e,t,r);s>n&&(s=n)}}if(1>s){const e=Array(o);e.fill(s),n._decayOpacities=e}}continue}const t=i.get(n.datum);if(null==t)continue;const o=Oe(e,t,r);"heatcell"===n.type?n.style={opacity:o}:"candlestick"===n.type?n._decayOpacity=o:n.style={...n.style,opacity:(n.style?.opacity??1)*o}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&He(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ne())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,i){n.clear(),i.clear();for(let r=0;t.length>r;r++){const o=t[r],s=Ge(e,o,r);s&&("point"===o.type?n.set(s,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"glyph"===o.type?n.set(s,{x:o.x,y:o.y,r:o.size,opacity:o.style.opacity,glyph:o.glyph}):"rect"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"heatcell"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style?.opacity}):"candlestick"===o.type?n.set(s,{x:o.x,y:o.openY,w:o.bodyWidth,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY,opacity:o.style?.opacity}):"line"===o.type?i.set(s,{path:o.path.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}):"area"===o.type&&i.set(s,{topPath:o.topPath.map(e=>[e[0],e[1]]),bottomPath:o.bottomPath.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],i=Ge(this.transitionContext,n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(i,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(i,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,i,r){if(0===i.size&&0===r.size)return n;const o=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let s=!1;const a=new Set,c=new Set;for(let t=0;n.scene.length>t;t++){const o=n.scene[t],l=Ge(e,o,t);if(!l)continue;if(o._transitionKey=l,"line"===o.type||"area"===o.type){const e=r.get(l);if(e){if(c.add(l),"line"===o.type&&e.path&&e.path.length===o.path.length){o._targetPath=o.path.map(e=>[e[0],e[1]]),o._prevPath=e.path;for(let t=0;o.path.length>t;t++)o.path[t]=[e.path[t][0],e.path[t][1]];s=!0}else if("area"===o.type&&e.topPath&&e.bottomPath&&e.topPath.length===o.topPath.length&&e.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(e=>[e[0],e[1]]),o._targetBottomPath=o.bottomPath.map(e=>[e[0],e[1]]),o._prevTopPath=e.topPath,o._prevBottomPath=e.bottomPath;for(let t=0;o.topPath.length>t;t++)o.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;o.bottomPath.length>t;t++)o.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];s=!0}o._targetOpacity=o.style.opacity??1,o._startOpacity=e.opacity??o.style.opacity??1}else o._targetOpacity=o.style.opacity??1,o._startOpacity=0,o.style={...o.style,opacity:0},s=!0;continue}const u=i.get(l);if("point"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,r:o.r};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.r,o.x=u.x,o.y=u.y,o.r=u.r??o.r,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("glyph"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,size:o.size};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.size,o.x=u.x,o.y=u.y,o.size=u.r??o.size,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("rect"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("heatcell"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0;else if("candlestick"===o.type)if(u&&null!=u.openY){a.add(l);const e={x:o.x,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY};o._targetOpacity=o.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(o._targetX=e.x,o._targetOpenY=e.openY,o._targetCloseY=e.closeY,o._targetHighY=e.highY,o._targetLowY=e.lowY,o.x=u.x,o.openY=u.openY,o.closeY=u.closeY??o.closeY,o.highY=u.highY??o.highY,o.lowY=u.lowY??o.lowY,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0}for(const[e,t]of r)if(!c.has(e))if(e.startsWith("l:")&&t.path){const i={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(i),s=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const i={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(i),s=!0}for(const[e,t]of i)if(!a.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const i=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:i,closeY:t.closeY??i,highY:t.highY??i,lowY:t.lowY??i,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}s=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),s&&(n.activeTransition={startTime:Ne(),duration:o}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,i){if(!n.activeTransition)return!1;const r=Be(e,n.activeTransition),o=De(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.r=Fe(n.r,e._targetR,o))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.size=Fe(n.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==n.w&&(e.w=Fe(n.w,e._targetW,o)),void 0!==n.h&&(e.h=Fe(n.h,e._targetH,o))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style={...e.style||{},opacity:Fe(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==n.w&&(e.w=Fe(n.w,e._targetW,o)),void 0!==n.h&&(e.h=Fe(n.h,e._targetH,o))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style={...e.style||{},opacity:Fe(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),void 0!==n.openY&&(e.openY=Fe(n.openY,e._targetOpenY,o)),void 0!==n.closeY&&(e.closeY=Fe(n.closeY,e._targetCloseY,o)),void 0!==n.highY&&(e.highY=Fe(n.highY,e._targetHighY,o)),void 0!==n.lowY&&(e.lowY=Fe(n.lowY,e._targetLowY,o))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fe(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let i=0;e.path.length>i;i++)e.path[i][0]=Fe(t[i][0],n[i][0],o),e.path[i][1]=Fe(t[i][1],n[i][1],o)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fe(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevTopPath,n=e._prevBottomPath,i=e._targetTopPath,r=e._targetBottomPath;if(t&&i&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Fe(t[n][0],i[n][0],o),e.topPath[n][1]=Fe(t[n][1],i[n][1],o);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Fe(n[t][0],r[t][0],o),e.bottomPath[t][1]=Fe(n[t][1],r[t][1],o)}}if(r>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,i){if(i&&i.version===n&&i.group===t&&i.data===e)return{result:i.result,cache:i};let r;if(t){const n=new Map;for(const i of e){const e=t(i);n.has(e)||n.set(e,[]),n.get(e).push(i)}r=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else r=[{key:"_default",data:e}];return{result:r,cache:{version:n,group:t,data:e,result:r}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,i,r){if(r&&r.version===i)return{map:r.map,cache:r};const o=new Set;if(t)for(const n of e){const e=t(n);e&&o.add(e)}const s=Array.from(o).sort(),a=s.join("\0");if(r&&r.key===a){const e={...r,version:i};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||R,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:i}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,i){const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.stroke&&t){const n=i(t);if(n)return{...e,stroke:n}}return e}const o=e.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||o||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:i(t)||o||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,i){if(e.areaStyle){const r=e.areaStyle(n||{});if(r&&!r.fill&&t){const e=i(t);if(e)return{...r,fill:e,stroke:r.stroke||e}}return r}const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.fill&&t){const n=i(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const o=e.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||o||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||o||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=i(t)||o||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:i}=function(e){const{group:t,colorMapCache:n,groupColorMap:i,groupColorMapCap:r,config:o}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=i.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(o.colorScheme)&&o.colorScheme.length>0?o.colorScheme:null)||(Array.isArray(o.themeCategorical)&&o.themeCategorical.length>0?o.themeCategorical:null)||R;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,i.set(t,l),i.size>r){const e=i.keys().next().value;void 0!==e&&i.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=i,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ze(e),n=this.getPointId,i=e=>t.has(n(e));Ct(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ne(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=ze(e),i=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(i(e))&&r.add(t)});const o=this.buffer.update(e=>n.has(i(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ne(),this.updateResults.recordData("update",o.length),o}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(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},r=n(i,t);i.style=r?{...e,...r}:e}}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this._stylePaintPending=!0,this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.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 e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let i=!1,r=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const o="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(o||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=o||!Ce(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=o||!Ce(n,s);(a||c)&&(e?(this.getX=Ie(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Ie(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Ie(this.config.xAccessor,"x"),this.getY=Ie(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=kt(this.config)),i=!0,r=!0)}if("groupAccessor"in e&&!Ce(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Re(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in e&&!Ce(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Re(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in e&&!Ce(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Ie(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in e&&!Ce(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Re(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Re(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in e&&!Ce(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Ie(this.config.y0Accessor,"y0"):void 0,i=!0,r=!0),("boundsAccessor"in e&&!Ce(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=kt(this.config),i=!0,r=!0),"pointIdAccessor"in e&&!Ce(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Re(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in e&&!Ce(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Ce(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Ce(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Ce(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Ie(this.config.openAccessor,"open"):void 0,this.getHigh=Ie(this.config.highAccessor,"high"),this.getLow=Ie(this.config.lowAccessor,"low"),this.getClose=t?Ie(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,i=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(i=!0,r=!0),!i){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const r of n)if(e[r]!==t[r]){i=!0;break}}i&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,i,r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Nt.GROUP_COLOR_MAP_CAP=1e3;var Ot=Nt,Wt={sceneGeometry:0,layout:0,domain:0},qt="production"!==process.env.NODE_ENV,Yt={revisions:Wt,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},Ht=class{constructor(){this.lastConsumed=Wt,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(e,t){if(!qt)return Yt;const n=function(e){const{domain:t,layout:n,sceneGeometry:i}=e.revisions;return{domain:t,layout:n,sceneGeometry:i}}(e),i=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((o=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&o.layout===s.layout&&o.domain===s.domain);var o,s;return{revisions:n,signature:i,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==i}}afterCompute(e,t,n){if(qt){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] StreamXYFrame observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] StreamXYFrame performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},Gt=c(require("react"));function Xt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:Gt.createElement(Gt.Fragment,null,...t)}var Vt=c(require("react")),Ut=require("react/jsx-runtime"),Kt=Vt.createContext(null);function Zt({value:e,children:t}){return(0,Ut.jsx)(Kt.Provider,{value:e,children:t})}function Qt(e,t){return null!=e?(0,Ut.jsx)(Zt,{value:t,children:e}):e}var Jt=require("react");function en(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>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 tn(e,t=30){return Math.max((e??4)+5,12,t)}function nn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function rn(e,t){const n=nn(e);if(!n)return!1;const i=nn(t);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}var on=[40,40],sn=[.5,.5];function an(e,t){const[n,i]=e.viewBox??on,[r,o]=e.anchor??sn,s=i>0?i:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-o*l}}function cn(e,t,n,i){if("none"!==e)return"color"===e||null==e?t??i:"accent"===e?n:e}var ln=null;function un(e){if("undefined"==typeof Path2D)return null;ln||(ln=new Map);const t=ln.get(e);if(t)return t;const n=new Path2D(e);return ln.size>1024&&ln.clear(),ln.set(e,n),n}function dn(e,t,n=0,i="horizontal"){const[r,o]=e.viewBox??on,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===i?{x:0,y:o*(1-a),width:r,height:o*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:o}:null:{x:0,y:0,width:0,height:0}}function hn(e,t){const n=an(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function fn(e,t,n,i,r,o=e=>e){for(const s of t.parts){const t=un(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=r?"none"===s.fill?void 0:r:cn(s.fill,n,i);l&&(e.fillStyle=o(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:cn(s.stroke??"none",n,i);u&&(e.strokeStyle=o(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}var pn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,yn=new WeakMap,gn=0,mn=!1,xn=null,bn=null;function vn(e,t){if(!t)return t;const n=pn.exec(t);if(!n)return t;const i=e.canvas;if(!i)return n[2]?.trim()||t;!function(){if(mn)return;if("undefined"==typeof window||"undefined"==typeof document)return;mn=!0;const e=()=>{gn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{xn=window.matchMedia("(prefers-color-scheme: dark)"),bn=e,"function"==typeof xn.addEventListener?xn.addEventListener("change",bn):"function"==typeof xn.addListener&&xn.addListener(bn)}catch{}}();let r=yn.get(i);r&&r.version===gn||(r={version:gn,map:new Map},yn.set(i,r));const o=r.map.get(t);if(void 0!==o)return o;const s=getComputedStyle(i).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return r.map.set(t,s),s}var wn=require("d3-shape");function kn(e){switch(e){case"monotoneX":return wn.curveMonotoneX;case"monotoneY":return wn.curveMonotoneY;case"cardinal":return wn.curveCardinal;case"catmullRom":return wn.curveCatmullRom;case"step":return wn.curveStep;case"stepBefore":return wn.curveStepBefore;case"stepAfter":return wn.curveStepAfter;case"basis":return wn.curveBasis;case"natural":return wn.curveNatural;default:return null}}function Sn(e,t,n){return null==t?n:"string"!=typeof t?t:vn(e,t)||n}function An(e,t,n,i,r,o,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(i,r,o,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),d=e.createLinearGradient(i,r,o,s),[h,f,p]=function(e,t){const n=e.fillStyle,i="#010203";try{e.fillStyle=i,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const r=e.fillStyle;if(e.fillStyle=n,"string"!=typeof r)return[78,121,167];if(r.toLowerCase()===i&&t.trim().toLowerCase()!==i)return[78,121,167];if(r.startsWith("#"))return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)];const o=r.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return o?[+o[1],+o[2],+o[3]]:[78,121,167]}(e,n);return d.addColorStop(0,`rgba(${h},${f},${p},${l})`),d.addColorStop(1,`rgba(${h},${f},${p},${u})`),d}function Mn(e,t,n,i,r,o){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,i,r,o);for(const e of s)a.addColorStop(e.offset,e.color);return a}var Pn=require("d3-shape"),_n=new WeakMap;function jn(e,t){const n=kn(t);if(!n)return e;const i=_n.get(e);if(i)return i;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const i=[];let r=null;const o={moveTo(e,t){r=[e,t],i.push([e,t])},lineTo(e,t){r=[e,t],i.push([e,t])},bezierCurveTo(e,t,o,s,a,c){if(!r)return r=[a,c],void i.push([a,c]);const[l,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;i.push([h*h*h*l+3*h*h*d*e+3*h*d*d*o+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*c])}r=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,o){r=[n,o],i.push([n,o])}};return(0,Pn.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(o)(e),i}(e,n);return _n.set(e,r),r}function Cn(e,t,n,i=30,r,o=0){let s=null;if(r){const e=function(e,t,n,i,r,o=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(i,r+5,12),l=t-c,u=t+c,d=n-c,h=n+c;let f=null,p=1/0;return e.visit((e,r,c,y,g)=>{if(r>u||l>y||c>h||d>g)return!0;if(!e.length){let r=e;do{const e=r.data,c=o(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);tn(a(e),i)>=u&&p>u&&(f=e,p=u),r=r.next}while(r)}return!1}),f?{node:f,distance:p}:null}(r,t,n,i,o);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const o of e){let e=null;switch(o.type){case"point":if(r)break;e=Tn(o,t,n,i);break;case"symbol":e=Rn(o,t,n,i);break;case"glyph":e=Ln(o,t,n,i);break;case"line":e=$n(o,t,n,i);break;case"rect":if(null==o.datum)break;e=zn(o,t,n);break;case"heatcell":e=Dn(o,t,n);break;case"area":if(!1===o.interactive)break;e=Fn(o,t,n);break;case"candlestick":e=Bn(o,t,n)}e&&i>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function In(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const i=Nn(e,t);if(0>i)return null;if(Math.abs(e[i][0]-t)>n)return null;let r=i,o=i;i>0&&e[i][0]>=t?(r=i-1,o=i):e.length-1>i&&(r=i,o=i+1);const[s,a]=e[r],[c,l]=e[o];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function Tn(e,t,n,i=30){const r=t-e.x,o=n-e.y,s=Math.sqrt(r*r+o*o);return s>tn(e.r,i)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Rn(e,t,n,i=30){const r=t-e.x,o=n-e.y,s=Math.sqrt(r*r+o*o);return s>tn(ft(e.size),i)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Ln(e,t,n,i=30){if(null==e.datum)return null;const r=hn(e.glyph,e.size),o=e.x+r.centerDx,s=e.y+r.centerDy,a=t-o,c=n-s,l=Math.sqrt(a*a+c*c);return l>tn(r.radius,i)?null:{node:e,datum:e.datum,x:o,y:s,distance:l}}function $n(e,t,n,i=30){if(0===e.path.length)return null;const r=Nn(e.path,t);if(0>r)return null;const[o,s]=e.path[r];let a;if(e.path.length>1){let i=1/0;const o=Math.max(0,r-1),s=Math.min(e.path.length-2,r);for(let r=o;s>=r;r++){const[o,s]=e.path[r],[a,c]=e.path[r+1],l=En(t,n,o,s,a,c);i>l&&(i=l)}a=i}else{const e=t-o,i=n-s;a=Math.sqrt(e*e+i*i)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,i)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:s,distance:a}}function En(e,t,n,i,r,o){const s=r-n,a=o-i,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-i)**2);let l=((e-n)*s+(t-i)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(i+l*a))**2)}function zn(e,t,n){const i=en(t,n,e);return i.hit?{node:e,datum:e.datum,x:i.cx,y:i.cy,distance:0}:null}function Dn(e,t,n){const i=en(t,n,e);return i.hit?{node:e,datum:e.datum,x:i.cx,y:i.cy,distance:0}:null}function Bn(e,t,n){const i=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-i-3>t||t>e.x+i+3||e.highY-3>n||n>e.lowY+3)){const i=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,o=t-e.x,s=n-i;return{node:e,datum:e.datum,x:e.x,y:i,distance:Math.sqrt(o*o+s*s)}}return null}function Fn(e,t,n){if(0===e.topPath.length)return null;const i=Nn(e.topPath,t);if(0>i)return null;const[r,o]=e.topPath[i],s=t-r,a=n-o,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:r,y:o,distance:c}}function Nn(e,t){if(0===e.length)return-1;let n=0,i=e.length-1;for(;i>n;){const r=n+i>>1;t>e[r][0]?n=r+1:i=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function On(e,t,n){const i=e.byGroup.get(t);let r=0,o=Math.abs(i[0].x-n.x);for(let e=1;i.length>e;e++){const t=Math.abs(i[e].x-n.x);o>t&&(o=t,r=e)}return i[r]._flatIndex}function Wn(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}var qn=require("react"),Yn={fresh:1,aging:.7,stale:.45,expired:.25},Hn={alpha:1,band:"fresh",isStale:!1};function Gn(e,t){if(!e||0>=t)return Hn;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,i=e.graded;if(i){const e="object"==typeof i?i:{},r=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...Yn,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Hn}var Xn=require("react/jsx-runtime");function Vn({isStale:e,position:t}){return(0,Xn.jsx)("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"})}var Un=require("react"),Kn=c(require("react")),Zn=require("react/jsx-runtime"),Qn={fill:(e,t)=>(0,Zn.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Zn.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Jn(e,t,n,i,r){let o;return o="function"==typeof n?n(e):(0,Qn[n])(i(e,t),r),o}function ei({swatchSize:e}){return(0,Zn.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ti(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var ni=(e,t,n,i,r,o,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:f}=e,p=[];let y=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=r,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((e,l)=>{const u=Jn(e,l,d,h,x),w=ti(e,i,r),k=r&&r.size>0&&r.has(e.label);p.push((0,Zn.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===o&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const i=t.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,Zn.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&(0,Zn.jsx)(ei,{swatchSize:x}),(0,Zn.jsx)("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),y+=v}),p};function ii({config:e,orientation:t="vertical",width:n=100}){const{colorFn:i,domain:r,label:o,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+Kn.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Zn.jsx)("stop",{offset:100*t+"%",stopColor:i(r[0]+t*(r[1]-r[0]))},e))}return(0,Zn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[(0,Zn.jsx)("defs",{children:(0,Zn.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),o&&(0,Zn.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Zn.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,Zn.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),(0,Zn.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Zn.jsx)("stop",{offset:100*t+"%",stopColor:i(r[1]-t*(r[1]-r[0]))},e))}return(0,Zn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[o&&(0,Zn.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Zn.jsx)("defs",{children:(0,Zn.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,Zn.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,Zn.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),(0,Zn.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function ri(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[f,p]=Kn.useState(0),[y,g]=Kn.useState(0),m=Kn.useCallback((e,t)=>{p(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push((0,Zn.jsx)("line",{stroke:"gray",x1:0,y1:d,x2:t,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push((0,Zn.jsx)("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push((0,Zn.jsx)("g",{className:"legend-item",transform:`translate(0,${d})`,children:ni(e,n,i,r,o,s,a,f,c,l,u)},"legend-group-"+f)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const y=((e,t,n,i,r,o,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:f,items:p}=e,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=p.map(e=>g+m+7*e.label.length),A=[];let M=0,P=0;S.forEach((e,t)=>{const n=0===P?e:P+x+e;d&&d>0&&P>0&&n>d?(A.push({start:M,end:t,width:P}),M=t,P=e):P=n}),p.length>0&&A.push({start:M,end:p.length,width:P}),A.forEach((e,l)=>{let u="center"===v?Math.max(0,((d??e.width)-e.width)/2):"end"===v?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=p[d],v=Jn(e,d,h,f,g),A=ti(e,i,r),M=r&&r.size>0&&r.has(e.label);y.push((0,Zn.jsxs)("g",{transform:`translate(${u},${l*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===o&&d===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(a,d),n&&n(e);const i=t.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&(0,Zn.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,M&&(0,Zn.jsx)(ei,{swatchSize:g}),(0,Zn.jsx)("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+x}});const _=Math.max(0,...A.map(e=>e.width)),j=A.length;return{items:y,offset:_,totalRows:j,totalHeight:j*b}})(e,i,r,o,s,a,c,t,l,u,d,d.maxWidth??n);p+=y.offset+5,f.push({label:e.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=p+12});const p=d.maxWidth??n;let y=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const g=[];return f.forEach((n,i)=>{const r=e[i];r.label&&(g.push((0,Zn.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+i)),y+=16),g.push((0,Zn.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+i)),y+=n.offset+5,e[i+1]&&g.push((0,Zn.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+i)),y+=12}),(0,Zn.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!i);return(0,Zn.jsxs)("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==o))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,Zn.jsx)("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function oi(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function si(e){return"object"==typeof e&&null!==e&&"gradient"in e}var ai=require("react/jsx-runtime");function ci(e){const{legend:t,totalWidth:n,totalHeight:i,margin:r,legendPosition:o="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===o||"bottom"===o,p=!!a,y=Math.max(0,n-r.left-r.right),g=Math.max(1,f?s?.maxWidth??y:100);let m,x;return"left"===o?(m=Math.max(4,r.left-g-10),x=r.top):"top"===o?(m=r.left,x=p?32:8):"bottom"===o?(m=r.left,x=i-r.bottom+38):(m=n-r.right+10,x=r.top),(0,ai.jsx)("g",{transform:`translate(${m}, ${x})`,children:si(t)?(0,ai.jsx)(ii,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):oi(t)?(0,ai.jsx)(ri,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t})}var li=require("react"),ui=require("d3-array");function di(e){let t=1/0,n=-1/0;for(const i of e)t>i&&(t=i),i>n&&(n=i);return[t,n]}function hi(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}var fi=require("react/jsx-runtime");function pi(e){return"string"==typeof e?{type:e}:e}function yi({orient:e,config:t,values:n,scale:i,size:r,length:o}){const s=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,c=(0,li.useMemo)(()=>{if(0===n.length)return null;const t=i.domain(),c=r-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const i=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],o=t[Math.floor(.75*n)],s=o-i;return{q1:i,median:r,q3:o,whiskerLow:Math.max(t[0],i-1.5*s),whiskerHigh:Math.min(t[n-1],o+1.5*s)}}(n);if(!t)return null;const{q1:r,median:o,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*c,20),f=(c-h)/2+4;if(a){const t=i(r),n=i(l),a=i(o),c=i(u),p=i(d),y="top"===e?-1:1,g=0;return(0,fi.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,fi.jsx)("line",{x1:c,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:c,y1:g+y*f,x2:c,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:s.fill,strokeWidth:2})]})}{const t=i(r),n=i(l),a=i(o),c=i(u),p=i(d),y="left"===e?-1:1,g=0;return(0,fi.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,fi.jsx)("line",{x1:g+y*(f+h/2),y1:c,x2:g+y*(f+h/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:g+y*f,y1:c,x2:g+y*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,ui.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=hi(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,fi.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*c;if(a){const o=i(t.x0),a=i(t.x1)-i(t.x0);return(0,fi.jsx)("rect",{x:o,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const o=i(t.x0),a=i(t.x1)-i(t.x0);return(0,fi.jsx)("rect",{x:"left"===e?-4-r:4,y:Math.min(o,o+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const r of l){if(null==r.x0||null==r.x1)continue;const o=r.length/u*(c/2),s=i((r.x0+r.x1)/2);n.push(a?`${s},${"top"===e?-(t-o):t-o}`:`${"left"===e?-(t-o):t-o},${s}`)}for(let r=l.length-1;r>=0;r--){const o=l[r];if(null==o.x0||null==o.x1)continue;const s=o.length/u*(c/2),d=i((o.x0+o.x1)/2);n.push(a?`${d},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${d}`)}return(0,fi.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,fi.jsx)("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 t=[];if(a){const n=0,r=null!=l[0].x0?i(l[0].x0):0;t.push(`M${r},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,o=i((n.x0+n.x1)/2);t.push(`L${o},${"top"===e?-r-4:r+4}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):o;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,r=null!=l[0].x0?i(l[0].x0):0;t.push(`M${n},${r}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,o=i((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${o}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):o;t.push(`L${n},${s}`),t.push("Z")}return(0,fi.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,fi.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,i,s,r,o,e,a,4]);return c?(0,fi.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var gi=c(require("react")),mi=require("react/jsx-runtime");function xi(e,t=120,n=8){if(!e)return[];const i=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),o=[];let s="";for(const e of r)s&&s.length+1+e.length>i?(o.push(s),s=e):s=s?`${s} ${e}`:e;return s&&o.push(s),o}function bi(e,t,n,i){return"curly"===e?i?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:i?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function vi(e,t,n,i){if(!e)return(0,mi.jsx)("g",{className:"annotation-note"});const{label:r,title:o,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!r&&!o)return(0,mi.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=o?l?[o]:xi(o,c):[],y=r?l?[r]:xi(r,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,mi.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?g-c:"middle"===h?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(o&&r?2:0))+f,style:{overflow:"visible"},children:(0,mi.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[o&&(0,mi.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:o}),r&&(0,mi.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(x.push((0,mi.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((e,t)=>(0,mi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,mi.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((e,t)=>(0,mi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((o||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=(0,mi.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),v=(0,mi.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),(0,mi.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,mi.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function wi(e,t,n,i,r){const o=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&o.push((0,mi.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,i=t?.height||0;(e>0||i>0)&&o.push((0,mi.jsx)("rect",{width:e,height:i,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&o.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=i||0,s=r||0;if(void 0!==t?.x){const i=(t.x||0)-e;o.push((0,mi.jsx)("line",{x1:i,y1:(t.y1||0)-s,x2:i,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const i=(t.y||0)-s;o.push((0,mi.jsx)("line",{x1:(t.x1||0)-e,y1:i,x2:(t.x2||0)-e,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?o.push((0,mi.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||o.push((0,mi.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&o.push((0,mi.jsx)("path",{d:bi(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,mi.jsx)("g",{className:"annotation-subject",children:o})}function ki(e,t,n,i,r,o){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!o?.radius){if("callout-rect"===r&&o){const n=o.width||0,i=o.height||0;if(n>0||i>0){const r=n/2,o=i/2,s=e-r,l=t-o;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,d=i/2,h=e*d>t*u?u/e:d/t;a=r+s*h,c=o+l*h}}}else if("bracket"===r&&o){const e=o.width,t=o.height,n=o.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const i=Math.atan2(t,e);a=Math.cos(i)*n,c=Math.sin(i)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",o="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(o){const i=(a+e)/2,o=(c+t)/2,d=-(t-c)/l,h=(e-a)/l,f=(n?.curve??.25)*l,p=i+d*f,y=o+h*f;s.push((0,mi.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,mi.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,mi.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,mi.jsx)("g",{className:"annotation-connector",children:s})}function Si(e){const{x:t=0,y:n=0,dx:i,dy:r,nx:o,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=i||0,k=r||0;null!=o&&(w=o-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const e=l.depth||30;k=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;w=e+(0>e?-5:5),k=l.height/2}return(0,mi.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&ki(w,k,c,d,S,l),!v.has("subject")&&wi(S,l,d,x,b),!v.has("note")&&vi(a,w,k,d)]})}function Ai(e){const{noteData:t}=e,{screenCoordinates:n}=t,i="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=t.ny||n[0][1]+(t.dy??0),o=n.map((n,o)=>{const s=Object.assign({},t,{note:0===o?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return(0,mi.jsx)(Si,{"data-testid":"semiotic-annotation",...s,type:i},"multi-annotation-"+o)});return(0,mi.jsx)("g",{children:o})}const o=t.note||{title:"none",label:t.label},s=`${o.label}-${o.title}-${t.i}`;return(0,mi.jsx)(Si,{"data-testid":"semiotic-annotation",events:r,...t,type:i},s)}var Mi=require("d3-hierarchy"),Pi=require("d3-shape"),_i=c(require("regression"));function ji(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Ci(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Ii(e){return null==e?null:e+""}function Ti(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Ri(e,t,n){const i=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId)return Ti(t,n,{x:r.x,y:r.y})}const i=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],i=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!i||!r)return null;const o=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==o||null==s?null:{x:i(o),y:r(s)}}(n);return i?Ti(t,n,i):null}if("semantic"===i){const i=function(e,t,n){const i=function(e){return Ii(e.provenance?.stableId??e.stableId)}(e);if(!i)return null;const r=n.pointNodes?.find(e=>Ii(e.pointId)===i);if(r)return Ti(t,n,{x:r.x,y:r.y});const o=n.data?.find(e=>function(e){return Ii(e.stableId??e.id??e.provenance?.stableId)}(e)===i);if(!o)return null;const s=ji(o,n),a=Ci(o,n);return null==s||null==a?null:Ti(t,n,{x:s,y:a})}(e,t,n);if(i)return i}let r=null,o=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,o=t.y)}if(null!=r&&null!=o||(r=ji(e,n),o=Ci(e,n)),null!=r&&null!=o)return Ti(t,n,{x:r,y:o});if("sticky"===i){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Li(e,t,n,i=50){return!(-i>e||e>(n.width||0)+i||-i>t||t>(n.height||0)+i)}var $i=require("react/jsx-runtime"),Ei={secondary:0,primary:3},zi=1,Di=2,Bi=.6,Fi="0.88em",Ni=.95,Oi=.72,Wi=.06,qi=".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}}",Yi=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Hi(e){return!0===e?._annotationDeferred}function Gi(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Xi(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Vi(e){return Math.max(Oi,Ni-e*Wi)}function Ui(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Xi(e.annotation),readingOrder:null,rank:zi};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),i=e.some(e=>Hi(e.annotation)),r=e.some(e=>null!=Gi(e.annotation)),o=e.some(e=>"layer"===Gi(e.annotation));if(!n&&!i&&!r)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=Di-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Ei[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:i,readingOrder:r}=e,o=Hi(t.annotation);let s=t.node;if("primary"===i||"secondary"===i||null!=r){const e=null==i&&null!=r;s=(0,$i.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i,..."secondary"===i?{opacity:Bi,fontSize:Fi}:{},...e?{opacity:Vi(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const a=Gi(t.annotation);return a&&(s=(0,$i.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),o&&(s=(0,$i.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return i&&a.unshift((0,$i.jsx)("style",{children:qi},"annotation-disclosure-style")),o&&a.unshift((0,$i.jsx)("style",{children:Yi},"annotation-cohesion-style")),a}var Ki=require("react/jsx-runtime"),Zi={linear:Pi.curveLinear,monotoneX:Pi.curveMonotoneX,monotoneY:Pi.curveMonotoneY,step:Pi.curveStep,stepAfter:Pi.curveStepAfter,stepBefore:Pi.curveStepBefore,basis:Pi.curveBasis,cardinal:Pi.curveCardinal,catmullRom:Pi.curveCatmullRom};function Qi(e,t,n,i){const r=[];return e.forEach((e,o)=>{let s;if(n){const r=n(e,o,i);s=null!=r?r:t(e,o,i)}else s=t(e,o,i);s&&r.push({node:s,annotation:e})}),Ui(r)}function Ji(e){return function(e,t,n){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const i=Ri(e,t,n);if(!i)return null;const{x:r,y:o}=i;if(!Li(r,o,n))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,Ki.jsx)(Ai,{noteData:{x:r,y:o,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+t)}case"x-threshold":{const i=ji(null!=e.value?{...e,x:e.value}:e,n);if(null==i)return null;const r=e.color||"#f97316",o=e.labelPosition||"top";let s;s="bottom"===o?(n.height||0)-4:"center"===o?(n.height||0)/2:12;const a=i>.6*(n.width||0),c=a?i-4:i+4,l=a?"end":"start";return(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:c,y:s,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"y-threshold":{const i=Ci(null!=e.value?{...e,y:e.value}:e,n);if(null==i)return null;const r=e.color||"#f97316",o=e.labelPosition||"right";let s,a;return"left"===o?(s=4,a="start"):"center"===o?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:s,y:i-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"enclose":{const i=(e.coordinates||[]).map(e=>({x:ji({...e,type:"point"},n),y:Ci({...e,type:"point"},n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=(0,Mi.packEnclose)(i),o=e.padding||10;return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("circle",{cx:r.x,cy:r.y,r:r.r+o,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ki.jsx)("text",{x:r.x,y:r.y-r.r-o-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"rect-enclose":{const i=(e.coordinates||[]).map(e=>({x:ji({...e,type:"point"},n),y:Ci({...e,type:"point"},n)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=e.padding||10,o=i.map(e=>e.x),s=i.map(e=>e.y),[a,c]=di(o),[l,u]=di(s),d=a-r,h=c+r,f=l-r;return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("rect",{x:d,y:f,width:h-d,height:u+r-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ki.jsx)("text",{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"highlight":{const i=n.data||[],r="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],o={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Ki.jsx)("g",{children:r.map((t,i)=>{const r=ji(t,n),s=Ci(t,n);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||o;return(0,Ki.jsx)("circle",{cx:r,cy:s,r:a,...c},"hl-"+i)})},"ann-"+t)}case"bracket":{const i=ji(e,n),r=Ci(e,n);return(0,Ki.jsx)(Ai,{noteData:{x:i??0,y:r??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,c=s?r:null,l=s?o:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const e of i){const t=e[c];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=i.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const i=h.get(t+"");return null!=i?[i,+n]:null}).filter(e=>null!==e)}else u=i.map(e=>[e[r],e[o]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,p=n.scales?.y??n.scales?.value;if(!f||!p)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),i=Math.min(d.length-1,n+1),r=t-n,o=e(d[n]);return o+(e(d[i])-o)*r},g=f,m=p;let x;if(s)if(a){const e=y(m);x=(t,n)=>[g(n),e(t)]}else{const e=y(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const b=e.method||"linear";let v;v="loess"===b?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const i=e.slice().sort((e,t)=>e[0]-t[0]),r=i.map(e=>e[0]),o=i.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],i=r.map(e=>Math.abs(e-t)),c=i.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:i[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,d+=t*r[e],h+=t*o[e],f+=t*r[e]*r[e],p+=t*r[e]*o[e])}if(0===u){a.push([t,o[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*p-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3):("polynomial"===b?_i.default.polynomial(u,{order:e.order||2}):_i.default.linear(u)).points;const w=v.map(([e,t])=>{const[n,i]=x(e,t);return`${n},${i}`}).join(" "),k=e.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"band":{const i=n.scales?.y??n.scales?.value,r=i?.(e.y0)??0,o=i?.(e.y1)??(n.height||0);return(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("rect",{x:0,y:Math.min(r,o),width:n.width||0,height:Math.abs(o-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&(0,Ki.jsx)("text",{x:(n.width||0)-4,y:Math.max(Math.min(r,o),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"x-band":{const i=n.scales?.x??n.scales?.time,r=null!=e.x0&&i?i(e.x0):null,o=null!=e.x1&&i?i(e.x1):null;return null==r||null==o?null:(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("rect",{x:Math.min(r,o),y:0,width:Math.abs(o-r),height:n.height||0,fill:e.fill||e.color||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity??.1}),e.label&&(0,Ki.jsx)("text",{x:Math.min(r,o)+4,y:13,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=i.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=Zi[n.curve||"linear"]||Pi.curveLinear,h=(0,Pi.area)().x(e=>o(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Ki.jsx)("text",{x:o(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(c+d*u),b=s(h),v=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return(0,Ki.jsxs)("g",{children:[f&&(0,Ki.jsx)("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((e,t)=>{const i=ji(e,n),r=Ci(e,n);return null==i||null==r?null:(0,Ki.jsx)("circle",{cx:i,cy:r,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Ki.jsx)("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",s=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!s||!a)return null;const c=i.map(e=>[e[r],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=_i.default.polynomial(c,{order:e.order||2}).equation;l=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const e=c.length;let t=0,n=0,i=0,r=0;for(const[e,o]of c)t+=e,n+=o,i+=e*e,r+=e*o;const o=e*i-t*t;if(1e-12>Math.abs(o))return null;const s=(e*r-t*n)/o,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-l(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-f)**2,0),y=e.confidence??.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,m=e.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),v=[];for(let e=1;m>=e;e++)v.push(x+e*b);const w=[];for(const e of v){const t=l(e),n=h*Math.sqrt(1+1/u+(p>0?(e-f)**2/p:0))*g;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),A=`${s(x)},${a(l(x))}`,M=e.strokeColor||"#6366f1";return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("path",{d:k,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Ki.jsx)("polyline",{points:`${A} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,Ki.jsx)("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let i,r;if(null!=e.px&&null!=e.py)i=e.px,r=e.py;else{const o=Ri(e,t,n);if(!o)return null;i=o.x,r=o.y}if(!Li(i,r,n))return null;const o=e.width??32,s=e.height??32;return(0,Ki.jsx)("foreignObject",{x:i+(e.dx??0)-o/2,y:r+(e.dy??0)-s/2,width:o,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Ki.jsx)("div",{style:{width:o,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:e.content??(0,Ki.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"})})},"ann-"+t)}case"text":{const i=Ri(e,t,n);if(!i)return null;const{x:r,y:o}=i,s=r+(e.dx||0),a=o+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,Ki.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?gi.cloneElement(l,{key:"ann-text-"+t}):(0,Ki.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Ki.jsx)("line",{x1:r,y1:o,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),gi.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+t)}case"category-highlight":{const i=e.category;if(null==i)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,o=n.scales?.o,s=n.scales?.x,a=n.scales?.y,c=r(o)?o:r(s)?s:r(a)?a:null;if(!c)return null;const l=c(i+"");if(null==l)return null;const u=c.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Ki.jsxs)("g",(n.projection?"vertical"===n.projection:c===s)?{children:[(0,Ki.jsx)("rect",{x:l,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),f&&(0,Ki.jsx)("text",{x:l+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[(0,Ki.jsx)("rect",{x:0,y:l,width:n.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Ki.jsx)("text",{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+t)}default:return null}}}var er=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function tr(e){return!!e&&"object"==typeof e&&er.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var nr=2e4,ir=1;function rr(e){return"primary"===e?.emphasis||!0===e?.defensive}function or(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:nr))):1/0}function sr(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const i=e?.provenance?.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(t+=15*Math.max(0,Math.min(1,i))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}var ar=32,cr=6,lr=4,ur=8,dr=72,hr=30,fr=-30,pr=8,yr=480,gr=3;var mr={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function xr(e){if(!br(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function br(e){return tr(e)}function vr(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),i=e.split(/\s+/).filter(Boolean),r=[];let o="";for(const e of i)o&&o.length+e.length+1>n?(r.push(o),o=e):o=o?`${o} ${e}`:e;return o&&r.push(o),r}function wr(e,t,n,i,r){const o=e+n,s=t+i;return Math.abs(n)>Math.abs(i)?{x:0>n?o-r.width-4:o+4,y:0>i?s-r.height:s,width:r.width,height:r.height}:{x:0>n?o-r.width:o,y:0>i?s-r.height-4:s+4,width:r.width,height:r.height}}function kr(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Sr(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Ar(e,t,n,i,r,o,s,a){const c=kr(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,i){const r=Math.max(0,i-e.x),o=Math.max(0,i-e.y);return(r+Math.max(0,e.x+e.width-(t-i)))*e.height+(o+Math.max(0,e.y+e.height-(n-i)))*e.width}(c,r,o,a);for(const e of n)l+=12*Sr(c,e);for(const e of i)l+=4*Sr(c,e);return l}function Mr(e){const{annotations:t,context:n,defaultOffset:i=ar,notePadding:r=cr,markPadding:o=lr,edgePadding:s=ur,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=dr,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=e,m=n.width||0,x=n.height||0,b="object"==typeof p?p:{},v=b.breakpoint??yr,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?t.map(xr):t,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,P=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const _=[],j=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,o);let C=!1;const I=k.map((e,t)=>{if(!br(e))return e;const o=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const i=e.pointId??e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,o=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&o){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=o([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ri(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!o)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...vr("string"==typeof e.title?e.title:void 0,t),...vr("string"==typeof e.label?e.label:void 0,t)],i=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*i)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:hr,dy:fr}}(e);return _.push(kr(wr(o.x,o.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(i)){const t=Ar(wr(o.x,o.y,e.dx,e.dy,u),e,_,j,m,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=kr(wr(o.x,o.y,h.dx,h.dy,u),r);_.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return C=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),T=C?I:k.slice();let R=T;if(h){let e=!1;const t=T.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<pr?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});R=e?t:T}{let e=!1;const t=R.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?mr[t.source]??t.source:null,i="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!i)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,i].filter(Boolean).join(" · "),o="string"==typeof e.label?e.label:"";return o.includes(`(${r})`)?e:{...e,label:o?`${o} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});R=e?t:R}const L=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return gr;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?gr:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??or(m,x,e))*t))},{deferred:i}=function(e){const{annotations:t,width:n,height:i}=e,r=Math.max(0,e.minVisible??ir),o=or(n,i,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,tr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||o>=a.length)return{visible:t.slice(),deferred:[],budget:o};const c=a.filter(e=>rr(e.annotation)),l=a.filter(e=>!rr(e.annotation)).sort((e,t)=>sr(t.annotation)-sr(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,o-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:o}}({annotations:R,width:m,height:x,...n});for(const e of i)L.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:yr)>=m)for(const e of R)br(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of R)!0===e?.defensive&&L.delete(e);let $;return $=0===L.size?R:A?R.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!L.has(e)),P?function(e,t){let n=!1;const i=e.map(e=>br(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?i:e}($,P):$}var Pr=require("react"),_r={positions:new Map},jr=new Set;function Cr(){for(const e of jr)e()}function Ir(e,t){const n=_r.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const i=new Map(_r.positions);i.delete(e),_r={positions:i},Cr()}function Tr(e,t){const n=_r.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const i=new Map(_r.positions);i.delete(e),_r={positions:i},Cr()}function Rr(){return _r}function Lr(e){return jr.add(e),()=>jr.delete(e)}var $r={positions:new Map};function Er(){return()=>{}}function zr(){return $r}function Dr(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),i=n[0],r=n[n.length-1],o=i instanceof Date,s=i instanceof Date?i.getTime():i,a=r instanceof Date?r.getTime():r;if(2>t||s===a)return o?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=o?new Date(n):n}return l}(e,t):e.ticks(t)}var Br=require("react/jsx-runtime");function Fr(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Nr(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Or(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const i of e)t>i.pixel&&(t=i.pixel),i.pixel>n&&(n=i.pixel);return{min:t,max:n}}function Wr(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function qr(e,t,n){if("left"===e||"right"===e){const i="left"===e?n:0,r="left"===e?-1:1,o=Math.ceil(t/8);let s="M0,"+i;for(let e=0;o>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${i+4*r}`,s+=`L${Math.min(n,t)},${i}`}return s}{const i="bottom"===e?0:t,r="bottom"===e?1:-1,o=Math.ceil(n/8);let s=`M${i},0`;for(let e=0;o>e;e++){const t=8*(e+1);s+=`L${i+4*r},${Math.min(8*e+4,n)}`,s+=`L${i},${Math.min(t,n)}`}return s}}function Yr(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,f=(0,Un.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Hr,i=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,o="exact"===h?Math.max(2,r):Math.min(r,i),a=e?.tickValues??Dr(s.x,o,h),l=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),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 Gr(d,Math.max(55,f+8))},[s,c,u,t,h]),p=(0,Un.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||Hr,i=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,o="exact"===h?Math.max(2,r):Math.min(r,i);return Gr((e?.tickValues??Dr(s.y,o,h)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,d,n,h]),y=l&&s,g=a&&s;if(!y&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),x=c?.find(e=>"left"===e.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return(0,Br.jsx)("svg",{width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Br.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[y&&(()=>{const e=Wr(c?.find(e=>"bottom"===e.orient)?.gridStyle),i=Wr(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Br.jsxs)("g",{className:"stream-grid",children:[f.map((t,i)=>(0,Br.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+i)),p.map((e,n)=>(0,Br.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),b&&!w&&(0,Br.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,Br.jsx)("path",{d:qr("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&(0,Br.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,Br.jsx)("path",{d:qr("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Hr(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Gr(e,t){if(2>=e.length)return e;const n=[e[0]];for(let i=1;e.length-1>i;i++)t>Math.abs(e[i].pixel-n[n.length-1].pixel)||n.push(e[i]);const i=e[e.length-1];return t>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Xr(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:f,axisExtent:p,showGrid:y,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:M,xValues:P,yValues:_,annotations:j,autoPlaceAnnotations:C,svgAnnotationRules:I,xAccessor:T,yAccessor:R,annotationData:L,pointNodes:$,curve:E,underlayRendered:z,canvasObscuresUnderlay:D=!0,linkedCrosshairName:B,linkedCrosshairSourceId:F,children:N}=e,O=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||Hr,i=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,o="exact"===p?Math.max(2,r):Math.min(r,i),l=e?.tickValues??Dr(s.x,o,p),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),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),y=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=Gr(d,y);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==p&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),i=g[g.length-1].pixel;if(Math.abs(t-i)>1){const r=n(e,g.length,u);y>t-i&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[a,s,c,h,t,p]),W=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Hr,i=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,o="exact"===p?Math.max(2,r):Math.min(r,i);let l=Gr((e?.tickValues??Dr(s.y,o,p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==p&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),i=l[l.length-1].pixel;if(Math.abs(n-i)>1){const r=t(e);22>Math.abs(n-i)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[a,s,c,f,n,p]),q=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Hr,i=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return Gr((e.tickValues??Dr(s.y,"exact"===p?Math.max(2,r):Math.min(r,i),p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,p]),Y=(0,Un.useRef)(new Map),H=(0,Un.useRef)(j?.length??0),G=j?.length??0;H.current!==G&&(H.current=G,Y.current=new Map);const X=(0,Un.useMemo)(()=>{if(!j||0===j.length)return null;const e=Ji(),i={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:t,height:n,data:L,frameType:"xy",pointNodes:$,curve:E,stickyPositionCache:Y.current};return Qi(C?Mr({annotations:j,context:i,..."object"==typeof C?C:{}}):j,e,I,i)},[j,C,I,t,n,T,R,L,s,$,E]),V=function(e){const t=(0,Pr.useSyncExternalStore)(e?Lr:Er,e?Rr:zr,e?Rr:zr);return e?t.positions.get(e)??null:null}(B);return(0,Un.useEffect)(()=>{if(!V?.locked||!B)return;const e=e=>{"Escape"===e.key&&Tr(B)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[V?.locked,B]),a||g||m||A||M||X&&X.length>0||y||N||V?(0,Br.jsxs)("svg",{role:"img",width:i,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Br.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,Br.jsx)("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),(0,Br.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[y&&s&&(!z||D)&&(()=>{const e=Wr(c?.find(e=>"bottom"===e.orient)?.gridStyle),i=Wr(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Br.jsxs)("g",{className:"stream-grid",children:[O.map((t,i)=>(0,Br.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+i)),W.map((e,n)=>(0,Br.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),i=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,s=!i||!1!==i.baseline,a=e?.jaggedBase||!1,h=i?.jaggedBase||!1,f=i?.landmarkTicks,p=e?.landmarkTicks,y="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!i?.autoRotate&&O.length>1&&(()=>{const e=t/Math.max(O.length-1,1);return O.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,v=n+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=i?.tickAnchor,M=e?.tickAnchor,P=Or(O),_=Or(W);return(0,Br.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!z||D)&&s&&!h&&(0,Br.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:y,strokeWidth:1}),(!z||D)&&h&&(0,Br.jsx)("path",{d:qr("bottom",t,n),fill:"none",stroke:y,strokeWidth:1}),O.map((e,t)=>{const i=!!f&&("function"==typeof f?f(e.value,t):rn(e.value,t>0?O[t-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Br.jsx)("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{y:b,textAnchor:x?"end":Fr(A,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},transform:x?"rotate(-45)":void 0,children:e.label}):(0,Br.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),l&&(0,Br.jsx)("text",{x:t/2,y:v,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:l})]}),(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!z||D)&&r&&!a&&(0,Br.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:y,strokeWidth:1}),(!z||D)&&a&&(0,Br.jsx)("path",{d:qr("left",t,n),fill:"none",stroke:y,strokeWidth:1}),W.map((e,t)=>{const n=!!p&&("function"==typeof p?p(e.value,t):rn(e.value,t>0?W[t-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Br.jsx)("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:Nr(M,e.pixel===_.min,e.pixel===_.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:e.label}):(0,Br.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,Br.jsx)("text",{x:15-o.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-o.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const i=!1!==e.baseline,r=e.landmarkTicks,s=e.label||d,a=e.tickAnchor,l=Or(q);return(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&(0,Br.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:y,strokeWidth:1}),q.map((e,n)=>{const i=!!r&&("function"==typeof r?r(e.value,n):rn(e.value,n>0?q[n-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Br.jsx)("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Nr(a,e.pixel===l.min,e.pixel===l.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},children:e.label}):(0,Br.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+n)}),s&&(0,Br.jsx)("text",{x:t+o.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+o.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:s})]})})()]})})(),X,M&&s&&P&&_&&(0,Br.jsxs)(Br.Fragment,{children:[M.top&&(0,Br.jsx)("g",{transform:"translate(0, 0)",children:(0,Br.jsx)(yi,{orient:"top",config:pi(M.top),values:P,scale:s.x,size:o.top,length:t})}),M.bottom&&(0,Br.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Br.jsx)(yi,{orient:"bottom",config:pi(M.bottom),values:P,scale:s.x,size:o.bottom,length:t})}),M.left&&(0,Br.jsx)("g",{transform:"translate(0, 0)",children:(0,Br.jsx)(yi,{orient:"left",config:pi(M.left),values:_,scale:s.y,size:o.left,length:n})}),M.right&&(0,Br.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Br.jsx)(yi,{orient:"right",config:pi(M.right),values:_,scale:s.y,size:o.right,length:n})})]}),A,V&&V.sourceId!==F&&s?.x&&(()=>{const e=s.x(V.xValue);if(null==e||0>e||e>t)return null;const i=V.locked;return(0,Br.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:i?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:i?1.5:1,strokeDasharray:i?"6,3":"4,4",pointerEvents:"none"})})(),N]}),g&&(0,Br.jsx)("text",{x:i/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof g?g:null}),ci({legend:m,totalWidth:i,totalHeight:r,margin:o,legendPosition:k,title:g,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w})]}):null}var Vr=c(require("react")),Ur=require("d3-shape");function Kr(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function Zr(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,i=e=>Math.max(0,Math.min(e??0,n));return{tl:i(t.tl),tr:i(t.tr),br:i(t.br),bl:i(t.bl)}}var Qr=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function Jr(e){const{innerRadius:t,outerRadius:n,startAngle:i,endAngle:r}=e,o=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(o){const e=Qr(n,i),t=Qr(n,r);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${r-i>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=Qr(n,i),s=Qr(n,r),a=Qr(t,r),c=Qr(t,i),l=r-i>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return Jr({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=o?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),l=r-i,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>a,h=!!e.roundEnd&&u>a;if(!d&&!h)return Jr({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=i+(d?a:0),p=r-(h?a:0),y=i+(d?c:0),g=r-(h?c:0),m=Qr(n,f),x=Qr(n,p),b=(n-s)*Math.cos(a),v=Qr(b,i),w=Qr(b,r),k=o?null:Qr(t,g),S=o?null:Qr(t,y),A=o?0:(t+s)*Math.cos(c),M=o?null:Qr(A,i),P=o?null:Qr(A,r),_=p-f>Math.PI?1:0,j=o?0:g-y>Math.PI?1:0;let C="";if(d)C+=`M${v.x},${v.y}`,C+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const e=Qr(n,i);C+=`M${e.x},${e.y}`}if(h)C+=` A${n},${n} 0 ${_} 1 ${x.x},${x.y}`,C+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=Qr(n,r);C+=` A${n},${n} 0 ${_} 1 ${e.x},${e.y}`}if(o)C+=" L0,0";else{if(h)C+=` L${P.x},${P.y}`,C+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=Qr(t,r);C+=` L${e.x},${e.y}`}if(d)C+=` A${t},${t} 0 ${j} 0 ${S.x},${S.y}`,C+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const e=Qr(t,i);C+=` A${t},${t} 0 ${j} 0 ${e.x},${e.y}`}}return C+=" Z",C}var eo=require("react/jsx-runtime"),to={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function no(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function io(e,t,n){const i=ht(e.symbolType,e.size,e.path);return(0,eo.jsx)("path",{d:i,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?no(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}function ro(e,t,n,i){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const o=an(r,e.size);if(0>=o.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${o.offsetX},${o.offsetY}) scale(${o.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=dn(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?oo(i+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,i)=>{const r=t?"none"===n.fill?void 0:t:cn(n.fill,a,e.accent),o=t?n.stroke&&"none"!==n.stroke?t:void 0:cn(n.stroke??"none",a,e.accent);return r||o?(0,eo.jsx)("path",{d:n.d,fill:r??"none",stroke:o,strokeWidth:o?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},i):null});return(0,eo.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,eo.jsx)("clipPath",{id:l,children:(0,eo.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,eo.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?(0,eo.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},i)}function oo(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function so(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return(0,eo.jsx)("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const i=e;if(0===i.topPath.length)return null;const r=`M${i.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(i.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("defs",{children:(0,eo.jsx)("clipPath",{id:e,children:(0,eo.jsx)("rect",{x:i.clipRect.x,y:i.clipRect.y,width:i.clipRect.width,height:i.clipRect.height})})}),(0,eo.jsx)("path",{d:r,fill:no(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return(0,eo.jsx)("path",{d:r,fill:no(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"area-"+t)}case"point":{const n=e;return(0,eo.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:no(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+t)}case"symbol":return io(e,t);case"glyph":return ro(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const n=e;return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:no(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,r,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]}(n.fill),s=.299*i+.587*r+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),(0,eo.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,eo.jsx)("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1})]},"candle-"+t)}default:return null}}function ao(e,t,n){const i=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",r=n=>`ord-${e.type}-${i}-${t}-${n}`,o=`ord-${e.type}-${i}-${t}`;switch(e.type){case"rect":{const t=e,n=oo(o)+"-grad",i=function(e,t){const n=e.fillGradient;if(!n)return null;let i=e.x,r=e.y,o=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,s=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,o=e.x,s=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,o=e.x+e.w,s=e.y);const a=[];if("colorStops"in n){const e=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>e.length)return null;for(let t=0;e.length>t;t++)a.push((0,eo.jsx)("stop",{offset:e[t].offset,stopColor:e[t].color},t))}else{const t=no(e.style.fill);a.push((0,eo.jsx)("stop",{offset:0,stopColor:t,stopOpacity:n.topOpacity},"0")),a.push((0,eo.jsx)("stop",{offset:1,stopColor:t,stopOpacity:n.bottomOpacity},"1"))}return(0,eo.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:o,y2:s,children:a})}(t,n),r=i?`url(#${n})`:no(t.style.fill);if(t.cornerRadii&&Kr(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:i,h:r}=e,{tl:o,tr:s,br:a,bl:c}=Zr(e);let l=`M${t+o},${n}`;return l+=` L${t+i-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+i},${n+s}`),l+=` L${t+i},${n+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+i-a},${n+r}`),l+=` L${t+c},${n+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${n+r-c}`),l+=` L${t},${n+o}`,o>0&&(l+=` A${o},${o} 0 0 1 ${t+o},${n}`),l+=" Z",l}(t);return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("path",{d:e,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:s,w:a,h:c}=t;let l;switch(t.roundedEdge){case"right":l=`M${n},${s} L${n+a-e},${s} A${e},${e} 0 0 1 ${n+a},${s+e} L${n+a},${s+c-e} A${e},${e} 0 0 1 ${n+a-e},${s+c} L${n},${s+c} Z`;break;case"left":l=`M${n+a},${s} L${n+e},${s} A${e},${e} 0 0 0 ${n},${s+e} L${n},${s+c-e} A${e},${e} 0 0 0 ${n+e},${s+c} L${n+a},${s+c} Z`;break;case"bottom":l=`M${n},${s} L${n+a},${s} L${n+a},${s+c-e} A${e},${e} 0 0 1 ${n+a-e},${s+c} L${n+e},${s+c} A${e},${e} 0 0 1 ${n},${s+c-e} Z`;break;default:l=`M${n},${s+c} L${n},${s+e} A${e},${e} 0 0 1 ${n+e},${s} L${n+a-e},${s} A${e},${e} 0 0 1 ${n+a},${s+e} L${n+a},${s+c} Z`}return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("path",{d:l,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}case"point":{const t=e;return(0,eo.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:no(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},o)}case"symbol":return io(e,t,n);case"glyph":return ro(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const i=e;if(i._gradientBand&&i._gradientBand.colors.length>0){const e=oo(`${n?n+"-":""}gauge-grad-${i.category||o}-${t}`),{clipPath:r,slices:s}=function(e){const t=Jr({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],i=e.colors;if(i.length>0){const t=(e.endAngle-e.startAngle)/i.length;for(let r=0;i.length>r;r++)n.push({d:Jr({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:i[r]})}return{clipPath:t,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds?.start??!0,roundEnd:i.roundedEnds?.end??!0,colors:i._gradientBand.colors});return(0,eo.jsxs)("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[(0,eo.jsx)("defs",{children:(0,eo.jsx)("clipPath",{id:e,children:(0,eo.jsx)("path",{d:r})})}),(0,eo.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,eo.jsx)("path",{d:e.d,fill:no(e.color)},t))}),i.style.stroke&&"none"!==i.style.stroke&&(0,eo.jsx)("path",{d:r,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},o)}let r;if(i.roundedEnds)r=Jr({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const e=(0,Ur.arc)().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&e.cornerRadius(i.cornerRadius),r=e(to)||""}return(0,eo.jsx)("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:no(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},o)}case"boxplot":{const t=e,n=t.columnWidth/2;return(0,eo.jsxs)("g","vertical"===t.projection?{children:[(0,eo.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,eo.jsx)("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,eo.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,eo.jsx)("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},o)}case"violin":{const t=e,n=[(0,eo.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},r("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,i=e.x+e.width/2,o=e.y+e.height/2;e.height>e.width?n.push((0,eo.jsx)("line",{x1:i,y1:t.iqrLine.q1Pos,x2:i,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,eo.jsx)("circle",{cx:i,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,eo.jsx)("line",{x1:t.iqrLine.q1Pos,y1:o,x2:t.iqrLine.q3Pos,y2:o,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,eo.jsx)("circle",{cx:t.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,eo.jsx)("g",{children:n},o)}case"connector":return(0,eo.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity??.5},o);case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return(0,eo.jsx)("polygon",{points:n,fill:no(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},o)}default:return null}}var co="undefined"==typeof window||"undefined"==typeof document,lo=require("react"),uo="undefined"!=typeof window?lo.useLayoutEffect:lo.useEffect;function ho(){const[e,t]=(0,lo.useState)(!1);return uo(()=>{t(!0)},[]),e}var fo=()=>()=>{},po=()=>!1,yo=()=>!0;function go(){const e=(0,lo.useSyncExternalStore)(fo,po,yo);return(0,lo.useRef)(e).current}function mo(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:o,cancelRender:s,cleanup:a}=e;uo(()=>{t&&n&&i.current?.cancelIntroAnimation?.(),r.current=!0,s?.(),o.current()},[t,n]);const c=(0,lo.useRef)(a);c.current=a,(0,lo.useEffect)(()=>()=>c.current?.(),[])}var xo=require("react");function bo(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Object.is(e[i],t[i]))return!1}return!0}function vo(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 wo(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}var ko={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 So(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],i=n[2],r=n[3];return`#${e}${e}${i}${i}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ao=c(require("react")),Mo=c(require("react")),Po=(require("react/jsx-runtime"),Mo.createContext(null));function _o(){return Mo.useContext(Po)}function jo(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,i]of Object.entries(e))n.startsWith("_")||null!=i&&""!==i&&("number"==typeof i?Number.isFinite(i)&&(t[n]=i):"string"==typeof i?t[n]=i:"boolean"==typeof i?t[n]=i+"":i instanceof Date&&(t[n]=i.toISOString().slice(0,10)));return t}function Co(e){return e&&"object"==typeof e?e:{}}function Io(e){return Co(e.accessibility).tableFields??e.accessibleDatum??e.datum}var To=require("react/jsx-runtime"),Ro={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Lo(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const i=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},o=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=o.indexOf(e),i=o.indexOf(t);return(-1===n?999:n)-(-1===i?999:i)});for(const e of s)i.push(`${n[e]} ${r[e]||e}`);return`${t}, ${i.join(", ")}`}var $o=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Eo="semiotic-accessible-data-table",zo=Eo+" semiotic-accessible-data-table-hidden",Do=Eo+" semiotic-accessible-data-table-visible",Bo={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"},Fo={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},No={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)"},Oo={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Wo={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))"},qo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Yo={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ho={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 Go({scene:e,chartType:t,tableId:n,chartTitle:i}){const[r,o]=Ao.useState(!1),[s,a]=Ao.useState(5),c=_o(),l=c?.visible??!1,u=r||l,d=Ao.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ao.useEffect(()=>{u||a(5)},[u]);const f=Ao.useCallback(e=>{e.target===e.currentTarget&&(r||l||o(!0))},[r,l]),p=Ao.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!e||0===e.length)return n?(0,To.jsx)("span",{id:n,tabIndex:-1,style:Ro}):null;if(!u)return(0,To.jsx)("div",{id:n,className:zo,tabIndex:-1,onFocus:f,style:Ro,role:"region","aria-label":h,children:(0,To.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",e.length," elements)"]})});const y=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const i of e)if(i&&"object"==typeof i&&null!==i.datum)try{switch(i.type){case"point":if(n)break;t.push({label:"Point",values:jo(Io(i))});break;case"line":case"area":{const e=Io(i),n=Array.isArray(e)?e:[],r="line"===i.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:jo(e)});break}case"rect":{const e=Io(i),n=null!=e&&"object"==typeof e?e:{},r=n.category??i.group??"",o=n.value??n.__aggregateValue??n.total,s=jo(n);null==s.category&&""!==r&&(s.category=r+""),null==s.value&&null!=o&&(s.value="number"==typeof o||"string"==typeof o?o:o+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=jo(Io(i));null==e.value&&"number"==typeof i.value&&Number.isFinite(i.value)&&(e.value=i.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Io(i),n=jo(e);if(null==n.category){const t=Co(e),i=t.category??t.label;null!=i&&(n.category=i+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:jo(Io(i))});break;case"arc":t.push({label:"Arc",values:jo(Io(i))});break;case"candlestick":t.push({label:"Candlestick",values:jo(Io(i))});break;case"geoarea":{const e=Co(Io(i)),n=jo(e);if(null==n.name){const t=Co(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const i of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[i];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],o=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),o+=n;n.push({name:i,count:t.length,numeric:!0,min:e,max:r,mean:o/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:i,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${$o(e.min)} to ${$o(e.max)}, mean ${$o(e.mean)}.`);else{const t=e.uniqueValues,i=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${i}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const e of b)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return(0,To.jsxs)("div",{ref:d,id:n,className:Do,tabIndex:-1,onBlur:p,style:Bo,role:"region","aria-label":h,children:[(0,To.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},"aria-label":"Close data summary",style:No,children:"×"}),(0,To.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Fo,children:m}),(0,To.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Oo,children:[(0,To.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Yo,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),(0,To.jsx)("thead",{children:(0,To.jsxs)("tr",{children:[(0,To.jsx)("th",{style:Wo,children:"type"}),k.map(e=>(0,To.jsx)("th",{style:Wo,children:e},e))]})}),(0,To.jsx)("tbody",{children:b.map((e,t)=>(0,To.jsxs)("tr",{children:[(0,To.jsx)("td",{style:qo,children:e.label}),k.map(t=>{return(0,To.jsx)("td",{style:qo,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":$o(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),v>0&&(0,To.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ho,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function Xo({summary:e}){return e?(0,To.jsx)("div",{role:"note",style:Ro,children:e}):null}function Vo({tableId:e}){return(0,To.jsx)("a",{href:"#"+e,style:Ro,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.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:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ro)},children:"Skip to data table"})}function Uo({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,To.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ro,children:t})}var Ko=require("react/jsx-runtime"),Zo="var(--semiotic-focus, #005fcc)";function Qo({active:e,hoverPoint:t,margin:n,size:i,shape:r="circle",width:o,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!a)if("rect"===r&&null!=o&&null!=s){const e=Math.max(o,4),t=Math.max(s,4);u=(0,Ko.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Zo,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Ko.jsx)("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:Zo,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:Zo,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Ko.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Ko.jsx)("path",{d:a,fill:"none",stroke:Zo,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Ko.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Jo=c(require("react")),es=require("react/jsx-runtime");function ts({x:e,y:t,containerWidth:n,containerHeight:i,margin:r,children:o,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=Jo.useRef(null),[u,d]=Jo.useState(null);Jo.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[o,s,n,i]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Jo.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background&&"transparent"!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor&&"transparent"!==i.backgroundColor)return!0}return!1}(o),p=f?null:V;return c?(0,es.jsx)("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:o}):null}var ns=c(require("react")),is=require("react"),rs=require("react");var os=require("react"),ss="undefined"==typeof window?is.useEffect:is.useLayoutEffect,as={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function cs(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function ls(e){const t=function(){const[e,t]=(0,rs.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,rs.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,is.useRef)(t);n.current=t;const[i,r]=function(e,t,n){const i=(0,os.useRef)(null),[r,o]=(0,os.useState)(null);return(0,os.useEffect)(()=>{if(!t&&!n)return;const e=i.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;o(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[i,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),o=(0,is.useMemo)(()=>({...e.marginDefault,...e.userMargin}),[e.marginDefault,e.userMargin]),s=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,c=cs(e.foregroundGraphics,r,o),l=cs(e.backgroundGraphics,r,o),u=Pe(e=>e.theme),{transition:d,introEnabled:h}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+ns.useId(),p=(0,is.useRef)(null),y=(0,is.useRef)(e.frameScheduler??as);y.current=e.frameScheduler??as;const g=(0,is.useRef)(null),m=(0,is.useRef)(!1),x=(0,is.useRef)(()=>{}),b=(0,is.useCallback)(()=>{if(null!==p.current||m.current)return;const e=y.current;let t=!1,n=!1;const i=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(m.current=!0),p.current=null,g.current=null;try{x.current()}finally{e&&(m.current=!1)}});n=!0,t||(p.current=i,g.current=e)},[]),v=(0,is.useCallback)(()=>{null!==p.current&&((g.current??y.current).cancelAnimationFrame(p.current),p.current=null,g.current=null)},[]);(0,is.useEffect)(()=>()=>{v()},[v]);const w=(0,is.useRef)(()=>{}),k=(0,is.useRef)(()=>{}),S=(0,is.useRef)(null),A=(0,is.useRef)(null),M=(0,is.useRef)(null),P=(0,is.useCallback)(()=>{const e=S.current;S.current=null,e&&w.current(e)},[]),_=(0,is.useCallback)(e=>{if(S.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===A.current){const e=y.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,A.current=null,M.current=null,P()});t||(A.current=n,M.current=e)}},[P]),j=(0,is.useCallback)(()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null),k.current()},[]);(0,is.useEffect)(()=>()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null)},[]);const C=e.themeDirtyRef;return ss(()=>{C&&(gn++,C.current=!0,b())},[u,b,C]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:i,size:r,margin:o,adjustedWidth:s,adjustedHeight:a,resolvedForeground:c,resolvedBackground:l,currentTheme:u,transition:d,introEnabled:h,tableId:f,rafRef:p,renderFnRef:x,scheduleRender:b,cancelRender:v,hoverHandlerRef:w,hoverLeaveRef:k,onPointerMove:_,onPointerLeave:j}}function us(e,t,n,i){const r=e.getContext("2d");if(!r)return null;const o=Math.round(t[0]*i),s=Math.round(t[1]*i),a=o/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===o&&e.height===s||(e.width=o,e.height=s),r.setTransform(a,0,0,c,0,0),r.translate(n.left,n.top),r}function ds(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}var hs=require("react");function fs(e,t,n,i){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:i,fn:t}:{key:void 0,fn:null}}var ps=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ys=3156e7;function gs(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")}`}:ys>t?e=>{const t=new Date(e);return`${ps[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*ys>t?e=>{const t=new Date(e);return`${ps[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function ms(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:ft(n.size)});else if("glyph"===n.type){const e=hn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var xs=require("d3-shape");function bs(e,t,n){let i=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(i=n.color):e>n.value&&(i=n.color);return i}function vs(e,t,n,i,r,o){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],i=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+i*i))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=i,e.lineCap=o;for(let n=0;t.length-1>n;n++){const i=(s[n]+s[n+1])/2;let o=r;c>i&&(o*=i/c),c>a-i&&(o*=(a-i)/c),e.globalAlpha=Math.max(0,o),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var ws=(e,t,n,i)=>{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,i.width*n,i.height),e.clip());const r=t.style.stroke||"#007bff",o=vn(e,r)||r,s=t.style.strokeWidth||2,a=t.colorThresholds,c=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=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){vs(e,t.path,o,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=kn(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=o;const n=t.style.opacity??1;for(let i=0;t.path.length-1>i;i++)e.globalAlpha=.5*(d[i]+d[i+1])*n,e.beginPath(),e.moveTo(t.path[i][0],t.path[i][1]),e.lineTo(t.path[i+1][0],t.path[i+1][1]),e.stroke()}else if(u){let n=function(t,n,i){e.beginPath(),e.strokeStyle=t,e.moveTo(n,i),d=!0},i=function(){d&&(e.stroke(),d=!1)},r=null,s=null,l=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,f]=t.path[d],p=c[d],y=bs(p,a,o);if(null!==r&&null!==u&&null!==l){if(y===u)e.lineTo(h,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>p)&&(n>l||p>n)||l===n||p===n||t.push({t:(n-l)/(p-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=r+(h-r)*c.t,u=s+(f-s)*c.t,d=bs(l+(p-l)*Math.min(c.t+1e-4,1),a,o);e.lineTo(t,u),i(),n(d,t,u)}e.lineTo(h,f)}r=h,s=f,l=p,u=y}else n(y,h,f),r=h,s=f,l=p,u=y}i()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?Mn(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||o,l)(0,xs.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,i]=t.path[0];e.moveTo(n,i);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=Sn(e,t.style.fill,t.style.fill),l&&!u)(0,xs.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,i]=t.path[0];e.moveTo(n,i);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],i.height),e.lineTo(n,i.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function ks(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ss(e,t,n=.3){ks(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 As(e,t,n=.6){if(!ks(t))return;const i=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,o=t.cy??t.y??0;e.beginPath(),e.arc(r,o,i,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 Ms(e,t,n,i=.35){ks(t)&&(e.globalAlpha=t._pulseIntensity*i,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Ps=require("d3-shape");function _s(e,t){const n=kn(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 i=(0,Ps.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),i(t.topPath)}}var js=(e,t,n,i)=>{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,i.width*r,i.height),e.clip());const o=Sn(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=o;for(let i=0;t.topPath.length-1>i;i++)e.globalAlpha=.5*(s[i]+s[i+1])*n,e.beginPath(),e.moveTo(t.topPath[i][0],t.topPath[i][1]),e.lineTo(t.topPath[i+1][0],t.topPath[i+1][1]),e.lineTo(t.bottomPath[i+1][0],t.bottomPath[i+1][1]),e.lineTo(t.bottomPath[i][0],t.bottomPath[i][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=vn(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*(s[n]+s[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(_s(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 i=-1/0;for(const e of t.bottomPath)e[1]>i&&(i=e[1]);const r=An(e,t.fillGradient,"string"==typeof o?o:"#4e79a7",0,n,0,i);e.fillStyle=r||o,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=o;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(_s(e,t),Ms(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?Mn(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const i=kn(t.curve);if(e.beginPath(),i)(0,Ps.line)().x(e=>e[0]).y(e=>e[1]).curve(i).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}},Cs=(e,t,n,i)=>{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=Sn(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Sn(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),As(e,n)}finally{e.restore()}}},Is=new Map;function Ts(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Is.get(t);return n||(n=new Path2D(ht(e.symbolType,e.size)),Is.size>256&&Is.clear(),Is.set(t,n)),n}catch{return null}}var Rs=(e,t)=>{const n=e.globalAlpha;for(const i of t){if("symbol"!==i.type)continue;const t=i;if(0>=t.size)continue;const r=Ts(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const o=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*o*(t.style.fillOpacity??1),e.fillStyle=Sn(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=Sn(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function Ls(e,t,n,i,r){if(0>=t.size)return;const o=t.glyph;if(!o||!o.parts?.length)return;const s=an(o,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=Sn(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,i),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=dn(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&fn(e,o,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),fn(e,o,l,t.accent,void 0,c),e.restore()}function $s(e,t){const{x:n,y:i,w:r,h:o}=t,{tl:s,tr:a,br:c,bl:l}=Zr(t);e.beginPath(),e.moveTo(n+s,i),e.lineTo(n+r-a,i),a>0&&e.arcTo(n+r,i,n+r,i+a,a),e.lineTo(n+r,i+o-c),c>0&&e.arcTo(n+r,i+o,n+r-c,i+o,c),e.lineTo(n+l,i+o),l>0&&e.arcTo(n,i+o,n,i+o-l,l),e.lineTo(n,i+s),s>0&&e.arcTo(n,i,n+s,i,s),e.closePath()}function Es(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 zs=(e,t,n,i)=>{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)Ds(e,t);else if(t.cornerRadii&&Kr(t.cornerRadii)){const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n,$s(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n;const o=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+o,a),e.arcTo(s,a,s,a+o,o),e.lineTo(s,a+l-o),e.arcTo(s,a+l,s+o,a+l,o),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s+o,a+l),e.arcTo(s,a+l,s,a+l-o,o);break;default:e.moveTo(s,a+l),e.lineTo(s,a+o),e.arcTo(s,a,s+o,a,o),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.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=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Ss(e,t),e.globalAlpha=1}};function Ds(e,t){const n=t.style.icon,i=t.style.iconPadding||2,r=Math.min(t.w,t.h)-i;if(0>=r)return;const o=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),o){const o=r+i,s=t.x+(t.w-r)/2;for(let i=t.y+t.h-r;i>=t.y-r;i-=o)e.drawImage(n,s,i,r,r)}else{const o=r+i,s=t.y+(t.h-r)/2;for(let i=t.x;t.x+t.w>i;i+=o)e.drawImage(n,i,s,r,r)}e.restore()}function Bs(e){const[t,n,i]=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*i>128?"#000":"#fff"}function Fs(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ns=(e,t,n,i)=>{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=vn(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Ss(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):Fs(t.value),i=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,o=t.y+t.h/2;e.fillStyle=Bs(t.fill),e.font=i+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,o)}}}finally{e.restore()}},Os=(e,t,n,i)=>{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 o=vn(e,t.wickColor)||t.wickColor,s=60>i.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=o,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*i.height));e.fillStyle=o,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),i=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,o=vn(e,r)||r;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(i,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(i,1))}s&&c(),e.restore()}},Ws={line:[js,ws,Cs],area:[js,Cs],stackedarea:[js,Cs],scatter:[Cs,Rs],bubble:[Cs,Rs],heatmap:[Ns],bar:[zs],swarm:[Cs],waterfall:[(e,t,n,i)=>{zs(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const o=r[0].datum,s=o?._connectorStroke;if(s){e.save(),e.strokeStyle=vn(e,s)||s,e.lineWidth=o?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const i=r[t],o=r[t+1],s=i.datum,a=o.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=i.x+i.w,u=o.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[Os],mixed:[js,ws,Cs],custom:[js,zs,Ns,ws,Cs,Rs,(e,t)=>{const n=e.globalAlpha;for(const i of t)"glyph"===i.type&&Ls(e,i,i.x,i.y,n);e.globalAlpha=n},Os]};require("react/jsx-runtime");var qs=require("react/jsx-runtime");function Ys(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Hs({hover:e}){const t=e.data??{},n=t.y??t.value,i=t.x??t.time;if(void 0===n&&void 0===i){const e=function(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,i=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(i&&H.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let o=r.findIndex(e=>W.includes(e.lower));const s=o>=0;0>o&&(o=r.findIndex(e=>"id"===e.lower)),0>o&&(o=r.findIndex(e=>"string"==typeof e.value));const a=0>o?void 0:r[o];let c=r.filter((e,t)=>t!==o);s&&(c=c.filter(e=>"id"!==e.lower));const l=G(c,q),u=G(c,Y),d=new Set(q),h=new Set(Y),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}(t);if(null!=e.title||e.entries.length>0)return(0,qs.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[null!=e.title&&(0,qs.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,qs.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,qs.jsx)("span",{style:{fontWeight:600},children:Ys(e.value)})]},e.key))]})}return(0,qs.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[(0,qs.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Ys(n)}),(0,qs.jsx)("div",{style:{opacity:.7,fontSize:11},children:Ys(i)})]})}Hs.ownsChrome=!0;var Gs=require("react/jsx-runtime"),Xs={top:20,right:20,bottom:30,left:40},Vs=ko;function Us(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Ks=(0,ie.memo)((0,ie.forwardRef)(function(e,t){const{chartType:n,runtimeMode:i,data:r,chunkThreshold:o,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p,lineDataAccessor:y,curve:g,normalize:m,baseline:x,stackOrder:b,binSize:v,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:M,xExtent:P,yExtent:_,extentPadding:j=.1,scalePadding:C,sizeRange:I,size:T=[500,300],responsiveWidth:R,responsiveHeight:L,margin:$,className:E,background:z,lineStyle:D,pointStyle:N,areaStyle:W,barStyle:q,waterfallStyle:Y,swarmStyle:H,barColors:G,colorScheme:X,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:Q,lineGradient:J,areaGroups:ee,openAccessor:te,highAccessor:re,lowAccessor:oe,closeAccessor:se,candlestickStyle:ae,showAxes:ce=!0,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:ye,yFormat:ge,axisExtent:me,tickFormatTime:be,tickFormatValue:ve,hoverAnnotation:we,tooltipContent:ke,customHoverBehavior:Se,customClickBehavior:Ae,enableHover:Me,hoverRadius:Pe=30,tooltipMode:_e,annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,showGrid:Te,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Be,legendCategoryAccessor:Fe,onCategoriesChange:Ne,backgroundGraphics:Oe,foregroundGraphics:We,canvasPreRenderers:qe,svgPreRenderers:Ye,title:He,categoryAccessor:Ge,brush:Xe,onBrush:Ve,decay:Ue,pulse:Ke,transition:Ze,animate:Qe,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:it,heatmapValueFormat:rt,marginalGraphics:st,pointIdAccessor:at,xScaleType:ct,yScaleType:lt,accessibleTable:ut=!0,description:dt,summary:ht,linkedCrosshairName:ft,linkedCrosshairSourceId:pt,customLayout:yt,onLayoutError:gt,layoutConfig:mt,layoutSelection:xt}=e,bt=(0,ie.useId)().replace(/:/g,""),vt=(0,ie.useRef)(!1),wt=(0,ie.useRef)({w:-1,h:-1}),kt=(0,ie.useRef)(!1),St=ls({sizeProp:T,responsiveWidth:R,responsiveHeight:L,userMargin:$,marginDefault:Xs,animate:Qe,transitionProp:Ze,themeDirtyRef:vt}),At=ho(),Mt=go(),{reducedMotionRef:Pt,responsiveRef:_t,size:jt,currentTheme:Ct,transition:It,introEnabled:Tt,tableId:Rt,rafRef:Lt,renderFnRef:$t,scheduleRender:Et,cancelRender:zt}=St;let Dt=St.margin;if(st){const e=60,t={...St.margin};st.top&&e>t.top&&(t.top=e),st.bottom&&e>t.bottom&&(t.bottom=e),st.left&&e>t.left&&(t.left=e),st.right&&e>t.right&&(t.right=e),Dt=t}const Bt=jt[0]-Dt.left-Dt.right,Ft=jt[1]-Dt.top-Dt.bottom,Nt=(0,ie.useMemo)(()=>B(r),[r]),Wt=we??Me,qt=(0,ie.useRef)(null),Yt=(0,ie.useRef)(null),[Gt,Vt]=(0,ie.useState)(0),Ut=(0,ie.useRef)(0),[Kt,Zt]=(0,ie.useState)(null),en=(e,t)=>"function"==typeof e?e({size:jt,margin:Dt,scales:t}):e,tn=en(We,Kt),nn=en(Oe,Kt),rn=(0,ie.useRef)(null),on=(0,ie.useRef)(null),sn=(0,ie.useRef)(void 0),[an,cn]=(0,ie.useState)(null),ln=(0,ie.useRef)(Vs.primary),un=(0,ie.useRef)(function(){let e=-1,t=ko;return{resolve(n){if(!n)return ko;const i=gn;return i===e||(t=function(e){if(!e)return ko;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),i=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),o=t.getPropertyValue("--semiotic-primary").trim(),s=i||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return s||a||n||o?{axisStroke:c||ko.axisStroke,tickText:s||ko.tickText,crosshair:s?So(s,"66"):ko.crosshair,hoverFill:l?So(l,"4D"):ko.hoverFill,hoverStroke:s?So(s,"99"):ko.hoverStroke,pointRing:l||ko.pointRing,primary:o||ko.primary,background:l||ko.background}:ko}(n),e=i),t},invalidate(){e=-1}}}()),dn=(0,ie.useRef)(!1),fn=(0,ie.useRef)(new Ht),pn=(0,ie.useRef)([]),yn=(0,ie.useRef)(Fe),mn=(0,ie.useRef)(Ne);yn.current=Fe,mn.current=Ne;const[xn,bn]=(0,ie.useState)(!1),[wn,kn]=(0,ie.useState)([]),[Sn,An]=(0,ie.useState)([]),Mn="streaming"===i||["bar","swarm","waterfall"].includes(n),Pn=function(e){const t=(0,xo.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return vo(e,t);if(!wo(e)||!wo(t))return!1;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;const n=e[i],r=t[i];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!vo(n,r))return!1}else{if(!wo(n)||!wo(r))return!1;if(!bo(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}((0,ie.useMemo)(()=>({chartType:n,runtimeMode:Mn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Mn?k:"right",extentPadding:j,scalePadding:C,axisExtent:me,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Mn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Ge,lineDataAccessor:y,xScaleType:ct,yScaleType:lt,xExtent:P,yExtent:_,sizeRange:I,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:!0===Q?{topOpacity:.8,bottomOpacity:.05}:!1===Q?void 0:Q,areaGroups:ee?new Set(ee):void 0,lineGradient:J,openAccessor:te,highAccessor:re,lowAccessor:oe,closeAccessor:se,candlestickStyle:ae,lineStyle:D,pointStyle:N,areaStyle:W,swarmStyle:H,waterfallStyle:Y,colorScheme:X,barColors:G,barStyle:q,annotations:je,decay:Ue,pulse:Ke,transition:It,introAnimation:Tt,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:it,heatmapValueFormat:rt,pointIdAccessor:at,curve:g,themeCategorical:Ct?.colors?.categorical,themeSemantic:xe(Ct),themeSequential:Ct?.colors?.sequential,themeDiverging:Ct?.colors?.diverging,customLayout:yt,onLayoutError:gt,layoutConfig:mt,layoutMargin:Dt}),[n,A,S,k,j,C,me,a,c,l,M,w,ct,lt,u,d,h,f,p,Ge,y,P,_,I,v,m,x,b,V,U,K,Z,Q,J,ee,te,re,oe,se,ae,D,N,W,H,Y,q,X,G,je,Ue,Ke,It?.duration,It?.easing,Tt,Je,et,tt,nt,it,rt,Mn,at,g,Ct,yt,gt,mt,Dt])),_n=(0,ie.useRef)(null);_n.current||(_n.current=new Ot(Pn));const Tn=function(e,t,n,i){return(0,hs.useCallback)(()=>{const r=t.current,o=n.current;if(!o||!r)return;const s=function(e,t){if(!t)return[];const n=new Set,i=[];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 o=e+"";n.has(o)||(n.add(o),i.push(o))}return i}(e.current?.getData()??[],r);(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})(s,i.current)||(i.current=s,o(s))},[t,n,i,e])}(_n,yn,mn,pn);!function(e,t,n,i){(0,Jt.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,i()},[t,i,e,n])}(_n,Pn,vt,Et),function(e,t,n,i){const r=(0,Jt.useRef)(null);(0,Jt.useEffect)(()=>{const o=e.current;if(!o)return;const s=t??null;r.current!==s&&(r.current=s,o.setLayoutSelection(s),o.hasCustomRestyle?o.restyleScene(s):n.current=!0,i())},[t,i,e,n])}(_n,xt,vt,Et);const Rn=(0,ie.useRef)(null);Rn.current||(Rn.current=new fe(e=>{const t=_n.current;t&&t.ingest(e)&&(vt.current=!0,Et())},{chunkThreshold:o,chunkSize:s})),(0,ie.useEffect)(()=>{Rn.current?.updateChunkOptions({chunkThreshold:o,chunkSize:s})},[o,s]);const Ln=(0,ie.useCallback)(e=>{Rn.current?.push(e)},[]),$n=(0,ie.useCallback)(e=>{Rn.current?.pushMany(e)},[]),En=(0,ie.useCallback)(()=>{Rn.current?.clear(),_n.current?.clear(),vt.current=!0,Et()},[Et]);(0,ie.useImperativeHandle)(t,()=>({push:Ln,pushMany:$n,remove:e=>{Rn.current?.flush();const t=_n.current?.remove(e)??[];return t.length>0&&(rn.current&&t.some(e=>e===rn.current?.data)&&(rn.current=null,cn(null)),vt.current=!0,Et()),t},update:(e,t)=>{Rn.current?.flush();const n=_n.current?.update(e,t)??[];return n.length>0&&(vt.current=!0,Et()),n},clear:En,getData:()=>(Rn.current?.flush(),_n.current?.getData()??[]),getScales:()=>_n.current?.scales??null,getExtents:()=>_n.current?.getExtents()??null,getCustomLayout:()=>_n.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>_n.current?.lastCustomLayoutFailure??null}),[Ln,$n,En,Et]),(0,ie.useEffect)(()=>{if(r){if(y&&Nt.length>0&&"object"==typeof Nt[0]&&null!==Nt[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(Nt[0][e])){const t=[];for(const n of Nt){const i=n[e];if(Array.isArray(i)){const e=n.label||n.id||n.key;if(null!=e)for(const n of i)t.push({...n,_lineGroup:e});else for(const e of i)t.push(e)}}return void Rn.current?.setBoundedData(t)}}Rn.current?.setBoundedData(Nt)}},[r,Nt,y]);const{hoverHandlerRef:zn,hoverLeaveRef:Dn,onPointerMove:Bn,onPointerLeave:Fn}=St;zn.current=e=>{if(!Wt)return;const t=qt.current;if(!t)return;const i=t.getBoundingClientRect(),r=e.clientX-i.left-Dt.left,o=e.clientY-i.top-Dt.top;if(0>r||r>Bt||0>o||o>Ft)return void(rn.current&&(rn.current=null,on.current=null,cn(null),Se&&(Se(null),vt.current=!0),Et()));const s=_n.current;if(!s||0===s.scene.length)return;const c=F(Pe,e.pointerType),l=Cn(s.scene,r,o,c,s.quadtree,s.maxPointRadius),u="multi"===_e,d=()=>{rn.current&&(rn.current=null,on.current=null,cn(null),Se&&Se(null),Et())};if(!l&&!u)return void d();const h=u||!l?r:l.x,f=u||!l?o:l.y,p=l?.datum?ot(l.datum,s.resolvedRibbons):{},y=s.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&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const i=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const o=In(jn(e.path,e.curve),t,n);if(null===o)continue;const s=Nn(e.path,t);i.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:o,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 o=jn(e.topPath,e.curve),s=jn(e.bottomPath,e.curve),a=In(o,t,n);if(null===a)continue;const c=In(s,t,n),l=Nn(e.topPath,t);i.push({node:r,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??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 i}(s.scene,h,Math.max(c,Bt));if(e.length>0){const t=s.scales.y.invert,i=ln.current,r=y?y(h):h;if(l)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,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=o?r-o:r,valuePx:e.y,color:e.color||i,datum:ot(e.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(rn.current=m,on.current=l?.node??null,cn(m),Se&&(Se(m),vt.current=!0),Et()):d()},Dn.current=()=>{rn.current&&(rn.current=null,on.current=null,cn(null),Se&&(Se(null),vt.current=!0),Et())};const Yn=(0,ie.useRef)(()=>{});Yn.current=e=>{if(!Ae)return;const t=qt.current;if(!t)return;const n=t.getBoundingClientRect(),i=e.clientX-n.left-Dt.left,r=e.clientY-n.top-Dt.top;if(0>i||i>Bt||0>r||r>Ft)return void Ae(null);const o=_n.current;if(!o||0===o.scene.length)return void Ae(null);const s=F(Pe,sn.current),a=Cn(o.scene,i,r,s,o.quadtree,o.maxPointRadius);if(!a)return void Ae(null);const c=a.datum||{},l=o.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Ae(O(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const Hn=(0,ie.useCallback)(e=>Yn.current(e),[]),Xn=(0,ie.useRef)(-1),Un=(0,ie.useRef)(null),Kn=(0,ie.useRef)(null),Zn=(0,ie.useCallback)(e=>{const t=_n.current;if(!t||0===t.scene.length)return;const n=t.version;let i;if(Kn.current&&Kn.current.version===n)i=Kn.current.graph;else{const e=function(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=hn(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,i=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&i.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:i[n],shape:"circle",group:r});break}case"area":{const e=n,i=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&i.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:i[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}(t.scene);if(0===e.length)return;i=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let i=t.get(e);i||(i=[],t.set(e,i)),i.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 i=t.get(e),r=t.get(n);return(i.length>0?i[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(t.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=i[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:i,groups:n,byGroup:t,idToIdx:r}}(e),Kn.current={version:n,graph:i}}const r=Xn.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Xn.current=0;const n=i.flat[0];Un.current={shape:n.shape,w:n.w,h:n.h};const r=Wn({...n,datum:ot(n.datum,t.resolvedRibbons)});return rn.current=r,cn(r),Se&&Se(r),void Et()}const o=function(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)),i=e.flat[n];return{flatIndex:n,group:i.group??"_default",indexInGroup:i._groupIndex??0}}(i,r),s=function(e,t,n){const{group:i,indexInGroup:r}=t,o=n.byGroup.get(i);switch(e){case"ArrowRight":return o.length-1>r?o[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?o[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(i);return n.groups.length-1>e?On(n,n.groups[e+1],o[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(i);return e>0?On(n,n.groups[e-1],o[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}}(e.key,o,i);if(null===s)return;if(e.preventDefault(),0>s)return Xn.current=-1,Un.current=null,rn.current=null,on.current=null,cn(null),Se&&Se(null),void Et();Xn.current=s;const a=i.flat[s];Un.current={shape:a.shape,w:a.w,h:a.h};const c=Wn({...a,datum:ot(a.datum,t.resolvedRibbons)});rn.current=c,cn(c),Se&&Se(c),Et()},[Se,Et]),Qn=(0,ie.useCallback)(e=>{sn.current=e.pointerType,Xn.current=-1,Un.current=null,Bn(e)},[Bn]),Jn=(0,ie.useCallback)(e=>{sn.current="mouse",Xn.current=-1,Un.current=null,Bn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Bn]),ei=(0,ie.useCallback)(e=>{sn.current=e.pointerType},[]);$t.current=()=>{Lt.current=null;const e=qt.current,t=Yt.current;if(!e||!t)return;const i=_n.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=i.advanceTransition(Pt.current?r+1e6:r),s=!Pt.current&&o,l=wt.current.w!==Bt||wt.current.h!==Ft,u=vt.current||o||l,d=i.consumeStylePaintPending();let h=!1;const f=i.getLastUpdateResult(),p=fn.current.beforeCompute(f,s);!u||s&&!l||(i.computeScene({width:Bt,height:Ft}),wt.current={w:Bt,h:Ft},h=!0,Tn()),fn.current.afterCompute(p,h,l);const y=function(e,t,n,i){const r=i.current,o=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!o&&e.hasActivePulsesAt(t),a=!(n||o||!s&&!r)&&e.refreshPulse(t);return i.current=s,{changed:a,pending:s}}(i,r,h,kt),g=ds(),m=un.current.resolve(e);ln.current=m.primary;const x=Gn(Je,i.lastIngestTime>0?r-i.lastIngestTime:0),b=Je&&x.isStale;if(u||d||y.changed){const t=us(e,jt,Dt,g);if(t){if(t.clearRect(-Dt.left,-Dt.top,jt[0],jt[1]),Je&&1>x.alpha&&(t.globalAlpha=x.alpha),function(e,t){const{background:n,hasBackgroundGraphics:i=!1,themeBackground:r="",x:o=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(i)return!1;const l=n||(r&&"transparent"!==r?r:"")||null;if(!l)return!1;const u=vn(e,l);u&&(e.fillStyle=u,e.fillRect(o,s,a,c))}(t,{background:z,hasBackgroundGraphics:!!Oe,themeBackground:m.background,x:-Dt.left,y:-Dt.top,width:jt[0],height:jt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Bt,Ft),t.clip()),qe&&i.scales)for(const e of qe)t.save(),e(t,i.scene,i.scales,{width:Bt,height:Ft}),t.restore();const e=yt?Ws.custom:Ws[n];if(e&&i.scales)for(const n of e)n(t,i.scene,i.scales,{width:Bt,height:Ft});t.restore(),Je&&1>x.alpha&&(t.globalAlpha=1)}}const v=!!(Wt&&rn.current&&i.scales),w=!!(on.current&&Array.isArray(we)&&we.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=v||w;if(k||dn.current){const e=us(t,jt,Dt,g);if(e&&(e.clearRect(-Dt.left,-Dt.top,jt[0],jt[1]),v&&rn.current&&function(e,t,n,i,r,o,s){if(!1===r.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,i),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.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}(o)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,rn.current,Bt,Ft,"object"==typeof Wt?Wt:{},on.current,m),w&&on.current&&Array.isArray(we))){const t=we.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,i,r){if(!n)return;const o="group"in n?n.group:void 0;if(void 0!==o)for(const n of t){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const t="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.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,i.scene,on.current,t,m)}dn.current=k}u&&e&&e.setAttribute("aria-label",Lo(i.scene,n+" chart"));const S=vt.current;if(vt.current=S&&s&&!h,S&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Kt||e(Kt.x.domain()[0])!==e(i.scales.x.domain()[0])||e(Kt.x.domain()[1])!==e(i.scales.x.domain()[1])||e(Kt.y.domain()[0])!==e(i.scales.y.domain()[0])||e(Kt.y.domain()[1])!==e(i.scales.y.domain()[1])||Kt.x.range()[0]!==i.scales.x.range()[0]||Kt.x.range()[1]!==i.scales.x.range()[1]||Kt.y.range()[0]!==i.scales.y.range()[0]||Kt.y.range()[1]!==i.scales.y.range()[1])&&Zt(i.scales),st){const e=i.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];kn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),An(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((je&&je.length>0||yt)&&(h||s))||!h&&33>r-Ut.current||(Vt(e=>e+1),Ut.current=r),Je?.showBadge&&bn(!!b),(s||null!=i.activeTransition||y.pending)&&Et()},mo({hydrated:At,wasHydratingFromSSR:Mt,storeRef:_n,dirtyRef:vt,renderFnRef:$t,cancelRender:zt,cleanup:()=>Rn.current?.clear()}),(0,ie.useEffect)(()=>{vt.current=!0,Et()},[n,Bt,Ft,ce,z,Oe,D,qe,Et]),function(e,t,n,i,r,o){const s=(0,qn.useRef)("fresh");(0,qn.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Gn(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===r||(s.current=l.band,l.isStale!==r&&o(l.isStale),n.current=!0,i())},1e3);return()=>clearInterval(a)},[e,r,i])}(Je,_n,vt,Et,xn,bn);const ti=(0,ie.useMemo)(()=>{if(ye||be)return;const e=_n.current;return e?.xIsDate&&Kt?gs(Kt.x.domain()):void 0},[ye,be,Kt]),ni=ye||be||ti,ii=Wt&&an?ke?ke(an):(0,Gs.jsx)(Hs,{hover:an}):null,ri=ii?(0,Gs.jsx)(ts,{x:an.x,y:an.y,containerWidth:Bt,containerHeight:Ft,margin:Dt,className:"stream-frame-tooltip",children:ii}):null,oi=Un.current,si=(0,Gs.jsx)(Qo,{active:Xn.current>=0,hoverPoint:an,margin:Dt,size:jt,shape:oi?.shape,width:oi?.w,height:oi?.h}),ai=fs(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),ci=fs(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),li=ai.key,ui=ci.key,di=function(e,t,n){return i=>{if(!i||!n||!e.fn&&!t.fn)return i;let r=!1;const o=i.map(n=>{const i=e.fn&&e.key&&!(e.key in n),o=t.fn&&t.key&&!(t.key in n);if(!i&&!o)return n;r=!0;const s={...n};return i&&(s[e.key]=e.fn(n)),o&&(s[t.key]=t.fn(n)),s});return r?o:i}}(ai,ci,je&&je.length>0||!1);if(co||!At&&Mt){const e=_n.current;e&&r&&(e.ingest({inserts:Nt,bounded:!0}),e.computeScene({width:Bt,height:Ft}));const t=e?.scene??[],n=e?.scales??null,i=en(We,n),o=en(Oe,n),s=ni||(()=>{if(e?.xIsDate&&n)return gs(n.x.domain())})();return(0,Gs.jsxs)("div",{ref:_t,className:"stream-xy-frame"+(E?" "+E:""),role:"img","aria-label":dt||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:R?"100%":jt[0],height:L?"100%":jt[1]},children:[(0,Gs.jsx)(Xo,{summary:ht}),(0,Gs.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:jt[0],height:jt[1],style:{position:"absolute",left:0,top:0},children:[(0,Gs.jsx)("g",{transform:`translate(${Dt.left},${Dt.top})`,children:o}),(0,Gs.jsxs)("g",{transform:`translate(${Dt.left},${Dt.top})`,children:[z&&(0,Gs.jsx)("rect",{x:0,y:0,width:Bt,height:Ft,fill:z}),Ye&&n&&Ye.map((e,i)=>(0,Gs.jsx)(ne.Fragment,{children:e(t,n,{width:Bt,height:Ft})},"svgpre-"+i)),t.map((e,t)=>so(e,t,bt)).filter(Boolean)]})]}),(0,Gs.jsx)(Xr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,scales:n,showAxes:ce,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:s,yFormat:ge||ve,axisExtent:me,showGrid:Te,title:He,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Be,foregroundGraphics:Xt(i,Qt(_n.current?.customLayoutOverlays,xt??null)),marginalGraphics:st,xValues:[],yValues:[],annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,annotationFrame:0,xAccessor:li,yAccessor:ui,annotationData:di(e?.getData()),pointNodes:ms(e?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:ft,linkedCrosshairSourceId:pt})]})}return(0,Gs.jsxs)("div",{ref:_t,className:"stream-xy-frame"+(E?" "+E:""),role:"group","aria-label":dt||("string"==typeof He?He:"XY chart"),tabIndex:0,style:{position:"relative",width:R?"100%":jt[0],height:L?"100%":jt[1],overflow:"visible",touchAction:Us(Xe)},onKeyDown:Zn,children:[ut&&(0,Gs.jsx)(Vo,{tableId:Rt}),ut&&(0,Gs.jsx)(Go,{scene:_n.current?.scene??[],chartType:n+" chart",tableId:Rt,chartTitle:"string"==typeof He?He:void 0}),(0,Gs.jsx)(Xo,{summary:ht}),(0,Gs.jsx)(Uo,{hoverPoint:an}),(0,Gs.jsxs)("div",{role:"img","aria-label":dt||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Wt?Qn:void 0,onMouseMove:Wt?Jn:void 0,onPointerLeave:Wt?Fn:void 0,onMouseLeave:Wt?Fn:void 0,onPointerDown:Wt||Ae?ei:void 0,onClick:Ae?Hn:void 0,children:[nn&&(0,Gs.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:jt[0],height:jt[1],pointerEvents:"none"},children:(0,Gs.jsx)("g",{transform:`translate(${Dt.left},${Dt.top})`,children:nn})}),(0,Gs.jsx)(Yr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,scales:Kt,showAxes:ce,axes:le,showGrid:Te,xFormat:ni,yFormat:ge||ve,axisExtent:me}),(0,Gs.jsx)("canvas",{ref:qt,"aria-label":Lo(_n.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Gs.jsx)("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Gs.jsx)(Xr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,scales:Kt,showAxes:ce,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:ni,yFormat:ge||ve,axisExtent:me,showGrid:Te,title:He,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Be,foregroundGraphics:Xt(tn,Qt(_n.current?.customLayoutOverlays,xt??null)),marginalGraphics:st,xValues:wn,yValues:Sn,annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,annotationFrame:Gt,xAccessor:li,yAccessor:ui,annotationData:di(_n.current?.getData()),pointNodes:ms(_n.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==z&&!Oe,linkedCrosshairName:ft,linkedCrosshairSourceId:pt}),(Xe||Ve)&&(0,Gs.jsx)(he,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:Dt,dimension:Xe?.dimension??"xy",scales:Kt,onBrush:Ve??(()=>{}),binSize:v,snap:Xe?.snap,binBoundaries:Xe?.binBoundaries??("bar"===n?_n.current?.getBinBoundaries():void 0),snapDuring:Xe?.snapDuring,streaming:"streaming"===i}),Je?.showBadge&&(0,Gs.jsx)(Vn,{isStale:xn,position:Je.badgePosition}),si,ri]})]})}));Ks.displayName="StreamXYFrame";var Zs=Ks,Qs=require("react"),Js=require("react"),ea=(require("react/jsx-runtime"),(0,Js.createContext)(null));function ta(){return(0,Js.useContext)(ea)}var na=require("react");function ia(e){const t=[];for(const[n,i]of Object.entries(e.fields))if("point"===i.type)t.push(e=>i.values.has(e[n]));else{const[e,r]=i.range;t.push(t=>{const i=t[n];return i>=e&&r>=i})}return e=>t.every(t=>t(e))}function ra(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function oa(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[sa,aa]=ge(e=>({selections:new Map,setClause(t,n){e(e=>{const i=e.selections.get(t),r=i?.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,i]of n){const n=t.fields[e];if(!n||!oa(i,n))return!1}return!0}(r,n))return{};const o=new Map(e.selections),s=ra(o,t),a=new Map(s.clauses);return a.set(n.clientId,n),o.set(t,{...s,clauses:a}),{selections:o}})},clearClause(t,n){e(e=>{const i=e.selections.get(t);if(!i||!i.clauses.has(n))return{};const r=new Map(e.selections),o=new Map(i.clauses);return o.delete(n),r.set(t,{...i,clauses:o}),{selections:r}})},setResolution(t,n){e(e=>{const i=e.selections.get(t);if(i?.resolution===n)return{};const r=new Map(e.selections),o=ra(r,t);return r.set(t,{...o,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const i=new Map(e.selections);return i.set(t,{...n,clauses:new Map}),{selections:i}})}})),[ca,la]=ge(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),ua=require("react");function da(e){const t=(0,ua.useId)(),n=e.clientId||t,{name:i}=e,r=aa(e=>e.selections.get(i)),o=aa(e=>e.setClause),s=aa(e=>e.clearClause),a=(0,ua.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,ua.useMemo)(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[i,r]of e.clauses)"crossfilter"===e.resolution&&i===t||n.push(ia(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,ua.useCallback)(e=>{const t={};let r=!1;for(const[n,i]of Object.entries(e))t[n]={type:"point",values:new Set(i)},r=!0;r&&o(i,{clientId:n,type:"point",fields:t})},[n,i,o]),selectInterval:(0,ua.useCallback)(e=>{const t={};let r=!1;for(const[n,i]of Object.entries(e))t[n]={type:"interval",range:i},r=!0;r&&o(i,{clientId:n,type:"interval",fields:t})},[n,i,o]),clear:(0,ua.useCallback)(()=>{s(i,n)},[s,i,n]),clientId:n}}require("react/jsx-runtime");var ha=(0,na.createContext)(!1);(0,na.createContext)(!1);var fa=(0,na.createContext)(null),pa="undefined"==typeof window?na.useEffect:na.useLayoutEffect;var ya=c(require("react")),ga={light:we,dark:ke,"high-contrast":Se,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function ma(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function xa(e,t,n){const i=e.xValue??t?.[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function ba(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function va(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}require("react/jsx-runtime"),ya.createContext(void 0);var wa={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function ka(e,t={}){const n=t.mobileSemantics?.interaction,i="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,o=!!n||void 0!==i,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!r&&!o)return wa;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??i??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Sa(){const e=Pe(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Aa({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:o,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,Qs.useId)(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),f="series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n||[],p=da({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:o,clear:s}=da({name:t,fields:n});return{onHover:(0,ua.useCallback)(e=>{if(!e)return void s();const t={};for(const i of n){const n=e[i];void 0!==n&&(t[i]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&o(t)},[n,o,s,t]),predicate:i,isActive:r}}({name:h?.name||"hover",fields:f}),g=la(e=>e.pushObservation),m=e?{isActive:p.isActive,predicate:p.predicate}:null,[x,b]=(0,Qs.useState)(null),v=(0,Qs.useRef)(!1),w=l||n[0],k=(0,Qs.useMemo)(()=>{if(!c||null==x||!w)return null;const e=x,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,x,w]),S=(0,Qs.useCallback)(e=>{const n=!e&&v.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=xa(e,t,h.xField);null!=n&&function(e,t,n){const i=_r.positions.get(e);i?.locked||i&&i.xValue===t&&i.sourceId===n||(_r={positions:new Map(_r.positions).set(e,{xValue:t,sourceId:n})},Cr())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||n||Ir(h.name||"hover",d),"x-position"===h?.mode||n||y.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else n||b(null);if(r||g){const t={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(e){const n=ba(e),i={...t,type:"hover",datum:n||{},x:e.x??0,y:e.y??0};r&&r(i),g&&g(i)}else{const e={...t,type:"hover-end"};r&&r(e),g&&g(e)}}},[t,y,h,d,r,o,s,g,c,w,u]),A=(0,Qs.useCallback)((n=!0)=>{v.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&c&&b(null),"x-position"===h?.mode&&(Tr(h.name||"hover",d),Ir(h.name||"hover",d))},[t,h,y,e,u,p,c,d]),M=(0,Qs.useCallback)(n=>{const i=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),l=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=xa(n,e,h.xField);null!=t&&function(e,t,n){const i=_r.positions.get(e);if(i?.locked){const t=new Map(_r.positions);return t.delete(e),_r={positions:t},Cr(),!1}_r={positions:new Map(_r.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Cr()}(h.name||"hover",t,d)}if(i)if(n){v.current=!0;const i=ba(n);if(t&&"x-position"!==h?.mode&&y.onHover(i),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=i[t];void 0!==n&&(e[t]=[n])}va(e)&&p.selectPoints(e)}if(c&&w){const e=i?.[w];b(null!=e?e+"":null)}}else l&&A();if(n||l){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}if(r||g){const e={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(n){const t=ba(n),i={...e,type:"click",datum:t||{},x:n.x??0,y:n.y??0};r&&r(i),g&&g(i)}else{const t={...e,type:"click-end"};r&&r(t),g&&g(t)}}}},[a,r,g,o,s,h,d,u,t,y,e,p,f,c,w,A]);return(0,Qs.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&v.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,Qs.useEffect)(()=>()=>{v.current&&A(!1)},[A]),(0,Qs.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Tr(e,d),Ir(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:d}}function Ma({data:e,colorBy:t,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:o,defaults:s={top:50,bottom:60,left:70,right:40},categories:a}){const c=(0,na.useContext)(ha),l=null!==(0,na.useContext)(fa),u=void 0!==i?i:!c&&!!t,d=!!t&&(u||l),h=(0,Qs.useMemo)(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const i of e){const e="function"==typeof t?t(i):i[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,d]);!function(e){const t=(0,na.useContext)(fa),n=(0,na.useId)(),i=function(e){const t=new Set,n=[];for(const i of e)t.has(i)||(t.add(i),n.push(i));return n}(e),r=(0,na.useRef)([]);(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})(r.current,i)||(r.current=i);const o=r.current;pa(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),pa(()=>{t&&t.registerCategories(n,o)},[t,n,o])}(l&&t?h:[]);const f=(0,Qs.useMemo)(()=>{if(!u||!t)return;const i=function({data:e,colorBy:t,colorScale:n,getColor:i,strokeColor:r,strokeWidth:o,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==o&&(n.strokeWidth=o),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,o)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?i(s,t,n):n?n(r):R[o%R.length];return{label:r+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:$,categories:h});return 0!==i.legendGroups.reduce((e,t)=>e+t.items.length,0)?i:void 0},[u,t,e,n,h]),p=(0,Qs.useMemo)(()=>{const e="number"==typeof o?{top:o,bottom:o,left:o,right:o}:o??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},i=t=>"number"==typeof e[t];return f&&("right"===r&&!i("right")&&110>n.right?n.right=110:"left"===r&&!i("left")&&110>n.left?n.left=110:"top"===r&&!i("top")&&50>n.top?n.top=50:"bottom"===r&&!i("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,o,f,r]);return{legend:f,margin:p,legendPosition:r}}var Pa={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 _a(e,t,n){const i=Pa[e||"primary"],r=e&&"primary"!==e||!n?.width?i.width:n.width,o=e&&"primary"!==e||!n?.height?i.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const i=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,i=t.width,r=t.height,o=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>i||"number"==typeof n.maxWidth&&i>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof o||n.minAspectRatio>o)||"number"==typeof n.maxAspectRatio&&("number"!=typeof o||o>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:i.reduce((e,t)=>function(e,t){const n={...e,...t};for(const i of["margin","frameProps","mobileSemantics","style"])ma(e[i])&&ma(t[i])&&(n[i]={...e[i],...t[i]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:i}}({...t,mode:e},{width:t.width??r,height:t.height??o}).props,a=s.mode||e,c=Pa[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:ja(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:ka(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function ja(e,t,n){if(!1!==t)return e;const i={...e};return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}var Ca=c(require("react")),Ia=require("react/jsx-runtime");function Ta({componentName:e,message:t,diagnosticHint:n,width:i,height:r}){return(0,Ia.jsx)("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,Ia.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Ia.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Ia.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Ia.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Ra=require("react/jsx-runtime"),La=class extends Ca.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Ra.jsx)(Ta,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},$a=require("react/jsx-runtime");function Ea({componentName:e,width:t,height:n,children:i}){return(0,$a.jsx)(La,{fallback:i=>(0,$a.jsx)(Ta,{componentName:e,message:i.message,width:t,height:n}),children:i})}"undefined"!=typeof process&&process;var za={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"},Da={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ba(e,t,n,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,$a.jsx)("div",{style:{...za,width:t,height:n},children:i||"No data available"}):null}function Fa(e,t,n,i){if(!e)return null;if(!1===i)return null;if(null!=i)return(0,$a.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*r))),s=Math.max(6,Math.floor(n/(2.5*r))),a=Math.floor((n-(r*(o+s)-s))/2);return(0,$a.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,n)=>(0,$a.jsx)("div",{className:"semiotic-loading-bar",style:{...Da,position:"absolute",top:a+n*(o+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2}},n))})}var Na=require("react"),Oa=require("react");var Wa=require("react/jsx-runtime");function qa(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;const t=+e;return Number.isFinite(t)?t:NaN}return NaN}function Ya(e,t,n,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),o=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>o.push(e),f=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;r.length>e;e++){const o=r[e],p=t(o),y=n(o),g=i(o);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const n=y-c.a-(g-c.b);if(0!==n){const i=Math.max(0,Math.min(1,(c.b-c.a)/n));e=c.x+i*(p-c.x),t=c.a+i*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)f(l[e],a)}else for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:o}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:o}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:o})}for(const e of l)f(e,a??"A");return o}var Ha=(0,te.forwardRef)(function(e,t){const n=(0,te.useRef)(null),i=_a(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:r,margin:o,className:s,xFormat:a,yFormat:c,xAccessor:l="x",seriesAAccessor:u="a",seriesBAccessor:d="b",seriesALabel:h="A",seriesBLabel:f="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:y="var(--semiotic-info, #2563eb)",showLines:g=!0,lineWidth:m=1.5,showPoints:x=!1,pointRadius:b=3,curve:v="linear",areaOpacity:w=.6,gradientFill:k,tooltip:S,annotations:A,xExtent:M,yExtent:P,frameProps:_={},selection:j,linkedHover:C,onObservation:I,onClick:T,hoverHighlight:L,chartId:$,loading:E,loadingContent:D,emptyContent:F,legendInteraction:N,legendPosition:O,pointIdAccessor:W,windowSize:q}=e,{width:Y,height:H,enableHover:G,showGrid:X,showLegend:U,title:K,description:Z,summary:ne,accessibleTable:ie,xLabel:re,yLabel:oe}=i,se=(0,te.useMemo)(()=>"function"==typeof l?e=>qa(l(e)):e=>qa(e[l]),[l]),ae=(0,te.useMemo)(()=>"function"==typeof u?e=>qa(u(e)):e=>qa(e[u]),[u]),ce=(0,te.useMemo)(()=>"function"==typeof d?e=>qa(d(e)):e=>qa(e[d]),[d]),[le,ue]=(0,te.useState)([]),de=(0,te.useRef)([]),he=null==r,fe=(0,te.useMemo)(()=>B(he?le:r),[he,le,r]),pe=(0,te.useMemo)(()=>Ya(fe,se,ae,ce),[fe,se,ae,ce]),ye=(0,te.useMemo)(()=>g?function(e,t,n,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),o=[];for(const e of r){const r=t(e),s=n(e),a=i(e);Number.isFinite(s)&&o.push({__x:r,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&o.push({__x:r,__y:a,__diffSegment:"line-B"})}return o}(fe,se,ae,ce):[],[g,fe,se,ae,ce]),ge=(0,te.useMemo)(()=>[...pe,...ye],[pe,ye]),me=(0,te.useMemo)(()=>{const e=new Set;for(const t of pe)e.add(t.__diffSegment);return Array.from(e)},[pe]);(0,te.useImperativeHandle)(t,()=>{const e=e=>{const t=q&&e.length>q?e.slice(e.length-q):e;de.current=t,ue(t)},t=W?"function"==typeof W?W:e=>e[W]:null;return{push:t=>e([...de.current,t]),pushMany:t=>e([...de.current,...t]),remove:n=>{if(!t)return[];const i=Array.isArray(n)?n:[n],r=[],o=[];for(const e of de.current)i.includes(t(e))?r.push(e):o.push(e);return e(o),r},update:(n,i)=>{if(!t)return[];const r=Array.isArray(n)?n:[n],o=[],s=de.current.map(e=>{if(r.includes(t(e))){const t=i(e);return o.push(t),t}return e});return e(s),o},clear:()=>e([]),getData:()=>he?de.current:fe,getScales:()=>n.current?.getScales()??null}},[he,fe,W,q]);const xe=function(e){const{data:t,rawData:n,colorBy:i,colorScheme:r,legendInteraction:o,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,userMargin:y,marginDefaults:g,onClick:m,hoverHighlight:x,mobileInteraction:b,mobileSemantics:v,loading:w,loadingContent:k,emptyContent:S,width:A,height:M}=e,P=void 0===n,_=(0,Na.useMemo)(()=>B(t),[t]),[j,C]=(0,Na.useState)([]),I=(0,Na.useCallback)(e=>{C(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),T="string"==typeof e.colorBy?e.colorBy:void 0,L=(0,Na.useMemo)(()=>ka(b,{width:A,mobileSemantics:v}),[b,A,v]),{activeSelectionHook:$,hoverSelectionHook:E,customHoverBehavior:D,customClickBehavior:F,crosshairSourceId:N}=Aa({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:m,hoverHighlight:x,colorByField:T,mobileInteraction:L}),O=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(c,N),W=function(e,t,n){const i=ta(),r=Sa();return(0,Qs.useMemo)(()=>{if(!t)return;const o=i??void 0,s=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(o&&va(o)){const e=z(n.map(e=>({_cat:e})),"_cat",s);return t=>o[t]||e(t)}return z(n.map(e=>({_cat:e})),"_cat",s)}if(o&&va(o)){const n=z(e,t,s);return e=>o[e]||n(e)}return z(e,t,s)}if(o&&va(o)){const e=z([{_:"a"}],"_",s);return t=>o[t]||e(t)}},[e,t,n,i,r])}(_,i,r),q=(0,Na.useMemo)(()=>{if(!i)return[];const e=new Set;for(const t of _){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[_,i]),Y=(0,Na.useMemo)(()=>P&&j.length>0?j:q,[P,j,q]),H=function(e,t,n){const[i,r]=(0,Qs.useState)(null),[o,s]=(0,Qs.useState)(new Set),a=(0,Qs.useMemo)(()=>new Set,[]),c=(0,Qs.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,Qs.useCallback)(t=>{"isolate"===e&&s(e=>{const i=new Set(e);return i.has(t.label)?i.delete(t.label):i.add(t.label),i.size===n.length?new Set:i})},[e,n.length]),u=(0,Qs.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===i}:"isolate"===e&&o.size>0?{isActive:!0,predicate:e=>{const i=n?e[n]:"function"==typeof t?t(e):null;return o.has(i)}}:null},[e,t,i,o]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?o:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}(o,i,Y),G=(0,Na.useMemo)(()=>E||(H.legendSelectionHook?H.legendSelectionHook:$),[E,H.legendSelectionHook,$]),X=function(e){const t=Pe(e=>e.theme.colors.selectionOpacity);return(0,Oa.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),V=Sa(),U=ta(),K=(0,Na.useMemo)(()=>{if(W)return W;if(!i||0===Y.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:V&&V.length>0?V:R,t="__streamCat",n=z(Y.map(e=>({[t]:e})),t,e);return e=>U?.[e]||n(e)||"#999"},[W,i,Y,r,V,U]),{legend:Z,margin:Q,legendPosition:J}=Ma({data:_,colorBy:i,colorScale:K,showLegend:p,legendPosition:s,userMargin:y,defaults:g,categories:Y}),ee=(0,Na.useMemo)(()=>{const e={};return Z&&(e.legend=Z,e.legendPosition=J),o&&"none"!==o&&(e.legendHoverBehavior=H.onLegendHover,e.legendClickBehavior=H.onLegendClick,e.legendHighlightedCategory=H.highlightedCategory,e.legendIsolatedCategories=H.isolatedCategories),P&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=I),e},[Z,J,o,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,P,i,I]),te=Array.isArray(n)?B(n):n,ne=Fa(w,A,M,k),ie=ne?null:Ba(te,A,M,S);return{data:_,colorScale:W,allCategories:Y,legendState:H,effectiveSelectionHook:G,activeSelectionHook:$,customHoverBehavior:D,customClickBehavior:F,mobileInteraction:L,legend:Z,margin:Q,legendPosition:J,earlyReturn:ne||ie||null,legendBehaviorProps:ee,crosshairProps:O,resolvedSelection:X}}({data:fe,rawData:r,colorBy:"__diffWinner",colorScheme:[p,y],legendInteraction:N,legendPosition:O,selection:j,linkedHover:C,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:I,onClick:T,hoverHighlight:L,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"DifferenceChart",chartId:$,showLegend:U,userMargin:o,marginDefaults:i.marginDefaults,loading:E,loadingContent:D,emptyContent:F,width:Y,height:H}),be=(0,te.useMemo)(()=>{if(!1!==U)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:h,color:p},{label:f,color:y}]}]}},[U,h,f,p,y]),ve=(0,te.useCallback)(e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?p:y,stroke:"none",fillOpacity:w}},[p,y,w]),we=(0,te.useCallback)(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?p:y,strokeWidth:m,fill:"none"}),[p,y,m]),ke=(0,te.useCallback)(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?p:y,r:b}),[p,y,b]),Se=(0,te.useCallback)(e=>{const t=e.data,n=e.allSeries,i=e.xValue??t?.__x;let r=t?.__valA,o=t?.__valB;if(n&&n.length>0){const e=n.find(e=>"line-A"===e.group),t=n.find(e=>"line-B"===e.group);null!=e?.value&&Number.isFinite(e.value)&&(r=e.value),null!=t?.value&&Number.isFinite(t.value)&&(o=t.value)}if(null!=i&&(null==r||null==o)){const e=fe.find(e=>se(e)===i);e&&(null==r&&(r=ae(e)),null==o&&(o=ce(e)))}const s=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",c=a&&null!=i?a(i):null!=i?i+"":"";return(0,Wa.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[c&&(0,Wa.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:c}),(0,Wa.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Wa.jsx)("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),(0,Wa.jsxs)("span",{children:[h,": ",s(r)]})]}),(0,Wa.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Wa.jsx)("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),(0,Wa.jsxs)("span",{children:[f,": ",s(o)]})]}),null!=r&&null!=o&&Number.isFinite(r)&&Number.isFinite(o)&&(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(r-o)]})]})},[fe,se,ae,ce,a,p,y,h,f]),Ae="multi"===S,Me=(0,te.useMemo)(()=>!1===S?()=>null:Ae?Se:Q(S)||Se,[S,Ae,Se]);if(xe.earlyReturn)return xe.earlyReturn;const _e={chartType:"mixed",data:ge,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:me,curve:v,areaStyle:ve,lineStyle:we,...x&&{pointStyle:ke},size:[Y,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:xe.margin,showAxes:i.showAxes,xLabel:re,yLabel:oe,xFormat:a,yFormat:c,enableHover:G,showGrid:X,...k&&{gradientFill:!0===k?{topOpacity:.85,bottomOpacity:.15}:k},...be&&{legend:be,legendPosition:xe.legendPosition},...J({title:K,description:Z,summary:ne,accessibleTable:ie,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:Me,...Ae&&{tooltipMode:"multi"},...ee({linkedHover:C,selection:j,onObservation:I,onClick:T,hoverHighlight:L,mobileInteraction:xe.mobileInteraction,customHoverBehavior:xe.customHoverBehavior,customClickBehavior:xe.customClickBehavior}),...A&&A.length>0&&{annotations:A},...M&&{xExtent:M},...P&&{yExtent:P},...xe.crosshairProps,..._};return(0,Wa.jsx)(Ea,{componentName:"DifferenceChart",width:Y,height:H,children:(0,Wa.jsx)(Zs,{ref:n,..._e})})});function Ga(e,t,n){return"function"==typeof e?e(n):n[e||t]}function Xa(e){return e instanceof Date?e.getTime():Number(e)}function Va(e,t){return S(1===t?.5:e/(t-1))}"function"==typeof Ha&&(Ha.displayName="DifferenceChart");var Ua={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=r.xAccessor||"x",s=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=e=>Xa(Ga(o,"x",e)),l=e=>Xa(Ga(s,"a",e)),u=e=>Xa(Ga(a,"b",e)),d=r.seriesAColor||"var(--semiotic-danger, #dc2626)",h=r.seriesBColor||"var(--semiotic-info, #2563eb)",f=r.areaOpacity??.6,p=r.lineWidth??1.5,y=!1!==r.showLines,g=Ya(Array.isArray(e)?e:[],c,l,u),m=[];if(y&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),n=l(e),i=u(e);Number.isFinite(n)&&m.push({__x:t,__y:n,__diffSegment:"line-A"}),Number.isFinite(i)&&m.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...g,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(g.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?d:h,stroke:"none",fillOpacity:f}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...i}}},Ka={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=t||r.areaBy,s="string"==typeof o&&Array.isArray(e)?z(e,o,n):void 0;return{chartType:"stackedarea",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:o,colorScheme:n,normalize:r.normalize,stackOrder:r.stackOrder,lineStyle:null==r.areaOpacity?void 0:e=>{const t=null==o?void 0:$(e,o,s),n=r.showLine??!0;return{fill:r.color??t,stroke:n?r.stroke??t:"none",...n?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:r.areaOpacity,...null==r.opacity?{}:{opacity:r.opacity}}},...i}}},Za={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=r.xCenter,s=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,h=c.stroke||"#999",f=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,y=d.createElement,g=a?[(e,t,n)=>{if(!t?.x||!t?.y)return null;const i=n.width,r=n.height,c=null!=o?t.x(o):i/2,g=null!=s?t.y(s):r/2;if(null!=o&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(i,c)),x=Math.max(0,Math.min(r,g)),b=[{c:a.topLeft,x:0,y:0,w:m,h:x},{c:a.topRight,x:m,y:0,w:i-m,h:x},{c:a.bottomLeft,x:0,y:x,w:m,h:r-x},{c:a.bottomRight,x:m,y:x,w:i-m,h:r-x}],v=l?[y("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),y("text",{key:"ltr",x:i-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),y("text",{key:"lbl",x:8,y:r-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),y("text",{key:"lbr",x:i-8,y:r-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return y(d.Fragment,null,...b.map((e,t)=>e.w>0&&e.h>0?y("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),y("line",{key:"vc",x1:m,y1:0,x2:m,y2:r,stroke:h,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:i,y2:x,stroke:h,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle,...i,...g&&{svgPreRenderers:g}}}},Qa={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const n=t.xAccessor||"x",i=t.yAccessor||"y",r=t.orderAccessor?[...e].sort((e,n)=>null==e||"object"!=typeof e?1:null==n||"object"!=typeof n?-1:Xa(Ga(t.orderAccessor,"order",e))-Xa(Ga(t.orderAccessor,"order",n))):e,o=new WeakMap;let s=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=Xa(Ga(n,"x",e)),r=Xa(Ga(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&s++}let a=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=Xa(Ga(n,"x",e)),r=Xa(Ga(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&o.set(e,{idx:a++,total:s})}return{data:r,orderMap:o}}(e,r),s=r.pointRadius??4;return{chartType:"line",data:o.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,lineStyle:r.lineStyle||{stroke:r.stroke||"#6366f1",strokeWidth:r.strokeWidth??s,opacity:r.opacity},pointStyle:e=>{const t=o.orderMap.get(e),n=t?.idx??0,i=t?.total??1;return{fill:i>0?Va(n,i):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...i}}};function Ja(e){return Math.max(0,Math.min(1,e))}function ec(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function tc(e,t,n){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function nc(e,t){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ja(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const i=Ja(t);if(n[0].offset>=i)return n[0].color;if(i>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1];if(t.offset>i||i>r.offset)continue;const o=r.offset-t.offset,s=o>0?(i-t.offset)/o:0,a=ec(t.color),c=ec(r.color);if(!a||!c)return.5>s?t.color:r.color;const[l,u,d]=a,[h,f,p]=c;return tc(l+(h-l)*s,u+(f-u)*s,d+(p-d)*s)}return n[n.length-1].color}function ic(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}var rc={frameType:"ordinal",buildProps:(e,t,n,i,r)=>{const o=r.min??0,s=r.max??100,a=r.sweep??240,c=r.arcWidth??.3,l=180+(360-a)/2,u=r.thresholds||[{value:s,color:r.color||"#4e79a7"}],d=i.gradientFill,h=function(e){const{min:t,max:n,value:i,thresholds:r,fillColor:o,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,i))-t)/d;let f=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:n,color:o||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(n,e.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const e=a?h:1,t=ic("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;n>t;t++)i.push(nc(l.colorStops,e*(t+.5)/n));const r=ic("fill",0);y.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),g.set(r,{fill:i[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const i=f[n],r=(i.value-e)/d,o=(e-t)/d,c=(i.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-o),u=a?Math.max(0,r-l):0;if(l>0){const e=ic("fill",n);y.push({category:e,value:l,_zone:i.label||"Zone "+(n+1),_isFill:!0}),g.set(e,{fill:i.color})}if(u>0){const e=ic("bg",n);y.push({category:e,value:u,_zone:i.label||"Zone "+(n+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=i.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&n>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}({min:o,max:s,value:r.value,thresholds:u,fillColor:r.color,backgroundColor:r.backgroundColor||"#e0e0e0",fillZones:!1!==r.fillZones,showScaleLabels:!1!==r.showScaleLabels,gradientFill:d&&"object"==typeof d&&"colorStops"in d?d:void 0}),f=i.margin||{top:20,right:20,bottom:30,left:40},[p,y]=i.size||[300,300];return{chartType:"donut",data:h.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(f.left||0)-(f.right||0),y-(f.top||0)-(f.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:h.pieceStyle,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i,showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...h.gaugeAnnotations],__gauge:{gMin:o,gMax:s,sweep:a,arcWidth:c,value:r.value,startAngleDeg:l,thresholds:u}}}},oc=require("d3-scale");function sc(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function ac(e,t,n){const i=t.incoming[e.id],r=t.outgoing[e.id],o=[];for(const e of i)o.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)o.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{o.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},c=o.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(o.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,d=[...new Set(o.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const p=[];let y=0,g=0;for(const e of o)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:g);if(n>0){const t="top"===e.side?"bot":"top",i=Math.min(n,"top"===t?y:g);if(i>0){const r=f(e.time);p.push({time:r,delta:-i,kind:"transfer-out",side:t}),p.push({time:r,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?y-=i:g-=i,"top"===e.side?y+=i:g+=i,n-=i}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:g+=n)}"top"===e.side?y-=t:g-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:g+=t}o.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const e of o){if(k.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:x+=e.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:e.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let e=M;for(;k.length>e+1&&k[e+1].t===k[M].t;)e++;A.push(k[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];k[t].topMass===e.topMass&&k[t].botMass===e.botMass||A.push(k[t])}M=e+1}const P=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let _=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===_||_>e.systemInTime)&&(_=e.systemInTime);let j=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=P?P:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],i=Math.min(null!=l?l:1/0,null!=_?_:1/0);Number.isFinite(i)&&n.t>i&&n.topMass+n.botMass>0&&A.unshift({t:i,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function cc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function lc(e,t){return e.map(e=>({t:cc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function uc(e,t,n){const i=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+i]}const o=t+r;return[o-i,o]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+i]}const o=t+r;return[o-i,o]}function dc(e,t){let n=0;for(let i=0;t.length>i;i++)for(let r=i+1;t.length>r;r++){const o=t[i],s=t[r];o.source!==s.source&&o.target!==s.target&&o.source!==s.target&&o.target!==s.source&&(Math.min(o.endTime,s.endTime)>Math.max(o.startTime,s.startTime)&&e[s.source]>e[o.source]!=e[s.target]>e[o.target]&&n++)}return n}function hc(e,t){let n=0;for(const i of t)n+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return n}function fc(e,t){return 1e3*dc(e,t)+hc(e,t)}function pc(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function yc(e,t,n){e.length>8||n.length>40?(function(e,t,n,i=6){const r=e.length;if(1>=r)return;let o=pc(e,t),s=fc(t,n);for(let a=0;i>a;a++){const i=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];i[n]+=r*(e.value||1),a[n]+=e.value||1,i[r]+=n*(e.value||1),a[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),u=new Map;c.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t);const d=fc(t,n);if(s>d)s=d,o=pc(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,o)}(e,t,n,6),function(e,t,n,i=6){const r=e.length;if(1>=r)return;let o=fc(t,n);for(let s=0;i>s;s++){let i=!1;for(let s=0;r-1>s;s++){const r=e[s];e[s]=e[s+1],e[s+1]=r;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=fc(t,n);if(o>a)o=a,i=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!i)break}}(e,t,n,6)):function(e,t,n){const i=e.length;if(1>=i)return;const r={...t},o=Object.keys(r),s=Array.from({length:i},(e,t)=>t),a=s.slice(),c={...r};let l=s.slice(),u=1/0;const d=()=>{for(const e of o)c[e]=a[r[e]];const e=fc(c,n);u>e&&(u=e,l=s.slice())},h=(e,t)=>{const n=s[e],i=s[t];s[e]=i,s[t]=n,a[n]=t,a[i]=e};d();const f=Array(i).fill(0);let p=0;for(;i>p;)p>f[p]?(h(p%2==0?0:f[p],p),d(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(t=>e[t]),g=new Map;l.forEach((e,t)=>g.set(e,t));for(const e of Object.keys(t))t[e]=g.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function gc(e,t,n,i,r){const{plotH:o,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,o=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of i.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>o&&(o=t)}for(const e of i.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>o&&(o=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>o&&(o=e.systemOutTime)}p[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(o)?o:null}}const y={},g=[];if("reuse"===c){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(r.get(e.target)??0)+1);const o=[];for(const t of e)0===(r.get(t.id)??0)&&o.push(t.id);for(;o.length;){const e=o.shift();for(const t of i.outgoing[e]??[]){const i=(n.get(e)??0)+1;i>(n.get(t.target)??0)&&n.set(t.target,i),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&o.push(t.target)}}const s=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=n.get(e.id)??0,r=n.get(t.id)??0;return i!==r?i-r:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...s,...a]){const t=p[e.id];let n=-1;for(let e=0;g.length>e;e++){const i=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){n=e;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:e.id,end:t?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,d[e.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{g.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,x=null,b=null,v=null;const w=()=>{m=dc(y,t),b=hc(y,t)},k=()=>{x=dc(y,t),v=hc(y,t)};"crossing-min"===l?(w(),yc(g,y,t),k()):"inside-out"===l?(w(),function(e,t){const n=e.length;if(1>=n)return;const i=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),o=Array(n),s=Math.floor((n-1)/2);o[s]=r[0].idx;let a=s-1,c=s+1;for(let e=1;r.length>e;e++)e%2==1&&n>c||0>a?o[c++]=r[e].idx:o[a--]=r[e].idx;const l=o.map(t=>e[t]),u=new Map;o.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),yc(g,y,t),function(e,t,n){const i=e.length;if(1>=i)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),o=Math.floor((i-1)/2);let s=fc(t,n);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const c=o;if(r===c)continue;const l=e[r];e.splice(r,1),e.splice(c,0,l);const u=new Map;for(let e=0;i>e;e++)u.set(e,e);if(c>r){for(let e=r+1;c>=e;e++)u.set(e,e-1);u.set(r,c)}else{for(let e=c;r>e;e++)u.set(e,e+1);u.set(r,c)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=fc(t,n);if(d>s){const n=e[c];e.splice(c,1),e.splice(r,0,n);const o=new Map;for(let e=0;i>e;e++)o.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)o.set(e,e-1);o.set(c,r)}else{for(let e=r;c>e;e++)o.set(e,e+1);o.set(c,r)}for(const e of Object.keys(t))t[e]=o.get(t[e])}else s=d}}(g,y,t),k());const S=g.map(e=>{const t=new Map;for(const i of e.occupants){const e=n[i.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[i,r]of e){if(i>t)break;n=r}return n},M=[];for(let e=0;g.length-1>e;e++){const t=S[e],n=S[e+1],i=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of i){const i=A(t,e),o=A(n,e);i.bot+o.top>r&&(r=i.bot+o.top)}M.push(r)}const P=[];let _=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&P.push(_);for(let e=1;g.length>e;e++)_+=M[e-1]*a+s,P.push(_);if(g.length>0&&(_+=g[g.length-1].peak.botPeak*a+s),_>o){const e=o/_;for(let t=0;P.length>t;t++)P[t]*=e}const j=0===g.length?0:g[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,C={};for(const t of e)C[t.id]=P[y[t.id]];return{effectiveSlotsHeight:j,centerlines:C,laneLifetime:p,slots:g,slotByNode:y,slotCenter:P,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function mc(e){const{sx:t,sTop:n,sBot:i,tx:r,tTop:o,tBot:s,cp1X:a,cp2X:c}=e,l=(n+i)/2,u=(o+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${o} ${r},${o}`,`L${r},${s}`,`C${c},${s} ${a},${i} ${t},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(i-n)/2}}}function xc(e){const{nodes:t,edges:n,domain:i,plotW:r,plotH:o,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,u=function(e,t,n){const i=[],r=new Set(e.map(e=>e.id)),o=Array.isArray(n)&&2===n.length,s=o&&Number.isFinite(n[0])&&Number.isFinite(n[1]);o&&s&&s&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,n,i),d=(0,oc.scaleTime)().domain(i).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(e,t,n){const{plotH:i,pairing:r="temporal",packing:o="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,c=function(e,t){const n={},i={};for(const t of e)n[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:i}}(e,t),l=function(e,t,n,i="value"){const r="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,o="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const i of e){const e=i[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(i),r.total+=i.value,r.earliestStart=Math.min(r.earliestStart,i.startTime),r.latestEnd=Math.max(r.latestEnd,i.endTime)}const s=[...n.values()];s.sort("temporal"===i?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?o:r);return s};for(const t of e){const e=n.outgoing[t.id],i=n.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(i,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(i,"source"),n=a(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=i;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=i}}}return s}(e,t,c,r);let u={};for(const t of e)u[t.id]=ac(t,c,l);const d=gc(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:o,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const i=l.get(e.id);t!==n?t>n?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(h.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(n.map(e=>l.get(e.id).targetSide));if(1===i.size&&n.length>0){const e=[...i][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===l.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=i(),o="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=o||0>=s)return!1;const a=Math.min(o,s),c=n.filter(t=>!h.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let o=n.length+1;for(;o-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=ac(t,c,l);const f=gc(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:o,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(i-y*(f.slots.length+1))/p):1,m=gc(e,t,u,c,{plotH:i,padding:y,valueScale:g,packing:o,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,n,{plotH:o,...l}),{centerlines:f,nodeData:p,valueScale:y}=h,g=[],m=[];t.forEach((e,t)=>{const r=p[e.id];if(!r||0===r.samples.length)return;const o=function(e,t,n,i,r){if(0===e.length)return null;const o=lc(e,r),s=e=>t-o[e].topMass*n,a=e=>t+o[e].botMass*n;let c=`M${i(o[0].t)},${s(0)}`;for(let e=1;o.length>e;e++)c+=` L${i(o[e].t)},${s(e)}`;c+=` L${i(o[o.length-1].t)},${a(o.length-1)}`;for(let e=o.length-2;e>=0;e--)c+=` L${i(o[e].t)},${a(e)}`;return c+" Z"}(r.samples,f[e.id],y,d,i);if(!o)return;const s=lc(r.samples,i),a=s.find(e=>e.topMass+e.botMass>0)||s[0],l=f[e.id]+(a.botMass-a.topMass)*y/2,u=c(e.id,t),m=function(e,t,n,i,r){const o=n.nodeData[e];if(!o||0===o.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],c=lc(o.samples,r),l=c.find(e=>e.topMass+e.botMass>0)||c[0],u=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=i(l.t),h=i(u.t),f=e=>i(cc(e,r)),p=[],y=(e,t,n,i)=>`M${e},${t} L${n},${t} L${n},${i} L${e},${i} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=o.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),i=f(n.startTime),r=t-20,o=Math.max(d,r);if(i>o){const[n,c]=uc(e,a,s);p.push({pathD:y(o,n,i,c),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=o.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),i=f(n.endTime),r=t+20,o=Math.min(h,r);if(o>i){const[n,c]=uc(e,a,s);p.push({pathD:y(i,n,o,c),x0:t,x1:r,from:1,to:0})}}}}return p}(e.id,n,h,d,i);g.push({id:e.id,pathD:o,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:d(a.t)-4,labelY:l,labelText:e.id})});const x=new Map;return t.forEach((e,t)=>x.set(e.id,t)),n.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),n=p[e.target]?.localAttachments.get(e.id);if(!t||!n)return;const r=x.get(e.source)??0,o=c(e.source,r),l=function(e,t,n,i,r,o,s,a){const c=r,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=o(l(e.time)),d=o(l(n.time)),h=e.value*c,f=n.value*c,p=e.sideMassBefore*c,y=n.sideMassAfter*c;let g,m,x,b;"top"===e.side?(g=t-p,m=g+h):(m=t+p,g=m-h),"top"===n.side?(x=i-y,b=x+f):(b=i+y,x=b-f);const v="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,f[e.source],n,f[e.target],y,d,s,i),{pathD:u,bezier:h}=mc(l);m.push({id:e.id,pathD:u,fill:o,opacity:a,rawDatum:e.__raw??e,bezier:h})}),{layout:h,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:d}}var bc=e=>{const{bands:t=[],ribbons:n=[],showLabels:i=!0}=e.config,r=[];for(const e of n)r.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];r.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)r.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const o=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:r,labels:o}},vc={frameType:"network",buildProps:(e,t,n,i,r)=>{const{edgeWidth:o,edgeColor:s,edgeOpacity:a}=r;return{chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:t,colorScheme:n,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle??(void 0!==o||void 0!==s||void 0!==a?e=>{const t=e?.data||e;let n=1;if("number"==typeof o)n=o;else if("function"==typeof o)n=o(t);else if("string"==typeof o){const e=t?.[o],i="number"==typeof e?e:Number(e);n=Number.isFinite(i)&&i>0?i:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),...i}}},wc={frameType:"network",buildProps:(e,t,n,i,r)=>{const o=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",d=r.endTimeAccessor||"endTime",h=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",y=r.edgeIdAccessor||"id",g=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(r.edges)?r.edges:[],x=Array.isArray(r.nodes)?r.nodes:[],b=x.length>0?x:function(e,t,n,i){const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],o="function"==typeof i?i(e):e[i];r.add(t),r.add(o)}),Array.from(r).map(e=>({id:e}))}(0,m,s,a),v=[o(r.domain?.[0]),o(r.domain?.[1])],w=b.map(e=>{const t=g(l,e)+"",n=g(p,e),i={id:t,__raw:e};if(Array.isArray(n)&&2===n.length){const e=o(n[0]),t=o(n[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),k=m.map((e,t)=>{const n=g(y,e),i={id:null!=n?n+"":`${g(s,e)}-${g(a,e)}-${t}`,source:g(s,e)+"",target:g(a,e)+"",value:Number(g(c,e)),startTime:o(g(u,e)),endTime:o(g(d,e)),__raw:e};if(h){const t=o(g(h,e));Number.isFinite(t)&&(i.systemInTime=t)}if(f){const t=o(g(f,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[S,A]=i.size??[600,400],M={top:20,right:20,bottom:20,left:20,...i.margin},P=i.legendPosition??"right";i.showLegend&&("right"===P?M.right=Math.max(M.right,100):"left"===P?M.left=Math.max(M.left,100):"bottom"===P?M.bottom=Math.max(M.bottom,70):"top"===P&&(M.top=Math.max(M.top,40)));const _=M,j=S-_.left-_.right,C=A-_.top-_.bottom,I=Array.isArray(n)?n:null,T=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],R="function"==typeof t?t:null,L=R?b.map(e=>({_cat:R(e)})):b,E=R?"_cat":"string"==typeof t?t:void 0,D=E?z(L,E,n):null,B=new Map;for(const e of w)B.set(e.id,e.__raw);const{layoutConfig:F,issues:N}=xc({nodes:w,edges:k,domain:v,plotW:j,plotH:C,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:(e,n)=>{if(t&&B.has(e)){const n=B.get(e);return R?$({_cat:R(n)},"_cat",D??void 0):$(n,t,D??void 0)}const i=I||T;return i[n%i.length]},layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(N.length>0){const e=N.map(sc).join("; ");throw Error("ProcessSankey: data invalid — "+e)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:bc,layoutConfig:F,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:n,...i,margin:_}}},kc={frameType:"geo",buildProps:(e,t,n,i,r)=>{const o=(Array.isArray(e)?e:null)||r.flows||[],s=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(r.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(const e of h)f.set(e[s]+"",e);const p=r.edgeColorBy??t,y="function"==typeof p,g=o.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=f.get(e.source+""),n=f.get(e.target+"");return t&&n?{...e,coordinates:[{x:t.x,y:t.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?z(g.map(e=>({[m]:p(e)})),m,n||"category10"):z(g,p,n||"category10"):null,b=e=>p&&x?$(e,p,x):"#007bff";let v=1/0,w=-1/0;for(const e of g){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>w&&(w=t))}const k=w>v?w-v:0,[S,A]=r.edgeWidthRange??[1,8],M=A-S,P=r.edgeOpacity??.6,_=r.edgeLinecap??"round";return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:n,lineStyle:e=>{const t=Number(e?.[a]),n=Number.isFinite(t)?t:v,i=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(e),strokeWidth:i,strokeLinecap:_,opacity:P,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}};function Sc(e){const[t,n]=e;return{width:t,height:n,plot:{x:32,y:24,width:Math.max(80,t-64),height:Math.max(80,n-58)}}}function Ac(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let i=0;for(let e=0;t.length>e;e+=1)i=31*i+t.charCodeAt(e)>>>0;return n[i%n.length]}function Mc(e,t="#4e79a7"){return n=>{const i=n.datum,r=i&&e?"function"==typeof e?e(i,0):i[e]:void 0;return{fill:null==r?t:Ac(r),stroke:"#111827",strokeWidth:1,opacity:.9}}}function Pc(e,t,n,i){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:n},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...i}}}function _c(e,t,n){return"function"==typeof n?n(e,t):e[n]}function jc(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Cc(e,t,n){return Math.max(t,Math.min(n,e))}function Ic(e,t){const n=jc(e);return null!=n&&n>0?n:t}function Tc(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Rc(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var Lc=require("d3-scale");function $c(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var Ec={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},zc=1e-9,Dc=.005;function Bc(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Fc(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Nc(e,t,n){return Math.max(t,Math.min(n,e))}function Oc(e){return 0>e?-1:1}function Wc(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,n=e.shape.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}function qc(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,n=t.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}const n=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-n,minY:Math.min(t.y1,t.y2)-n,maxX:Math.max(t.x1,t.x2)+n,maxY:Math.max(t.y1,t.y2)+n}}function Yc(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Hc(e,t,n,i,r,o,s,a){const c=r-e,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=o-t,d=(i+a)/2-Math.abs(u);return d>0?d>l?{nx:Oc(c),ny:0,penetration:l}:{nx:0,ny:Oc(u),penetration:d}:null}function Gc(e,t,n,i,r,o,s){const a=o/2,c=s/2;let l=e-Nc(e,i-a,i+a),u=t-Nc(t,r-c,r+c);const d=l*l+u*u;if(d>n*n)return null;if(zc>=d){const o=Math.abs(e-(i-a)),s=Math.abs(e-(i+a)),d=Math.abs(t-(r-c)),h=Math.abs(t-(r+c)),f=Math.min(o,s,d,h);return f===o?(l=-1,u=0,{nx:l,ny:u,penetration:n+o}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:n+s}):f===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function Xc(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,i,r,o){const s=i-e,a=r-t,c=n+o,l=s*s+a*a;if(l>=c*c)return null;if(zc>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Hc(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const n=Gc(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Gc(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Vc(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?Gc(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):Hc(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,i,r,o,s,a=0){const c=o-i,l=s-r,u=c*c+l*l,d=u>zc?Nc(((e-i)*c+(t-r)*l)/u,0,1):0,h=n+a/2,f=e-(i+c*d),p=t-(r+l*d),y=f*f+p*p;if(y>=h*h)return null;if(zc>=y){const e=Math.sqrt(u);return e>zc?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function Uc(e,t){return`${e}\0${t}`}function Kc(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Zc(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,shape:Bc(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Qc(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Jc(e){return{id:e.id,shape:Fc(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Qc(e.bodyFilter),index:e.index}}function el(e,t){return!!t?.some(t=>Object.is(e,t))}function tl(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const i=function(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(t,n.property);return!("equals"in n&&!Object.is(i,n.equals)||"notEquals"in n&&Object.is(i,n.notEquals)||n.oneOf&&!el(i,n.oneOf)||n.notOneOf&&el(i,n.notOneOf))}var nl=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...Ec,...e},this.random=$c(this.options.seed)}init(e={}){this.options={...Ec,...e},this.random=$c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(zc,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:Bc(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Kc(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:Fc(t.shape),bodyFilter:Qc(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,n){const i=this.bodies.get(e);i&&(i.vx+=t/i.mass,i.vy+=n/i.mass,this.wake(i))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const n=this.sortedBodies();for(const e of n)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const i=this.options.maxVelocity;for(const e of n)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,i>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>i){const n=i/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const r=this.bodyPairKeys(n),o=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,r,0===e),this.resolveColliders(n,o,0===e);this.updateSensors(n),this.updateSleeping(n,t)}settle(e=1200,t=this.options.fixedDt){let n=0;for(;e>n&&!this.allSleeping();)this.step(t),n+=1;return n}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:Bc(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Kc)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Zc),colliders:this.sortedColliders().map(Jc),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=$c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Zc(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Jc(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const n=this.bodies.get(t.bodyId);if(!n||n.sleeping)continue;const i="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!i)continue;const r=i.x-n.x,o=i.y-n.y,s=Math.sqrt(r*r+o*o);if(zc>=s)continue;const a=r/s,c=o/s,l=(s-t.restLength)*t.stiffness+((("vx"in i?i.vx:0)-n.vx)*a+(("vy"in i?i.vy:0)-n.vy)*c)*t.damping;n.vx+=l*a*e/n.mass,n.vy+=l*c*e/n.mass}}resolveBodyPairs(e,t,n){for(const i of t){const[t,r]=i.split(":").map(Number),o=e[t],s=e[r];if(!o||!s)continue;const a=Xc(o,s);a&&(this.resolveDynamicCollision(o,s,a),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),n=new Map;for(let i=0;e.length>i;i+=1){if(!1===e[i].bodyCollisions)continue;const r=Wc(e[i]),o=Math.floor(r.minX/t),s=Math.floor(r.maxX/t),a=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=o;s>=e;e+=1)for(let t=a;c>=t;t+=1){const r=`${e}:${t}`,o=n.get(r);o?o.push(i):n.set(r,[i])}}const i=new Set;for(const t of Array.from(n.keys()).sort()){const r=n.get(t)??[];r.sort((e,t)=>e-t);for(let t=0;r.length>t;t+=1)for(let n=t+1;r.length>n;n+=1){const o=r[t],s=r[n];!1!==e[o].bodyCollisions&&!1!==e[s].bodyCollisions&&Yc(Wc(e[o]),Wc(e[s]))&&i.add(`${o}:${s}`)}}return Array.from(i).sort((e,t)=>{const[n,i]=e.split(":").map(Number),[r,o]=t.split(":").map(Number);return n===r?i-o:n-r})}resolveDynamicCollision(e,t,n){e.sleeping&&this.supportedThisStep.add(t.id),t.sleeping&&this.supportedThisStep.add(e.id);const i=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,o=i+r;if(zc>=o)return;const s=Math.max(0,n.penetration-Dc)/o;e.x-=n.nx*s*i,e.y-=n.ny*s*i,t.x+=n.nx*s*r,t.y+=n.ny*s*r;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*a/o,u=l*n.nx,d=l*n.ny;e.vx-=u*i,e.vy-=d*i,t.vx+=u*r,t.vy+=d*r,this.applyFriction(e,t,n,l,i,r),c>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,i,r,o){const s=-n.ny,a=n.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=r+o;if(zc>=Math.abs(c)||zc>=l)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=Nc(-c/l,-i*u,i*u),h=d*s,f=d*a;e.vx-=h*r,e.vy-=f*r,t.vx+=h*o,t.vy+=f*o}resolveColliders(e,t,n){for(const i of e)for(const e of t){if(!tl(e,i))continue;if(!Yc(Wc(i),qc(e)))continue;const t=Vc(i,e);t&&(this.resolveStaticCollision(i,e,t),this.supportedThisStep.add(i.id),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-Dc),e.y+=n.ny*Math.max(0,n.penetration-Dc);const i=e.vx*n.nx+e.vy*n.ny;if(0>i){const r=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+r)*i*n.nx,e.vy-=(1+r)*i*n.ny;const o=-n.ny,s=n.nx,a=e.vx*o+e.vy*s,c=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=a*o*c,e.vy-=a*s*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const i of e){const e=Wc(i);for(const r of n){if(!tl(r,i))continue;if(!Yc(e,qc(r)))continue;if(!Vc(i,r))continue;const n=Uc(r.id,i.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:r.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:i}=Kc(e);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of e)Math.sqrt(i.vx*i.vx+i.vy*i.vy)>=this.options.sleepSpeed||Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=t,i.sleeping||this.options.sleepAfter>i.sleepTime||(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},il=class{constructor(e={}){this.id="builtin",this.capabilities={...(new nl).capabilities,engine:"builtin"},this.world=new nl(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function rl(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new il(e)}(t)}var ol=["binId","targetBin","category","windowIndex","lane","group"];function sl(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const n=t-e.mean;e.mean+=n/e.count,e.m2+=n*(t-e.mean)}function al(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function cl(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function ll(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function ul(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?ll(t,e):void 0}function dl(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function hl(e){const t=al(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:al(e.x),y:al(e.y),value:t}}var fl=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const n=dl(ul(this.config.binAccessor,e,t))??function(e){for(const t of ol){const n=dl(ll(e,t));if(n)return n}return"sediment"}(e),i=dl(ul(this.config.labelAccessor,e,t))??n,r=function(e,t,n){if("number"==typeof e)return e;const i="function"==typeof e?e(t,n):"string"==typeof e?ll(t,e):1,r="number"==typeof i?i:Number(i);return Number.isFinite(r)?r:1}(this.config.valueAccessor,e,t),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:i,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(n,s)),s.label=i,s.lastBodyId=e.id,s.lastDatum=e.datum,sl(s.x,e.x),sl(s.y,e.y),sl(s.value,r),o>0&&(s.bodyIds.push(e.id),s.bodyIds.length>o&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-o))),hl(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(hl)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:cl(t.x),y:cl(t.y),value:cl(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function pl(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var yl={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},gl={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function ml(e={},t=gl){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function xl(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function bl(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function vl(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function wl(e){return{...xl(e),sequence:e.sequence,spawnAt:e.spawnAt}}function kl(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function Sl(e){return!1!==e&&{...e}}function Al(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Ml(e){return{...e,gravity:{...e.gravity}}}function Pl(e,t,n,i){if("circle"===e.shape.type){const r=e.x-t,o=e.y-n,s=e.shape.radius+i,a=r*r+o*o;return a>s*s?null:a}const r=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),o=Math.max(Math.abs(n-e.y)-e.shape.height/2,0),s=r*r+o*o;return s>i*i?null:s}function _l(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function jl(e,t={}){const{idPrefix:n="plot",includeFloor:i=!0,includeCeiling:r=!1,includeLeftWall:o=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return i&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),o&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function Cl(e){const{idPrefix:t="bin",count:n,domainStart:i,domainStep:r,xScale:o,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?n:n-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=o(i+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=i+e*r,s=n+r;if(s>=d)continue;const a=o(n),l=o(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}var Il=require("d3-quadtree"),Tl=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,i,r,o=0){const s=this.ensure(e,t);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,o)+this.maxSearchRadius,u=i-l,d=i+l,h=r-l,f=r+l;return s.visit((e,t,s,l,p)=>{if(u>l||t>d||h>p||s>f)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=Pl(e,i,r,Math.max(0,o));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,c=t)}y=y.next}return!1}),a}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const n=e.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=n.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=(0,Il.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},Rl=["data","scene-geometry","data-paint","accessibility","evidence"],Ll=["scene-geometry","data-paint","accessibility","evidence"],$l=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],El=["overlay","accessibility","evidence"],zl=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function Dl(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&zl.every(n=>e[n]===t[n])}function Bl(e,t,n,i){return e||!t?"paused":n||!i?"running":"settled"}var Fl=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Tl,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Lt,this.simulationState="settled",this.visible=!0;const{bodyBudget:t,colliders:n,engine:i,kernel:r,observation:o,sediment:s,...a}=e;this.config={...yl,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=i,this.observation=ml(o),this.sediment=new fl(s??!1),this.world=rl(i,{fixedDt:this.config.fixedDt,...r}),n&&this.world.setColliders(kl(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!Dl(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:i,engine:r,kernel:o,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=rl(r,e.options),this.world.restore(e),this.revision+=1}if(o&&!Dl(o,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...o,gravity:{...e.options.gravity,...o.gravity}};this.world.restore({...e,options:t}),this.revision+=1}s&&(this.observation=ml(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(kl(n)),this.revision+=1),this.configInput={...this.configInput,...e},this.updateResults.record({kind:"config",keys:t},t.length?$l:[])}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(kl(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},$l)}enqueue(e,t){const n=Array.isArray(e)?e:[e],i=t?function(e,t={}){const n=bl(t.startAt)??0,i=t.pacing??"immediate";if("arrival"===i){const i=e.map((e,n)=>function(e,t,n){return"function"==typeof n?bl(n(e,t)):"string"==typeof n?bl(vl(e,n)):bl(e.spawnAt)??bl(vl(e,"arrivalTime"))??bl(vl(e,"timestamp"))??bl(vl(e,"time"))??bl(vl(e,"eventTime"))}(e,n,t.timeAccessor)),r=i.filter(e=>null!=e),o=r.length>0?Math.min(...r):0,s=bl(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const r=i[t],s=null==r?0:Math.max(0,r-o);return{...xl(e),spawnAt:n+s/a}})}if("object"==typeof i){const t=bl(i.ratePerSec);if(t&&t>0)return e.map((e,i)=>({...xl(e),spawnAt:n+i/t}))}return e.map(e=>({...xl(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of i)this.queue.push({...xl(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Al),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?Rl:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(xl(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},Rl)}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},Rl)}tick(e){const t=this.revision,n=[],i=[],r=[],o=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,i,r,o,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const a=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);i.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const e=this.world.events();o.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||n.length>0||i.length>0||r.length>0||o.length>0)&&(this.revision+=1);const d=this.result(u,n,i,r,o,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||i.length||r.length?Rl:Ll:[]),d}settle(e=this.config.settleStepLimit){const t=this.revision;this.spawnDue([],[]);const n=this.world.settle(e,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==t?Ll:[]),n}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,n=[],i=[],r=[],o=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,i,r,o,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);i.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(;e>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const e=this.world.events();o.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),l+=1}(l>0||n.length>0||i.length>0||r.length>0||o.length>0)&&(this.revision+=1);const u=this.result(l,n,i,r,o,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==t?n.length||i.length||r.length?Rl:Ll:[]),u}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:n=0,binWidth:i=24,gap:r=2,maxHeight:o=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*o),u=a?.(e,t)??t*(i+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:i,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:n,chartId:i,...r}=e,o={...r,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?El:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?El:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),i=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const r=e.filter(e=>n.has(e)||i.has(e));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?Rl:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Ll),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Ll)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Ll)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,i)=>e.applyImpulse(t,n,i),clear:()=>e.clear(),hitTest:(t,n,i)=>e.hitTest(t,n,i),pause:()=>e.setPaused(!0),push:(t,n)=>e.enqueue(t,n),pushMany:(t,n)=>e.enqueue(t,n),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Sl(this.bodyBudget),config:{...this.config,kernel:Ml(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(wl),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:Sl(e.bodyBudget??{}),kernel:Ml(e.world.options)},this.bodyBudget=Sl(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(wl).sort(Al),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Bl(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},$l)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,t),e.push(n.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const n=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:n?.datum??e.datum,x:n?.x??e.x,y:n?.y??e.y},t)}result(e,t,n,i,r,o,s,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:i,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const i=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=i.get(e.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,n){const i=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===i.size&&0===t.size)return i;const r=new Map(e.readState().map(e=>[e.id,e])),o=(e,t)=>{const{sensorId:i,bodyId:o}=_l(t),s=n.observation.sensors[i],a=r.get(o);n.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:s?.binId??i})};for(const e of Array.from(i).sort())t.has(e)||o("enter",e);for(const e of Array.from(t).sort())i.has(e)||o("exit",e);return i}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(_l(n).bodyId)&&e.delete(n)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return function(e){const t=Math.max(0,Math.floor(e.liveBodies)),n=Math.max(0,Math.floor(e.queuedBodies??0)),i=t+n,r=pl(e.bodyLimit),o=pl(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const i=pl(n?.warnAt);return null!=i?i:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(r,o,e.options),a=null==r?0:Math.max(0,t-r),c=a>0?"overflow":null==s||s>i?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:o,liveBodies:t,overflow:a,projectedBodies:i,queuedBodies:n,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const n=`${t.state}:${t.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,this.emitObservation({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:t.action,bodyLimit:t.bodyLimit,engineMaxBodiesHint:t.engineMaxBodiesHint,liveBodies:t.liveBodies,overflow:t.overflow,projectedBodies:t.projectedBodies,queuedBodies:t.queuedBodies,warnAt:t.warnAt},e)),t}syncSimulationState(e){const t=Bl(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(t===this.simulationState)return;const n=this.simulationState;this.simulationState=t,function(e,t,n){n.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||n.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:t,previousSimulationState:e})}(n,t,this.observationContext(e))}evictOverflow(e){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const t=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(t))return{evicted:[],sedimented:[]};const n=this.liveBodyOrder.length-t;if(0>=n)return{evicted:[],sedimented:[]};const i=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,n);if(0===i.length)return{evicted:[],sedimented:[]};const r=this.absorbSediment(i,e);this.world.remove(i);const o=new Set(i);return this.liveBodyOrder=this.liveBodyOrder.filter(e=>!o.has(e)),this.removeActiveSensorPairsForBodies(o),{evicted:i,sedimented:r}}absorbSediment(e,t){const n=new Map(this.world.readState().map(e=>[e.id,e])),i=[];for(const r of e){const e=n.get(r);if(!e)continue;const o=this.sediment.add(e);o&&(i.push(r),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:r,datum:e.datum,x:e.x,y:e.y,binId:o.id,count:o.count,total:o.total},t))}return i}sleepingFirstEvictionOrder(){const e=new Map(this.world.readState().map(e=>[e.id,e.sleeping])),t=[],n=[];for(const i of this.liveBodyOrder)e.get(i)?t.push(i):n.push(i);return[...t,...n]}};var Nl=require("d3-scale");function Ol(e){const{count:t,idPrefix:n,wallThickness:i,xScale:r,yBottom:o,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(o-1,a?.(t)??s),l=Math.max(1,o-c);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:r(t),y:c+l/2,width:i,height:l}}})}var Wl=require("d3-scale");function ql(e){if(Array.isArray(e)&&e.length>=2){const t=jc(e[0]),n=jc(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=jc(t.x),i=jc(t.y);return null!=n&&null!=i?{x:n,y:i}:null}return null}function Yl(e){return Array.isArray(e)?e.map(ql).filter(e=>null!=e):[]}function Hl(e,t,n){return"normalized"===n?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:Cc(e.x,t.plot.x,t.plot.x+t.plot.width),y:Cc(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Gl(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Xl(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=Cc(t,0,1)*Gl(e);let i=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],o=e[t],s=Math.hypot(o.x-r.x,o.y-r.y);if(s>0){if(i+s>=n){const e=(n-i)/s;return{x:r.x+(o.x-r.x)*e,y:r.y+(o.y-r.y)*e}}i+=s}}return{...e[e.length-1]}}function Vl(e,t){const n=Xl(e,Math.max(0,t-.02)),i=Xl(e,Math.min(1,t+.02)),r=i.x-n.x,o=i.y-n.y,s=Math.hypot(r,o)||1;return{x:r/s,y:o/s}}function Ul(e,t,n){return Math.max(t,Math.min(n,e))}function Kl(e,t,n,i,r,o={}){return{id:e,friction:o.friction,restitution:o.restitution,bodyFilter:o.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:i,y2:r,thickness:o.thickness??8}}}function Zl(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,i=e.width,r=e.height,{type:"aabb",x:t,y:n,width:i,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,i,r}function Ql(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Jl(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function eu(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,i=Sc(n),r=Cc(e.ballRadius??6,2,18),o=e.seed??1,s=Rc(o),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(l?"allAbsorbed":"none"),p=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=function(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height)),r=e.padX??46,o=e.padY??72,s=r,a=n-r,c=o,l=i-Math.max(24,Math.round(.45*o)),u=(c+l)/2,d=Math.max(1,l-c),h=Ul(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Ul(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,S=e.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Ul(e.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(S),P=a-s;let _=s;const j=S.map((e,t)=>{const n=_,i=t===S.length-1?a:_+(e.share??1)/M*P;return _=i,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:i,x:(n+i)/2,width:i-n,y:u,height:d}}),C=j[A],I=C.x0,T=C.x1,R=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Ul((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(I>=e){const t=Ul((e-s)/Math.max(1,I-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(T>=e)return"top"===n?m:x;const i=Ul((e-T)/Math.max(1,a-T),0,1);return"top"===n?m+(c-m)*i:x+(l-x)*i},L=j.map(e=>{const t=Math.min(R(e.x0,"top"),R(e.x1,"top")),n=Math.max(R(e.x0,"bottom"),R(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),$={thickness:k,friction:v,restitution:w},E=[];"lane"===t?E.push(Kl(b+"-top",s,c,a,c,$),Kl(b+"-bottom",s,l,a,l,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)})):"funnel"===t?E.push(Kl(b+"-top",s,c,a,m,$),Kl(b+"-bottom",s,l,a,x,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,m,a,x,{...$,thickness:Math.max(6,k)})):E.push(Kl(b+"-left-top",s,c,I,m,$),Kl(b+"-left-bottom",s,l,I,x,$),Kl(b+"-center-top",I,m,T,m,$),Kl(b+"-center-bottom",I,x,T,x,$),Kl(b+"-right-top",T,m,a,c,$),Kl(b+"-right-bottom",T,x,a,l,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)}));const z=e.membraneDampingScale??.5,D=s,B=Math.max(1,("bowtie"===t?I:a)-D),F=(e.membranes??[]).map(e=>{const t=D+Ul(e.offset,0,1)*B,n=e.width??18+18*e.cost,i=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:i}}),N=!1===e.includeMembraneRegions?[]:F.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,i=Ul(e.cost,0,2);return{...Zl({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:i,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i*t,energyDelta:-i*n}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??z,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:i,padX:r,padY:o,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:I,centerRight:T,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:L,membranes:F,colliders:E,regionEffects:N,boundaryY:R}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,i.plot.x),padY:Math.max(36,i.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),A=t.map(e=>{const t=v.get(e.id)??k;return function(e,t){const n={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Zl({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}({...n,kind:e.kind??"sink",force:Jl(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return i={...n,kind:e.kind??"force-field",force:Jl(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...Zl({...i,kind:i.kind??"force-field",attributes:{primitive:"portal",targetStage:i.targetStage,..."object"==typeof i.attributes&&i.attributes?i.attributes:{}}}),force:i.force,impulseOnEnter:i.impulseOnEnter,damping:i.damping??.08}}var i;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}({...n,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Jl(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...n.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,i=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Zl({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*i,energyDelta:r?-t*r:void 0,force:e.force}}({...n,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:Jl(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Ql({...n,kind:e.kind??"force-field",force:Jl(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}({...n,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});A.unshift(Ql({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const e of x.stages)M.set(e.id,0);const P=[];e.data.forEach((e,t)=>{const n=(a?_c(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",i=(_c(e,t,c)??w)+"",o=b.has(i)?i:w;M.set(o,(M.get(o)??0)+1);const s=l?(_c(e,t,l)??"")+"":void 0,f=s&&u?(_c(e,t,u)??s)+"":s,p=d?jc(_c(e,t,d))??1:1,y=h?jc(_c(e,t,h)):null,g=Cc(null!=y&&y>0?y:r,2,18);P.push({datum:e,id:n,stageId:o,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});const _=new Map,j=new Map;for(const e of P){if(!e.groupId)continue;const t=_.get(e.groupId)??[];t.push(e.id),_.set(e.groupId,t),e.groupLabel&&j.set(e.groupId,e.groupLabel)}const C=Cc(e.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*C,T=Array.from(_.keys()),R=T.map((e,n)=>{const i=_.get(e)??[],r=T.length>1?x.topY+28+n/Math.max(1,T.length-1)*(x.bottomY-x.topY-56):x.midY;return function(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:j.get(e)??e,bodyIds:i,anchor:{x:I,y:r},x:I,y:r,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),L=function(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],i=t.filter(e=>!n.has(e)),r=t.length-i.length,o=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===o?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:o,complete:t.length>0&&("anyAbsorbed"===o?r>0:"threshold"===o?l>=(d??c):0===i.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:i}})}(R,P.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(R.map(e=>[e.id,e])),E=P.map((e,t)=>{const n=v.get(e.stageId)??k,i=n.x+(s()-.5)*Math.min(24,.2*n.width),r=x.boundaryY(i,"top")+e.radius+10,o=x.boundaryY(i,"bottom")-e.radius-10,a=o>r?r+s()*Math.max(1,o-r):x.midY,c=g?i:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:i,y:a},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){const t=$.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),z={kernel:{seed:o,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},D=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),B=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:z,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:D,metadata:{kind:"process-flow",plot:i.plot,volume:x,stages:B,groups:R,groupCompletion:L,regionEffects:A}}}var tu=require("react"),nu=require("d3-scale");function iu(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=I[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}function ru(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&E(n,e)||"#4e79a7":t=>{if(n){const e=E(n,t);if(e)return e}let i=0;for(let e=0;t.length>e;e++)i=31*i+t.charCodeAt(e)|0;return e[Math.abs(i)%e.length]??"#4e79a7"}}var ou=c(require("react")),su=require("react"),au={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},cu={names:["--semiotic-border","--surface-3"],fallback:"#334155"},lu={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},uu={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},du={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},hu={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},fu={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},pu={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},yu={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},gu={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function mu(e,t){const n=e.canvas;if("function"!=typeof getComputedStyle||!n)return t.fallback;const i=getComputedStyle(n);for(const n of t.names){const t=i.getPropertyValue(n).trim();if(t)return vn(e,t)??t}return t.fallback}function xu(e,t){const n=Math.max(0,Math.min(1,t)),i=e.trim(),r=i.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(r){const[,e,t,i]=r;return xu(`#${e}${e}${t}${t}${i}${i}`,n)}const o=i.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(o){const[,e,t,i]=o;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(i,16)}, ${n})`}const s=i.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(s)return`rgba(${s[1]}, ${n})`;const a=i.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return a?`rgba(${a[1]}, ${n})`:i}var bu=c(require("react")),vu=require("d3-scale"),wu=require("react/jsx-runtime");function ku(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function Su(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,title:s,legend:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:f,pointNodes:p=[],annotations:y,autoPlaceAnnotations:g,svgAnnotationRules:m,children:x}=e,b=bu.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(y),[y]),v=bu.useMemo(()=>function(e){const{width:t,height:n,pointNodes:i=[],data:r}=e;return{scales:{x:(0,vu.scaleLinear)().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:(0,vu.scaleLinear)().domain([0,Math.max(1,n)]).range([0,Math.max(1,n)])},width:t,height:n,frameType:"network",pointNodes:i,data:r,xAccessor:"x",yAccessor:"y"}}({width:t,height:n,pointNodes:p}),[n,p,t]),w=bu.useMemo(()=>b&&g?Mr({annotations:b,context:v,..."object"==typeof g?g:{}}):b,[v,g,b]),k=bu.useMemo(()=>Ji(),[]),S=w?Qi(w.filter(e=>"widget"!==e.type),k,m,v):null,A=!0===w?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,wu.jsxs)(wu.Fragment,{children:[A?(0,wu.jsx)("style",{children:qi},"physics-annotation-disclosure-style"):null,(0,wu.jsxs)("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,wu.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[S,x]}),s&&"string"==typeof s?(0,wu.jsx)("text",{x:i/2,y:16,textAnchor:"middle",fontWeight:600,fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,wu.jsx)("foreignObject",{x:0,y:0,width:i,height:Math.max(o.top,28),children:s}):null,a?ci({legend:a,totalWidth:i,totalHeight:r,margin:o,legendPosition:h,legendLayout:f,title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}function Au(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Mu(e,t){const n="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,Au(e.thickness)??Au(n)??Au(t.thickness)??4)}var Pu=2500;function _u(e){return"function"==typeof e}function ju(e){return void 0===e||!1===e||!_u(e.binAccessor)&&!_u(e.labelAccessor)&&!_u(e.valueAccessor)}function Cu(e){if(void 0!==e){if(!1===e)return!1;if(!ju(e))throw new TypeError("Physics worker sediment config only supports string or numeric accessors");return{binAccessor:"string"==typeof e.binAccessor?e.binAccessor:void 0,labelAccessor:"string"==typeof e.labelAccessor?e.labelAccessor:void 0,valueAccessor:"string"==typeof e.valueAccessor||"number"==typeof e.valueAccessor?e.valueAccessor:void 0,retainBodyIds:e.retainBodyIds}}}function Iu(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function Tu(e){return function(e){return!_u(e?.timeAccessor)}(e)}function Ru(e={}){if(e.engine)throw new TypeError("Physics workers use the built-in kernel adapter");const{engine:t,observation:n,sediment:i,...r}=e;return{...r,observation:Iu(n),sediment:Cu(i)}}var Lu={};function $u(){if("undefined"!=typeof DOMException)return new DOMException("Physics worker request aborted","AbortError");const e=Error("Physics worker request aborted");return e.name="AbortError",e}var Eu=class{constructor(e=function(){const e="string"==typeof Lu.url&&Lu.url?new URL("./physicsWorker.js",Lu.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("physicsWorker.js");return new Worker(e,{type:"module",name:"semiotic-physics"})}()){this.nextRequestId=1,this.pending=new Map,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=this.pending.get(t.requestId);n&&(this.pending.delete(t.requestId),n.cleanup(),t.ok?n.resolve(t.payload):n.reject(function(e){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),t}(t)))},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Physics worker failed")),this.worker.terminate()}}request(e,t){if(t?.aborted)return Promise.reject($u());const n=this.nextRequestId;this.nextRequestId+=1;const i={command:e,requestId:n};return new Promise((e,r)=>{const o=()=>{this.pending.delete(n),t?.removeEventListener("abort",o),r($u())},s=()=>t?.removeEventListener("abort",o);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",o,{once:!0});try{this.worker.postMessage(i)}catch(e){this.pending.delete(n),s(),r(e)}})}async init(e,t,n,i){if(!Tu(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"init",config:Ru(e),initialSpawns:t,initialSpawnPacing:n},i);if("frame"!==r.type)throw Error("Physics worker returned a non-frame init response");return r.frame}async restore(e,t){const n=await this.request({type:"restore",snapshot:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame restore response");return n.frame}async initFromSnapshot(e,t,n){const i=await this.request({type:"init",config:Ru(e),snapshot:t},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame init response");return i.frame}async enqueue(e,t,n){if(!Tu(t))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const i=await this.request({type:"enqueue",spawns:e,pacing:t},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame enqueue response");return i.frame}async tick(e,t){const n=await this.request({type:"tick",deltaSeconds:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame tick response");return n.frame}async settle(e,t){const n=await this.request({type:"settle",maxSteps:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame settle response");return n.frame}async snapshot(e){const t=await this.request({type:"snapshot"},e);if("snapshot"!==t.type)throw Error("Physics worker returned a non-snapshot response");return t.snapshot}async remove(e,t){const n=await this.request({type:"remove",ids:e},t);if("removed"!==n.type)throw Error("Physics worker returned a non-remove response");return{frame:n.frame,removed:n.removed}}terminate(){this.rejectAll(Error("Physics worker terminated")),this.worker.terminate()}rejectAll(e){for(const[t,n]of this.pending)this.pending.delete(t),n.cleanup(),n.reject(e)}},zu=c(require("react-dom/server"));function Du(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}var Bu={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function Fu(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Nu(e,t){const n="function"==typeof t?t(e):t;return{...Bu,...n??{}}}function Ou(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),i={label:t.getBodyLabel?.(e)??Fu(e)},r={style:Nu(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:i,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}(e,t))}var Wu=require("react/jsx-runtime");function qu(e,t={}){const{width:n=640,height:i=360,title:r,description:o,background:s,className:a,idPrefix:c="physics",...l}=t,u=function(e,t={}){const n=e.settle(t.maxSteps),i=e.readBodies(),r=e.snapshot(),o=Ou(i,t),s=function(e,t={}){const n=t.bodies??function(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}(e),i=n.filter(e=>e.sleeping).length;return{bodyCount:n.length,sleepingCount:i,settled:"settled"===e.simulationState&&0===e.queue.length&&i===n.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Du(t.projectionRows)}}(r,{bodies:i,projectionRows:t.projectionRows,stepsRun:n});return{snapshot:r,bodies:i,sceneNodes:o,evidence:s,stepsRun:n}}(e,l),d=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(c),h=r?d+"-title":void 0,f=o?d+"-desc":void 0,p=[h,f].filter(Boolean).join(" ")||void 0;return{svg:zu.renderToStaticMarkup((0,Wu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:n,height:i,viewBox:`0 0 ${n} ${i}`,role:"img","aria-labelledby":p,children:[r&&(0,Wu.jsx)("title",{id:h,children:r}),o&&(0,Wu.jsx)("desc",{id:f,children:o}),s&&"transparent"!==s?(0,Wu.jsx)("rect",{x:0,y:0,width:n,height:i,fill:s}):null,(0,Wu.jsx)("g",{id:d+"-data-area",children:u.sceneNodes.map((e,t)=>so(e,t,d))})]})),scene:u,evidence:u.evidence}}function Yu(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const i=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(i)&&i>0?i:1}function Hu(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=Xu(e.datum,t),i=Xu(e,t),r=n??i;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Gu(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),i=Math.floor(n);return e[i]+(e[Math.ceil(n)]-e[i])*(n-i)}function Xu(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function Vu(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=Xu(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function Uu(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),i=e.queueLayout??"lane",r=e.queueSlotSpacing??14,o=e.queueStiffness??.35,s=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,a=Math.max(.25,e.metricWindowSeconds??30),c=Math.max(1/60,e.snapshotIntervalSeconds??.25),l=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,p=new Map,y=new Map,g=new Map,m=[];let x=0,b=new Map,v=new Map,w=0,k=0,S=0,A=null,M=0,P=0,_=0,j=0,C=0,I=0,T=0,R=0,L=0,$=0,E=0,z=0,D=-1,B=!1;function F(e,n){const i=n(e);return!!i&&i.activeRegionIds.includes(t)}function N(){z+=1}function O(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function W(n,i,r,o){const s={bodyId:n.id,jobId:i.jobId,visitId:i.visitId,visit:i.visit,remaining:i.work,total:i.work,queuedAt:i.queuedAt,sequence:o};return u.set(i.jobId,s),g.delete(n.id),y.set(n.id,i.jobId),P+=1,_+=i.work,N(),function(n,i,r){const o=O(i);e.onQueued?.(n,o),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:i.total,jobId:i.jobId,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,queueDepth:u.size})}(n,s,r),s}function q(e){if(u.size>=s||0===d.size)return;const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(u.size>=s)break;const t=p.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),g.delete(n.bodyId),W(t,n,e,n.sequence)):d.delete(n.jobId)}}function Y(){let e=0;for(const t of u.values())e+=t.remaining;return e}function H(){L=Math.max(L,u.size),$=Math.max($,Y())}function G(){const e=S-a,t=Math.max(0,Math.min(a,S-(A??S)));let i=0,r=0,o=0,s=0,c=0;for(const t of m){if(e>t.end)continue;i+=t.arrivals,r+=t.arrivalWork,o+=t.completions,s+=t.completedWork;const n=t.end-t.start;c+=n>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/n):t.processedWork}const l=t>0?r/t:0;return{seconds:t,arrivals:i,arrivalWork:r,completions:o,completedWork:s,processedWork:c,arrivalsPerSecond:t>0?i/t:0,throughputPerSecond:t>0?o/t:0,utilization:t>0&&n>0?Math.max(0,Math.min(1,c/(n*t))):0,pressure:n>0?l/n:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:i=>{const r=i.controls.readBodies(),o=new Map,P=new Map;for(const t of r){if(o.set(t.id,t),!F(t.id,i.getRegionState))continue;if(!Vu(t,e.bodyFilter))continue;const n=Hu(t,e.jobKey),r=P.get(n)??[];r.push(t),P.set(n,r)}const _=Number.isFinite(i.dt)?Math.max(0,i.dt):0;if(!B){const e=Number.isFinite(i.elapsed)?Math.max(0,i.elapsed):_;S=Math.max(0,e-_),B=!0}const L=S,$=L+_;S=$,A=null==A?L:Math.min(A,L);const z={start:L,end:$,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},Y=new Map;for(const[e,t]of P){const n=h.get(e)?.bodyId,i=t.find(e=>e.id===n)??t[0];Y.set(e,i),p.set(e,i)}for(const[n,r]of h){if(Y.has(n))continue;const s=u.get(n),a=o.get(r.bodyId)??p.get(n);if(s){u.delete(n),y.delete(s.bodyId),T+=1,R+=s.remaining,N();const o={...O(s),abandonedAt:S,remainingWork:s.remaining,queueSeconds:Math.max(0,S-s.queuedAt)};a&&e.onAbandoned?.(a,o),i.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:t,work:s.total,remainingWork:s.remaining,jobId:n,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:S,queueSeconds:o.queueSeconds,queueDepth:u.size})}d.delete(n),g.delete(r.bodyId),h.delete(n),p.delete(n)}for(const[n,r]of Y){if(h.has(n))continue;const o=(f.get(n)??0)+1;f.set(n,o);const a=Yu(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${o}`,visit:o,regionId:t,work:a,queuedAt:S};h.set(n,c),M+=1,z.arrivals+=1,z.arrivalWork+=a;const l=x++;if(s>u.size)W(r,c,i,l);else{const s={...c,blockedAt:S,sequence:l};d.set(n,s),g.set(r.id,n),I+=1,N(),e.onBlocked?.(r,s),i.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:a,jobId:n,visitId:c.visitId,visit:o,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}q(i),H();const G=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let X=n*_;for(const n of G){if(0>=X)break;const r=Math.min(n.remaining,X);if(n.remaining-=r,X-=r,j+=r,z.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),y.delete(n.bodyId),k+=1,C+=n.total,z.completions+=1,z.completedWork+=n.total;const s=Math.max(0,S-n.queuedAt);E+=s,N();const a=o.get(n.bodyId);if(!a)continue;i.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...O(n),completedAt:S,queueSeconds:s};e.onProcessed?.(a,c),i.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:S,queueSeconds:s,queueDepth:u.size})}q(i),H(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);b=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);v=new Map(t.map((e,t)=>[e.bodyId,t])),w=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&m.push(e);const t=S-a;for(;m.length>0&&t>m[0].end;)m.shift()}(z);const V=Math.floor(S/c);V!==D&&(D=V,N())},getSnapshot:()=>{const e=Y(),i=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),r=u.size,o=Array.from(u.values()).map(e=>Math.max(0,S-e.queuedAt)).sort((e,t)=>e-t),s=o.reduce((e,t)=>e+t,0);return{regionId:t,queueDepth:r,processedCount:k,unitsPerSecond:n,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+i,blockedDepth:d.size,blockedWork:i,arrivalCount:M,admittedCount:P,admittedWork:_,processedWork:j,completedWork:C,blockedCount:I,abandonedCount:T,abandonedWork:R,peakQueueDepth:L,peakRemainingWork:$,queueAge:{count:o.length,meanSeconds:o.length>0?s/o.length:0,p50Seconds:Gu(o,.5),p95Seconds:Gu(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:k>0?E/k:0,window:G(),simulatedAt:S,metricRevision:z}},bodyForce:e=>{if("none"===i)return null;const n=y.get(e.body.id),s=g.get(e.body.id),a=n?u.get(n):void 0,c=s?d.get(s):void 0;if(!a&&!c)return null;const l=a?b.get(e.body.id):v.get(e.body.id);if(null==l)return null;let h;const f=e.regions;if(f)for(let e=0;f.length>e;e+=1)if(f[e].id===t){const t=f[e].shape;t&&"aabb"===t.type&&(h=t);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-e.body.x)*o,y:(h.y-(l-((c?d.size:w)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:w))-e.body.y)*o*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Ku(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}var Zu=require("react");function Qu(){return"undefined"==typeof document||!document.hidden}function Ju(e,t,n){const i=n.fill??"#4e79a7",r=n.stroke,o=n.strokeWidth??0,s=n.opacity??1,a=n.fillOpacity??1,c=function(e,t){const n=t.mark;if(n)return n;const i=e.datum,r=i?.__physicsMark??i?.mark;return"circle"===r||"halo"===r||"faceted"===r||"pill"===r||"diamond"===r||"square"===r?r:"circle"===e.shape.type?"circle":"square"}(t,n),l="circle"===t.shape.type?n.r??t.shape.radius:Math.max(t.shape.width,t.shape.height)/2;if(e.save(),e.globalAlpha*=s,e.beginPath(),"pill"===c||"square"===c||"aabb"===t.shape.type){const n="pill"===c?2.4*l:"aabb"===t.shape.type?t.shape.width:1.7*l,i="pill"===c?1.35*l:"aabb"===t.shape.type?t.shape.height:1.7*l,r=t.x-n/2,o=t.y-i/2,s="pill"===c?i/2:Math.min(4,n/4);e.moveTo(r+s,o),e.arcTo(r+n,o,r+n,o+i,s),e.arcTo(r+n,o+i,r,o+i,s),e.arcTo(r,o+i,r,o,s),e.arcTo(r,o,r+n,o,s),e.closePath()}else if("diamond"===c)e.moveTo(t.x,t.y-l),e.lineTo(t.x+l,t.y),e.lineTo(t.x,t.y+l),e.lineTo(t.x-l,t.y),e.closePath();else if("faceted"===c){const n=6;for(let i=0;n>i;i+=1){const r=2*Math.PI*i/n-Math.PI/2,o=t.x+Math.cos(r)*l,s=t.y+Math.sin(r)*l;0===i?e.moveTo(o,s):e.lineTo(o,s)}e.closePath()}else e.arc(t.x,t.y,l,0,2*Math.PI);i&&(e.save(),e.globalAlpha*=a,e.fillStyle=i,e.fill(),e.restore()),"halo"===c&&(e.beginPath(),e.arc(t.x,t.y,1.35*l,0,2*Math.PI),e.strokeStyle=r??i,e.lineWidth=Math.max(1.5,o||1.5),e.globalAlpha*=.55,e.stroke(),e.globalAlpha/=.55),r&&o>0&&(e.strokeStyle=r,e.lineWidth=o,n.strokeDasharray&&e.setLineDash(n.strokeDasharray.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e))),e.stroke()),e.restore()}function ed(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function td(e){return e.sensorId??"stream-region-"+e.id}function nd(e){const t=td(e),n={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){const i=e.colliderThickness??8,r=e.shape.x-e.shape.width/2,o=e.shape.x+e.shape.width/2,s=e.shape.y-e.shape.height/2,a=e.shape.y+e.shape.height/2;return[{...n,id:t+"-top",shape:{type:"segment",x1:r,y1:s,x2:o,y2:s,thickness:i}},{...n,id:t+"-right",shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:i}},{...n,id:t+"-bottom",shape:{type:"segment",x1:o,y1:a,x2:r,y2:a,thickness:i}},{...n,id:t+"-left",shape:{type:"segment",x1:r,y1:a,x2:r,y2:s,thickness:i}}]}return e.collider?[{...n,id:t+"-collider",shape:e.shape}]:[]}function id(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function rd(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const i=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(r)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(r)?r:0}:null}function od(e){if(!1===e.semanticItem)return null;const t=e.shape,n=e.semanticItem??{},i="aabb"===t.type?{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:t.x,y:t.y,width:t.width,height:t.height}:{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2,pathData:`M ${t.x1} ${t.y1} L ${t.x2} ${t.y2}`};return{...i,...n,id:n.id??i.id}}function sd(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}function ad(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const i=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(r)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(r)?r:0}:null}var cd=[];function ld(e){const t=e.store.controls(),n=e.store.snapshot(),i=Math.max(0,e.result.steps*(n.config.fixedDt||1/60)),r=function(e,t,n,i){const r=Number.isFinite(i)?Math.max(0,i):0;if(0>=r||!sd(t))return!1;const o=new Map(t.map(e=>[e.id,e])),s=e.readBodies();let a=!1;for(const t of s){const i=n.get(t.id);if(!i||!i.activeRegionIds.size)continue;const s=id(i);if(s)for(const n of i.activeRegionIds){const i=o.get(n);if(!i)continue;const c=rd(i.force,{body:t,region:i,regionState:s}),l=Number(i.damping??0),u=(c?.x??0)*r-(Number.isFinite(l)?t.vx*l*r:0),d=(c?.y??0)*r-(Number.isFinite(l)?t.vy*l*r:0);(u||d)&&(e.applyImpulse(t.id,u,d),a=!0)}}return a}(t,e.regionEffects,e.regionState,i),o=function(e,t,n,i,r,o){const s=Number.isFinite(o)?Math.max(0,o):0;if(0>=s||!t)return!1;const a=new Map(n.map(e=>[e.id,e])),c=e.readBodies();let l=!1;for(let n=0;c.length>n;n+=1){const o=c[n],u=i.get(o.id),d=id(u);let h=cd;if(u&&u.activeRegionIds.size>0){const e=[];for(const t of u.activeRegionIds){const n=a.get(t);n&&e.push(n)}h=e}const f=ad(t,{body:o,bodies:c,index:n,regionState:d,regions:h,simulationState:r});if(!f)continue;const p=(f.x??0)*s,y=(f.y??0)*s;(p||y)&&(e.applyImpulse(o.id,p,y),l=!0)}return l}(t,e.bodyForces,e.regionEffects,e.regionState,n.simulationState,i);return e.composed&&e.composed.onTick(e.result,t,{dt:i,elapsed:e.result.elapsedSeconds,getRegionState:t=>id(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:r,bodyForcesApplied:o,snapshot:n}}function ud(e,t,n,i,r,o,s,a,c,l){const u=function(e,t){return!!t?.isActive&&(t.predicate?.(e)??!0)}(e,r),d={selected:u,simulationState:t,regionState:o,regions:s},h="function"==typeof n?n(e,d):n,f=s.reduce((t,n)=>n.bodyStyle?{...t,..."function"==typeof n.bodyStyle?n.bodyStyle(e,d):n.bodyStyle}:t,{}),p=u?"function"==typeof i?i(e,d):i:void 0;return{fill:l?.color??a,stroke:l?.stroke??c,strokeWidth:l?.strokeWidth??1,opacity:l?.opacity??.9,...h,...f,...p}}var dd=c(require("react")),hd=require("react/jsx-runtime"),fd={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},pd="semiotic-accessible-data-table",yd=pd+" semiotic-accessible-data-table-hidden",gd=pd+" semiotic-accessible-data-table-visible",md={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"},xd={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},bd={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)"},vd={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},wd={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))"},kd={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Sd={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ad={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 Md(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function Pd(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function _d(e){if("circle"===e.shape.type){const t=Math.max(4,2*e.shape.radius);return{height:t,shape:"circle",width:t}}return{height:e.shape.height,shape:"rect",width:e.shape.width}}function jd(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e+""}return e.id}function Cd(e){const t=Id(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function Id(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const n=Md(t);return null==n?null:[e,n]}).filter(e=>null!=e).slice(0,8):[]}function Td({hover:e}){const t=Id(e.data);return(0,hd.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[(0,hd.jsx)("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>(0,hd.jsxs)("div",{children:[(0,hd.jsxs)("span",{style:{opacity:.72},children:[e,": "]}),(0,hd.jsx)("span",{children:t})]},e))]})}function Rd(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const n=Md(t);return null==n?null:`${e}: ${n}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function Ld(e){const t=[`${e.length} semantic item${1===e.length?"":"s"}.`],n=new Map;for(const t of e)t.group&&n.set(t.group,(n.get(t.group)??0)+1);return n.size&&t.push(Array.from(n).map(([e,t])=>`${e}: ${t}`).join(", ")),t.join(" ")}function $d(e){const{chartTitle:t,items:n,tableId:i}=e,[r,o]=dd.useState(!1),[s,a]=dd.useState(5),c=_o(),l=c?.visible??!1,u=r||l,d=dd.useRef(null),h="Data summary for "+(t??"physics chart");dd.useEffect(()=>{u||a(5)},[u]);const f=dd.useCallback(e=>{e.target===e.currentTarget&&(r||l||o(!0))},[r,l]),p=dd.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!n.length)return(0,hd.jsx)("span",{id:i,tabIndex:-1,style:fd});if(!u)return(0,hd.jsx)("div",{id:i,className:yd,role:"region","aria-label":h,tabIndex:-1,style:fd,onFocus:f,children:(0,hd.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",n.length," semantic items)"]})});const y=Math.min(s,n.length),g=n.slice(0,y),m=n.length-y;return(0,hd.jsxs)("div",{ref:d,id:i,className:gd,role:"region","aria-label":h,tabIndex:-1,onBlur:p,style:md,children:[(0,hd.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},style:bd,children:"×"}),(0,hd.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:xd,children:Ld(n)}),(0,hd.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:vd,children:[(0,hd.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Sd,children:m>0?`First ${y} of ${n.length} semantic items`:`All ${n.length} semantic items`}),(0,hd.jsx)("thead",{children:(0,hd.jsxs)("tr",{children:[(0,hd.jsx)("th",{scope:"col",style:wd,children:"Item"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Description"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Group"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Position"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Data"})]})}),(0,hd.jsx)("tbody",{children:g.map((e,t)=>(0,hd.jsxs)("tr",{children:[(0,hd.jsx)("th",{scope:"row",style:kd,children:e.label}),(0,hd.jsx)("td",{style:kd,children:e.description??e.label}),(0,hd.jsx)("td",{style:kd,children:e.group??""}),(0,hd.jsxs)("td",{style:kd,children:[Math.round(e.x),", ",Math.round(e.y)]}),(0,hd.jsx)("td",{style:kd,children:Rd(e)})]},e.id??`${e.label}-${t}`))})]}),m>0?(0,hd.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ad,children:["Show ",Math.min(25,m)," more"," ",1===m?"row":"rows"," (",m," remaining)"]}):null]})}Td.ownsChrome=!0;var Ed=require("react/jsx-runtime"),zd=[640,360],Dd={top:0,right:0,bottom:0,left:0},Bd=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Fd(e,t,n){const i=new Fl(e);return t?.length&&i.enqueue(t,n),i}var Nd="StreamPhysicsFrame";function Od(){return"undefined"!=typeof performance?performance.now():Date.now()}var Wd=(0,su.memo)((0,su.forwardRef)(function(e,t){const{accessibleTable:n=!0,annotations:i,autoPlaceAnnotations:r,background:o,backgroundGraphics:s,bodySemanticItemLimit:a=200,bodySemanticItems:c=!1,bodySemanticUpdateMs:l=200,bodyForces:u,bodyStyle:d,chartId:h,className:f,frameScheduler:p,clock:y,color:g,config:m,controllers:x,continuous:b=!1,description:v,emphasis:w,chartMode:k,enableHover:S=!0,foregroundGraphics:A,hoverRadius:M=16,initialSpawns:P,initialSpawnPacing:_,legend:j,legendClickBehavior:C,legendHighlightedCategory:I,legendHoverBehavior:T,legendIsolatedCategories:R,legendLayout:L,legendPosition:$,margin:E,onClick:z,onObservation:D,onRegionEvent:B,onSimulationExecutionChange:F,onBodyHover:N,onBodyPointerDown:O,onSemanticItemActivate:W,onSemanticItemFocus:q,onTick:Y,opacity:H,paused:G=!1,regionEffects:X=[],responsiveHeight:V,responsiveWidth:U,selectedBodyStyle:K={stroke:"#111827",strokeWidth:2,opacity:1},selection:Z,semanticItems:Q=[],simulationExecution:J="auto",size:ee=zd,stroke:te,strokeWidth:ne,summary:ie,suspendWhenHidden:re=!0,svgAnnotationRules:oe,title:se,tooltipContent:ae,workerBodyThreshold:ce=Pu,renderBody:le,beforePaint:ue,afterPaint:de}=e,he=ou.useMemo(()=>({color:g,stroke:te,strokeWidth:ne,opacity:H}),[g,H,te,ne]),fe=(0,su.useRef)(D);fe.current=D;const pe=(0,su.useRef)(h);pe.current=h;const ye=(0,su.useRef)(new Map),ge=(0,su.useRef)(X);ge.current=X;const me=(0,su.useRef)(u);me.current=u;const xe=(0,su.useRef)(Y);xe.current=Y;const be=ou.useMemo(()=>function(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,i)=>{const r={result:e,controls:n,dt:i.dt,elapsed:i.elapsed,getRegionState:i.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const i of t)i.bodyForce&&(n=Ku(n,i.bodyForce(e)));return n}}}(x),[x]),ve=(0,su.useRef)(be);ve.current=be;const we=b||!!be?.continuous,ke=(0,su.useRef)(we);ke.current=we;const Se=ou.useMemo(()=>{if(!u&&!be?.bodyForce)return u;if(!be?.bodyForce)return u;if(!u)return be.bodyForce;const e=be.bodyForce;return t=>{const n="function"==typeof u?u(t):u,i="function"==typeof e?e(t):e;return n||i?{x:(n?.x??0)+(i?.x??0),y:(n?.y??0)+(i?.y??0)}:null}},[u,be]);me.current=Se;const Ae=ou.useMemo(()=>new Map(X.map(e=>[td(e),e])),[X]),Me=ou.useMemo(()=>new Map(X.map(e=>[e.id,e])),[X]),Pe=ou.useMemo(()=>X.map(od).filter(e=>null!=e),[X]),[_e,je]=ou.useState([]),Ce=ou.useMemo(()=>_e.length||Pe.length?[...Q,..._e,...Pe]:Q,[_e,Pe,Q]),Ie=ou.useMemo(()=>sd(X),[X]),Te=!!Se,Re=(0,su.useRef)(null),Le=(0,su.useRef)(y??Od);Le.current=y??Od;const $e=(0,su.useCallback)((e,t,n)=>{const i=Re.current;if(!i||!n)return!1;const r=i.readBodies().find(t=>t.id===e),o=id(ye.current.get(e));if(!r||!o)return!1;const s=rd(n,{body:r,region:t,regionState:o});return!(!s||!s.x&&!s.y||(i.applyImpulse(e,s.x??0,s.y??0),0))},[]),Ee=(0,su.useCallback)((e,t,n)=>{if(!n.bodyId)return;const i=id(ye.current.get(n.bodyId));if(!i)return;const r={bodyId:n.bodyId,datum:n.datum,observation:n,region:t,regionState:i,type:e};"region-enter"===e?t.onEnter?.(r):t.onExit?.(r),B?.(r)},[B]),ze=(0,su.useCallback)(e=>{const t=e.sensorId?Ae.get(e.sensorId):void 0;if(!t||!e.bodyId)return;const n=function(e,t){let n=e.get(t);return n||(n={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},e.set(t,n)),n}(ye.current,e.bodyId),i=Re.current?.readBodies().find(t=>t.id===e.bodyId),r=id(n),o=i&&r?{body:i,region:t,regionState:r}:null;if("physics-proximity-enter"===e.type){if(n.activeRegionIds.add(t.id),n.regionIds.add(t.id),n.energy+=t.energyDelta??0,o){!function(e,t,n){const i="function"==typeof e.attributes?e.attributes(t):e.attributes;i&&(n.attributes={...n.attributes,...i})}(t,o,n);const e=function(e,t){return void 0!==e.charge?"function"==typeof e.charge?e.charge(t):e.charge:"charge-gate"===e.kind?1:void 0}(t,o);void 0!==e&&(n.charges[t.id]=e)}$e(e.bodyId,t,t.impulseOnEnter),Ee("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(n.activeRegionIds.delete(t.id),$e(e.bodyId,t,t.impulseOnExit),Ee("region-exit",t,e))},[$e,Ee,Ae]),De=ou.useMemo(()=>{if(!i?.length)return[];const e=i.filter(e=>"barrier"===e.physics||"sensor"===e.physics);return e.length?function(e=[],t={}){const n=t.idPrefix?t.idPrefix+"-":"",i=[];for(const r of e){if("barrier"!==r.physics&&"sensor"!==r.physics)continue;const e=r.axis??t.defaultAxis??"x",o=Mu(r,t),s=r.colliderId??`${n}${r.id}`;let a;if("x"===e){const e=Au(r.x),n=Au(r.y1)??Au(t.plotBounds?.y)??Au(r.y),i=Au(r.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??Au(r.y);if(null==e||null==n||null==i)continue;a={type:"segment",x1:e,y1:n,x2:e,y2:i,thickness:o}}else{const e=Au(r.y),n=Au(r.x1)??Au(t.plotBounds?.x)??Au(r.x),i=Au(r.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??Au(r.x);if(null==e||null==n||null==i)continue;a={type:"segment",x1:n,y1:e,x2:i,y2:e,thickness:o}}i.push({id:s,shape:a,sensor:"sensor"===r.physics,..."barrier"!==r.physics||null==r.restitution&&null==t.barrierRestitution?{}:{restitution:Au(r.restitution)??Au(t.barrierRestitution)},..."barrier"!==r.physics||null==r.friction&&null==t.barrierFriction?{}:{friction:Au(r.friction)??Au(t.barrierFriction)}})}return i}(e,{idPrefix:h?h+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:ee?.[0]??zd[0],height:ee?.[1]??zd[1]}}):[]},[i,h,ee]),Be=ou.useMemo(()=>{const e=X.flatMap(e=>[{id:td(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...nd(e)]),t=Object.fromEntries(X.map(e=>[td(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),n=m?.observation,i=X.length>0;return i||e.length>0||De.length>0||null!=h||n?{...m,colliders:[...m?.colliders??[],...e,...De],observation:{...n,chartId:h??n?.chartId,chartType:n?.chartType??Nd,sensors:{...n?.sensors??{},...t},onObservation:e=>{i&&ze(e),n?.onObservation?.(e)}}}:m},[De,h,m,ze,X]);if(!Re.current){const e=Fd(Be,P,_);e.setPaused(G),re&&e.setVisible(Qu()),Re.current=e}const Fe=(0,su.useRef)(null),Ne=(0,su.useRef)(-1),Oe=(0,su.useRef)(null),We=(0,su.useRef)(!0),qe=(0,su.useRef)(""),Ye=(0,su.useId)().replace(/:/g,""),He=(0,su.useRef)(!1),Ge=(0,su.useRef)(!1),Xe=(0,su.useRef)(0),Ve=(0,su.useRef)(!1),Ue=(0,su.useRef)(null),Ke=(0,su.useRef)(!1),Ze=ls({sizeProp:ee,responsiveWidth:U,responsiveHeight:V,userMargin:E,marginDefault:Dd,foregroundGraphics:A,backgroundGraphics:s,frameScheduler:p}),{margin:Qe,rafRef:Je,reducedMotionRef:et,renderFnRef:tt,cancelRender:nt,resolvedBackground:it,resolvedForeground:rt,responsiveRef:ot,scheduleRender:st,size:at}=Ze,ct=ho(),lt=go(),[ut,dt]=ou.useState(null),[ht,ft]=ou.useState(null),pt=(0,su.useRef)(null),yt=(0,su.useRef)(0),gt=(0,su.useRef)(new Map),mt=Ye+"-physics-live",xt=(0,su.useCallback)((e,t,n=!1)=>{if(!c)return void je(e=>e.length?[]:e);const i=Le.current();if(!n&&l>0&&l>i-yt.current)return;yt.current=i;const r=function(e,t,n,i){if(!n)return[];const r=Math.max(0,Math.floor(i));if(!r)return[];const o=[];for(let i=0;e.length>i&&r>o.length;i+=1){const r=e[i],s="function"==typeof n?n(r,{index:i,simulationState:t}):void 0;if(!1===s)continue;const a=_d(r);o.push({datum:r.datum??r,description:Cd(r),group:"body",label:jd(r),...a,...s??{},bodyId:s?.bodyId??r.id,id:s?.id??"body:"+r.id,x:s?.x??r.x,y:s?.y??r.y})}return o}(e,t,c,a);je(e=>function(e,t){if(e.length!==t.length)return!0;for(let n=0;e.length>n;n+=1){const i=e[n],r=t[n];if(i.id!==r.id||i.label!==r.label||i.description!==r.description||i.group!==r.group||i.bodyId!==r.bodyId||Math.round(i.x)!==Math.round(r.x)||Math.round(i.y)!==Math.round(r.y))return!0}return!1}(e,r)?r:e)},[a,c,l]),bt=(0,su.useCallback)(e=>{if(!Ce.length)return;const t=Math.max(0,Math.min(e,Ce.length-1));Ne.current=t;const n=Ce[t];if(pt.current=n.bodyId??null,dt(n),q?.(n),n.bodyId&&Re.current){const e=Re.current.readBodies().find(e=>e.id===n.bodyId);if(e){const t=Pd(e);ft(t),N?.(e,t)}}},[Ce,N,q]),vt=(0,su.useCallback)(()=>{Ne.current=-1,pt.current=null,dt(null),q?.(null)},[q]),wt=(0,su.useCallback)((e,t)=>{const n=fe.current;if(!n)return;const i=Le.current();n("hover"!==e&&"click"!==e?{type:e,timestamp:i,chartType:Nd,chartId:pe.current}:{type:e,datum:t?.datum??{},x:t?.x??0,y:t?.y??0,timestamp:i,chartType:Nd,chartId:pe.current})},[]),kt=(0,su.useCallback)(()=>{ft(e=>e?(N?.(null,null),wt("hover-end"),null):e)},[wt,N]),St=(0,su.useCallback)(e=>{if(!S||!Re.current)return;const t=e.currentTarget.getBoundingClientRect(),n=Re.current.hitTest(e.clientX-t.left,e.clientY-t.top,M);if(!n)return void kt();const i=Pd(n);ft(e=>e&&e.id===i.id&&e.x===i.x&&e.y===i.y?e:(N?.(n,i),wt("hover",{datum:n.datum,x:n.x,y:n.y}),i))},[kt,wt,S,M,N]),At=(0,su.useCallback)(e=>{vt();const t=Re.current,n=e.currentTarget.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=t?t.hitTest(i,r,Math.max(16,M)):null;O?.(o,e),o?(wt("click",{datum:o.datum,x:o.x,y:o.y}),z?.(o.datum??null,{x:o.x,y:o.y,body:o})):(wt("click-end"),z?.(null,{x:i,y:r,body:null}),kt())},[kt,vt,wt,M,O,z]);(0,su.useEffect)(()=>{if(!Ce.length)return void vt();const e=Ne.current;if(Ce.length>e){if(e>=0){const t=Ce[e];if(pt.current=t.bodyId??null,dt(e=>null!=e&&e.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t),t.bodyId&&Re.current){const e=Re.current.readBodies().find(e=>e.id===t.bodyId);if(e){const t=Pd(e);ft(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else bt(Ce.length-1)},[Ce,vt,bt]),(0,su.useEffect)(()=>{S||kt()},[kt,S]);const Mt=(0,su.useCallback)(e=>{if(!Ce.length)return;if("Escape"===e.key)return e.preventDefault(),void vt();if(("Enter"===e.key||" "===e.key)&&Ne.current>=0)return e.preventDefault(),void W?.(Ce[Ne.current]);if(!Bd.has(e.key))return;e.preventDefault();const t=Ne.current;if(0>t)return void bt(0);const n=Math.max(1,Math.floor(.1*Ce.length));let i=t;"Home"===e.key?i=0:"End"===e.key?i=Ce.length-1:"PageDown"===e.key?i=Math.min(Ce.length-1,t+n):"PageUp"===e.key?i=Math.max(0,t-n):"ArrowRight"===e.key||"ArrowDown"===e.key?i=Math.min(Ce.length-1,t+1):"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(i=Math.max(0,t-1)),bt(i)},[vt,bt,W,Ce]),[Pt,_t]=ou.useState([]),jt=(0,su.useRef)(0),Ct=!!i?.length&&i.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),It=(0,su.useCallback)(()=>{const e=Fe.current,t=Re.current;if(!e||!t)return;const n=ds(),i=us(e,at,Qe,n);if(!i)return;const r=function(e){const t=mu(e,hu),n=mu(e,lu),i=mu(e,gu),r=mu(e,fu),o=mu(e,cu),s=mu(e,au),a=mu(e,pu),c=mu(e,yu),l=mu(e,uu),u=mu(e,du);return{annotationBackground:xu(s,.94),annotationStroke:o,annotationText:a,background:s,border:o,closedWindowFill:xu(n,.08),closedWindowStroke:xu(n,.55),danger:n,focus:l,grid:u,gutterFill:xu(c,.14),lateFill:i,openWindowFill:xu(t,.07),openWindowStroke:xu(t,.3),primary:t,selectedFill:i,selectedStroke:l,success:r,text:a,textSecondary:c,warning:i}}(i);i.clearRect(-Qe.left,-Qe.top,at[0],at[1]),s||"transparent"===o||(i.fillStyle=o??r.background,i.fillRect(-Qe.left,-Qe.top,at[0],at[1]));const a=t.snapshot(),c=t.readBodies();if(xt(c,a.simulationState),Ct){const e=Le.current();if(e-jt.current>=100){jt.current=e;const t=function(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,ku(e))}))}(c);_t(e=>e.length===t.length&&e.every((e,n)=>e.pointId===t[n].pointId&&Math.round(e.x)===Math.round(t[n].x)&&Math.round(e.y)===Math.round(t[n].y))?e:t)}}ue&&(i.save(),ue(i,c),i.restore());for(const e of c){const t=ye.current.get(e.id),n=t?Array.from(t.activeRegionIds).map(e=>Me.get(e)).filter(e=>null!=e):[],o=ud(e,a.simulationState,d,K,Z,id(t),n,r.primary,r.text,he);le?(i.save(),le(i,e,o),i.restore()):Ju(i,e,o)}de&&(i.save(),de(i,c),i.restore()),function(e,t,n){let i=!1;for(const[r,o]of t){const s=Math.min(1,Math.max(0,(n-o.startedAt)/o.durationMs));if(s>=1){t.delete(r);continue}i=!0;const a=1-Math.pow(1-s,3),{body:c}=o,l=o.radius+28*a,u=1-s;e.save(),e.globalAlpha*=u,e.strokeStyle=o.color,e.fillStyle=o.color,e.lineWidth=2.4*u+.4,e.beginPath(),e.arc(c.x,c.y,l,0,2*Math.PI),e.stroke(),e.globalAlpha*=.18,e.beginPath(),e.arc(c.x,c.y,.52*l,0,2*Math.PI),e.fill(),e.restore(),e.save(),e.globalAlpha*=u,e.strokeStyle=o.color,e.lineWidth=1.8;for(let t=0;8>t;t+=1){const n=t*(Math.PI/4)+1.4*s,i=o.radius+5+12*a,r=o.radius+12+34*a;e.beginPath(),e.moveTo(c.x+Math.cos(n)*i,c.y+Math.sin(n)*i),e.lineTo(c.x+Math.cos(n)*r,c.y+Math.sin(n)*r),e.stroke()}e.restore()}}(i,gt.current,Le.current()),We.current=!1},[de,o,s,ue,d,Qe,Ct,Me,le,K,Z,he,xt,at]),Tt=(0,su.useCallback)((e,t)=>{const n=Re.current,i=`${J}:${e}:${t??""}`;qe.current!==i&&(qe.current=i,F?.({execution:e,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:t,requested:J}))},[F,J]),Rt=(0,su.useCallback)((e,t=!0)=>{Xe.current+=1,He.current=!1,Ve.current=!1,Ke.current=!1,Ue.current?.terminate(),Ue.current=null,t&&Tt("sync",e)},[Tt]),Lt=(0,su.useCallback)(()=>ct?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Ie?"runtime region effects require sync":Te?"body forces require sync":be?"physics controllers require sync":function(e){return!e||!e.engine&&ju(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(Be??{})?Tu(_)?Ge.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[Be,be,Te,Ie,ct,_]),$t=(0,su.useCallback)(()=>{const e=Re.current,t=Lt();if(!e||t)return{reason:t,useWorker:!1};const n=e.liveBodyCount(),i=e.queueSize(),r=function(e,t,n=0,i=Pu){return"sync"!==e&&("worker"===e||t+n>=i)}(J,n,i,ce);return{reason:r?"worker"===J?"forced worker":"body threshold":"below threshold",useWorker:r}},[J,ce,Lt]),Et=(0,su.useCallback)(e=>{const t=Re.current;return t&&e.snapshot?(t.restore(e.snapshot),We.current=!0,t):t},[]),zt=(0,su.useCallback)((e,t=!0)=>{const n=Et(e);if(!n)return;t&&Y?.(e.result,n.controls()),It();const i=n.snapshot();!e.result.shouldContinue&>.current.size<=0||i.paused||!i.visible||et.current||st()},[Et,Y,It,et,st]),Dt=(0,su.useCallback)(e=>{Ge.current=!0,Rt("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[Rt]),Bt=(0,su.useCallback)(()=>{const e=Re.current;if(!e)return!1;const t=$t();if(!t.useWorker)return He.current||Ke.current?Rt(t.reason??"sync fallback"):Tt("sync",t.reason??"sync"),!1;if(He.current||Ke.current)return!0;const n=Ue.current??new Eu;Ue.current=n,Ke.current=!0;const i=Xe.current+1;return Xe.current=i,n.initFromSnapshot(Be??{},e.snapshot()).then(e=>{if(Xe.current!==i)return;Ke.current=!1,He.current=!0,Ge.current=!1,Et(e),Tt("worker",t.reason??"worker"),It();const n=Re.current?.snapshot();e.result.shouldContinue&&n&&!n.paused&&n.visible&&!et.current&&(Oe.current=null,st())}).catch(e=>{Xe.current===i&&Dt(e)}),!0},[Et,Be,Dt,It,et,Tt,st,Rt,$t]),Ft=(0,su.useCallback)(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),Nt=(0,su.useCallback)((e,t=!0)=>{const n=Ue.current;if(!n||!He.current)return;const i=Xe.current;n.request(e).then(e=>{if(Xe.current!==i)return;const n=Ft(e);n&&zt(n,t)}).catch(Dt)},[zt,Ft,Dt]),Ot=(0,su.useCallback)(()=>{const e=Re.current;if(!e)return;const t=Bt(),n=e.snapshot(),i=we||Te||Ie||!!be;n.paused||!n.visible||!e.hasPendingWork()&&!i||et.current?tt.current():t&&Ke.current||(Oe.current=null,st())},[be,we,Te,Ie,et,tt,st,Bt]),Wt=(0,su.useCallback)(()=>{nt(),Je.current=null;const e=Re.current;if(!e)return;if(He.current&&Ue.current){if(Ve.current)return;let t=0;if(!et.current){const e=Le.current();t=null!==Oe.current?(e-Oe.current)/1e3:0,Oe.current=e}const n=Ue.current,i=Xe.current;return Ve.current=!0,void(et.current?n.settle():n.tick(t)).then(e=>{Ve.current=!1,Xe.current===i&&zt(e)}).catch(n=>{if(Ve.current=!1,Xe.current!==i)return;Dt(n);const r=et.current?e.settleWithObservations():e.tick(t);ld({store:e,result:r,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:ve.current,onTick:xe.current}),It()})}let t;if(et.current)t=e.settleWithObservations();else{const n=Le.current(),i=null!==Oe.current?(n-Oe.current)/1e3:0;Oe.current=n,t=e.tick(i)}const n=ve.current,{regionEffectsApplied:i,bodyForcesApplied:r,snapshot:o}=ld({store:e,result:t,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:n,onTick:xe.current});It(),(ke.current||t.shouldContinue||i||r||n||gt.current.size>0)&&!o.paused&&o.visible&&!et.current&&st()},[zt,Dt,It,nt,st,et,Je]);tt.current=Wt,mo({hydrated:ct,wasHydratingFromSSR:lt,storeRef:Re,dirtyRef:We,renderFnRef:tt,cancelRender:nt}),(0,su.useEffect)(()=>{Ge.current=!1,(He.current||Ke.current)&&Rt("config changed",!1),Re.current?.updateConfig(Be??{}),Ot()},[Be,Rt]),(0,su.useEffect)(()=>{Ge.current=!1,Ot()},[ct,J,ce]),function({cancelRender:e,lastFrameTimeRef:t,paused:n,postWorkerCommand:i,requestRender:r,storeRef:o,suspendWhenHidden:s}){const a=(0,Zu.useRef)(i);a.current=i;const c=(0,Zu.useRef)(r);c.current=r,(0,Zu.useEffect)(()=>{const i=o.current;i&&(i.setPaused(n),n&&(t.current=null,e()),a.current({type:"setPaused",paused:n},!1),c.current())},[e,n]),(0,Zu.useEffect)(()=>{if(!s||"undefined"==typeof document)return;const n=()=>{const n=o.current;if(!n)return;const i=Qu();n.setVisible(i),i||(t.current=null,e()),a.current({type:"setVisible",visible:i},!1),c.current()};return n(),document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[e,s])}({cancelRender:nt,lastFrameTimeRef:Oe,paused:G,postWorkerCommand:Nt,requestRender:Ot,storeRef:Re,suspendWhenHidden:re}),(0,su.useEffect)(()=>()=>Rt("unmount",!1),[Rt]),(0,su.useEffect)(()=>{It()},[It]),(0,su.useImperativeHandle)(t,()=>({...Re.current.controls(),applyImpulse:(e,t,n)=>{Re.current.applyImpulse(e,t,n),Nt({type:"applyImpulse",id:e,ix:t,iy:n}),Ot()},clear:()=>{Re.current.clear(),ye.current.clear(),gt.current.clear(),Nt({type:"clear"}),Ot()},clearRegionState:e=>{e?ye.current.delete(e):ye.current.clear(),Ot()},getData:()=>Re.current.readBodies(),getRegionState:e=>e?id(ye.current.get(e)):function(e){const t={};return e.forEach((e,n)=>{const i=id(e);i&&(t[n]=i)}),t}(ye.current),getStore:()=>Re.current,pause:()=>{Re.current.setPaused(!0),Nt({type:"setPaused",paused:!0},!1),Ot()},push:(e,t)=>{Re.current.enqueue(e,t),Tu(t)?Nt({type:"enqueue",spawns:[e],pacing:t}):(He.current||Ke.current)&&Rt("spawn pacing is not worker-cloneable"),Ot()},pushMany:(e,t)=>{Re.current.enqueue(e,t),Tu(t)?Nt({type:"enqueue",spawns:e,pacing:t}):(He.current||Ke.current)&&Rt("spawn pacing is not worker-cloneable"),Ot()},popBodies:(e,t={})=>{const n=Re.current,i=new Map(n.readBodies().map(e=>[e.id,e])),r=n.remove(e),o=Le.current();for(const e of r){const n=i.get(e);n&&(ye.current.delete(e),gt.current.set(e,{body:n,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??ed(n),startedAt:o}),pt.current===e&&(pt.current=null,dt(null)),ft(t=>t?.id===e?null:t))}return r.length&&(Nt({type:"remove",ids:r}),Ot()),r},remove:e=>{const t=Re.current.remove(e);for(const t of e)ye.current.delete(t);return Nt({type:"remove",ids:e}),Ot(),t},restore:e=>{Re.current.restore(e),ye.current.clear(),gt.current.clear(),Nt({type:"restore",snapshot:e},!1),Ot()},resume:()=>{Re.current.setPaused(!1),Nt({type:"setPaused",paused:!1},!1),Ot()},settle:e=>{const t=Re.current.settle(e);return Nt({type:"settle",maxSteps:e}),Ot(),t},settleWithObservations:e=>{const t=Re.current.settleWithObservations(e);return Nt({type:"settle",maxSteps:e}),Ot(),t},step:e=>{const t=Re.current,n=t.tick(e);return ld({store:t,result:n,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:ve.current,onTick:xe.current}),Nt({type:"tick",deltaSeconds:e}),It(),n}}),[It,Nt,Ot,Rt]);const qt=co||!ct&<,Yt=["stream-physics-frame",k?"stream-physics-frame--mode-"+k:null,w?"stream-physics-frame--emphasis-"+w:null,f].filter(Boolean).join(" "),Ht=v??("string"==typeof se?se:void 0)??"Physics chart",Gt=Ye+"-physics-table",Xt=Math.max(1,at[0]-Qe.left-Qe.right),Vt=Math.max(1,at[1]-Qe.top-Qe.bottom),Ut=S&&ht?ae?ae(ht):(0,Ed.jsx)(Td,{hover:ht}):null,Kt=Ut&&ht?(0,Ed.jsx)(ts,{x:ht.x-Qe.left,y:ht.y-Qe.top,containerWidth:Math.max(1,at[0]-Qe.left-Qe.right),containerHeight:Math.max(1,at[1]-Qe.top-Qe.bottom),margin:Qe,className:"stream-physics-tooltip",children:Ut}):null;if(qt){const e=Re.current??Fd(Be,P,_),t="string"==typeof se?se:void 0,{svg:n}=qu(e,{width:at[0],height:at[1],title:t,description:v,background:"transparent"===o?void 0:o,className:"stream-physics-frame__svg",idPrefix:"physics-"+Ye});return(0,Ed.jsxs)("div",{ref:ot,className:Yt,"data-semiotic-mode":k,role:"img","aria-label":Ht,style:{width:at[0],height:at[1]},children:[(0,Ed.jsx)(Xo,{summary:ie}),(0,Ed.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}return(0,Ed.jsxs)("div",{ref:ot,className:Yt,"data-semiotic-mode":k,role:"group","aria-label":Ht,"aria-describedby":ut?mt:void 0,tabIndex:0,style:{position:"relative",width:at[0],height:at[1]},onKeyDown:Mt,children:[n?(0,Ed.jsx)(Vo,{tableId:Gt}):null,n?(0,Ed.jsx)($d,{chartTitle:"string"==typeof se?se:Ht,items:Ce,tableId:Gt}):null,(0,Ed.jsx)(Xo,{summary:ie}),(0,Ed.jsx)(Uo,{hoverPoint:ht}),(0,Ed.jsx)("div",{id:mt,"aria-live":"polite","aria-atomic":"true",style:fd,children:ut?ut.description??ut.label:""}),(0,Ed.jsxs)("div",{role:"img","aria-label":Ht,style:{position:"relative",width:"100%",height:"100%"},children:[it,(0,Ed.jsx)("canvas",{ref:Fe,width:at[0],height:at[1],"aria-hidden":"true",onPointerDown:At,onPointerMove:S?St:void 0,onPointerLeave:S?kt:void 0}),rt,(0,Ed.jsx)(Su,{width:Xt,height:Vt,totalWidth:at[0],totalHeight:at[1],margin:Qe,title:se,legend:j,legendPosition:$,legendLayout:L,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:I,legendIsolatedCategories:R,pointNodes:Pt,annotations:i,autoPlaceAnnotations:r,svgAnnotationRules:oe}),(0,Ed.jsx)(Qo,{active:null!=ut,hoverPoint:ut?{x:ut.x,y:ut.y}:null,margin:Qe,size:at,shape:ut?.shape,width:ut?.width,height:ut?.height,pathData:ut?.pathData}),Kt]})]})}));Wd.displayName="StreamPhysicsFrame";var qd=Wd,Yd=require("react");function Hd(e,t){if(!t?.length)return[e];const n=t.filter(t=>{if(t.id===e||t.id.startsWith(e+"-"))return!0;const n=t.datum;return!(!n||"object"!=typeof n||null==n.id)&&n.id+""===e}).map(e=>e.id);return n.length?n:[e]}function Gd(e,t,n){if("function"==typeof n)return n(e,t)+"";if("string"==typeof n){const t=e[n];if(null!=t)return t+""}return null!=e&&"object"==typeof e&&"id"in e&&null!=e.id?e.id+"":"physics-row-"+t}function Xd(e,t){const n=e?.getData().find(e=>e.id===t),i=n?.datum;if(i&&"object"==typeof i)return i}var Vd=require("react"),Ud=require("react/jsx-runtime"),Kd=new Set(["sample","mechanical"]);function Zd(e,t,n){const i=n?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&Kd.has(e);return e.simulationMode?{chartMode:t(e.mode)?void 0:e.mode,simulationMode:e.simulationMode}:t(e.mode)?{chartMode:void 0,simulationMode:e.mode}:{chartMode:e.mode,simulationMode:"sample"}}({mode:e.mode,simulationMode:e.simulationMode}):{chartMode:"sample"===e.mode||"mechanical"===e.mode?void 0:e.mode,simulationMode:"sample"},r=_a(i.chartMode,{width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:t[0],height:t[1]}),o=e.size?.[0],s=e.size?.[1],a=t[0],c=t[1],l=(0,Vd.useMemo)(()=>{return e=[a,c],(null!=o&&null!=s?[o,s]:void 0)??[r.width??e[0],r.height??e[1]];var e},[c,a,r.height,r.width,s,o]),u=r.compactMode?"sparkline"===i.chartMode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0};const d=e.showProjection??!r.compactMode,h=e.showChrome??!r.compactMode,f=th(e.tooltip,void 0),p=void 0!==f.enableHover?f.enableHover:r.enableHover,y=r.compactMode?r.title:r.title??e.title,g=[e.className,i.chartMode&&"primary"!==i.chartMode?"semiotic-physics--"+i.chartMode:null].filter(Boolean).join(" ")||void 0;return{chartMode:i.chartMode,simulationMode:i.simulationMode,resolved:r,chartSize:l,margin:u,showProjection:d,showChrome:h,enableHover:p,title:y,description:r.description??e.description,summary:r.summary??e.summary,accessibleTable:r.accessibleTable??e.accessibleTable,className:g,compactMode:r.compactMode,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics}}function Qd(e){const[t,n]=e.size;return Fa(e.loading,t,n,e.loadingContent)||Ba(e.data,t,n,e.emptyContent)}function Jd(e,t,n){return(0,Ud.jsx)(Ea,{componentName:e,width:t[0],height:t[1],children:n})}function eh(e,t){return e?t?n=>(0,Ud.jsxs)(Ud.Fragment,{children:["function"==typeof e?e(n):e,"function"==typeof t?t(n):t]}):e:t}function th(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:Q(e)||t?.tooltipContent}}function nh(e,t,n,i){return{accessibleTable:i?.accessibleTable??e.accessibleTable??t?.accessibleTable,annotations:e.annotations??t?.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations??t?.autoPlaceAnnotations,background:e.background??t?.background,chartId:e.chartId??t?.chartId,chartMode:i?.chartMode??t?.chartMode,className:i?.className??e.className??t?.className,color:e.color??t?.color,description:i?.description??e.description??t?.description,emphasis:e.emphasis??t?.emphasis,enableHover:i?.enableHover??t?.enableHover,hoverRadius:e.hoverRadius??t?.hoverRadius,legend:e.legend??t?.legend,legendLayout:e.legendLayout??t?.legendLayout,legendPosition:e.legendPosition??t?.legendPosition,margin:i?.margin??t?.margin,onClick:null!=e.onClick?(t,n)=>{e.onClick?.(t,{x:n.x,y:n.y})}:t?.onClick,onObservation:e.onObservation??t?.onObservation,opacity:e.opacity??t?.opacity,semanticItems:t?.semanticItems??n,stroke:e.stroke??t?.stroke,strokeWidth:e.strokeWidth??t?.strokeWidth,summary:i?.summary??e.summary??t?.summary,svgAnnotationRules:e.svgAnnotationRules??t?.svgAnnotationRules,title:i?.title??e.title??t?.title}}var ih=require("react/jsx-runtime");function rh(e,t){const n=t.config??{},i=(t.sensors??[]).map(e=>({...e,sensor:!0})),r=[...t.colliders??[],...i],o=[...e.colliders??[],...n.colliders??[],...r];return{...e,...n,observation:{...e.observation,...n.observation},...o.length>0&&{colliders:o}}}function oh(e){const t=function(e,t,n){const i=e?.observation;return{...e,observation:{...i,chartId:t??i?.chartId??"physics-custom",chartType:i?.chartType??"PhysicsCustomChart",onObservation:n??i?.onObservation}}}(e.config,e.chartId,e.onObservation),n=iu(e.colorScheme,e.themeCategorical,g),i=Sc(e.size),r={data:e.data,scales:{x:(0,nu.scaleLinear)().domain(e.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:(0,nu.scaleLinear)().domain(e.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:ru(n,e.colorScheme),config:e.layoutConfig??{},world:new Fl(t)},o=e.skipLayout?{}:e.layout(r)??{},s=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...i}=e,r=n.get(t)??[];r.push(i),n.set(t,r)}return e.map(e=>{const t=n.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...o.initialSpawns??o.bodies??[]],o.constraints);return{config:rh(t,o),context:r,initialSpawnPacing:o.initialSpawnPacing,initialSpawns:s,result:o}}(0,tu.forwardRef)(function(e,t){const{chartId:n,color:i,colorBy:r,colorScheme:o,config:s,controllers:a,data:c,emptyContent:l,frameProps:u={},layout:d,layoutConfig:h,loading:f,loadingContent:p,onObservation:y,opacity:g,paused:m,spawnDatum:x,stroke:b,strokeWidth:v,title:w,xExtent:k,yExtent:S}=e,A=Zd(e,[700,380]),{chartSize:M,className:P,title:_,chartMode:j,margin:C,enableHover:I,description:T,summary:R,accessibleTable:L}=A,$=(0,tu.useRef)(null),E=(0,tu.useRef)(null),z=(0,tu.useRef)(""),D=Qd({data:c,emptyContent:l,loading:f,loadingContent:p,size:M}),F=null!=D,N=(0,tu.useMemo)(()=>B(c??[]),[c]),O=Pe(e=>e.theme),W=(0,tu.useMemo)(()=>xe(O)??{},[O]),q=O?.colors?.categorical??we.colors.categorical,Y=(0,tu.useMemo)(()=>[M[0],M[1],N.length,N.map((e,t)=>(e.id??t)+"").join("|"),k?.join(",")??"",S?.join(",")??""].join("::"),[M,N,k,S]),H=(0,tu.useMemo)(()=>oh({chartId:n,colorScheme:o,config:s,data:N,layout:d,layoutConfig:h,onObservation:y,semantic:W,skipLayout:F,size:M,themeCategorical:q,xExtent:k,yExtent:S}),[n,M,o,s,d,h,y,N,W,F,q,k,S]);z.current===Y&&null!=E.current||(z.current=Y,E.current=H.initialSpawns);const G=E.current,X=(0,tu.useMemo)(()=>{const e=[...H.result.controllers??[],...a??[],...u.controllers??[]];return e.length?e:void 0},[u.controllers,a,H.result.controllers]),V=(0,tu.useMemo)(()=>{const e=[...H.result.regionEffects??[],...u.regionEffects??[]];return e.length?e:void 0},[u.regionEffects,H.result.regionEffects]),U=(0,tu.useCallback)(e=>{const t=e.datum,n=t&&r?function(e,t,n){return"function"==typeof n?n(e,0):e[n]}(t,0,r)+"":e.id;return{fill:i??H.context.resolveColor(n,t),stroke:b??"#111827",strokeWidth:v??1,opacity:g??.9}},[i,r,g,H.context,b,v]);!function(e,t){const{frameRef:n,spawnDatum:i,seedRows:r,idAccessor:o,bodyIdsForSeed:s,seedSpawns:a}=t,c=(0,Yd.useRef)(new Map),l=(0,Yd.useRef)(new Map),u=(0,Yd.useRef)(""),d=r?r.map((e,t)=>Gd(e,t,o)).join("\0"):"";if(d!==u.current&&(u.current=d,r))for(let e=0;r.length>e;e+=1){const t=r[e],n=Gd(t,e,o);c.current.set(n,t),l.current.set(n,s?.(t,n,e)??Hd(n,a))}(0,Yd.useImperativeHandle)(e,()=>{const e=c.current,t=l.current;function r(e,t){const n=i(e,t);return{datumId:n.datumId||Gd(e,t,o),spawns:n.spawns.map(e=>({...e,spawnAt:void 0}))}}function s(i){const r=[];for(const{datum:n,result:o}of i)e.set(o.datumId,n),t.set(o.datumId,o.spawns.map(e=>e.id)),r.push(...o.spawns);if(!r.length)return;const o=n.current;o?(o.pushMany(r),o.step(0)):"production"!==process.env.NODE_ENV&&console.warn("[semiotic/physics] push() called before the physics frame mounted (loading/empty early-return). Omit data for push mode and ensure the chart is mounted.")}function a(i){const r=e.get(i);if(r)return r;const o=t.get(i)??[i];for(const r of o){const o=Xd(n.current,r);if(o)return e.set(i,o),t.has(i)||t.set(i,[r]),o}}return{push:t=>{s([{datum:t,result:r(t,e.size)}])},pushMany:t=>{const n=e.size;s(t.map((e,t)=>({datum:e,result:r(e,n+t)})))},remove:i=>{const r=Array.isArray(i)?i:[i],o=[],s=[];for(const n of r){const i=a(n);i&&o.push(i),e.delete(n),s.push(...t.get(n)??[n]),t.delete(n)}return s.length&&n.current?.remove(s),o},update:(i,o)=>{const c=Array.isArray(i)?i:[i],l=[];for(const i of c){const c=a(i);if(!c)continue;l.push(c);const u=t.get(i)??[i];n.current?.remove(u),e.delete(i),t.delete(i);const d=o(c);s([{datum:d,result:r(d,e.size)}])}return l},clear:()=>{e.clear(),t.clear(),u.current="",n.current?.clear()},getData:()=>{const t=n.current;if(!t)return Array.from(e.values());const i=t.getData().map(e=>e.datum).filter(e=>!!e&&"object"==typeof e);return i.length?i:Array.from(e.values())},getScales:()=>null,getCustomLayout:()=>n.current?.snapshot()??null,popBodies:(e,t)=>n.current?.popBodies(e,t)??[]}},[s,n,o,i])}(t,{frameRef:$,spawnDatum:(0,tu.useCallback)((e,t)=>{const i=e;if(x)return function(e,t,n){return Array.isArray(n)?{datumId:(e.id??n[0]?.id??"physics-custom-"+t)+"",spawns:n}:"spawns"in n?n:{datumId:(e.id??n.id??"physics-custom-"+t)+"",spawns:[n]}}(e,t,x(i,t,H.context));const r=oh({chartId:n,colorScheme:o,config:s,data:[i],layout:d,layoutConfig:h,onObservation:y,semantic:W,size:M,themeCategorical:q,xExtent:k,yExtent:S}),a=r.initialSpawns.length?r.initialSpawns:[{id:(e.id??"physics-custom-"+t)+"",x:r.context.dimensions.plot.x+r.context.dimensions.plot.width/2,y:r.context.dimensions.plot.y+12,mass:1,shape:{type:"circle",radius:5},datum:e}];return{datumId:(e.id??a[0].id)+"",spawns:a}},[n,M,o,s,x,d,h,y,H.context,W,q,k,S]),seedRows:N,seedSpawns:G});const K=(0,tu.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]);if(D)return D;const Z=th(e.tooltip,u),Q=nh(e,u,H.result.semanticItems,{chartMode:j,className:P,title:_??w,description:T,summary:R,accessibleTable:L,enableHover:I,margin:C});return Jd("PhysicsCustomChart",M,(0,ih.jsx)(qd,{...u,...Z,...Q,ref:$,backgroundGraphics:eh(u.backgroundGraphics,H.result.backgroundOverlays),bodyForces:H.result.bodyForces??u.bodyForces,bodyStyle:H.result.bodyStyle??u.bodyStyle??U,config:H.config,controllers:X,foregroundGraphics:eh(u.foregroundGraphics,H.result.overlays),initialSpawnPacing:H.initialSpawnPacing,initialSpawns:G,onBodyPointerDown:K,paused:m,regionEffects:V,responsiveHeight:e.responsiveHeight,responsiveWidth:e.responsiveWidth,selectedBodyStyle:H.result.selectedBodyStyle??u.selectedBodyStyle,size:M}))}).displayName="PhysicsCustomChart";var sh=require("react"),ah="gauntlet-core",ch="gauntlet-positive",lh="gauntlet-negative";function uh(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function dh(e,t,n,i){return n?"function"==typeof n?n(e,t):e[n]??i:i}function hh(e){return e?.label??e?.id??"property"}function fh(e){return`gauntlet:${e}:core`}function ph(e,t){return`gauntlet:${e}:positive:${t}`}function yh(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}function gh(e,t,n,i){const r=Math.max(2,n+2),o=80+r,s=i.floorY-r;return{x:Math.max(32+r,Math.min(i.width-30-4-r,e)),y:Math.max(o,Math.min(s,t))}}function mh(e,t,n){const[i,r]=e,o=Math.round(.48*r),s=r-36,a=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,a.length),l=.22*i,u=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:s-n,floorY:s,gates:a.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*u),width:e.width??Math.max(54,Math.round(.07*i))})),graveyardX:Math.round(.84*i),graveyardY:s-4,height:r,routeY:o,socketX:Math.round(.92*i),startX:d,width:i}}function xh(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function bh(e,t,n,i){const r=xh(n),o=i?.(e,t,n)??{};return{...r,...o,startY:o.startY??o.routeY??r.startY,socketY:o.socketY??o.routeY??r.socketY,graveyardY:o.graveyardY??r.graveyardY}}function vh(e,t){const n=[...e].sort((e,t)=>e.localeCompare(t)),i=Math.max(0,n.indexOf(t));return{angle:.82*-Math.PI+(n.length>1?i/(n.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function wh(e,t,n){const i=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,o=e.negativeIds.reduce((e,t)=>e+(n.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*o-1.2*e.delay-5*r))}function kh(e,t,n,i,r){const o=dh(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=i.map(e=>e.id),a=[...dh(e,t,n.positiveAccessor,s)],c=[...dh(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:o,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...dh(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(dh(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:dh(e,t,n.initialViability,100)}}function Sh(e,t,n,i,r,o,s){const a=i.startX,c=i.startY+(i.startY===n.routeY?38*t:0),l=s?.(e,t,n,i)??{},u={__gauntlet:!0,kind:ah,projectId:e.id,sourceDatum:e.datum},d=[{...l,id:fh(e.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:u}],h=gh(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,n);d[0].x=h.x,d[0].y=h.y;for(const t of e.activePositiveIds){const i=r.get(t);if(!i)continue;const o=vh(e.activePositiveIds,t),s=i.radius??10,a=gh(h.x+Math.cos(o.angle)*o.radius,h.y+Math.sin(o.angle)*o.radius,s,n);d.push({id:ph(e.id,t),x:a.x,y:a.y,vx:18*Math.cos(o.angle),vy:18*Math.sin(o.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:ch,projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:fh(e.id)},stiffness:.56,damping:.9,restLength:52+o.index%2*4,...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const r=o.get(t);r&&d.push(Ah(e,r,i,h.x,h.y,n,l.spawnAt??e.startedAt))}),d}function Ah(e,t,n,i,r,o,s){const a=t.radius??7.2,c=gh(i-12+n%4*12,r+54+12*Math.floor(n/4),a,o);return{id:yh(e.id,t.id,n),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:lh,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:fh(e.id)},stiffness:.62,damping:.92,restLength:52+n%4*3,...t.spring??{}}]}}function Mh(e){return e?Array.isArray(e)?[...e]:Object.entries(e).flatMap(([e,t])=>Array.from({length:Math.max(0,Math.round(Number(t)||0))},()=>e)):[]}function Ph(e,t){return t?Array.isArray(t)?[...t]:t.ids?[...t.ids]:t.candidates?t.candidates.filter(t=>e.includes(t)).slice(0,t.count??1):[]:[]}function _h(e,t){return Ph(e.activePositiveIds,t.popPositive)}function jh(e,t){const n=Ph(e.negativeIds,t.popNegative);if(!n.length)return[];const i=new Map;for(const e of n)i.set(e,(i.get(e)??0)+1);const r=[];return e.negativeIds.forEach((e,t)=>{const n=i.get(e)??0;n>0&&(r.push({propertyId:e,index:t}),i.set(e,n-1))}),r}function Ch(e,t,n){if(t.when&&!t.when(n))return e;let i={...e};const r=_h(i,t);r.length&&(i={...i,activePositiveIds:i.activePositiveIds.filter(e=>!r.includes(e)),poppedPositiveIds:Array.from(new Set([...i.poppedPositiveIds,...r]))});const o=jh(i,t);if(o.length){const e=new Set(o.map(e=>e.index));i={...i,negativeIds:i.negativeIds.filter((t,n)=>!e.has(n)),poppedNegativeIds:[...i.poppedNegativeIds,...o.map(e=>e.propertyId)]}}const s=Mh(t.addPositive);s.length&&(i={...i,activePositiveIds:Array.from(new Set([...i.activePositiveIds,...s])),missingPositiveIds:i.missingPositiveIds.filter(e=>!s.includes(e))});const a=Mh(t.addNegative);if(a.length&&(i={...i,negativeIds:[...i.negativeIds,...a]}),t.delayDelta&&(i={...i,delay:i.delay+t.delayDelta}),t.metricsDelta){const e={...i.metrics};for(const[n,i]of Object.entries(t.metricsDelta))e[n]=Number(e[n]??0)+i;i={...i,metrics:e}}return t.viabilityDelta&&(i={...i,viability:i.viability+t.viabilityDelta}),t.stage&&(i={...i,stage:t.stage}),t.outcome&&(i={...i,outcome:t.outcome}),i}function Ih(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function Th(e,t){return e.eventsApplied.includes(t.id)?e:{...e,eventsApplied:[...e.eventsApplied,t.id],eventHistory:[...e.eventHistory??[],t],lastEvent:t,stage:t.label??e.stage}}function Rh(e,t){const n=e.datum;return!(!n?.__gauntlet||n.projectId!==t||n.kind!==lh)}function Lh(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(t);return Number.isFinite(n)?n:-1}var $h=require("react/jsx-runtime");function Eh(e){const t=e.data;return t?.__gauntlet?(0,$h.jsxs)("div",{className:"semiotic-tooltip",style:{background:"var(--semiotic-tooltip-bg, rgba(15, 23, 42, 0.94))",color:"var(--semiotic-tooltip-text, #f8fafc)",padding:"8px 12px",borderRadius:6,boxShadow:"var(--semiotic-tooltip-shadow, 0 8px 24px rgba(0,0,0,0.35))",maxWidth:280},children:[(0,$h.jsx)("strong",{children:t.kind===ah?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:hh(t.property)}),(0,$h.jsx)("div",{children:t.kind===ch?"Positive property":t.kind===lh?"Negative property":"Project core"})]}):null}function zh(e,t,n){const i=t.datum;if(!i?.__gauntlet)return;const r="circle"===t.shape.type?t.shape.radius:8;if(e.save(),e.translate(t.x,t.y),i.kind===ah)e.fillStyle=Dh(e,n.fill,"#0f766e"),e.strokeStyle=Dh(e,n.stroke,"#f8fafc"),e.lineWidth=2.4,e.beginPath(),e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke();else{const t=i.property;e.fillStyle=Dh(e,n.fill??t?.color,"#38bdf8"),e.strokeStyle=Dh(e,n.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),i.kind===lh?e.rect(-r,-r,2*r,2*r):e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=Dh(e,"var(--semiotic-background, #07111f)","#07111f"),e.font=`900 ${i.kind===lh?9:8}px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(t?.short??t?.id?.slice(0,1).toUpperCase()??"?",0,.5)}e.restore()}function Dh(e,t,n){if("string"!=typeof t)return n;if("function"!=typeof getComputedStyle||!e.canvas)return t||n;const i=t.startsWith("var(")?t.match(/var\((--[^,\s)]+)/)?.[1]:t.startsWith("--")?t:null;return i?getComputedStyle(e.canvas).getPropertyValue(i).trim()||n:t||n}function Bh({layout:e,states:t}){return(0,$h.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,$h.jsx)("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-accent, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),(0,$h.jsx)("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-negative, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),(0,$h.jsx)("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),e.gates.map(t=>(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:t.x-t.width/2,y:Math.max(80,e.routeY-180),width:t.width,height:Math.min(360,e.height-170),rx:12,fill:t.color??"var(--semiotic-accent, #38bdf8)",fillOpacity:.1,stroke:t.color??"var(--semiotic-accent, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),(0,$h.jsx)("text",{x:t.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:t.label??t.id})]},t.id)),(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-positive, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-positive, #22c55e)",strokeWidth:1.5}),(0,$h.jsx)("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-negative, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-negative, #ef4444)",strokeOpacity:.7}),(0,$h.jsx)("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,$h.jsx)("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function Fh(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===ah?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${hh(t.property)} ${t.kind===ch?"positive":"negative"} property`,group:t.kind===ch?"positive property":"negative property",description:`${hh(t.property)} attached to ${t.projectId}.`})}function Nh({states:e,layout:t}){const n=function(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}(e);if(!n.length)return null;const i=Math.max(1,...n.map(e=>e.value)),r=Math.max(40,(t.width-80)/n.length);return(0,$h.jsxs)("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,$h.jsx)("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),n.map((e,t)=>{const n=40+t*r,o=Math.max(2,e.value/i*28),s=/kill|crash|block|grave/i.test(e.outcome);return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:n+.18*r,y:28-o+22,width:Math.max(10,.45*r),height:o,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),(0,$h.jsx)("text",{x:n+.4*r,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}var Oh=require("react/jsx-runtime"),Wh=require("react"),qh=[];function Yh(e){return e.map(e=>({...e,spawnAt:void 0}))}(0,sh.forwardRef)(function(e,t){const{bodyGroups:n,coreBody:i,coreForceMode:r="route",crashDetection:o=!0,crashOffset:s=30,data:a,emptyContent:c,events:l,frameProps:u={},gates:d,initialSpawnPacing:h,loading:f,loadingContent:p,negativeProperties:y,onCapacityChange:g,onClick:m,onStateChange:x,outcome:b,paused:v,positiveProperties:w=qh,projectPlacement:k,responsiveHeight:S,responsiveWidth:A,showTethers:M=!0,terminalBehavior:P="outcome",viability:_}=e,j=(0,sh.useRef)(null),C=(0,sh.useMemo)(()=>({idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor}),[e.idAccessor,e.initialViability,e.metricsAccessor,e.negativeAccessor,e.positiveAccessor,e.startTimeAccessor]),I=Zd(e,[900,520]),{chartSize:T,showProjection:R,showChrome:L,className:$,title:E,chartMode:z,margin:D,enableHover:F,description:N,summary:O,accessibleTable:W}=I,q=Qd({data:a,emptyContent:c,loading:f,loadingContent:p,size:T}),Y=(0,sh.useMemo)(()=>B(a??[]),[a]),H=(0,sh.useMemo)(()=>Y.map((e,t)=>dh(e,t,C.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[Y,C.idAccessor]),G=(0,sh.useMemo)(()=>new Map(w.map(e=>[e.id,e])),[w]),X=(0,sh.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),V=(0,sh.useMemo)(()=>mh(T,d,s),[T,s,d]),U=(0,sh.useMemo)(()=>new Map(V.gates.map(e=>[e.id,e])),[V.gates]),K=(0,sh.useMemo)(()=>V.gates.map(e=>({kind:"force-field",damping:.035,force:{x:12,y:0},semanticItem:!1,...e.regionEffect,id:"gauntlet-gate-"+e.id,label:e.label??e.id,description:e.description,bodyFilter:e.capacity?{property:"datum.kind",equals:ah}:e.regionEffect?.bodyFilter,shape:{type:"aabb",x:e.x,y:V.routeY,width:e.capacity?e.capacity.sensorWidth??Math.max(96,6*e.width):Math.max(e.width,54),height:Math.min(360,V.height-170)}})),[V.gates,V.height,V.routeY]),[Z,Q]=(0,sh.useState)(()=>Y.map((e,t)=>{const n=kh(e,t,C,w,X);return{...n,viability:_?.(n,{negativeProperties:X,positiveProperties:G})??wh(n,G,X)}})),J=(0,sh.useRef)(Z),ee=(0,sh.useRef)(0),te=(0,sh.useRef)(new Map),ne=(0,sh.useRef)([]),ie=(0,sh.useRef)(g);ie.current=g;const re=(0,sh.useMemo)(()=>function(e){const{dataKey:t,gates:n,statesRef:i,processedGateVisitsRef:r}=e;return n.flatMap(e=>e.capacity&&e.capacity.unitsPerSecond>0?[Uu({id:`gauntlet-capacity-${t}-${e.id}`,regionId:"gauntlet-gate-"+e.id,unitsPerSecond:e.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:ah},maxQueue:e.capacity.maxQueue,queueLayout:e.capacity.queueLayout,queueSlotSpacing:e.capacity.queueSlotSpacing,queueStiffness:e.capacity.queueStiffness??24,releaseImpulse:{x:36,y:0},unitAccessor:t=>{const n=t.datum,r=n?.sourceDatum,o=e.capacity?.unitAccessor,s=i.current.find(e=>e.id===n?.projectId);let a;"function"==typeof o?a=s?o(s):void 0:o&&(a=r?.[o]);const c=Number(a??r?.reviewWork??r?.work??s?.metrics.reviewWork??r?.points);return Number.isFinite(c)&&c>0?c:1},onProcessed:t=>{const n=t.datum;if(!n?.projectId)return;const i=`${n.projectId}:${e.id}`;r.current.set(i,(r.current.get(i)??0)+1)}})]:[])}({dataKey:H,gates:V.gates,statesRef:J,processedGateVisitsRef:te}),[H,V.gates]),oe=(0,sh.useMemo)(()=>[...re,...u.controllers??[]],[re,u.controllers]),se=(0,sh.useRef)(Y);se.current=Y;const ae=(0,sh.useRef)(x);ae.current=x;const ce=(0,sh.useRef)({negativeById:X,positiveById:G,positiveProperties:w,stateAccessors:C,viability:_});ce.current={negativeById:X,positiveById:G,positiveProperties:w,stateAccessors:C,viability:_};const le=(0,sh.useCallback)((e,t,n=0)=>{const i=ce.current,r=kh(e,t,i.stateAccessors,i.positiveProperties,i.negativeById);return i.stateAccessors.startTimeAccessor||(r.startedAt=Math.max(0,n)),{...r,viability:i.viability?.(r,{negativeProperties:i.negativeById,positiveProperties:i.positiveById})??wh(r,i.positiveById,i.negativeById)}},[]);(0,sh.useEffect)(()=>{te.current.clear(),ne.current=[];const e=se.current.map((e,t)=>le(e,t));J.current=e,Q(e)},[le,H]),(0,sh.useEffect)(()=>{J.current=Z,ae.current?.(Z)},[Z]);const ue=(0,sh.useCallback)(e=>[...("function"==typeof l?l(e,V):l)??[]].sort((e,t)=>e.time-t.time),[l,V]),de=(0,sh.useCallback)((e,t,n)=>{if(!t.gateId||!U.get(t.gateId)?.capacity)return!0;const i=Number(t.gateVisit),r=Number.isFinite(i)&&i>0?Math.floor(i):n.filter(e=>e.gateId===t.gateId).findIndex(e=>e.id===t.id)+1;return r>0&&(te.current.get(`${e.id}:${t.gateId}`)??0)>=r},[U]),he=(0,sh.useCallback)(()=>{if(!re.length)return;const e=re.flatMap(e=>{const t=e.getSnapshot?.();return t?[t]:[]});var t,n;(t=ne.current).length===(n=e).length&&t.every((e,t)=>{const i=n[t];return!!i&&e.regionId===i.regionId&&e.queueDepth===i.queueDepth&&e.blockedDepth===i.blockedDepth&&e.processedCount===i.processedCount&&e.metricRevision===i.metricRevision})||(ne.current=e,ie.current?.(e))},[re]),fe=(0,sh.useMemo)(()=>Z.flatMap((e,t)=>{const n=bh(e,t,V,k);return Sh(e,t,V,n,G,X,i)}),[i,V,X,G,k,Z]),pe=(0,sh.useCallback)((e,t)=>{let n=!1;const i=J.current.map(i=>{if(i.id!==e)return i;const r=t(i);return n=n||r!==i,r});n&&(J.current=i,Q(i))},[]);(0,sh.useImperativeHandle)(t,()=>function(e){const{statesRef:t,setStates:n,elapsedRef:i,frameRef:r,layout:o,projectPlacement:s,positiveById:a,negativeById:c,coreBody:l,createState:u}=e;return{push:e=>{const d=u(e,t.current.length,i.current),h=bh(d,t.current.length,o,s),f=Sh(d,t.current.length,o,h,a,c,l),p=[...t.current,d];t.current=p,n(p),r.current?.pushMany(f),r.current?.step(0)},pushMany:e=>{const d=[...t.current],h=[],f=i.current;e.forEach(e=>{const t=u(e,d.length,f),n=bh(t,d.length,o,s);h.push(...Sh(t,d.length,o,n,a,c,l)),d.push(t)}),t.current=d,n(d),h.length&&r.current?.pushMany(h),r.current?.step(0)},remove:e=>{const i=Array.isArray(e)?e:[e],o=[],s=[];for(const e of i){const n=t.current.find(t=>t.id===e);n&&(o.push(n.datum),s.push(fh(n.id),...n.activePositiveIds.map(e=>ph(n.id,e))),n.negativeIds.forEach((e,t)=>{s.push(yh(n.id,e,t))}))}return t.current=t.current.filter(e=>!i.includes(e.id)),n(t.current),r.current?.remove(s),o},update:(e,d)=>{const h=Array.isArray(e)?e:[e],f=[];for(const e of h){const n=t.current.find(t=>t.id===e);if(!n)continue;const h=t.current.findIndex(t=>t.id===e);f.push(n.datum);const p=d(n.datum),y=u(p,0>h?t.current.length:h,n.startedAt??i.current),g=bh(y,0>h?t.current.length:h,o,s);r.current?.remove([fh(n.id),...n.activePositiveIds.map(e=>ph(n.id,e)),...n.negativeIds.map((e,t)=>yh(n.id,e,t))]),r.current?.pushMany(Sh(y,0>h?t.current.length:h,o,g,a,c,l)),t.current=t.current.map(t=>t.id===e?y:t)}return n(t.current),f},clear:()=>{t.current=[],n([]),r.current?.clear()},getData:()=>t.current.map(e=>e.datum),getScales:()=>null,getCustomLayout:()=>r.current?.snapshot()??null,popBodies:(e,t)=>r.current?.popBodies(e,t)??[]}}({statesRef:J,setStates:Q,elapsedRef:ee,frameRef:j,layout:V,projectPlacement:k,positiveById:G,negativeById:X,coreBody:i,createState:le}),[i,le,V,X,G,k]);const ye=(0,sh.useCallback)((e,t,n)=>{!function(e){const{project:t,effect:n,controls:i,layout:r,positiveById:o,negativeById:s,coreBody:a,popBodies:c}=e,l=i.readBodies().find(e=>e.id===fh(t.id)),u=i.readBodies(),d=l?.x??r.startX,h=l?.y??r.routeY,f=function(e,t){let n=-1;for(const i of t)Rh(i,e.id)&&(n=Math.max(n,Lh(i)));return Math.max(e.negativeIds.length,n+1)}(t,u),p=Mh(n.addNegative).flatMap((e,n)=>{const i=s.get(e);return i?[Ah(t,i,f+n,d,h,r)]:[]}),y=Mh(n.addPositive).flatMap(e=>{if(!o.get(e)||t.activePositiveIds.includes(e))return[];const n={...xh(r),routeY:h,socketY:h,startX:d,startY:h};return Sh({...t,activePositiveIds:[e],negativeIds:[]},0,r,n,o,s,a).filter(e=>e.id.includes(":positive:"))});(p.length||y.length)&&i.pushMany([...p,...y]);const g=_h(t,n);for(const e of g){const n=o.get(e);c([ph(t.id,e)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3})}const m=jh(t,n),x=function(e,t,n){const i=t.filter(t=>Rh(t,e.id)).sort((e,t)=>Lh(e)-Lh(t)||e.id.localeCompare(t.id)),r=new Set;return n.map(t=>{const n=i.find(e=>!r.has(e.id)&&e.datum.property?.id===t.propertyId);return n?(r.add(n.id),n.id):yh(e.id,t.propertyId,t.index)})}(t,u,m);m.forEach((e,t)=>{const n=s.get(e.propertyId);c([x[t]],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??7)+3})})}({project:e,effect:t,controls:n,layout:V,positiveById:G,negativeById:X,coreBody:i,popBodies:(e,t)=>j.current?.popBodies(e,t)})},[i,V,X,G]),ge=(0,sh.useCallback)(({body:e,bodies:t})=>function(e){const{body:t,bodies:n,layout:i,states:r,projectPlacement:o,positiveById:s,negativeById:a,projectEvents:c,gateById:l,coreForceMode:u,terminalBehavior:d,elapsed:h}=e,f=t.datum;if(!f?.__gauntlet)return null;const p=r.findIndex(e=>e.id===f.projectId),y=0>p?void 0:r[p];if(!y)return null;const g=bh(y,p,i,o),m=n.find(e=>e.id===fh(y.id)),x=y.negativeIds.reduce((e,t)=>e+(a.get(t)?.load??1),0),b=y.killed?0:58;if(f.kind!==ah){if(!m)return null;let e;const r=f.property;if(r?.target){const o=n.filter(e=>{const t=e.datum;return t?.__gauntlet&&t.projectId===y.id&&t.kind===f.kind}).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),s=Math.max(0,o.findIndex(e=>e.id===t.id));e=r.target({body:t,bodies:n,core:m,index:s,layout:i,placement:g,project:y})??{x:m.x,y:m.y}}else if(f.kind===ch&&f.property){const t=vh(y.activePositiveIds,f.property.id);e={x:m.x+Math.cos(t.angle)*t.radius,y:m.y+Math.sin(t.angle)*t.radius-2}}else{const i=n.filter(e=>e.datum?.kind===lh&&e.datum.projectId===y.id).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),r=Math.max(0,i.findIndex(e=>e.id===t.id)),o=Math.floor(r/4);e={x:m.x+18*(r%4-(Math.min(4,i.length-4*o)-1)/2),y:m.y+54+13*o}}const o="circle"===t.shape.type?t.shape.radius:8;e=gh(e.x,e.y,o,i);const s=gh(t.x,t.y,o,i);if(Math.abs(s.x-t.x)>.5||Math.abs(s.y-t.y)>.5)return{x:48*(s.x-t.x)-6*t.vx,y:48*(s.y-t.y)-6*t.vy};const a=f.kind!==ch||y.killed?0:3.2*(r?.buoyancy??r?.value??1),c=f.kind===lh?{x:.22*(r?.pull?.x??-8),y:.22*(r?.pull?.y??22)}:{x:0,y:0};return{x:28*(e.x-t.x)-3*(t.vx-m.vx)+c.x+.01*b,y:28*(e.y-t.y)-3*(t.vy-m.vy)+c.y-a}}if(y.killed)return{x:44*((y.crashX??y.metrics.lastX??t.x)-t.x)-9*t.vx,y:160+12*x-1.6*t.vy};const v=c(y),w=function(e,t,n,i,r,o,s){if(t.killed)return{x:t.metrics.lastX??i.graveyardX,y:i.graveyardY};const a=r[r.length-1];if(!a)return{x:i.socketX,y:i.routeY};const c=r.find(n=>e>=n.time&&!t.eventsApplied.includes(n.id)&&!(!n.gateId||!o.get(n.gateId)?.capacity)),l=c?Math.min(e,c.time):e,u="built"===t.outcome||"built_diminished"===t.outcome;if(l>a.time+.85){if("hold-last"===s){const e=a.gateId?o.get(a.gateId):void 0;return{x:a.routeX??e?.x??i.socketX,y:a.routeY??i.routeY}}return u?{x:i.socketX,y:i.socketY}:{x:i.graveyardX,y:i.graveyardY-14}}const d=.85*t.delay+12*t.negativeIds.length+8*(t.poppedPositiveIds.length+t.missingPositiveIds.length),h=[{time:0,x:i.startX,y:i.startY},...r.map(e=>{const t=e.gateId?o.get(e.gateId):void 0;return{time:e.time,x:e.routeX??t?.x??i.startX,y:e.routeY??i.routeY+.28*Math.min(180,d)}})].sort((e,t)=>e.time-t.time);let f=h[0],p=h[h.length-1];for(let e=1;h.length>e;e+=1){if(h[e].time>=l){p=h[e];break}f=h[e]}const y=Math.max(0,Math.min(1,(l-f.time)/Math.max(.1,p.time-f.time))),g=y*y*(3-2*y);return{x:f.x+(p.x-f.x)*g,y:f.y+(p.y-f.y)*g+7*Math.sin(2.6*l)}}(Math.max(0,h-(y.startedAt??0)),y,0,g,v,l,d),k=y.activePositiveIds.reduce((e,t)=>e+(s.get(t)?.buoyancy??s.get(t)?.value??1),0);return"net"===u?{x:15*(w.x-t.x)-1.8*t.vx+.18*b,y:1.25*(g.routeY-t.y)-1.4*t.vy+32*(x-k)}:{x:15*(w.x-t.x)-1.8*t.vx+.18*b,y:15*(w.y-t.y)-1.8*t.vy+13*x-2.2*k}}({body:e,bodies:t,layout:V,states:J.current,projectPlacement:k,positiveById:G,negativeById:X,projectEvents:ue,gateById:U,coreForceMode:r,terminalBehavior:P,elapsed:ee.current}),[r,U,V,X,G,ue,k,P]),me=(0,sh.useCallback)((e,t)=>{!function(e,t,n){const{frameProps:i,elapsedRef:r,statesRef:o,crashDetection:s,layout:a,projectEvents:c,gateById:l,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:f,positiveById:p,negativeById:y,outcome:g,reportCapacity:m}=n;i.onTick?.(e,t),r.current=e.elapsedSeconds??t.snapshot().elapsedSeconds,m();for(const e of o.current){const n=t.readBodies().find(t=>t.id===fh(e.id));if(!n)continue;if(s&&!e.killed&&n.y+("circle"===n.shape.type?n.shape.radius:28)>=a.crashY){t.readBodies().forEach(n=>{const i=n.datum;i?.__gauntlet&&i.projectId===e.id&&t.applyImpulse(n.id,-n.vx*n.mass,0)}),h(e.id,e=>{const t={appliedAt:Math.max(0,r.current-(e.startedAt??0)),id:"gauntlet-crash-line",label:"Crash Line",summary:"The project hit the crash threshold; lift and forward motion shut off.",time:Math.max(0,r.current-(e.startedAt??0))};return{...e,crashX:n.x,eventHistory:[...e.eventHistory??[],t],killed:!0,lastEvent:t,metrics:{...e.metrics,lastX:n.x},outcome:"bad_design_crash",stage:"Crash Line",viability:Math.min(0,e.viability)}});continue}if(e.killed)continue;const i=Math.max(0,r.current-(e.startedAt??0)),o=c(e),m=o.filter(t=>i>=t.time&&!e.eventsApplied.includes(t.id)&&u(e,t,o));let x=e;for(const n of m){const r=n.gateId?l.get(n.gateId):void 0,o=n.effects??[];for(const e of o){const i={event:n,gate:r,negativeProperties:y,positiveProperties:p,project:x};e.when&&!e.when(i)||(d(x,e,t),x=Ch(x,e,i))}const s={...Ih(n,o),appliedAt:i};x=Th(x,s),h(e.id,e=>{let t=Th(e,s);if(t===e)return e;for(const e of o)t=Ch(t,e,{event:n,gate:r,negativeProperties:y,positiveProperties:p,project:t});const i=f?.(t,{negativeProperties:y,positiveProperties:p})??wh(t,p,y);return t={...t,viability:i},n.final&&(t={...t,outcome:n.outcome??g?.(t,{layout:a,negativeProperties:y,positiveProperties:p})??(t.viability>20?"built":"approved_not_built")}),t})}}}(e,t,{frameProps:u,elapsedRef:ee,statesRef:J,crashDetection:o,layout:V,projectEvents:ue,gateById:U,capacityEventReady:de,addBodiesForEffect:ye,updateProjectState:pe,viability:_,positiveById:G,negativeById:X,outcome:b,reportCapacity:he})},[ye,de,o,u,U,V,X,b,G,ue,he,pe,_]),xe=(0,sh.useCallback)((e,t)=>{const n="function"==typeof u.bodyStyle?u.bodyStyle(e,t):u.bodyStyle,i=e.datum;return i?.__gauntlet?{fill:i.kind===ah?"var(--semiotic-accent, #0f766e)":i.property?.color??"var(--semiotic-accent, #38bdf8)",stroke:i.kind===ah?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[u]),be=(0,sh.useMemo)(()=>"function"==typeof n?n(Z,V):n??[],[n,V,Z]),ve=(0,sh.useMemo)(()=>be.flatMap(e=>{if(!1===e.semanticItem)return[];const t=e.semanticItem??{},n={id:e.id,label:e.label??e.id,description:e.description,datum:e.datum,group:e.group??e.state??"body group",x:e.x??0,y:e.y??0,width:e.width,height:e.height};return[{...n,...t,id:t.id??n.id}]}),[be]),we=(0,sh.useMemo)(()=>R?function(e,t){if(!e.length)return[];const n=Math.max(40,(t.width-80)/e.length);return e.map((e,t)=>{const i=`${e.id}: viability ${Math.round(e.viability)}, ${e.outcome||e.stage}`;return{id:"gauntlet-projection-"+e.id,label:i,description:i,datum:e,x:40+(t+.5)*n,y:28,shape:"rect",width:Math.max(16,.55*n),height:22,group:"settled projection"}})}(Z,V):[],[V,R,Z]),ke=(0,sh.useMemo)(()=>[...we,...ve],[ve,we]),Se=(0,sh.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]),Ae=(0,sh.useCallback)((e,t)=>{m&&m(e&&"object"==typeof e&&e.__gauntlet?e.sourceDatum:e,{x:t.x,y:t.y})},[m]);if(q)return q;const Me=th(e.tooltip,u),Pe=nh(e,u,ke,{chartMode:z,className:$,title:E,description:N,summary:O,accessibleTable:W,enableHover:F,margin:D}),_e=R?(0,Oh.jsx)(Nh,{states:Z,layout:V}):void 0,je=eh(L?(0,Oh.jsx)(Bh,{layout:V,states:Z}):void 0,u.backgroundGraphics),Ce=eh(_e,u.foregroundGraphics),Ie=u.renderBody??zh,Te=Me.tooltipContent??Eh;return Jd("GauntletChart",T,(0,Wh.createElement)(qd,{...u,...Me,...Pe,key:`${T[0]}x${T[1]}:${H}`,ref:j,accessibleTable:e.accessibleTable??u.accessibleTable,backgroundGraphics:je,bodyForces:ge,bodySemanticItems:u.bodySemanticItems??Fh,bodyStyle:xe,beforePaint:(e,t)=>{u.beforePaint?.(e,t),M&&function(e,t){const n=new Map(t.filter(e=>e.datum?.kind===ah).map(e=>[e.datum.projectId,e]));e.save(),e.lineWidth=1.1,e.setLineDash([3,4]);for(const i of t){const t=i.datum;if(!t?.__gauntlet||t.kind===ah)continue;const r=n.get(t.projectId);r&&(e.globalAlpha=t.kind===lh?.24:.36,e.strokeStyle=t.kind===lh?"#d94a45":"#7a8794",e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(i.x,i.y),e.stroke())}e.restore()}(e,t)},onClick:m?Ae:Pe.onClick,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7,...u.config?.kernel??{}},colliders:[...uh(V),...u.config?.colliders??[]]},controllers:oe,enableHover:Me.enableHover??!0,foregroundGraphics:Ce,hoverRadius:e.hoverRadius??u.hoverRadius??18,initialSpawns:fe,initialSpawnPacing:h,onBodyPointerDown:Se,onTick:me,paused:v,regionEffects:[...K,...u.regionEffects??[]],renderBody:Ie,responsiveHeight:S,responsiveWidth:A,size:T,tooltipContent:Te}))}).displayName="GauntletChart";var Hh={Sparkline:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,colorScheme:n,lineStyle:r.lineStyle,...i})},AreaChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"area",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||t,colorAccessor:t,colorScheme:n,...i})},DifferenceChart:Ua,StackedAreaChart:Ka,Scatterplot:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,colorScheme:n,...i})},CandlestickChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"candlestick",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,...i})},BubbleChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:n,...i})},ConnectedScatterplot:Qa,QuadrantChart:Za,Heatmap:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"heatmap",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:n||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor,...i})},XYCustomChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"custom",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:i.showAxes??!1})},BarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,colorAccessor:t,colorScheme:n,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:t||r.stackBy,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"clusterbar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:t||r.groupBy,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},PieChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"pie",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:t||r.categoryAccessor,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i})},DonutChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"donut",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:t||r.categoryAccessor,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i})},Histogram:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"histogram",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:t,colorScheme:n,...i})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"boxplot",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:n,...i})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"violin",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:n,...i})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"swarm",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...i})},DotPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"point",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...i,showGrid:i.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"swimlane",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:t||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",...i})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"ridgeline",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude,...i})},LikertChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:t||r.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal",...i})},FunnelChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>{const o="vertical"===r.orientation;return{chartType:o?"bar-funnel":"funnel",data:e,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:t||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:o?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,barPadding:o?40:0,showAxes:o,showGrid:o,colorScheme:n,...i}}},GaugeChart:rc,OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"custom",data:e,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:i.showAxes??!1})},ForceDirectedGraph:vc,NetworkCustomChart:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"force",nodes:r.nodes||e||[],edges:r.edges||[],nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor||"id",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",valueAccessor:r.valueAccessor||"value",colorBy:t,colorScheme:n,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...i})},SankeyDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:t,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:n,...i})},ProcessSankey:wc,ChordDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:t,edgeColorBy:r.edgeColorBy,colorScheme:n,...i})},TreeDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"cluster"===r.layout?"cluster":"tree",data:e,childrenAccessor:r.childrenAccessor,colorBy:t,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:n,...i})},Treemap:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"treemap",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:n,...i})},CirclePack:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"circlepack",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,colorScheme:n,...i})},ChoroplethMap:{frameType:"geo",buildProps:(e,t,n,i,r)=>({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:n||"blues",graticule:r.graticule,fitPadding:r.fitPadding,...i})},ProportionalSymbolMap:{frameType:"geo",buildProps:(e,t,n,i,r)=>({points:e||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:t,colorScheme:n,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...i})},FlowMap:kc,GeoCustomChart:{frameType:"geo",buildProps:(e,t,n,i,r)=>({points:r.points||e||[],areas:r.areas||[],lines:r.lines||[],projection:r.projection||"equirectangular",xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",lineDataAccessor:r.lineDataAccessor,colorBy:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s=r.bins??21,a=r.seed??1,c=Math.max(1,Math.round(r.pegRows??s-1)),l="mechanical"===r.mode,u=l?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),i=Math.max(1,Math.round(e.count??Math.max(64,4*t))),r=Cc(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),o=Rc(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:i},(e,t)=>{let i=0;for(let e=0;n>e;e+=1)o()<r&&(i+=1);const a=n/2;return{id:`${s}-${t}`,value:i,mechanical:!0,pegRows:n,branchProbability:r,pathRights:i,side:a>i?"left":i>a?"right":"center"}})}({bins:s,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],d=function(e){const{data:t,valueAccessor:n,bins:i,ballRadius:r,seed:o,size:s,valueExtent:a}=e,c=Sc(s),l=t.map((e,t)=>jc(_c(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=jc(e[0]),n=jc(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),f=h===d?1:h-d,p=(0,Lc.scaleLinear)().domain([0,i]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:i},()=>0),g=[];t.forEach((e,t)=>{const o=jc(_c(e,t,n));if(null==o)return;const s=Math.max(0,Math.min(i-1,Math.floor((o-d)/f*i)));y[s]+=1,g.push({id:(e.id??"galton-"+t)+"",x:p(s+.5),y:c.plot.y+r+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...e,value:o,bin:s}})});const m=c.plot.y+c.plot.height;return{config:Pc(o,[...jl({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Cl({idPrefix:"galton-bin",count:i,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:i,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:r.valueAccessor||"value",bins:s,ballRadius:r.ballRadius??4,seed:a,size:o,valueExtent:l?[0,c]:void 0});return{...i,config:d.config,initialSpawns:Yh(d.initialSpawns),projectionRows:d.projectionRows,bodyStyle:Mc(t||r.colorBy||(l?"side":void 0))}}},EventDropChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s=function(e){const{data:t,timeAccessor:n,arrivalAccessor:i,windows:r,watermark:o,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=e,d=Sc(c),h=t.map((e,t)=>jc(_c(e,t,n))).filter(e=>null!=e),f=jc(l?.[0]),p=jc(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):y+r.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/r.size)*r.size,v=Math.max(1,Math.ceil((x-b+r.size)/r.size)),w=h.length?Math.max(...h):0,k="function"==typeof o?o(w):jc(o?.value)??w-(o?.delay??r.size),S=Math.max(0,Math.min(v,Array.from({length:v},(e,t)=>t).reduce((e,t)=>b+(t+1)*r.size>k?e:e+1,0))),A=function(e,t){const n=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:n,height:e.plot.height},windowPlot:{x:e.plot.x+n,y:e.plot.y,width:Math.max(40,e.plot.width-n),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,s),M=b+v*r.size,P=(0,Nl.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),_=Array.from({length:v},()=>({value:0,secondary:0})),j=[];t.forEach((e,t)=>{const o=jc(_c(e,t,n));if(null==o)return;const a=jc(_c(e,t,i))??o,c=Math.max(0,Math.min(v-1,Math.floor((o-b)/r.size))),l=k>=b+(c+1)*r.size;_[c].value+=l?0:1,_[c].secondary+=l?1:0,j.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,P(o))),y:d.plot.y+s+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...e,eventTime:o,arrivalTime:a,windowIndex:c,late:l}})});const C=d.plot.y+d.plot.height,I=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const i=e.windowStart,r=e.windowStart+e.windowCount*e.windowSize,o=(0,Nl.scaleLinear)().domain([i,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=o(e.windowStart+n*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,i=n+e.windowSize,r=o(n),s=o(i);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:r.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Pc(a,[...jl({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Ol({idPrefix:"eventdrop-window",count:v,xScale:e=>P(b+e*r.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?I[0]?.y1:I[e-1]?.y2??I[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:C,wallThickness:6}),...I.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:j,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:_.map((e,t)=>({label:`${b+t*r.size}-${b+(t+1)*r.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:I,lateCount:_.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:r.size,windowStart:b}}}({data:Array.isArray(e)?e:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:o,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy)}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s="mechanical"===r.mode,a=function(e){const{data:t,categoryAccessor:n,valueAccessor:i,unitValue:r,ballRadius:o,seed:s,size:a}=e,c=Ic(r,1),l=Sc(a),u=[],d=new Map,h=new Map,f=[];function p(e){let t=d.get(e);return null==t&&(t=u.length,u.push(e),d.set(e,t)),t}t.forEach((e,t)=>{p((_c(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(e,t,n){const i=e.width/Math.max(1,t),r=Math.max(2,2*n),o=Math.min(.7*i,Math.max(3.2*r,r+8)),s=Math.max(1,Math.floor(o/r));return{laneWidth:i,tubeWidth:o,ballDiameter:r,perRow:s,centerX:t=>e.x+(t+.5)*i,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*r}}(l.plot,y,o),m=Math.max(0,g.tubeWidth/2-o-1),x=u.map(()=>[]);t.forEach((e,t)=>{const r=(_c(e,t,n)??"unknown")+"",s=p(r),a=i?jc(_c(e,t,i)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let n=0;u>n;n+=1){const i=h.get(r)??0,a=g.perRow>1?((g.perRow>1?i%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(r,i+1),x[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+a,y:l.plot.y+o+2,vx:(n%3-1)*o/2,vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,category:r,unitIndex:n}})}});const b=x.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;b>e;e+=1)for(const t of x)t.length>e&&f.push(t[e]);const v=l.plot.y+l.plot.height,w=[...jl({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let e=0;y>e;e+=1){const t=g.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:Pc(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}({data:s?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),n=t.length?t:["Intake"],i=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),r=Ic(e.unitValue,1),o=Rc(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*o()),c=a.reduce((e,t)=>e+t,0)||1,l=i-n.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=i-d.reduce((e,t)=>e+t,0);const f=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%f.length)d[f[e].index]+=1,h-=1;return n.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*r,mechanical:!0,unitCount:d[t],unitValue:r,share:d[t]/i}))}({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(s?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:o});return{...i,config:a.config,initialSpawns:Yh(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:Mc(t||r.colorBy||(s?"category":void 0))}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,360],s=function(e){const{data:t,xAccessor:n,groupAccessor:i,radiusAccessor:r,pointRadius:o,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=Sc(a),h=Rc(s),f=[],p=[],y=new Map;t.forEach((e,t)=>{const s=jc(_c(e,t,n));if(null==s)return;const a=i?(_c(e,t,i)??"All")+"":"All",c=r?jc(_c(e,t,r)):null,l=Cc(null!=c&&c>0?c:o,2,18);!function(e){let t=y.get(e);null==t&&(t=p.length,p.push(e),y.set(e,t))}(a),f.push({datum:e,index:t,value:s,group:a,radius:l})});const g=f.map(e=>e.value),m=c?jc(c[0]):null,x=c?jc(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const e=k;k=w,w=e}const S=Math.max(o,...f.map(e=>e.radius)),A=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,P=(0,Wl.scaleLinear)().domain([w,k]).range([A,M]),_=Math.max(1,p.length),j=d.plot.y+Math.max(28,3*S),C=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-j),I=e=>{const t=y.get(e)??0;return 1===_?d.plot.y+.54*d.plot.height:j+t/(_-1)*C},T=new Map,R=f.map((e,t)=>{T.set(e.group,(T.get(e.group)??0)+1);const n=P(e.value),i=I(e.group),r=(h()-.5)*e.radius*1.6,o=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+r:Cc(n+(t%9-4)*e.radius*2.5,A,M),y:u?i+o:d.plot.y-18-t%12*e.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:i},springs:[{target:{type:"point",x:n,y:i},restLength:0,stiffness:34,damping:5.5}]}});return{config:Pc(s,jl({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:R,projectionRows:p.map(e=>({label:e,value:T.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(e=>({label:e,y:I(e),count:T.get(e)??0})),plot:d.plot}}}({data:Array.isArray(e)?e:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:o,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy||r.groupAccessor)}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[900,420],s=Array.isArray(r.stages)?r.stages:[],a=eu({data:Array.isArray(e)?e:[],stages:s,size:o,idAccessor:r.idAccessor,stageAccessor:r.stageAccessor||"stage",groupBy:r.groupBy,groupLabelAccessor:r.groupLabelAccessor,workAccessor:r.workAccessor,radiusAccessor:r.radiusAccessor,ballRadius:r.ballRadius??6,seed:r.seed??1,groupCompletion:r.groupCompletion,groupAnchorAlong:r.groupAnchorAlong,settle:r.settle??!0,gravityX:r.gravityX,gravityY:r.gravityY}),c=a.metadata;return{...i,config:a.config,initialSpawns:Yh(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:Mc(t||r.colorBy||r.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[900,520],s=function(e){const t=mh(e.size??[900,520],e.gates,e.crashOffset??30),n=e.positiveProperties??[],i=new Map(n.map(e=>[e.id,e])),r=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),o={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=kh(t,s,o,n,r);return{...a,viability:e.viability?.(a,{negativeProperties:r,positiveProperties:i})??wh(a,i,r)}}).flatMap((n,o)=>{const s=bh(n,o,t,e.projectPlacement);return Sh(n,o,t,s,i,r,e.coreBody)});return{layout:t,initialSpawns:s,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:uh(t)}}}({data:Array.isArray(e)?e:[],size:o,gates:r.gates,positiveProperties:r.positiveProperties,negativeProperties:r.negativeProperties,crashOffset:r.crashOffset,idAccessor:r.idAccessor,positiveAccessor:r.positiveAccessor,negativeAccessor:r.negativeAccessor,metricsAccessor:r.metricsAccessor,initialViability:r.initialViability,projectPlacement:r.projectPlacement,coreBody:r.coreBody,viability:r.viability});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:[],bodyStyle:Mc(t||r.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[760,420],s=function(e){const{coordinateMode:t,flowSpeed:n,links:i,maxParticles:r,nodeIdAccessor:o,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=e,b=Sc(y),v=Rc(p),w=new Map,k=new Map,S=[];function A(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof o){const e=o(t,0);if(null!=e)return e+""}if("string"==typeof o&&null!=t[o])return t[o]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}c.forEach((e,t)=>{const n=(_c(e,t,o)??e.id??t)+"",i=jc(_c(e,t,s)),r=jc(_c(e,t,a));if(null!=i&&null!=r){const e={x:i,y:r};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const M=[];i.forEach((e,t)=>{const n=A(_c(e,t,g)),i=A(_c(e,t,m)),r=Math.max(0,jc(_c(e,t,x))??0),o=Yl(d?_c(e,t,d):void 0),s=o.length?o:Yl(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${i}-${t}`)+"",link:e,index:t,source:n,target:i,throughput:r,rawPath:s})});const P=(j=S,"normalized"===(_=t)||"pixels"===_?_:j.length>0&&j.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var _,j;const C=new Map;for(const[e,t]of w)C.set(e,Hl(t,b,P));const I=[];for(const e of M){let t=e.rawPath.map(e=>Hl(e,b,P));if(2>t.length){const n=C.get(e.source),i=C.get(e.target);n&&i&&(t=[n,i])}else C.has(e.source)||C.set(e.source,t[0]),C.has(e.target)||C.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(k.has(e.source)||k.set(e.source,e.source),k.has(e.target)||k.set(e.target,e.target),I.push({...e,path:t,packetCount:0}))}const T=Ic(u,.12),R=Math.max(1,Math.round(r)),L=I.map(e=>Math.max(1,Math.round(e.throughput*T))),$=L.reduce((e,t)=>e+t,0),E=$>R?R/$:1;I.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(L[t]*E))});let z=I.reduce((e,t)=>e+t.packetCount,0);for(;z>R;){const e=I.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>I[e].packetCount)?n:e,-1);if(-1===e)break;I[e].packetCount-=1,z-=1}const D=new Map,B=new Map,F=[],N=Ic(n,90),O=Ic(l,4);I.forEach((e,t)=>{D.set(e.target,(D.get(e.target)??0)+e.throughput),B.set(e.source,(B.get(e.source)??0)+e.throughput);const n=Gl(e.path);for(let i=0;e.packetCount>i;i+=1){const r=(i+.5)/e.packetCount,o=f?r:Cc(.12+.84*r+.04*(v()-.5),.04,.98),s=f?o:Math.max(0,o-(.18+.12*v())),a=Xl(e.path,s),c=Xl(e.path,o),l=Vl(e.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*O*1.5;F.push({id:`${e.id}-packet-${i}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*N+10*(v()-.5),vy:f?0:l.y*N+10*(v()-.5),mass:.8,spawnAt:f?0:.04*t+i/32,shape:{type:"circle",radius:O},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:i,packetCount:e.packetCount,routeProgress:o,flowPath:e.path,flowPathLength:n,flowRouteId:e.id,flowSpeed:N,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*O,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*O),q=Array.from(C,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+Tc(e),point:t})),Y=q.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),H=Object.fromEntries(q.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=Pc(p,[...jl({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...Y],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*O),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=R,G.eviction="oldest",G.observation={...G.observation,sensors:H};const X=Array.from(C,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Tc(e),incoming:D.get(e)??0,outgoing:B.get(e)??0})),V=I.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:F,projectionRows:X.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:P,particleCount:F.length,totalThroughput:I.reduce((e,t)=>e+t.throughput,0),plot:b.plot,nodes:X,links:V}}}({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(e)?e:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:o});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[700,380],s=oh({chartId:r.chartId,colorScheme:n,config:r.config,data:Array.isArray(e)?e:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:xe(we)??{},size:o,themeCategorical:we.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Mc(t||r.colorBy)}}}};function Gh(e){if(!e)return we;if("string"==typeof e){if("light"===e)return we;if("dark"===e)return ke;if("high-contrast"===e)return Se;return ga[e]||we}const t="dark"===e.mode?ke:we;return be({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}})}function Xh(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function Vh(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Uh(e){if(!e||2>e.length)return;const t=Vh(e[0]),n=Vh(e[e.length-1]);return null!==t&&null!==n?[t,n]:void 0}function Kh(e){const{count:t,byType:n}=function(e){const t={};for(const n of e){const e="string"==typeof n?.type&&n.type.length>0?n.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,r=[...e.extraWarnings??[]];return i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:n,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:r}}var Zh=c(require("react")),Qh=c(require("react-dom/server")),Jh=require("d3-scale"),ef=require("react/jsx-runtime"),tf=14,nf=20,rf=6,of=8;function sf(e){return"left"===e?"start":"right"===e?"end":e??"start"}function af(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function cf(e,t,n,i){const r=af(i);return t+n+Math.ceil(e.length*r*.58)}function lf(e){const{categories:t,theme:n,position:i="right",totalWidth:r,totalHeight:o,margin:s,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??tf),l=Math.max(0,a?.labelGap??rf),u=Math.max(0,a?.itemGap??of),d=Math.max(c,a?.rowHeight??nf),h=c+l,f=Math.min(2,c/2),p="top"===i||"bottom"===i,y=Math.max(c,r-s.left-s.right),g=Math.max(d,o-s.top-s.bottom),m=t.map(e=>cf(e,c,l,n));if(p){const e=Math.max(c,a?.maxWidth??y),n=[];let i=0,r=0;m.forEach((t,o)=>{const s=0===r?t:r+u+t;r>0&&s>e?(n.push({start:i,end:o,width:r}),i=o,r=t):r=s}),t.length>0&&n.push({start:i,end:t.length,width:r});const o=sf(a?.align),s=[];return n.forEach((n,i)=>{let r="center"===o?Math.max(0,(e-n.width)/2):"end"===o?Math.max(0,e-n.width):0;for(let e=n.start;n.end>e;e++)s.push({category:t[e],width:m[e],x:r,y:i*d}),r+=m[e]+u}),{items:s,width:Math.max(0,...n.map(e=>e.width)),height:n.length*d,swatchSize:c,labelOffset:h,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/d)),v=Math.max(1,Math.ceil(t.length/b));return{items:t.map((e,t)=>({category:e,width:m[t],x:Math.floor(t/b)*(x+u),y:t%b*d})),width:v*x+Math.max(0,v-1)*u,height:Math.min(t.length,b)*d,swatchSize:c,labelOffset:h,swatchRadius:f}}function uf(e){const{legendGroups:t,theme:n,position:i="right",totalWidth:r,totalHeight:o,margin:s,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??tf),l=Math.max(0,a?.labelGap??rf),u=Math.max(0,a?.itemGap??of),d=Math.max(c,a?.rowHeight??nf),h=c+l,f=Math.min(2,c/2),p=Math.max(12,af(n)),y="top"===i||"bottom"===i,g=Math.max(c,r-s.left-s.right),m=Math.max(d,o-s.top-s.bottom);if(y){const i=Math.max(c,a?.maxWidth??g),r=sf(a?.align);let o=0,s=0;const l=[];for(const r of t){const t=r.items.map(e=>e.label),u=lf({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(c,i-p-8),align:"start"}}),d=r.label?p:0,h=r.label?cf(r.label,0,0,n):0,f=d>0?d+8:0,y=f+u.width,g=Math.max(u.height,h);l.push({group:r,x:o,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),o+=y+12,s=Math.max(s,g)}const u=l.length>0?o-12:0,d=u>i?0:"center"===r?Math.max(0,(i-u)/2):"end"===r?Math.max(0,i-u):0;return{groups:l.map(e=>({...e,x:e.x+d})),width:u,height:s,swatchSize:c,labelOffset:h,swatchRadius:f}}let x=0,b=0;const v=[];for(const e of t){const t=e.items.map(e=>e.label).map(e=>cf(e,c,l,n)),i=Math.max(0,...t),r=Math.max(1,Math.min(e.items.length||1,Math.max(1,Math.floor(Math.max(d,m-x)/d)))),o=Math.max(1,Math.ceil(e.items.length/r)),s=e.items.map((e,n)=>({category:e.label,width:t[n],x:Math.floor(n/r)*(i+u),y:n%r*d})),a=o*i+Math.max(0,o-1)*u,h=Math.min(e.items.length,r)*d,f=e.label?cf(e.label,0,0,n):0,y=e.label?p+8:0,g=y+h+12,w=Math.max(a,f);v.push({group:e,x:0,y:x,itemOffsetX:0,itemOffsetY:y,width:w,height:g,items:s}),b=Math.max(b,w),x+=g}return{groups:v,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:h,swatchRadius:f}}function df(e){const t="top"===e.position||"bottom"===e.position,n=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??n,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function hf(e){const{categories:t,colorScheme:n,theme:i,position:r="right",totalWidth:o,totalHeight:s,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=function(e,t,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>E(e,t)??"#999"}const i=Array.isArray(t)?t:n.colors.categorical.length>0?n.colors.categorical:g;return(0,Jh.scaleOrdinal)().domain(e).range(i)}(t,n,i),u="top"===r||"bottom"===r,d=lf(e);let h,f;if("left"===r?(h=Math.max(4,a.left-d.width-10),f=a.top):"top"===r?(h=a.left,f=c?32:8):"bottom"===r?(h=a.left,f=Math.min(s-a.bottom+38,s-d.height-2)):(h=Math.min(o-d.width-4,o-a.right+10),f=a.top),u){const e=d.items.map((e,t)=>(0,ef.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,ef.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),(0,ef.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:af(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${h},${f})`,children:e})}const p=d.items.map((e,t)=>(0,ef.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,ef.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),(0,ef.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:af(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${h},${f})`,children:p})}function ff(e,t){if(!t||!e||0===e.length)return[];const n="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=n(t);null!=e&&i.add(e+"")}return Array.from(i)}var pf=require("react/jsx-runtime");function yf(e,t){return e.color||t.colors.annotation||t.colors.text}function gf(e,t,n){return null!=e.x&&t.x?t.x(e.x):n&&null!=e[n]&&t.x?t.x(e[n]):"number"==typeof e.x?e.x:null}function mf(e,t,n){return null!=e.y&&t.y?t.y(e.y):n&&null!=e[n]&&t.y?t.y(e[n]):"number"==typeof e.y?e.y:null}function xf(e){const{annotations:t}=e;if(!t||0===t.length)return null;const n=e.autoPlaceAnnotations?Mr({annotations:t,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):t,i=[];for(let t=0;n.length>t;t++){const r=bf(n[t],t,e);r&&i.push({node:r,annotation:n[t]})}const r=Ui(i);return r.length>0?(0,pf.jsx)("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function bf(e,t,n){const{scales:i,layout:r,theme:o,xAccessor:s,yAccessor:a}=n;switch(e.type){case"y-threshold":{const s=e.value;if(null==s)return null;const a=yf(e,o),c=e.label,l=e.labelPosition||"right",u=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===n.projection&&i.r){const n=i.r(s);return null==n?null:(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("line",{x1:n,y1:0,x2:n,y2:r.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,pf.jsx)("text",{x:n+4,y:12,textAnchor:"start",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,children:c})]},"ann-ythresh-"+t)}const h=i.y?i.y(s):i.r?i.r(s):null;return null==h?null:(0,pf.jsxs)("g",{children:[(0,pf.jsx)("line",{x1:0,y1:h,x2:r.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,pf.jsx)("text",{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,children:c})]},"ann-ythresh-"+t)}case"x-threshold":{const n=e.value;if(null==n||!i.x)return null;const s=i.x(n);if(null==s)return null;const a=yf(e,o),c=e.label,l=e.labelPosition||"top";return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("line",{x1:s,y1:0,x2:s,y2:r.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&(0,pf.jsx)("text",{x:s>.6*r.width?s-4:s+4,y:"bottom"===l?r.height-4:"center"===l?r.height/2:12,textAnchor:s>.6*r.width?"end":"start",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:c})]},"ann-xthresh-"+t)}case"band":{const n=null!=e.y0&&i.y?i.y(e.y0):null,s=null!=e.y1&&i.y?i.y(e.y1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=e.fill||yf(e,o);return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("rect",{x:0,y:a,width:r.width,height:c,fill:l,fillOpacity:e.fillOpacity??.1}),e.label&&(0,pf.jsx)("text",{x:r.width-4,y:Math.max(a,0)+13,textAnchor:"end",fontSize:o.typography.tickSize,fill:e.color||yf(e,o),fontFamily:o.typography.fontFamily,fontWeight:"bold",stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-band-"+t)}case"x-band":{const n=null!=e.x0&&i.x?i.x(e.x0):null,s=null!=e.x1&&i.x?i.x(e.x1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=e.fill||yf(e,o);return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("rect",{x:a,y:0,width:c,height:r.height,fill:l,fillOpacity:e.fillOpacity??.1}),e.label&&(0,pf.jsx)("text",{x:a+4,y:13,textAnchor:"start",fontSize:o.typography.tickSize,fill:e.color||yf(e,o),fontFamily:o.typography.fontFamily,fontWeight:"bold",stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-xband-"+t)}case"category-highlight":{if(!e.category||!i.o)return null;const s=i.o(e.category);if(null==s)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=yf(e,o),l=e.opacity??.1;return(0,pf.jsx)("rect","horizontal"===n.projection?{x:0,y:s,width:r.width,height:a,fill:c,opacity:l}:{x:s,y:0,width:a,height:r.height,fill:c,opacity:l},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:r}=function(e,t,n,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const n=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:gf(e,t,n),y:mf(e,t,i)}}(e,i,s,a);if(null==n||null==r)return null;const c="text"===e.type,l=e.dx??(c?0:30),u=e.dy??(c?0:-30),d=e.color||o.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,o="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return(0,pf.jsx)(Ai,{noteData:{x:n,y:r,dx:l,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...o?{subject:o}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return(0,pf.jsx)("g",{children:(0,pf.jsx)("text",{x:n+l,y:r+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||o.typography.labelSize,fill:d,fontFamily:o.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}var vf=require("react/jsx-runtime");function wf(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function kf(e,t){if(0===t.categories.length)return;const n=t.position||"right",i=function(e){const{width:t,height:n,swatchSize:i}=lf(e);return{width:t,height:n,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout});"right"===n?e.right=Math.max(e.right,i.width+14):"left"===n?e.left=Math.max(e.left,i.width+14):"top"===n?e.top=Math.max(e.top,(t.hasTitle?32:8)+i.height+4):e.bottom=Math.max(e.bottom,38+i.height+4)}function Sf(e,t){const n=t.position||"right",i={theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},r=oi(t.legend)?function(e){const{width:t,height:n,swatchSize:i}=uf(e);return{width:t,height:n,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):si(t.legend)?df({...i,gradient:t.legend.gradient}):null;r&&("right"===n?e.right=Math.max(e.right,r.width+14):"left"===n?e.left=Math.max(e.left,r.width+14):"top"===n?e.top=Math.max(e.top,(t.hasTitle?32:8)+r.height+4):e.bottom=Math.max(e.bottom,38+r.height+4))}function Af(e,t){const n={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix};return oi(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,n)=>({group:e,item:t,itemIndex:n,label:t.label})))).length)return null;var t;const n=uf(e),i="top"===e.position||"bottom"===e.position,r=e.theme.colors.grid||e.theme.colors.textSecondary;let o,s;"left"===e.position?(o=Math.max(4,e.margin.left-n.width-10),s=e.margin.top):"top"===e.position?(o=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(o=e.margin.left,s=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-n.height-2)):(o=Math.min(e.totalWidth-n.width-4,e.totalWidth-e.margin.right+10),s=e.margin.top);const a=n.groups.flatMap((t,o)=>{const{group:s}=t,a=s.type??"fill",c=[];if(s.label&&c.push((0,ef.jsx)("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label}:{x:t.x,y:t.y+af(e.theme),fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label},"legend-group-label-"+o)),c.push(...t.items.map((i,r)=>{const c=s.items[r],l=s.styleFn(c,r),u="function"==typeof a?a(c):"line"===a?(0,ef.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:l}):(0,ef.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:l});return(0,ef.jsxs)("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[u,(0,ef.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${o}-${r}`)})),!i&&n.groups.length-1>o)c.push((0,ef.jsx)("line",{x1:0,y1:t.y+t.height-6,x2:n.width,y2:t.y+t.height-6,stroke:r},"legend-group-separator-"+o));else if(i&&n.groups.length-1>o){const e=t.x+t.width+6;c.push((0,ef.jsx)("line",{x1:e,y1:0,x2:e,y2:n.height,stroke:r},"legend-group-separator-"+o))}return c});return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${o},${s})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...n,legendGroups:e.legendGroups}):si(e)?function(e){const t=df(e),n="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=e.gradient.format||(e=>Math.round(100*e)/100+"");let o,s;"left"===e.position?(o=Math.max(4,e.margin.left-t.width-10),s=e.margin.top):"top"===e.position?(o=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(o=e.margin.left,s=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-t.height-2)):(o=Math.min(e.totalWidth-t.width-4,e.totalWidth-e.margin.right+10),s=e.margin.top);const a=Array.from({length:17},(t,i)=>{const r=i/16;return(0,ef.jsx)("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(n?e.gradient.domain[0]+r*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-r*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(n){const n=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return(0,ef.jsxs)("g",{className:"semiotic-legend",transform:`translate(${o},${s})`,children:[(0,ef.jsx)("defs",{children:(0,ef.jsx)("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&(0,ef.jsx)("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,ef.jsx)("rect",{x:0,y:l,width:t.width,height:n,fill:`url(#${i})`,rx:2}),(0,ef.jsx)("text",{x:0,y:l+n+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])}),(0,ef.jsx)("text",{x:t.width,y:l+n+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return(0,ef.jsxs)("g",{className:"semiotic-legend",transform:`translate(${o},${s+(e.gradient.label?12:0)})`,children:[(0,ef.jsx)("defs",{children:(0,ef.jsx)("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&(0,ef.jsx)("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,ef.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),(0,ef.jsx)("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])}),(0,ef.jsx)("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}function Mf(e){return Math.round(100*e)/100+""}function Pf(e,t){const n=Xh(t.theme),i=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,o=r?i+"semiotic-title":void 0,s=t.description?i+"semiotic-desc":void 0,a=[o,s].filter(Boolean).join(" ")||void 0;return(0,vf.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":a,style:{fontFamily:n.fontFamily},children:[r&&(0,vf.jsx)("title",{id:o,children:r}),t.description&&(0,vf.jsx)("desc",{id:s,children:t.description}),t.defs&&(0,vf.jsx)("defs",{children:t.defs}),t.background&&"transparent"!==t.background&&(0,vf.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:t.background}),(0,vf.jsx)("g",{id:i+"data-area",transform:t.innerTransform,children:e}),r&&(0,vf.jsx)("text",{id:i+"chart-title",x:t.width/2,y:16,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:r}),t.legend&&(0,vf.jsx)("g",{id:i+"legend",children:t.legend}),t.outerElements]})}var _f=require("react/jsx-runtime");function jf(e,t){const n=Gh(e.theme),i=e.size||[500,300],r={top:20,right:20,bottom:30,left:40,...e.margin},o=B(e.data),s=e.showLegend?ff(o,e.colorAccessor||e.groupAccessor):[],a=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&s.length>0&&kf(r,{categories:s,colorScheme:e.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d=e.colorScheme||n.colors.categorical,h={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:u?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:d,themeCategorical:n.colors.categorical,themeSemantic:xe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new Ot(h);if(e.data&&f.ingest({inserts:o,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=Kh({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),Qh.renderToStaticMarkup(Pf(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));t&&(t.evidence=Kh({frameType:"xy",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:Uh(f.scales.x?.domain?.()),yDomain:Uh(f.scales.y?.domain?.()),legendItems:s.length>0?s.length:void 0}));const p=e._idPrefix,y=e.showGrid?function(e,t,n,i){const{grid:r}=Xh(n),o=i?i+"-":"",s=e.x.ticks(5),a=e.y.ticks(5);return(0,vf.jsxs)("g",{id:o+"grid",className:"semiotic-grid",opacity:.8,children:[s.map((n,i)=>{const o=e.x(n);return(0,vf.jsx)("line",{x1:o,y1:0,x2:o,y2:t.height,stroke:r,strokeWidth:.5},"gx-"+i)}),a.map((n,i)=>{const o=e.y(n);return(0,vf.jsx)("line",{x1:0,y1:o,x2:t.width,y2:o,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(f.scales,{width:c,height:l},n,p):null,g=f.scene.map((e,t)=>so(e,t,p)).filter(Boolean),m=!1!==e.showAxes?function(e,t,n,i,r){const o=Xh(i),s=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(n.xFormat||n.tickFormatTime||Mf)(t)})),a=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(n.yFormat||n.tickFormatValue||Mf)(t)}));return(0,vf.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[(0,vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:o.border,strokeWidth:1}),s.map((e,n)=>(0,vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,vf.jsx)("line",{y2:5,stroke:o.border,strokeWidth:1}),(0,vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:o.tickSize,fill:o.textSecondary,fontFamily:o.fontFamily,children:e.label})]},"xtick-"+n)),n.xLabel&&(0,vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:o.labelSize,fill:o.text,fontFamily:o.fontFamily,children:n.xLabel}),(0,vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:o.border,strokeWidth:1}),a.map((e,t)=>(0,vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,vf.jsx)("line",{x2:-5,stroke:o.border,strokeWidth:1}),(0,vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o.tickSize,fill:o.textSecondary,fontFamily:o.fontFamily,children:e.label})]},"ytick-"+t)),n.yLabel&&(0,vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:o.labelSize,fill:o.text,fontFamily:o.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:n.yLabel})]})}(f.scales,{width:c,height:l},e,n,p):null,x=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:c,height:l},theme:n,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,b=e.svgPreRenderers&&f.scales?e.svgPreRenderers.map((e,t)=>{try{return(0,_f.jsx)(Zh.Fragment,{children:e(f.scene,f.scales,{width:c,height:l})},"pre-"+t)}catch{return null}}).filter(Boolean):null,v=e.showLegend?0===s.length?null:hf({categories:s,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,w=Zh.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v;return Qh.renderToStaticMarkup(Pf((0,_f.jsxs)(_f.Fragment,{children:[e.backgroundGraphics,b,y,g,m,x,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,legend:w,idPrefix:e._idPrefix}))}var Cf=c(require("react")),If=c(require("react-dom/server")),Tf=require("d3-scale");function Rf(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,i=new Map;let r=0;return e=>{const o=t(e)+"",s=n?.[o];if(s)return s;let a=i.get(o);return a||(a=dt[r%dt.length],r++,i.set(o,a)),a}}function Lf(e,t,n,i,r,o,s){e.push(t?{type:"symbol",x:i,y:r,size:Math.PI*o*o,symbolType:t(n),style:s,datum:n}:{type:"point",x:i,y:r,r:o,style:s,datum:n})}function $f(e,t){const{columns:n,config:i,resolvePieceStyle:r}=e,o=[],s=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(n),h=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(i.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,h=c+u*l,p=c+(u+("number"==typeof n?._pct?n._pct:t.pct))*l,y=r(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:y,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),o.push(x)}return o}var Ef=require("d3-array");function zf(e){const t=e.length,n=e[0],i=e[t-1];return{n:t,min:n,q1:(0,Ef.quantile)(e,.25)??n,median:(0,Ef.quantile)(e,.5)??(n+i)/2,q3:(0,Ef.quantile)(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}var Df=require("d3-scale"),Bf={bar:function(e,t){const{scales:n,columns:i,config:r,getR:o,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,f=r.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(i))for(const n of t.pieceData){const t=s(n);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=o(n),i.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let i=0,r=0;for(const o of p){const l=t.get(o);if(!l)continue;let p=l.total;f&&n>0&&(p/=n);const y=a(l.pieces[0],s?o:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?r:i+p),n=0>p?c(r+p)-c(r):c(i)-c(i+p);u.push(Qe(e.x,t,e.width,Math.abs(n),y,g,o)),0>p?r+=p:i+=p}else if(h){const t=c(0>p?r+p:i),n=0>p?c(r)-c(r+p):c(i+p)-c(i);u.push(Qe(t,e.x,Math.abs(n),e.width,y,g,o)),0>p?r+=p:i+=p}}}const y="vertical"===l,g=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(g>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const n=t.datum?.category||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),n=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=g),n.length>0&&(n.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=g)}}return u},clusterbar:function(e,t){const{scales:n,columns:i,config:r,getR:o,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],f=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),h.push(e))}const p=h.length||1;for(const e of Object.values(i)){const t=e.width/p,n=.2*t,i=t-n,r=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let s=0;h.length>s;s++){const l=r.get(h[s])||[];for(const r of l){const l=o(r),f=a(r,h[s]);if(d){const o=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qe(o,Math.min(a,d),i,Math.abs(a-d),f,r,h[s]))}else{const o=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qe(Math.min(a,d),o,Math.abs(d-a),i,f,r,h[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=o(e.datum);y>0&&(e.roundedTop=y),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:n,columns:i,getR:r,multiScales:o,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=o.length>0,f=Rf(e),p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const n=t.__rIndex??0,i=t.__rValue??r(t),c=h&&o[n]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*p,n=c(i);x=Math.cos(t)*n,b=Math.sin(t)*n}else u?(x=e.middle,b=c(i)):(x=c(i),b=e.middle);Lf(l,f,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:n,columns:i,getR:r,resolvePieceStyle:o}=e,{r:s,projection:a}=n,c=[],l="vertical"===a,u=Rf(e);for(const e of Object.values(i)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const i=e.pieceData[n],a=r(i),d=o(i,e.name),h=d.r||4,f=(7919*n%100/100-.5)*t*.8;Lf(c,u,i,l?e.middle+f:s(a),l?s(a):e.middle+f,h,d)}}return c},pie:$f,donut:$f,boxplot:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=!1!==r.showOutliers;for(const t of Object.values(i)){const n=t.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===n.length)continue;const i=n[0],r=n[n.length-1],c=(0,Ef.quantile)(n,.25)??i,h=(0,Ef.quantile)(n,.5)??(i+r)/2,f=(0,Ef.quantile)(n,.75)??r,p=f-c,y=c-1.5*p,g=f+1.5*p,m=n.find(e=>e>=y)??i,x=[...n].reverse().find(e=>g>=e)??r,b=s(t.pieceData[0],t.name),v=[];if(d)for(const e of t.pieceData){const n=o(e);if(y>n||n>g){const i=u?t.middle:a(n),r=u?a(n):t.middle;v.push({px:i,py:r,value:n,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(h),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:c,median:h,q3:f,max:x,mean:n.reduce((e,t)=>e+t,0)/n.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),d)for(const t of v)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:b.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=r.bins||20,h=!1!==r.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=hi(c,1),p=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const i=a(n+(t+.5)*r);y+=` L ${e.middle+c[t]/f*p} ${i}`}y+=` L ${e.middle} ${a(i)}`;for(let t=d-1;t>=0;t--){const i=a(n+(t+.5)*r);y+=` L ${e.middle-c[t]/f*p} ${i}`}y+=" Z"}else{y=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(n+(t+.5)*r)} ${e.middle-c[t]/f*p}`;y+=` L ${a(i)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(n+(t+.5)*r)} ${e.middle+c[t]/f*p}`;y+=" Z"}const g=s(e.pieceData[0],e.name);let m;if(h&&t.length>=4){const r=(0,Ef.quantile)(t,.25)??n,o=(0,Ef.quantile)(t,.5)??(n+i)/2,s=(0,Ef.quantile)(t,.75)??i;m={q1Pos:a(r),medianPos:a(o),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const x=u?{x:e.x,y:Math.min(a(i),a(n)),width:e.width,height:Math.abs(a(i)-a(n))}:{x:Math.min(a(n),a(i)),y:e.x,width:Math.abs(a(i)-a(n)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:zf(t),style:g,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a}=n,c=[],l=r.bins||25,u=r.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,i]=di(t),r=null!=h&&isFinite(h)?h:n,d=null!=f&&isFinite(f)?f:i,p=(d-r)/l||1,y=Array(l).fill(0);for(const e of t)r>e||e>d||y[Math.min(Math.floor((e-r)/p),l-1)]++;const g=t.length,m=hi(y,1),x=s(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===y[t])continue;const n=(u?y[t]/g:y[t]/m)*e.width*.9,i=a(r+t*p),o=a(r+(t+1)*p);c.push(Qe(Math.min(i,o),e.x+e.width-n,Math.abs(o-i),n,x,{bin:t,count:y[t],range:[r+t*p,r+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u=r.bins||20,d="horizontal"===c,h=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/u||1,c=Array(u).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),u-1)]++;const f=hi(c,1),p=s(e.pieceData[0],e.name),y=e.width*h;let g;if(d){const t=e.x+e.width;g=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)g+=` L ${a(n+(e+.5)*r)} ${t-c[e]/f*y}`;g+=` L ${a(i)} ${t} Z`}else{const t=e.x;g=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const i=a(n+(e+.5)*r);g+=` L ${t+c[e]/f*y} ${i}`}g+=` L ${t} ${a(i)} Z`}const m=d?{x:Math.min(a(n),a(i)),y:e.x,width:Math.abs(a(i)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(i),a(n)),width:e.width,height:Math.abs(a(i)-a(n))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:zf(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:n,columns:i,getRawRange:r,resolvePieceStyle:o}=e,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[i,a]=n,u=o(t,e.name);if(l){const n=s(Math.min(i,a)),r=s(Math.max(i,a));c.push(Qe(n,e.x,r-n,e.width,u,t,e.name))}else{const n=s(Math.max(i,a)),r=s(Math.min(i,a));c.push(Qe(e.x,n,e.width,r-n,u,t,e.name))}}return c},funnel:function(e,t){const{columns:n,getR:i,getStack:r,resolvePieceStyle:o}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const e of l){const t=new Map;let n=0;for(const o of e.pieceData){const e=r?r(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=i(o);s.total+=a,s.pieces.push(o),n+=a}f.push({col:e,groups:t,stepTotal:n}),h||n>p&&(p=n)}if(h)for(const e of f){let t=0,n=0;for(let i=0;u.length>i;i++){const r=e.groups.get(u[i]);r&&(i%2==0?t+=r.total:n+=r.total)}const i=Math.max(t,n);i>p&&(p=i)}if(0===p)return s;const y=new Map;for(const e of u){const t=f[0].groups.get(e);y.set(e,t?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,Df.scaleLinear)().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;f.length>t;t++){const n=f[t],i=n.col,r=0===t,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(h){let e=0;for(const t of u){const i=n.groups.get(t);i&&(e+=x(i.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=o(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Qe(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const e=n.stepTotal,t=x(e),l=a-t/2,h=u[0],f="_default"!==h,y=n.groups.get(h)?.pieces[0]??i.pieceData[0],b=f?h:i.name,v=o(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:i.name,__funnelIsFirstStep:r,category:f?h:i.name};c&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=t),s.push(Qe(l,p,t,d,v,k,b)),m.set(h,{x:l,y:p,w:t,h:d})}if(t>0&&v.size>0){const t=h?u:[u[0]];for(const r of t){const t=v.get(r),a=m.get(r);if(!t||!a)continue;const c=(()=>{const e=n.groups.get(r);return o(e?e.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:n.groups.get(r)?.pieces[0]??i.pieceData[0],category:"_default"===r?i.name:r};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:n,getR:i,getStack:r,resolvePieceStyle:o,scales:s}=e,a=[],c=s.o.domain().map(e=>n[e]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const e of c)for(const t of e.pieceData){const e=r?r(t):"_default";u.has(e)||(u.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=new Map;let n=0;for(const o of e.pieceData){const e=r?r(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=i(o);s.total+=a,s.pieces.push(o),n+=a}h.push({col:e,groups:t,stepTotal:n})}const f=new Map;for(const e of l){const t=h[0]?.groups.get(e);f.set(e,t?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],n=t.col,i=0===e,r=e>0?h[e-1]:null,s=n.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=r?.groups.get(h),v=i?0:Math.max(0,(b?.total??g)-g),w=n.x+e*s+c/2,k=p(g),S=p(0)-k,A=o(y.pieces[0],d?h:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Qe(w,k,u,S,A,M,d?h:n.name)),v>0){const e=p(g+v),t=k-e,i={...A},r={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};a.push(Qe(w,e,u,t,i,r,d?h:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:i,getR:r,getStack:o,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:f.opacity??1,[n,r]=a.range(),o=Math.min(n,r),s=Math.abs(r-n);for(const n of Object.values(i)){const i={fill:e,opacity:t},r=u?Qe(o,n.x,s,n.width,i,null,"__track__"):Qe(n.x,o,n.width,s,i,null,"__track__");l.push(r)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const n=l.length;for(const n of e.pieceData){const i=Math.abs(r(n));if(0===i)continue;const c=o?o(n):e.name,f=s(n,c);let p;if(u){const r=a(t),o=a(t+i);p=Qe(r,e.x,o-r,e.width,f,n,c)}else{const r=a(t+i),o=a(t);p=Qe(e.x,r,e.width,o-r,f,n,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),t+=i}if(p>0&&l.length>n){const e=l.slice(n),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},Ff=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nf=["scene-style","data-paint","accessibility","evidence"],Of=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Wf=new Set(["accessorRevision","axisExtent","categoryAccessor","chartType","extentPadding","groupBy","multiAxis","normalize","oAccessor","oExtent","oSort","rAccessor","rExtent","runtimeMode","stackBy","timeAccessor","valueAccessor"]),qf=new Set(["barColors","colorScheme","connectorStyle","pieceStyle","summaryStyle","themeCategorical","themeDiverging","themeSemantic","themeSequential"]),Yf=class{constructor(){this.tracker=new Lt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Ff)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Nf):this.recordNoop("restyle")}recordConfig(e){if(0===e.length)return this.tracker.record({kind:"config",keys:e},[]);const t=new Set(Of);return e.some(e=>Wf.has(e))&&t.add("domain"),e.some(e=>qf.has(e))&&t.add("scene-style"),this.tracker.record({kind:"config",keys:e},t)}},Hf=require("d3-quadtree"),Gf=class{constructor(e){this.rExtent=new je,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Yf,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new _e(e.windowSize),this.getO=Re(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Ie(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new je)):(this.getR=Ie(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Re(e.stackBy),this.getGroup=Re(e.groupBy),this.getColor=Re(e.colorAccessor),this.getSymbol=Re(e.symbolAccessor),this.getConnector=Re(e.connectorAccessor),this.getDataId=Re(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new _e(e.windowSize))}syncPulseTimestampBuffer(){var e,t,n,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,i=Ne(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:_t(t,i):null)}ingest(e){const t=Ne();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Pt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)jt(this.buffer,n,this.timestampBuffer,t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=jt(this.buffer,n,this.timestampBuffer,t);this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this,i=this.scales,r=this.multiScales,o=this.columns;if(0===n.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let f,p;if(d){f=(0,Tf.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=(0,Tf.scaleLinear)().domain(l).range([i,n])}else u?(f=(0,Tf.scaleBand)().domain(c).range([0,e.height]).padding(h),p=(0,Tf.scaleLinear)().domain(l).range([0,e.width])):(f=(0,Tf.scaleBand)().domain(c).range([0,e.width]).padding(h),p=(0,Tf.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,r)=>{const o=this.rExtents[r];o.dirty&&o.recalculate(n,i);let[s,a]=o.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Tf.scaleLinear)().domain([s,a]).range([0,e.width]):(0,Tf.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,c,f,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=r,this.columns=o):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let r=null;if(n){r=new Set;for(const t of e)r.add(this.getO(t))}const o=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(n&&void 0===i){const e=Math.max(50,3*r.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;r.has(e)||(this.categories.delete(e),t--)}}return o}if(!1===i)return o;if("function"==typeof i)return o.sort(i);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return o.sort("asc"===i?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:n,projection:i,normalize:r,rExtent:o,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,f=s;if("radial"===i&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&d&&r)p=0,y=1;else if("bar"===n&&d){const e=new Map,n=new Map;for(const i of t){const t=l(i),r=u(i);0>r?n.set(t,(n.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>y&&(y=t);for(const e of n.values())p>e&&(p=e)}else if("bar"===n){const e=new Map;for(const n of t){const t=l(n),i=u(n);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===n){const e=new Map;for(const n of t){const t=l(n),i=Math.abs(u(n));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>y&&(y=t)}else if("clusterbar"===n||"bar-funnel"===n)for(const e of t){const t=u(e);t>y&&(y=t),p>t&&(p=t)}else{const e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}o&&(null!=o[0]&&(p=o[0]),null!=o[1]&&(y=o[1]));const g="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==o?.[0]&&null==o?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const e=y-p,t=e>0?e*f:1,i=g&&!a&&0===p,r=g&&!a&&0===y||"swimlane"===n;null!=o?.[0]||i||(p-=t),null!=o?.[1]||r||(y+=t)}return[p,y]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,n,i,r){return function(e){const{data:t,oExtent:n,oScale:i,projection:r,layout:o,dynamicColumnWidth:s,getO:a,getR:c}=e,l={},u=new Map;for(const e of t){const t=a(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===r)for(const e of t)d+=Math.abs(c(e));let h=null;if(s&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let i;i="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(n),h.set(t,i),e+=i}const t=("horizontal"===r?o.height:o.width)-i.padding()*i.step()*n.length;if(e>0)for(const[n,i]of h)h.set(n,i/e*t)}let f=0,p=0;for(const e of n){const t=u.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=d>0?n/d:0;let o,s;h?(o=p,s=h.get(e)||i.bandwidth(),p+=s+i.padding()*i.step()):(o=i(e)??0,s=i.bandwidth()),l[e]={name:e,x:o,y:0,width:s,middle:o+s/2,padding:i.padding()*i.step(),pieceData:t,pct:r,pctStart:f},f+=r}return l}({data:e,oExtent:t,oScale:n,projection:i,layout:r,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const n=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=vt("ordinal",e,t,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?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 r=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return mt({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),i=Bf[this.config.chartType];let r=i?i(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:i,getConnector:r,getO:o}=e;if(!r||!n)return[];const s=[],{projection:a}=n,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let i,s;"point"===e.type?(i=e.x,s=e.y):(i=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:i,y:s,datum:t,category:o(t)})}const l=n.o.domain(),u=i.connectorStyle;for(const[t,n]of c)if(n.length>=2){n.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;n.length-1>i;i++){const r=n[i],o=n[i+1],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:o.x,y2:o.y,style:a,datum:r.datum,group:t})}}return s}(n,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const n=this.config,i=n.layoutMargin??{top:0,right:0,bottom:0,left:0},r=iu(n.colorScheme,n.themeCategorical,R),o=this.scales;return{data:e,scales:{o:o.o,r:o.r,projection:o.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===o.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:n.themeSemantic??{},categorical:[...r]},resolveColor:ru(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?{...n,fill:this.getColorFromScheme(t)}:n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||R,i=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,i),i}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Oe(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=We(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const n="function"==typeof t,i=n?null:t||"category",r=new Map;for(let o=0;e.length>o;o++){const s=e[o],a=n?t(s):s[i],c=r.get(a);c?c.push(o):r.set(a,[o])}return r}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,n=0;for(const i of e)"point"===i.type&&(t++,i.r>n&&(n=i.r));if(500>=t)return{quadtree:null,maxRadius:n};const i=Array(t);let r=0;for(const t of e)"point"===t.type&&(i[r++]=t);return{maxRadius:n,quadtree:(0,Hf.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const n=t.length;if(1>=n)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,n=Ne()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,i,r,o){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const s of r(t)??[]){const t=n.get(s);null!=t&&(i=Math.max(i,qe(e,t,o)))}c=Ye(l,i,s)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const u=n.get(t);c=Ye(l,null==u?0:qe(e,u,o),s,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),n)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&He(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ne())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,n="horizontal"!==this.scales?.projection;let i;for(let r=0;this.scene.length>r;r++){const o=this.scene[r],s=this.getNodeKey(o,e);s&&("rect"===o.type?this.prevPositionMap.set(s,n?{x:o.x,y:t,w:o.w,h:0,opacity:o.style.opacity??1}:{x:t,y:o.y,w:0,h:o.h,opacity:o.style.opacity??1}):"point"===o.type?this.prevPositionMap.set(s,{x:o.x,y:o.y,r:0,opacity:0}):"wedge"===o.type&&(void 0===i&&(i=o.startAngle),this.prevPositionMap.set(s,{x:o.cx,y:o.cy,startAngle:i,endAngle:i,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(n)||0;return t.set(n,i+1),`${n}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],i=this.getNodeKey(n,e);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const n=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],o=this.getNodeKey(r,i);if(!o)continue;r._transitionKey=o;const s=this.prevPositionMap.get(o);if("point"===r.type)s?(n.add(o),r._targetOpacity=r.style.opacity??1,(s.x!==r.x||s.y!==r.y||void 0!==s.r&&s.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=s.x,r.y=s.y,void 0!==s.r&&(r.r=s.r),t=!0)):(r._targetOpacity=r.style.opacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},t=!0);else if("rect"===r.type)s?(n.add(o),r._targetOpacity=r.style.opacity??1,s.x===r.x&&s.y===r.y&&s.w===r.w&&s.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=s.x,r.y=s.y,r.w=s.w??r.w,r.h=s.h??r.h,t=!0)):(r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},t=!0);else if("wedge"===r.type)if(s)n.add(o),r._targetOpacity=r.style.opacity??1,s.startAngle===r.startAngle&&s.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=s.startAngle,r.endAngle=s.endAngle,t=!0);else{r._targetOpacity=r.style.opacity??1,r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle;const e=r.startAngle;r.startAngle=e,r.endAngle=e,r.style={...r.style,opacity:0},this.prevPositionMap.set(o,{x:r.cx,y:r.cy,startAngle:e,endAngle:e,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,n={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:Ne(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=Be(e,this.activeTransition),n=De(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Fe(i?i.opacity??1:0,e._targetOpacity,n)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=Fe(i.x,e._targetX,n),e.y=Fe(i.y,e._targetY,n)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=Fe(i.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Fe(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=Fe(i.x,e._targetX,n),e.y=Fe(i.y,e._targetY,n),void 0!==i.w&&(e.w=Fe(i.w,e._targetW,n),e.h=Fe(i.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:Fe(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=Fe(i.startAngle,e._targetStartAngle,n),e.endAngle=Fe(i.endAngle,e._targetEndAngle,n))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ze(e),n=this.getDataId,i=e=>t.has(n(e));Ct(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=Ne(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=ze(e),i=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(i(e))&&r.add(t)});const o=this.buffer.update(e=>n.has(i(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),r.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=Ne(),this.updateResults.recordData("update",o.length),o}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},r=n(i,t);i.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.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 e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!Ce(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Ce(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Ce(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Re(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],o=Array.isArray(n)?n:[n];if(r=i.length!==o.length||i.some((e,t)=>!Ce(e,o[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Ie(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new je)):(this.getR=Ie(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Ce(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Re(this.config.stackBy):void 0),"groupBy"in e&&!Ce(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Re(this.config.groupBy):void 0),"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Re(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Ce(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Re(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Ce(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Re(this.config.connectorAccessor):void 0),(i||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}},Xf=require("react/jsx-runtime"),Vf=require("react/jsx-runtime");function Uf(e,t){const n=Gh(e.theme),i=e.size||[500,400],r={top:20,right:20,bottom:30,left:40,...e.margin},o=B(e.data),s=e.showLegend?ff(o,e.colorAccessor||e.stackBy||e.groupBy):[],a=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&s.length>0&&kf(r,{categories:s,colorScheme:e.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u=e.projection||"vertical",d="radial"===u,h={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:u,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||n.colors.categorical,themeCategorical:n.colors.categorical,themeSemantic:xe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new Gf(h);if(e.data&&f.ingest({inserts:o,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=Kh({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),If.renderToStaticMarkup(Pf(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));if(t){const n=f.scales.o?.domain?.();t.evidence=Kh({frameType:"ordinal",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:Uh(f.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0})}const p=e._idPrefix,y=e.showGrid?function(e,t,n,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:o}=Xh(n),s=i?i+"-":"",a="vertical"===r.projection,c=r.r.ticks(5);return(0,vf.jsx)("g",a?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const i=r.r(e);return(0,vf.jsx)("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:o,strokeWidth:.5},"gr-"+n)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const i=r.r(e);return(0,vf.jsx)("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:o,strokeWidth:.5},"gr-"+n)})})}(f,{width:c,height:l},n,p):null;let g=null;if(f.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=function(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const n=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;n.length>e;e++)i=31*i+n.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}(e),i=new Set;for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");g=Array.from(i).map((e,i)=>function(e){const{id:t,background:n="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:o=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*o));return(0,Xf.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Xf.jsx)("rect",{width:a,height:a,fill:n}),(0,Xf.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:r}),(0,Xf.jsx)("line",{x1:o,y1:0,x2:o,y2:a,stroke:i,strokeWidth:r})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((e,n)=>r.set(e,`funnel-hatch-${t}-${n}`));for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${r.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const m=f.scene.map((e,t)=>ao(e,t,p)).filter(Boolean),x=!1!==e.showAxes?function(e,t,n,i,r){const o=e.scales;if(!o)return null;if("radial"===o.projection)return null;const s=Xh(i),a="vertical"===o.projection,c=n.categoryFormat||n.oFormat,l=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,d=n.valueLabel||n.rLabel,h=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),f=o.r.ticks(5).map(e=>({pixel:o.r(e),label:(l||Mf)(e)}));return(0,Vf.jsxs)("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,n)=>(0,Vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Vf.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),u&&(0,Vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,t)=>(0,Vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vf.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),d&&(0,Vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,n)=>(0,Vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Vf.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),d&&(0,Vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:d}),(0,Vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,t)=>(0,Vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vf.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),u&&(0,Vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:u})]})}(f,{width:c,height:l},e,n,p):null,b=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:c,height:l},theme:n,projection:u,idPrefix:p}):null,v=e.showLegend?0===s.length?null:hf({categories:s,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,w=Cf.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v,k=d?r.left+c/2:r.left,S=d?r.top+l/2:r.top;return If.renderToStaticMarkup(Pf((0,Vf.jsxs)(Vf.Fragment,{children:[e.backgroundGraphics,y,m,x,b,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${k},${S})`,innerWidth:c,innerHeight:l,legend:w,defs:g,idPrefix:e._idPrefix}))}var Kf=c(require("react")),Zf=c(require("react-dom/server"));function Qf(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Jf(e,t){var n,i=[],r=[],o=[],s={},a=[];function c(e){o[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],o[t]&&c(t)})}function l(e){var t,i,d=!1;for(r.push(e),o[e]=!0,t=0;a[e].length>t;t++)(i=a[e][t])===n?(u(n,r),d=!0):o[i]||(d=l(i));if(d)c(e);else for(t=0;a[e].length>t;t++){var h=s[i=a[e][t]];h||(s[i]=h={}),h[i]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):i.push(r)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,i=function(e){for(var t=e.length,n=Array(t),i=Array(t),r=Array(t),o=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,i[c]=0,r[c]=!1,o[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(t){var c=[t],l=[t];for(n[t]=i[t]=u,r[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>o[t]){for(var p=o[t];f.length>p;++p){var y=f[p];if(0>n[y]){n[y]=i[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(i[t]=0|Math.min(i[t],i[y])),0>s[y]||a[t].push(s[y])}o[t]=p}else{if(i[t]===n[t]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(r[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=d.length,b===t){c.length=p;break}}d.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];h.push(v)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;h.length>c;c++){var p=h[c];if(0!==p.length){p.sort(function(e,t){return e-t}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=i.components.filter(function(e){return e.length>1}),o=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)o>r[s][a]&&(o=r[s][a],n=s);var c=r[n];return!!c&&{leastVertex:o,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];o[+g]=!1,s[g]={}}l(n),n+=1}else n=h}return t?void 0:i}function ep(e){return e.y0-e.y1>0?"up":"down"}function tp(e,t){return t(e.source)==t(e.target)}function np(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function ip(e){return e.target.x0-e.source.x1}function rp(e,t){var n=sp(e),i=ip(t)/Math.tan(n);return"up"==ep(e)?e.y1-i:e.y1+i}function op(e,t){var n=sp(e),i=ip(t)/Math.tan(n);return"up"==ep(e)?e.y1+i:e.y1-i}function sp(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function ap(e,t){return t(e)}function cp(e){return up(e.source)}function lp(e){return up(e.target)}function up(e){return(e.y0+e.y1)/2}function dp(e){return e.virtual?0:e.value}function hp(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!tp(e,t)?n+1:n});var i=0;return e.targetLinks.forEach(function(e){i=e.circular&&!tp(e,t)?i+1:i}),n+i}function fp(e){return e.target.depth}function pp(e,t){return e.sourceLinks.length?e.depth:t-1}function yp(e,t){return e.y0-t.y0}function gp(e,t){return t.y0-e.y0}function mp(e,t){return e.y1-t.y1}function xp(e,t){return t.y1-e.y1}function bp(e,t){return wp(e.source,t.source)||e.index-t.index}function vp(e,t){return wp(e.target,t.target)||e.index-t.index}function wp(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function kp(e,t){return Sp(e)==Sp(t)?"bottom"==e.circularLinkType?gp(e,t):yp(e,t):Sp(t)-Sp(e)}function Sp(e){return e.target.column-e.source.column}function Ap(e,t){return Mp(e)==Mp(t)}function Mp(e){return e.y0-e.y1>0?"up":"down"}var Pp=require("d3-array");function _p(e,t,n,i,r){let o=e;var s=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,Pp.min)(o.links,function(e){return e.source.y0});o.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=o.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),jp(o.links.filter(function(e){return"top"==e.circularLinkType}),t,n),jp(o.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),o.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+i,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,tp(e,t)&&np(e))e.circularPathData.rightSmallArcRadius=i+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=i+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=i+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=i+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=o.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?gp:yp);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=i+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=i+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=o.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?xp:mp),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=i+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=i+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(o.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,i=e.target.x0,r=e.y1,o=(t+i)/2;return"M"+t+","+n+"C"+o+","+n+" "+o+","+r+" "+i+","+r}(e)}),o}function jp(e,t,n){e.sort(kp);var i=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(tp(e,t)&&np(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Cp(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=c>o?c:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function Cp(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Ip=require("d3-array");function Tp(e){return function(){return e}}function Rp(e){return e.index}function Lp(e){return e.nodes}function $p(e){return e.links}function Ep(e,t,n){var i=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});i.forEach(function(r,o){var s=r.length;if(t)r.sort(t);else if(o>0){var a=new Map;r.forEach(function(e,t){var n,i,r,o=(i=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=up(e.source)*t,i+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=up(e.target)*t,i+=t}}),i>0?r/i:NaN);a.set(e,{bc:o,idx:t})}),r.sort(function(e,t){var n=a.get(e),i=a.get(t),r=n.bc,o=i.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(o)?isNaN(r)?isNaN(o)?n.idx-i.idx:1:-1:r-o})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?hp(t,n)-hp(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==i.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==hp(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+r,t.y1=t.y0+t.value*e.ky)})})}function zp(e,t,n,i,r,o){var s=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=o;c>0;--c)l(a*=.99,n),u();function l(t,n){var i=s.length;s.forEach(function(r){var o=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&hp(r,n)>0){var c=(0,Ip.mean)(r.sourceLinks,lp),l=(0,Ip.mean)(r.targetLinks,cp),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-up(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==s&&1==o)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(s==i-1&&1==o)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var h=(0,Ip.mean)(r.sourceLinks,lp),f=(0,Ip.mean)(r.targetLinks,cp),p=((h&&f?(h+f)/2:h||f)-up(r))*t;r.y0+=p,r.y1+=p}})})}function u(){s.forEach(function(n){var o,s,a,c=e.y0,l=n.length;for(n.sort(t||wp),a=0;l>a;++a)(s=c-(o=n[a]).y0)>0&&(o.y0+=s,o.y1+=s),c=o.y1+i;if((s=c-i-e.y1)>0)for(c=o.y0-=s,o.y1-=s,a=l-2;a>=0;--a)(s=(o=n[a]).y1+r-c)>0&&(o.y0-=s,o.y1-=s),c=o.y0})}}function Dp(e){e.nodes.forEach(function(e){e.sourceLinks.sort(vp),e.targetLinks.sort(bp)}),e.nodes.forEach(function(e){var t=e.y0,n=t,i=e.y1,r=i;e.sourceLinks.forEach(function(e){e.circular?(e.y0=i-e.width/2,i-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Bp(){var e=0,t=0,n=1,i=1,r=24,o=8,s=null,a=Rp,c=pp,l=void 0,u=32,d=2,h=Lp,f=$p;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=i,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,Ip.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var i=e.source,r=e.target;"object"!=typeof i&&(i=e.source=Qf(n,i)),"object"!=typeof r&&(r=e.target=Qf(n,r)),i.sourceLinks.push(e),r.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var i=[],r=0;e.links.length>r;r++){var o=e.links[r],s=o.source.index,a=o.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=Jf(i);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,i=e.source.index;t===i||l[i]&&l[i][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,l),function(e,t){var n=0,i=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:i>n?"top":"bottom","top"==r.circularLinkType?n++:i++,e.nodes.forEach(function(e){ap(e,t)!=ap(r.source,t)&&ap(e,t)!=ap(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),tp(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Ip.sum)(e.sourceLinks,dp),(0,Ip.sum)(e.targetLinks,dp)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var i,r,o;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(i=e.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(i=e.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,o):e.column})}(h,l,c);var f=o;if(null!==s){var p=(0,Ip.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Ip.max)(p,function(e){return e.length});y>1&&(f=Math.max(1,(i-t)*s/(y-1)))}(function(e,t,n){var i=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=(0,Ip.min)(i,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Ip.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var o=(0,Ip.max)(e.nodes,function(e){return e.column});e.nodes.forEach(o>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/o),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,r),Ep(h,l,a),zp(h,l,a,f,f,u),Dp(h),_p(h,a,d,10,8),Ep(h,l,a),zp(h,l,a,f,f,u),Dp(h),_p(h,a,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var i=n.links.filter(function(n){return ap(n.source,t)==ap(e,t)}),r=i.length;r>1&&i.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ap(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=rp(t,e);return e.y1-n}if(t.target.column>e.target.column)return rp(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;i.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),i.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;r>o;o++)s+=i[o].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var i=n.links.filter(function(n){return ap(n.target,t)==ap(e,t)}),r=i.length;r>1&&i.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ap(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=op(t,e);return e.y0-n}if(t.source.column>e.source.column)return op(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;i.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),i.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;r>o;o++)s+=i[o].width;t.y1=e.y1-s-t.width/2}})})}(h,a),function(e){var t=e.nodes,n=e.links,i=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?i=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==i||0==r){let i=function(t){return(t-o)/(s-o)*(e.y1-e.y0)+e.y0};var o=(0,Ip.min)(t,function(e){return e.y0}),s=(0,Ip.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-o);1>a?(t.forEach(function(e){e.y0=i(e.y0),e.y1=i(e.y1)}),n.forEach(function(e){e.y0=i(e.y0),e.y1=i(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=i(e.y0)-e.y0;e.y0=i(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),_p(h,a,d,10,8)}(p),p}return p.update=function(e){return Dp(e),_p(e,a,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(o=+e,p):o},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Tp(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Tp(e),p):f},p.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:Tp(e),p):a},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Tp(e),p):c},p.nodeSort=function(e){return arguments.length?(l=e,p):l},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],i=+r[1][1],p):[[e,t],[n,i]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],i=+r[1],p):[n-e,i-t]},p}var Fp=require("d3-interpolate"),Np=(require("d3-shape"),.5),Op=e=>{let t,n,i,r,o,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,i=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,o=e.source.x1,s=e.target.x0,a=(0,Fp.interpolateNumber)(o,s),c=a(Np),l=a(.5),`M${t},${o}C${t},${c} ${n},${l} ${n},${s}L${i},${s}C${i},${l} ${r},${c} ${r},${o}Z`;const u=e.sankeyWidth/2,d=(0,Fp.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=mc({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(Np),cp2X:d(.5)});return h};function Wp(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const n=i.sourceX,r=i.sourceY,o=i.targetX,s=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${n},${r-t}L${n+a},${r-t}L${n+a},${r+t}L${n},${r+t}ZM${o},${s-t}L${o-c},${s-t}L${o-c},${s+t}L${o},${s+t}Z`}const r=i.sourceX,o=i.sourceY,s=i.targetX,a=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${r},${o-d*t}L${c},${o-d*t}L${c+n},${o-d*t+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${a-d*t+d*h}L${l-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+n},${a+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${o+d*t}L${r},${o+d*t}Z`}var qp=new Set,Yp=new WeakMap;function Hp(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Yp.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Yp.set(e,n);const i=new Proxy(e,{get(e,n,i){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;qp.has(e)||(qp.add(e),console.warn(`[Semiotic] "${t}" 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(e,n,i)}});return n.set(t,i),i}var Gp={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(fp))-1:0},justify:pp};function Xp(e){return"string"==typeof e?e:e.id}var Vp={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",o=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===r?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const h=Bp().extent(d).links(u).nodes(l).nodeAlign(Gp[o]||pp).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const i of l)e>i.x0&&(e=i.x0),i.x1>t&&(t=i.x1),n>i.y0&&(n=i.y0),i.y1>r&&(r=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,s=(i._circularWidth??i.width??0)/2;e>o.leftFullExtent-s&&(e=o.leftFullExtent-s),o.rightFullExtent+s>t&&(t=o.rightFullExtent+s),n>o.verticalFullExtent-s&&(n=o.verticalFullExtent-s),o.verticalFullExtent+s>r&&(r=o.verticalFullExtent+s)}const o=t-e,s=r-n,a=i[0],c=i[1];if(o>0&&s>0&&(0>e||0>n||t>a||r>c)){const t=Math.min(a/o,c/s),i=-e*t+(a-o*t)/2,r=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+i,e.x1=e.x1*t+i,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+i,n.targetX=n.targetX*t+i,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+i,n.leftFullExtent=n.leftFullExtent*t+i,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+i,n.leftInnerExtent=n.leftInnerExtent*t+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const p=new Map;for(const e of t)p.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Xp(e.source),n=Xp(e.target),i=p.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=e.width??0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=r;const o=f.get(t),s=f.get(n);o&&(i.source=o),s&&(i.target=s)}}},buildScene(e,t,n,i){const r="vertical"===n.orientation?"down":"right",o=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:g,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],f=[],p=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const i=o?o(Hp(t,"nodeStyle")):{},s={fill:i.fill||u.get(t.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};p.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;if(!t||!i)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?p.get(i.id)||u.get(i.id)||r:p.get(t.id)||u.get(t.id)||r;const o=s?s(Hp(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||r;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Wp(e):Op(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:o.fill||r,fillOpacity:o.fillOpacity??a,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity},datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===r?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(i[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+o/2),f.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:h,labels:f}}},Up=require("d3-force"),Kp=require("d3-scale"),Zp={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const r=n.forceStrength??.1,o=i[0]/2,s=i[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const i=Qp(e.id,t,n);if(i.length>0){let t=0,n=0;for(const e of i)t+=e.x,n+=e.y;const r=Jp(e.id),o=r%360*(Math.PI/180),s=10+r%20;e.x=t/i.length+s*Math.cos(o),e.y=n/i.length+s*Math.sin(o)}else{const t=Jp(e.id),n=t%360*(Math.PI/180),i=15+t%30;e.x=o+i*Math.cos(n),e.y=s+i*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const i=e[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const e=10*Math.sqrt(n+.5),r=n*t;i.x=o+e*Math.cos(r),i.y=s+e*Math.sin(r)}}}const d=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=ey(n.nodeSize,n.nodeSizeRange,e),f=e=>h(e);if(d>0){const n=new Map,i=new Map;for(const t of e)n.set(t.id,0),i.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,i="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(i,(n.get(i)??0)+1)}const a=(0,Up.forceLink)().strength(e=>{const t=e.weight,i="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(n.get("string"==typeof e.source?e.source:e.source.id)??1,n.get(i)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*o))}).distance(e=>{const t="string"==typeof e.source?i.get(e.source):e.source,n="string"==typeof e.target?i.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),c=(0,Up.forceSimulation)().force("charge",(0,Up.forceManyBody)().strength(e=>{const t=n.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",(0,Up.forceCollide)(e=>f(e)+3).strength(.9).iterations(2)).force("center",(0,Up.forceCenter)(o,s).strength(.8)).force("x",(0,Up.forceX)(o).strength(.06)).force("y",(0,Up.forceY)(s).strength(.06));if(c.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));a.links(e),c.force("link",a)}u?c.alpha(.3):.1>c.alpha()&&c.alpha(1),c.stop();for(let e=0;d>e;++e)c.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(i[0]-e,t.x)),t.y=Math.max(e,Math.min(i[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,i){const r=n.nodeStyle,o=n.edgeStyle,s=ey(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:g,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Hp(t,"nodeSize")),i=r?r(Hp(t,"nodeStyle")):{},o={fill:i.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),i="object"==typeof e.target?e.target:h.get(e.target);if(!t||!i)continue;if(null==t.x||null==t.y)continue;if(null==i.x||null==i.y)continue;const r=o?o(Hp(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const i=s(Hp(n,"nodeSize"));d.push({x:n.x,y:n.y-i-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:d}}};function Qp(e,t,n){const i=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let s=null;if(t===e?s=o:o===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||i.push({x:e.x,y:e.y})}}return i}function Jp(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function ey(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const i=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>i[0];const[o,s]=di(r);if(o===s)return()=>(i[0]+i[1])/2;const a=(0,Kp.scaleLinear)().domain([o,s]).range(i).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?i[0]:a(n)}}var ty=require("d3-chord"),ny=require("d3-shape"),iy=g,ry={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,c=a-o,l=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),i=f.get(t);if(void 0===n||void 0===i)continue;const r=d(e);y[n][i]=r}const g=(0,ty.chord)().padAngle(r);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,ny.arc)().innerRadius(c).outerRadius(a);for(const t of x){const n=e[t.index],i=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=i[0]+l,n.y=i[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=v.get("string"==typeof e.source?e.source:e.source.id),i=v.get(t);n&&(e.source=n),i&&(e.target=i)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,i=e[t.target.index].id,r=w.get(`${n}\0${i}`)||w.get(`${i}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,i){const{groupWidth:r=20,edgeOpacity:o=.5}=n,s=Math.min(i[0],i[1])/2,a=s-r,c=i[0]/2,l=i[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:iy,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=(0,ty.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],i=n.__arcData;if(!i)continue;let r;r=u?u(Hp(n,"nodeStyle")).fill||p.get(n.id)||f[t%f.length]:p.get(n.id)||f[t%f.length];const o=u?u(Hp(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:{fill:r,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const i=y(t);if(!i)continue;const r=oy(i,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Hp(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=p.get(n.id)||s:t&&(s=p.get(t.id)||s)}const a=d?d(Hp(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:r,style:{fill:s,fillOpacity:a.fillOpacity??o,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null,i=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const o=(e.startAngle+e.endAngle)/2,s=o-Math.PI/2;x.push({x:c+Math.cos(s)*i,y:l+Math.sin(s)*i,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function oy(e,t,n){const i=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return e;const r=[];let o=0;for(;i.length>o;){const e=i[o];if("M"===e||"L"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("C"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)for(let e=0;3>e&&i.length>o&&!isNaN(Number(i[o]));e++)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("Q"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)for(let e=0;2>e&&i.length>o&&!isNaN(Number(i[o]));e++)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("A"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&(r.push(Number(i[o])+t+""),o++),i.length>o&&(r.push(Number(i[o])+n+""),o++);else"Z"===e||"z"===e?(r.push(e),o++):(r.push(i[o]),o++)}return r.join(" ")}var sy=require("d3-hierarchy"),ay=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function cy(e){const[t,n,i]=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*i>150?"#222":"#fff"}function ly(e,t,n){const i=t.nodeIDAccessor;return"function"==typeof i?i(e.data)+"":"string"==typeof i&&void 0!==e.data[i]?e.data[i]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function uy(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function dy(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:ay}function hy(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function fy(e,t,n,i,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${i} ${n},${i}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+i)/2} T ${n},${i}`}{const r=(t+i)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${i}`}}var py={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,i){const r=n.__hierarchyRoot;if(!r)return;const o=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,sy.hierarchy)(r,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=i;switch(o){case"tree":!function(e,t,n,i){const r=t.treeOrientation||"vertical",o=(0,sy.tree)();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,i){const r=t.treeOrientation||"vertical",o=(0,sy.cluster)();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,i){const r=t.padding??4,o=t.paddingTop??0,s=(0,sy.treemap)().size([n,i]).tile(sy.treemapBinary).padding(r);o>0&&s.paddingTop(o),s(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,i){const r=t.padding??4;(0,sy.pack)().size([n,i]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,i){(0,sy.partition)().size([n,i]).padding(t.padding??1)(e)}(l,n,u,d)}const h=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const i=h[t],r={id:ly(i,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===o||"cluster"===o?yy(r,i,n):"treemap"===o||"partition"===o?gy(r,i):"circlepack"===o&&my(r,i),r.__hierarchyNode=i,e.push(r),f.set(i,r)}if("tree"===o||"cluster"===o)for(const e of h)if(e.parent){const n=f.get(e.parent),i=f.get(e);n&&i&&t.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,i){const r=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,i,r,o){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=i[0]/2,h=i[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const t of e){let e=t.x,i=t.y;u&&(e+=d,i+=h);const o=r(Hp(t,"nodeStyle"));let a=o.fill||hy(n);if(n.colorByDepth&&void 0!==t.depth){const e=dy(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:i,r:f,style:{fill:a,stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;if(!t||!i)continue;let r=t.x,s=t.y,c=i.x,f=i.y;u&&(r+=d,s+=h,c+=d,f+=h);const p=fy(r,s,c,f,l),g=o(Hp(e,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:e})}if(!1!==n.showLabels){const t=uy(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let i,r,o,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(i=s+e/n*10,r=a+t/n*10,o=0>e?"end":"start"):(i=s,r=a-12,o="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(i=s-f-6,o="end"):(i=s+f+6,o="start"),r=a):(i=s,r=a+f+14,o="middle");c.push({x:i,y:r,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,i,r,o);case"treemap":case"partition":return function(e,t,n,i){const r=[],o=[];for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=i(Hp(n,"nodeStyle"));let a=s.fill||hy(t);if(t.colorByDepth&&void 0!==n.depth){const e=dy(t);a=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:o,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=uy(t.nodeLabel),r=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=i(Hp(a,"nodeStyle")).fill||hy(t);if(t.colorByDepth&&void 0!==a.depth){const e=dy(t);d=e[a.depth%e.length]}const h="string"==typeof d?cy(d):t.themeSemantic?.text??"#000";o.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:o}}(e,n,0,r);case"circlepack":return function(e,t,n,i){const r=[],o=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const o=i(Hp(n,"nodeStyle"));let s=o.fill||hy(t);if(t.colorByDepth&&void 0!==n.depth){const e=dy(t);s=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:o.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=uy(t.nodeLabel);for(const r of e){const e=r.__radius??5,s=n?n(r):r.id;if(!s)continue;if(15>e)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=i(Hp(r,"nodeStyle")).fill||hy(t);if(t.colorByDepth&&void 0!==r.depth){const e=dy(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?cy(c):t.themeSemantic?.text??"#000";o.push({x:r.x,y:r.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else o.push({x:r.x,y:r.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:o}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function yy(e,t,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=t.x,i=t.y;e.x=i*Math.cos(n-Math.PI/2),e.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function gy(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function my(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var xy=require("d3-shape");function by(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var vy={sankey:Vp,force:Zp,chord:ry,tree:py,cluster:py,treemap:py,circlepack:py,partition:py,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,i){const r=n.__hierarchyRoot;r&&function(e,t,n,i,r){const o=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=by(n);h.metaMap.clear(),i.length=0,r.length=0;const f=new Map;function p(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=p(s(e));i.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,y,g){const m=o(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:n,depth:y,data:t,parentId:n},M=g?f/u(A)*S:f*S,P=(0,xy.pie)().value(e=>{const t=o(e)?.length;return t?4:1}).sort(null)(w),_=d(A);for(let t=0;w.length>t;t++){const o=(P[t].startAngle+P[t].endAngle)/2,a=w[t],u=p(s(a)),d=c+M*Math.sin(o),f=l+M*Math.cos(o)*_;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:o,depth:y,parentId:n,eccentricity:_}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(r,i,n,e,t)},buildScene(e,t,n,i){const r=n.nodeStyle,o=n.nodeSize,s="number"==typeof o?()=>o:"function"==typeof o?o:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=by(n),i=new Map;for(const t of e)i.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=i.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const o=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:i}]of r)for(let r=0;o>r;r++){const a=r/o*Math.PI*2,l=(r+1)/o*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*i,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*i,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Hp(t,"nodeSize")),i=r?r(Hp(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:i.fill||n.themeSemantic?.primary||"#6366f1",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Hp(n,"nodeSize"));if(4>=e)continue;const i="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,i,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=by(t),i=t.orbitSpeed??.25,r=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),o=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=i*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const i=a.get(e.parentId);if(!i)continue;const c=e.angle+o*s*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=i.x+e.ring*Math.sin(c),t.y=i.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}},wy=require("react/jsx-runtime");function ky(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var Sy=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ay(e,t){const n=Gh(e.theme),i=e.chartType||"force",r=()=>Kh({frameType:"network",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),o=e.size||[500,500],s={top:20,right:20,bottom:20,left:20,...e.margin},a=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const i=B(e.nodes||[]);if(i.length>0)return ff(i,t);const r=Array.isArray(e.edges)?B(e.edges):[];if(0===r.length)return[];const o=ky(e.sourceAccessor,"source"),s=ky(e.targetAccessor,"target");return ff(Array.from(new Set(r.flatMap(e=>[o(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[],c=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(s,{legend:e.legend,theme:n,position:c||"right",size:o,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&kf(s,{categories:a,colorScheme:e.colorScheme,theme:n,position:c||"right",size:o,hasTitle:!!e.title,legendLayout:e.legendLayout});const l=o[0]-s.left-s.right,u=o[1]-s.top-s.bottom,d=function(e){return vy[e]}(i);if(!d&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||n.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let f,p;if(Sy.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=r()),Zf.renderToStaticMarkup(Pf(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));h.__hierarchyRoot=i,f=[],p=[]}else{const i=B(e.nodes||[]),a=Array.isArray(e.edges)?B(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=r()),Zf.renderToStaticMarkup(Pf(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const n=ky(t.sourceAccessor,"source"),i=ky(t.targetAccessor,"target"),r=ky(t.valueAccessor,"value");return e.map(e=>({source:n(e)+"",target:i(e)+"",value:Number(r(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,h),0===i.length&&p.length>0){const e=new Set;for(const t of p){const n=wf(t.source),i=wf(t.target);n&&e.add(n),i&&e.add(i)}f=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else f=function(e,t){const n=ky(t.nodeIDAccessor,"id");return e.map(e=>({id:n(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,h)}let y=[],m=[],x=[],b=null;if(h.customNetworkLayout){const e=h.colorScheme,t=iu(e,n.colors.categorical,g),i=ru(t,e),r={nodes:f,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:n.colors,categorical:[...t]},resolveColor:i,config:h.layoutConfig??{}},o=h.customNetworkLayout(r);y=o.sceneNodes??[],m=o.sceneEdges??[],x=o.labels??[],b=o.overlays??null}else if(d){d.computeLayout(f,p,h,[l,u]);const e=d.buildScene(f,p,h,[l,u]);y=e.sceneNodes,m=e.sceneEdges,x=e.labels}const v=Xh(n);for(const e of x)e.fill||(e.fill=v.text);t&&(t.evidence=Kh({frameType:"network",width:o[0],height:o[1],marks:[...y.map(e=>({type:"node:"+(e.type??"node")})),...m.map(e=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:y.length,edgeCount:m.length}));const w=m.map((e,t)=>function(e,t){switch(e.type){case"line":return(0,eo.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,eo.jsx)("path",{d:n.pathD,fill:no(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,eo.jsx)("path",{d:n.pathD,fill:no(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,eo.jsx)("path",{d:n.pathD,fill:no(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)).filter(Boolean),k=y.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return(0,eo.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+t)}case"rect":{const n=e;return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+t)}case"arc":{const n=e,i=(0,Ur.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(to)||"";return(0,eo.jsx)("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+t)}case"symbol":{const n=e,i=ht(n.symbolType,n.size,n.path);return(0,eo.jsx)("path",{d:i,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?no(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return ro(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)).filter(Boolean),S=x.map((e,t)=>function(e,t){return(0,eo.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean),A=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:l,height:u},theme:n,idPrefix:e._idPrefix}):null,M=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const r=ff(f.length>0?f.map(e=>e.data||{id:e.id}):Array.from(new Set(p.flatMap(e=>[wf(e.source),wf(e.target)]).filter(Boolean))).map(e=>({id:e})),t);return 0===r.length?null:hf({categories:r,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:s,hasTitle:!!e.title,legendLayout:e.legendLayout})})():null,P=Kf.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:o,margin:s,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||M;return Zf.renderToStaticMarkup(Pf((0,wy.jsxs)(wy.Fragment,{children:[e.backgroundGraphics,w,k,S,A,e.foregroundGraphics,b]}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,legend:P,idPrefix:e._idPrefix}))}var My=c(require("react")),Py=c(require("react-dom/server")),_y=require("d3-geo"),jy=require("d3-quadtree"),Cy=require("d3-geo"),Iy={mercator:Cy.geoMercator,equalEarth:Cy.geoEqualEarth,albersUsa:Cy.geoAlbersUsa,orthographic:Cy.geoOrthographic,naturalEarth:Cy.geoNaturalEarth1,equirectangular:Cy.geoEquirectangular};function Ty(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Ry(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Ly(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function $y(e,t){if(2>e.length)return[e];const n=.4*t,i=[];let r=[e[0]];for(let t=1;e.length>t;t++){const o=e[t];Math.abs(o[0]-e[t-1][0])>n?(2>r.length||i.push(r),r=[o]):r.push(o)}return 2>r.length||i.push(r),i}function Ey(e,t,n=24){const i=t[0]-e[0],r=t[1]-e[1],o=Math.sqrt(i*i+r*r);if(0===o)return[e,t];const s=-r/o,a=i/o,c=Math.min(.3*o,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let i=0;n>=i;i++){const r=i/n,o=1-r;d.push([o*o*e[0]+2*o*r*l+r*r*t[0],o*o*e[1]+2*o*r*u+r*r*t[1]])}return d}function zy(e,t){if(2>e.length)return e;const n=t/2+1,i=[];for(let t=0;e.length>t;t++){const r=e[t];let o,s;0===t?(o=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(o=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(o*o+s*s)||1;i.push([r[0]+s/a*n,r[1]+-o/a*n])}return i}function Dy(e,t,n,i,r){const o=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(o*o+s*s);if(0===a)return[e,t];const c=s/a,l=-o/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}var By=require("d3-scale"),Fy=class e{constructor(e){this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this._stylePaintPending=!1,this.config=e}updateConfig(e){this.config={...this.config,...e},"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e.slice()}initStreaming(e=500){this.pointBuffer=new _e(e),this.timestampBuffer=new _e(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=Ne();jt(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t}pushMany(e){this.pointBuffer||this.initStreaming();const t=Ne();for(const n of e)jt(this.pointBuffer,n,this.timestampBuffer,t);this.lastIngestTime=t}pushLine(e){null!=e&&"object"==typeof e&&(this.lineData.push(e),this.version++)}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return;const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){for(const e of t)this.lineData.push(e);this.version++}}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!i.has(n(e)+"")||(r.push(e),!1)),r.length>0&&this.version++,r}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(n(e)+"");Ct(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(n(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++}setLayoutSelection(e){this.config.layoutSelection=e}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){const t=this._customRestyle;if(t){for(const n of this.scene){const i=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...i,...r}:i}this._stylePaintPending=!0}}computeScene(e){const{config:t}=this,n=this.projection,i=this.geoPath,r=this.scales,o=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return(0,Cy.geoEqualEarth)();if("string"==typeof e){const t=Iy[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Cy.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Iy[e.type],n=t?t():(0,Cy.geoEqualEarth)();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=(0,_y.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,_y.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=i,this.scales=r,this.baseScale=o,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,n=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,i=[...this.areas],r=Ty(n.xAccessor,"lon"),o=Ty(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[r(e),o(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Ry(n.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[r(e),o(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(n.projectionExtent){const[[i,r],[o,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,r],[o,r],[o,s],[i,s],[i,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*i),t.translate([e.width/2,e.height/2])}else{const r={type:"FeatureCollection",features:i},o=n.fitPadding??0;1>o||"undefined"==typeof process||"production"===process.env.NODE_ENV||console.warn(`[semiotic] fitPadding=${o} looks like pixels, but it's a fraction of the plot (0–0.5). A value >= 1 collapses the projection off-canvas — use e.g. 0.06.`);const s=e.width*o,a=e.height*o;t.fitExtent([[s,a],[e.width-s,e.height-a]],r)}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const i=this.geoPath,r=this.scales,o=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(o),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;if(!n)return;const i=this.geoPath,r=this.scales,o=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(o),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;if(!n||!n.rotate)return;const i=this.geoPath,r=this.scales,o=[...n.rotate()];n.rotate(e),this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(o),this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,n=0;for(const e of this.scene)"point"===e.type&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const i=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&(i[r++]=e);this._quadtree=(0,jy.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,i=this.geoPath,r=Ty(t.xAccessor,"lon"),o=Ty(t.yAccessor,"lat");if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=iu(t.colorScheme,t.themeCategorical,R),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:ru(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let o;try{o=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,i=vt("geo",e,n,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=o.nodes??[];if(this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null,this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return mt({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap;const s=[],a=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),c=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),l=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const n=!0===t.graticule?{}:t.graticule,r=(0,_y.geoGraticule)();n.step&&r.step(n.step);const o=i(r())||"";o&&s.push({type:"geoarea",pathData:o,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:n.stroke||"#e0e0e0",strokeWidth:n.strokeWidth||.5,strokeDasharray:n.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const n=i(e);if(!n)continue;const r=i.centroid(e),o=i.bounds(e),c=i.area(e),l=Ly(t.areaStyle,e,a);s.push({type:"geoarea",pathData:n,centroid:r,bounds:o,screenArea:c,style:l,datum:e,interactive:!0})}const u=Ry(t.lineDataAccessor);for(const i of this.lineData){const a=u(i);if(!a||2>a.length)continue;let l=[];if("geo"===t.lineType){const e=Array(a.length);for(let t=0;a.length>t;t++)e[t]=[r(a[t]),o(a[t])];for(let t=0;e.length-1>t;t++){const i=e[t],r=e[t+1],o=(0,_y.geoDistance)(i,r)||0,s=Math.max(2,Math.ceil(o/(Math.PI/180))),a=(0,_y.geoInterpolate)(i,r);for(let e=0;s>=e;e++){if(t>0&&0===e)continue;const i=n(a(e/s));null!=i&&l.push(i)}}}else for(let e=0;a.length>e;e++){const t=a[e],i=n([r(t),o(t)]);null!=i&&l.push(i)}if(2>l.length)continue;const d=Ly(t.lineStyle,i,c),h="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==a.length||2>l.length||"arc"!==t.flowStyle?2!==a.length||2>l.length||"offset"!==t.flowStyle||(l="geo"===t.lineType?zy(l,h):Dy(l[0],l[l.length-1],0,0,h)):l=Ey(l[0],l[l.length-1]);const f=$y(l,e.width);if(f.length>1)for(const e of f){if(2>e.length)continue;const t={type:"line",path:e,style:{...d,_edgeFade:!0},datum:i};s.push(t)}else s.push({type:"line",path:2>l.length&&f[0]||l,style:d,datum:i})}const d=this.getPoints(),h=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,f=n.clipAngle?n.clipAngle()??0:0,p=f>0?f*Math.PI/180:null,y=n.rotate?n.rotate():[0,0,0],g="function"==typeof n.center?n.center():[0,0],m=[(g[0]??0)-y[0],(g[1]??0)-y[1]];for(let e=0;d.length>e;e++){const i=d[e],a=r(i),c=o(i);if(null!=p&&(0,_y.geoDistance)([a,c],m)>p)continue;const u=n([a,c]);if(!u)continue;const f=t.pointStyle?t.pointStyle(i):{...l},y={type:"point",x:u[0],y:u[1],r:f.r||4,style:f,datum:i,pointId:h?h(i)+"":void 0};s.push(y)}return s}applyCartogramTransform(e,t){const n=function(e,t,n,i){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const o=t.strength??1;if(0===o)return null;const s=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&s(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,u=c.y,d=hi(r.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),1),h=Math.min(n.width,n.height)/2,f=(0,By.scaleLinear)().domain([0,d]).range([0,h]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}for(const e of r){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-u,e.x-l),n=Math.sqrt((e.x-l)**2+(e.y-u)**2),i=a(e.datum),r=n+((isFinite(i)?f(i):n)-n)*o;e.x=l+Math.cos(t)*r,e.y=u+Math.sin(t)*r}const p=n.width/2,y=n.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const e of r)e.x+=g,e.y+=m;const x={cx:p,cy:y,maxCost:d,availableRadius:h},b=e.filter(e=>"line"===e.type);if(b.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of r)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of b){const n=t.datum?.source,i=t.datum?.target;if(n&&i){const r=e.get(n+""),o=e.get(i+"");r&&o&&(t.path=[r,o])}}}return x}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let i=0;n.length>i;i++){const r=Oe(e,i,t);n[i]._decayOpacity=r,n[i].style={...n[i].style,opacity:r}}}applyPulse(){const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const t=Ne(),n=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray();for(let r=0;n.length>r&&i.length>r;r++){const o=qe(e,i[r],t);o>0&&(n[r]._pulseIntensity=o,n[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",n[r]._pulseGlowRadius=e.glowRadius??4)}}get hasActivePulses(){return He(this.config.pulse??{},this.timestampBuffer)}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of i)if(e.pointId){const t=n.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(r=!0))}for(const e of i)e.pointId&&!n.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:Ne(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=Be(e,this.activeTransition),n=De(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Fe(e.x,e._targetX,n),e.y=Fe(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Fy.QUADTREE_THRESHOLD=500;var Ny=Fy,Oy=require("react/jsx-runtime");function Wy(e,t){const n=Gh(e.theme),i=e.size||[e.width||600,e.height||400],r={top:10,right:10,bottom:10,left:10,...e.margin},o=Array.isArray(e.areas)?B(e.areas):e.areas,s=B(e.points),a=B(e.lines),c=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return ff(s.length>0?s:Array.isArray(o)&&o.length>0?"string"==typeof t?o.map(e=>({...e.properties||{},...e})):o:[],t)})():[],l=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:l||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&c.length>0&&kf(r,{categories:c,colorScheme:e.colorScheme,theme:n,position:l||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const u=i[0]-(r.left??0)-(r.right??0),d=i[1]-(r.top??0)-(r.bottom??0),h={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,themeCategorical:n.colors.categorical,themeSemantic:xe(n)},f=new Ny(h);if(o){if("string"==typeof o)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${o}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${o}')\` before calling renderGeoToStaticSVG.`);f.setAreas(o)}if(e.points&&f.setPoints(s),e.lines&&f.setLines(a),f.computeScene({width:u,height:d}),t&&(t.evidence=Kh({frameType:"geo",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:c.length>0?c.length:void 0})),0===f.scene.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||f.customLayoutOverlays?(0,Oy.jsxs)(Oy.Fragment,{children:[e.backgroundGraphics,e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,e.foregroundGraphics,f.customLayoutOverlays]}):null;return Py.renderToStaticMarkup(Pf(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,idPrefix:e._idPrefix}))}const p=f.scene.map((e,t)=>function(e,t){switch(e.type){case"geoarea":{const n=e;return n.pathData?(0,eo.jsx)("path",{d:n.pathData,fill:no(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1},"geoarea-"+t):null}case"point":{const n=e;return(0,eo.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:no(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const i="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return(0,eo.jsx)("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return ro(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)).filter(Boolean),y=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,g=e.showLegend?0===c.length?null:hf({categories:c,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,m=My.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||g;return Py.renderToStaticMarkup(Pf((0,Oy.jsxs)(Oy.Fragment,{children:[e.backgroundGraphics,p,y,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,legend:m,idPrefix:e._idPrefix}))}function qy(e,t){const n=e.size??[e.width??600,e.height??400],i=new Fl(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const r=qu(i,{...e,width:n[0],height:n[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=Kh({frameType:"physics",width:n[0],height:n[1],marks:r.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),r.svg}var Yy=require("react/jsx-runtime");function Hy(e,t){switch(e){case"xy":return jf(t);case"ordinal":return Uf(t);case"network":return Ay(t);case"geo":return Wy(t);case"physics":return qy(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Gy(e){return jf(e)}function Xy(e){return Uf(e)}function Vy(e){return Ay(e)}function Uy(e){return Wy(e)}var Ky=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Zy(e,t,n){return Jy(e,t).svg}function Qy(e,t,n){const i={},{svg:r,frameType:o}=Jy(e,t,0,i),s=i.evidence??Kh({frameType:o,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=e,{svg:r,evidence:s}}function Jy(e,t,n,i){const{data:r,width:o=600,height:s=400,theme:a,title:c,description:l,showLegend:d,showGrid:h,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=t,w=[o,s],k={...v.frameProps||{},...function(e,t){const n={};for(const i of t)void 0!==e[i]&&(n[i]=e[i]);return n}(v,Ky),theme:a,title:c,description:l,showLegend:d,showGrid:h,background:f,className:p,annotations:y,size:w,...void 0!==g&&{margin:g},...void 0!==m&&{colorScheme:m},...void 0!==b&&{legendPosition:b},_idPrefix:v._idPrefix},S=Hh[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const A=S.buildProps(r,x,m,k,v);let M=(0,{xy:jf,ordinal:Uf,network:Ay,geo:Wy,physics:qy}[S.frameType])(A,i);if("GaugeChart"===e&&A.__gauge){const e=A.__gauge,t=k.margin||{top:20,right:20,bottom:30,left:40},n=(o||300)-t.left-t.right,i=(s||300)-t.top-t.bottom,r=Math.min(n,i)/2*.85,c=t.left+n/2,l=t.top+i/2,d=(e.startAngleDeg+(e.gMax===e.gMin?0:(Math.max(e.gMin,Math.min(e.gMax,e.value??e.gMin))-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,h=Gh(a).colors.text,f=u.renderToStaticMarkup((0,Yy.jsxs)(Yy.Fragment,{children:[(0,Yy.jsx)("line",{x1:c,y1:l,x2:c+r*Math.cos(d),y2:l+r*Math.sin(d),stroke:h,strokeWidth:2.5,strokeLinecap:"round"}),(0,Yy.jsx)("circle",{cx:c,cy:l,r:4,fill:h})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}async function eg(e,t,n={}){const{format:i="png",scale:r=1,background:o}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(e)?Hy(e,t):Zy(e,t),o&&(s=s.replace(/<svg /,`<svg style="background:${o}" `));try{const e="sharp",t=await import(e);a=t.default??t}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=t.width||t.size?.[0]||600,l=t.height||t.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*r}).resize(Math.round(c*r),Math.round(l*r));return"jpeg"===i?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function tg(e,t={}){const{title:n,subtitle:i,theme:r,width:o=1200,height:s,layout:a={},background:c}=t,l=Xh(Gh(r)),d=a.columns||2,h=a.gap??16;let f=0;n&&(f+=30),i&&(f+=20),f>0&&(f+=10);const p=Math.floor((o-h-h*(d-1))/d),y=[];let g=0,m=f+h,x=0;for(const t of e){const e=Math.min(t.colSpan||1,d),n=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0),y.push({chart:t,x:h/2+g*(p+h),y:m,w:p*e+h*(e-1),h:n}),x=Math.max(x,n),g+=e}const b=s||m+x+h,v=y.map((e,t)=>{const{chart:n,x:i,y:o,w:s,h:a}=e,c={...n.props,width:s,height:a,theme:r,_idPrefix:"chart-"+t};let l;return l=n.component?Zy(n.component,c):n.frameType?Hy(n.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Yy.jsx)("g",{transform:`translate(${i},${o})`,children:(0,Yy.jsx)("foreignObject",{width:s,height:a,children:(0,Yy.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return u.renderToStaticMarkup((0,Yy.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:b,role:"img","aria-label":n||"Dashboard",style:{fontFamily:l.fontFamily},children:[n&&(0,Yy.jsx)("title",{children:n}),c&&(0,Yy.jsx)("rect",{x:0,y:0,width:o,height:b,fill:c}),n&&(0,Yy.jsx)("text",{x:o/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:n}),i&&(0,Yy.jsx)("text",{x:o/2,y:n?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),v]}))}var ng=c(require("react-dom/server")),ig=require("react/jsx-runtime");function rg(e,t,n,i={}){const{stepSize:r,windowSize:o,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=n.width||600,p=n.height||400,y=Gh(n.theme),g={...n,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=r||Math.max(1,Math.ceil(t.length/(s||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=m;t.length>=e;e+=m)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v={top:20,right:20,bottom:30,left:40,...n.margin},w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let i=0;x.length>i;i++){const r=x[i],s=t.slice(o?Math.max(0,r-o):0,r),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical,...h&&{decay:h}},c=new Gf(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(ug(c.scene,f,p,y,g))}else for(let i=0;x.length>i;i++){const r=x[i],s=t.slice(o?Math.max(0,r-o):0,r),m={chartType:e,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...h&&{decay:h},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new Ot(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(lg(b.scene,f,p,y,g,v)),l>0&&i>0&&b.activeTransition){const e=l*(1e3/u);for(let t=1;l>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/l*e),S.push(lg(b.scene,f,p,y,g,v))}}return S}function og(e,t,n={}){return t.map(t=>{try{return Zy(e,{...n,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||t.width||600}" height="${n.height||t.height||400}"></svg>`}})}function sg(e,t,n){const i=t.size??[t.width??600,t.height??400],r=Gh(t.theme),o=Xh(r),s=t.background||r.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${n}`:void 0,l=t.description?`${a}-desc-${n}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=Ou(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),h=(0,ig.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:o.fontFamily},children:[t.title&&(0,ig.jsx)("title",{id:c,children:t.title}),t.description&&(0,ig.jsx)("desc",{id:l,children:t.description}),s&&"transparent"!==s?(0,ig.jsx)("rect",{x:0,y:0,width:i[0],height:i[1],fill:s}):null,(0,ig.jsx)("g",{id:`${a}-frame-${n}`,children:d.map((e,t)=>so(e,t,`${a}-${n}`))})]});return ng.renderToStaticMarkup(h)}function ag(e,t={}){const{fps:n=12,frameCount:i,durationSeconds:r=2,includeInitialFrame:o=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/l)),d=i??Math.max(1,Math.ceil(r*Math.max(1,n))),h=c?{...e,background:c}:e,f=new Fl(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(o&&(f.tick(0),p.push(sg(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(l);p.push(sg(f,h,p.length))}return p}function cg(e,t){const n=e.background||t.colors.background;return n&&"transparent"!==n?n:null}function lg(e,t,n,i,r,o){const s=Xh(i),a={top:20,right:20,bottom:30,left:40,...r.margin},c=t-a.left-a.right,l=n-a.top-a.bottom,u=cg(r,i),d=e.map((e,t)=>so(e,t)).filter(Boolean),h=function(e,t,n,i,r,o){if(!e||0===e.length)return null;const s=Xh(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(o)e=o(c.value);else if(r){const[t,i]=r,o=i-t;if(0===o)continue;e=n-(c.value-t)/o*n}if(null==e)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,ig.jsxs)("g",{children:[(0,ig.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,ig.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?(0,ig.jsx)(ig.Fragment,{children:a}):null}(r.annotations,c,l,i,r.yExtent,o?.y),f="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return ng.renderToStaticMarkup((0,ig.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&(0,ig.jsx)("title",{id:y,children:f}),p&&(0,ig.jsx)("desc",{id:g,children:p}),u&&(0,ig.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,ig.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[h,d]}),f&&(0,ig.jsx)("text",{x:t/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]}))}function ug(e,t,n,i,r){const o=Xh(i),s={top:20,right:20,bottom:30,left:40,...r.margin},a="radial"===r.projection,c=a?s.left+(t-s.left-s.right)/2:s.left,l=a?s.top+(n-s.top-s.bottom)/2:s.top,u=cg(r,i),d=e.map((e,t)=>ao(e,t)).filter(Boolean),h="string"==typeof r.title?r.title:void 0,f="string"==typeof r.description?r.description:void 0,p=h?"semiotic-title":void 0,y=f?"semiotic-desc":void 0,g=[p,y].filter(Boolean).join(" ")||void 0;return ng.renderToStaticMarkup((0,ig.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":g,style:{fontFamily:o.fontFamily},children:[h&&(0,ig.jsx)("title",{id:p,children:h}),f&&(0,ig.jsx)("desc",{id:y,children:f}),u&&(0,ig.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,ig.jsx)("g",{transform:`translate(${c},${l})`,children:d}),h&&(0,ig.jsx)("text",{x:t/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:h})]}))}async function dg(e,t,n,i={}){const{fps:r=12,loop:o=!0,scale:s=1,background:a}=i,c=n.width||600,l=n.height||400,u=rg(e,t,a?{...n,background:a}:n,i);if(0===u.length)throw Error("No frames generated — check that data is not empty");return fg(u,c,l,{fps:r,loop:o,scale:s})}async function hg(e,t={}){const{fps:n=12,loop:i=!0,scale:r=1}=t,o=e.size??[e.width??600,e.height??400],s=ag(e,t);if(0===s.length)throw Error("No physics frames generated");return fg(s,o[0],o[1],{fps:n,loop:i,scale:r})}async function fg(e,t,n,i={}){const{fps:r=12,loop:o=!0,scale:s=1}=i,a=Math.round(t*s),c=Math.round(n*s);let l,u,d,h;try{const e="sharp",t=await import(e);l=t.default??t}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const e="gifenc",t=await import(e);u=t.GIFEncoder??t.default?.GIFEncoder??t.default?.default?.GIFEncoder,d=t.quantize??t.default?.quantize??t.default?.default?.quantize,h=t.applyPalette??t.default?.applyPalette??t.default?.default?.applyPalette}catch{throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const f=Math.round(1e3/r),p=u();for(let t=0;e.length>t;t++){const n=e[t],i=await l(Buffer.from(n),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),r=new Uint8Array(i),u=d(r,256),y=h(r,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:o?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|
|
1
|
+
var t,e=Object.create,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(t,e,r,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let c of n(e))s.call(t,c)||c===r||i(t,c,{get:()=>e[c],enumerable:!(a=o(e,c))||a.enumerable});return t},c=(t,o,n)=>(n=null!=t?e(r(t)):{},a(!o&&t&&t.__esModule?n:i(n,"default",{value:t,enumerable:!0}),t)),l={};((t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})})(l,{generateFrameSVGs:()=>tu,generateFrameSequence:()=>eu,generatePhysicsFrameSVGs:()=>ou,renderChart:()=>Vl,renderChartWithEvidence:()=>Hl,renderDashboard:()=>Ul,renderGeoToStaticSVG:()=>Xl,renderNetworkToStaticSVG:()=>ql,renderOrdinalToStaticSVG:()=>Yl,renderPhysicsToAnimatedGif:()=>cu,renderToAnimatedGif:()=>au,renderToImage:()=>Kl,renderToStaticSVG:()=>Bl,renderXYToStaticSVG:()=>Wl,resolveTheme:()=>io,themeStyles:()=>oo}),module.exports=(t=l,a(i({},"__esModule",{value:!0}),t));var u=c(require("react-dom/server")),h=c(require("react")),d=require("d3-scale");function f(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function p(t,e,i){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function y(t){const e=t.map(f),i=e.length-1;return t=>{if(0>=t){const[t,i,o]=e[0];return p(t,i,o)}if(t>=1){const[t,o,n]=e[i];return p(t,o,n)}const o=t*i,n=Math.floor(o),r=o-n,[s,a,c]=e[n],[l,u,h]=e[n+1];return p(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(h-c)*r))}}var g=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=y(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),x=y(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),b=y(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),v=y(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=y(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),k=y(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),S=y(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=y(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),M=y(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),_=y(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),P=y(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),T=y(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),R={blues:m,reds:x,greens:b,viridis:S,oranges:v,purples:w,greys:k,plasma:A,inferno:M,magma:_,cividis:P,turbo:T};function L(t){return t&&R[t]||m}y(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),y(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),y(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),y(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),y(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var C={category10:g,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...R},$=g,j=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],z=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function E(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||z.has(e)}(o)?i(o):o}const o=t?.[e]+"";return i?i(o):$[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o))%$.length]}function D(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const i=t[e];return"string"==typeof i&&i.length>0?i:void 0}function N(t,e,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const t=i;return e=>D(t,e)??"#999"}const o=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),n=o.every(t=>!isNaN(Number(t)));if(Array.isArray(i))return(0,d.scaleOrdinal)().domain(o).range(i).unknown("#999");const r=C[i]||C.category10;if(n&&"function"==typeof r){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:$;return(0,d.scaleOrdinal)().domain(o).range(t).unknown("#999")}}function F(t,e,i=[3,20],o){let n;if(n="function"==typeof e?e(t):t?.[e],!o)return n;const[r,s]=o,[a,c]=i;if(s===r)return(a+c)/2;let l=(n-r)/(s-r);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function I(t,e,i){return"function"==typeof t?t(i):i[t||e]}function O(t){return t instanceof Date?t.getTime():Number(t)}function B(t,e){return S(1===e?.5:t/(e-1))}function W(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>q(e(t))}function Y(t,e){const i=W(e??"value"),o=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=o?o(t):void 0;return{value:i(t),category:null==e?void 0:e+""}}}function q(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}}function X(t,e,i){const o=t.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(e,i):function(t,e,i){const o=null!=t.axis?i[t.axis]:null!=t.field?e[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const n=q(o);if(void 0===n)return!1;if(void 0!==t.gt&&t.gt>=n)return!1;if(void 0!==t.gte&&t.gte>n)return!1;if(void 0!==t.lt&&n>=t.lt)return!1;if(void 0!==t.lte&&n>t.lte)return!1;if(void 0!==t.within){const[e,i]=t.within;if(e>n||n>i)return!1}if(void 0!==t.outside){const[e,i]=t.outside;if(n>=e&&i>=n)return!1}return!0}(o,e,i))}function G(t,e,i){if(!e||0===e.length)return{};let o={};for(const n of e){if(!X(n,t,i))continue;const e="function"==typeof n.style?n.style(t,i):n.style;e&&(o={...o,...e})}return o}function V(t,e,i,o=t=>t){const n=t??(()=>({}));return e&&0!==e.length?(t,r)=>{const s=o(t),a={...n(t,r)};return Object.assign(a,G(s,e,i(s,r))),a}:n}function H(t,e,i){return t&&0!==t.length?(o,n)=>{const r=G(o,t,e(o,n)),s=i?i(o,n):void 0;return s?{...r,...s}:r}:i}function Z(t,e,i,o){if(!t||0===t.length)return o;const n=Y(e,i);return(e,i)=>{const r=e&&e.data||e,s=G(r,t,n(r)),a=o?o(e,i):void 0;return a?{...s,...a}:s}}function K(t,e,i,o){return H(t,function(t,e){const i=W(t),o=W(e);return(t,e)=>{const n=o(t);return{value:n,x:i(t),y:n,category:e}}}(e,i),o)}function U(t,e,i){const o=W(e);return H(t,(t,e)=>({value:o(t),category:e}),i)}var Q={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:n.lineStyle,...o,...n.styleRules&&{lineStyle:K(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.lineStyle||n.lineStyle)}})},J={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"area",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",y0Accessor:n.y0Accessor,groupAccessor:n.areaBy||e,colorAccessor:e,colorScheme:i,...o,...n.styleRules&&{lineStyle:K(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.lineStyle)}})},tt={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=n.xAccessor||"x",s=n.seriesAAccessor||"a",a=n.seriesBAccessor||"b",c=t=>O(I(r,"x",t)),l=t=>O(I(s,"a",t)),u=t=>O(I(a,"b",t)),h=n.seriesAColor||"var(--semiotic-danger, #dc2626)",d=n.seriesBColor||"var(--semiotic-info, #2563eb)",f=n.areaOpacity??.6,p=n.lineWidth??1.5,y=!1!==n.showLines,g=function(t,e,i,o){if(!t.length)return[];const n=t.filter(t=>Number.isFinite(e(t))).sort((t,i)=>e(t)-e(i)),r=[];let s=0,a=null,c=null,l=[];const u=(t,e)=>t>e?"A":e>t?"B":null,h=t=>`seg-${s}-${t}`,d=t=>r.push(t),f=(t,e)=>{d({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:h(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;n.length>t;t++){const r=n[t],p=e(r),y=i(r),g=o(r);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let t,e;if(l.length>0)t=l[0].x,e=l[0].y;else{const i=y-c.a-(g-c.b);if(0!==i){const o=Math.max(0,Math.min(1,(c.b-c.a)/i));t=c.x+o*(p-c.x),e=c.a+o*(y-c.a)}else t=c.x,e=c.a}d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:r})}for(const t of l)f(t,a??"A");return r}(Array.isArray(t)?t:[],c,l,u),m=[];if(y&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(c(t))).sort((t,e)=>c(t)-c(e));for(const t of e){const e=c(t),i=l(t),o=u(t);Number.isFinite(i)&&m.push({__x:e,__y:i,__diffSegment:"line-A"}),Number.isFinite(o)&&m.push({__x:e,__y:o,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...g,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(g.map(t=>t.__diffSegment))),areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?h:d,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:n.curve||"linear",...o}}},et={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=e||n.areaBy,s="string"==typeof r&&Array.isArray(t)?N(t,r,i):void 0;return{chartType:"stackedarea",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.areaBy,colorAccessor:r,colorScheme:i,normalize:n.normalize,stackOrder:n.stackOrder,lineStyle:null==n.areaOpacity?void 0:t=>{const e=null==r?void 0:E(t,r,s),i=n.showLine??!0;return{fill:n.color??e,stroke:i?n.stroke??e:"none",...i?{strokeWidth:n.strokeWidth??n.lineWidth??2}:{},fillOpacity:n.areaOpacity,...null==n.opacity?{}:{opacity:n.opacity}}},...o}}},it={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,...n.symbolBy&&{symbolAccessor:n.symbolBy},...n.symbolMap&&{symbolMap:n.symbolMap},colorScheme:i,...o,...n.styleRules&&{pointStyle:K(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.pointStyle)}})},ot={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=n.xCenter,s=n.yCenter,a=n.quadrants,c=n.centerlineStyle||{},l=!1!==n.showQuadrantLabels,u=n.quadrantLabelSize??12,d=c.stroke||"#999",f=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,y=h.createElement,g=a?[(t,e,i)=>{if(!e?.x||!e?.y)return null;const o=i.width,n=i.height,c=null!=r?e.x(r):o/2,g=null!=s?e.y(s):n/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(o,c)),x=Math.max(0,Math.min(n,g)),b=[{c:a.topLeft,x:0,y:0,w:m,h:x},{c:a.topRight,x:m,y:0,w:o-m,h:x},{c:a.bottomLeft,x:0,y:x,w:m,h:n-x},{c:a.bottomRight,x:m,y:x,w:o-m,h:n-x}],v=l?[y("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),y("text",{key:"ltr",x:o-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),y("text",{key:"lbl",x:8,y:n-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),y("text",{key:"lbr",x:o-8,y:n-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return y(h.Fragment,null,...b.map((t,e)=>t.w>0&&t.h>0?y("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),y("line",{key:"vc",x1:m,y1:0,x2:m,y2:n,stroke:d,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:o,y2:x,stroke:d,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange,colorScheme:i,pointStyle:n.pointStyle,...o,...g&&{svgPreRenderers:g}}}},nt={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const i=e.xAccessor||"x",o=e.yAccessor||"y",n=e.orderAccessor?[...t].sort((t,i)=>null==t||"object"!=typeof t?1:null==i||"object"!=typeof i?-1:O(I(e.orderAccessor,"order",t))-O(I(e.orderAccessor,"order",i))):t,r=new WeakMap;let s=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=O(I(i,"x",t)),n=O(I(o,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&s++}let a=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=O(I(i,"x",t)),n=O(I(o,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&r.set(t,{idx:a++,total:s})}return{data:n,orderMap:r}}(t,n),s=n.pointRadius??4;return{chartType:"line",data:r.data,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:i,lineStyle:n.lineStyle||{stroke:n.stroke||"#6366f1",strokeWidth:n.strokeWidth??s,opacity:n.opacity},pointStyle:t=>{const e=r.orderMap.get(t),i=e?.idx??0,o=e?.total??1;return{fill:o>0?B(i,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...o}}};function rt(t){return Math.max(0,Math.min(1,t))}function st(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const i=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){const t=[Number(i[1]),Number(i[2]),Number(i[3])];if(t.every(Number.isFinite))return t}return null}function at(t,e,i){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function ct(t,e){const i=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:rt(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===i.length)return"#999999";if(1===i.length)return i[0].color;const o=rt(e);if(i[0].offset>=o)return i[0].color;if(o>=i[i.length-1].offset)return i[i.length-1].color;for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1];if(e.offset>o||o>n.offset)continue;const r=n.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=st(e.color),c=st(n.color);if(!a||!c)return.5>s?e.color:n.color;const[l,u,h]=a,[d,f,p]=c;return at(l+(d-l)*s,u+(f-u)*s,h+(p-h)*s)}return i[i.length-1].color}function lt(t,e,i){return null==i?`${t}-${e}`:`${t}-${e}-${i}`}function ut(t){return!0===t?{topOpacity:.8,bottomOpacity:.05}:!1===t?void 0:t}var ht={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,colorAccessor:e,colorScheme:i,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,gradientFill:ut(o.gradientFill),...n.styleRules&&{pieceStyle:U(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},dt={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.stackBy,colorAccessor:e||n.stackBy,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",normalize:n.normalize,oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,gradientFill:ut(o.gradientFill),...n.styleRules&&{pieceStyle:U(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},ft={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"clusterbar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",groupBy:n.groupBy,colorAccessor:e||n.groupBy,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,gradientFill:ut(o.gradientFill),...n.styleRules&&{pieceStyle:U(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},pt={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"swimlane",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.subcategoryAccessor,colorAccessor:e||n.subcategoryAccessor,categoryAccessor:n.categoryAccessor,subcategoryAccessor:n.subcategoryAccessor,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",...null!=n.trackFill&&{trackFill:n.trackFill},...o,gradientFill:ut(o.gradientFill)})},yt={frameType:"ordinal",buildProps:(t,e,i,o,n)=>{const r=n.min??0,s=n.max??100,a=n.sweep??240,c=n.arcWidth??.3,l=180+(360-a)/2,u=n.thresholds||[{value:s,color:n.color||"#4e79a7"}],h=o.gradientFill,d=function(t){const{min:e,max:i,value:o,thresholds:n,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,h=i-e||1,d=(Math.max(e,Math.min(i,o))-e)/h;let f=n&&n.length>0?[...n].sort((t,e)=>t.value-e.value):[{value:i,color:r||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(i,t.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?d:1,e=lt("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;i>e;e++)o.push(ct(l.colorStops,t*(e+.5)/i));const n=lt("fill",0);y.push({category:n,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(n,{fill:o[0]||s})}}else{let t=e;for(let i=0;f.length>i;i++){const o=f[i],n=(o.value-t)/h,r=(t-e)/h,c=(o.value-e)/h,l=Math.max(0,(a?Math.min(d,c):c)-r),u=a?Math.max(0,n-l):0;if(l>0){const t=lt("fill",i);y.push({category:t,value:l,_zone:o.label||"Zone "+(i+1),_isFill:!0}),g.set(t,{fill:o.color})}if(u>0){const t=lt("bg",i);y.push({category:t,value:u,_zone:o.label||"Zone "+(i+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=o.value}}if(c&&n&&n.length>0)for(const t of n)t.value>e&&i>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>g.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:r,max:s,value:n.value,thresholds:u,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:!1!==n.fillZones,showScaleLabels:!1!==n.showScaleLabels,gradientFill:h&&"object"==typeof h&&"colorStops"in h?h:void 0}),f=o.margin||{top:20,right:20,bottom:30,left:40},[p,y]=o.size||[300,300];return{chartType:"donut",data:d.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(f.left||0)-(f.right||0),y-(f.top||0)-(f.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:d.pieceStyle,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o,showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...d.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:n.value,startAngleDeg:l,thresholds:u}}}},gt=require("d3-scale");function mt(t){let e=1/0,i=-1/0;for(const o of t)e>o&&(e=o),o>i&&(i=o);return[e,i]}function xt(t,e=-1/0){let i=e;for(const e of t)e>i&&(i=e);return i}function bt(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function vt(t,e,i){const o=e.incoming[t.id],n=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:i.get(t.id).targetSide});for(const t of n)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:i.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>t.time-e.time||(s[t.kind]??99)-(s[e.kind]??99))},c=r.length?function(t,e=1/0){let i=e;for(const e of t)i>e&&(i=e);return i}(r.map(t=>t.time)):null,l=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,h=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),d=new Map;for(let t=1;h.length>t;t++)d.set(h[t],h[t-1]);const f=t=>{const e=d.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const p=[];let y=0,g=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let i=e-("top"===t.side?y:g);if(i>0){const e="top"===t.side?"bot":"top",o=Math.min(i,"top"===e?y:g);if(o>0){const n=f(t.time);p.push({time:n,delta:-o,kind:"transfer-out",side:e}),p.push({time:n,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:g-=o,"top"===t.side?y+=o:g+=o,i-=o}i>0&&null!==u&&(p.push({time:u,delta:+i,kind:"create",side:t.side}),"top"===t.side?y+=i:g+=i)}"top"===t.side?y-=e:g-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:g+=e}r.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const t of r){if(k.push({t:t.time,topMass:m,botMass:x}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:x;S.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:x+=t.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:t.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let t=M;for(;k.length>t+1&&k[t+1].t===k[M].t;)t++;A.push(k[M]);for(let e=M+1;t>=e;e++){const t=A[A.length-1];k[e].topMass===t.topMass&&k[e].botMass===t.botMass||A.push(k[e])}M=t+1}const _=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of n)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let T=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===T||t.systemOutTime>T)&&(T=t.systemOutTime);if(A.length>0){const t=A[A.length-1],e=Math.max(null!=_?_:-1/0,null!=T?T:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&A.push({t:e,topMass:t.topMass,botMass:t.botMass});const i=A[0],o=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(o)&&i.t>o&&i.topMass+i.botMass>0&&A.unshift({t:o,topMass:i.topMass,botMass:i.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function wt(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function kt(t,e){return t.map(t=>({t:wt(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function St(t,e,i){const o=t.value*i;if("out"===t.kind){const n=t.sideMassBefore*i;if("top"===t.side){const t=e-n;return[t,t+o]}const r=e+n;return[r-o,r]}const n=t.sideMassAfter*i;if("top"===t.side){const t=e-n;return[t,t+o]}const r=e+n;return[r-o,r]}function At(t,e){let i=0;for(let o=0;e.length>o;o++)for(let n=o+1;e.length>n;n++){const r=e[o],s=e[n];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&i++)}return i}function Mt(t,e){let i=0;for(const o of e)i+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return i}function _t(t,e){return 1e3*At(t,e)+Mt(t,e)}function Pt(t,e){return{slots:t.map(t=>({peak:{...t.peak},occupants:t.occupants.slice()})),map:{...e}}}function Tt(t,e,i){t.length>8||i.length>40?(function(t,e,i,o=6){const n=t.length;if(1>=n)return;let r=Pt(t,e),s=_t(e,i);for(let a=0;o>a;a++){const o=Array(n).fill(0),a=Array(n).fill(0);for(const t of i){const i=e[t.source],n=e[t.target];o[i]+=n*(t.value||1),a[i]+=t.value||1,o[n]+=i*(t.value||1),a[n]+=t.value||1}const c=Array.from({length:n},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),l=c.map(e=>t[e]),u=new Map;c.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e);const h=_t(e,i);if(s>h)s=h,r=Pt(t,e);else if(h===s)break}!function(t,e,i){t.length=0;for(const e of i.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(i.map))e[t]=i.map[t]}(t,e,r)}(t,e,i,6),function(t,e,i,o=6){const n=t.length;if(1>=n)return;let r=_t(e,i);for(let s=0;o>s;s++){let o=!1;for(let s=0;n-1>s;s++){const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=_t(e,i);if(r>a)r=a,o=!0;else{const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,i,6)):function(t,e,i){const o=t.length;if(1>=o)return;const n={...e},r=Object.keys(n),s=Array.from({length:o},(t,e)=>e),a=s.slice(),c={...n};let l=s.slice(),u=1/0;const h=()=>{for(const t of r)c[t]=a[n[t]];const t=_t(c,i);u>t&&(u=t,l=s.slice())},d=(t,e)=>{const i=s[t],o=s[e];s[t]=o,s[e]=i,a[i]=e,a[o]=t};h();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(d(p%2==0?0:f[p],p),h(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(e=>t[e]),g=new Map;l.forEach((t,e)=>g.set(t,e));for(const t of Object.keys(e))e[t]=g.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,i)}function Rt(t,e,i,o,n){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=n,h={},d={};for(const e of t)h[e.id]=i[e.id].topPeak||0,d[e.id]=i[e.id].botPeak||0;const f="half"===u,p={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,i=Array.isArray(e.xExtent)?e.xExtent[1]:null;let n=null!=t&&Number.isFinite(t)?t:1/0,r=null!=i&&Number.isFinite(i)?i:-1/0;for(const t of o.outgoing[e.id]){n>t.startTime&&(n=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&n>t.systemInTime&&(n=t.systemInTime);const e=f?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=f?(t.startTime+t.endTime)/2:t.startTime;n>e&&(n=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}p[e.id]={start:Number.isFinite(n)?n:null,end:Number.isFinite(r)?r:null}}const y={},g=[];if("reuse"===c){const i=new Map;for(const e of t)i.set(e.id,0);const n=new Map;for(const e of t)n.set(e.id,0);for(const t of e)n.set(t.target,(n.get(t.target)??0)+1);const r=[];for(const e of t)0===(n.get(e.id)??0)&&r.push(e.id);for(;r.length;){const t=r.shift();for(const e of o.outgoing[t]??[]){const o=(i.get(t)??0)+1;o>(i.get(e.target)??0)&&i.set(e.target,o),n.set(e.target,n.get(e.target)-1),0===n.get(e.target)&&r.push(e.target)}}const s=[...t].filter(t=>null!==p[t.id].start).sort((t,e)=>{const o=i.get(t.id)??0,n=i.get(e.id)??0;return o!==n?o-n:p[t.id].start-p[e.id].start}),a=t.filter(t=>null===p[t.id].start);for(const t of[...s,...a]){const e=p[t.id];let i=-1;for(let t=0;g.length>t;t++){const o=g[t].occupants[g[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){i=t;break}}-1===i&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),i=g.length-1),g[i].occupants.push({id:t.id,end:e?.end??-1/0}),g[i].peak.topPeak=Math.max(g[i].peak.topPeak,h[t.id]),g[i].peak.botPeak=Math.max(g[i].peak.botPeak,d[t.id]),y[t.id]=i}}else t.forEach((t,e)=>{g.push({occupants:[{id:t.id,end:p[t.id]?.end??-1/0}],peak:{topPeak:h[t.id],botPeak:d[t.id]}}),y[t.id]=e});let m=null,x=null,b=null,v=null;const w=()=>{m=At(y,e),b=Mt(y,e)},k=()=>{x=At(y,e),v=Mt(y,e)};"crossing-min"===l?(w(),Tt(g,y,e),k()):"inside-out"===l?(w(),function(t,e){const i=t.length;if(1>=i)return;const o=t=>t.peak.topPeak+t.peak.botPeak,n=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(i),s=Math.floor((i-1)/2);r[s]=n[0].idx;let a=s-1,c=s+1;for(let t=1;n.length>t;t++)t%2==1&&i>c||0>a?r[c++]=n[t].idx:r[a--]=n[t].idx;const l=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),Tt(g,y,e),function(t,e,i){const o=t.length;if(1>=o)return;const n=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=_t(e,i);for(const{slot:a}of n){const n=t.indexOf(a);if(0>n)continue;const c=r;if(n===c)continue;const l=t[n];t.splice(n,1),t.splice(c,0,l);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(c>n){for(let t=n+1;c>=t;t++)u.set(t,t-1);u.set(n,c)}else{for(let t=c;n>t;t++)u.set(t,t+1);u.set(n,c)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const h=_t(e,i);if(h>s){const i=t[c];t.splice(c,1),t.splice(n,0,i);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(n>c){for(let t=c+1;n>=t;t++)r.set(t,t-1);r.set(c,n)}else{for(let t=n;c>t;t++)r.set(t,t+1);r.set(c,n)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=h}}(g,y,e),k());const S=g.map(t=>{const e=new Map;for(const o of t.occupants){const t=i[o.id];if(t)for(const i of t.samples){const t=e.get(i.t)||{top:0,bot:0};e.set(i.t,{top:Math.max(t.top,i.topMass),bot:Math.max(t.bot,i.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),A=(t,e)=>{let i={top:0,bot:0};for(const[o,n]of t){if(o>e)break;i=n}return i},M=[];for(let t=0;g.length-1>t;t++){const e=S[t],i=S[t+1],o=new Set([...e.map(t=>t[0]),...i.map(t=>t[0])]);let n=0;for(const t of o){const o=A(e,t),r=A(i,t);o.bot+r.top>n&&(n=o.bot+r.top)}M.push(n)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let t=1;g.length>t;t++)P+=M[t-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>r){const t=r/P;for(let e=0;_.length>e;e++)_[e]*=t}const T=0===g.length?0:g[0].peak.topPeak+M.reduce((t,e)=>t+e,0)+g[g.length-1].peak.botPeak,R={};for(const e of t)R[e.id]=_[y[e.id]];return{effectiveSlotsHeight:T,centerlines:R,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Lt(t){const{sx:e,sTop:i,sBot:o,tx:n,tTop:r,tBot:s,cp1X:a,cp2X:c}=t,l=(i+o)/2,u=(r+s)/2;return{pathD:[`M${e},${i}`,`C${a},${i} ${c},${r} ${n},${r}`,`L${n},${s}`,`C${c},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:n,y:u}],halfWidth:(o-i)/2}}}function Ct(t){const{nodes:e,edges:i,domain:o,plotW:n,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=t,u=function(t,e,i){const o=[],n=new Set(t.map(t=>t.id)),r=Array.isArray(i)&&2===i.length,s=r&&Number.isFinite(i[0])&&Number.isFinite(i[1]);r&&s&&s&&i[1]>=i[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)n.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),n.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,i,o),h=(0,gt.scaleTime)().domain(o).range([0,n]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(t,e,i){const{plotH:o,pairing:n="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=i,c=function(t,e){const i={},o={};for(const e of t)i[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),i[t.target]&&i[t.target].push(t);return{incoming:i,outgoing:o}}(t,e),l=function(t,e,i,o="value"){const n="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const i=new Map;for(const o of t){const t=o[e];i.has(t)||i.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const n=i.get(t);n.edges.push(o),n.total+=o.value,n.earliestStart=Math.min(n.earliestStart,o.startTime),n.latestEnd=Math.max(n.latestEnd,o.endTime)}const s=[...i.values()];s.sort("temporal"===o?(t,i)=>"target"===e?t.earliestStart-i.earliestStart:t.latestEnd-i.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:n);return s};for(const e of t){const t=i.outgoing[e.id],o=i.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=i});else if(0===t.length)a(o,"source").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=i});else{const e=a(o,"source"),i=a(t,"target"),n=Math.max(e.length,i.length);for(let t=0;n>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const i of e[t].edges)s.get(i.id).targetSide=o;if(i[t])for(const e of i[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,n);let u={};for(const e of t)u[e.id]=vt(e,c,l);const h=Rt(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),d=new Set;for(const t of e){const e=h.slotByNode[t.source],i=h.slotByNode[t.target];if(void 0===e||void 0===i)continue;const o=l.get(t.id);e!==i?e>i?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(d.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],i=c.incoming[e.id],o=new Set(t.map(t=>l.get(t.id).sourceSide)),n=new Set(i.map(t=>l.get(t.id).targetSide));if(1===o.size&&i.length>0){const t=[...o][0];for(const e of i)h.slotByNode[e.source]===h.slotByNode[e.target]&&(l.get(e.id).targetSide=t)}if(1===n.size&&t.length>0){const e=[...n][0];for(const i of t)h.slotByNode[i.source]===h.slotByNode[i.target]&&(l.get(i.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],i=c.outgoing[e.id];if(0===t.length||0===i.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const i of t)"top"===l.get(i.id).targetSide?e.inTop+=i.value:e.inBot+=i.value;for(const t of i)"top"===l.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},n=(t,e)=>{const n=o(),r="top"===t?n.outTop-n.inTop:n.outBot-n.inBot,s="top"===e?n.inTop-n.outTop:n.inBot-n.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),c=i.filter(e=>!d.has(e.id)&&l.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=e,!0)};let r=i.length+1;for(;r-- >0&&(n("top","bot")||n("bot","top")););}u={};for(const e of t)u[e.id]=vt(e,c,l);const f=Rt(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(o-y*(f.slots.length+1))/p):1,m=Rt(t,e,u,c,{plotH:o,padding:y,valueScale:g,packing:r,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(e,i,{plotH:r,...l}),{centerlines:f,nodeData:p,valueScale:y}=d,g=[],m=[];e.forEach((t,e)=>{const n=p[t.id];if(!n||0===n.samples.length)return;const r=function(t,e,i,o,n){if(0===t.length)return null;const r=kt(t,n),s=t=>e-r[t].topMass*i,a=t=>e+r[t].botMass*i;let c=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)c+=` L${o(r[t].t)},${s(t)}`;c+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)c+=` L${o(r[t].t)},${a(t)}`;return c+" Z"}(n.samples,f[t.id],y,h,o);if(!r)return;const s=kt(n.samples,o),a=s.find(t=>t.topMass+t.botMass>0)||s[0],l=f[t.id]+(a.botMass-a.topMass)*y/2,u=c(t.id,e),m=function(t,e,i,o,n){const r=i.nodeData[t];if(!r||0===r.samples.length)return[];const s=i.valueScale,a=i.centerlines[t],c=kt(r.samples,n),l=c.find(t=>t.topMass+t.botMass>0)||c[0],u=[...c].reverse().find(t=>t.topMass+t.botMass>0)||c[c.length-1],h=o(l.t),d=o(u.t),f=t=>o(wt(t,n)),p=[],y=(t,e,i,o)=>`M${t},${e} L${i},${e} L${i},${o} L${t},${o} Z`;for(const i of e){if(i.source===t&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){const t=r.localAttachments.get(i.id);if(t&&"out"===t.kind&&i.startTime>i.systemInTime){const e=f(i.systemInTime),o=f(i.startTime),n=e-20,r=Math.max(h,n);if(o>r){const[i,c]=St(t,a,s);p.push({pathD:y(r,i,o,c),x0:n,x1:e,from:0,to:1})}}}if(i.target===t&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){const t=r.localAttachments.get(i.id);if(t&&"in"===t.kind&&i.systemOutTime>i.endTime){const e=f(i.systemOutTime),o=f(i.endTime),n=e+20,r=Math.min(d,n);if(r>o){const[i,c]=St(t,a,s);p.push({pathD:y(o,i,r,c),x0:e,x1:n,from:1,to:0})}}}}return p}(t.id,i,d,h,o);g.push({id:t.id,pathD:r,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:t.__raw??t,labelX:h(a.t)-4,labelY:l,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),i.forEach(t=>{const e=p[t.source]?.localAttachments.get(t.id),i=p[t.target]?.localAttachments.get(t.id);if(!e||!i)return;const n=x.get(t.source)??0,r=c(t.source,n),l=function(t,e,i,o,n,r,s,a){const c=n,l=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(l(t.time)),h=r(l(i.time)),d=t.value*c,f=i.value*c,p=t.sideMassBefore*c,y=i.sideMassAfter*c;let g,m,x,b;"top"===t.side?(g=e-p,m=g+d):(m=e+p,g=m-d),"top"===i.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(h-u):"target"===s?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:g,sBot:m,tx:h,tTop:x,tBot:b,cp1X:v,cp2X:v}}(e,f[t.source],i,f[t.target],y,h,s,o),{pathD:u,bezier:d}=Lt(l);m.push({id:t.id,pathD:u,fill:r,opacity:a,rawDatum:t.__raw??t,bezier:d})}),{layout:d,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:h}}var $t=t=>{const{bands:e=[],ribbons:i=[],showLabels:o=!0}=t.config,n=[];for(const t of i)n.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}});for(const t of e)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const i=t.gradientStubs[e];n.push({type:"bezier",pathD:i.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:i.x0,x1:i.x1,from:i.from,to:i.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of e)n.push({type:"bezier",pathD:t.pathD,style:{...t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86},stroke:t.stroke??t.fill,strokeWidth:t.strokeWidth??.5},datum:{__kind:"band",data:t.rawDatum,id:t.id}});const r=o?e.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:e.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:n,labels:r}},jt={frameType:"network",buildProps:(t,e,i,o,n)=>{const{edgeWidth:r,edgeColor:s,edgeOpacity:a}=n,c=n.edgeStyle??(void 0!==r||void 0!==s||void 0!==a?t=>{const e=t?.data||t;let i=1;if("number"==typeof r)i=r;else if("function"==typeof r)i=r(e);else if("string"==typeof r){const t=e?.[r],o="number"==typeof t?t:Number(t);i=Number.isFinite(o)&&o>0?o:1}return{stroke:s??"#999",strokeWidth:i,opacity:a??.6}}:void 0);return{chartType:"force",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,colorBy:e,colorScheme:i,iterations:n.iterations,forceStrength:n.forceStrength,showLabels:n.showLabels,nodeLabel:n.nodeLabel,nodeSize:n.nodeSize,nodeSizeRange:n.nodeSizeRange,nodeStyle:Z(n.styleRules,e,"number"==typeof n.nodeSize?void 0:n.nodeSize,n.nodeStyle)??n.nodeStyle,edgeStyle:c,...o}}},zt={frameType:"network",buildProps:(t,e,i,o,n)=>{const r=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),s=n.sourceAccessor||"source",a=n.targetAccessor||"target",c=n.valueAccessor||"value",l=n.nodeIdAccessor||"id",u=n.startTimeAccessor||"startTime",h=n.endTimeAccessor||"endTime",d=n.systemInTimeAccessor,f=n.systemOutTimeAccessor,p=n.xExtentAccessor||"xExtent",y=n.edgeIdAccessor||"id",g=(t,e)=>"function"==typeof t?t(e):e[t],m=Array.isArray(n.edges)?n.edges:[],x=Array.isArray(n.nodes)?n.nodes:[],b=x.length>0?x:function(t,e,i,o){const n=new Set;return e.forEach(t=>{const e="function"==typeof i?i(t):t[i],r="function"==typeof o?o(t):t[o];n.add(e),n.add(r)}),Array.from(n).map(t=>({id:t}))}(0,m,s,a),v=[r(n.domain?.[0]),r(n.domain?.[1])],w=b.map(t=>{const e=g(l,t)+"",i=g(p,t),o={id:e,__raw:t};if(Array.isArray(i)&&2===i.length){const t=r(i[0]),e=r(i[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),k=m.map((t,e)=>{const i=g(y,t),o={id:null!=i?i+"":`${g(s,t)}-${g(a,t)}-${e}`,source:g(s,t)+"",target:g(a,t)+"",value:Number(g(c,t)),startTime:r(g(u,t)),endTime:r(g(h,t)),__raw:t};if(d){const e=r(g(d,t));Number.isFinite(e)&&(o.systemInTime=e)}if(f){const e=r(g(f,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[S,A]=o.size??[600,400],M={top:20,right:20,bottom:20,left:20,...o.margin},_=o.legendPosition??"right";o.showLegend&&("right"===_?M.right=Math.max(M.right,100):"left"===_?M.left=Math.max(M.left,100):"bottom"===_?M.bottom=Math.max(M.bottom,70):"top"===_&&(M.top=Math.max(M.top,40)));const P=M,T=S-P.left-P.right,R=A-P.top-P.bottom,L=Array.isArray(i)?i:null,C=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],$="function"==typeof e?e:null,j=$?b.map(t=>({_cat:$(t)})):b,z=$?"_cat":"string"==typeof e?e:void 0,D=z?N(j,z,i):null,F=new Map;for(const t of w)F.set(t.id,t.__raw);const{layoutConfig:I,issues:O}=Ct({nodes:w,edges:k,domain:v,plotW:T,plotH:R,ribbonLane:n.ribbonLane||"both",edgeOpacity:"number"==typeof n.edgeOpacity?n.edgeOpacity:.35,colorOf:(t,i)=>{if(e&&F.has(t)){const i=F.get(t);return $?E({_cat:$(i)},"_cat",D??void 0):E(i,"string"==typeof e?e:"id",D??void 0)}const o=L||C;return o[i%o.length]},layoutOpts:{pairing:n.pairing||"temporal",packing:n.packing||"reuse",laneOrder:n.laneOrder||"crossing-min",lifetimeMode:n.lifetimeMode||"half"}});if(O.length>0){const t=O.map(bt).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:$t,layoutConfig:I,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:e,colorScheme:i,...o,margin:P}}},Et=(require("react"),require("react")),Dt=require("react/jsx-runtime");function Nt(t,e){const i=new Set;let o={...t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o={...o,...e};for(const t of i)t()}}),...e??{}};return{getState:()=>o,subscribe:function(t){return i.add(t),()=>{i.delete(t)}}}}function Ft(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 It(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:Ot}}),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 Ot=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Bt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Wt={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}},Yt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Ot,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 qt(t,e){if("light"===e)return Bt;if("dark"===e)return Wt;if("high-contrast"===e)return Yt;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?Wt:Bt;return It({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return It({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[Xt,Gt]=function(t){let e=null;const i=()=>(e||(e=(0,Et.createContext)(null)),e),o=Nt(t);return[function({children:e,initialState:o}){const n=(0,Et.useRef)(o),r=(0,Et.useMemo)(()=>Nt(t,n.current),[]),s=i();return(0,Dt.jsx)(s.Provider,{value:r,children:e})},(t,e)=>{const n=i(),r=(0,Et.useContext)(n)??o,s=(0,Et.useRef)(t);s.current=t;const a=(0,Et.useRef)({hasValue:!1,value:void 0}),c=(0,Et.useCallback)(()=>{const t=s.current(r.getState()),i=a.current;return i.hasValue&&e&&e(i.value,t)?i.value:(a.current={hasValue:!0,value:t},t)},[r,e]),l=(0,Et.useCallback)(()=>s.current(r.getState()),[r]);return(0,Et.useSyncExternalStore)(r.subscribe,c,l)}]}(t=>({theme:Bt,setTheme(e){t(t=>({theme:qt(t.theme,e)}))}})),Vt={light:Bt,dark:Wt,"high-contrast":Yt,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}},Ht=require("d3-scale");function Zt(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}var Kt={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r="string"==typeof i?i:"blues",s=n.areaStyle??function(t,e,i,o){if(!Array.isArray(t))return;const n=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let r=1/0,s=-1/0;for(const e of t){const t=n(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>s&&(s=t))}const a=(0,Ht.scaleSequential)(L(i)).domain([Number.isFinite(r)?r:0,Number.isFinite(s)?s:1]);return t=>{const e=n(t);return{fill:null!=e&&isFinite(e)?a(e):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(n.areas,n.valueAccessor,r,n.areaOpacity??1),a=n.styleRules?V(s,n.styleRules,t=>{return{value:(e=t,"function"==typeof n.valueAccessor?n.valueAccessor(e):null!=n.valueAccessor?e?.properties?.[n.valueAccessor]??e?.[n.valueAccessor]:void 0)};var e},Zt):s;return{areas:n.areas,projection:n.projection||"equalEarth",areaStyle:a,valueAccessor:n.valueAccessor,colorScheme:r,graticule:n.graticule,fitPadding:n.fitPadding,...o}}},Ut={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r=t||n.points,s=n.pointStyle??function(t,e,i,o){const n=Array.isArray(t)?t:[];let r,s;if(e){const t="string"==typeof e?e:"__geoColorBy",o="string"==typeof e?n:n.map(t=>({...t,__geoColorBy:e(t)}));r=N(o,t,i)}if(o.sizeBy){const t=n.map("function"==typeof o.sizeBy?o.sizeBy:t=>t?.[o.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=mt(t))}return t=>({fill:e&&r?E(t,e,r):"#007bff",fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?F(t,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(r,e,i,{sizeBy:n.sizeBy,sizeRange:n.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=n.styleRules?V(s,n.styleRules,Y(e,n.sizeBy)):s;return{points:r,xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",areas:n.areas,areaStyle:n.areaStyle,pointStyle:a,sizeBy:n.sizeBy,colorBy:e,colorScheme:i,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,...o}}},Qt={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r=(Array.isArray(t)?t:null)||n.flows||[],s=n.nodeIdAccessor||"id",a=n.valueAccessor||"value",c=n.xAccessor||"lon",l=n.yAccessor||"lat",u="function"==typeof c?c:t=>t[c],h="function"==typeof l?l:t=>t[l],d=(n.nodes||[]).map(t=>({...t,x:u(t),y:h(t)})),f=new Map;for(const t of d)f.set(t[s]+"",t);const p=n.edgeColorBy??e,y="function"==typeof p,g=r.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=f.get(t.source+""),i=f.get(t.target+"");return e&&i?{...t,coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?N(g.map(t=>({[m]:p(t)})),m,i||"category10"):N(g,p,i||"category10"):null,b=t=>p&&x?E(t,p,x):"#007bff";let v=1/0,w=-1/0;for(const t of g){const e=Number(t[a]??0);isFinite(e)&&(v>e&&(v=e),e>w&&(w=e))}const k=w>v?w-v:0,[S,A]=n.edgeWidthRange??[1,8],M=A-S,_=n.edgeOpacity??.6,P=n.edgeLinecap??"round";return{lines:g,points:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:n.lineType||"geo",flowStyle:n.flowStyle||"basic",areas:n.areas,areaStyle:n.areaStyle,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(t?.[a]),i=Number.isFinite(e)?e:v,o=S+Math.max(0,Math.min(1,k>0?(i-v)/k:0))*M;return{stroke:b(t),strokeWidth:o,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}};function Jt(t){const[e,i]=t;return{width:e,height:i,plot:{x:32,y:24,width:Math.max(80,e-64),height:Math.max(80,i-58)}}}function te(t){const e=(t??"")+"";if(!e)return"#4e79a7";const i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let t=0;e.length>t;t+=1)o=31*o+e.charCodeAt(t)>>>0;return i[o%i.length]}function ee(t,e="#4e79a7",i){const o=i?.styleRules,n=!!o&&o.length>0,r=n?W(i?.valueAccessor):void 0;return i=>{const s=i.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,c={fill:null==a?e:te(a),stroke:"#111827",strokeWidth:1,opacity:.9};return n&&s&&Object.assign(c,G(s,o,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function ie(t,e,i,o){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:i},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function oe(t,e,i){return"function"==typeof i?i(t,e):t[i]}function ne(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function re(t,e,i){return Math.max(e,Math.min(i,t))}function se(t,e){const i=ne(t);return null!=i&&i>0?i:e}function ae(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function ce(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}var le=require("d3-scale");function ue(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var he={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},de=1e-9,fe=.005;function pe(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function ye(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function ge(t,e,i){return Math.max(e,Math.min(i,t))}function me(t){return 0>t?-1:1}function xe(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function be(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function ve(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function we(t,e,i,o,n,r,s,a){const c=n-t,l=(i+s)/2-Math.abs(c);if(0>=l)return null;const u=r-e,h=(o+a)/2-Math.abs(u);return h>0?h>l?{nx:me(c),ny:0,penetration:l}:{nx:0,ny:me(u),penetration:h}:null}function ke(t,e,i,o,n,r,s){const a=r/2,c=s/2;let l=t-ge(t,o-a,o+a),u=e-ge(e,n-c,n+c);const h=l*l+u*u;if(h>i*i)return null;if(de>=h){const r=Math.abs(t-(o-a)),s=Math.abs(t-(o+a)),h=Math.abs(e-(n-c)),d=Math.abs(e-(n+c)),f=Math.min(r,s,h,d);return f===r?(l=-1,u=0,{nx:l,ny:u,penetration:i+r}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:i+s}):f===h?(l=0,u=-1,{nx:l,ny:u,penetration:i+h}):(l=0,u=1,{nx:l,ny:u,penetration:i+d})}const d=Math.sqrt(h);return{nx:l/d,ny:u/d,penetration:i-d}}function Se(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,o,n,r){const s=o-t,a=n-e,c=i+r,l=s*s+a*a;if(l>=c*c)return null;if(de>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return we(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=ke(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?ke(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function Ae(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?ke(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):we(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,o,n,r,s,a=0){const c=r-o,l=s-n,u=c*c+l*l,h=u>de?ge(((t-o)*c+(e-n)*l)/u,0,1):0,d=i+a/2,f=t-(o+c*h),p=e-(n+l*h),y=f*f+p*p;if(y>=d*d)return null;if(de>=y){const t=Math.sqrt(u);return t>de?{nx:-l/t,ny:c/t,penetration:d}:{nx:1,ny:0,penetration:d}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:d-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Me(t,e){return`${t}\0${e}`}function _e(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function Pe(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:pe(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function Te(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function Re(t){return{id:t.id,shape:ye(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:Te(t.bodyFilter),index:t.index}}function Le(t,e){return!!e?.some(e=>Object.is(t,e))}function Ce(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const o=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(o,i.equals)||"notEquals"in i&&Object.is(o,i.notEquals)||i.oneOf&&!Le(o,i.oneOf)||i.notOneOf&&Le(o,i.notOneOf))}var $e=class{constructor(t={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...he,...t},this.random=ue(this.options.seed)}init(t={}){this.options={...he,...t},this.random=ue(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(de,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:pe(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))_e(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:ye(e.shape),bodyFilter:Te(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const o=this.bodies.get(t);o&&(o.vx+=e/o.mass,o.vy+=i/o.mass,this.wake(o))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const o=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,o>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>o){const i=o/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(i),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,n,0===t),this.resolveColliders(i,r,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:pe(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(_e)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Pe),colliders:this.sortedColliders().map(Re),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(t){this.options={...t.options,gravity:{...t.options.gravity}},this.random=ue(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(t.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of t.bodies){const t=Pe(e);this.bodies.set(t.id,t),this.nextBodyIndex=Math.max(this.nextBodyIndex,t.index+1)}this.nextColliderIndex=0;for(const e of t.colliders){const t=Re(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of t.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const o="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!o)continue;const n=o.x-i.x,r=o.y-i.y,s=Math.sqrt(n*n+r*r);if(de>=s)continue;const a=n/s,c=r/s,l=(s-e.restLength)*e.stiffness+((("vx"in o?o.vx:0)-i.vx)*a+(("vy"in o?o.vy:0)-i.vy)*c)*e.damping;i.vx+=l*a*t/i.mass,i.vy+=l*c*t/i.mass}}resolveBodyPairs(t,e,i){for(const o of e){const[e,n]=o.split(":").map(Number),r=t[e],s=t[n];if(!r||!s)continue;const a=Se(r,s);a&&(this.resolveDynamicCollision(r,s,a),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let o=0;t.length>o;o+=1){if(!1===t[o].bodyCollisions)continue;const n=xe(t[o]),r=Math.floor(n.minX/e),s=Math.floor(n.maxX/e),a=Math.floor(n.minY/e),c=Math.floor(n.maxY/e);for(let t=r;s>=t;t+=1)for(let e=a;c>=e;e+=1){const n=`${t}:${e}`,r=i.get(n);r?r.push(o):i.set(n,[o])}}const o=new Set;for(const e of Array.from(i.keys()).sort()){const n=i.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let i=e+1;n.length>i;i+=1){const r=n[e],s=n[i];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&ve(xe(t[r]),xe(t[s]))&&o.add(`${r}:${s}`)}}return Array.from(o).sort((t,e)=>{const[i,o]=t.split(":").map(Number),[n,r]=e.split(":").map(Number);return i===n?o-r:i-n})}resolveDynamicCollision(t,e,i){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,n=e.sleeping?0:1/e.mass,r=o+n;if(de>=r)return;const s=Math.max(0,i.penetration-fe)/r;t.x-=i.nx*s*o,t.y-=i.ny*s*o,e.x+=i.nx*s*n,e.y+=i.ny*s*n;const a=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*a/r,u=l*i.nx,h=l*i.ny;t.vx-=u*o,t.vy-=h*o,e.vx+=u*n,e.vy+=h*n,this.applyFriction(t,e,i,l,o,n),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,o,n,r){const s=-i.ny,a=i.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=n+r;if(de>=Math.abs(c)||de>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),h=ge(-c/l,-o*u,o*u),d=h*s,f=h*a;t.vx-=d*n,t.vy-=f*n,e.vx+=d*r,e.vy+=f*r}resolveColliders(t,e,i){for(const o of t)for(const t of e){if(!Ce(t,o))continue;if(!ve(xe(o),be(t)))continue;const e=Ae(o,t);e&&(this.resolveStaticCollision(o,t,e),this.supportedThisStep.add(o.id),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-fe),t.y+=i.ny*Math.max(0,i.penetration-fe);const o=t.vx*i.nx+t.vy*i.ny;if(0>o){const n=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+n)*o*i.nx,t.vy-=(1+n)*o*i.ny;const r=-i.ny,s=i.nx,a=t.vx*r+t.vy*s,c=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*r*c,t.vy-=a*s*c}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const o of t){const t=xe(o);for(const n of i){if(!Ce(n,o))continue;if(!ve(t,be(n)))continue;if(!Ae(o,n))continue;const i=Me(n.id,o.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:o}=_e(t);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of t)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*e||i&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=e,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},je=class{constructor(t={}){this.id="builtin",this.capabilities={...(new $e).capabilities,engine:"builtin"},this.world=new $e(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function ze(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new je(t)}(e)}var Ee=["binId","targetBin","category","windowIndex","lane","group"];function De(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function Ne(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function Fe(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function Ie(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Oe(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?Ie(e,t):void 0}function Be(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function We(t){const e=Ne(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Ne(t.x),y:Ne(t.y),value:e}}var Ye=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=Be(Oe(this.config.binAccessor,t,e))??function(t){for(const e of Ee){const i=Be(Ie(t,e));if(i)return i}return"sediment"}(t),o=Be(Oe(this.config.labelAccessor,t,e))??i,n=function(t,e,i){if("number"==typeof t)return t;const o="function"==typeof t?t(e,i):"string"==typeof t?Ie(e,t):1,n="number"==typeof o?o:Number(o);return Number.isFinite(n)?n:1}(this.config.valueAccessor,t,e),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(i);return s||(s={id:i,label:o,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,s)),s.label=o,s.lastBodyId=t.id,s.lastDatum=t.datum,De(s.x,t.x),De(s.y,t.y),De(s.value,n),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),We(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(We)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:Fe(e.x),y:Fe(e.y),value:Fe(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function qe(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var Xe={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},Ge={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Ve(t={},e=Ge){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function He(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function Ze(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function Ke(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Ue(t){return{...He(t),sequence:t.sequence,spawnAt:t.spawnAt}}function Qe(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function Je(t){return!1!==t&&{...t}}function ti(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function ei(t){return{...t,gravity:{...t.gravity}}}function ii(t,e,i,o){if("circle"===t.shape.type){const n=t.x-e,r=t.y-i,s=t.shape.radius+o,a=n*n+r*r;return a>s*s?null:a}const n=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),r=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),s=n*n+r*r;return s>o*o?null:s}function oi(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function ni(t,e={}){const{idPrefix:i="plot",includeFloor:o=!0,includeCeiling:n=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,h=t.y+t.height/2;return o&&l.push({id:i+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),n&&l.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),r&&l.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:h,width:a,height:t.height+2*c}}),s&&l.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:h,width:a,height:t.height+2*c}}),l}function ri(t){const{idPrefix:e="bin",count:i,domainStart:o,domainStep:n,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:h,lidY:d=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?i:i-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&i>t)continue;const s=r(o+t*n);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=h)for(let t=0;i>t;t+=1){const i=o+t*n,s=i+n;if(s>=h)continue;const a=r(i),l=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:d,x2:Math.max(a,l)-c/2,y2:d,thickness:f}})}return p}var si={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 ai(t,e){const i={...t};for(const t of e)i[si[t]]++;return i}function ci(t,e,i){const o=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:o,revisions:ai(i,o)}}var li=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=ci({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}record(t,e){const i=ci(t,e,this.revisions);this.revisions=i.revisions,this.latest=i;for(const t of[...this.listeners])t();return i}},ui=require("d3-quadtree"),hi=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,o,n,r=0){const s=this.ensure(t,e);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,r)+this.maxSearchRadius,u=o-l,h=o+l,d=n-l,f=n+l;return s.visit((t,e,s,l,p)=>{if(u>l||e>h||d>p||s>f)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=ii(t,o,n,Math.max(0,r));null!=e&&(c>e||e===c&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,c=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=(0,ui.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},di=["data","scene-geometry","data-paint","accessibility","evidence"],fi=["scene-geometry","data-paint","accessibility","evidence"],pi=["overlay","accessibility","evidence"],yi=(t,e)=>({retainedData:t,invalidations:e}),gi=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mi=["scene-geometry","data-paint","accessibility","evidence"],xi=[],bi={engine:yi("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:yi("preserve",mi),colliders:yi("preserve",mi),sediment:yi("preserve",mi),bodyBudget:yi("preserve",gi),bodyLimit:yi("preserve",gi),eviction:yi("preserve",gi),fixedDt:yi("preserve",xi),maxDeltaSeconds:yi("preserve",xi),maxSubsteps:yi("preserve",xi),settleStepLimit:yi("preserve",xi),timeScale:yi("preserve",xi),observation:yi("preserve",xi)},vi=yi("preserve",gi);function wi(t){let e="preserve";const i=new Set;for(const o of t){const t=bi[o]??vi;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var ki=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function Si(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&ki.every(i=>t[i]===e[i])}function Ai(t,e,i,o){return t||!e?"paused":i||!o?"running":"settled"}var Mi=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new hi,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new li,this.simulationState="settled",this.visible=!0;const{bodyBudget:e,colliders:i,engine:o,kernel:n,observation:r,sediment:s,...a}=t;this.config={...Xe,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=o,this.observation=Ve(r),this.sediment=new Ye(s??!1),this.world=ze(o,{fixedDt:this.config.fixedDt,...n}),i&&this.world.setColliders(Qe(i))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!Si(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:o,engine:n,kernel:r,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=ze(n,t.options),this.world.restore(t),this.revision+=1}if(r&&!Si(r,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...r,gravity:{...t.options.gravity,...r.gravity}};this.world.restore({...t,options:e}),this.revision+=1}s&&(this.observation=Ve(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(Qe(i)),this.revision+=1),this.configInput={...this.configInput,...t};const l=wi(e);this.updateResults.record({kind:"config",keys:e},l.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(Qe(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},wi(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],o=e?function(t,e={}){const i=Ze(e.startAt)??0,o=e.pacing??"immediate";if("arrival"===o){const o=t.map((t,i)=>function(t,e,i){return"function"==typeof i?Ze(i(t,e)):"string"==typeof i?Ze(Ke(t,i)):Ze(t.spawnAt)??Ze(Ke(t,"arrivalTime"))??Ze(Ke(t,"timestamp"))??Ze(Ke(t,"time"))??Ze(Ke(t,"eventTime"))}(t,i,e.timeAccessor)),n=o.filter(t=>null!=t),r=n.length>0?Math.min(...n):0,s=Ze(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const n=o[e],s=null==n?0:Math.max(0,n-r);return{...He(t),spawnAt:i+s/a}})}if("object"==typeof o){const e=Ze(o.ratePerSec);if(e&&e>0)return t.map((t,o)=>({...He(t),spawnAt:i+o/e}))}return t.map(t=>({...He(t),spawnAt:i}))}(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of o)this.queue.push({...He(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(ti),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?di:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(He(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},di)}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},di)}tick(t){const e=this.revision,i=[],o=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,n,r,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),n.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||i.length>0||o.length>0||n.length>0||r.length>0)&&(this.revision+=1);const h=this.result(u,i,o,n,r,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?i.length||o.length||n.length?di:fi:[]),h}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?fi:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],o=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,n,r,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);o.push(...c.evicted),n.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(;t>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),l+=1}(l>0||i.length>0||o.length>0||n.length>0||r.length>0)&&(this.revision+=1);const u=this.result(l,i,o,n,r,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==e?i.length||o.length||n.length?di:fi:[]),u}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return function(t,e={}){const{baselineY:i=0,binWidth:o=24,gap:n=2,maxHeight:r=80,value:s="count",x:a}=e,c=Math.max(1,...t.map(t=>t[s]));return t.map((t,e)=>{const l=Math.max(0,t[s]/c*r),u=a?.(t,e)??e*(o+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:i-l,width:o,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:i,chartId:o,...n}=t,r={...n,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?pi:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?pi:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),o=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>i.has(t)||o.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?di:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},fi),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},fi)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},fi)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,o)=>t.applyImpulse(e,i,o),clear:()=>t.clear(),hitTest:(e,i,o)=>t.hitTest(e,i,o),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Je(this.bodyBudget),config:{...this.config,kernel:ei(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Ue),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:Je(t.bodyBudget??{}),kernel:ei(t.world.options)},this.bodyBudget=Je(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(Ue).sort(ti),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??Ai(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},di)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,o,n,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:n,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:o,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const o=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=o.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const o=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===o.size&&0===e.size)return o;const n=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:o,bodyId:r}=oi(e),s=i.observation.sensors[o],a=n.get(r);i.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const t of Array.from(o).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())o.has(t)||r("exit",t);return o}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(oi(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return function(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),o=e+i,n=qe(t.bodyLimit),r=qe(t.engineMaxBodiesHint),s=function(t,e,i){if(!1===i)return;const o=qe(i?.warnAt);return null!=o?o:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,r,t.options),a=null==n?0:Math.max(0,e-n),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:o,queuedBodies:i,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=Ai(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const e=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(e))return{evicted:[],sedimented:[]};const i=this.liveBodyOrder.length-e;if(0>=i)return{evicted:[],sedimented:[]};const o=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,i);if(0===o.length)return{evicted:[],sedimented:[]};const n=this.absorbSediment(o,t);this.world.remove(o);const r=new Set(o);return this.liveBodyOrder=this.liveBodyOrder.filter(t=>!r.has(t)),this.removeActiveSensorPairsForBodies(r),{evicted:o,sedimented:n}}absorbSediment(t,e){const i=new Map(this.world.readState().map(t=>[t.id,t])),o=[];for(const n of t){const t=i.get(n);if(!t)continue;const r=this.sediment.add(t);r&&(o.push(n),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:n,datum:t.datum,x:t.x,y:t.y,binId:r.id,count:r.count,total:r.total},e))}return o}sleepingFirstEvictionOrder(){const t=new Map(this.world.readState().map(t=>[t.id,t.sleeping])),e=[],i=[];for(const o of this.liveBodyOrder)t.get(o)?e.push(o):i.push(o);return[...e,...i]}};var _i=require("d3-scale");function Pi(t){const{count:e,idPrefix:i,wallThickness:o,xScale:n,yBottom:r,yTop:s,yTopForIndex:a}=t;return Array.from({length:e+1},(t,e)=>{const c=Math.min(r-1,a?.(e)??s),l=Math.max(1,r-c);return{id:`${i}-wall-${e}`,shape:{type:"aabb",x:n(e),y:c+l/2,width:o,height:l}}})}var Ti=require("d3-scale");function Ri(t){if(Array.isArray(t)&&t.length>=2){const e=ne(t[0]),i=ne(t[1]);return null!=e&&null!=i?{x:e,y:i}:null}if(t&&"object"==typeof t){const e=t,i=ne(e.x),o=ne(e.y);return null!=i&&null!=o?{x:i,y:o}:null}return null}function Li(t){return Array.isArray(t)?t.map(Ri).filter(t=>null!=t):[]}function Ci(t,e,i){return"normalized"===i?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:re(t.x,e.plot.x,e.plot.x+e.plot.width),y:re(t.y,e.plot.y,e.plot.y+e.plot.height)}}function $i(t){let e=0;for(let i=1;t.length>i;i+=1)e+=Math.hypot(t[i].x-t[i-1].x,t[i].y-t[i-1].y);return e}function ji(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const i=re(e,0,1)*$i(t);let o=0;for(let e=1;t.length>e;e+=1){const n=t[e-1],r=t[e],s=Math.hypot(r.x-n.x,r.y-n.y);if(s>0){if(o+s>=i){const t=(i-o)/s;return{x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t}}o+=s}}return{...t[t.length-1]}}function zi(t,e){const i=ji(t,Math.max(0,e-.02)),o=ji(t,Math.min(1,e+.02)),n=o.x-i.x,r=o.y-i.y,s=Math.hypot(n,r)||1;return{x:n/s,y:r/s}}function Ei(t,e,i){return Math.max(e,Math.min(i,t))}function Di(t,e,i,o,n,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:o,y2:n,thickness:r.thickness??8}}}function Ni(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,o=t.width,n=t.height,{type:"aabb",x:e,y:i,width:o,height:n}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,o,n}function Fi(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ni({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Ii(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function Oi(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=t.size,o=Jt(i),n=re(t.ballRadius??6,2,18),r=t.seed??1,s=ce(r),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,h=t.workAccessor,d=t.radiusAccessor,f=t.groupCompletion??(l?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),o=Math.max(1,Math.round(t.height)),n=t.padX??46,r=t.padY??72,s=n,a=i-n,c=r,l=o-Math.max(24,Math.round(.45*r)),u=(c+l)/2,h=Math.max(1,l-c),d=Ei(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Ei(h*d+p,.06*h,.5*h),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,S=t.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Ei(t.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(S),_=a-s;let P=s;const T=S.map((t,e)=>{const i=P,o=e===S.length-1?a:P+(t.share??1)/M*_;return P=o,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:o,x:(i+o)/2,width:o-i,y:u,height:h}}),R=T[A],L=R.x0,C=R.x1,$=(t,i)=>{if("lane"===e)return"top"===i?c:l;if("funnel"===e){const e=Ei((t-s)/Math.max(1,a-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(L>=t){const e=Ei((t-s)/Math.max(1,L-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(C>=t)return"top"===i?m:x;const o=Ei((t-C)/Math.max(1,a-C),0,1);return"top"===i?m+(c-m)*o:x+(l-x)*o},j=T.map(t=>{const e=Math.min($(t.x0,"top"),$(t.x1,"top")),i=Math.max($(t.x0,"bottom"),$(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),z={thickness:k,friction:v,restitution:w},E=[];"lane"===e?E.push(Di(b+"-top",s,c,a,c,z),Di(b+"-bottom",s,l,a,l,z),Di(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Di(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)})):"funnel"===e?E.push(Di(b+"-top",s,c,a,m,z),Di(b+"-bottom",s,l,a,x,z),Di(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Di(b+"-right",a,m,a,x,{...z,thickness:Math.max(6,k)})):E.push(Di(b+"-left-top",s,c,L,m,z),Di(b+"-left-bottom",s,l,L,x,z),Di(b+"-center-top",L,m,C,m,z),Di(b+"-center-bottom",L,x,C,x,z),Di(b+"-right-top",C,m,a,c,z),Di(b+"-right-bottom",C,x,a,l,z),Di(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Di(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)}));const D=t.membraneDampingScale??.5,N=s,F=Math.max(1,("bowtie"===e?L:a)-N),I=(t.membranes??[]).map(t=>{const e=N+Ei(t.offset,0,1)*F,i=t.width??18+18*t.cost,o=h-16,n=u+.25*(t.wobble??0);return{...t,x:e,y:n,width:i,height:o}}),O=!1===t.includeMembraneRegions?[]:I.map(t=>function(t){const e=t.dampingScale??.5,i=t.energyScale??1,o=Ei(t.cost,0,2);return{...Ni({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o*e,energyDelta:-o*i}}({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??D,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:o,padX:n,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:L,centerRight:C,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:j,membranes:I,colliders:E,regionEffects:O,boundaryY:$}}({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],S=new Set(e.filter(t=>t.absorb).map(t=>t.id)),A=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const i={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Ni({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}({...i,kind:t.kind??"sink",force:Ii(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return o={...i,kind:t.kind??"force-field",force:Ii(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Ni({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ni({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}({...i,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Ii(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...i.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return function(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,o=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Ni({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*o,energyDelta:n?-e*n:void 0,force:t.force}}({...i,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:Ii(t.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Fi({...i,kind:t.kind??"force-field",force:Ii(t.force,14),damping:t.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):function(t){return{...Ni({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}({...i,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Fi({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const t of x.stages)M.set(t.id,0);const _=[];t.data.forEach((t,e)=>{const i=(a?oe(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",o=(oe(t,e,c)??w)+"",r=b.has(o)?o:w;M.set(r,(M.get(r)??0)+1);const s=l?(oe(t,e,l)??"")+"":void 0,f=s&&u?(oe(t,e,u)??s)+"":s,p=h?ne(oe(t,e,h))??1:1,y=d?ne(oe(t,e,d)):null,g=re(null!=y&&y>0?y:n,2,18);_.push({datum:t,id:i,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const P=new Map,T=new Map;for(const t of _){if(!t.groupId)continue;const e=P.get(t.groupId)??[];e.push(t.id),P.set(t.groupId,e),t.groupLabel&&T.set(t.groupId,t.groupLabel)}const R=re(t.groupAnchorAlong??.55,.15,.9),L=x.left+(x.right-x.left)*R,C=Array.from(P.keys()),$=C.map((t,i)=>{const o=P.get(t)??[],n=C.length>1?x.topY+28+i/Math.max(1,C.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:T.get(t)??t,bodyIds:o,anchor:{x:L,y:n},x:L,y:n,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),j=function(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],o=e.filter(t=>!i.has(t)),n=e.length-o.length,r=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},c=e.reduce((t,e)=>t+a(e),0),l=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),u=t.completion?.threshold,h="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:r,complete:e.length>0&&("anyAbsorbed"===r?n>0:"threshold"===r?l>=(h??c):0===o.length),absorbed:n,total:e.length,absorbedValue:l,totalValue:c,threshold:h,missing:o}})}($,_.filter(t=>S.has(t.stageId)).map(t=>t.id)),z=new Map($.map(t=>[t.id,t])),E=_.map((t,e)=>{const i=v.get(t.stageId)??k,o=i.x+(s()-.5)*Math.min(24,.2*i.width),n=x.boundaryY(o,"top")+t.radius+10,r=x.boundaryY(o,"bottom")-t.radius-10,a=r>n?n+s()*Math.max(1,r-n):x.midY,c=g?o:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=z.get(t.groupId);e?.anchor&&!S.has(t.stageId)&&u.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:g?0:.03*e,springs:u,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),D={kernel:{seed:r,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},N=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),F=e.map(t=>{const e=v.get(t.id)??k;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:M.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:D,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:N,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:F,groups:$,groupCompletion:j,regionEffects:A}}}var Bi=require("d3-scale");function Wi(t,e,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=C[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:i}function Yi(t,e){const i=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>i&&D(i,t)||"#4e79a7":e=>{if(i){const t=D(i,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}function qi(t,e){const i=e.config??{},o=(e.sensors??[]).map(t=>({...t,sensor:!0})),n=[...e.colliders??[],...o],r=[...t.colliders??[],...i.colliders??[],...n];return{...t,...i,observation:{...t.observation,...i.observation},...r.length>0&&{colliders:r}}}function Xi(t){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:t.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:t.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:t.floorY,x2:t.width-30,y2:t.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-30,y1:76,x2:t.width-30,y2:t.floorY,thickness:8}}]}function Gi(t,e,i,o){return i?"function"==typeof i?i(t,e):t[i]??o:o}function Vi(t){return`gauntlet:${t}:core`}function Hi(t,e){return`gauntlet:${t}:positive:${e}`}function Zi(t,e,i){return`gauntlet:${t}:negative:${e}:${i}`}function Ki(t,e,i,o){const n=Math.max(2,i+2),r=80+n,s=o.floorY-n;return{x:Math.max(32+n,Math.min(o.width-30-4-n,t)),y:Math.max(r,Math.min(s,e))}}function Ui(t,e){const i=[...t].sort((t,e)=>t.localeCompare(e)),o=Math.max(0,i.indexOf(e));return{angle:.82*-Math.PI+(i.length>1?o/(i.length-1):.5)*Math.PI*.64,index:o,radius:48+o%2*6}}function Qi(t,e,i){const o=t.activePositiveIds.reduce((t,i)=>t+(e.get(i)?.value??1),0),n=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(i.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*r-1.2*t.delay-5*n))}function Ji(t){const e=function(t,e,i){const[o,n]=t,r=Math.round(.48*n),s=n-36,a=(e??[]).filter(t=>!1!==t.enabled),c=Math.max(1,a.length),l=.22*o,u=c>1?(.78*o-l)/(c-1):0,h=Math.max(Math.round(.14*o),110);return{crashY:s-i,floorY:s,gates:a.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(l+e*u),width:t.width??Math.max(54,Math.round(.07*o))})),graveyardX:Math.round(.84*o),graveyardY:s-4,height:n,routeY:r,socketX:Math.round(.92*o),startX:h,width:o}}(t.size??[900,520],t.gates,t.crashOffset??30),i=t.positiveProperties??[],o=new Map(i.map(t=>[t.id,t])),n=new Map((t.negativeProperties??[]).map(t=>[t.id,t])),r={idAccessor:t.idAccessor,initialViability:t.initialViability,metricsAccessor:t.metricsAccessor,negativeAccessor:t.negativeAccessor,positiveAccessor:t.positiveAccessor,startTimeAccessor:t.startTimeAccessor},s=(t.data??[]).map((e,s)=>{const a=function(t,e,i,o,n){const r=Gi(t,e,i.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=o.map(t=>t.id),a=[...Gi(t,e,i.positiveAccessor,s)],c=[...Gi(t,e,i.negativeAccessor,[])].filter(t=>n.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Gi(t,e,i.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Gi(t,e,i.startTimeAccessor,0))||0),stage:"project filed",viability:Gi(t,e,i.initialViability,100)}}(e,s,r,i,n);return{...a,viability:t.viability?.(a,{negativeProperties:n,positiveProperties:o})??Qi(a,o,n)}}),a=s.flatMap((i,r)=>{const s=function(t,e,i,o){const n=function(t){return{graveyardX:t.graveyardX,graveyardY:t.graveyardY,routeY:t.routeY,socketX:t.socketX,socketY:t.routeY-4,startX:t.startX,startY:t.routeY}}(i),r=o?.(t,e,i)??{};return{...n,...r,startY:r.startY??r.routeY??n.startY,socketY:r.socketY??r.routeY??n.socketY,graveyardY:r.graveyardY??n.graveyardY}}(i,r,e,t.projectPlacement);return function(t,e,i,o,n,r,s){const a=o.startX,c=o.startY+(o.startY===i.routeY?38*e:0),l=s?.(t,e,i,o)??{},u={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},h=[{...l,id:Vi(t.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??t.startedAt,datum:u}],d=Ki(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,i);h[0].x=d.x,h[0].y=d.y;for(const e of t.activePositiveIds){const o=n.get(e);if(!o)continue;const r=Ui(t.activePositiveIds,e),s=o.radius??10,a=Ki(d.x+Math.cos(r.angle)*r.radius,d.y+Math.sin(r.angle)*r.radius,s,i);h.push({id:Hi(t.id,e),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:o,sourceDatum:t.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:Vi(t.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...o.spring??{}}]})}return t.negativeIds.forEach((e,o)=>{const n=r.get(e);n&&h.push(function(t,e,i,o,n,r,s){const a=e.radius??7.2,c=Ki(o-12+i%4*12,n+54+12*Math.floor(i/4),a,r);return{id:Zi(t.id,e.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:Vi(t.id)},stiffness:.62,damping:.92,restLength:52+i%4*3,...e.spring??{}}]}}(t,n,o,d.x,d.y,i,l.spawnAt??t.startedAt))}),h}(i,r,e,s,o,n,t.coreBody)});return{layout:e,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Xi(e)}}}function to(t){return t.map(t=>({...t,spawnAt:void 0}))}var eo={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,...o,showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:Q,AreaChart:J,DifferenceChart:tt,StackedAreaChart:et,Scatterplot:it,CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"candlestick",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.highAccessor||"high",highAccessor:n.highAccessor||"high",lowAccessor:n.lowAccessor||"low",openAccessor:n.openAccessor,closeAccessor:n.closeAccessor,candlestickStyle:n.candlestickStyle,...o})},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[5,40],colorScheme:i,...o})},ConnectedScatterplot:nt,QuadrantChart:ot,Heatmap:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"heatmap",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",valueAccessor:n.valueAccessor,colorScheme:i||n.colorScheme||"blues",showValues:n.showValues,cellBorderColor:n.cellBorderColor,...o})},XYCustomChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"custom",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o,showAxes:o.showAxes??!1})},BarChart:ht,StackedBarChart:dt,GroupedBarChart:ft,PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"pie",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",colorAccessor:e||n.categoryAccessor,colorScheme:i,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o})},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"donut",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",innerRadius:n.innerRadius||60,colorAccessor:e||n.categoryAccessor,colorScheme:i,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o})},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"histogram",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal",bins:n.bins,colorAccessor:e,colorScheme:i,...o})},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"boxplot",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorScheme:i,...o})},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"violin",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",bins:n.bins,colorScheme:i,...o})},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"swarm",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,...n.symbolBy&&{symbolAccessor:n.symbolBy},...n.symbolMap&&{symbolMap:n.symbolMap},colorScheme:i,...o})},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"point",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:i,...o,showGrid:o.showGrid??!0})},SwimlaneChart:pt,RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"ridgeline",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",bins:n.bins,amplitude:n.amplitude,...o})},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.levelAccessor||"level",colorAccessor:e||n.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===n.orientation?"vertical":"horizontal",...o})},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>{const r="vertical"===n.orientation;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:n.stepAccessor||"step",rAccessor:n.valueAccessor||"value",colorAccessor:e||n.categoryAccessor,categoryAccessor:n.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:n.connectorAccessor,connectorStyle:n.connectorStyle,...!r&&null!=n.connectorOpacity&&{connectorOpacity:n.connectorOpacity},barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:i,...o}}},GaugeChart:yt,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"custom",data:t,oAccessor:n.categoryAccessor||n.oAccessor||"category",rAccessor:n.valueAccessor||n.rAccessor||"value",projection:n.projection||"vertical",colorAccessor:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o,showAxes:o.showAxes??!1})},ForceDirectedGraph:jt,NetworkCustomChart:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"force",nodes:n.nodes||t||[],edges:n.edges||[],nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor||"id",sourceAccessor:n.sourceAccessor||"source",targetAccessor:n.targetAccessor||"target",valueAccessor:n.valueAccessor||"value",colorBy:e,colorScheme:i,customNetworkLayout:n.layout||n.customNetworkLayout,layoutConfig:n.layoutConfig,...o})},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"sankey",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,valueAccessor:n.valueAccessor,orientation:n.orientation,nodeAlign:n.nodeAlign,nodeWidth:n.nodeWidth,nodePaddingRatio:n.nodePaddingRatio,showLabels:n.showLabels,nodeLabel:n.nodeLabel,colorBy:e,edgeColorBy:n.edgeColorBy,edgeOpacity:n.edgeOpacity,nodeStyle:n.nodeStyle,edgeStyle:n.edgeStyle,colorScheme:i,...o})},ProcessSankey:zt,ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"chord",nodes:n.nodes,edges:n.edges,valueAccessor:n.valueAccessor,padAngle:n.padAngle,groupWidth:n.groupWidth,showLabels:n.showLabels,colorBy:e,edgeColorBy:n.edgeColorBy,colorScheme:i,...o})},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"cluster"===n.layout?"cluster":"tree",data:t,childrenAccessor:n.childrenAccessor,colorBy:e,colorByDepth:n.colorByDepth,orientation:n.orientation,showLabels:n.showLabels,colorScheme:i,...o})},Treemap:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"treemap",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,colorScheme:i,...o})},CirclePack:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"circlepack",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,colorScheme:i,...o})},ChoroplethMap:Kt,ProportionalSymbolMap:Ut,FlowMap:Qt,GeoCustomChart:{frameType:"geo",buildProps:(t,e,i,o,n)=>({points:n.points||t||[],areas:n.areas||[],lines:n.lines||[],projection:n.projection||"equirectangular",xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",lineDataAccessor:n.lineDataAccessor,colorBy:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s=n.bins??21,a=n.seed??1,c=Math.max(1,Math.round(n.pegRows??s-1)),l="mechanical"===n.mode,u=l?function(t){const e=Math.max(2,Math.round(t.bins)),i=Math.max(1,Math.round(t.pegRows??e-1)),o=Math.max(1,Math.round(t.count??Math.max(64,4*e))),n=re(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=ce(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:o},(t,e)=>{let o=0;for(let t=0;i>t;t+=1)r()<n&&(o+=1);const a=i/2;return{id:`${s}-${e}`,value:o,mechanical:!0,pegRows:i,branchProbability:n,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:a}):Array.isArray(t)?t:[],h=function(t){const{data:e,valueAccessor:i,bins:o,ballRadius:n,seed:r,size:s,valueExtent:a}=t,c=Jt(s),l=e.map((t,e)=>ne(oe(t,e,i))).filter(t=>null!=t),u=function(t){if(!t)return;const e=ne(t[0]),i=ne(t[1]);return null!=e&&null!=i?e>i?[i,e]:[e,i]:void 0}(a),h=u?.[0]??(l.length?Math.min(...l):0),d=u?.[1]??(l.length?Math.max(...l):1),f=d===h?1:d-h,p=(0,le.scaleLinear)().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),g=[];e.forEach((t,e)=>{const r=ne(oe(t,e,i));if(null==r)return;const s=Math.max(0,Math.min(o-1,Math.floor((r-h)/f*o)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:c.plot.y+n+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:n},datum:{...t,value:r,bin:s}})});const m=c.plot.y+c.plot.height;return{config:ie(r,[...ni({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...ri({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[h,d]}}}({data:u,valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??4,seed:a,size:r,valueExtent:l?[0,c]:void 0});return{...o,config:h.config,initialSpawns:to(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:ee(e||n.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s=function(t){const{data:e,timeAccessor:i,arrivalAccessor:o,windows:n,watermark:r,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=t,h=Jt(c),d=e.map((t,e)=>ne(oe(t,e,i))).filter(t=>null!=t),f=ne(l?.[0]),p=ne(l?.[1]),y=d.length?Math.min(...d):0,g=d.length?Math.max(...d):y+n.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/n.size)*n.size,v=Math.max(1,Math.ceil((x-b+n.size)/n.size)),w=d.length?Math.max(...d):0,k="function"==typeof r?r(w):ne(r?.value)??w-(r?.delay??n.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>b+(e+1)*n.size>k?t:t+1,0))),A=function(t,e){const i=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:i,height:t.plot.height},windowPlot:{x:t.plot.x+i,y:t.plot.y,width:Math.max(40,t.plot.width-i),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(h,s),M=b+v*n.size,_=(0,_i.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),T=[];e.forEach((t,e)=>{const r=ne(oe(t,e,i));if(null==r)return;const a=ne(oe(t,e,o))??r,c=Math.max(0,Math.min(v-1,Math.floor((r-b)/n.size))),l=k>=b+(c+1)*n.size;P[c].value+=l?0:1,P[c].secondary+=l?1:0,T.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(r))),y:h.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...t,eventTime:r,arrivalTime:a,windowIndex:c,late:l}})});const R=h.plot.y+h.plot.height,L=function(t,e){const i=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!i)return[];const o=t.windowStart,n=t.windowStart+t.windowCount*t.windowSize,r=(0,_i.scaleLinear)().domain([o,n]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+i*t.windowSize),a=t.windowPlot.x,c=e+Math.max(18,Math.min(.3*t.windowPlot.height,s-a)),l=t=>s===a?e:c+(t-a)/(s-a)*(e-c),u=[];for(let e=0;i>e;e+=1){const i=t.windowStart+e*t.windowSize,o=i+t.windowSize,n=r(i),s=r(o);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:n,y1:l(n),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:h.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:n.size,windowStart:b},h.plot.y+.28*h.plot.height);return{config:ie(a,[...ni({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Pi({idPrefix:"eventdrop-window",count:v,xScale:t=>_(b+t*n.size),yTop:A.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?L[0]?.y1:L[t-1]?.y2??L[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:R,wallThickness:6}),...L.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:T,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:P.map((t,e)=>({label:`${b+e*n.size}-${b+(e+1)*n.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:L,lateCount:P.reduce((t,e)=>t+e.secondary,0),plot:h.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:n.size,windowStart:b}}}({data:Array.isArray(t)?t:[],timeAccessor:n.timeAccessor||"time",arrivalAccessor:n.arrivalAccessor||"arrivalTime",windows:n.windows||{size:10},watermark:n.watermark,ballRadius:n.ballRadius??5,seed:n.seed??1,size:r,timeExtent:n.timeExtent,timeScale:n.timeScale??1});return{...o,config:s.config,initialSpawns:to(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:ee(e||n.colorBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||n.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s="mechanical"===n.mode,a=function(t){const{data:e,categoryAccessor:i,valueAccessor:o,unitValue:n,ballRadius:r,seed:s,size:a}=t,c=se(n,1),l=Jt(a),u=[],h=new Map,d=new Map,f=[];function p(t){let e=h.get(t);return null==e&&(e=u.length,u.push(t),h.set(t,e)),e}e.forEach((t,e)=>{p((oe(t,e,i)??"unknown")+"")});const y=Math.max(1,u.length),g=function(t,e,i){const o=t.width/Math.max(1,e),n=Math.max(2,2*i),r=Math.min(.7*o,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(r/n));return{laneWidth:o,tubeWidth:r,ballDiameter:n,perRow:s,centerX:e=>t.x+(e+.5)*o,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*n}}(l.plot,y,r),m=Math.max(0,g.tubeWidth/2-r-1),x=u.map(()=>[]);e.forEach((t,e)=>{const n=(oe(t,e,i)??"unknown")+"",s=p(n),a=o?ne(oe(t,e,o)):1,u=Math.max(0,Math.round((a??0)/c)),h=g.centerX(s);for(let i=0;u>i;i+=1){const o=d.get(n)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;d.set(n,o+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${i}`,x:h+a,y:l.plot.y+r+2,vx:(i%3-1)*r/2,vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,category:n,unitIndex:i}})}});const b=x.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of x)e.length>t&&f.push(e[t]);const v=l.plot.y+l.plot.height,w=[...ni({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let t=0;y>t;t+=1){const e=g.centerX(t);for(const i of[-1,1])w.push({id:`pile-tube-${t}-${0>i?"l":"r"}`,shape:{type:"aabb",x:e+i*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:ie(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:d.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),i=e.length?e:["Intake"],o=Math.max(i.length,Math.round(t.count??Math.max(48,12*i.length))),n=se(t.unitValue,1),r=ce(t.seed??1),s=t.idPrefix??"mechanical-pile",a=i.map(()=>.65+.9*r()),c=a.reduce((t,e)=>t+e,0)||1,l=o-i.length,u=a.map(t=>t/c*l),h=u.map(t=>1+Math.floor(t));let d=o-h.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%f.length)h[f[t].index]+=1,d-=1;return i.map((t,e)=>({id:`${s}-${e}`,category:t,value:h[e]*n,mechanical:!0,unitCount:h[e],unitValue:n,share:h[e]/o}))}({categories:n.mechanicalCategories,count:n.mechanicalCount,seed:n.seed??1,unitValue:n.unitValue??1}):Array.isArray(t)?t:[],categoryAccessor:n.categoryAccessor||"category",valueAccessor:n.valueAccessor||(s?"value":void 0),unitValue:n.unitValue??1,ballRadius:n.ballRadius??5,seed:n.seed??1,size:r});return{...o,config:a.config,initialSpawns:to(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:ee(e||n.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,360],s=function(t){const{data:e,xAccessor:i,groupAccessor:o,radiusAccessor:n,pointRadius:r,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,h=Jt(a),d=ce(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=ne(oe(t,e,i));if(null==s)return;const a=o?(oe(t,e,o)??"All")+"":"All",c=n?ne(oe(t,e,n)):null,l=re(null!=c&&c>0?c:r,2,18);!function(t){let e=y.get(t);null==e&&(e=p.length,p.push(t),y.set(t,e))}(a),f.push({datum:t,index:e,value:s,group:a,radius:l})});const g=f.map(t=>t.value),m=c?ne(c[0]):null,x=c?ne(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const t=k;k=w,w=t}const S=Math.max(r,...f.map(t=>t.radius)),A=h.plot.x+S+8,M=h.plot.x+h.plot.width-S-8,_=(0,Ti.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),T=h.plot.y+Math.max(28,3*S),R=Math.max(0,h.plot.y+h.plot.height-Math.max(28,3*S)-T),L=t=>{const e=y.get(t)??0;return 1===P?h.plot.y+.54*h.plot.height:T+e/(P-1)*R},C=new Map,$=f.map((t,e)=>{C.set(t.group,(C.get(t.group)??0)+1);const i=_(t.value),o=L(t.group),n=(d()-.5)*t.radius*1.6,r=(d()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?i+n:re(i+(e%9-4)*t.radius*2.5,A,M),y:u?o+r:h.plot.y-18-e%12*t.radius,vx:u?0:22*(d()-.5),vy:u?0:24+18*d(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:i,targetY:o},springs:[{target:{type:"point",x:i,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:ie(s,ni({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:$,projectionRows:p.map(t=>({label:t,value:C.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(t=>({label:t,y:L(t),count:C.get(t)??0})),plot:h.plot}}}({data:Array.isArray(t)?t:[],xAccessor:n.xAccessor||"x",groupAccessor:n.groupAccessor,radiusAccessor:n.radiusAccessor,pointRadius:n.pointRadius??5,seed:n.seed??1,size:r,xExtent:n.xExtent,collisionIterations:n.collisionIterations,settle:n.settle});return{...o,config:s.config,initialSpawns:to(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:ee(e||n.colorBy||n.groupAccessor,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[900,420],s=Array.isArray(n.stages)?n.stages:[],a=Oi({data:Array.isArray(t)?t:[],stages:s,size:r,idAccessor:n.idAccessor,stageAccessor:n.stageAccessor||"stage",groupBy:n.groupBy,groupLabelAccessor:n.groupLabelAccessor,workAccessor:n.workAccessor,radiusAccessor:n.radiusAccessor,ballRadius:n.ballRadius??6,seed:n.seed??1,groupCompletion:n.groupCompletion,groupAnchorAlong:n.groupAnchorAlong,settle:n.settle??!0,gravityX:n.gravityX,gravityY:n.gravityY}),c=a.metadata;return{...o,config:a.config,initialSpawns:to(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:ee(e||n.colorBy||n.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[900,520],s=Ji({data:Array.isArray(t)?t:[],size:r,gates:n.gates,positiveProperties:n.positiveProperties,negativeProperties:n.negativeProperties,crashOffset:n.crashOffset,idAccessor:n.idAccessor,positiveAccessor:n.positiveAccessor,negativeAccessor:n.negativeAccessor,metricsAccessor:n.metricsAccessor,initialViability:n.initialViability,projectPlacement:n.projectPlacement,coreBody:n.coreBody,viability:n.viability});return{...o,config:s.config,initialSpawns:to(s.initialSpawns),projectionRows:[],bodyStyle:ee(e||n.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:i,links:o,maxParticles:n,nodeIdAccessor:r,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:h,pathConstraint:d="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=Jt(y),v=ce(p),w=new Map,k=new Map,S=[];function A(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof r){const t=r(e,0);if(null!=t)return t+""}if("string"==typeof r&&null!=e[r])return e[r]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const i=(oe(t,e,r)??t.id??e)+"",o=ne(oe(t,e,s)),n=ne(oe(t,e,a));if(null!=o&&null!=n){const t={x:o,y:n};w.set(i,t),S.push(t)}k.set(i,(t.label??t.name??i)+"")});const M=[];o.forEach((t,e)=>{const i=A(oe(t,e,g)),o=A(oe(t,e,m)),n=Math.max(0,ne(oe(t,e,x))??0),r=Li(h?oe(t,e,h):void 0),s=r.length?r:Li(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${i}-${o}-${e}`)+"",link:t,index:e,source:i,target:o,throughput:n,rawPath:s})});const _=(T=S,"normalized"===(P=e)||"pixels"===P?P:T.length>0&&T.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var P,T;const R=new Map;for(const[t,e]of w)R.set(t,Ci(e,b,_));const L=[];for(const t of M){let e=t.rawPath.map(t=>Ci(t,b,_));if(2>e.length){const i=R.get(t.source),o=R.get(t.target);i&&o&&(e=[i,o])}else R.has(t.source)||R.set(t.source,e[0]),R.has(t.target)||R.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),L.push({...t,path:e,packetCount:0}))}const C=se(u,.12),$=Math.max(1,Math.round(n)),j=L.map(t=>Math.max(1,Math.round(t.throughput*C))),z=j.reduce((t,e)=>t+e,0),E=z>$?$/z:1;L.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(j[e]*E))});let D=L.reduce((t,e)=>t+e.packetCount,0);for(;D>$;){const t=L.reduce((t,e,i)=>e.packetCount>1&&(-1===t||e.packetCount>L[t].packetCount)?i:t,-1);if(-1===t)break;L[t].packetCount-=1,D-=1}const N=new Map,F=new Map,I=[],O=se(i,90),B=se(l,4);L.forEach((t,e)=>{N.set(t.target,(N.get(t.target)??0)+t.throughput),F.set(t.source,(F.get(t.source)??0)+t.throughput);const i=$i(t.path);for(let o=0;t.packetCount>o;o+=1){const n=(o+.5)/t.packetCount,r=f?n:re(.12+.84*n+.04*(v()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*v())),a=ji(t.path,s),c=ji(t.path,r),l=zi(t.path,s),u={x:-l.y,y:l.x},h=(v()-.5)*B*1.5;I.push({id:`${t.id}-packet-${o}`,x:a.x+u.x*h,y:a.y+u.y*h,vx:f?0:l.x*O+10*(v()-.5),vy:f?0:l.y*O+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+o/32,shape:{type:"circle",radius:B},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:o,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:i,flowRouteId:t.id,flowSpeed:O,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==d&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*B,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*B),Y=Array.from(R,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+ae(t),point:e})),q=Y.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:W,height:W}})),X=Object.fromEntries(Y.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=ie(p,[...ni({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*B),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=$,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(R,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+ae(t),incoming:N.get(t)??0,outgoing:F.get(t)??0})),H=L.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:G,initialSpawns:I,projectionRows:V.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:I.length,totalThroughput:L.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:V,links:H}}}({nodes:Array.isArray(n.nodes)?n.nodes:[],links:Array.isArray(n.links)?n.links:Array.isArray(n.edges)?n.edges:Array.isArray(t)?t:[],nodeIdAccessor:n.nodeIdAccessor||"id",nodeXAccessor:n.nodeXAccessor||"x",nodeYAccessor:n.nodeYAccessor||"y",sourceAccessor:n.sourceAccessor||"source",targetAccessor:n.targetAccessor||"target",throughputAccessor:n.throughputAccessor||"value",pathAccessor:n.pathAccessor||"path",coordinateMode:n.coordinateMode||"auto",particleRate:n.particleRate??.16,maxParticles:n.maxParticles??180,particleRadius:n.particleRadius??4,flowSpeed:n.flowSpeed??90,pathConstraint:n.pathConstraint||"path",reducedMotion:!0,seed:n.seed??1,size:r});return{...o,config:s.config,initialSpawns:to(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:ee(e||n.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[700,380],s=function(t){const e=function(t,e,i){const o=t?.observation;return{...t,observation:{...o,chartId:e??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:i??o?.onObservation}}}(t.config,t.chartId,t.onObservation),i=Wi(t.colorScheme,t.themeCategorical,g),o=Jt(t.size),n={data:t.data,scales:{x:(0,Bi.scaleLinear)().domain(t.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,Bi.scaleLinear)().domain(t.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:t.semantic,categorical:[...i]},resolveColor:Yi(i,t.colorScheme),config:t.layoutConfig??{},world:new Mi(e)},r=t.skipLayout?{}:t.layout(n)??{},s=function(t,e){if(!e?.length)return t;const i=new Map;for(const t of e){const{bodyId:e,...o}=t,n=i.get(e)??[];n.push(o),i.set(e,n)}return t.map(t=>{const e=i.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:qi(e,r),context:n,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}({chartId:n.chartId,colorScheme:i,config:n.config,data:Array.isArray(t)?t:[],layout:n.layout,layoutConfig:n.layoutConfig,semantic:Ft(Bt)??{},size:r,themeCategorical:Bt.colors.categorical,xExtent:n.xExtent,yExtent:n.yExtent});return{...o,config:s.config,initialSpawns:to(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??ee(e||n.colorBy)}}}};function io(t){if(!t)return Bt;if("string"==typeof t){if("light"===t)return Bt;if("dark"===t)return Wt;if("high-contrast"===t)return Yt;return Vt[t]||Bt}const e="dark"===t.mode?Wt:Bt;return It({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}},tooltip:{...e.tooltip,...t.tooltip||{}}})}function oo(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:t.colors.annotation??t.colors.text,legendSize:t.typography.legendSize??t.typography.labelSize,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}function no(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function ro(t){if(!t||2>t.length)return;const e=no(t[0]),i=no(t[t.length-1]);return null!==e&&null!==i?[e,i]:void 0}function so(t){const{count:e,byType:i}=function(t){const e={};for(const i of t){const t="string"==typeof i?.type&&i.type.length>0?i.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),o=0===e,n=[...t.extraWarnings??[]];return o&&!n.includes("EMPTY_SCENE")&&n.push("EMPTY_SCENE"),{component:"",frameType:t.frameType,status:o?"empty":"ok",empty:o,markCount:e,markCountByType:i,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:Array.isArray(t.annotations)?t.annotations.length:0,ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:n}}function ao(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function co(t){return"object"==typeof t&&null!==t&&"gradient"in t}var lo=Object.freeze([]);function uo(t){if(!t)return lo;let e=!1;for(let i=0;t.length>i;i++){const o=t[i];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const i=[];for(const e of t)null!=e&&"object"==typeof e&&i.push(e);return i}var ho=c(require("react")),fo=c(require("react-dom/server")),po=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let i=0,o=[];e.length>t&&(i=e.length-t,o=e.slice(0,i)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=i;e.length>t;t++)this.push(e[t]);return o}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++){const r=(o+n)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},i.push(t),this.buffer[r]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},yo=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function go(t,e){return t===e}function mo(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function xo(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function bo(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var vo=/^\d{4}-\d{1,2}$/;function wo(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const i=vo.test(e)?e+"-01":e;if(i===e&&10>e.length)return NaN;const o=Date.parse(i);return Number.isFinite(o)?o:NaN}function ko(t){return t instanceof Date?t.getTime():"string"==typeof t?wo(t):+t}function So(t){return new Set(Array.isArray(t)?t:[t])}function Ao(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Mo(t,e){return Math.min((t-e.startTime)/e.duration,1)}function _o(t,e,i){return t+(e-t)*i}function Po(){return"undefined"!=typeof performance?performance.now():Date.now()}function To(t,e,i){if(1>=i)return 1;const o=i-1;return function(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const i=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>i?1:e;if("exponential"===t.type){const o=t.halfLife??t.extent/2;return e+Math.pow(.5,i/(o>0?o:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-i/t.extent))*(1-e)}({age:o-e,extent:o,type:t.type,halfLife:t.halfLife??i/2,threshold:t.stepThreshold??.5*i,minOpacity:t.minOpacity??.1})}function Ro(t){const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return e}function Lo(t,e,i){const o=t.duration??500,n=i-e;return o>n?1-n/o:0}function Co(t,e,i,o){let n=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,n=!0),t._pulseColor!==i&&(t._pulseColor=i,n=!0),t._pulseGlowRadius!==o&&(t._pulseGlowRadius=o,n=!0),n):(0!==t._pulseIntensity&&(t._pulseIntensity=0,n=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,n=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,n=!0),n)}function $o(t,e,i=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const o=t.duration??500,n=e.peek();return null!=n&&o>i-n}function jo(t,e,i){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+i;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function zo(t,e,i,o,n,r){const s=[];for(const n of t){const t=i(n),r=o(n);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:n})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:n,datum:l,group:r}}function Eo(t,e,i,o,n,r,s,a){const c=[];for(const r of t){const t=i(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(r):n;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:r,datum:t,group:s}}function Do(t,e,i,o){const n=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const n of e)t+=i(n,o)||0;n.set(o,-t/2)}else if("wiggle"===o){t.length>0&&n.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let a=0,c=0,l=0;for(const t of e){const e=i(t,s)||0;a+=(2*l+e)*(e-(i(t,r)||0)),c+=e,l+=e}const u=n.get(r)??0;n.set(s,u-(c>0?a/(2*c):0))}if(t.length>0){let o=0;for(const r of t){let t=0;for(const o of e)t+=i(o,r)||0;o+=(n.get(r)??0)+t/2}const r=o/t.length;for(const e of t)n.set(e,(n.get(e)??0)-r)}}else for(const e of t)n.set(e,0);return n}function No(t,e,i,o,n,r,s){const a=i(t),c=o(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:n,style:r,datum:t};return void 0!==s&&(l.pointId=s),l}function Fo(t,e,i,o,n,r,s,a){const c=i(t),l=o(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:n,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function Io(t,e,i,o,n,r,s){return{type:"rect",x:t,y:e,w:i,h:o,style:n,datum:r,group:s}}function Oo(t,e,i,o,n,r,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:n,datum:r};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Bo(t,e,i,o){return"function"==typeof e.style?e.style(o||{},i):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(i,o)}function Wo(t,e,i,o){if(!t.scales)return null;const n=[],r=[];for(const i of e){const e=t.getX(i);if(!Number.isFinite(e))continue;const s=o.getTop(i),a=o.getBottom(i);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=t.scales.x(e),l=t.scales.y(s),u=t.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(n.push([c,l]),r.push([c,u]))}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:Bo(t,o,i,e[0]),datum:e,group:i,interactive:o.interactive}}function Yo(t){const e=[],i=[];if(!t)return{perSeries:e,aggregate:i};for(const o of t)o.perSeries?e.push(o):i.push(o);return{perSeries:e,aggregate:i}}function qo(t,e,i){const o=[];for(const n of i){const i=Wo(t,e,"__ribbon_aggregate",n);i&&o.push(i)}return o}function Xo(t,e,i,o){const n=[];for(const r of o){const o=Wo(t,e,i,r);o&&n.push(o)}return n}function Go(t,e,i,o){if(!t.config.pointStyle)return;const n=o??t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const r of o.data){let o=t.config.pointStyle(r);!o.fill&&e&&(o={...o,fill:e});const s=o.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,c=No(r,t.scales,t.getX,n,s,o,a);c&&i.push(c)}}}function Vo(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var Ho={topOpacity:.8,bottomOpacity:.05};function Zo(t){if(t)return!0===t?Ho:"colorStops"in t?t:{topOpacity:t.topOpacity??Ho.topOpacity,bottomOpacity:t.bottomOpacity??Ho.bottomOpacity}}var Ko=require("d3-shape"),Uo={circle:Ko.symbolCircle,square:Ko.symbolSquare,triangle:Ko.symbolTriangle,diamond:Ko.symbolDiamond,star:Ko.symbolStar,cross:Ko.symbolCross,wye:Ko.symbolWye},Qo=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Jo(t,e,i){if(i)return i;const o=t??"circle";return"chevron"===o?function(t){const e=1.5*function(t){return Math.sqrt(Math.max(1,t)/Math.PI)}(t),i=.92*e;return`M0,${-e}L${i},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-i},${(.78*e).toFixed(3)}Z`}(e):(0,Ko.symbol)(Uo[o]??Ko.symbolCircle,Math.max(1,e))()??""}var tn=new Map;function en(t,e,i,o,n){const r=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=r.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},r.set(c,l)),l.total+=a,n){const t=n(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return r}function on(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:i,overlays:o,warned:n}=t;nn(o)&&0===i.length&&rn(n,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(t=>null==t.datum)&&rn(n,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function nn(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(nn))}function rn(t,e,i){t.has(e)||(t.add(e),console.warn(i))}function sn(t,e,i,o){const n=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),r="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:r,message:`Semiotic ${t} ${r} failed: ${n.message}`,error:n,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:o}}function an(t,e){const i="function"==typeof t?t:i=>i[t||e];return t=>{const e=i(t);return null==e?NaN:+e}}function cn(t){const e=[],i=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=an(i&&t.valueAccessor||t.yAccessor,i?"value":"y");if(t.boundsAccessor){const i=mo(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const n=i(t);return Number.isFinite(n)&&0!==n?e+n:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const n=i(t);return Number.isFinite(n)&&0!==n?e-n:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const i=Array.isArray(t.band)?t.band:[t.band];for(const t of i)e.push({kind:"band",getTop:an(t.y1Accessor,"y1"),getBottom:an(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}var ln=require("d3-scale");function un(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function hn(t,e,i){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return(0,ln.scaleLog)().domain(t).range(i).clamp(!0)}return"symlog"===t?(0,ln.scaleSymlog)().domain(e).range(i):"time"===t?(0,ln.scaleTime)().domain([new Date(e[0]),new Date(e[1])]).range(i):(0,ln.scaleLinear)().domain(e).range(i)}function dn(t,e,i){e>t.capacity&&(t.resize(e),i&&e>i.capacity&&i.resize(e))}function fn(t,e){const i=new po(t.capacity);return t.forEach(()=>i.push(e)),i}function pn(t,e,i,o){const n=t.push(e);return i&&i.push(o),n}function yn(t,e,i){if(!e||0===e.size)return;const o=new Set;if(t.forEach((t,e)=>{i(t)&&o.add(e)}),0===o.size)return;const n=e.toArray();e.clear();for(let t=0;n.length>t;t++)o.has(t)||e.push(n[t])}var gn=new WeakMap;function mn(){return this.updateResults.last}function xn(){return this.updateResults.last}function bn(t){return this.updateResults.subscribe(t)}function vn(t){this.config.layoutSelection=t}function wn(){gn.set(this,!0)}function kn(){const t=!0===gn.get(this);return gn.delete(this),t}function Sn(t){Object.assign(t.prototype,{getLastUpdateResult:mn,getUpdateSnapshot:xn,subscribeUpdateResult:bn,setLayoutSelection:vn,markStylePaintPending:wn,consumeStylePaintPending:kn})}var An=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mn=["scene-style","data-paint","accessibility","evidence"],_n=(t,e)=>({retainedData:t,invalidations:e}),Pn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Tn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ln=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Cn=["scene-geometry","data-paint","accessibility","evidence"],$n=["scene-style","data-paint","accessibility","evidence"],jn=[],zn={chartType:_n("rebuild",Pn),runtimeMode:_n("rebuild",Pn),xAccessor:_n("rebuild",Pn),yAccessor:_n("rebuild",Pn),timeAccessor:_n("rebuild",Pn),valueAccessor:_n("rebuild",Pn),y0Accessor:_n("rebuild",Pn),boundsAccessor:_n("rebuild",Pn),band:_n("rebuild",Pn),openAccessor:_n("rebuild",Pn),highAccessor:_n("rebuild",Pn),lowAccessor:_n("rebuild",Pn),closeAccessor:_n("rebuild",Pn),candlestickRangeMode:_n("rebuild",Pn),accessorRevision:_n("rebuild",Pn),groupAccessor:_n("rebuild",Tn),categoryAccessor:_n("rebuild",Tn),lineDataAccessor:_n("rebuild",Tn),colorAccessor:_n("rebuild",$n),sizeAccessor:_n("rebuild",Cn),symbolAccessor:_n("rebuild",Cn),pointIdAccessor:_n("rebuild",Cn),xScaleType:_n("preserve",Rn),yScaleType:_n("preserve",Rn),xExtent:_n("preserve",Rn),yExtent:_n("preserve",Rn),extentPadding:_n("preserve",Rn),scalePadding:_n("preserve",Rn),axisExtent:_n("preserve",Rn),binSize:_n("preserve",Rn),normalize:_n("preserve",Rn),heatmapAggregation:_n("preserve",Rn),heatmapXBins:_n("preserve",Rn),heatmapYBins:_n("preserve",Rn),arrowOfTime:_n("preserve",Ln),baseline:_n("preserve",Ln),stackOrder:_n("preserve",Ln),sizeRange:_n("preserve",Ln),curve:_n("preserve",Ln),areaGroups:_n("preserve",Ln),customLayout:_n("preserve",Ln),layoutConfig:_n("preserve",Ln),layoutMargin:_n("preserve",Ln),symbolMap:_n("preserve",Cn),showValues:_n("preserve",Cn),heatmapValueFormat:_n("preserve",Cn),lineStyle:_n("preserve",$n),pointStyle:_n("preserve",$n),areaStyle:_n("preserve",$n),barStyle:_n("preserve",$n),swarmStyle:_n("preserve",$n),waterfallStyle:_n("preserve",$n),candlestickStyle:_n("preserve",$n),boundsStyle:_n("preserve",$n),gradientFill:_n("preserve",$n),lineGradient:_n("preserve",$n),colorScheme:_n("preserve",$n),themeCategorical:_n("preserve",$n),themeSemantic:_n("preserve",$n),themeSequential:_n("preserve",$n),themeDiverging:_n("preserve",$n),barColors:_n("preserve",$n),decay:_n("preserve",$n),pulse:_n("preserve",$n),staleness:_n("preserve",$n),layoutSelection:_n("preserve",$n),annotations:_n("preserve",["overlay","accessibility","evidence"]),windowSize:_n("preserve",jn),windowMode:_n("preserve",jn),maxCapacity:_n("preserve",jn),clock:_n("preserve",jn),transition:_n("preserve",jn),introAnimation:_n("preserve",jn),onLayoutError:_n("preserve",jn)},En=_n("preserve",Ln),Dn=class{constructor(){this.tracker=new li}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},An)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Mn):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=zn[o]??En;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},Nn=require("d3-quadtree"),Fn=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let i=0,o=0;for(const t of e)"point"===t.type&&(i++,t.r>o&&(o=t.r));if(this.maxRadius=o,500>=i)return void(this.tree=null);const n=Array(i);let r=0;for(const t of e)"point"===t.type&&(n[r++]=t);this.tree=(0,Nn.quadtree)().x(t=>t.x).y(t=>t.y).addAll(n)}},In=class t{constructor(t){if(this.xExtent=new yo,this.yExtent=new yo,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 Dn,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 Fn,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,n,r=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;const l=n??(()=>{const t=new Map;for(let e=0;i.length>e;e++)t.set(i[e],e);return t})();for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let n=0,a=!1;for(const i of e){const e=l.get(i);if(null==e)continue;a=!0;const s=o.get(e);if(null==s)continue;const c=Lo(t,s,r);c>n&&(n=c)}a&&(c=Co(i,n,s)||c);continue}const e=l.get(i.datum);if(null==e)continue;const n=o.get(e);c=Co(i,null==n?0:Lo(t,n,r),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),i),this.config=t,this.buffer=new po(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=mo(t.timeAccessor||t.xAccessor,"time"),this.getY=mo(t.valueAccessor||t.yAccessor,"value")):(this.getX=mo(t.xAccessor,"x"),this.getY=mo(t.yAccessor,"y")),this.getGroup=bo(t.groupAccessor),this.getCategory=bo(t.categoryAccessor),this.getSize=t.sizeAccessor?mo(t.sizeAccessor,"size"):void 0,this.getColor=bo(t.colorAccessor),this.getSymbol=bo(t.symbolAccessor),this.getY0=t.y0Accessor?mo(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=cn(t),this.getPointId=bo(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?mo(t.openAccessor,"open"):void 0,this.getHigh=mo(t.highAccessor,"high"),this.getLow=mo(t.lowAccessor,"low"),this.getClose=i?mo(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new po(t.windowSize))}currentTime(){return this.config.clock?.()??Po()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=fn(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?mo(this.config.timeAccessor||this.config.xAccessor,"time"):mo(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],n=o instanceof Date,r="string"==typeof o&&Number.isFinite(wo(o));if(this.xIsDate=n||r,r){const t="string"==typeof i?i:void 0;this.getX=t?e=>ko(e[t]):t=>ko(i(t))}}dn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)pn(this.buffer,i,this.timestampBuffer,e),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=pn(this.buffer,i,this.timestampBuffer,e);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,n=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.yExtent.extent;let a=un(this.xExtent.extent,e.xExtent),c=un(s,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&i.size>0){const t=function(t){const{config:e,groups:i,getX:o,getY:n}=t,r="exact"===e.axisExtent;if(e.normalize){const i=[0,r?1:1+e.extentPadding];return{yDomain:i,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:i}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const t of i){const e=new Map;let i=0;for(const r of t.data){const t=o(r),s=n(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),i+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),h.set(t.key,i)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===d)p=i.map(t=>t.key);else if("insideOut"===d){const t=[...i].map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}),e=[],o=[];let n=0,r=0;for(const i of t)r>n?(e.push(i),n+=h.get(i)??0):(o.push(i),r+=h.get(i)??0);p=[...o.reverse(),...e]}else p="asc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(t)??0)-(h.get(e)??0);return 0!==i?i:f(t,e)}):"desc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}):i.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),i=Do(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let o=1/0,n=-1/0;for(const e of t){const t=i.get(e)??0,r=u.get(e)??0;o>t&&(o=t),t+r>n&&(n=t+r)}Number.isFinite(o)&&Number.isFinite(n)||(o=0,n=0);const s=n-o,l=r?0:s>0?s*e.extentPadding:1;y=[o-l,n+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[i,o]=function(t,e,i){let o=0,n=0;for(const r of t){let t=0,s=0;for(const o of e){const e=i(o,r)||0;0>e?s+=e:t+=e}o>s&&(o=s),t>n&&(n=t)}return[o,n]}(t,p,(t,e)=>a.get(t)?.get(e)||0),n=o-i,s=r?0:n>0?n*e.extentPadding:1;y=[i-s,o+s]}else y=[0,l+(r?0:l>0?l*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&i.size>0?c=function(t,e,i,o,n,r,s){const[,a]=function(t,e,i,o,n){const r=en(t,e,i,o,n);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(t,e,i,o,n);return[0,s?a:a+a*r]}(i,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!l&&i.size>0?c=function(t,e,i,o){const[n,r]=function(t,e){let i=0,o=0,n=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(n+=t,i>n&&(i=n),n>o&&(o=n))}return[i,o]}(t,e),s=r-n,a=o?0:s>0?s*i:1;return[Math.min(0,n-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(i,this.getY,e.extentPadding,h):l||c[0]===1/0||(c=function(t,e,i){if(!i.length)return t;let[o,n]=t;for(const t of e)for(const e of i){const i=e.getTop(t),r=e.getBottom(t);Number.isFinite(i)&&(o>i&&(o=i),i>n&&(n=i)),Number.isFinite(r)&&(o>r&&(o=r),r>n&&(n=r))}return[o,n]}(c,r,this.resolvedRibbons),c=function(t,e){const i=t[1]-t[0],o=e.exactMode?0:i>0?i*e.extentPadding:1,n=[null!=e.userMin?t[0]:t[0]-o,null!=e.userMax?t[1]:t[1]+o];return"log"!==e.yScaleType||n[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(n[0]=e.dataYDomain[0]/(1+e.extentPadding)),n}(c,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));c=function(t,e,i){if(!e||i)return t;const o=e[0],n=e[1];return null==o&&null==n?t:[null!=o?o:t[0],null!=n?n:t[1]]}(c,e.yExtent,!!l),({xDomain:a,yDomain:c}=function(t,e,i){let o=t,n=e;if(o[0]===1/0||o[1]===-1/0)if("time"===i){const t=Date.now();o=[t-864e5,t]}else o=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:o,yDomain:n}}(a,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:i,xDomain:o,yDomain:n}=t,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(i.width,i.height)/2-1));if(r){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,i.width-s]:[i.width-s,s];return{x:(0,ln.scaleLinear)().domain(o).range(t),y:hn(e.yScaleType,n,[i.height-s,s])}}const t="down"===e.arrowOfTime?[s,i.height-s]:[i.height-s,s];return{x:hn(e.yScaleType,n,[s,i.width-s]),y:(0,ln.scaleLinear)().domain(o).range(t)}}var a;return{x:hn(e.xScaleType,o,[s,i.width-s]),y:hn(e.yScaleType,n,[i.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=n):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":case"glyph":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),n=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=hn,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,r[0]>r[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,n,l?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:i,scales:o}=this;if(!o)return[];if(i.customLayout){const n={data:e,scales:o,dimensions:{width:t.width,height:t.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??j},resolveColor:(t,e)=>{const o=this.resolveGroupColor(t);if(o)return o;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null};let r;try{r=i.customLayout(n)}catch(t){const e=null!==this.lastCustomLayoutResult,o=sn("xy",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{i.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const s=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return on({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const n={scales:o,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){const i=t.groupData(e),o=[],n=t.config.annotations?.filter(Vo).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Yo(t.ribbons);if(r.length>0&&o.push(...qo(t,e,r)),n.length>0)for(const e of i)o.push(...Xo(t,e.data,e.key,n))}for(const e of i){const i=t.resolveLineStyle(e.key,e.data[0]),r=zo(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(r.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Go(t,i,o),o}(n,e);case"area":return function(t,e){const i=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Yo(t.ribbons);if(r.length>0&&o.push(...qo(t,e,r)),n.length>0)for(const e of i)o.push(...Xo(t,e.data,e.key,n))}const n=t.scales.y.domain()[0],r=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=Eo(e.data,t.scales,t.getX,t.getY,n,i,e.key,r),a=Zo(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return Go(t,i,o),o}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],n=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Yo(t.ribbons);if(r.length>0&&o.push(...qo(t,e,r)),n.length>0)for(const e of i)o.push(...Xo(t,e.data,e.key,n))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i)if(n.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),n=Eo(e.data,t.scales,t.getX,t.getY,r,i,e.key,s),a=Zo(t.config.gradientFill);a&&(n.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}else{const i=t.resolveLineStyle(e.key,e.data[0]),n=zo(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}return Go(t,i,o),o}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e),o=t.config.stackOrder??"key",n=()=>i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===o);else if("key"===o)n();else if("asc"===o||"desc"===o||"insideOut"===o){const e=new Map;for(const o of i){let i=0;for(const e of o.data){const o=t.getX(e),n=t.getY(e);Number.isFinite(o)&&Number.isFinite(n)&&(i+=n)}e.set(o.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===o)i.sort((t,i)=>{const o=(e.get(t.key)??0)-(e.get(i.key)??0);return 0!==o?o:n(t.key,i.key)});else if("desc"===o)i.sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:n(t.key,i.key)});else{const t=[...i].sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:n(t.key,i.key)}),o=[],r=[];let s=0,a=0;for(const i of t)a>s?(o.push(i),s+=e.get(i.key)??0):(r.push(i),a+=e.get(i.key)??0);i.length=0,i.push(...r.reverse(),...o)}}else n();const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:c}=function(t,e,i,o,n,r,s,a="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);Number.isFinite(e)&&c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=i(n),r=o(n);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let h;if(r){h=new Map;for(const e of l){let i=0;for(const o of t)i+=u.get(o.key)?.get(e)||0;h.set(e,i||1)}}const d=Do(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!r,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of l)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const i of t){const t=u.get(i.key),o=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:c,style:n(i.key,i.data[0]),datum:i.data,group:i.key};s&&(t.curve=s),p.push(t)}a=[],c=[]};for(const i of l){const n=t.has(i);let s,l,u=n?t.get(i):0;if(r&&n&&(u/=h.get(i)),!n||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(i),l=s+u,m.set(i,l)):(s=x.get(i),l=s+u,x.set(i,l)):(s=g.get(i),l=s+u,g.set(i,l));const p=e.x(i);c.push([p,e.y(s)]),a.push([p,e.y(l)]),o.set(i,l)}d(),y.set(i.key,o)}return{nodes:p,stackedTops:y}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,r,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=c.get(o.key);if(i)for(const n of o.data){const o=t.getX(n),r=t.getY(n);null==o||Number.isNaN(o)||null==r||Number.isNaN(r)||!i.has(o)||e.set(n,i.get(o))}}const o=i=>e.get(i)??t.getY(i);Go(t,i,l,o)}return l}(n,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let r=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);r=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",c=t.getSymbol,l=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=l?.[t];if(e)return e;let i=u.get(t);return i||(i=Qo[h%Qo.length],h++,u.set(t,i)),i};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},l=e.r||o;if(r&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(l=r(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(n);i&&s.has(i)&&(e={...e,fill:s.get(i)})}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const o=d(c(n)+""),r=Fo(n,t.scales,t.getX,t.getY,Math.PI*l*l,o,e,u);r&&i.push(r)}else{const o=No(n,t.scales,t.getX,t.getY,l,e,u);o&&i.push(o)}}return i}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){const o=Math.max(1,Math.floor(t.config.heatmapXBins??20)),n=Math.max(1,Math.floor(t.config.heatmapYBins??20)),r=t.config.heatmapAggregation??"count",s=mo(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),h=(c-a||1)/o,d=(u-l||1)/n,f=o*n;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let i=0;e.length>i;i++){const r=e[i],c=t.getX(r),u=t.getY(r);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),o-1),g=Math.min(Math.floor((u-l)/d),n-1);if(0>f||0>g)continue;const m=g*o+f;p[m]++;const x=s(r);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===p[t])continue;let e;switch(r){case"sum":e=y[t];break;case"mean":e=y[t]/p[t];break;default:e=p[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,b=i.width/o,v=i.height/n,w=t.config.showValues,k=t.config.heatmapValueFormat,S=[];for(let t=0;n>t;t++){const e=t*o;for(let i=0;o>i;i++){const o=e+i;if(0===p[o])continue;let s;switch(r){case"sum":s=y[o];break;case"mean":s=y[o]/p[o];break;default:s=p[o]}const c=(s-g)/x;S.push(Oo(i*b,(n-1-t)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:i,yi:t,value:s,count:p[o],sum:y[o],xCenter:a+(i+.5)*h,yCenter:l+(t+.5)*d,agg:r},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(t,e,i);if(0===e.length)return[];const o=mo(t.config.valueAccessor,"value"),n=xo(t.config.xAccessor,"x"),r=xo(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=n(i),u=r(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),p=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(p){d.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),b=new Map;let v=0;for(let t=0;e.length>t;t++){const i=e[t],n=s.get(c[t]),r=a.get(l[t]);if(void 0===n||void 0===r)continue;const h=o(i),d=r*u+n,f=b.get(d);let p;void 0!==f?p=f:(p=v++,b.set(d,p)),g[p]=d,m[p]=h,x[p]=i}let w=1/0,k=-1/0;for(let t=0;v>t;t++){const e=m[t];isFinite(e)&&(w>e&&(w=e),e>k&&(k=e))}if(!isFinite(w)||!isFinite(k))return[];const S=function(t){const e=t in R?t:"blues";let i=tn.get(e);if(i)return i;i=Array(256);const o=L(e);for(let t=0;256>t;t++)i[t]=o(t/255);return tn.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),A=255/(k-w||1),M=i.width/u,_=i.height/h,P=t.config.showValues,T=t.config.heatmapValueFormat,C=[];for(let t=0;v>t;t++){const e=m[t];if(!isFinite(e))continue;const i=g[t],o=i%u;C.push(Oo(o*M,(h-1-(i-o)/u)*_,M,_,S[Math.min((e-w)*A+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:T}:void 0))}return C}(n,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=en(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const i of t.categories.keys())e.add(i);const n=t.config.barColors?Object.keys(t.config.barColors):[],r=new Set(n),s=Array.from(e).filter(t=>!r.has(t)).sort(),a=n.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:c,order:o})}const n=[],r=t.scales,[s,a]=r.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const e of i.values()){const i=Math.max(e.start,s),u=Math.min(e.end,a);if(i>=u)continue;const f=r.x(i),p=r.x(u),y=Math.abs(p-f),g=y>h+1?h:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&e.categories.size>0){let i=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=r.y(i),u=r.y(i+o);n.push(Io(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),i+=o}}else{const t=r.y(0),i=r.y(e.total);n.push(Io(m,Math.min(t,i),x,Math.abs(t-i),{fill:c?.fill||l||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of i.values())f.add(t.start),f.add(t.end);return{nodes:n,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=n.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const i=[],o=t.config.swarmStyle||{},n=o.radius??3,r=o.fill??t.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,c=o.strokeWidth;for(const o of e){const e=t.getX(o),l=t.getY(o);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),h=t.scales.y(l);let d=r;if(t.getCategory){const e=t.getCategory(o);d=t.config.barColors?.[e]||d}const{r:f,...p}=t.config.pointStyle?.(o)??{},y={type:"point",x:u,y:h,r:f??n,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...p},datum:o};t.getPointId&&(y.pointId=t.getPointId(o)+""),i.push(y)}return i}(n,e);case"waterfall":return function(t,e,i){const o=[],n=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,h=r?.strokeWidth,d=r?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-y:e>0?y-t.getX(s[e-1]):0;const b=n.x(y),v=0!==x?n.x(y+x):b+i.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=n.y(f),A=n.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),o.push(Io(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth})),f=m}return o}(n,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const i=t.config.candlestickRangeMode??!1;if(!(i||t.getOpen&&t.getClose))return[];const o=[],n=t.config.candlestickStyle||{},r=n.rangeColor||"#6366f1",s=i?r:n.upColor||"#28a745",a=i?r:n.downColor||"#dc3545",c=i?r:n.wickColor||"#333",l=n.wickWidth||(i?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=n.bodyWidth??0;if(null==n.bodyWidth)if(u.length>1){let e=1/0;for(let i=1;u.length>i;i++){const o=Math.abs(t.scales.x(u[i])-t.scales.x(u[i-1]));o>0&&e>o&&(e=o)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),u=t.getLow(n);if(null==r||Number.isNaN(r)||null==u||Number.isNaN(u))continue;const d=i?r:t.getOpen(n),f=i?u:t.getClose(n);if(!i&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const p=f>=d,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:n};i&&(y.isRange=!0),o.push(y)}return o}(n,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,i,o){const n=t.boundsStyle;return"function"==typeof n?n(i||{},e):n&&"object"==typeof n?n:{fill:o(e,i).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?To(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=Ro(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,i,o=Ro(i)){const n=i.length;if(n>1)for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let i=0;e.length>i;i++){const a=o.get(e[i]);null!=a?(r[i]=To(t,a,n),1>r[i]&&(s=!0)):r[i]=1}s&&(i._decayOpacities=r);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let i=0;e.length>i;i++){const r=o.get(e[i]);null!=r?(s[i]=To(t,r,n),1>s[i]&&(a=!0)):s[i]=1}a&&(i._decayOpacities=s)}else{let s=1;for(const i of e){const e=o.get(i);if(null!=e){const i=To(t,e,n);s>i&&(s=i)}}if(1>s){const t=Array(r);t.fill(s),i._decayOpacities=t}}continue}const e=o.get(i.datum);if(null==e)continue;const r=To(t,e,n);"heatcell"===i.type?i.style={opacity:r}:"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&$o(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){i.clear(),o.clear();for(let n=0;e.length>n;n++){const r=e[n],s=jo(t,r,n);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:r.style.opacity,glyph:r.glyph}):"rect"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style?.opacity}):"candlestick"===r.type?i.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:r.style?.opacity}):"line"===r.type?o.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&o.set(s,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=jo(this.transitionContext,i,e);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(o,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(o,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,n,r=Po()){if(0===o.size&&0===n.size)return i;const s=e.duration??300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let e=0;i.scene.length>e;e++){const r=i.scene[e],s=jo(t,r,e);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){const t=n.get(s);if(t){if(l.add(s),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];a=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];a=!0}r._targetOpacity=r.style.opacity??1,r._startOpacity=t.opacity??r.style.opacity??1}else r._targetOpacity=r.style.opacity??1,r._startOpacity=0,r.style={...r.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=u.x,r.y=u.y,r.r=u.r??r.r,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("glyph"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,size:r.size};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.size,r.x=u.x,r.y=u.y,r.size=u.r??r.size,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("rect"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("heatcell"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){c.add(s);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=r.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=u.x,r.openY=u.openY,r.closeY=u.closeY??r.closeY,r.highY=u.highY??r.highY,r.lowY=u.lowY??r.lowY,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0}for(const[t,e]of n)if(!l.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}for(const[t,e]of o)if(!c.has(t)){if(t.startsWith("p:"))i.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)i.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))i.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const o=e.openY??e.y;i.exitNodes.push({type:"candlestick",x:e.x,openY:o,closeY:e.closeY??o,highY:e.highY??o,lowY:e.lowY??o,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:r,duration:s}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){if(!i.activeTransition)return!1;const n=Mo(t,i.activeTransition),r=Ao(n,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=_o(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=_o(i.x,t._targetX,r),t.y=_o(i.y,t._targetY,r),void 0!==t._targetR&&void 0!==i.r&&(t.r=_o(i.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=_o(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=_o(i.x,t._targetX,r),t.y=_o(i.y,t._targetY,r),void 0!==t._targetR&&void 0!==i.r&&(t.size=_o(i.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=_o(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=_o(i.x,t._targetX,r),t.y=_o(i.y,t._targetY,r),void 0!==i.w&&(t.w=_o(i.w,t._targetW,r)),void 0!==i.h&&(t.h=_o(i.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:_o(i?i.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=_o(i.x,t._targetX,r),t.y=_o(i.y,t._targetY,r),void 0!==i.w&&(t.w=_o(i.w,t._targetW,r)),void 0!==i.h&&(t.h=_o(i.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:_o(i?i.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=_o(i.x,t._targetX,r),void 0!==i.openY&&(t.openY=_o(i.openY,t._targetOpenY,r)),void 0!==i.closeY&&(t.closeY=_o(i.closeY,t._targetCloseY,r)),void 0!==i.highY&&(t.highY=_o(i.highY,t._targetHighY,r)),void 0!==i.lowY&&(t.lowY=_o(i.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:_o(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=_o(e[o][0],i[o][0],r),t.path[o][1]=_o(e[o][1],i[o][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:_o(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,n=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=_o(e[i][0],o[i][0],r),t.topPath[i][1]=_o(e[i][1],o[i][1],r);if(i&&n&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=_o(i[e][0],n[e][0],r),t.bottomPath[e][1]=_o(i[e][1],n[e][1],r)}}if(n>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:i}=function(t,e,i,o){if(o&&o.version===i&&o.group===e&&o.data===t)return{result:o.result,cache:o};let n;if(e){const i=new Map;for(const o of t){const t=e(o);i.has(t)||i.set(t,[]),i.get(t).push(o)}n=Array.from(i.entries()).map(([t,e])=>({key:t,data:e}))}else n=[{key:"_default",data:t}];return{result:n,cache:{version:i,group:e,data:t,result:n}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,e}resolveColorMap(t){const{map:e,cache:i}=function(t,e,i,o,n){if(n&&n.version===o)return{map:n.map,cache:n};const r=new Set;if(e)for(const i of t){const t=e(i);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(n&&n.key===a){const t={...n,version:o};return{map:t.map,cache:t}}const c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical||j,l=new Map;for(let t=0;s.length>t;t++)l.set(s[t],c[t%c.length]);return{map:l,cache:{key:a,map:l,version:o}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,e}resolveLineStyle(t,e){return function(t,e,i,o){const n=t.lineStyle;if("function"==typeof n){const t=n(i||{},e);if(t&&!t.stroke&&e){const i=o(e);if(i)return{...t,stroke:i}}return t}const r=t.themeSemantic?.primary;return n&&"object"==typeof n?{stroke:n.stroke||r||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:o(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,i,o){if(t.areaStyle){const n=t.areaStyle(i||{});if(n&&!n.fill&&e){const t=o(e);if(t)return{...n,fill:t,stroke:n.stroke||t}}return n}const n=t.lineStyle;if("function"==typeof n){const t=n(i||{},e);if(t&&!t.fill&&e){const i=o(e);if(i)return{...t,fill:i,stroke:t.stroke||i}}return t}const r=t.themeSemantic?.primary;if(n&&"object"==typeof n)return{fill:n.fill||n.stroke||r||"#4e79a7",fillOpacity:n.fillOpacity??.7,stroke:n.stroke||r||"#4e79a7",strokeWidth:n.strokeWidth||2};const s=o(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:i,groupColorCounter:o}=function(t){const{group:e,colorMapCache:i,groupColorMap:o,groupColorMapCap:n,config:r}=t;let{groupColorCounter:s}=t;if(i){const t=i.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=o.get(e);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(r.colorScheme)&&r.colorScheme.length>0?r.colorScheme:null)||(Array.isArray(r.themeCategorical)&&r.themeCategorical.length>0?r.themeCategorical:null)||j;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(e,l),o.size>n){const t=o.keys().next().value;void 0!==t&&o.delete(t)}return{color:l,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=So(t),i=this.getPointId,o=t=>e.has(i(t));yn(this.buffer,this.timestampBuffer,o);const n=this.buffer.remove(o);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=So(t),o=this.getPointId,n=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&n.add(e)});const r=this.buffer.update(t=>i.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{n.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},n=i(o,e);o.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let o=!1,n=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const r="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(r||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=r||!go(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!go(i,s);(a||c)&&(t?(this.getX=mo(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=mo(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=mo(this.config.xAccessor,"x"),this.getY=mo(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=cn(this.config)),o=!0,n=!0)}if("groupAccessor"in t&&!go(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bo(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in t&&!go(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bo(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in t&&!go(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?mo(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in t&&!go(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?bo(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in t&&!go(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bo(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in t&&!go(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?mo(this.config.y0Accessor,"y0"):void 0,o=!0,n=!0),("boundsAccessor"in t&&!go(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=cn(this.config),o=!0,n=!0),"pointIdAccessor"in t&&!go(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bo(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!go(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!go(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!go(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!go(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?mo(this.config.openAccessor,"open"):void 0,this.getHigh=mo(this.config.highAccessor,"high"),this.getLow=mo(this.config.lowAccessor,"low"),this.getClose=e?mo(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,o=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(o=!0,n=!0),!o){const i=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of i)if(t[n]!==e[n]){o=!0;break}}o&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};In.GROUP_COLOR_MAP_CAP=1e3;var On=In;Sn(On);var Bn=c(require("react")),Wn=require("d3-shape"),Yn=require("react/jsx-runtime");function qn(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function Xn(t,e){const{background:i="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45,lineOpacity:a=1}=t,c=Math.max(8,Math.ceil(2*r));return(0,Yn.jsxs)("pattern",{id:e,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&(0,Yn.jsx)("rect",{width:c,height:c,fill:i}),(0,Yn.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:n,strokeOpacity:a}),(0,Yn.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:o,strokeWidth:n,strokeOpacity:a})]},e)}function Gn(t,e,i="#4e79a7"){if(qn(t)){const i=function(t,e){let i=2166136261;const o=function(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}(e);for(let t=0;o.length>t;t++)i^=o.charCodeAt(t),i=Math.imul(i,16777619);return`${t}-hatch-${(i>>>0).toString(36)}`}(e,t);return{fill:`url(#${i})`,def:Xn(t,i)}}return t&&"string"==typeof t?{fill:t}:{fill:i}}var Vn=[40,40],Hn=[.5,.5];function Zn(t,e,i,o){if("none"!==t)return"color"===t||null==t?e??o:"accent"===t?i:t}var Kn=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function Un(t){const{innerRadius:e,outerRadius:i,startAngle:o,endAngle:n}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=Kn(i,o),e=Kn(i,n);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${n-o>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=Kn(i,o),s=Kn(i,n),a=Kn(e,n),c=Kn(e,o),l=n-o>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(i-e)/2));if(0===s)return Un({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,i-s))),c=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=n-o,u=t.roundStart&&t.roundEnd?l/2:l,h=!!t.roundStart&&u>a,d=!!t.roundEnd&&u>a;if(!h&&!d)return Un({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(h?a:0),p=n-(d?a:0),y=o+(h?c:0),g=n-(d?c:0),m=Kn(i,f),x=Kn(i,p),b=(i-s)*Math.cos(a),v=Kn(b,o),w=Kn(b,n),k=r?null:Kn(e,g),S=r?null:Kn(e,y),A=r?0:(e+s)*Math.cos(c),M=r?null:Kn(A,o),_=r?null:Kn(A,n),P=p-f>Math.PI?1:0,T=r?0:g-y>Math.PI?1:0;let R="";if(h)R+=`M${v.x},${v.y}`,R+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=Kn(i,o);R+=`M${t.x},${t.y}`}if(d)R+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,R+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=Kn(i,n);R+=` A${i},${i} 0 ${P} 1 ${t.x},${t.y}`}if(r)R+=" L0,0";else{if(d)R+=` L${_.x},${_.y}`,R+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=Kn(e,n);R+=` L${t.x},${t.y}`}if(h)R+=` A${e},${e} 0 ${T} 0 ${S.x},${S.y}`,R+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=Kn(e,o);R+=` A${e},${e} 0 ${T} 0 ${t.x},${t.y}`}}return R+=" Z",R}var Qn=require("react/jsx-runtime"),Jn={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function tr(t,e="#4e79a7"){return qn(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function er(t,e,i){const o=Jo(t.symbolType,t.size,t.path);return(0,Qn.jsx)("path",{d:o,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?tr(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${i??""}symbol-${e}`)}function ir(t,e,i,o){const n=t.glyph;if(!n?.parts?.length||0>=t.size)return null;const r=function(t,e){const[i,o]=t.viewBox??Vn,[n,r]=t.anchor??Hn,s=o>0?o:1,a=Math.max(0,e)/s,c=(i>0?i:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-n*c,offsetY:-r*l}}(n,t.size);if(0>=r.scale)return null;const s=`translate(${e},${i})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${r.offsetX},${r.offsetY}) scale(${r.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),c=function(t,e,i=0,o="horizontal"){const[n,r]=t.viewBox??Vn,s=Math.min(1,Math.max(0,i)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===o?{x:0,y:r*(1-a),width:n,height:r*(a-s)}:{x:n*s,y:0,width:n*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}(n,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),l=c?or(o+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>n.parts.map((i,o)=>{const n=e?"none"===i.fill?void 0:e:Zn(i.fill,a,t.accent),r=e?i.stroke&&"none"!==i.stroke?e:void 0:Zn(i.stroke??"none",a,t.accent);return n||r?(0,Qn.jsx)("path",{d:i.d,fill:n??"none",stroke:r,strokeWidth:r?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},o):null});return(0,Qn.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,Qn.jsx)("clipPath",{id:l,children:(0,Qn.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?(0,Qn.jsx)("g",{children:h(t.ghostColor)}):null,c&&l?(0,Qn.jsx)("g",{clipPath:`url(#${l})`,children:h()}):h()]},o)}function or(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function nr(t,e,i){switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return(0,Qn.jsx)("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+e)}case"area":{const o=t;if(0===o.topPath.length)return null;const n=`M${o.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`,r=`${i?i+"-":""}area-${e}-hatch`,s=qn(o.style.fill)?Xn(o.style.fill,r):void 0,a=s?`url(#${r})`:tr(o.style.fill);if(o.clipRect){const t=`${i?i+"-":""}area-clip-${e}`;return(0,Qn.jsxs)("g",{children:[(0,Qn.jsxs)("defs",{children:[s,(0,Qn.jsx)("clipPath",{id:t,children:(0,Qn.jsx)("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),(0,Qn.jsx)("path",{d:n,fill:a,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+e)}return(0,Qn.jsxs)(Bn.Fragment,{children:[s&&(0,Qn.jsx)("defs",{children:s}),(0,Qn.jsx)("path",{d:n,fill:a,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"area-"+e)}case"point":{const o=t,n=`${i?i+"-":""}point-${e}-hatch`,r=qn(o.style.fill)?Xn(o.style.fill,n):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[r&&(0,Qn.jsx)("defs",{children:r}),(0,Qn.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:r?`url(#${n})`:tr(o.style.fill),opacity:o.style.opacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+e)}case"symbol":return er(t,e);case"glyph":return ir(t,t.x,t.y,`${i??""}glyph-${t.pointId??e}`);case"rect":{const o=t,n=`${i?i+"-":""}xyrect-${e}-hatch`,r=qn(o.style.fill)?Xn(o.style.fill,n):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[r&&(0,Qn.jsx)("defs",{children:r}),(0,Qn.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r?`url(#${n})`:tr(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+e)}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),s=.299*o+.587*n+.114*r>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return(0,Qn.jsxs)("g",{children:[(0,Qn.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),(0,Qn.jsx)("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return(0,Qn.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+e)}case"candlestick":{const i=t,o=Math.min(i.openY,i.closeY),n=Math.max(Math.abs(i.openY-i.closeY),1),r=i.isUp?i.upColor:i.downColor;return(0,Qn.jsxs)("g",{children:[(0,Qn.jsx)("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),(0,Qn.jsx)("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:n,fill:r,stroke:r,strokeWidth:1})]},"candle-"+e)}default:return null}}function rr(t,e,i){const o=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",n=i=>`ord-${t.type}-${o}-${e}-${i}`,r=`ord-${t.type}-${o}-${e}`;switch(t.type){case"rect":{const e=t,i=or(r)+"-grad",o=function(t,e){const i=t.fillGradient;if(!i||"object"!=typeof i)return null;let o=t.x,n=t.y,r=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(n=t.y+t.h,s=t.y):"right"===t.roundedEdge?(o=t.x+t.w,n=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(o=t.x,n=t.y,r=t.x+t.w,s=t.y);const a=[];if("colorStops"in i){const t=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>t.length)return null;for(let e=0;t.length>e;e++)a.push((0,Qn.jsx)("stop",{offset:t[e].offset,stopColor:t[e].color},e))}else{const e=tr(t.style.fill);a.push((0,Qn.jsx)("stop",{offset:0,stopColor:e,stopOpacity:i.topOpacity},"0")),a.push((0,Qn.jsx)("stop",{offset:1,stopColor:e,stopOpacity:i.bottomOpacity},"1"))}return(0,Qn.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:o,y1:n,x2:r,y2:s,children:a})}(e,i);let n,a;if(o)a=`url(#${i})`;else if(qn(e.style.fill)){const t=or(r)+"-hatch";n=Xn(e.style.fill,t),a=`url(#${t})`}else a=tr(e.style.fill);const c=o||n?(0,Qn.jsxs)("defs",{children:[o,n]}):null;if(e.cornerRadii&&(((s=e.cornerRadii).tl??0)>0||(s.tr??0)>0||(s.br??0)>0||(s.bl??0)>0)){const t=function(t){const{x:e,y:i,w:o,h:n}=t,{tl:r,tr:s,br:a,bl:c}=function(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const i=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(t??0,i));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}(t);let l=`M${e+r},${i}`;return l+=` L${e+o-s},${i}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+o},${i+s}`),l+=` L${e+o},${i+n-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+o-a},${i+n}`),l+=` L${e+c},${i+n}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${i+n-c}`),l+=` L${e},${i+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${e+r},${i}`),l+=" Z",l}(e);return(0,Qn.jsxs)(Bn.Fragment,{children:[c,(0,Qn.jsx)("path",{d:t,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}if(e.roundedTop&&e.roundedTop>0){const t=Math.min(e.roundedTop,e.w/2,e.h/2),{x:i,y:o,w:n,h:s}=e;let l;switch(e.roundedEdge){case"right":l=`M${i},${o} L${i+n-t},${o} A${t},${t} 0 0 1 ${i+n},${o+t} L${i+n},${o+s-t} A${t},${t} 0 0 1 ${i+n-t},${o+s} L${i},${o+s} Z`;break;case"left":l=`M${i+n},${o} L${i+t},${o} A${t},${t} 0 0 0 ${i},${o+t} L${i},${o+s-t} A${t},${t} 0 0 0 ${i+t},${o+s} L${i+n},${o+s} Z`;break;case"bottom":l=`M${i},${o} L${i+n},${o} L${i+n},${o+s-t} A${t},${t} 0 0 1 ${i+n-t},${o+s} L${i+t},${o+s} A${t},${t} 0 0 1 ${i},${o+s-t} Z`;break;default:l=`M${i},${o+s} L${i},${o+t} A${t},${t} 0 0 1 ${i+t},${o} L${i+n-t},${o} A${t},${t} 0 0 1 ${i+n},${o+t} L${i+n},${o+s} Z`}return(0,Qn.jsxs)(Bn.Fragment,{children:[c,(0,Qn.jsx)("path",{d:l,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return(0,Qn.jsxs)(Bn.Fragment,{children:[c,(0,Qn.jsx)("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}case"point":{const e=t;return(0,Qn.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:tr(e.style.fill),opacity:e.style.opacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return er(t,e,i);case"glyph":return ir(t,t.x,t.y,`${i??""}ord-glyph-${t.pointId??e}`);case"wedge":{const o=t;if(o._gradientBand&&o._gradientBand.colors.length>0){const t=or(`${i?i+"-":""}gauge-grad-${o.category||r}-${e}`),{clipPath:n,slices:s}=function(t){const e=Un({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),i=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let n=0;o.length>n;n++)i.push({d:Un({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+n*e,endAngle:t.endAngle}),color:o[n]})}return{clipPath:e,slices:i}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return(0,Qn.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,Qn.jsx)("defs",{children:(0,Qn.jsx)("clipPath",{id:t,children:(0,Qn.jsx)("path",{d:n})})}),(0,Qn.jsx)("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>(0,Qn.jsx)("path",{d:t.d,fill:tr(t.color)},e))}),o.style.stroke&&"none"!==o.style.stroke&&(0,Qn.jsx)("path",{d:n,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},r)}let n;if(o.roundedEnds)n=Un({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const t=(0,Wn.arc)().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&t.cornerRadius(o.cornerRadius),n=t(Jn)||""}return(0,Qn.jsx)("path",{d:n,transform:`translate(${o.cx},${o.cy})`,fill:tr(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},r)}case"boxplot":{const e=t,i=e.columnWidth/2;return(0,Qn.jsxs)("g","vertical"===e.projection?{children:[(0,Qn.jsx)("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Qn.jsx)("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:tr(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Qn.jsx)("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),(0,Qn.jsx)("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Qn.jsx)("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,Qn.jsx)("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Qn.jsx)("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:tr(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Qn.jsx)("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),(0,Qn.jsx)("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,Qn.jsx)("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1})]},r)}case"violin":{const e=t,i=[(0,Qn.jsx)("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:tr(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},n("path"))];if(e.iqrLine&&e.bounds){const t=e.bounds,o=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?i.push((0,Qn.jsx)("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,Qn.jsx)("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med"))):i.push((0,Qn.jsx)("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,Qn.jsx)("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med")))}return(0,Qn.jsx)("g",{children:i},r)}case"connector":return(0,Qn.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity??.5},r);case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return(0,Qn.jsx)("polygon",{points:i,fill:tr(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}var s}var sr=new Set;function ar(t){const{node:e,index:i,renderMode:o,fallback:n}=t,r=function(t,e){const i="function"==typeof t?t(e.datum??null,e):t;return(o=i)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?i:void 0;var o}(o,e);if(!r)return n();const s=r.renderStaticSVG({node:e,style:e.style??{},key:`${r.id}-${i}`});return null!=s?s:(function(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${t}:${e}`;sr.has(i)||(sr.add(i),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}(r.id,e.type??"unknown"),n())}var cr=require("d3-scale"),lr=require("react/jsx-runtime"),ur=14,hr=20,dr=6,fr=8;function pr(t){return"left"===t?"start":"right"===t?"end":t??"start"}function yr(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function gr(t,e,i,o){const n=yr(o);return e+i+Math.ceil(t.length*n*.58)}function mr(t){const{categories:e,theme:i,position:o="right",totalWidth:n,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??ur),l=Math.max(0,a?.labelGap??dr),u=Math.max(0,a?.itemGap??fr),h=Math.max(c,a?.rowHeight??hr),d=c+l,f=Math.min(2,c/2),p="top"===o||"bottom"===o,y=Math.max(c,n-s.left-s.right),g=Math.max(h,r-s.top-s.bottom),m=e.map(t=>gr(t,c,l,i));if(p){const t=Math.max(c,a?.maxWidth??y),i=[];let o=0,n=0;m.forEach((e,r)=>{const s=0===n?e:n+u+e;n>0&&s>t?(i.push({start:o,end:r,width:n}),o=r,n=e):n=s}),e.length>0&&i.push({start:o,end:e.length,width:n});const r=pr(a?.align),s=[];return i.forEach((i,o)=>{let n="center"===r?Math.max(0,(t-i.width)/2):"end"===r?Math.max(0,t-i.width):0;for(let t=i.start;i.end>t;t++)s.push({category:e[t],width:m[t],x:n,y:o*h}),n+=m[t]+u}),{items:s,width:Math.max(0,...i.map(t=>t.width)),height:i.length*h,swatchSize:c,labelOffset:d,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/h)),v=Math.max(1,Math.ceil(e.length/b));return{items:e.map((t,e)=>({category:t,width:m[e],x:Math.floor(e/b)*(x+u),y:e%b*h})),width:v*x+Math.max(0,v-1)*u,height:Math.min(e.length,b)*h,swatchSize:c,labelOffset:d,swatchRadius:f}}function xr(t){const{legendGroups:e,theme:i,position:o="right",totalWidth:n,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??ur),l=Math.max(0,a?.labelGap??dr),u=Math.max(0,a?.itemGap??fr),h=Math.max(c,a?.rowHeight??hr),d=c+l,f=Math.min(2,c/2),p=Math.max(12,yr(i)),y="top"===o||"bottom"===o,g=Math.max(c,n-s.left-s.right),m=Math.max(h,r-s.top-s.bottom);if(y){const o=Math.max(c,a?.maxWidth??g),n=pr(a?.align);let r=0,s=0;const l=[];for(const n of e){const e=n.items.map(t=>t.label),u=mr({...t,categories:e,legendLayout:{...a,maxWidth:Math.max(c,o-p-8),align:"start"}}),h=n.label?p:0,d=n.label?gr(n.label,0,0,i):0,f=h>0?h+8:0,y=f+u.width,g=Math.max(u.height,d);l.push({group:n,x:r,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,s=Math.max(s,g)}const u=l.length>0?r-12:0,h=u>o?0:"center"===n?Math.max(0,(o-u)/2):"end"===n?Math.max(0,o-u):0;return{groups:l.map(t=>({...t,x:t.x+h})),width:u,height:s,swatchSize:c,labelOffset:d,swatchRadius:f}}let x=0,b=0;const v=[];for(const t of e){const e=t.items.map(t=>t.label).map(t=>gr(t,c,l,i)),o=Math.max(0,...e),n=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(h,m-x)/h)))),r=Math.max(1,Math.ceil(t.items.length/n)),s=t.items.map((t,i)=>({category:t.label,width:e[i],x:Math.floor(i/n)*(o+u),y:i%n*h})),a=r*o+Math.max(0,r-1)*u,d=Math.min(t.items.length,n)*h,f=t.label?gr(t.label,0,0,i):0,y=t.label?p+8:0,g=y+d+12,w=Math.max(a,f);v.push({group:t,x:0,y:x,itemOffsetX:0,itemOffsetY:y,width:w,height:g,items:s}),b=Math.max(b,w),x+=g}return{groups:v,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:d,swatchRadius:f}}function br(t){const e="top"===t.position||"bottom"===t.position,i=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??i,200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function vr(t){const{categories:e,colorScheme:i,theme:o,position:n="right",totalWidth:r,totalHeight:s,margin:a,hasTitle:c=!1}=t;if(!e||0===e.length)return null;const l=function(t,e,i){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>D(t,e)??"#999"}const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:g;return(0,cr.scaleOrdinal)().domain(t).range(o)}(e,i,o),u="top"===n||"bottom"===n,h=mr(t);let d,f;if("left"===n?(d=Math.max(4,a.left-h.width-10),f=a.top):"top"===n?(d=a.left,f=c?32:8):"bottom"===n?(d=a.left,f=Math.min(s-a.bottom+38,s-h.height-2)):(d=Math.min(r-h.width-4,r-a.right+10),f=a.top),u){const t=h.items.map((t,e)=>(0,lr.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,lr.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(t.category),rx:h.swatchRadius}),(0,lr.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:yr(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return(0,lr.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:t})}const p=h.items.map((t,e)=>(0,lr.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,lr.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(t.category),rx:h.swatchRadius}),(0,lr.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:yr(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return(0,lr.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:p})}function wr(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}var kr=require("react/jsx-runtime");function Sr(t,e=120,i=8){if(!t)return[];const o=Math.max(1,Math.floor(e/i)),n=t.split(/\s+/),r=[];let s="";for(const t of n)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function Ar(t,e,i,o){return"curly"===t?o?`M0,0 C${.6*i},0 ${.4*i},${e/2} ${i},${e/2} C${.4*i},${e/2} ${.6*i},${e} 0,${e}`:`M0,0 C0,${.6*i} ${e/2},${.4*i} ${e/2},${i} C${e/2},${.4*i} ${e},${.6*i} ${e},0`:o?`M0,0 L${i},0 L${i},${e} L0,${e}`:`M0,0 L0,${i} L${e},${i} L${e},0`}function Mr(t,e,i,o){if(!t)return(0,kr.jsx)("g",{className:"annotation-note"});const{label:n,title:r,orientation:s,align:a,wrap:c=120,noWrap:l}=t;if(!n&&!r)return(0,kr.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>i?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,p=r?l?[r]:Sr(r,c):[],y=n?l?[n]:Sr(n,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push((0,kr.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(r&&n?2:0))+f,style:{overflow:"visible"},children:(0,kr.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[r&&(0,kr.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),n&&(0,kr.jsx)("div",{className:"annotation-note-label",children:n})]})},"annotation-note-html")):(p.length>0&&(x.push((0,kr.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:d,fontWeight:"bold",children:p.map((t,e)=>(0,kr.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,kr.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:d,y:m,children:y.map((t,e)=>(0,kr.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((r||n)&&(0!==e||0!==i))if("topBottom"===u){const t=Math.min(c,120);let e=0,i=t;"end"===d?(e=-t,i=0):"middle"===d&&(e=-t/2,i=t/2),v=(0,kr.jsx)("line",{className:"note-line",x1:e,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,i=t;"bottom"===h?(e=-t,i=0):"middle"===h&&(e=-t/2,i=t/2),v=(0,kr.jsx)("line",{className:"note-line",x1:0,x2:0,y1:e,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>i?-(w+2):18:"leftRight"===u&&(k="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),(0,kr.jsxs)("g",{className:"annotation-note",transform:`translate(${e},${i})`,children:[(0,kr.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function _r(t,e,i,o,n){const r=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&r.push((0,kr.jsx)("circle",{r:t,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,o=e?.height||0;(t>0||o>0)&&r.push((0,kr.jsx)("rect",{width:t,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&r.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=o||0,s=n||0;if(void 0!==e?.x){const o=(e.x||0)-t;r.push((0,kr.jsx)("line",{x1:o,y1:(e.y1||0)-s,x2:o,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const o=(e.y||0)-s;r.push((0,kr.jsx)("line",{x1:(e.x1||0)-t,y1:o,x2:(e.x2||0)-t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?r.push((0,kr.jsx)("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||r.push((0,kr.jsx)("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",o=e?.width??e?.height;void 0!==o&&r.push((0,kr.jsx)("path",{d:Ar(t,o,e?.depth||30,void 0===e?.width),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,kr.jsx)("g",{className:"annotation-subject",children:r})}function Pr(t,e,i,o,n,r){const s=[];let a=0,c=0;if("callout-circle"!==n&&"label"!==n||!r?.radius){if("callout-rect"===n&&r){const i=r.width||0,o=r.height||0;if(i>0||o>0){const n=i/2,r=o/2,s=t-n,l=e-r;if(0!==s||0!==l){const t=Math.abs(s),e=Math.abs(l),u=i/2,h=o/2,d=t*h>e*u?u/t:h/e;a=n+s*d,c=r+l*d}}}else if("bracket"===n&&r){const t=r.width,e=r.height,i=r.depth||30;void 0!==t?(a=t/2,c=i):void 0!==e&&(a=i,c=e/2)}}else{const i=(r.radius||0)+(r.radiusPadding||0);if(i>0&&(0!==t||0!==e)){const o=Math.atan2(e,t);a=Math.cos(o)*i,c=Math.sin(o)*i}}const l=Math.sqrt((t-a)**2+(e-c)**2);if(l>.5){const n=o||"var(--semiotic-text-secondary, currentColor)",r="curve"===i?.type;let u=Math.atan2(e-c,t-a);if(r){const o=(a+t)/2,r=(c+e)/2,h=-(e-c)/l,d=(t-a)/l,f=(i?.curve??.25)*l,p=o+h*f,y=r+d*f;s.push((0,kr.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${t},${e}`,fill:"none",stroke:n},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,kr.jsx)("line",{x1:a,y1:c,x2:t,y2:e,stroke:n},"connector-line"));if("arrow"===i?.end){const t=10,e=16/180*Math.PI;s.push((0,kr.jsx)("path",{d:`M${a},${c}L${a+t*Math.cos(u+e)},${c+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${c+t*Math.sin(u-e)}Z`,fill:n,stroke:"none"},"connector-arrow"))}}return(0,kr.jsx)("g",{className:"annotation-connector",children:s})}function Tr(t){const{x:e=0,y:i=0,dx:o,dy:n,nx:r,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(i)?i[0]??0:i,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=n||0;null!=r&&(w=r-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const t=l.depth||30;k=t+(0>t?-5:5)}else if(void 0!==l.height){const t=l.depth||30;w=t+(0>t?-5:5),k=l.height/2}return(0,kr.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&Pr(w,k,c,h,S,l),!v.has("subject")&&_r(S,l,h,x,b),!v.has("note")&&Mr(a,w,k,h)]})}function Rr(t){const{noteData:e}=t,{screenCoordinates:i}=e,o="string"==typeof e.type?e.type:"label",n=e.eventListeners||e.events||{};if(e.coordinates&&i){const t=e.nx||i[0][0]+(e.dx??0),n=e.ny||i[0][1]+(e.dy??0),r=i.map((i,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:i[0],y:i[1],nx:t,ny:n});return(0,kr.jsx)(Tr,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+r)});return(0,kr.jsx)("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return(0,kr.jsx)(Tr,{"data-testid":"semiotic-annotation",events:n,...e,type:o},s)}var Lr=require("react/jsx-runtime"),Cr={secondary:0,primary:3},$r=1,jr=2,zr=.6,Er="0.88em",Dr=.95,Nr=.72,Fr=.06,Ir=".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}}",Or=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Br(t){return!0===t?._annotationDeferred}function Wr(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function Yr(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function qr(t){return Math.max(Nr,Dr-t*Fr)}function Xr(t,e){const i=e.scales?.x??e.scales?.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function Gr(t,e){const i=e.scales?.y??e.scales?.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function Vr(t){return null==t?null:t+""}function Hr(t,e,i){return e.stickyPositionCache?.set(t,i),i}var Zr=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Kr(t){return!!t&&"object"==typeof t&&Zr.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}new Set(["label","callout","callout-circle","callout-rect"]);var Ur=2e4,Qr=1;function Jr(t){return"primary"===t?.emphasis||!0===t?.defensive}function ts(t,e,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:Ur))):1/0}function es(t){let e;const i=t?.emphasis;e="primary"===i?100:"secondary"===i?10:50;const o=t?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(e+=15*Math.max(0,Math.min(1,o))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}var is=32,os=6,ns=4,rs=8,ss=72,as=30,cs=-30,ls=8,us=480,hs=3;var ds={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function fs(t){if(!ps(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 ps(t){return Kr(t)}function ys(t,e){if(!t)return[];const i=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),n=[];let r="";for(const t of o)r&&r.length+t.length+1>i?(n.push(r),r=t):r=r?`${r} ${t}`:t;return r&&n.push(r),n}function gs(t,e,i,o,n){const r=t+i,s=e+o;return Math.abs(i)>Math.abs(o)?{x:0>i?r-n.width-4:r+4,y:0>o?s-n.height:s,width:n.width,height:n.height}:{x:0>i?r-n.width:r,y:0>o?s-n.height-4:s+4,width:n.width,height:n.height}}function ms(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function xs(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 bs(t,e,i,o,n,r,s,a){const c=ms(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,i,o){const n=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(n+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(i-o)))*t.width}(c,n,r,a);for(const t of i)l+=12*xs(c,t);for(const t of o)l+=4*xs(c,t);return l}function vs(t,e,i){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const o=t.pointId??t.nodeId;if(null!=o&&i.pointNodes){const t=i.pointNodes.find(t=>t.pointId===o);if(t)return{x:t.x,y:t.y}}const n=t.coordinates,r=i.scales?.geoProjection;if(Array.isArray(n)&&n.length>=2&&r){const t=n[0],e=n[1];if("number"==typeof t&&"number"==typeof e){const i=r([t,e]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof t.x||"number"!=typeof t.y?function(t,e,i){const o=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=t.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let o=i.pointNodes.length-1;o>=0;o--){const n=i.pointNodes[o];if(n.pointId===t.pointId)return Hr(e,i,{x:n.x,y:n.y})}const o=function(t){const e=t.data;if(!e||0===e.length)return null;const i=e[e.length-1],o=t.scales?.x??t.scales?.time,n=t.scales?.y??t.scales?.value;if(!o||!n)return null;const r=i[t.xAccessor||"x"],s=i[t.yAccessor||"y"];return null==r||null==s?null:{x:o(r),y:n(s)}}(i);return o?Hr(e,i,o):null}if("semantic"===o){const o=function(t,e,i){const o=function(t){return Vr(t.provenance?.stableId??t.stableId)}(t);if(!o)return null;const n=i.pointNodes?.find(t=>Vr(t.pointId)===o);if(n)return Hr(e,i,{x:n.x,y:n.y});const r=i.data?.find(t=>function(t){return Vr(t.stableId??t.id??t.provenance?.stableId)}(t)===o);if(!r)return null;const s=Xr(r,i),a=Gr(r,i);return null==s||null==a?null:Hr(e,i,{x:s,y:a})}(t,e,i);if(o)return o}let n=null,r=null;if(null!=t.pointId&&i.pointNodes){const e=i.pointNodes.find(e=>e.pointId===t.pointId);e&&(n=e.x,r=e.y)}if(null!=n&&null!=r||(n=Xr(t,i),r=Gr(t,i)),null!=n&&null!=r)return Hr(e,i,{x:n,y:r});if("sticky"===o){const t=i.stickyPositionCache?.get(e);if(t)return t}return null}(t,e,i):{x:t.x,y:t.y}}function ws(t){const{annotations:e,context:i,defaultOffset:o=is,notePadding:n=os,markPadding:r=ns,edgePadding:s=rs,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ss,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=i.width||0,x=i.height||0,b="object"==typeof p?p:{},v=b.breakpoint??us,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(fs):e,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=h||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const P=[],T=function(t,e){return(t.pointNodes||[]).map(t=>{const i=Math.max(1,t.r||1)+e;return{x:t.x-i,y:t.y-i,width:2*i,height:2*i}})}(i,r);let R=!1;const L=k.map((t,e)=>{if(!ps(t))return t;const r=vs(t,e,i);if(!r)return t;const u=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,i=[...ys("string"==typeof t.title?t.title:void 0,e),...ys("string"==typeof t.label?t.label:void 0,e)],o=i.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*i.length+6)}}(t);if(a&&("number"==typeof(h=t).dx||"number"==typeof h.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:as,dy:cs}}(t);return P.push(ms(gs(r.x,r.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),n)),t}var h;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(o)){const e=bs(gs(r.x,r.y,t.dx,t.dy,u),t,P,T,m,x,n,s);f>e&&(d=t,f=e)}if(!d)return t;const p=ms(gs(r.x,r.y,d.dx,d.dy,u),n);P.push(p);const y=Math.hypot(d.dx,d.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return R=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),C=R?L:k.slice();let $=C;if(d){let t=!1;const e=C.map(e=>{const i=function(t){return"text"!==t.type||"string"!=typeof t.color||Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)<ls?t:{...t,_redundantConnector:!0}}(e);return i!==e&&(t=!0),i});$=t?e:C}{let t=!1;const e=$.map(e=>{if(!0!==e?.defensive)return e;const i=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const i="string"==typeof e.source?ds[e.source]??e.source:null,o="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!i&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const n=[i,o].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${n})`)?t:{...t,label:r?`${r} (${n})`:`(${n})`}}(e);return i!==e&&(t=!0),i});$=t?e:$}const j=new Set;if(S){const t="object"==typeof S?S:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return hs;const i=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===i.length?hs:i.reduce((t,e)=>t+e,0)/i.length}(t);return e>2?4>e?1:.6:1.5}(g),i=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??ts(m,x,t))*e))},{deferred:o}=function(t){const{annotations:e,width:i,height:o}=t,n=Math.max(0,t.minVisible??Qr),r=ts(i,o,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(i=t,Kr(i))};var i}),a=s.filter(t=>t.note);if(0===a.length||r>=a.length)return{visible:e.slice(),deferred:[],budget:r};const c=a.filter(t=>Jr(t.annotation)),l=a.filter(t=>!Jr(t.annotation)).sort((t,e)=>es(e.annotation)-es(t.annotation)||t.index-e.index),u=Math.min(l.length,Math.max(Math.max(0,r-c.length),Math.max(0,n-c.length))),h=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),d=[],f=[];for(const{annotation:t,index:e,note:i}of s)!i||h.has(e)?d.push(t):f.push(t);return{visible:d,deferred:f,budget:r}}({annotations:$,width:m,height:x,...i});for(const t of o)j.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:us)>=m)for(const t of $)ps(t)&&"secondary"===t.emphasis&&j.add(t);if(j.size>0)for(const t of $)!0===t?.defensive&&j.delete(t);let z;return z=0===j.size?$:A?$.map(t=>j.has(t)?{...t,_annotationDeferred:!0}:t):$.filter(t=>!j.has(t)),_?function(t,e){let i=!1;const o=t.map(t=>ps(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(i=!0,{...t,cohesion:e}):t);return i?o:t}(z,_):z}var ks=require("react/jsx-runtime"),Ss="var(--semiotic-bg, #ffffff)",As=.85;function Ms(t){const{x:e,y:i,text:o,fill:n,fontSize:r=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=t,d=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(u),f=t=>(0,ks.jsx)("text",{x:e,y:i,textAnchor:c,dominantBaseline:l,fill:n,fontSize:r,fontWeight:s,fontFamily:a,className:h,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??Ss,strokeWidth:d.haloWidth??3});const p=d.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(t,e){return(t+"").length*e*.6}(o,r),x=r+2*g;let b,v;return b="middle"===c?e-m/2-y:"end"===c?e-m-y:e-y,v="middle"===l||"central"===l?i-x/2:"hanging"===l||"text-before-edge"===l?i-g:i-.8*r-g,(0,ks.jsxs)("g",{className:h,children:[(0,ks.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??Ss,fillOpacity:d.opacity??As,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}var _s=require("react/jsx-runtime"),Ps=16,Ts=20;function Rs(t,e){return t.color||e.colors.annotation||e.colors.text}function Ls(t,e,i){const o=t.labelBackground,n=e.colors.background;return void 0===o?"none"===i?"none":{type:"halo",fill:n}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:n}:"box"===o?{type:"box",fill:n}:{fill:n,...o}}function Cs(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):"number"==typeof t.x?t.x:null}function $s(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):"number"==typeof t.y?t.y:null}function js(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=t.autoPlaceAnnotations?ws({annotations:e,context:{scales:{x:t.scales.x,y:t.scales.y,time:t.scales.x,value:t.scales.y,o:t.scales.o,geoProjection:t.scales.geoProjection},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,frameType:t.projection?"ordinal":"xy",projection:"horizontal"===t.projection?"horizontal":"vertical"},..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):e,o=[];for(let e=0;i.length>e;e++){const n=zs(i[e],e,t);n&&o.push({node:n,annotation:i[e]})}const n=function(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(i=t.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:Yr(t.annotation),readingOrder:null,rank:$r};var i}),i=e.some(t=>null!=t.emphasis||null!=t.confidence),o=t.some(t=>Br(t.annotation)),n=t.some(t=>null!=Wr(t.annotation)),r=t.some(t=>"layer"===Wr(t.annotation));if(!i&&!o&&!n)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=jr-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Cr[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:i,emphasis:o,readingOrder:n}=t,r=Br(e.annotation);let s=e.node;if("primary"===o||"secondary"===o||null!=n){const t=null==o&&null!=n;s=(0,Lr.jsx)("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:zr,fontSize:Er}:{},...t?{opacity:qr(n),"data-annotation-reading-order":n}:{},children:e.node},"annotation-emphasis-"+i)}const a=Wr(e.annotation);return a&&(s=(0,Lr.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+i)),r&&(s=(0,Lr.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+i)),s});return o&&a.unshift((0,Lr.jsx)("style",{children:Ir},"annotation-disclosure-style")),r&&a.unshift((0,Lr.jsx)("style",{children:Or},"annotation-cohesion-style")),a}(o);return n.length>0?(0,_s.jsx)("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:n}):null}function zs(t,e,i){const{scales:o,layout:n,theme:r,xAccessor:s,yAccessor:a}=i;switch(t.type){case"y-threshold":{const s=t.value;if(null==s)return null;const a=Rs(t,r),c=t.label,l=t.labelPosition||"right",u=t.strokeDasharray||"6,4",h=t.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){const i=o.r(s);return null==i?null:(0,_s.jsxs)("g",{opacity:t.opacity,children:[(0,_s.jsx)("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&(0,_s.jsx)(Ms,{x:i+4,y:Ps,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ls(t,r,"halo")})]},"ann-ythresh-"+e)}const d=o.y?o.y(s):o.r?o.r(s):null;return null==d?null:(0,_s.jsxs)("g",{children:[(0,_s.jsx)("line",{x1:0,y1:d,x2:n.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&(0,_s.jsx)(Ms,{x:"left"===l?4:"center"===l?n.width/2:n.width-4,y:Ts>d?Math.min(n.height-4,d+Ps):d-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ls(t,r,"halo")})]},"ann-ythresh-"+e)}case"x-threshold":{const i=t.value;if(null==i||!o.x)return null;const s=o.x(i);if(null==s)return null;const a=Rs(t,r),c=t.label,l=t.labelPosition||"top";return(0,_s.jsxs)("g",{opacity:t.opacity,children:[(0,_s.jsx)("line",{x1:s,y1:0,x2:s,y2:n.height,stroke:a,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),c&&(0,_s.jsx)(Ms,{x:s>.6*n.width?s-4:s+4,y:"bottom"===l?n.height-4:"center"===l?n.height/2:Ps,textAnchor:s>.6*n.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ls(t,r,"halo")})]},"ann-xthresh-"+e)}case"band":{const i=null!=t.y0&&o.y?o.y(t.y0):null,s=null!=t.y1&&o.y?o.y(t.y1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=Gn(t.fill||Rs(t,r),"ssr-band-"+e),u=t.fillOpacity??.1;return(0,_s.jsxs)("g",{opacity:t.opacity,children:[l.def&&(0,_s.jsx)("defs",{children:l.def}),(0,_s.jsx)("rect",{x:0,y:a,width:n.width,height:c,fill:l.fill,fillOpacity:u}),t.label&&(0,_s.jsx)(Ms,{x:n.width-4,y:Math.max(a,0)+Ps,textAnchor:"end",fontSize:r.typography.tickSize,fill:t.color||Rs(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Ls(t,r,"halo")})]},"ann-band-"+e)}case"x-band":{const i=null!=t.x0&&o.x?o.x(t.x0):null,s=null!=t.x1&&o.x?o.x(t.x1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=Gn(t.fill||Rs(t,r),"ssr-xband-"+e),u=t.fillOpacity??.1;return(0,_s.jsxs)("g",{opacity:t.opacity,children:[l.def&&(0,_s.jsx)("defs",{children:l.def}),(0,_s.jsx)("rect",{x:a,y:0,width:c,height:n.height,fill:l.fill,fillOpacity:u}),t.label&&(0,_s.jsx)(Ms,{x:a+4,y:Ps,textAnchor:"start",fontSize:r.typography.tickSize,fill:t.color||Rs(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Ls(t,r,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!o.o)return null;const s=o.o(t.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,c=Rs(t,r),l=t.opacity??.1,u=t.label;return(0,_s.jsxs)("g","horizontal"===i.projection?{children:[(0,_s.jsx)("rect",{x:0,y:s,width:n.width,height:a,fill:c,opacity:l}),u&&(0,_s.jsx)(Ms,{x:12,y:s+a/2,dominantBaseline:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Ls(t,r,"none")})]}:{children:[(0,_s.jsx)("rect",{x:s,y:0,width:a,height:n.height,fill:c,opacity:l}),u&&(0,_s.jsx)(Ms,{x:s+a/2,y:Ps,textAnchor:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Ls(t,r,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:i,y:n}=function(t,e,i,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const i=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:Cs(t,e,i),y:$s(t,e,o)}}(t,o,s,a);if(null==i||null==n)return null;const c="text"===t.type,l=t.dx??(c?0:30),u=t.dy??(c?0:-30),h=t.color||r.colors.text;if(!c){const o="callout"===t.type?"callout-circle":t.type,r="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return(0,_s.jsx)(Rr,{noteData:{x:i,y:n,dx:l,dy:u,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:o,...r?{subject:r}:{},connector:t.connector||{end:"arrow"},color:h,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return(0,_s.jsx)("g",{children:(0,_s.jsx)("text",{x:i+l,y:n+u,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||r.typography.labelSize,fill:h,fontFamily:r.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}var Es=36,Ds=34,Ns=58,Fs=22;function Is(t){return"string"==typeof t&&t.length>0}function Os(t,e){return function(t,e,i=!1){const o=i?e?Ns:Ds:e?Es:0;return o>t.top?{...t,top:o}:t}(t,Is(e))}function Bs(t,e,i){return"exact"===i?function(t,e){const i=t.domain(),o=i[0],n=i[i.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,a=n instanceof Date?n.getTime():n;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(e-1),l=Array(e);for(let t=0;e>t;t++){const i=t===e-1?a:s+t*c;l[t]=r?new Date(i):i}return l}(t,e):t.ticks(e)}var Ws=require("react/jsx-runtime");function Ys(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function qs(t,e){if(0===e.categories.length)return;const i=e.position||"right",o=function(t){const{width:e,height:i,swatchSize:o}=mr(t);return{width:e,height:i,swatchSize:o}}({categories:e.categories,colorScheme:e.colorScheme,theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout});"right"===i?t.right=Math.max(t.right,o.width+14):"left"===i?t.left=Math.max(t.left,o.width+14):"top"===i?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4)}function Xs(t,e){const i=e.position||"right",o={theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},n=ao(e.legend)?function(t){const{width:e,height:i,swatchSize:o}=xr(t);return{width:e,height:i,swatchSize:o}}({...o,legendGroups:e.legend.legendGroups}):co(e.legend)?br({...o,gradient:e.legend.gradient}):null;n&&("right"===i?t.right=Math.max(t.right,n.width+14):"left"===i?t.left=Math.max(t.left,n.width+14):"top"===i?t.top=Math.max(t.top,(e.hasTitle?32:8)+n.height+4):t.bottom=Math.max(t.bottom,38+n.height+4))}function Gs(t,e){const i={theme:e.theme,position:e.position||"right",totalWidth:e.size[0],totalHeight:e.size[1],margin:e.margin,hasTitle:e.hasTitle,legendLayout:e.legendLayout,idPrefix:e.idPrefix};return ao(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,i)=>({group:t,item:e,itemIndex:i,label:e.label})))).length)return null;var e;const i=xr(t),o="top"===t.position||"bottom"===t.position,n=t.theme.colors.grid||t.theme.colors.textSecondary;let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-i.width-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=Math.min(t.totalHeight-t.margin.bottom+38,t.totalHeight-i.height-2)):(r=Math.min(t.totalWidth-i.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=i.groups.flatMap((e,r)=>{const{group:s}=e,a=s.type??"fill",c=[];if(s.label&&c.push((0,lr.jsx)("text",o?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:yr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label}:{x:e.x,y:e.y+yr(t.theme),fontSize:yr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label},"legend-group-label-"+r)),c.push(...e.items.map((o,n)=>{const c=s.items[n],l=s.styleFn(c,n),u="function"==typeof a?a(c):"line"===a?(0,lr.jsx)("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:l}):(0,lr.jsx)("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:l});return(0,lr.jsxs)("g",{transform:`translate(${e.x+e.itemOffsetX+o.x},${e.y+e.itemOffsetY+o.y})`,children:[u,(0,lr.jsx)("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:yr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.category})]},`legend-${r}-${n}`)})),!o&&i.groups.length-1>r)c.push((0,lr.jsx)("line",{x1:0,y1:e.y+e.height-6,x2:i.width,y2:e.y+e.height-6,stroke:n},"legend-group-separator-"+r));else if(o&&i.groups.length-1>r){const t=e.x+e.width+6;c.push((0,lr.jsx)("line",{x1:t,y1:0,x2:t,y2:i.height,stroke:n},"legend-group-separator-"+r))}return c});return(0,lr.jsx)("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,"data-orientation":o?"horizontal":"vertical",children:a})}({...i,legendGroups:t.legendGroups}):co(t)?function(t){const e=br(t),i="top"===t.position||"bottom"===t.position,o=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",n=t.gradient.format||(t=>Math.round(100*t)/100+"");let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-e.width-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=Math.min(t.totalHeight-t.margin.bottom+38,t.totalHeight-e.height-2)):(r=Math.min(t.totalWidth-e.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=Array.from({length:17},(e,o)=>{const n=o/16;return(0,lr.jsx)("stop",{offset:100*n+"%",stopColor:t.gradient.colorFn(i?t.gradient.domain[0]+n*(t.gradient.domain[1]-t.gradient.domain[0]):t.gradient.domain[1]-n*(t.gradient.domain[1]-t.gradient.domain[0]))},o)});if(i){const i=12,c=t.gradient.label?0:void 0,l=t.gradient.label?8:0;return(0,lr.jsxs)("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,children:[(0,lr.jsx)("defs",{children:(0,lr.jsx)("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),t.gradient.label&&(0,lr.jsx)("text",{x:e.width/2,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),(0,lr.jsx)("rect",{x:0,y:l,width:e.width,height:i,fill:`url(#${o})`,rx:2}),(0,lr.jsx)("text",{x:0,y:l+i+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[0])}),(0,lr.jsx)("text",{x:e.width,y:l+i+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[1])})]})}const c=t.gradient.label?-6:void 0;return(0,lr.jsxs)("g",{className:"semiotic-legend",transform:`translate(${r},${s+(t.gradient.label?12:0)})`,children:[(0,lr.jsx)("defs",{children:(0,lr.jsx)("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),t.gradient.label&&(0,lr.jsx)("text",{x:7,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),(0,lr.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${o})`,rx:2}),(0,lr.jsx)("text",{x:19,y:10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[1])}),(0,lr.jsx)("text",{x:19,y:100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[0])})]})}({...i,gradient:t.gradient}):null}function Vs(t){return Math.round(100*t)/100+""}function Hs(t,e){const i=oo(e.theme),o=e.idPrefix?e.idPrefix+"-":"",n="string"==typeof e.title?e.title:void 0,r=n?o+"semiotic-title":void 0,s=e.description?o+"semiotic-desc":void 0,a=[r,s].filter(Boolean).join(" ")||void 0;return(0,Ws.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":a,style:{fontFamily:i.fontFamily},children:[n&&(0,Ws.jsx)("title",{id:r,children:n}),e.description&&(0,Ws.jsx)("desc",{id:s,children:e.description}),e.defs&&(0,Ws.jsx)("defs",{children:e.defs}),e.background&&"transparent"!==e.background&&(0,Ws.jsx)("rect",{x:0,y:0,width:e.width,height:e.height,fill:e.background}),(0,Ws.jsx)("g",{id:o+"data-area",transform:e.innerTransform,children:t}),n&&(0,Ws.jsx)("text",{id:o+"chart-title",x:e.width/2,y:Fs,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:n}),e.legend&&(0,Ws.jsx)("g",{id:o+"legend",children:e.legend}),e.outerElements]})}var Zs=require("react/jsx-runtime");function Ks(t,e){const i=io(t.theme),o=t.size||[500,300],n=Os({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Is(t.title),s=uo(t.data),a=t.showLegend?wr(s,t.colorAccessor||t.groupAccessor):[],c=t.legendPosition;ao(t.legend)||co(t.legend)?Xs(n,{legend:t.legend,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&a.length>0&&qs(n,{categories:a,colorScheme:t.colorScheme,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const l=o[0]-n.left-n.right,u=o[1]-n.top-n.bottom,h="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),d=t.colorScheme||i.colors.categorical,f={chartType:t.chartType,windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:h?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:h?void 0:t.xAccessor,yAccessor:h?void 0:t.yAccessor,timeAccessor:h?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,axisExtent:t.axisExtent,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:!0===t.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===t.gradientFill?void 0:t.gradientFill,lineGradient:t.lineGradient,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,barStyle:t.barStyle,waterfallStyle:t.waterfallStyle,swarmStyle:t.swarmStyle,colorScheme:d,themeCategorical:i.colors.categorical,themeSemantic:Ft(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},p=new On(f);if(t.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return e&&(e.evidence=so({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),fo.renderToStaticMarkup(Hs(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));e&&(e.evidence=so({frameType:"xy",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,xDomain:ro(p.scales.x?.domain?.()),yDomain:ro(p.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const y=t._idPrefix,g=t.showGrid?function(t,e,i,o,n){const{grid:r}=oo(i),s=o?o+"-":"",a=Bs(t.x,5,n),c=Bs(t.y,5,n);return(0,Ws.jsxs)("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((i,o)=>{const n=t.x(i);return(0,Ws.jsx)("line",{x1:n,y1:0,x2:n,y2:e.height,stroke:r,strokeWidth:.5},"gx-"+o)}),c.map((i,o)=>{const n=t.y(i);return(0,Ws.jsx)("line",{x1:0,y1:n,x2:e.width,y2:n,stroke:r,strokeWidth:.5},"gy-"+o)})]})}(p.scales,{width:l,height:u},i,y,t.axisExtent):null,m=p.scene.map((e,i)=>ar({node:e,index:i,renderMode:t.renderMode,fallback:()=>nr(e,i,y)})).filter(Boolean),x=!1!==t.showAxes?function(t,e,i,o,n){const r=oo(o),s=Bs(t.x,5,i.axisExtent).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||Vs)(e)})),a=Bs(t.y,5,i.axisExtent).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||Vs)(e)}));return(0,Ws.jsxs)("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[(0,Ws.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:r.border,strokeWidth:1}),s.map((t,i)=>(0,Ws.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,Ws.jsx)("line",{y2:5,stroke:r.border,strokeWidth:1}),(0,Ws.jsx)("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"xtick-"+i)),i.xLabel&&(0,Ws.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:i.xLabel}),(0,Ws.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:r.border,strokeWidth:1}),a.map((t,e)=>(0,Ws.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Ws.jsx)("line",{x2:-5,stroke:r.border,strokeWidth:1}),(0,Ws.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"ytick-"+e)),i.yLabel&&(0,Ws.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:i.yLabel})]})}(p.scales,{width:l,height:u},t,i,y):null,b=t.annotations?js({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:p.scales.x,y:p.scales.y},layout:{width:l,height:u},theme:i,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:y}):null,v=t.svgPreRenderers&&p.scales?t.svgPreRenderers.map((t,e)=>{try{return(0,Zs.jsx)(ho.Fragment,{children:t(p.scene,p.scales,{width:l,height:u})},"pre-"+e)}catch{return null}}).filter(Boolean):null,w=t.showLegend?0===a.length?null:vr({categories:a,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,k=ho.isValidElement(t.legend)?t.legend:Gs(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||w;return fo.renderToStaticMarkup(Hs((0,Zs.jsxs)(Zs.Fragment,{children:[t.backgroundGraphics,v,g,m,x,b,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,legend:k,idPrefix:t._idPrefix}))}var Us=c(require("react")),Qs=c(require("react-dom/server")),Js=require("d3-scale"),ta=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,i){if(e&&"function"==typeof t.pieceStyle){const o=t.pieceStyle(e,i);return o&&!o.fill&&i?{...o,fill:this.getColorFromScheme(t,i)}:o}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&i?{fill:t.barColors[i]||"#007bff"}:{fill:i?this.getColorFromScheme(t,i):"#007bff"}}resolveSummaryStyle(t,e,i){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,i):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const i=this.colorSchemeMap.get(e);if(i)return i;const o=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||j,n=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,n),n}};function ea(t){const e=t.getSymbol;if(!e)return null;const i=t.config.symbolMap,o=new Map;let n=0;return t=>{const r=e(t)+"",s=i?.[r];if(s)return s;let a=o.get(r);return a||(a=Qo[n%Qo.length],n++,o.set(r,a)),a}}function ia(t,e,i,o,n,r,s){t.push(e?{type:"symbol",x:o,y:n,size:Math.PI*r*r,symbolType:e(i),style:s,datum:i}:{type:"point",x:o,y:n,r:r,style:s,datum:i})}function oa(t,e){const{columns:i,config:o,resolvePieceStyle:n}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,h=Object.values(i),d=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!d&&h.length>1&&(o.cornerRadius??0)>0;for(let t=0;h.length>t;t++){const e=h[t],i=e.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:e.pctStart,d=c+u*l,p=c+(u+("number"==typeof i?._pct?i._pct:e.pct))*l,y=n(e.pieceData[0],e.name),g=0===t,m=t===h.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:d,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:i?._nonInteractive?null:e.pieceData,category:e.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),r.push(x)}return r}var na=require("d3-array");function ra(t){const e=t.length,i=t[0],o=t[e-1];return{n:e,min:i,q1:(0,na.quantile)(t,.25)??i,median:(0,na.quantile)(t,.5)??(i+o)/2,q3:(0,na.quantile)(t,.75)??o,max:o,mean:t.reduce((t,e)=>t+e,0)/e}}var sa=require("d3-scale"),aa={bar:function(t,e){const{scales:i,columns:o,config:n,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d="horizontal"===l,f=n.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(o))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(o)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=r(i),o.pieces.push(i)}let i=0;if(f)for(const t of e.values())i+=Math.abs(t.total);let o=0,n=0;for(const r of p){const l=e.get(r);if(!l)continue;let p=l.total;f&&i>0&&(p/=i);const y=a(l.pieces[0],s?r:t.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name};if(h){const e=c(0>p?n:o+p),i=0>p?c(n+p)-c(n):c(o)-c(o+p);u.push(Io(t.x,e,t.width,Math.abs(i),y,g,r)),0>p?n+=p:o+=p}else if(d){const e=c(0>p?n+p:o),i=0>p?c(n)-c(n+p):c(o+p)-c(o);u.push(Io(e,t.x,Math.abs(i),t.width,y,g,r)),0>p?n+=p:o+=p}}}const y="vertical"===l,g=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;const e=t.datum?.__aggregateValue??0;t.roundedEdge=y?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}if(g>0){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const i=e.datum?.category||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),i=e.filter(t=>0>(t.datum?.__aggregateValue??0));t.length>0&&(t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=g),i.length>0&&(i.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=g)}}return u},clusterbar:function(t,e){const{scales:i,columns:o,config:n,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const p=d.length||1;for(const t of Object.values(o)){const e=t.width/p,i=.2*e,o=e-i,n=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";n.has(t)||n.set(t,[]),n.get(t).push(e)}for(let s=0;d.length>s;s++){const l=n.get(d[s])||[];for(const n of l){const l=r(n),f=a(n,d[s]);if(h){const r=t.x+s*e+i/2,a=c(0),h=c(l);u.push(Io(r,Math.min(a,h),o,Math.abs(a-h),f,n,d[s]))}else{const r=t.x+s*e+i/2,a=c(0),h=c(l);u.push(Io(Math.min(a,h),r,Math.abs(h-a),o,f,n,d[s]))}}}}const y=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}return u},point:function(t,e){const{scales:i,columns:o,getR:n,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h="radial"===c,d=r.length>0,f=ea(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const i=e.__rIndex??0,o=e.__rValue??n(e),c=d&&r[i]||a,g=s(e,t.name),m=g.r||5;let x,b;if(h){const e=y+(t.pctStart+t.pct/2)*p,i=c(o);x=Math.cos(e)*i,b=Math.sin(e)*i}else u?(x=t.middle,b=c(o)):(x=c(o),b=t.middle);ia(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:i,columns:o,getR:n,resolvePieceStyle:r}=t,{r:s,projection:a}=i,c=[],l="vertical"===a,u=ea(t);for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=n(o),h=r(o,t.name),d=h.r||4,f=(7919*i%100/100-.5)*e*.8;ia(c,u,o,l?t.middle+f:s(a),l?s(a):t.middle+f,d,h)}}return c},pie:oa,donut:oa,boxplot:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=!1!==n.showOutliers;for(const e of Object.values(o)){const i=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===i.length)continue;const o=i[0],n=i[i.length-1],c=(0,na.quantile)(i,.25)??o,d=(0,na.quantile)(i,.5)??(o+n)/2,f=(0,na.quantile)(i,.75)??n,p=f-c,y=c-1.5*p,g=f+1.5*p,m=i.find(t=>t>=y)??o,x=[...i].reverse().find(t=>g>=t)??n,b=s(e.pieceData[0],e.name),v=[];if(h)for(const t of e.pieceData){const i=r(t);if(y>i||i>g){const o=u?e.middle:a(i),n=u?a(i):e.middle;v.push({px:o,py:n,value:i,datum:t})}}if(l.push({type:"boxplot",x:u?e.middle:0,y:u?0:e.middle,projection:u?"vertical":"horizontal",columnWidth:.6*e.width,minPos:a(m),q1Pos:a(c),medianPos:a(d),q3Pos:a(f),maxPos:a(x),stats:{n:i.length,min:m,q1:c,median:d,q3:f,max:x,mean:i.reduce((t,e)=>t+e,0)/i.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),h)for(const e of v)l.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:b.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6},datum:e.datum})}return l},violin:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=n.bins||20,d=!1!==n.showIQR;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/h||1,c=Array(h).fill(0);for(const t of e)c[Math.min(Math.floor((t-i)/n),h-1)]++;const f=xt(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(i)}`;for(let e=0;h>e;e++){const o=a(i+(e+.5)*n);y+=` L ${t.middle+c[e]/f*p} ${o}`}y+=` L ${t.middle} ${a(o)}`;for(let e=h-1;e>=0;e--){const o=a(i+(e+.5)*n);y+=` L ${t.middle-c[e]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(i)} ${t.middle}`;for(let e=0;h>e;e++)y+=` L ${a(i+(e+.5)*n)} ${t.middle-c[e]/f*p}`;y+=` L ${a(o)} ${t.middle}`;for(let e=h-1;e>=0;e--)y+=` L ${a(i+(e+.5)*n)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(d&&e.length>=4){const n=(0,na.quantile)(e,.25)??i,r=(0,na.quantile)(e,.5)??(i+o)/2,s=(0,na.quantile)(e,.75)??o;m={q1Pos:a(n),medianPos:a(r),q3Pos:a(s),centerPos:t.middle,isVertical:u}}const x=u?{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))}:{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:ra(e),style:g,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a}=i,c=[],l=n.bins||25,u=n.normalize,h=a.domain?.(),d=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[i,o]=mt(e),n=null!=d&&isFinite(d)?d:i,h=null!=f&&isFinite(f)?f:o,p=(h-n)/l||1,y=Array(l).fill(0);for(const t of e)n>t||t>h||y[Math.min(Math.floor((t-n)/p),l-1)]++;const g=e.length,m=xt(y,1),x=s(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===y[e])continue;const i=(u?y[e]/g:y[e]/m)*t.width*.9,o=a(n+e*p),r=a(n+(e+1)*p);c.push(Io(Math.min(o,r),t.x+t.width-i,Math.abs(r-o),i,x,{bin:e,count:y[e],range:[n+e*p,n+(e+1)*p],category:t.name},t.name))}}return c},ridgeline:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u=n.bins||20,h="horizontal"===c,d=n.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/u||1,c=Array(u).fill(0);for(const t of e)i>t||t>o||c[Math.min(Math.floor((t-i)/n),u-1)]++;const f=xt(c,1),p=s(t.pieceData[0],t.name),y=t.width*d;let g;if(h){const e=t.x+t.width;g=`M ${a(i)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(i+(t+.5)*n)} ${e-c[t]/f*y}`;g+=` L ${a(o)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(i)}`;for(let t=0;u>t;t++){const o=a(i+(t+.5)*n);g+=` L ${e+c[t]/f*y} ${o}`}g+=` L ${e} ${a(o)} Z`}const m=h?{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width}:{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:ra(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:i,columns:o,getRawRange:n,resolvePieceStyle:r}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=n(e);if(!i)continue;const[o,a]=i,u=r(e,t.name);if(l){const i=s(Math.min(o,a)),n=s(Math.max(o,a));c.push(Io(i,t.x,n-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),n=s(Math.min(o,a));c.push(Io(t.x,i,t.width,n-i,u,e,t.name))}}return c},funnel:function(t,e){const{columns:i,getR:o,getStack:n,resolvePieceStyle:r}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>i[t]).filter(Boolean);if(0===l.length)return s;const u=[],h=new Set;for(const t of l)for(const e of t.pieceData){const t=n?n(e):"_default";h.has(t)||(h.add(t),u.push(t))}const d=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let i=0;for(const r of t.pieceData){const t=n?n(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),i+=a}f.push({col:t,groups:e,stepTotal:i}),d||i>p&&(p=i)}if(d)for(const t of f){let e=0,i=0;for(let o=0;u.length>o;o++){const n=t.groups.get(u[o]);n&&(o%2==0?e+=n.total:i+=n.total)}const o=Math.max(e,i);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=d?.95*a:.9*e.width,x=(0,sa.scaleLinear)().domain([0,p]).range([0,m]),b=t.config.connectorOpacity??.3;let v=new Map;for(let e=0;f.length>e;e++){const i=f[e],o=i.col,n=0===e,l=o.width,h=.55*l,p=o.x+(l-h)/2,m=new Map;if(d){let t=0;for(const e of u){const o=i.groups.get(e);o&&(t+=x(o.total))}let e=a,l=a;for(let d=0;u.length>d;d++){const f=u[d],g=i.groups.get(f);if(!g)continue;const b=x(g.total),v=d%2==0,w=v?e:l-b;v?e+=b:l-=b;const k=r(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:n,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===d&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Io(w,p,b,h,k,A,f)),m.set(f,{x:w,y:p,w:b,h:h})}}else{const t=i.stepTotal,e=x(t),l=a-e/2,d=u[0],f="_default"!==d,y=i.groups.get(d)?.pieces[0]??o.pieceData[0],b=f?d:o.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:n,category:f?d:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(Io(l,p,e,h,v,k,b)),m.set(d,{x:l,y:p,w:e,h:h})}if(e>0&&v.size>0){const e=d?u:[u[0]];for(const n of e){const e=v.get(n),a=m.get(n);if(!e||!a)continue;const c=(()=>{const t=i.groups.get(n);return r(t?t.pieces[0]:o.pieceData[0],"_default"===n?o.name:n)})(),l={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||t.config.themeSemantic?.secondary||"#999",opacity:b},datum:i.groups.get(n)?.pieces[0]??o.pieceData[0],category:"_default"===n?o.name:n};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:i,getR:o,getStack:n,resolvePieceStyle:r,scales:s}=t,a=[],c=s.o.domain().map(t=>i[t]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const t of c)for(const e of t.pieceData){const t=n?n(e):"_default";u.has(t)||(u.add(t),l.push(t))}const h=l.length>1&&"_default"!==l[0],d=[];for(const t of c){const e=new Map;let i=0;for(const r of t.pieceData){const t=n?n(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),i+=a}d.push({col:t,groups:e,stepTotal:i})}const f=new Map;for(const t of l){const e=d[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=h?l.length:1,g=h?.15:0;for(let t=0;d.length>t;t++){const e=d[t],i=e.col,o=0===t,n=t>0?d[t-1]:null,s=i.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const d=l[t],y=e.groups.get(d);if(!y)continue;const g=y.total,m=f.get(d)??g,x=m>0?g/m*100:0,b=n?.groups.get(d),v=o?0:Math.max(0,(b?.total??g)-g),w=i.x+t*s+c/2,k=p(g),S=p(0)-k,A=r(y.pieces[0],h?d:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Io(w,k,u,S,A,M,h?d:i.name)),v>0){const t=p(g+v),e=k-t,o={...A},n={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name};a.push(Io(w,t,u,e,o,n,h?d:i.name))}}}return a},swimlane:function(t,e){const{scales:i,columns:o,getR:n,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c,h=t.config.gradientFill,d=u?"left":"bottom",f=t.config.trackFill;if(f){const t="string"==typeof f?f:f.color,e="string"==typeof f?1:f.opacity??1,[i,n]=a.range(),r=Math.min(i,n),s=Math.abs(n-i);for(const i of Object.values(o)){const o={fill:t,opacity:e},n=u?Io(r,i.x,s,i.width,o,null,"__track__"):Io(i.x,r,i.width,s,o,null,"__track__");l.push(n)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(o)){let e=0;const i=l.length;for(const i of t.pieceData){const o=Math.abs(n(i));if(0===o)continue;const c=r?r(i):t.name,f=s(i,c);let p;if(u){const n=a(e),r=a(e+o);p=Io(n,t.x,r-n,t.width,f,i,c)}else{const n=a(e+o),r=a(e);p=Io(t.x,n,t.width,r-n,f,i,c)}h&&(p.fillGradient=h,p.roundedEdge=d),l.push(p),e+=o}if(p>0&&l.length>i){const t=l.slice(i),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(e.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return l}},ca=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],la=["scene-style","data-paint","accessibility","evidence"],ua=(t,e)=>({retainedData:t,invalidations:e}),ha=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],da=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fa=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pa=["scene-geometry","data-paint","accessibility","evidence"],ya=["scene-style","data-paint","accessibility","evidence"],ga=[],ma={chartType:ua("rebuild",ha),runtimeMode:ua("rebuild",ha),categoryAccessor:ua("rebuild",ha),valueAccessor:ua("rebuild",ha),oAccessor:ua("rebuild",ha),rAccessor:ua("rebuild",ha),stackBy:ua("rebuild",ha),groupBy:ua("rebuild",ha),timeAccessor:ua("rebuild",ha),accessorRevision:ua("rebuild",ha),colorAccessor:ua("rebuild",ya),symbolAccessor:ua("rebuild",pa),connectorAccessor:ua("rebuild",pa),dataIdAccessor:ua("rebuild",pa),projection:ua("preserve",da),extentPadding:ua("preserve",da),axisExtent:ua("preserve",da),rExtent:ua("preserve",da),oExtent:ua("preserve",da),multiAxis:ua("preserve",da),normalize:ua("preserve",da),bins:ua("preserve",da),oSort:ua("preserve",fa),barPadding:ua("preserve",fa),roundedTop:ua("preserve",fa),baselinePadding:ua("preserve",fa),innerRadius:ua("preserve",fa),cornerRadius:ua("preserve",fa),startAngle:ua("preserve",fa),sweepAngle:ua("preserve",fa),trackFill:ua("preserve",fa),showOutliers:ua("preserve",fa),showIQR:ua("preserve",fa),amplitude:ua("preserve",fa),connectorOpacity:ua("preserve",fa),showLabels:ua("preserve",fa),dynamicColumnWidth:ua("rebuild",fa),customLayout:ua("preserve",fa),layoutConfig:ua("preserve",fa),layoutMargin:ua("preserve",fa),symbolMap:ua("preserve",pa),pieceStyle:ua("preserve",ya),summaryStyle:ua("preserve",ya),connectorStyle:ua("preserve",ya),gradientFill:ua("preserve",ya),colorScheme:ua("preserve",ya),themeCategorical:ua("preserve",ya),themeSemantic:ua("preserve",ya),themeSequential:ua("preserve",ya),themeDiverging:ua("preserve",ya),barColors:ua("preserve",ya),decay:ua("preserve",ya),pulse:ua("preserve",ya),staleness:ua("preserve",ya),layoutSelection:ua("preserve",ya),windowSize:ua("preserve",ga),windowMode:ua("preserve",ga),clock:ua("preserve",ga),transition:ua("preserve",ga),introAnimation:ua("preserve",ga),onLayoutError:ua("preserve",ga)},xa=ua("preserve",fa),ba=class{constructor(){this.tracker=new li}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},ca)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},la):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=ma[o]??xa;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},va=require("d3-quadtree"),wa=class{constructor(t){this.rExtent=new yo,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new ba,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new ta,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new po(t.windowSize),this.getO=bo(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>mo(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new yo)):(this.getR=mo(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=bo(t.stackBy),this.getGroup=bo(t.groupBy),this.getColor=bo(t.colorAccessor),this.getSymbol=bo(t.symbolAccessor),this.getConnector=bo(t.connectorAccessor),this.getDataId=bo(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new po(t.windowSize))}syncPulseTimestampBuffer(){var t,e,i,o;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,i=this.timestampBuffer,o=this.currentTime(),t?null!=i&&i.capacity===e.capacity&&i.size===e.size?i:fn(e,o):null)}currentTime(){return this.config.clock?.()??Po()}ingest(t){const e=this.currentTime();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),dn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)pn(this.buffer,i,this.timestampBuffer,e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=pn(this.buffer,i,this.timestampBuffer,e);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,n=this.multiScales,r=this.columns;if(0===i.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(h){f=(0,Js.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;p=(0,Js.scaleLinear)().domain(l).range([o,i])}else u?(f=(0,Js.scaleBand)().domain(c).range([0,t.height]).padding(d),p=(0,Js.scaleLinear)().domain(l).range([0,t.width])):(f=(0,Js.scaleBand)().domain(c).range([0,t.width]).padding(d),p=(0,Js.scaleLinear)().domain(l).range([t.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,n)=>{const r=this.rExtents[n];r.dirty&&r.recalculate(i,o);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(e.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Js.scaleLinear)().domain([s,a]).range([0,t.width]):(0,Js.scaleLinear)().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,i)=>({...t,__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,c,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=n,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let n=null;if(i){n=new Set;for(const e of t)n.add(this.getO(e))}const r=n?Array.from(this.categories).filter(t=>n.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*n.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;n.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:i,projection:o,normalize:n,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:h,rawRExtent:d}=t,f=s;if("radial"===o&&("pie"===i||"donut"===i))return[0,1];let p=0,y=0;if("bar"===i&&h&&n)p=0,y=1;else if("bar"===i&&h){const t=new Map,i=new Map;for(const o of e){const e=l(o),n=u(o);0>n?i.set(e,(i.get(e)||0)+n):t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>y&&(y=e);for(const t of i.values())p>t&&(p=t)}else if("bar"===i){const t=new Map;for(const i of e){const e=l(i),o=u(i);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===i){const t=new Map;for(const i of e){const e=l(i),o=Math.abs(u(i));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===i||"bar-funnel"===i)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=d[0],e=d[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(y=r[1]));const g="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==i&&"exact"!==c){const t=y-p,e=t>0?t*f:1,o=g&&!a&&0===p,n=g&&!a&&0===y||"swimlane"===i;null!=r?.[0]||o||(p-=e),null!=r?.[1]||n||(y+=e)}return[p,y]}({data:t,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(t,e,i,o,n){return function(t){const{data:e,oExtent:i,oScale:o,projection:n,layout:r,dynamicColumnWidth:s,getO:a,getR:c}=t,l={},u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let h=0;if("radial"===n)for(const t of e)h+=Math.abs(c(t));let d=null;if(s&&"radial"!==n){d=new Map;let t=0;for(const e of i){const i=u.get(e)||[];let o;o="string"==typeof s?i.reduce((t,e)=>t+(Number(e[s])||0),0):s(i),d.set(e,o),t+=o}const e=("horizontal"===n?r.height:r.width)-o.padding()*o.step()*i.length;if(t>0)for(const[i,o]of d)d.set(i,o/t*e)}let f=0,p=0;for(const t of i){const e=u.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(c(e)),0),n=h>0?i/h:0;let r,s;d?(r=p,s=d.get(t)||o.bandwidth(),p+=s+o.padding()*o.step()):(r=o(t)??0,s=o.bandwidth()),l[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:o.padding()*o.step(),pieceData:e,pct:n,pctStart:f},f+=n}return l}({data:t,oExtent:e,oScale:i,projection:o,layout:n,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.styleResolver.resolvePieceStyle(this.config,t,e),resolveSummaryStyle:(t,e)=>this.styleResolver.resolveSummaryStyle(this.config,t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(t,e);let o;try{o=this.config.customLayout(i)}catch(t){const e=null!==this.lastCustomLayoutResult,i=sn("ordinal",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of n)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return on({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const i=this.getSceneContext(),o=aa[this.config.chartType];let n=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:o,getConnector:n,getO:r}=t;if(!n||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=n(e);if(!i)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:o,y:s,datum:e,category:r(e)})}const l=i.o.domain(),u=o.connectorStyle;for(const[e,i]of c)if(i.length>=2){i.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let o=0;i.length-1>o;o++){const n=i[o],r=i[o+1],a="function"==typeof u?u(n.datum):u||{stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:n.x,y1:n.y,x2:r.x,y2:r.y,style:a,datum:n.datum,group:e})}}return s}(i,n);n=[...t,...n]}return n}buildLayoutContext(t,e){const i=this.config,o=i.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Wi(i.colorScheme,i.themeCategorical,j),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:o,plot:"radial"===r.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:[...n]},resolveColor:Yi(n,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?To(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=Ro(t);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=function(t,e){const i="function"==typeof e,o=i?null:e||"category",n=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=i?e(s):s[o],c=n.get(a);c?c.push(r):n.set(a,[r])}return n}(t,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:e},e}rebuildPointQuadtree(){const t=function(t){let e=0,i=0;for(const o of t)"point"===o.type&&(e++,o.r>i&&(i=o.r));if(500>=e)return{quadtree:null,maxRadius:i};const o=Array(e);let n=0;for(const e of t)"point"===e.type&&(o[n++]=e);return{maxRadius:i,quadtree:(0,va.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=o.get(e.datum);if(null==t)continue;const n=this.computeDecayOpacity(t,i);e.style={...e.style,opacity:(e.style?.opacity??1)*n}}}applyPulse(t,e,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,n,r){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;for(const l of e){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const e=l.category;if(!e)continue;let o=0;for(const s of n(e)??[]){const e=i.get(s);null!=e&&(o=Math.max(o,Lo(t,e,r)))}c=Co(l,o,s)||c;continue}if(null==l.datum)continue;const e=o.get(l.datum);if(null==e)continue;const u=i.get(e);c=Co(l,null==u?0:Lo(t,u,r),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),i)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&$o(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const t=new Map,e=this.scales?.r(0)??0,i="horizontal"!==this.scales?.projection;let o;for(let n=0;this.scene.length>n;n++){const r=this.scene[n],s=this.getNodeKey(r,t);s&&("rect"===r.type?this.prevPositionMap.set(s,i?{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}:{x:e,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===o&&(o=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:o,endAngle:o,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${t.datum?.category??""}`:"wedge"===t.type?"w:"+(t.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=this.getNodeKey(i,t);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"wedge"===i.type&&this.prevPositionMap.set(o,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const t=this.config.transition.duration??300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let e=!1;const i=new Set,o=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=this.getNodeKey(n,o);if(!r)continue;n._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===n.type)s?(i.add(r),n._targetOpacity=n.style.opacity??1,(s.x!==n.x||s.y!==n.y||void 0!==s.r&&s.r!==n.r)&&(n._targetX=n.x,n._targetY=n.y,n._targetR=n.r,n.x=s.x,n.y=s.y,void 0!==s.r&&(n.r=s.r),e=!0)):(n._targetOpacity=n.style.opacity??1,n._targetR=n.r,n.r=0,n.style={...n.style,opacity:0},e=!0);else if("rect"===n.type)s?(i.add(r),n._targetOpacity=n.style.opacity??1,s.x===n.x&&s.y===n.y&&s.w===n.w&&s.h===n.h||(n._targetX=n.x,n._targetY=n.y,n._targetW=n.w,n._targetH=n.h,n.x=s.x,n.y=s.y,n.w=s.w??n.w,n.h=s.h??n.h,e=!0)):(n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},e=!0);else if("wedge"===n.type)if(s)i.add(r),n._targetOpacity=n.style.opacity??1,s.startAngle===n.startAngle&&s.endAngle===n.endAngle||(n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle,n.startAngle=s.startAngle,n.endAngle=s.endAngle,e=!0);else{n._targetOpacity=n.style.opacity??1,n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle;const t=n.startAngle;n.startAngle=t,n.endAngle=t,n.style={...n.style,opacity:0},this.prevPositionMap.set(r,{x:n.cx,y:n.cy,startAngle:t,endAngle:t,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0}),e=!0}}this.exitNodes=[];for(const[t,o]of this.prevPositionMap)if(!i.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((o.startAngle??0)+(o.endAngle??0))/2,i={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(i)}e=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),e&&(this.activeTransition={startTime:this.currentTime(),duration:t})}advanceTransition(t){if(!this.activeTransition)return!1;const e=Mo(t,this.activeTransition),i=Ao(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=_o(o?o.opacity??1:0,t._targetOpacity,i)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=_o(o.x,t._targetX,i),t.y=_o(o.y,t._targetY,i)),void 0!==t._targetR&&void 0!==o?.r&&(t.r=_o(o.r,t._targetR,i))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=_o(o?o.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=_o(o.x,t._targetX,i),t.y=_o(o.y,t._targetY,i),void 0!==o.w&&(t.w=_o(o.w,t._targetW,i),t.h=_o(o.h,t._targetH,i))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style={...t.style,opacity:_o(o?o.opacity??1:0,t._targetOpacity,i)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const o=this.prevPositionMap.get(e);o&&void 0!==o.startAngle&&(t.startAngle=_o(o.startAngle,t._targetStartAngle,i),t.endAngle=_o(o.endAngle,t._targetEndAngle,i))}}}if(e>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style={...t.style||{},opacity:0===t._targetOpacity?0:t._targetOpacity},t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=So(t),i=this.getDataId,o=t=>e.has(i(t));yn(this.buffer,this.timestampBuffer,o);const n=this.buffer.remove(o);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=So(t),o=this.getDataId,n=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&n.add(e)});const r=this.buffer.update(t=>i.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),n.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},n=i(o,e);o.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();this._categoryIndexCache=null,this.buffer.forEach(t=>{this.categories.add(this.getO(t)),this.pushValueExtent(t)})}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!go(t.colorAccessor,e.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in t&&!go(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!go(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in t||"oAccessor"in t)&&(go(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=bo(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let n=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,i=e.valueAccessor||e.rAccessor,o=Array.isArray(t)?t:[t],r=Array.isArray(i)?i:[i];if(n=o.length!==r.length||o.some((t,e)=>!go(t,r[e])),n){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>mo(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new yo)):(this.getR=mo(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!go(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?bo(this.config.stackBy):void 0),"groupBy"in t&&!go(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?bo(this.config.groupBy):void 0),"colorAccessor"in t&&!go(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bo(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!go(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?bo(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!go(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?bo(this.config.connectorAccessor):void 0),(o||n||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Sn(wa);var ka=require("react/jsx-runtime"),Sa=require("react/jsx-runtime");function Aa(t,e){const i=io(t.theme),o=t.size||[500,400],n=Os({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Is(t.title),s=uo(t.data),a=t.showLegend?wr(s,t.colorAccessor||t.stackBy||t.groupBy):[],c=t.legendPosition;ao(t.legend)||co(t.legend)?Xs(n,{legend:t.legend,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&a.length>0&&qs(n,{categories:a,colorScheme:t.colorScheme,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const l=o[0]-n.left-n.right,u=o[1]-n.top-n.bottom,h=t.projection||"vertical",d="radial"===h,f={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:h,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,axisExtent:t.axisExtent,barPadding:t.barPadding,roundedTop:t.roundedTop,innerRadius:t.innerRadius,cornerRadius:t.cornerRadius,normalize:t.normalize,startAngle:t.startAngle,sweepAngle:t.sweepAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,gradientFill:t.gradientFill,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,multiAxis:t.multiAxis,baselinePadding:t.baselinePadding,trackFill:t.trackFill,connectorOpacity:t.connectorOpacity,showLabels:t.showLabels,colorScheme:t.colorScheme||i.colors.categorical,themeCategorical:i.colors.categorical,themeSemantic:Ft(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},p=new wa(f);if(t.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return e&&(e.evidence=so({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),Qs.renderToStaticMarkup(Hs(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));if(e){const i=p.scales.o?.domain?.();e.evidence=so({frameType:"ordinal",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,yDomain:ro(p.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0})}const y=t._idPrefix,g=t.showGrid?function(t,e,i,o,n){const r=t.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=oo(i),a=o?o+"-":"",c="vertical"===r.projection,l=Bs(r.r,5,n);return(0,Ws.jsx)("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((t,i)=>{const o=r.r(t);return(0,Ws.jsx)("line",{x1:0,y1:o,x2:e.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((t,i)=>{const o=r.r(t);return(0,Ws.jsx)("line",{x1:o,y1:0,x2:o,y2:e.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}(p,{width:l,height:u},i,y,t.axisExtent):null;let m=null;if(p.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(t),o=new Set;for(const t of p.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");m=Array.from(o).map((t,o)=>function(t){const{id:e,background:i="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return(0,ka.jsxs)("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&(0,ka.jsx)("rect",{width:a,height:a,fill:i}),(0,ka.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:n}),(0,ka.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:o,strokeWidth:n})]},e)}({id:`funnel-hatch-${e}-${o}`,background:t,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(o).forEach((t,i)=>n.set(t,`funnel-hatch-${e}-${i}`));for(const t of p.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&(t.style={...t.style,fill:`url(#${n.get("string"==typeof t.style.fill?t.style.fill:"#666")})`})}const x=p.scene.map((e,i)=>ar({node:e,index:i,renderMode:t.renderMode,fallback:()=>rr(e,i,y)})).filter(Boolean),b=!1!==t.showAxes?function(t,e,i,o,n){const r=t.scales;if(!r)return null;if("radial"===r.projection)return null;const s=oo(o),a="vertical"===r.projection,c=i.categoryFormat||i.oFormat,l=i.valueFormat||i.rFormat,u=i.categoryLabel||i.oLabel,h=i.valueLabel||i.rLabel,d=Object.values(t.columns).map(t=>({pixel:t.middle,label:(c||String)(t.name)})),f=Bs(r.r,5,i.axisExtent).map(t=>({pixel:r.r(t),label:(l||Vs)(t)}));return(0,Sa.jsxs)("g",a?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[(0,Sa.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,i)=>(0,Sa.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,Sa.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Sa.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),u&&(0,Sa.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Sa.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,e)=>(0,Sa.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Sa.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Sa.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),h&&(0,Sa.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:h})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[(0,Sa.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,i)=>(0,Sa.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,Sa.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Sa.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),h&&(0,Sa.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:h}),(0,Sa.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,e)=>(0,Sa.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Sa.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Sa.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),u&&(0,Sa.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:u})]})}(p,{width:l,height:u},t,i,y):null,v=t.annotations?js({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{o:p.scales.o,r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:l,height:u},theme:i,projection:h,idPrefix:y}):null,w=t.showLegend?0===a.length?null:vr({categories:a,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,k=Us.isValidElement(t.legend)?t.legend:Gs(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||w,S=d?n.left+l/2:n.left,A=d?n.top+u/2:n.top;return Qs.renderToStaticMarkup(Hs((0,Sa.jsxs)(Sa.Fragment,{children:[t.backgroundGraphics,g,x,b,v,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${S},${A})`,innerWidth:l,innerHeight:u,legend:k,defs:m,idPrefix:t._idPrefix}))}var Ma=c(require("react")),_a=c(require("react-dom/server"));function Pa(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Ta(t,e){var i,o=[],n=[],r=[],s={},a=[];function c(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&c(e)})}function l(t){var e,o,h=!1;for(n.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,n),h=!0):r[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return n.pop(),h}function u(t,i){var n=[].concat(i).concat(t);e?e(n):o.push(n)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),n=Array(e),r=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,n[c]=!1,r[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,n[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>r[e]){for(var p=r[e];f.length>p;++p){var y=f[p];if(0>i[y]){i[y]=o[y]=u,n[y]=!0,u+=1,c.push(y),l.push(y);break}n[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=p}else{if(o[e]===i[e]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(n[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=h.length,b===e){c.length=p;break}}h.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];d.push(v)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var p=d[c];if(0!==p.length){p.sort(function(t,e){return t-e}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),n=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;n.length>s;s++)for(var a=0;n[s].length>a;a++)r>n[s][a]&&(r=n[s][a],i=s);var c=n[i];return!!c&&{leastVertex:r,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];r[+g]=!1,s[g]={}}l(i),i+=1}else i=d}return e?void 0:o}function Ra(t){return t.y0-t.y1>0?"up":"down"}function La(t,e){return e(t.source)==e(t.target)}function Ca(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function $a(t){return t.target.x0-t.source.x1}function ja(t,e){var i=Ea(t),o=$a(e)/Math.tan(i);return"up"==Ra(t)?t.y1-o:t.y1+o}function za(t,e){var i=Ea(t),o=$a(e)/Math.tan(i);return"up"==Ra(t)?t.y1+o:t.y1-o}function Ea(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Da(t,e){return e(t)}function Na(t){return Ia(t.source)}function Fa(t){return Ia(t.target)}function Ia(t){return(t.y0+t.y1)/2}function Oa(t){return t.virtual?0:t.value}function Ba(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!La(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!La(t,e)?o+1:o}),i+o}function Wa(t){return t.target.depth}function Ya(t,e){return t.sourceLinks.length?t.depth:e-1}function qa(t,e){return t.y0-e.y0}function Xa(t,e){return e.y0-t.y0}function Ga(t,e){return t.y1-e.y1}function Va(t,e){return e.y1-t.y1}function Ha(t,e){return Ka(t.source,e.source)||t.index-e.index}function Za(t,e){return Ka(t.target,e.target)||t.index-e.index}function Ka(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ua(t,e){return Qa(t)==Qa(e)?"bottom"==t.circularLinkType?Xa(t,e):qa(t,e):Qa(e)-Qa(t)}function Qa(t){return t.target.column-t.source.column}function Ja(t,e){return tc(t)==tc(e)}function tc(t){return t.y0-t.y1>0?"up":"down"}var ec=require("d3-array");function ic(t,e,i,o,n){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=(0,ec.min)(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),oc(r.links.filter(function(t){return"top"==t.circularLinkType}),e,i),oc(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,La(t,e)&&Ca(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,c=t.circularLinkType,l=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?Xa:qa);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?Va:Ga),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,o=t.target.x0,n=t.y1,r=(e+o)/2;return"M"+e+","+i+"C"+r+","+i+" "+r+","+n+" "+o+","+n}(t)}),r}function oc(t,e,i){t.sort(Ua);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(La(t,e)&&Ca(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&nc(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;r=c>r?c:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function nc(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}var rc=require("d3-array");function sc(t){return function(){return t}}function ac(t){return t.index}function cc(t){return t.nodes}function lc(t){return t.links}function uc(t,e,i){var o=(0,rc.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(n,r){var s=n.length;if(e)n.sort(e);else if(r>0){var a=new Map;n.forEach(function(t,e){var i,o,n,r=(o=0,n=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Ia(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Ia(t.target)*e,o+=e}}),o>0?n/o:NaN);a.set(t,{bc:r,idx:e})}),n.sort(function(t,e){var i=a.get(t),o=a.get(e),n=i.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(n)||isNaN(r)?isNaN(n)?isNaN(r)?i.idx-o.idx:1:-1:n-r})}else n.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ba(e,i)-Ba(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});n.forEach(function(e,n){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Ba(e,i)?(e.y0=t.y1/2+n,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+n,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-n,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*n,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+n,e.y1=e.y0+e.value*t.ky)})})}function hc(t,e,i,o,n,r){var s=(0,rc.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,c=r;c>0;--c)l(a*=.99,i),u();function l(e,i){var o=s.length;s.forEach(function(n){var r=n.length,s=n[0].depth;n.forEach(function(n){var a;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&Ba(n,i)>0){var c=(0,rc.mean)(n.sourceLinks,Fa),l=(0,rc.mean)(n.targetLinks,Na),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Ia(n))*e*.3;n.y0+=h,n.y1+=h}}else if(0==s&&1==r)n.y0=t.y1/2-(a=n.y1-n.y0)/2,n.y1=t.y1/2+a/2;else if(s==o-1&&1==r)n.y0=t.y1/2-(a=n.y1-n.y0)/2,n.y1=t.y1/2+a/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)a=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+a;else{var d=(0,rc.mean)(n.sourceLinks,Fa),f=(0,rc.mean)(n.targetLinks,Na),p=((d&&f?(d+f)/2:d||f)-Ia(n))*e;n.y0+=p,n.y1+=p}})})}function u(){s.forEach(function(i){var r,s,a,c=t.y0,l=i.length;for(i.sort(e||Ka),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+o;if((s=c-o-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+n-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function dc(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Za),t.targetLinks.sort(Ha)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,n=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function fc(){var t=0,e=0,i=1,o=1,n=24,r=8,s=null,a=ac,c=Ya,l=void 0,u=32,h=2,d=cc,f=lc;function p(){var p={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return(0,rc.group)(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,n=t.target;"object"!=typeof o&&(o=t.source=Pa(i,o)),"object"!=typeof n&&(n=t.target=Pa(i,n)),o.sourceLinks.push(t),n.targetLinks.push(t)})}(d,a),function(t,e){var i=0;if(null==e){for(var o=[],n=0;t.links.length>n;n++){var r=t.links[n],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Ta(o);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,l),function(t,e){var i=0,o=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:o>i?"top":"bottom","top"==n.circularLinkType?i++:o++,t.nodes.forEach(function(t){Da(t,e)!=Da(n.source,e)&&Da(t,e)!=Da(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),La(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max((0,rc.sum)(t.sourceLinks,Oa),(0,rc.sum)(t.targetLinks,Oa)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,i){var o,n,r;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,n=[],r=0;o.length;++r,o=n,n=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(o=t.nodes,n=[],r=0;o.length;++r,o=n,n=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,r):t.column})}(d,l,c);var f=r;if(null!==s){var p=(0,rc.groups)(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=(0,rc.max)(p,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=(0,rc.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var n=(0,rc.min)(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/(0,rc.sum)(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var r=(0,rc.max)(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/r),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,f,n),uc(d,l,a),hc(d,l,a,f,f,u),dc(d),ic(d,a,h,10,8),uc(d,l,a),hc(d,l,a,f,f,u),dc(d),ic(d,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return Da(i.source,e)==Da(t,e)}),n=o.length;n>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ja(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=ja(e,t);return t.y1-i}if(e.target.column>t.target.column)return ja(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var r=i+1,s=0;n>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Da(i.target,e)==Da(t,e)}),n=o.length;n>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ja(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=za(e,t);return t.y0-i}if(e.source.column>t.source.column)return za(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var r=i+1,s=0;n>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,i=t.links,o=!1,n=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==o||0==n){let o=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=(0,rc.min)(e,function(t){return t.y0}),s=(0,rc.max)(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1)}),i.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=o(t.y0)-t.y0;t.y0=o(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),ic(d,a,h,10,8)}(p),p}return p.update=function(t){return dc(t),ic(t,a,h,10,8),t},p.nodeWidth=function(t){return arguments.length?(n=+t,p):n},p.nodePadding=function(t){return arguments.length?(r=+t,p):r},p.nodePaddingRatio=function(t){return arguments.length?(s=+t,p):s},p.nodes=function(t){return arguments.length?(d="function"==typeof t?t:sc(t),p):d},p.links=function(t){return arguments.length?(f="function"==typeof t?t:sc(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:sc(t),p):a},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:sc(t),p):c},p.nodeSort=function(t){return arguments.length?(l=t,p):l},p.iterations=function(t){return arguments.length?(u=+t,p):u},p.circularLinkGap=function(t){return arguments.length?(h=+t,p):h},p.extent=function(n){return arguments.length?(t=+n[0][0],e=+n[0][1],i=+n[1][0],o=+n[1][1],p):[[t,e],[i,o]]},p.size=function(n){return arguments.length?(t=e=0,i=+n[0],o=+n[1],p):[i-t,o-e]},p}var pc=require("d3-interpolate"),yc=(require("d3-shape"),.5),gc=t=>{let e,i,o,n,r,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=(0,pc.interpolateNumber)(r,s),c=a(yc),l=a(.5),`M${e},${r}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${n},${c} ${n},${r}Z`;const u=t.sankeyWidth/2,h=(0,pc.interpolateNumber)(t.source.x1,t.target.x0),{pathD:d}=Lt({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(yc),cp2X:h(.5)});return d};function mc(t){const e=t.sankeyWidth/2,i=(t._circularWidth??t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const i=o.sourceX,n=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-i))),c=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${i},${n-e}L${i+a},${n-e}L${i+a},${n+e}L${i},${n+e}ZM${r},${s-e}L${r-c},${s-e}L${r-c},${s+e}L${r},${s+e}Z`}const n=o.sourceX,r=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(i,15));return`M${n},${r-h*e}L${c},${r-h*e}L${c+i},${r-h*e+h*d}L${c+i},${u+h*i-h*d}L${c+i-d},${u+h*i}L${l-i+d},${u+h*i}L${l-i},${u+h*i-h*d}L${l-i},${a-h*e+h*d}L${l-i+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${l+i},${a+h*e}L${l+i},${u-h*i}L${c-i},${u-h*i}L${c-i},${r+h*e}L${n},${r+h*e}Z`}var xc=new Set,bc=new WeakMap;function vc(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=bc.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,bc.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;xc.has(t)||(xc.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}var wc={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(Wa))-1:0},justify:Ya};function kc(t){return"string"==typeof t?t:t.id}var Sc={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const n="vertical"===i.orientation?"down":"right",r=i.nodeAlign||"justify",s=i.nodeWidth??15,a=i.nodePaddingRatio??.05,c=i.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===n?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const d=fc().extent(h).links(u).nodes(l).nodeAlign(wc[r]||Ya).nodeId(t=>t.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const o of l)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>n&&(n=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(o._circularWidth??o.width??0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),i>r.verticalFullExtent-s&&(i=r.verticalFullExtent-s),r.verticalFullExtent+s>n&&(n=r.verticalFullExtent+s)}const r=e-t,s=n-i,a=o[0],c=o[1];if(r>0&&s>0&&(0>t||0>i||e>a||n>c)){const e=Math.min(a/r,c/s),o=-t*e+(a-r*e)/2,n=-i*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of u)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+n,i.targetY=i.targetY*e+n,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+n,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+n,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+n,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of l){const e=f.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const p=new Map;for(const t of e)p.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=kc(t.source),i=kc(t.target),o=p.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=t.width??0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=n;const r=f.get(e),s=f.get(i);r&&(o.source=r),s&&(o.target=s)}}},buildScene(t,e,i,o){const n="vertical"===i.orientation?"down":"right",r=i.nodeStyle,s=i.edgeStyle,a=i.edgeOpacity??.5,c=i.edgeColorBy||"source",l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:g,u=new Map;t.forEach((t,e)=>{u.set(t.id,l[e%l.length])});const h=[],d=[],f=[],p=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=r?r(vc(e,"nodeStyle")):{},s={fill:o.fill||u.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),h.push("down"===n?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:s,datum:e,id:e.id,label:e.id})}const y=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of y){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let n=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";n="function"==typeof c?c(t)||n:"target"===c?p.get(o.id)||u.get(o.id)||n:p.get(e.id)||u.get(e.id)||n;const r=s?s(vc(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=r.fill||n;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),d.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-s},${e.targetY-i}L${e.targetX-s},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;(l=t.circular&&t.circularPathData?mc(t):gc(t),l)&&d.push({type:"bezier",pathD:l,bezierCache:t.bezier,style:{fill:r.fill||n,fillOpacity:r.fillOpacity??a,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity},datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const s=e?e(i):i.id;if(!s)continue;let a,c,l;"down"===n?(a=i.y0+(i.y1-i.y0)/2,c=i.x1+14,l="start"):(o[0]/2>i.x0+t/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),c=i.y0+r/2),f.push({x:a,y:c,text:s+"",anchor:"down"===n?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:h,sceneEdges:d,labels:f}}},Ac=require("d3-force"),Mc=require("d3-scale"),_c={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const n=i.forceStrength??.1,r=o[0]/2,s=o[1]/2,a=i.__previousPositions;let c=0;const l=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=a?.get(e.id);t?c++:i?(e.x=i.x,e.y=i.y,c++):l.push(e)}const u=c>0&&.3>=(t.length>0?l.length/t.length:1);if(u){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of l){const o=Pc(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const n=Tc(t.id),r=n%360*(Math.PI/180),s=10+n%20;t.x=e/o.length+s*Math.cos(r),t.y=i/o.length+s*Math.sin(r)}else{const e=Tc(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=r+o*Math.cos(i),t.y=s+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),n=i*e;o.x=r+t*Math.cos(n),o.y=s+t*Math.sin(n)}}}const h=i.__skipForceSimulation||0===i.iterations?0:u?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),d=Rc(i.nodeSize,i.nodeSizeRange,t),f=t=>d(t);if(h>0){const o=new Map,a=new Map;for(const e of t)o.set(e.id,0),a.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id;o.set(e,(o.get(e)??0)+1),o.set(i,(o.get(i)??0)+1)}const c=(0,Ac.forceLink)().strength(t=>{const e=t.weight,i="string"==typeof t.target?t.target:t.target.id,r=Math.max(1,Math.min(o.get("string"==typeof t.source?t.source:t.source.id)??1,o.get(i)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*n/(.1*r))}).distance(t=>{const e="string"==typeof t.source?a.get(t.source):t.source,i="string"==typeof t.target?a.get(t.target):t.target,o=(e?f(e):0)+(i?f(i):0)+12;return Math.max(40,o)}).id(t=>t.id),l=(0,Ac.forceSimulation)();if(void 0===i.random&&void 0===i.seed||l.randomSource(i.random??function(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}(i.seed)),l.force("charge",(0,Ac.forceManyBody)().strength(t=>{const e=o.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",(0,Ac.forceCollide)(t=>f(t)+3).strength(.9).iterations(2)).force("center",(0,Ac.forceCenter)(r,s).strength(.8)).force("x",(0,Ac.forceX)(r).strength(.06)).force("y",(0,Ac.forceY)(s).strength(.06)),l.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));c.links(t),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let t=0;h>t;++t)l.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=p.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=p.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){const n=i.nodeStyle,r=i.edgeStyle,s=Rc(i.nodeSize,i.nodeSizeRange,t),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:g,c=new Map;t.forEach((t,e)=>{c.set(t.id,a[e%a.length])});const l=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(vc(e,"nodeSize")),o=n?n(vc(e,"nodeStyle")):{},r={fill:o.fill||c.get(e.id)||i.themeSemantic?.primary||"#007bff",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};l.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:d.get(t.source),o="object"==typeof t.target?t.target:d.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const n=r?r(vc(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:n.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6},datum:t})}if(!1!==i.showLabels){const e=(f=i.nodeLabel)?"function"==typeof f?f:t=>t[f]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=s(vc(i,"nodeSize"));h.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Pc(t,e,i){const o=[];for(const n of e){const e="string"==typeof n.source?n.source:n.source.id,r="string"==typeof n.target?n.target:n.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Tc(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function Rc(t,e,i){if(i.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],n=[];for(const e of i){const i=e.data?.[t];"number"==typeof i&&n.push(i)}if(0===n.length)return()=>o[0];const[r,s]=mt(n);if(r===s)return()=>(o[0]+o[1])/2;const a=(0,Mc.scaleLinear)().domain([r,s]).range(o).clamp(!0);return e=>{const i=e.data?.[t];return null==i||"number"!=typeof i?o[0]:a(i)}}var Lc=require("d3-chord"),Cc=require("d3-shape"),$c=g,jc={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:n=.01,groupWidth:r=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-r,l=o[0]/2,u=o[1]/2,h=(d=i.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const n=h(t);y[i][o]=n}const g=(0,Lc.chord)().padAngle(n);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,Cc.arc)().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],o=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});i.x=o[0]+l,i.y=o[1]+u,i.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=v.get("string"==typeof t.source?t.source:t.source.id),o=v.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const i=t[e.source.index].id,o=t[e.target.index].id,n=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);n&&(n.__chordData=e)}},buildScene(t,e,i,o){const{groupWidth:n=20,edgeOpacity:r=.5}=i,s=Math.min(o[0],o[1])/2,a=s-n,c=o[0]/2,l=o[1]/2,u=i.nodeStyle,h=i.edgeStyle,d=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:$c,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=(0,Lc.ribbon)().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.__arcData;if(!o)continue;let n;n=u?u(vc(i,"nodeStyle")).fill||p.get(i.id)||f[e%f.length]:p.get(i.id)||f[e%f.length];const r=u?u(vc(i,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:n,stroke:r.stroke||"black",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=y(e);if(!o)continue;const n=zc(o,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";if(h)s=h(vc(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===d&&i?s=p.get(i.id)||s:e&&(s=p.get(e.id)||s)}const a=h?h(vc(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:n,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==i.showLabels){const e=(b=i.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,o=s+12;for(const i of t){const t=i.__arcData;if(!t)continue;const n=e?e(i):i.id;if(!n)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:n+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function zc(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const n=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("C"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("Q"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("A"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&(n.push(Number(o[r])+e+""),r++),o.length>r&&(n.push(Number(o[r])+i+""),r++);else"Z"===t||"z"===t?(n.push(t),r++):(n.push(o[r]),r++)}return n.join(" ")}var Ec=require("d3-hierarchy"),Dc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Nc(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Fc(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Ic(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 Oc(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Dc}function Bc(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 Wc(t,e,i,o,n){if("horizontal"===n){const n=(t+i)/2;return`M ${t},${e} C ${n},${e} ${n},${o} ${i},${o}`}if("radial"===n){const n=(t+i)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+o)/2} T ${i},${o}`}{const n=(e+o)/2;return`M ${t},${e} C ${t},${n} ${i},${n} ${i},${o}`}}var Yc={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){const n=i.__hierarchyRoot;if(!n)return;const r=i.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),a=i.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=(0,Ec.hierarchy)(n,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=o;switch(r){case"tree":!function(t,e,i,o){const n=e.treeOrientation||"vertical",r=(0,Ec.tree)();r.size("horizontal"===n?[o,i]:"radial"===n?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),r(t)}(l,i,u,h);break;case"cluster":!function(t,e,i,o){const n=e.treeOrientation||"vertical",r=(0,Ec.cluster)();r.size("horizontal"===n?[o,i]:"radial"===n?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),r(t)}(l,i,u,h);break;case"treemap":!function(t,e,i,o){const n=e.padding??4,r=e.paddingTop??0,s=(0,Ec.treemap)().size([i,o]).tile(Ec.treemapBinary).padding(n);r>0&&s.paddingTop(r),s(t)}(l,i,u,h);break;case"circlepack":!function(t,e,i,o){const n=e.padding??4;(0,Ec.pack)().size([i,o]).padding(n)(t)}(l,i,u,h);break;case"partition":!function(t,e,i,o){(0,Ec.partition)().size([i,o]).padding(e.padding??1)(t)}(l,i,u,h)}const d=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const o=d[e],n={id:Fc(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===r||"cluster"===r?qc(n,o,i):"treemap"===r||"partition"===r?Xc(n,o):"circlepack"===r&&Gc(n,o),n.__hierarchyNode=o,t.push(n),f.set(o,n)}if("tree"===r||"cluster"===r)for(const t of d)if(t.parent){const i=f.get(t.parent),o=f.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const n=i.nodeStyle||(()=>({})),r=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,n,r){const s=[],a=[],c=[],l=i.treeOrientation||"vertical",u="radial"===l,h=o[0]/2,d=o[1]/2,f="number"==typeof(p=i.nodeSize)?p:5;var p;for(const e of t){let t=e.x,o=e.y;u&&(t+=h,o+=d);const r=n(vc(e,"nodeStyle"));let a=r.fill||Bc(i);if(i.colorByDepth&&void 0!==e.depth){const t=Oc(i);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:o,r:f,style:{fill:a,stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=i.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let n=e.x,s=e.y,c=o.x,f=o.y;u&&(n+=h,s+=d,c+=h,f+=d);const p=Wc(n,s,c,f,l),g=r(vc(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:t})}if(!1!==i.showLabels){const e=Ic(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,n,r,s=i.x,a=i.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,n=a+e/i*10,r=0>t?"end":"start"):(o=s,n=a-12,r="middle")}else"horizontal"===l?(i.data?.children&&0!==i.data.children.length?(o=s-f-6,r="end"):(o=s+f+6,r="start"),n=a):(o=s,n=a+f+14,r="middle");c.push({x:o,y:n,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,i,o,n,r);case"treemap":case"partition":return function(t,e,i,o){const n=[],r=[];for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const s=o(vc(i,"nodeStyle"));let a=s.fill||Bc(e);if(e.colorByDepth&&void 0!==i.depth){const t=Oc(e);a=t[i.depth%t.length]}n.push({type:"rect",x:i.x0,y:i.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ic(e.nodeLabel),n=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,c=a.y1-a.y0;if(0>=t||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===n&&!l)continue;if("parent"===n&&l)continue}const u=i?i(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let h=o(vc(a,"nodeStyle")).fill||Bc(e);if(e.colorByDepth&&void 0!==a.depth){const t=Oc(e);h=t[a.depth%t.length]}const d="string"==typeof h?Nc(h):e.themeSemantic?.text??"#000";r.push(l?{x:a.x0+t/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,i,0,n);case"circlepack":return function(t,e,i,o){const n=[],r=[];for(const i of t){const t=i.__radius??5;if(0>=t)continue;const r=o(vc(i,"nodeStyle"));let s=r.fill||Bc(e);if(e.colorByDepth&&void 0!==i.depth){const t=Oc(e);s=t[i.depth%t.length]}n.push({type:"circle",cx:i.x,cy:i.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ic(e.nodeLabel);for(const n of t){const t=n.__radius??5,s=i?i(n):n.id;if(!s)continue;if(15>t)continue;const a=!(n.data?.children&&n.data.children.length>0);let c=o(vc(n,"nodeStyle")).fill||Bc(e);if(e.colorByDepth&&void 0!==n.depth){const t=Oc(e);c=t[n.depth%t.length]}if(a){const i="string"==typeof c?Nc(c):e.themeSemantic?.text??"#000";r.push({x:n.x,y:n.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else r.push({x:n.x,y:n.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,i,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function qc(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Xc(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 Gc(t,e){const i=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}var Vc=require("d3-shape");function Hc(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var Zc={sankey:Sc,force:_c,chord:jc,tree:Yc,cluster:Yc,treemap:Yc,circlepack:Yc,partition:Yc,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const n=i.__hierarchyRoot;n&&function(t,e,i,o,n){const r=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(i.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,l=i.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=Hc(i);d.metaMap.clear(),o.length=0,n.length=0;const f=new Map;function p(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const y=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=p(s(t));o.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,c,l,f,y,g){const m=r(e);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:i,depth:y,data:e,parentId:i},M=g?f/u(A)*S:f*S,_=(0,Vc.pie)().value(t=>{const e=r(t)?.length;return e?4:1}).sort(null)(w),P=h(A);for(let e=0;w.length>e;e++){const r=(_[e].startAngle+_[e].endAngle)/2,a=w[e],u=p(s(a)),h=c+M*Math.sin(r),f=l+M*Math.cos(r)*P;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),d.metaMap.set(u,{ring:M,angle:r,depth:y,parentId:i,eccentricity:P}),n.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(a,u,h,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(n,o,i,t,e)},buildScene(t,e,i,o){const n=i.nodeStyle,r=i.nodeSize,s="number"==typeof r?()=>r:"function"==typeof r?r:()=>6,a=[],c=[],l=[];if(!1!==i.orbitShowRings){const e=Hc(i),o=new Map;for(const e of t)o.set(e.id,e);const n=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;n.has(i)||n.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of n)for(let n=0;r>n;n++){const a=n/r*Math.PI*2,l=(n+1)/r*Math.PI*2;c.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(l),y2:e+i*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(vc(e,"nodeSize")),o=n?n(vc(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:o.fill||i.themeSemantic?.primary||"#6366f1",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const u=new Map;for(const e of t)u.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:u.get(t.source),i="object"==typeof t.target?t.target:u.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&c.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=s(vc(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e?i.data?.[e]??i.id:i.id;l.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(t,e,i,o,n)=>!1!==i.orbitAnimated&&(function(t,e){const i=Hc(e),o=e.orbitSpeed??.25,n=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),r=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const o=a.get(t.parentId);if(!o)continue;const c=t.angle+r*s*n({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=o.x+t.ring*Math.sin(c),e.y=o.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}},Kc=require("react/jsx-runtime");function Uc(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var Qc=new Set(["tree","cluster","treemap","circlepack","partition"]);function Jc(t,e){const i=io(t.theme),o=t.chartType||"force",n=()=>so({frameType:"network",width:r[0],height:r[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,nodeCount:0,edgeCount:0}),r=t.size||[500,500],s=Os({top:20,right:20,bottom:20,left:20,...t.margin},t.title),a=Is(t.title),c=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;if(!e)return[];const o=uo(t.nodes||[]);if(o.length>0)return wr(o,e);const n=Array.isArray(t.edges)?uo(t.edges):[];if(0===n.length)return[];const r=Uc(t.sourceAccessor,"source"),s=Uc(t.targetAccessor,"target");return wr(Array.from(new Set(n.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[],l=t.legendPosition;ao(t.legend)||co(t.legend)?Xs(s,{legend:t.legend,theme:i,position:l||"right",size:r,hasTitle:a,legendLayout:t.legendLayout}):t.showLegend&&c.length>0&&qs(s,{categories:c,colorScheme:t.colorScheme,theme:i,position:l||"right",size:r,hasTitle:a,legendLayout:t.legendLayout});const u=r[0]-s.left-s.right,h=r[1]-s.top-s.bottom,d=function(t){return Zc[t]}(o);if(!d&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const f={chartType:o,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme||i.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let p,y;if(Qc.has(o)){const o=t.data||t.edges;if(!o||Array.isArray(o))return e&&(e.evidence=n()),_a.renderToStaticMarkup(Hs(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:h,idPrefix:t._idPrefix}));f.__hierarchyRoot=o,p=[],y=[]}else{const o=uo(t.nodes||[]),a=Array.isArray(t.edges)?uo(t.edges):[];if(0===o.length&&0===a.length)return e&&(e.evidence=n()),_a.renderToStaticMarkup(Hs(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:h,idPrefix:t._idPrefix}));if(y=function(t,e){const i=Uc(e.sourceAccessor,"source"),o=Uc(e.targetAccessor,"target"),n=Uc(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(a,f),0===o.length&&y.length>0){const t=new Set;for(const e of y){const i=Ys(e.source),o=Ys(e.target);i&&t.add(i),o&&t.add(o)}p=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else p=function(t,e){const i=Uc(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(o,f)}let m=[],x=[],b=[],v=null;if(f.customNetworkLayout){const t=f.colorScheme,e=Wi(t,i.colors.categorical,g),o=Yi(e,t),n={nodes:p,edges:y,dimensions:{width:u,height:h,plot:{x:0,y:0,width:u,height:h}},theme:{semantic:i.colors,categorical:[...e]},resolveColor:o,config:f.layoutConfig??{}},r=f.customNetworkLayout(n);m=r.sceneNodes??[],x=r.sceneEdges??[],b=r.labels??[],v=r.overlays??null}else if(d){d.computeLayout(p,y,f,[u,h]);const t=d.buildScene(p,y,f,[u,h]);m=t.sceneNodes,x=t.sceneEdges,b=t.labels}const w=oo(i);for(const t of b)t.fill||(t.fill=w.text);e&&(e.evidence=so({frameType:"network",width:r[0],height:r[1],marks:[...m.map(t=>({type:"node:"+(t.type??"node")})),...x.map(t=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,nodeCount:m.length,edgeCount:x.length}));const k=x.map((e,i)=>ar({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"line":return(0,Qn.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const i=t;return(0,Qn.jsx)("path",{d:i.pathD,fill:tr(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"ribbon":{const i=t;return(0,Qn.jsx)("path",{d:i.pathD,fill:tr(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"curved":{const i=t;return(0,Qn.jsx)("path",{d:i.pathD,fill:tr(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+e)}default:return null}}(e,i)})).filter(Boolean),S=m.map((e,i)=>ar({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"circle":{const i=t,o=qn(i.style.fill)?Xn(i.style.fill,`net-circle-${e}-hatch`):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[o&&(0,Qn.jsx)("defs",{children:o}),(0,Qn.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:o?`url(#net-circle-${e}-hatch)`:tr(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-circle-"+e)}case"rect":{const i=t,o=qn(i.style.fill)?Xn(i.style.fill,`net-rect-${e}-hatch`):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[o&&(0,Qn.jsx)("defs",{children:o}),(0,Qn.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:o?`url(#net-rect-${e}-hatch)`:tr(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-rect-"+e)}case"arc":{const i=t,o=(0,Wn.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Jn)||"",n=qn(i.style.fill)?Xn(i.style.fill,`net-arc-${e}-hatch`):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[n&&(0,Qn.jsx)("defs",{children:n}),(0,Qn.jsx)("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:n?`url(#net-arc-${e}-hatch)`:tr(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-arc-"+e)}case"symbol":{const i=t,o=Jo(i.symbolType,i.size,i.path);return(0,Qn.jsx)("path",{d:o,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?tr(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-symbol-"+e)}case"glyph":return ir(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(e,i)})).filter(Boolean),A=b.map((t,e)=>function(t,e){return(0,Qn.jsx)("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}(t,e)).filter(Boolean),M=t.annotations?js({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{},layout:{width:u,height:h},theme:i,idPrefix:t._idPrefix}):null,_=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;if(!e)return[];const n=wr(p.length>0?p.map(t=>t.data||{id:t.id}):Array.from(new Set(y.flatMap(t=>[Ys(t.source),Ys(t.target)]).filter(Boolean))).map(t=>({id:t})),e);return 0===n.length?null:vr({categories:n,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:s,hasTitle:a,legendLayout:t.legendLayout})})():null,P=Ma.isValidElement(t.legend)?t.legend:Gs(t.legend,{theme:i,position:t.legendPosition||"right",size:r,margin:s,hasTitle:a,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||_;return _a.renderToStaticMarkup(Hs((0,Kc.jsxs)(Kc.Fragment,{children:[t.backgroundGraphics,k,S,A,M,t.foregroundGraphics,v]}),{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:h,legend:P,idPrefix:t._idPrefix}))}var tl=c(require("react")),el=c(require("react-dom/server")),il=require("d3-geo"),ol=require("d3-quadtree"),nl=require("d3-geo"),rl={mercator:nl.geoMercator,equalEarth:nl.geoEqualEarth,albersUsa:nl.geoAlbersUsa,orthographic:nl.geoOrthographic,naturalEarth:nl.geoNaturalEarth1,equirectangular:nl.geoEquirectangular};function sl(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function al(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function cl(t,e,i){return t?"function"==typeof t?{...i,...t(e)}:{...i,...t}:{...i}}function ll(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let n=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>i?(2>n.length||o.push(n),n=[r]):n.push(r)}return 2>n.length||o.push(n),o}function ul(t,e,i=24){const o=e[0]-t[0],n=e[1]-t[1],r=Math.sqrt(o*o+n*n);if(0===r)return[t,e];const s=-n/r,a=o/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const n=o/i,r=1-n;h.push([r*r*t[0]+2*r*n*l+n*n*e[0],r*r*t[1]+2*r*n*u+n*n*e[1]])}return h}function hl(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const n=t[e];let r,s;0===e?(r=t[1][0]-n[0],s=t[1][1]-n[1]):e===t.length-1?(r=n[0]-t[e-1][0],s=n[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([n[0]+s/a*i,n[1]+-r/a*i])}return o}function dl(t,e,i,o,n){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const c=s/a,l=-r/a,u=n/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}var fl=require("d3-scale"),pl=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yl=["scene-style","data-paint","accessibility","evidence"],gl=(t,e)=>({retainedData:t,invalidations:e}),ml=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xl=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bl=["scene-geometry","data-paint","accessibility","evidence"],vl=["scene-style","data-paint","accessibility","evidence"],wl=["overlay","accessibility","evidence"],kl=[],Sl={xAccessor:gl("rebuild",ml),yAccessor:gl("rebuild",ml),lineDataAccessor:gl("rebuild",ml),pointIdAccessor:gl("rebuild",bl),lineIdAccessor:gl("rebuild",bl),windowSize:gl("rebuild",ml),projection:gl("preserve",xl),projectionExtent:gl("preserve",xl),fitPadding:gl("preserve",xl),lineType:gl("preserve",xl),flowStyle:gl("preserve",xl),graticule:gl("preserve",xl),projectionTransform:gl("preserve",xl),customLayout:gl("preserve",xl),layoutConfig:gl("preserve",xl),layoutMargin:gl("preserve",xl),areaStyle:gl("preserve",vl),pointStyle:gl("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:gl("preserve",vl),colorScheme:gl("preserve",vl),themeCategorical:gl("preserve",vl),themeDiverging:gl("preserve",vl),themeSemantic:gl("preserve",vl),themeSequential:gl("preserve",vl),decay:gl("preserve",vl),pulse:gl("preserve",vl),layoutSelection:gl("preserve",vl),annotations:gl("preserve",wl),autoPlaceAnnotations:gl("preserve",wl),clock:gl("preserve",kl),transition:gl("preserve",kl),introAnimation:gl("preserve",kl),onLayoutError:gl("preserve",kl)},Al=gl("preserve",xl),Ml=class{constructor(){this.tracker=new li}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},pl)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},yl):this.recordNoop("restyle")}recordConfig(t,e={}){const i=function(t){let e="preserve";const i=new Set;for(const o of t){const t=Sl[o]??Al;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t),o=new Set(i.invalidations);return e.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:t},o)}},_l=require("d3-geo");function Pl(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var Tl=class t{constructor(t){this.updateResults=new Ml,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(t){return{...t,fitPadding:Pl(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??Po()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],o=e.slice(-t),n=i.slice(-o.length),r=this.currentTime();this.pointBuffer=new po(t),this.timestampBuffer=new po(t),o.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(n[e]??r)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:Pl(t.fitPadding)}:t}(t),i=this.config,o=this.getConfiguredWindowSize(),n=Object.keys(e).filter(t=>e[t]!==i[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==o;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(n,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],n=i.slice(-e),r=o.slice(-n.length),s=this.currentTime();this.pointBuffer=new po(e),this.timestampBuffer=new po(e),n.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??s)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();pn(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const i of t)pn(this.pointBuffer,i,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),n=[];return this.lineData=this.lineData.filter(t=>!o.has(i(t)+"")||(n.push(t),!1)),n.length>0?(this.version++,this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");yn(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(t){const e=this._customRestyle;if(e){for(const i of this.scene){const o=this._baseStyles.get(i)??i.style,n=e(i,t);i.style=n?{...o,...n}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,i=this.projection,o=this.geoPath,n=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return(0,nl.geoEqualEarth)();if("string"==typeof t){const e=rl[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),(0,nl.geoEqualEarth)())}if("object"==typeof t&&"type"in t){const e=rl[t.type],i=e?e():(0,nl.geoEqualEarth)();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=(0,il.geoPath)(this.projection),this.fitProjection(t),this.geoPath=(0,il.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(t,e)=>l([t,e]),invertedPoint:(t,e)=>l.invert?l.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=o,this.scales=n,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,i=this.config,o=[...this.areas],n=sl(i.xAccessor,"lon"),r=sl(i.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[n(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=al(i.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[n(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==o.length){if(i.projectionExtent){const[[o,n],[r,s]]=i.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,n],[r,n],[r,s],[o,s],[o,n]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const o=i.fitPadding??0,n=Math.min(t.width,t.height);e.scale(n/2-n*o),e.translate([t.width/2,t.height/2])}else{const n=i.fitPadding??0,r=t.width*n,s=t.height*n;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,n=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=(0,il.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,n=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=(0,il.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;if(!i||!i.rotate)return;const o=this.geoPath,n=this.scales,r=[...i.rotate()];i.rotate(t),this.geoPath=(0,il.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(r),this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,i=0;for(const t of this.scene)"point"===t.type&&(i++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);const o=Array(i);let n=0;for(const t of this.scene)"point"===t.type&&(o[n++]=t);this._quadtree=(0,ol.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,i=this.projection,o=this.geoPath;if(e.customLayout&&this.scales){const i=e.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Wi(e.colorScheme,e.themeCategorical,j),n={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:i,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...o]},resolveColor:Yi(o,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(n)}catch(t){const i=null!==this.lastCustomLayoutResult,o=sn("geo",t,i,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return i?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return on({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:t,projection:e,path:i,areas:o,points:n,lines:r,layout:s}){const a=sl(t.xAccessor,"lon"),c=sl(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,o=(0,_l.geoGraticule)();e.step&&o.step(e.step);const n=i(o())||"";n&&l.push({type:"geoarea",pathData:n,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of o){const o=i(e);if(!o)continue;const n=i.centroid(e),r=i.bounds(e),s=i.area(e);l.push({type:"geoarea",pathData:o,centroid:n,bounds:r,screenArea:s,style:cl(t.areaStyle,e,u),datum:e,interactive:!0})}const f=al(t.lineDataAccessor);for(const i of r){const o=f(i);if(!o||2>o.length)continue;let n=[];if("geo"===t.lineType){const t=Array(o.length);for(let e=0;o.length>e;e++)t[e]=[a(o[e]),c(o[e])];for(let i=0;t.length-1>i;i++){const o=t[i],r=t[i+1],s=(0,_l.geoDistance)(o,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,_l.geoInterpolate)(o,r);for(let t=0;a>=t;t++){if(i>0&&0===t)continue;const o=e(c(t/a));null!=o&&n.push(o)}}}else for(let t=0;o.length>t;t++){const i=o[t],r=e([a(i),c(i)]);null!=r&&n.push(r)}if(2>n.length)continue;const r=cl(t.lineStyle,i,h),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==o.length||2>n.length||"arc"!==t.flowStyle?2!==o.length||2>n.length||"offset"!==t.flowStyle||(n="geo"===t.lineType?hl(n,u):dl(n[0],n[n.length-1],0,0,u)):n=ul(n[0],n[n.length-1]);const d=ll(n,s.width);if(d.length>1)for(const t of d)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:i});else l.push({type:"line",path:2>n.length&&d[0]||n,style:r,datum:i})}const p=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,y=e.clipAngle?e.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=e.rotate?e.rotate():[0,0,0],x="function"==typeof e.center?e.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const i of n){const o=a(i),n=c(i);if(null!=g&&(0,_l.geoDistance)([o,n],b)>g)continue;const r=e([o,n]);if(!r)continue;const s=t.pointStyle?t.pointStyle(i):{...d},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:i,pointId:p?p(i)+"":void 0};l.push(u)}return l}({config:e,projection:i,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const i=function(t,e,i,o){const n=t.filter(t=>"point"===t.type);if(2>n.length)return null;const r=e.strength??1;if(0===r)return null;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,a="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=n.find(t=>t.datum&&s(t.datum)+""==e.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const l=c.x,u=c.y,h=xt(n.map(t=>t.datum?a(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),d=Math.min(i.width,i.height)/2,f=(0,fl.scaleLinear)().domain([0,h]).range([0,d]);o>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const i=t[e];"geoarea"===i.type&&i.interactive&&t.splice(e,1)}for(const t of n){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-u,t.x-l),i=Math.sqrt((t.x-l)**2+(t.y-u)**2),o=a(t.datum),n=i+((isFinite(o)?f(o):i)-i)*r;t.x=l+Math.cos(e)*n,t.y=u+Math.sin(e)*n}const p=i.width/2,y=i.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const t of n)t.x+=g,t.y+=m;const x={cx:p,cy:y,maxCost:h,availableRadius:d},b=t.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==e.lineMode){const t=new Map;for(const e of n)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const i=e.datum?.source,o=e.datum?.target;if(i&&o){const n=t.get(i+""),r=t.get(o+"");n&&r&&(e.path=[n,r])}}}return x}(this.scene,t,e,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const n=To(t,o,e);i[o]._decayOpacity=n,i[o].style={...i[o].style,opacity:n}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const i=this.scene.filter(t=>"point"===t.type),o=this.timestampBuffer.toArray(),n=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let s=!1;for(let a=0;i.length>a&&o.length>a;a++){const c=Lo(e,o[a],t);s=Co(i[a],c,n,r)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&$o(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const i=new Map;for(const e of t)"point"===e.type&&e.pointId&&i.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let n=!1;for(const t of o)if(t.pointId){const e=i.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(n=!0))}for(const t of o)t.pointId&&!i.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},n=!0);n&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=Mo(t,this.activeTransition),i=Ao(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=_o(t.x,t._targetX,i),t.y=_o(e,t._targetY,i)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*i})}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Tl.QUADTREE_THRESHOLD=500;var Rl=Tl;Sn(Rl);var Ll=require("react/jsx-runtime");function Cl(t,e){const i=io(t.theme),o=t.size||[t.width||600,t.height||400],n=Os({top:10,right:10,bottom:10,left:10,...t.margin},t.title),r=Is(t.title),s=Array.isArray(t.areas)?uo(t.areas):t.areas,a=uo(t.points),c=uo(t.lines),l=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;return wr(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof e?s.map(t=>({...t.properties||{},...t})):s:[],e)})():[],u=t.legendPosition;ao(t.legend)||co(t.legend)?Xs(n,{legend:t.legend,theme:i,position:u||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&l.length>0&&qs(n,{categories:l,colorScheme:t.colorScheme,theme:i,position:u||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const h=o[0]-(n.left??0)-(n.right??0),d=o[1]-(n.top??0)-(n.bottom??0),f={projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,themeCategorical:i.colors.categorical,themeSemantic:Ft(i)},p=new Rl(f);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);p.setAreas(s)}if(t.points&&p.setPoints(a),t.lines&&p.setLines(c),p.computeScene({width:h,height:d}),e&&(e.evidence=so({frameType:"geo",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,legendItems:l.length>0?l.length:void 0})),0===p.scene.length){const e=t.backgroundGraphics||t.foregroundGraphics||t.annotations||p.customLayoutOverlays?(0,Ll.jsxs)(Ll.Fragment,{children:[t.backgroundGraphics,t.annotations?js({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,t.foregroundGraphics,p.customLayoutOverlays]}):null;return el.renderToStaticMarkup(Hs(e,{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:h,innerHeight:d,idPrefix:t._idPrefix}))}const y=p.scene.map((e,i)=>ar({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"geoarea":{const i=t;if(!i.pathData)return null;const o=qn(i.style.fill)?Xn(i.style.fill,`geoarea-${e}-hatch`):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[o&&(0,Qn.jsx)("defs",{children:o}),(0,Qn.jsx)("path",{d:i.pathData,fill:o?`url(#geoarea-${e}-hatch)`:tr(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:i._decayOpacity??1})]},"geoarea-"+e)}case"point":{const i=t,o=qn(i.style.fill)?Xn(i.style.fill,`geopoint-${e}-hatch`):void 0;return(0,Qn.jsxs)(Bn.Fragment,{children:[o&&(0,Qn.jsx)("defs",{children:o}),(0,Qn.jsx)("circle",{cx:i.x,cy:i.y,r:i.r,fill:o?`url(#geopoint-${e}-hatch)`:tr(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+e)}case"line":{const i=t;if(2>i.path.length)return null;const o="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return(0,Qn.jsx)("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+e)}case"glyph":return ir(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(e,i)})).filter(Boolean),g=t.annotations?js({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,m=t.showLegend?0===l.length?null:vr({categories:l,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,x=tl.isValidElement(t.legend)?t.legend:Gs(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||m;return el.renderToStaticMarkup(Hs((0,Ll.jsxs)(Ll.Fragment,{children:[t.backgroundGraphics,y,g,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:h,innerHeight:d,legend:x,idPrefix:t._idPrefix}))}var $l=c(require("react-dom/server"));function jl(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}var zl={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function El(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function Dl(t,e){const i="function"==typeof e?e(t):e;return{...zl,...i??{}}}function Nl(t,e={}){return t.map(t=>function(t,e={}){const i=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),o={label:e.getBodyLabel?.(t)??El(t)},n={style:Dl(t,e.bodyStyle),datum:i,accessibleDatum:i,accessibility:o,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...n}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...n}}(t,e))}var Fl=require("react/jsx-runtime");function Il(t,e){const i=t.size??[t.width??600,t.height??400],o=new Mi(t.config);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&o.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const n=function(t,e={}){const{width:i=640,height:o=360,title:n,description:r,background:s,className:a,idPrefix:c="physics",...l}=e,u=function(t,e={}){const i=t.settle(e.maxSteps),o=t.readBodies(),n=t.snapshot(),r=Nl(o,e),s=function(t,e={}){const i=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),o=i.filter(t=>t.sleeping).length;return{bodyCount:i.length,sleepingCount:o,settled:"settled"===t.simulationState&&0===t.queue.length&&o===i.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:jl(e.projectionRows)}}(n,{bodies:o,projectionRows:e.projectionRows,stepsRun:i});return{snapshot:n,bodies:o,sceneNodes:r,evidence:s,stepsRun:i}}(t,l),h=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(c),d=n?h+"-title":void 0,f=r?h+"-desc":void 0,p=[d,f].filter(Boolean).join(" ")||void 0;return{svg:$l.renderToStaticMarkup((0,Fl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:i,height:o,viewBox:`0 0 ${i} ${o}`,role:"img","aria-labelledby":p,children:[n&&(0,Fl.jsx)("title",{id:d,children:n}),r&&(0,Fl.jsx)("desc",{id:f,children:r}),s&&"transparent"!==s?(0,Fl.jsx)("rect",{x:0,y:0,width:i,height:o,fill:s}):null,(0,Fl.jsx)("g",{id:h+"-data-area",children:u.sceneNodes.map((t,e)=>nr(t,e,h))})]})),scene:u,evidence:u.evidence}}(o,{...t,width:i[0],height:i[1],idPrefix:t.idPrefix??t._idPrefix??"physics"});return e&&(e.evidence=so({frameType:"physics",width:i[0],height:i[1],marks:n.scene.sceneNodes,title:t.title,description:t.description,annotations:[],extraWarnings:0===n.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),n.svg}var Ol=require("react/jsx-runtime");function Bl(t,e){switch(t){case"xy":return Ks(e);case"ordinal":return Aa(e);case"network":return Jc(e);case"geo":return Cl(e);case"physics":return Il(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Wl(t){return Ks(t)}function Yl(t){return Aa(t)}function ql(t){return Jc(t)}function Xl(t){return Cl(t)}var Gl=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Vl(t,e,i){return Zl(t,e).svg}function Hl(t,e,i){const o={},{svg:n,frameType:r}=Zl(t,e,0,o),s=o.evidence??so({frameType:r,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=t,{svg:n,evidence:s}}function Zl(t,e,i,o){const{data:n,width:r=600,height:s=400,theme:a,title:c,description:l,showLegend:h,showGrid:d,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=e,w=[r,s],k={...v.frameProps||{},...function(t,e){const i={};for(const o of e)void 0!==t[o]&&(i[o]=t[o]);return i}(v,Gl),theme:a,title:c,description:l,showLegend:h,showGrid:d,background:f,className:p,annotations:y,size:w,...void 0!==g&&{margin:g},...void 0!==m&&{colorScheme:m},...void 0!==b&&{legendPosition:b},_idPrefix:v._idPrefix},S=eo[t];if(!S)throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`);const A=S.buildProps(n,x,m,k,v);let M;switch(S.frameType){case"xy":M=Ks(A,o);break;case"ordinal":M=Aa(A,o);break;case"network":M=Jc(A,o);break;case"geo":M=Cl(A,o);break;case"physics":M=Il(A,o)}if("GaugeChart"===t&&A.__gauge){const t=A.__gauge,e=k.margin||{top:20,right:20,bottom:30,left:40},i=(r||300)-e.left-e.right,o=(s||300)-e.top-e.bottom,n=Math.min(i,o)/2*.85,c=e.left+i/2,l=e.top+o/2,h=(t.startAngleDeg+(t.gMax===t.gMin?0:(Math.max(t.gMin,Math.min(t.gMax,t.value??t.gMin))-t.gMin)/(t.gMax-t.gMin))*t.sweep-90)*Math.PI/180,d=io(a).colors.text,f=u.renderToStaticMarkup((0,Ol.jsxs)(Ol.Fragment,{children:[(0,Ol.jsx)("line",{x1:c,y1:l,x2:c+n*Math.cos(h),y2:l+n*Math.sin(h),stroke:d,strokeWidth:2.5,strokeLinecap:"round"}),(0,Ol.jsx)("circle",{cx:c,cy:l,r:4,fill:d})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}async function Kl(t,e,i={}){const{format:o="png",scale:n=1,background:r}=i;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?Bl(t,e):Vl(t,e),r&&(s=s.replace(/<svg /,`<svg style="background:${r}" `));try{const t="sharp",e=await import(t);a=e.default??e}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=e.width||e.size?.[0]||600,l=e.height||e.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*n}).resize(Math.round(c*n),Math.round(l*n));return"jpeg"===o?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function Ul(t,e={}){const{title:i,subtitle:o,theme:n,width:r=1200,height:s,layout:a={},background:c}=e,l=oo(io(n)),h=a.columns||2,d=a.gap??16;let f=0;i&&(f+=30),o&&(f+=20),f>0&&(f+=10);const p=Math.floor((r-d-d*(h-1))/h),y=[];let g=0,m=f+d,x=0;for(const e of t){const t=Math.min(e.colSpan||1,h),i=e.props.height||300;g+t>h&&(m+=x+d,g=0,x=0),y.push({chart:e,x:d/2+g*(p+d),y:m,w:p*t+d*(t-1),h:i}),x=Math.max(x,i),g+=t}const b=s||m+x+d,v=y.map((t,e)=>{const{chart:i,x:o,y:r,w:s,h:a}=t,c={...i.props,width:s,height:a,theme:n,_idPrefix:"chart-"+e};let l;return l=i.component?Vl(i.component,c):i.frameType?Bl(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Ol.jsx)("g",{transform:`translate(${o},${r})`,children:(0,Ol.jsx)("foreignObject",{width:s,height:a,children:(0,Ol.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+e)});return u.renderToStaticMarkup((0,Ol.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:b,role:"img","aria-label":i||"Dashboard",style:{fontFamily:l.fontFamily},children:[i&&(0,Ol.jsx)("title",{children:i}),c&&(0,Ol.jsx)("rect",{x:0,y:0,width:r,height:b,fill:c}),i&&(0,Ol.jsx)("text",{x:r/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:i}),o&&(0,Ol.jsx)("text",{x:r/2,y:i?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:o}),v]}))}var Ql=c(require("react-dom/server")),Jl=require("react/jsx-runtime");function tu(t,e,i,o={}){const{stepSize:n,windowSize:r,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,p=i.height||400,y=io(i.theme),g={...i,...a&&{xExtent:a},...c&&{yExtent:c}};if(!e||0===e.length)return[];const m=n||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),v=Os({top:20,right:20,bottom:30,left:40,...i.margin},i.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let o=0;x.length>o;o++){const n=x[o],s=e.slice(r?Math.max(0,n-r):0,n),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical,...d&&{decay:d}},c=new wa(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(su(c.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const n=x[o],s=e.slice(r?Math.max(0,n-r):0,n),m={chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...d&&{decay:d},...l>0&&{transition:{duration:l*(1e3/u),easing:h}}},b=new On(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(ru(b.scene,f,p,y,g,v)),l>0&&o>0&&b.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/l*t),S.push(ru(b.scene,f,p,y,g,v))}}return S}function eu(t,e,i={}){return e.map(e=>{try{return Vl(t,{...i,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function iu(t,e,i){const o=e.size??[e.width??600,e.height??400],n=io(e.theme),r=oo(n),s=e.background||n.colors.background,a=e.idPrefix??"physics-gif",c=e.title?`${a}-title-${i}`:void 0,l=e.description?`${a}-desc-${i}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,h=Nl(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),d=(0,Jl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:r.fontFamily},children:[e.title&&(0,Jl.jsx)("title",{id:c,children:e.title}),e.description&&(0,Jl.jsx)("desc",{id:l,children:e.description}),s&&"transparent"!==s?(0,Jl.jsx)("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,(0,Jl.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((t,e)=>nr(t,e,`${a}-${i}`))})]});return Ql.renderToStaticMarkup(d)}function ou(t,e={}){const{fps:i=12,frameCount:o,durationSeconds:n=2,includeInitialFrame:r=!0,stepDt:s,stepsPerFrame:a,background:c}=e,l=Math.max(.001,s??t.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,i)/l)),h=o??Math.max(1,Math.ceil(n*Math.max(1,i))),d=c?{...t,background:c}:t,f=new Mi(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push(iu(f,d,0)));h>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(iu(f,d,p.length))}return p}function nu(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function ru(t,e,i,o,n,r){const s=oo(o),a=Os({top:20,right:20,bottom:30,left:40,...n.margin},n.title),c=e-a.left-a.right,l=i-a.top-a.bottom,u=nu(n,o),h=n.renderMode,d=t.map((t,e)=>ar({node:t,index:e,renderMode:h,fallback:()=>nr(t,e)})).filter(Boolean),f=function(t,e,i,o,n,r){if(!t||0===t.length)return null;const s=oo(o),a=[];for(let o=0;t.length>o;o++){const c=t[o];if("y-threshold"===c.type&&null!=c.value){let t=null;if(r)t=r(c.value);else if(n){const[e,o]=n,r=o-e;if(0===r)continue;t=i-(c.value-e)/r*i}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,Jl.jsxs)("g",{children:[(0,Jl.jsx)("line",{x1:0,y1:t,x2:e,y2:t,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,Jl.jsx)("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(i-4,t+16):t-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+o))}}return a.length>0?(0,Jl.jsx)(Jl.Fragment,{children:a}):null}(n.annotations,c,l,o,n.yExtent,r?.y),p="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return Ql.renderToStaticMarkup((0,Jl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,Jl.jsx)("title",{id:g,children:p}),y&&(0,Jl.jsx)("desc",{id:m,children:y}),u&&(0,Jl.jsx)("rect",{x:0,y:0,width:e,height:i,fill:u}),(0,Jl.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,d]}),p&&(0,Jl.jsx)("text",{x:e/2,y:Fs,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function su(t,e,i,o,n){const r=oo(o),s=Os({top:20,right:20,bottom:30,left:40,...n.margin},n.title),a="radial"===n.projection,c=a?s.left+(e-s.left-s.right)/2:s.left,l=a?s.top+(i-s.top-s.bottom)/2:s.top,u=nu(n,o),h=n.renderMode,d=t.map((t,e)=>ar({node:t,index:e,renderMode:h,fallback:()=>rr(t,e)})).filter(Boolean),f="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return Ql.renderToStaticMarkup((0,Jl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[f&&(0,Jl.jsx)("title",{id:y,children:f}),p&&(0,Jl.jsx)("desc",{id:g,children:p}),u&&(0,Jl.jsx)("rect",{x:0,y:0,width:e,height:i,fill:u}),(0,Jl.jsx)("g",{transform:`translate(${c},${l})`,children:d}),f&&(0,Jl.jsx)("text",{x:e/2,y:Fs,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:f})]}))}async function au(t,e,i,o={}){const{fps:n=12,loop:r=!0,scale:s=1,background:a}=o,c=i.width||600,l=i.height||400,u=tu(t,e,a?{...i,background:a}:i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return lu(u,c,l,{fps:n,loop:r,scale:s})}async function cu(t,e={}){const{fps:i=12,loop:o=!0,scale:n=1}=e,r=t.size??[t.width??600,t.height??400],s=ou(t,e);if(0===s.length)throw Error("No physics frames generated");return lu(s,r[0],r[1],{fps:i,loop:o,scale:n})}async function lu(t,e,i,o={}){const{fps:n=12,loop:r=!0,scale:s=1}=o,a=Math.round(e*s),c=Math.round(i*s);let l,u,h,d;try{const t="sharp",e=await import(t);l=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await import(t),i=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!i)throw Error("gifenc did not expose its encoder functions");u=i.GIFEncoder,h=i.quantize,d=i.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:t})}const f=Math.round(1e3/n),p=u();for(let e=0;t.length>e;e++){const i=t[e],o=await l(Buffer.from(i),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),n=new Uint8Array(o),u=h(n,256),y=d(n,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|