semiotic 3.9.1 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -58
- package/agent-skill/semiotic-charts/SKILL.md +27 -17
- package/ai/artifact-contract-reference.md +408 -0
- package/ai/artifact-surface-inventory.json +5586 -0
- package/ai/behaviorContracts.cjs +24 -2
- package/ai/cli.js +480 -56
- package/ai/componentMetadata.cjs +13 -3
- package/ai/dist/mcp-server.js +140 -36407
- package/ai/examples.md +110 -7
- package/ai/reference.md +82 -28
- package/ai/schema.json +7675 -1471
- package/ai/surface-manifest.json +60 -9
- package/ai/system-prompt.md +18 -3
- package/ai/task-packets/compare-category-totals.json +301 -0
- package/ai/task-packets/compare-category-totals.md +188 -0
- package/ai/task-packets/correct-published-chart.json +271 -0
- package/ai/task-packets/correct-published-chart.md +597 -0
- package/ai/task-packets/index.json +40 -0
- package/ai/task-packets/update-live-chart.json +289 -0
- package/ai/task-packets/update-live-chart.md +424 -0
- package/dist/c-2N7IU2NY.min.js +1 -0
- package/dist/c-2WK7YJLL.min.js +1 -0
- package/dist/c-33QOXEUG.min.js +1 -0
- package/dist/c-42PLDTX7.min.js +1 -0
- package/dist/c-447VIMRO.min.js +1 -0
- package/dist/c-4FN7Q6VQ.min.js +1 -0
- package/dist/c-553QUDKA.min.js +1 -0
- package/dist/c-55BAJ333.min.js +1 -0
- package/dist/c-7242NXSG.min.js +1 -0
- package/dist/c-7EGHJU2F.min.js +1 -0
- package/dist/c-7HP7MB2I.min.js +1 -0
- package/dist/c-7NBU5ZKS.min.js +1 -0
- package/dist/c-AFBSWT77.min.js +1 -0
- package/dist/c-AJ7EC32V.min.js +1 -0
- package/dist/c-AQADQNY7.min.js +1 -0
- package/dist/c-ATM475SA.min.js +1 -0
- package/dist/c-AVO3Q7T7.min.js +1 -0
- package/dist/c-AZKPVBOC.min.js +1 -0
- package/dist/c-BNFJMDHN.min.js +1 -0
- package/dist/c-BNG5ECK5.min.js +1 -0
- package/dist/c-BOHCQILI.min.js +1 -0
- package/dist/c-CCTGN5CK.min.js +1 -0
- package/dist/c-CPSPZH6A.min.js +1 -0
- package/dist/c-CPV4N35K.min.js +1 -0
- package/dist/c-D6HAAPTX.min.js +1 -0
- package/dist/c-DE5Q3U2X.min.js +1 -0
- package/dist/c-DK662R77.min.js +1 -0
- package/dist/c-DY2676CR.min.js +1 -0
- package/dist/c-E32M6XW5.min.js +1 -0
- package/dist/c-E4JDJH4I.min.js +1 -0
- package/dist/c-E7I2L7CU.min.js +1 -0
- package/dist/c-EBOQ7ER7.min.js +1 -0
- package/dist/c-ELDWAO2V.min.js +1 -0
- package/dist/c-EUBTECGM.min.js +1 -0
- package/dist/c-GNTXRXRN.min.js +1 -0
- package/dist/c-GSZRZRD6.min.js +1 -0
- package/dist/c-GWX7JGMF.min.js +1 -0
- package/dist/c-GXV3C3MO.min.js +1 -0
- package/dist/c-HHTK2R75.min.js +1 -0
- package/dist/c-HLLFJYTY.min.js +1 -0
- package/dist/c-HPOYKCCG.min.js +1 -0
- package/dist/c-HXDKPIKR.min.js +1 -0
- package/dist/c-I4QJ6YLM.min.js +1 -0
- package/dist/c-IDJV3CZK.min.js +1 -0
- package/dist/c-ITKX3RC5.min.js +1 -0
- package/dist/c-JG2JCQLP.min.js +1 -0
- package/dist/c-JLGRHXGZ.min.js +1 -0
- package/dist/c-JO2UGTCP.min.js +1 -0
- package/dist/c-JUKIWTBJ.min.js +1 -0
- package/dist/c-KCRJGUHP.min.js +1 -0
- package/dist/c-LMGSSD2E.min.js +1 -0
- package/dist/c-LYQMZMZQ.min.js +1 -0
- package/dist/c-LYVKDBQJ.min.js +1 -0
- package/dist/c-MVR3RWF3.min.js +1 -0
- package/dist/c-MXCP7GNZ.min.js +1 -0
- package/dist/c-NG7BLZTR.min.js +1 -0
- package/dist/c-NYZ2QNAM.min.js +1 -0
- package/dist/c-OO5QLMJC.min.js +1 -0
- package/dist/c-OOVX2JPQ.min.js +1 -0
- package/dist/c-ORLEBW72.min.js +1 -0
- package/dist/c-P65V6HLO.min.js +1 -0
- package/dist/c-PP6VY3QU.min.js +1 -0
- package/dist/c-PRIKOLTE.min.js +1 -0
- package/dist/c-PSNI6KAZ.min.js +1 -0
- package/dist/c-PYNW54D2.min.js +1 -0
- package/dist/c-QA3HMQJP.min.js +1 -0
- package/dist/c-QAVFOEUY.min.js +1 -0
- package/dist/c-ROEHCIGV.min.js +1 -0
- package/dist/c-S3AZX5PP.min.js +1 -0
- package/dist/c-T2V7O2LO.min.js +1 -0
- package/dist/c-TIXX5CAU.min.js +1 -0
- package/dist/c-TKG2NP7G.min.js +1 -0
- package/dist/c-VJTDST2R.min.js +1 -0
- package/dist/c-VXLOLYTO.min.js +1 -0
- package/dist/c-W4ZUKSEQ.min.js +1 -0
- package/dist/c-WH2O53VI.min.js +1 -0
- package/dist/c-WNGH47HF.min.js +1 -0
- package/dist/c-WUWXGQYA.min.js +1 -0
- package/dist/c-XDQKXPX4.min.js +1 -0
- package/dist/c-XSB27XPS.min.js +1 -0
- package/dist/c-YDECTEUW.min.js +1 -0
- package/dist/c-YF3YKVQI.min.js +1 -0
- package/dist/c-YLZIV3VS.min.js +1 -0
- package/dist/c-ZYPXQF7B.min.js +1 -0
- package/dist/components/Annotation.d.ts +3 -2
- package/dist/components/access/chartAccessCapabilities.generated.d.ts +14 -0
- package/dist/components/access/chartAccessContract.d.ts +90 -0
- package/dist/components/access/chartAccessContractFixtures.d.ts +11 -0
- package/dist/components/ai/aestheticProfileTypes.d.ts +35 -0
- package/dist/components/ai/annotationProvenance.d.ts +2 -7
- package/dist/components/ai/auditVisualHierarchy.d.ts +49 -0
- package/dist/components/ai/builtInChartRecipeLayouts.d.ts +2 -0
- package/dist/components/ai/builtInChartRecipePublic.d.ts +4 -0
- package/dist/components/ai/builtInChartRecipes.d.ts +26 -0
- package/dist/components/ai/chartCapabilities.d.ts +3 -1
- package/dist/components/ai/chartRecipeRegistry.d.ts +7 -1
- package/dist/components/ai/chartRecipes.d.ts +10 -0
- package/dist/components/ai/colorEvidence.d.ts +12 -0
- package/dist/components/ai/describePhysicsProjection.d.ts +18 -0
- package/dist/components/ai/describePhysicsSource.d.ts +13 -0
- package/dist/components/ai/evaluateAesthetics.d.ts +47 -0
- package/dist/components/ai/geoNavigation.d.ts +4 -0
- package/dist/components/ai/hierarchyNavigation.d.ts +4 -0
- package/dist/components/ai/navigationTree.d.ts +7 -1
- package/dist/components/ai/qualityFixtures.d.ts +8 -0
- package/dist/components/ai/suggestionPropContracts.d.ts +1 -1
- package/dist/components/ai/useNavigationSync.d.ts +3 -3
- package/dist/components/artifact/ArtifactInspector.d.ts +26 -0
- package/dist/components/artifact/ArtifactInspectorContextSections.d.ts +18 -0
- package/dist/components/artifact/artifactContractDiff.d.ts +8 -0
- package/dist/components/artifact/artifactInspectorSummary.d.ts +53 -0
- package/dist/components/artifact/artifactRevision.d.ts +54 -0
- package/dist/components/artifact/artifactTestFixtures.d.ts +17 -0
- package/dist/components/artifact/attachmentAudit.d.ts +13 -0
- package/dist/components/artifact/claimCorrections.d.ts +3 -0
- package/dist/components/artifact/claimGraph.d.ts +5 -0
- package/dist/components/artifact/claimLifecycle.d.ts +32 -0
- package/dist/components/artifact/claims.d.ts +24 -0
- package/dist/components/artifact/collection.d.ts +10 -0
- package/dist/components/artifact/collectionCorrectionScope.d.ts +4 -0
- package/dist/components/artifact/collectionImpact.d.ts +11 -0
- package/dist/components/artifact/collectionLineage.d.ts +3 -0
- package/dist/components/artifact/collectionOperations.d.ts +8 -0
- package/dist/components/artifact/collectionPolicy.d.ts +22 -0
- package/dist/components/artifact/collectionTypes.d.ts +117 -0
- package/dist/components/artifact/configurationRepair.d.ts +8 -0
- package/dist/components/artifact/contract.d.ts +30 -0
- package/dist/components/artifact/evaluateArtifact.d.ts +12 -0
- package/dist/components/artifact/evaluateArtifactTypes.d.ts +78 -0
- package/dist/components/artifact/evaluationPresentation.d.ts +9 -0
- package/dist/components/artifact/evidenceSample.d.ts +8 -0
- package/dist/components/artifact/exportPaths.d.ts +8 -0
- package/dist/components/artifact/fieldPolicies.d.ts +12 -0
- package/dist/components/artifact/fingerprint.d.ts +36 -0
- package/dist/components/artifact/grounding.d.ts +51 -0
- package/dist/components/artifact/groundingBudget.d.ts +38 -0
- package/dist/components/artifact/hostTransfer.d.ts +13 -0
- package/dist/components/artifact/identity.d.ts +19 -0
- package/dist/components/artifact/inheritance.d.ts +48 -0
- package/dist/components/artifact/inheritanceIntegrity.d.ts +3 -0
- package/dist/components/artifact/jsonCompatibility.d.ts +2 -0
- package/dist/components/artifact/obligations.d.ts +3 -0
- package/dist/components/artifact/policies.d.ts +45 -0
- package/dist/components/artifact/policyRelations.d.ts +3 -0
- package/dist/components/artifact/recordProjection.d.ts +7 -0
- package/dist/components/artifact/representation.d.ts +50 -0
- package/dist/components/artifact/serialization.d.ts +40 -0
- package/dist/components/artifact/temporal.d.ts +32 -0
- package/dist/components/artifact/temporalAdapters.d.ts +75 -0
- package/dist/components/artifact/temporalAuditHelpers.d.ts +12 -0
- package/dist/components/artifact/temporalPresentation.d.ts +8 -0
- package/dist/components/artifact/types.d.ts +341 -0
- package/dist/components/artifact/validation.d.ts +13 -0
- package/dist/components/artifact/validationFieldStatus.d.ts +7 -0
- package/dist/components/artifact/validationPrimitives.d.ts +24 -0
- package/dist/components/artifact/validationSurfaces.d.ts +7 -0
- package/dist/components/artifact/validationTemporal.d.ts +3 -0
- package/dist/components/charts/geo/FlowMap.d.ts +7 -0
- package/dist/components/charts/geo/flowMapLineStyle.d.ts +18 -0
- package/dist/components/charts/index.d.ts +4 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +5 -1
- package/dist/components/charts/network/CirclePack.d.ts +8 -1
- package/dist/components/charts/network/OrbitDiagram.d.ts +9 -0
- package/dist/components/charts/network/TreeDiagram.d.ts +8 -1
- package/dist/components/charts/network/Treemap.d.ts +8 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +6 -0
- package/dist/components/charts/ordinal/BoxPlot.d.ts +3 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +5 -0
- package/dist/components/charts/ordinal/DotPlot.d.ts +3 -0
- package/dist/components/charts/ordinal/FunnelChart.d.ts +5 -0
- package/dist/components/charts/ordinal/GaugeChart.d.ts +3 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +6 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +3 -0
- package/dist/components/charts/ordinal/LikertChart.d.ts +3 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +5 -0
- package/dist/components/charts/ordinal/RadarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/RadarChart.d.ts +77 -0
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +3 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +6 -0
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +3 -0
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +3 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +3 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
- package/dist/components/charts/physics/EventDropChart.d.ts +3 -1
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +4 -2
- package/dist/components/charts/physics/GauntletChart.d.ts +1 -5
- package/dist/components/charts/physics/ProcessFlowChart.d.ts +6 -0
- package/dist/components/charts/physics/UnitPileChart.d.ts +2 -1
- package/dist/components/charts/physics/chainReactionTypes.d.ts +3 -0
- package/dist/components/charts/physics/collisionSwarmPacking.d.ts +14 -0
- package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +1 -0
- package/dist/components/charts/physics/eventDropAdmission.d.ts +32 -0
- package/dist/components/charts/physics/eventDropPhysics.d.ts +22 -1
- package/dist/components/charts/physics/galtonBoardPhysics.d.ts +2 -9
- package/dist/components/charts/physics/gauntletPhysics.d.ts +1 -0
- package/dist/components/charts/physics/physicsChartReconcile.d.ts +4 -0
- package/dist/components/charts/physics/physicsChartUtils.d.ts +1 -1
- package/dist/components/charts/physics/physicsGaltonData.d.ts +10 -0
- package/dist/components/charts/physics/physicsHocHandle.d.ts +2 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +7 -1
- package/dist/components/charts/physics/physicsPileData.d.ts +11 -0
- package/dist/components/charts/physics/physicsPilePhysics.d.ts +5 -12
- package/dist/components/charts/physics/physicsProjectionOverlays.d.ts +1 -1
- package/dist/components/charts/physics/physicsSourceRows.d.ts +8 -0
- package/dist/components/charts/physics/usePhysicsChartData.d.ts +19 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +14 -1
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +25 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +18 -5
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +11 -1
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +11 -1
- package/dist/components/charts/realtime/aggregate.d.ts +12 -1
- package/dist/components/charts/realtime/realtimeAccessors.d.ts +4 -0
- package/dist/components/charts/realtime/realtimeChartRuntime.d.ts +8 -5
- package/dist/components/charts/realtime/realtimeChartTypes.d.ts +7 -0
- package/dist/components/charts/realtime/realtimeStyleRules.d.ts +4 -0
- package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +17 -11
- package/dist/components/charts/shared/GaugeReadout.d.ts +9 -0
- package/dist/components/charts/shared/ThresholdAnnotation.d.ts +18 -0
- package/dist/components/charts/shared/ThresholdEndCap.d.ts +7 -0
- package/dist/components/charts/shared/annotationStatusFilter.d.ts +18 -0
- package/dist/components/charts/shared/auditAccessibilityText.d.ts +4 -2
- package/dist/components/charts/shared/chartDefinitionPilot.d.ts +5 -4
- package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
- package/dist/components/charts/shared/heatmapStyleRules.d.ts +13 -0
- package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
- package/dist/components/charts/shared/networkUtils.d.ts +14 -0
- package/dist/components/charts/shared/numericTickFormatter.d.ts +2 -0
- package/dist/components/charts/shared/radialCenterContent.d.ts +10 -0
- package/dist/components/charts/shared/selectionUtils.d.ts +3 -1
- package/dist/components/charts/shared/tooltipUtils.d.ts +1 -1
- package/dist/components/charts/shared/types.d.ts +4 -2
- package/dist/components/charts/shared/useChartLegend.d.ts +6 -1
- package/dist/components/charts/shared/useLikertAggregation.d.ts +8 -2
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +9 -5
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +1 -1
- package/dist/components/charts/shared/useXYBrush.d.ts +24 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +2 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +7 -0
- package/dist/components/charts/xy/CandlestickChart.d.ts +7 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +7 -0
- package/dist/components/charts/xy/Heatmap.d.ts +16 -0
- package/dist/components/charts/xy/LineChart.d.ts +9 -0
- package/dist/components/charts/xy/MinimapChart.d.ts +7 -0
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +7 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +7 -0
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +6 -0
- package/dist/components/charts/xy/WaterfallChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/WaterfallChart.d.ts +76 -0
- package/dist/components/charts/xy/differenceMarkStyle.d.ts +28 -0
- package/dist/components/charts/xy/multiAxisFields.d.ts +23 -0
- package/dist/components/charts/xy/scatterplotMatrixCells.d.ts +50 -0
- package/dist/components/evidence/chartEvidenceEnvelope.d.ts +154 -0
- package/dist/components/evidence/evidenceEnvelopeInput.d.ts +8 -0
- package/dist/components/evidence/evidenceEnvelopeValidation.d.ts +11 -0
- package/dist/components/evidence/evidenceGate.d.ts +30 -0
- package/dist/components/evidence/renderedSceneHash.d.ts +23 -0
- package/dist/components/evidence/stableJsonHash.d.ts +4 -0
- package/dist/components/export/chartConfig.d.ts +40 -5
- package/dist/components/export/chartConfigArtifact.d.ts +6 -0
- package/dist/components/legendLayout.d.ts +18 -0
- package/dist/components/legendStyles.d.ts +4 -0
- package/dist/components/realtime/BinAccumulator.d.ts +5 -1
- package/dist/components/realtime/types.d.ts +16 -7
- package/dist/components/recipes/adjacencyFlow.d.ts +12 -0
- package/dist/components/recipes/adjacencyFlowAggregation.d.ts +72 -0
- package/dist/components/recipes/adjacencyFlowGeometry.d.ts +79 -0
- package/dist/components/recipes/firstAvailableTrack.d.ts +17 -0
- package/dist/components/recipes/intervals.d.ts +1 -1
- package/dist/components/recipes/lineageDag.d.ts +17 -0
- package/dist/components/recipes/lineageDagHulls.d.ts +22 -0
- package/dist/components/recipes/transitDiagram.d.ts +75 -0
- package/dist/components/recipes/transitDiagramGeometry.d.ts +47 -0
- package/dist/components/semiotic-access.d.ts +9 -0
- package/dist/components/semiotic-ai-audits.d.ts +17 -0
- package/dist/components/semiotic-ai-core.d.ts +38 -18
- package/dist/components/semiotic-ai.d.ts +20 -20
- package/dist/components/semiotic-artifact-react.d.ts +10 -0
- package/dist/components/semiotic-artifact.d.ts +23 -0
- package/dist/components/semiotic-evidence.d.ts +10 -0
- package/dist/components/semiotic-experimental.d.ts +1 -1
- package/dist/components/semiotic-line.d.ts +9 -0
- package/dist/components/semiotic-network.d.ts +3 -0
- package/dist/components/semiotic-ordinal.d.ts +2 -0
- package/dist/components/semiotic-physics.d.ts +4 -4
- package/dist/components/semiotic-realtime-core.d.ts +3 -2
- package/dist/components/semiotic-recipes-core.d.ts +6 -0
- package/dist/components/semiotic-text.d.ts +2 -0
- package/dist/components/semiotic-themes-core.d.ts +3 -0
- package/dist/components/semiotic-utils-core.d.ts +19 -14
- package/dist/components/semiotic-xy.d.ts +3 -0
- package/dist/components/semiotic.d.ts +11 -5
- package/dist/components/server/renderDashboard.d.ts +37 -0
- package/dist/components/server/renderEvidence.d.ts +39 -0
- package/dist/components/server/renderToStaticSVG.d.ts +5 -30
- package/dist/components/server/serverChartConfigShared.d.ts +13 -0
- package/dist/components/server/serverChartConfigs.d.ts +9 -0
- package/dist/components/server/serverChartConfigsComposite.d.ts +4 -0
- package/dist/components/server/serverChartConfigsCustom.d.ts +2 -0
- package/dist/components/server/serverChartConfigsGeo.d.ts +1 -0
- package/dist/components/server/serverChartConfigsOrdinal.d.ts +3 -2
- package/dist/components/server/serverChartConfigsXY.d.ts +1 -0
- package/dist/components/server/serverChartConfigsXYExtra.d.ts +3 -0
- package/dist/components/server/serverCompositeChainReaction.d.ts +3 -0
- package/dist/components/server/serverOrdinalGauge.d.ts +3 -0
- package/dist/components/server/serverOrdinalLikert.d.ts +2 -0
- package/dist/components/server/staticSVGChrome.d.ts +1 -4
- package/dist/components/server/staticXYAxisTicks.d.ts +2 -38
- package/dist/components/server/staticXYGrid.d.ts +1 -1
- package/dist/components/server/svgSizing.d.ts +6 -0
- package/dist/components/shared/svgRoot.d.ts +17 -0
- package/dist/components/store/selectionProvenance.d.ts +14 -0
- package/dist/components/store/themeCore.d.ts +5 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +1 -1
- package/dist/components/stream/GeoSVGOverlay.d.ts +4 -0
- package/dist/components/stream/MarginalGraphics.d.ts +3 -3
- package/dist/components/stream/MarginalGraphicsLazy.d.ts +22 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +2 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +1 -1
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +4 -0
- package/dist/components/stream/PipelineStore.d.ts +1 -1
- package/dist/components/stream/SVGOverlay.d.ts +4 -0
- package/dist/components/stream/SceneToSVG.d.ts +4 -19
- package/dist/components/stream/SceneToSVGXY.d.ts +13 -0
- package/dist/components/stream/StreamGeoFrame.d.ts +1 -2
- package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -2
- package/dist/components/stream/XYGrid.d.ts +11 -0
- package/dist/components/stream/axisTickUtils.d.ts +0 -1
- package/dist/components/stream/canvasSetup.d.ts +8 -2
- package/dist/components/stream/customLayoutAttempt.d.ts +21 -0
- package/dist/components/stream/geoTypes.d.ts +1 -1
- package/dist/components/stream/hitTestUtils.d.ts +2 -0
- package/dist/components/stream/isServerEnvironment.d.ts +6 -0
- package/dist/components/stream/layouts/forceLayoutNodeSize.d.ts +12 -0
- package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +2 -9
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +2 -21
- package/dist/components/stream/layouts/forceLayoutWorkerPolicy.d.ts +21 -0
- package/dist/components/stream/layouts/index.d.ts +6 -12
- package/dist/components/stream/layouts/missingPlugin.d.ts +7 -0
- package/dist/components/stream/layouts/registerBuiltIn.d.ts +1 -0
- package/dist/components/stream/layouts/registry.d.ts +12 -0
- package/dist/components/stream/marginalConfig.d.ts +3 -0
- package/dist/components/stream/networkCustomLayout.d.ts +7 -0
- package/dist/components/stream/networkCustomLayoutOutput.d.ts +13 -0
- package/dist/components/stream/networkCustomLayoutRunner.d.ts +1 -1
- package/dist/components/stream/networkTypes.d.ts +5 -1
- package/dist/components/stream/ordinalTypes.d.ts +1 -1
- package/dist/components/stream/overlayAccessibleText.d.ts +18 -0
- package/dist/components/stream/physics/PhysicsControllers.d.ts +1 -1
- package/dist/components/stream/physics/PhysicsKernel.d.ts +9 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +5 -4
- package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +9 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +4 -1
- package/dist/components/stream/physics/physicsCanvasCoordinates.d.ts +5 -0
- package/dist/components/stream/physics/physicsFixedPosition.d.ts +16 -0
- package/dist/components/stream/physics/physicsKernelCloning.d.ts +6 -0
- package/dist/components/stream/physics/physicsPipelineObservations.d.ts +2 -0
- package/dist/components/stream/physics/physicsPipelineSettle.d.ts +15 -9
- package/dist/components/stream/physics/physicsRegionRuntime.d.ts +8 -17
- package/dist/components/stream/physics/physicsSemanticUI.d.ts +9 -0
- package/dist/components/stream/pipelineConfig.d.ts +4 -0
- package/dist/components/stream/pipelineDomainResolution.d.ts +6 -0
- package/dist/components/stream/pipelineStoreUpdateResults.d.ts +1 -1
- package/dist/components/stream/renderers/pointCanvasRenderer.d.ts +4 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +4 -4
- package/dist/components/stream/resolveXYAxes.d.ts +13 -0
- package/dist/components/stream/sceneToSVGShared.d.ts +2 -1
- package/dist/components/stream/seriesGeometry.d.ts +13 -0
- package/dist/components/stream/streamEncodingTypes.d.ts +53 -0
- package/dist/components/stream/types.d.ts +12 -54
- package/dist/components/stream/useEnsureCustomXYRenderers.d.ts +18 -0
- package/dist/components/stream/useGeoFrameHandle.d.ts +16 -0
- package/dist/components/stream/useMarginalValues.d.ts +13 -0
- package/dist/components/stream/useOrdinalFrameHandle.d.ts +15 -0
- package/dist/components/stream/useXYFrameHandle.d.ts +15 -0
- package/dist/components/stream/xyAxisTicks.d.ts +25 -0
- package/dist/components/stream/xyCanvasRenderers.d.ts +4 -4
- package/dist/components/stream/xyDateTicks.d.ts +3 -2
- package/dist/components/stream/xyFrameAxisTypes.d.ts +2 -0
- package/dist/components/stream/xyPlugins/areaPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/barPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/candlestickPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/customPlugin.d.ts +6 -0
- package/dist/components/stream/xyPlugins/heatmapPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/lineFamily.d.ts +5 -0
- package/dist/components/stream/xyPlugins/linePlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/missingPlugin.d.ts +7 -0
- package/dist/components/stream/xyPlugins/mixedPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/pointPlugin.d.ts +3 -0
- package/dist/components/stream/xyPlugins/registerBuiltIn.d.ts +1 -0
- package/dist/components/stream/xyPlugins/registry.d.ts +31 -0
- package/dist/components/stream/xyPlugins/stackedAreaPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/swarmPlugin.d.ts +2 -0
- package/dist/components/stream/xyPlugins/waterfallPlugin.d.ts +2 -0
- package/dist/components/stream/xySceneBuilders/ribbonScene.d.ts +1 -1
- package/dist/components/stream/xySceneBuilders/types.d.ts +1 -0
- package/dist/components/text/annotationTextLayout.d.ts +28 -0
- package/dist/components/text/pretextAnnotationLayout.d.ts +29 -0
- package/dist/components/text/usePretextAnnotations.d.ts +12 -0
- 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.module.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.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/processSankeyLayoutWorker.js +1 -1
- package/dist/rough.min.js +1 -1
- package/dist/rough.module.min.js +1 -1
- package/dist/semiotic-access.d.ts +9 -0
- package/dist/semiotic-access.min.js +2 -0
- package/dist/semiotic-access.module.min.js +2 -0
- package/dist/semiotic-ai-artifact-policy-constants.module.min.js +2 -0
- package/dist/semiotic-ai-core.d.ts +38 -18
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai-hash-primitives.module.min.js +2 -0
- package/dist/semiotic-ai.d.ts +20 -20
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-artifact-react.d.ts +10 -0
- package/dist/semiotic-artifact-react.min.js +2 -0
- package/dist/semiotic-artifact-react.module.min.js +2 -0
- package/dist/semiotic-artifact.d.ts +23 -0
- package/dist/semiotic-artifact.min.js +1 -0
- package/dist/semiotic-artifact.module.min.js +1 -0
- package/dist/semiotic-client-cjs-shared.min.js +1 -1
- package/dist/semiotic-client-glyph.module.min.js +1 -1
- package/dist/semiotic-client-responsive.module.min.js +1 -1
- package/dist/semiotic-client-shared.module.min.js +1 -1
- package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +1 -1
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-evidence.d.ts +10 -0
- package/dist/semiotic-evidence.min.js +1 -0
- package/dist/semiotic-evidence.module.min.js +1 -0
- package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
- package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.min.js +1 -1
- package/dist/semiotic-experimental-vacp.module.min.js +1 -1
- package/dist/semiotic-experimental.d.ts +1 -1
- package/dist/semiotic-line.d.ts +9 -0
- package/dist/semiotic-line.min.js +2 -0
- package/dist/semiotic-line.module.min.js +2 -0
- package/dist/semiotic-network.d.ts +3 -0
- package/dist/semiotic-ordinal.d.ts +2 -0
- package/dist/semiotic-physics.d.ts +4 -4
- package/dist/semiotic-realtime-core.d.ts +3 -2
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-realtime-react.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +6 -0
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes-geo-cjs.min.js +1 -1
- package/dist/semiotic-recipes-react.min.js +1 -1
- package/dist/semiotic-server-edge-node.module.min.js +1 -1
- 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-text.d.ts +2 -0
- package/dist/semiotic-text.min.js +2 -0
- package/dist/semiotic-text.module.min.js +2 -0
- package/dist/semiotic-themes-core.d.ts +3 -0
- package/dist/semiotic-themes-core.min.js +1 -1
- package/dist/semiotic-themes-core.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 +19 -14
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +3 -0
- package/dist/semiotic.d.ts +11 -5
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +91 -71
- package/spec/README.md +8 -3
- package/spec/v0.1/artifact-contract.schema.json +2299 -0
- package/spec/v0.1/examples/artifact-contract-full.json +369 -0
- package/spec/v0.1/examples/artifact-contract-unknown-state.json +46 -0
- package/dist/c-3BLJEQNG.min.js +0 -1
- package/dist/c-3KZD6AXJ.min.js +0 -1
- package/dist/c-4TWEX5HG.min.js +0 -1
- package/dist/c-52TEGIUJ.min.js +0 -1
- package/dist/c-5YCIX3VZ.min.js +0 -1
- package/dist/c-6FEKTA3U.min.js +0 -1
- package/dist/c-6O5EVOPH.min.js +0 -1
- package/dist/c-74HEEZGK.min.js +0 -1
- package/dist/c-AKAF6JAD.min.js +0 -1
- package/dist/c-BBKITSXB.min.js +0 -1
- package/dist/c-BWNB6USU.min.js +0 -1
- package/dist/c-C25ENHIK.min.js +0 -1
- package/dist/c-CDR5AO3R.min.js +0 -1
- package/dist/c-COHXCW3Q.min.js +0 -1
- package/dist/c-DADXPJXV.min.js +0 -1
- package/dist/c-E3JFRRMI.min.js +0 -1
- package/dist/c-EBFPQHHO.min.js +0 -1
- package/dist/c-G36WS6LN.min.js +0 -1
- package/dist/c-GGISSW5E.min.js +0 -1
- package/dist/c-GIKRQI4X.min.js +0 -1
- package/dist/c-GPYOFETM.min.js +0 -1
- package/dist/c-IDUHYYSI.min.js +0 -1
- package/dist/c-IUHFPMHD.min.js +0 -1
- package/dist/c-J5G56TUH.min.js +0 -1
- package/dist/c-JAZ73J32.min.js +0 -1
- package/dist/c-KG3NXHAL.min.js +0 -1
- package/dist/c-KII3PLZE.min.js +0 -1
- package/dist/c-LIXGXMNS.min.js +0 -1
- package/dist/c-LVEY6D6B.min.js +0 -1
- package/dist/c-M4Y3BHFR.min.js +0 -1
- package/dist/c-MAIICR2Z.min.js +0 -1
- package/dist/c-MG5DM6VE.min.js +0 -1
- package/dist/c-MNF2S4AA.min.js +0 -1
- package/dist/c-MT3WBK7M.min.js +0 -1
- package/dist/c-NY3JWV2K.min.js +0 -1
- package/dist/c-O6U6K4CW.min.js +0 -1
- package/dist/c-OQ7M4AGV.min.js +0 -1
- package/dist/c-OXYMVK7Q.min.js +0 -1
- package/dist/c-PPWDL5ZI.min.js +0 -1
- package/dist/c-QHF5YON3.min.js +0 -1
- package/dist/c-RR3GO5SW.min.js +0 -1
- package/dist/c-RSVIHIQ4.min.js +0 -1
- package/dist/c-S2BXNNJN.min.js +0 -1
- package/dist/c-S6U5CGT5.min.js +0 -1
- package/dist/c-SLGMUBUL.min.js +0 -1
- package/dist/c-SUILCHWU.min.js +0 -1
- package/dist/c-TZW3JGJ5.min.js +0 -1
- package/dist/c-US5ZFT6E.min.js +0 -1
- package/dist/c-USFMFKIH.min.js +0 -1
- package/dist/c-UUKVD4WB.min.js +0 -1
- package/dist/c-VGW3VG3I.min.js +0 -1
- package/dist/c-W3CE4A4S.min.js +0 -1
- package/dist/c-WJCD5EUY.min.js +0 -1
- package/dist/c-X5UBGU2V.min.js +0 -1
- package/dist/c-YDAY2WFR.min.js +0 -1
- package/dist/c-ZOWWU34K.min.js +0 -1
- /package/dist/{c-N4G2L7ID.min.js → c-HYW2XA4Q.min.js} +0 -0
- /package/dist/{c-OCI56QF2.min.js → c-V4XMSLC3.min.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e=Object.create,o=Object.defineProperty,i=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||o(t,c,{get:()=>e[c],enumerable:!(a=i(e,c))||a.enumerable});return t},c=(t,i,n)=>(n=null!=t?e(r(t)):{},a(!i&&t&&t.__esModule?n:o(n,"default",{value:t,enumerable:!0}),t)),l={};function u(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}((t,e)=>{for(var i in e)o(t,i,{get:e[i],enumerable:!0})})(l,{generateFrameSVGs:()=>dm,generateFrameSequence:()=>hm,generatePhysicsFrameSVGs:()=>pm,renderChart:()=>nm,renderChartWithEvidence:()=>rm,renderDashboard:()=>cm,renderGeoToStaticSVG:()=>Kg,renderNetworkToStaticSVG:()=>Ug,renderOrdinalToStaticSVG:()=>Hg,renderPhysicsToAnimatedGif:()=>bm,renderToAnimatedGif:()=>xm,renderToImage:()=>am,renderToStaticSVG:()=>Gg,renderXYToStaticSVG:()=>Vg,resolveTheme:()=>Ot,serializeSvgPrecision:()=>tm,themeStyles:()=>zt}),module.exports=(t=l,a(o({},"__esModule",{value:!0}),t));var d=44,h={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:d,snap:"nearestDatum",brushHandleSize:d,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function f(t,e={}){const o=e.mobileSemantics?.interaction,i="number"==typeof o?.targetSize?o.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,n="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,r=!!o||void 0!==i,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!n&&!r)return h;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??i??d,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??d,standardControls:a.standardControls??!1}}var p={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 y(t,e,o){if(!1!==e)return t;const i={...t};return"horizontal"===o?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}function g(t){return t instanceof Date?"date:"+t.getTime():`${typeof t}:${t+""}`}var m={kind:"rank-competition"};function x(t,e,o,i){const n=t??e;return"function"==typeof n?n(o,i):o[n+""]}var b=Symbol.for("semiotic.semantic-viability"),v=globalThis,w=v[b]??(v[b]=new Map);function k(t){return"string"==typeof t?.code&&t.code.length>0&&("warning"===t.severity||"error"===t.severity)&&"string"==typeof t.message&&t.message.length>0}function S(t,e,o){if(t.semanticDiagnostics=[],t.semanticStatus="not-assessed",t.empty)return;const i=function(t){return function(t){return w.has(t)}(t)?function(t){return w.get(t)}(t):"BumpChart"===t?m:void 0}(e);if(!i)return;let n;try{const e="function"==typeof i?i(o,t):function(t){const e=new Map;(Array.isArray(t.data)?t.data:[]).forEach((o,i)=>{if(!Number.isFinite(Number(x(t.yAccessor,"y",o,i))))return;const n=g(x(t.xAccessor,"x",o,i)),r=e.get(n)??new Set;r.add(x(t.lineBy,"series",o,i)+""),e.set(n,r)});const o=Array.from(e.values(),t=>t.size).sort((t,e)=>t-e);if(0===o.length)return[];const i=Math.floor(o.length/2),n={columns:o.length,median:o.length%2?o[i]:(o[i-1]+o[i])/2,max:o[o.length-1],contestedColumns:o.filter(t=>t>=2).length},r=2>n.max;return r||2>n.contestedColumns||2>n.median?[{code:r?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:r?"error":"warning",message:r?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...n}}]:[]}(o);n=Array.from(e).filter(k)}catch{return void(t.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||t.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}t.semanticDiagnostics=n,t.semanticStatus=n.some(t=>"error"===t.severity)?"degenerate":n.some(t=>"warning"===t.severity)?"degraded":"meaningful";for(const e of n)t.warnings.includes(e.code)||t.warnings.push(e.code)}var A=c(require("react-dom/server")),M=c(require("react")),_=Object.freeze([]);function P(t){if(!t)return _;let e=!1;for(let o=0;t.length>o;o++){const i=t[o];if(null==i||"object"!=typeof i){e=!0;break}}if(!e)return t;const o=[];for(const e of t)null!=e&&"object"==typeof e&&o.push(e);return o}var j=require("d3-scale");function L(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function $(t,e,o){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(o)}`}function R(t){const e=t.map(L),o=e.length-1;return t=>{if(0>=t){const[t,o,i]=e[0];return $(t,o,i)}if(t>=1){const[t,i,n]=e[o];return $(t,i,n)}const i=t*o,n=Math.floor(i),r=i-n,[s,a,c]=e[n],[l,u,d]=e[n+1];return $(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(d-c)*r))}}var C=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],I=R(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),T=R(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),O=R(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),z=R(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),F=R(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),N=R(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),E=R(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),D=R(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),B=R(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),W=R(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Y=R(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),q=R(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),X={blues:I,reds:T,greens:O,viridis:E,oranges:z,purples:F,greys:N,plasma:D,inferno:B,magma:W,cividis:Y,turbo:q};function G(t){return t&&Object.prototype.hasOwnProperty.call(X,t)?X[t]:I}var V=R(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),H=R(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),U=R(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),K=R(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Z=R(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Q=R(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),J=R(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),tt={category10:C,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...X},et=C,ot="#007bff";function it(t,e,o=et){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=Object.prototype.hasOwnProperty.call(tt,t)?tt[t]:void 0;if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:o}var nt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],rt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],st=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 at(t,e,o){if("function"==typeof e){const i=e(t);return o&&i&&"string"==typeof i&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||st.has(e)}(i)?o(i):i}const i=t?.[e]+"";return o?o(i):et[Math.abs(function(t){let e=0;for(let o=0;t.length>o;o++)e=(e<<5)-e+t.charCodeAt(o),e&=e;return Math.abs(e)}(i))%et.length]}function ct(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const o=t[e];return"string"==typeof o&&o.length>0?o:void 0}function lt(t,e,o="category10"){if(o&&"object"==typeof o&&!Array.isArray(o)){const t=o;return e=>ct(t,e)??"#999"}const i=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),n=i.every(t=>!isNaN(Number(t)));if(Array.isArray(o))return(0,j.scaleOrdinal)().domain(i).range(o).unknown("#999");const r=Object.prototype.hasOwnProperty.call(tt,o)?tt[o]:tt.category10;if(n&&"function"==typeof r){let t=-1/0;for(const e of i){const o=Number(e);o>t&&(t=o)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:et;return(0,j.scaleOrdinal)().domain(i).range(t).unknown("#999")}}function ut(t,e,o=[3,20],i){let n;if(n="function"==typeof e?e(t):t?.[e],!i)return n;const[r,s]=i,[a,c]=o;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 dt(t){return void 0!==t.stroke||void 0!==t.strokeWidth||void 0!==t.opacity}function ht(t,e){if(!dt(e))return t??((...t)=>({}));const o={};return void 0!==e.stroke&&(o.stroke=e.stroke),void 0!==e.strokeWidth&&(o.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(o.opacity=e.opacity),t?(...e)=>({...t(...e)||{},...o}):(...t)=>({...o})}function ft(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>gt(e(t))}function pt(t,e){const o=ft(t),i=ft(e);return(t,e)=>{const n=i(t);return{value:n,x:o(t),y:n,category:e}}}function yt(t,e){const o=ft(e??"value"),i=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=i?i(t):void 0;return{value:o(t),category:null==e?void 0:e+""}}}function gt(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 mt(t,e,o){const i=t.when;return void 0===i||!0===i||!1!==i&&("function"==typeof i?i(e,o):function(t,e,o){const i=null!=t.axis?o[t.axis]:null!=t.field?e[t.field]:o.value;if(void 0!==t.eq&&i!==t.eq)return!1;if(void 0!==t.ne&&i===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(i))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=gt(i);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,o]=t.within;if(e>n||n>o)return!1}if(void 0!==t.outside){const[e,o]=t.outside;if(n>=e&&o>=n)return!1}return!0}(i,e,o))}function xt(t,e,o){if(!e||0===e.length)return{};let i={};for(const n of e){if(!mt(n,t,o))continue;const e="function"==typeof n.style?n.style(t,o):n.style;e&&(i={...i,...e})}return i}function bt(t,e,o,i=t=>t){const n=t??(()=>({}));return e&&0!==e.length?(t,r)=>{const s=i(t),a={...n(t,r)};return Object.assign(a,xt(s,e,o(s,r))),a}:n}function vt(t,e,o,i){if(!t||0===t.length)return i;const n=yt(e,o);return(e,o)=>{const r=e&&e.data||e,s=xt(r,t,n(r)),a=i?i(e,o):void 0;return a?{...s,...a}:s}}var wt={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function kt(t,e=wt){if(t)return!0===t?e:"stops"in t?Array.isArray(t.stops)?t:void 0:"colorStops"in t?Array.isArray(t.colorStops)?{stops:t.colorStops.map(({offset:t,color:e})=>({offset:t,color:e}))}:void 0:{stops:[{offset:0,opacity:t.topOpacity??e.stops[0]?.opacity??.8},{offset:1,opacity:t.bottomOpacity??e.stops.at(-1)?.opacity??.05}]}}function St(t){return t?kt(t):void 0}function At(t,e,o){return"function"==typeof t?t(o):o[t||e]}function Mt(t){return t instanceof Date?t.getTime():Number(t)}function _t(t,e){return E(1===e?.5:t/(e-1))}function Pt(t){const e={};return void 0!==t.stroke&&(e.stroke=t.stroke),void 0!==t.strokeWidth&&(e.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(e.opacity=t.opacity),e}function jt(t,e){const o=function(t){if(!t)return;const e="boolean"==typeof t?{}:"string"==typeof t?{method:t}:t;return{type:"trend",method:e.method??"linear",...null!=e.bandwidth&&{bandwidth:e.bandwidth},...null!=e.order&&{order:e.order},...null!=e.color&&{color:e.color},...null!=e.strokeWidth&&{strokeWidth:e.strokeWidth},...null!=e.strokeDasharray&&{strokeDasharray:e.strokeDasharray},...null!=e.label&&{label:e.label}}}(e),i=Array.isArray(t)?t:void 0;return o?[o,...i??[]]:i}var Lt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],$t={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}},Rt={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}},Ct={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Lt,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 It(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}}var Tt={light:$t,dark:Rt,"high-contrast":Ct,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 Ot(t){if(!t)return $t;if("string"==typeof t){if("light"===t)return $t;if("dark"===t)return Rt;if("high-contrast"===t)return Ct;return(Object.prototype.hasOwnProperty.call(Tt,e=t)?Tt[e]:void 0)||$t}var e;const o="dark"===t.mode?Rt:$t;return function(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:Lt}}),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}({...o,...t,colors:{...o.colors,...t.colors||{}},typography:{...o.typography,...t.typography||{}},tooltip:{...o.tooltip,...t.tooltip||{}}})}function zt(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,legendFontFamily:t.typography.legendFontFamily??t.typography.fontFamily,legendFontWeight:t.typography.legendFontWeight,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,titleFontFamily:t.typography.titleFontFamily??t.typography.fontFamily,titleFontWeight:t.typography.titleFontWeight??"bold",tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}function Ft(t,e,o){const i="function"==typeof e?e(t):t[e??o];if(null==i)return null;if(i instanceof Date)return i.getTime();if("string"==typeof i&&""===i.trim())return null;const n=Number(i);return Number.isFinite(n)?n:null}function Nt(t){let e=1/0,o=-1/0;for(const i of t)e>i&&(e=i),i>o&&(o=i);return[e,o]}function Et(t,e=-1/0){let o=e;for(const e of t)e>o&&(o=e);return o}var Dt=2;function Bt(t){const e=10**Dt;return Math.round(t*e)/e}function Wt(t,e=2){const o=[],i=[],n=e+1;for(let e=0;n>e;e++){let r=0;for(const[o,i]of t)null!==i&&(r+=o**e*i);o.push(r);const s=[];for(let o=0;n>o;o++){let i=0;for(const[n,r]of t)null!==r&&(i+=n**(e+o));s.push(i)}i.push(s)}i.push(o);const r=function(t,e){const o=t,i=t.length-1,n=[e];for(let t=0;i>t;t++){let e=t;for(let n=t+1;i>n;n++)Math.abs(o[t][n])>Math.abs(o[t][e])&&(e=n);for(let n=t;i+1>n;n++){const i=o[n][t];o[n][t]=o[n][e],o[n][e]=i}for(let e=t+1;i>e;e++)for(let n=i;n>=t;n--)o[n][e]-=o[n][t]*o[t][e]/o[t][t]}for(let t=i-1;t>=0;t--){let e=0;for(let r=t+1;i>r;r++)e+=o[r][t]*n[r];n[t]=(o[i][t]-e)/o[t][t]}return n}(i,n).map(Bt);return{points:t.map(([t])=>[Bt(t),Bt(r.reduce((e,o,i)=>e+o*t**i,0))]),equation:[...r].reverse()}}function Yt(t){const e=t.length;let o=0,i=0,n=0,r=0;for(const[e,s]of t)o+=e,i+=s,n+=e*e,r+=e*s;const s=e*n-o*o;if(1e-12>Math.abs(s))return null;const a=(e*r-o*i)/s,c=(i-a*o)/e;return t=>c+a*t}function qt(t,e){const o=t.length,i=t.map(([t,o])=>o-e(t)).reduce((t,e)=>t+e*e,0),n=Math.sqrt(i/Math.max(o-2,1)),r=t.reduce((t,e)=>t+e[0],0)/o,s=t.reduce((t,e)=>t+(e[0]-r)**2,0);return{se:n,meanX:r,ssX:s}}function Xt(t){return.99>t?.95>t?.9>t?1:1.645:1.96:2.576}var Gt="__forecastSegment",Vt="__forecastOpacity";function Ht(t,e,o,i){const n=e.uncertaintyOpacity,r=e.confidenceAccessor;if(!n&&!r)return;const s="object"==typeof n?n:{},a=s.min??.15,c=s.max??1;if(r){const e="function"==typeof r?r:t=>t[r];for(const o of t){const t=e(o);null!=t&&Number.isFinite(t)&&(o[Vt]=a+Math.max(0,Math.min(1,t))*(c-a))}return}const l=t.map(t=>{const e=o(t),n=i(t);return null!=e&&null!=n&&Number.isFinite(e)&&Number.isFinite(n)?Math.abs(e-n):NaN}),u=l.filter(t=>Number.isFinite(t));if(0===u.length)return;const[d,h]=Nt(u),f=h-d;t.forEach((t,e)=>{const o=l[e];Number.isFinite(o)&&(t[Vt]=c-(f>0?(o-d)/f:0)*(c-a))})}function Ut(t,e){return"function"==typeof e?e(t):!!t[e]}var Kt="__semiotic_resolvedX",Zt="__semiotic_resolvedY",Qt="__compoundGroup";function Jt(t,e,o){const i=t[e],n=t[o];return null==i||null==n||Number.isNaN(i)||Number.isNaN(n)}function te(t){const e=t.xAccessor||"x",o=t.yAccessor||"y",i=t.lineBy,n=t.colorBy||i;let r=Array.isArray(t.data)?P(t.data).filter(t=>!!t&&"object"==typeof t):[];const s=function(t,e,o){const i="function"==typeof e,n="function"==typeof o,r=i?Kt:e,s=n?Zt:o;return i||n?{xKey:r,yKey:s,rows:t.map(t=>{const r={...t};return i&&(r[Kt]=e(t)),n&&(r[Zt]=o(t)),r})}:{rows:t,xKey:r,yKey:s}}(r,e,o);r=s.rows;const a=s.xKey,c=s.yKey,l=Array.isArray(t.annotations)?[...t.annotations]:[];let u,d="string"==typeof i||"function"==typeof i?i:void 0,h=t.baseLineStyle;if(t.forecast){const e=function(t,e,o,i,n){return(r=i).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(t,e,o,i,n){const{isTraining:r,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=i,y=t.map(t=>{let e="observed";return s&&Ut(t,s)?e="forecast":r&&Ut(t,r)&&(e="training"),{...t,[Gt]:e}}),g=i._groupBy,m=[];if(g){const t=new Map;for(const e of y){const o=e[g]??"__default";t.has(o)||t.set(o,[]),t.get(o).push(e)}const e=[];for(const[,o]of t)for(let t=0;o.length-1>t;t++)o[t][Gt]!==o[t+1][Gt]&&(e.push({...o[t+1],[Gt]:o[t][Gt]}),e.push({...o[t],[Gt]:o[t+1][Gt]}));m.push(...y,...e)}else for(let t=0;y.length>t;t++)m.push(y[t]),y.length-1>t&&y[t][Gt]!==y[t+1][Gt]&&(m.push({...y[t+1],[Gt]:y[t][Gt]}),m.push({...y[t],[Gt]:y[t+1][Gt]}));if(i.trainUnderline){const t=[];for(const e of m)"training"===e[Gt]&&t.push({...e,[Gt]:"training-base"});m.unshift(...t)}const x=[];if(c&&l){const t="string"==typeof c?c:"__envUpper",e="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const o of m)"function"==typeof c&&(o[t]=c(o)),"function"==typeof l&&(o[e]=l(o));x.push({type:"envelope",upperAccessor:t,lowerAccessor:e,fill:u,fillOpacity:d,label:p})}if(i.uncertaintyOpacity||i.confidenceAccessor){const t=c?"function"==typeof c?c:t=>t[c]:()=>{},e=l?"function"==typeof l?l:t=>t[l]:()=>{};Ht(m.filter(t=>"forecast"===t[Gt]),i,t,e)}if(a){const t=i.anomalyStyle,e={type:"highlight",filter:t=>Ut(t,a)};t?(e.style=t,e.r=f):"function"==typeof h?(e.style=t=>{const e=h(t);return{stroke:e,strokeWidth:1.5,fill:e,fillOpacity:.7}},e.r=f):(e.color=h,e.r=f,e.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(e)}return n&&x.push({type:"anomaly-band",threshold:n.threshold??2,showBand:!1!==n.showBand,fill:n.bandColor||"#6366f1",fillOpacity:n.bandOpacity??.1,anomalyColor:n.anomalyColor||"#ef4444",anomalyRadius:n.anomalyRadius??6,label:n.label}),{processedData:m,annotations:x}}(t,0,0,i,n):function(t,e,o,i,n){const{trainEnd:r,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=i;if(null==r)return{processedData:t,annotations:[]};const d=[],h=[];for(const o of t)o[e]>r?h.push({...o,[Gt]:"observed"}):d.push({...o,[Gt]:"training"});const f=d.map(t=>[t[e],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]),p=[],y=[];if(f.length>=3){const n=f.length,r=Yt(f);if(r){const{se:d,meanX:h,ssX:g}=qt(f,r),m=Xt(a),x=Et(t.map(t=>t[e]).filter(t=>null!=t&&isFinite(t))),b=f.length>1?(f[n-1][0]-f[0][0])/(n-1):1;for(let t=1;s>=t;t++){const i=x+t*b,s=r(i),a=d*Math.sqrt(1+1/n+(g>0?(i-h)**2/g:0))*m;y.push({[e]:i,[o]:s,[Gt]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}Ht(y,i,t=>t.__forecastUpper,t=>t.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}p.push({type:"x-threshold",x:r,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),n&&p.push({type:"anomaly-band",threshold:n.threshold??2,showBand:!1!==n.showBand,fill:n.bandColor||"#6366f1",fillOpacity:n.bandOpacity??.1,anomalyColor:n.anomalyColor||"#ef4444",anomalyRadius:n.anomalyRadius??6,label:n.label});const g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[Gt]:"observed"}),g.push(...h),y.length>0){const t=h.length>0?h[h.length-1]:d[d.length-1];t&&g.push({...t,[Gt]:"forecast"}),g.push(...y)}return{processedData:g,annotations:p}}(t,e,o,i,n);var r}(r,a,c,i&&"string"==typeof i&&"object"==typeof t.forecast?{...t.forecast,_groupBy:i}:t.forecast,t.anomaly);if(r=e.processedData,l.push(...e.annotations),u=function(t,e,o){const i=o.upperBounds,n=o.lowerBounds;if(!i&&!n)return;const r="function"==typeof i?i:"string"==typeof i?t=>t[i]:null,s="function"==typeof n?n:"string"==typeof n?t=>t[n]:null;let a=1/0,c=-1/0;for(const o of t){const t=Number(o[e]);if(Number.isFinite(t)&&(a>t&&(a=t),t>c&&(c=t)),r){const t=r(o);null!=t&&Number.isFinite(t)&&(t>c&&(c=t),a>t&&(a=t))}if(s){const t=s(o);null!=t&&Number.isFinite(t)&&(a>t&&(a=t),t>c&&(c=t))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}(r,c,t.forecast),i&&"string"==typeof i?(r=r.map(t=>({...t,[Qt]:`${t[i]}__${t[Gt]||"observed"}`})),d=Qt):d=Gt,t.baseLineStyle){const e=function(t,e){const o=e.trainDasharray??"8,4",i=e.forecastDasharray??"4,4",n=e.color||"#6366f1",r=e.trainOpacity,s=e.forecastOpacity,a=e.trainStroke,c=e.trainLinecap,l=e.trainUnderline;return e=>{const u=t(e),d=e[Gt];if("training"===d){let t=u.stroke;return"darken"===a?t=function(t,e=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const i=Math.round(parseInt(o[1],16)*(1-e)),n=Math.round(parseInt(o[2],16)*(1-e)),r=Math.round(parseInt(o[3],16)*(1-e));return`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):a&&(t=a),{...u,stroke:t,strokeDasharray:o,...c&&{strokeLinecap:c},...null!=r&&{strokeOpacity:r}}}if("training-base"===d){let t=u.stroke||"#666";return"lighten"===l&&(t=function(t,e=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const i=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*e),n=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*e),r=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*e);return`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}(t,.4)),{...u,stroke:t,strokeDasharray:void 0}}if("forecast"===d){const t=e[Vt],o=null!=t?t:s;return{...u,stroke:n,strokeDasharray:i,...null!=o&&{strokeOpacity:o}}}return u}}(e=>t.baseLineStyle(e),t.forecast);h=t=>e(t)}}else t.anomaly&&l.push(...(f=t.anomaly,[{type:"anomaly-band",threshold:f.threshold??2,showBand:!1!==f.showBand,fill:f.bandColor||"#6366f1",fillOpacity:f.bandOpacity??.1,anomalyColor:f.anomalyColor||"#ef4444",anomalyRadius:f.anomalyRadius??6,label:f.label}]));var f;if(t.gapStrategy){if("function"==typeof d){const t=d;r=r.map(e=>({...e,__semiotic_gapGroup:t(e)})),d="__semiotic_gapGroup"}const e=function(t,e,o,i,n){const r=new Map;for(const e of t){const t=n?(e[n]??"")+"":"__single";r.has(t)||r.set(t,[]),r.get(t).push(e)}if("interpolate"===e){const t=[];for(const[,e]of r)for(const n of e)Jt(n,o,i)||t.push(n);return{rows:t,groupKey:n}}if("zero"===e){const t=[];for(const[,e]of r)for(const n of e)Jt(n,o,i)?t.push({...n,[i]:0}):t.push(n);return{rows:t,groupKey:n}}const s=[],a="_gapSegment";for(const[t,e]of r){let n=0,r=[];const c=()=>{if(0===r.length)return;const e="__single"===t?"__seg"+n:`${t}__seg${n}`;for(const t of r)s.push({...t,[a]:e});r=[],n++};for(const t of e)Jt(t,o,i)?c():r.push(t);c()}return{rows:s,groupKey:a}}(r,t.gapStrategy,a,c,"string"==typeof d?d:void 0);r=e.rows,e.groupKey&&(d=e.groupKey)}let p;if(t.directLabel){const e=function(t,e,o,i,n,r,s,a){if(!e||!o)return{annotations:[]};const c="object"==typeof e?e:{},l=c.position||"end",u=c.fontSize||11,d="function"==typeof o?o:t=>t[o],h=new Map;for(const e of t){const t=d(e);if(null==t)continue;const o=t+"";""!==o&&(h.has(o)||h.set(o,[]),h.get(o).push(e))}const f=new Map;for(const[t,e]of h)e.sort((t,e)=>Number(t[i])-Number(e[i])),f.set(t,"end"===l?e[e.length-1]:e[0]);const p=lt(Array.from(f.entries()).map(([t])=>({__lbl:t})),"__lbl",r??s),y=Array.from(f.entries()).map(([t,e])=>({type:"text",label:t,[i]:e[i],[n]:e[n],dx:"end"===l?6:-6,dy:0,color:p?at({__lbl:t},"__lbl",p):a||ot,fontSize:u}));y.sort((t,e)=>Number(t[n])-Number(e[n]));for(let t=1;y.length>t;t++){const e=y[t-1],o=y[t],i=Number(e[n])+e.dy;u+2>Math.abs(Number(o[n])+o.dy-i)&&(o.dy+=u+2)}const g=y.reduce((t,e)=>Math.max(t,(e.label+"").length*(.6*u)),0)+10;return{annotations:y,marginExtra:"end"===l?{right:g}:{left:g}}}(r,t.directLabel,"string"==typeof n||"function"==typeof n?n:void 0,a,c,t.colorScheme,t.themeCategorical,t.color);l.push(...e.annotations),p=e.marginExtra}return{data:r,xAccessor:"function"==typeof e?a:e,yAccessor:"function"==typeof o?c:o,groupAccessor:d,colorAccessor:n,annotations:l,lineStyle:h,yExtent:u,marginExtra:p}}function ee(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Ot(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrScatterColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrScatterColorBy:e(t)})):r,u=e?lt(l,c,a):void 0,d=n.sizeBy,h=Array.isArray(n.sizeRange)?n.sizeRange:[3,15],f=d?r.map(t=>"function"==typeof d?d(t):Number(t[d])).filter(Number.isFinite):[],p=f.length?Nt(f):void 0,y=pt(n.xAccessor,n.yAccessor),g=n.styleRules;return t=>{const o={fill:e&&u?at(t,e,u):"string"==typeof n.color?n.color:ot,fillOpacity:"number"==typeof n.pointOpacity?n.pointOpacity:.8,r:d?ut(t,d,h,p):"number"==typeof n.pointRadius?n.pointRadius:5};return g?.length&&Object.assign(o,xt(t,g,y(t))),void 0!==n.stroke&&(o.stroke=n.stroke),void 0!==n.strokeWidth&&(o.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(o.opacity=n.opacity),o}}var oe={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=te({data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",forecast:n.forecast,anomaly:n.anomaly,annotations:i.annotations,themeCategorical:Ot(i.theme).colors.categorical}),s=jt(r.annotations,n.regression);return{chartType:"scatter",data:r.data,xAccessor:r.xAccessor,yAccessor:r.yAccessor,colorAccessor:e,sizeAccessor:n.sizeBy,...n.symbolBy&&{symbolAccessor:n.symbolBy},...n.symbolMap&&{symbolMap:n.symbolMap},colorScheme:o,...i,...s&&s.length>0&&{annotations:s},...r.yExtent&&!i.yExtent&&{yExtent:r.yExtent},sizeRange:n.sizeRange||[3,15],pointStyle:i.pointStyle||ee(t,e,o,i,n),showLegend:i.showLegend??!!e}}},ie={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=jt(i.annotations,n.regression);return{chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[5,40],colorScheme:o,...i,...r&&{annotations:r},pointStyle:i.pointStyle||ne(t,e,o,i,n),showLegend:i.showLegend??!!e}}};function ne(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Ot(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrBubbleColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrBubbleColorBy:e(t)})):r,u=e?lt(l,c,a):void 0,d=n.sizeBy,h=Array.isArray(n.sizeRange)?n.sizeRange:[5,40],f=d?r.map(t=>"function"==typeof d?d(t):Number(t[d])).filter(Number.isFinite):[],p=f.length?Nt(f):void 0,y=pt(n.xAccessor,n.yAccessor),g=n.styleRules;return t=>{const o={fill:e&&u?at(t,e,u):"string"==typeof n.color?n.color:ot,fillOpacity:"number"==typeof n.bubbleOpacity?n.bubbleOpacity:.6,r:d?ut(t,d,h,p):h[0],stroke:n.bubbleStrokeColor??"white",strokeWidth:n.bubbleStrokeWidth??1};return g?.length&&Object.assign(o,xt(t,g,y(t))),void 0!==n.stroke&&(o.stroke=n.stroke),void 0!==n.strokeWidth&&(o.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(o.opacity=n.opacity),o}}function re(...t){let e;for(const o of t)o&&(e=se(e)&&se(o)?{legendGroups:[...e.legendGroups,...o.legendGroups],legendDistance:o.legendDistance??e.legendDistance}:o);return e}function se(t){return"object"==typeof t&&null!==t&&"legendGroups"in t&&Array.isArray(t.legendGroups)}function ae(t){return"object"==typeof t&&null!==t&&"gradient"in t}require("react");var ce=36,le=34,ue=58,de=22;function he(t){return"string"==typeof t&&t.length>0}function fe(t,e,o=!1){const i=o?e?ue:le:e?ce:0;return i>t.top?{...t,top:i}:t}function pe(t,e){return fe(t,he(e))}var ye=16,ge=6,me=10,xe=22,be=100,ve=10,we=3;function ke(t,e,o,i,n=8){const r=i,s="left"===i?"right":"right"===i?"left":"top"===i?"bottom":"top",a=Math.max(e[r],Math.max(0,("left"===i||"right"===i?o[0]:o[1])-n)-t[s]);t[r]>a&&(t[r]=a)}var Se=12,Ae=18,Me=46,_e=26;function Pe(t){return Math.ceil(7*t.length)}function je(t,e){if(se(t)){const o=We(e),i=t.legendGroups.flatMap(t=>[t.label?Pe(t.label):0,...t.items.map(t=>o.swatchSize+o.labelGap+Pe(t.label))]);return Math.max(be,...i)}if(ae(t)){const{gradient:e}=t,o=e.format||(t=>Math.round(100*t)/100+""),i=Math.max(Pe(o(e.domain[0])),Pe(o(e.domain[1]))),n=e.label?Pe(e.label):0;return Math.max(be,19+i,n)}return be}function Le(t){return(se(t)||ae(t))&&Number.isFinite(t.legendDistance)?Math.max(0,t.legendDistance):ve}function $e(t,e){return null!=t?.sideGutter?Math.max(0,t.sideGutter):e?.hasAxis?e.hasAxisLabel?ze:Oe:0}function Re(t){return Math.max(0,t?.edgeGutter??we)}var Ce=22,Ie=46,Te=64,Oe=34,ze=70;function Fe(t,e){return null!=e?.axisGutter?Math.max(0,e.axisGutter):t?.hasAxis?t.hasAxisLabel?t.rotatedTicks?Te:Ie:Ce:0}function Ne(t,e,o){if(ae(t))return t.gradient.label?Me:_e;if(!se(t))return 20;const i=We(o),n=Math.max(1,o?.maxWidth??e);let r=i.rowHeight;for(const e of t.legendGroups){let t=0,o=0;for(const r of e.items){const e=i.swatchSize+i.labelGap+Pe(r.label),s=0===o?e:o+i.itemGap+e;o>0&&s>n?(t+=1,o=e):o=s}e.items.length>0&&(t+=1),r=Math.max(r,t*i.rowHeight,e.label?Pe(e.label):0)}return r+(t.legendGroups.length>1?16:0)}function Ee(t,e,o){return je(t,e)+Le(t)+$e(e,o)+Re(e)}function De(t,e){const{legend:o}=e;if(!o)return;const i=e.position??"right",n=Ne(o,Math.max(1,e.size[0]-t.left-t.right),e.legendLayout)+Le(o)+Fe("bottom"===i?e.axisChrome:"top"===i?e.axisChrome?.topAxis:void 0,e.legendLayout)+("top"===i&&e.hasTitle?24:0),r=Math.max(e.minimumMargin??0,"top"===i?e.hasTitle?ue:le:0);"right"===i?t.right=Math.max(t.right,r,Ee(o,e.legendLayout,e.axisChrome?.rightAxis)):"left"===i?t.left=Math.max(t.left,r,Ee(o,e.legendLayout,e.axisChrome?.leftAxis)):"top"===i?t.top=Math.max(t.top,r,n):t.bottom=Math.max(t.bottom,r,n)}function Be(t,e){const o=e.position??"right",i="top"===o||"bottom"===o,n=Math.max(0,e.totalWidth-e.margin.left-e.margin.right),r=Math.max(1,i?e.legendLayout?.maxWidth??n:e.reservedWidth??je(t,e.legendLayout)),s=Le(t),a=$e(e.legendLayout,"left"===o?e.axisChrome?.leftAxis:e.axisChrome?.rightAxis),c=Re(e.legendLayout),l=Ne(t,n,e.legendLayout),u=Fe(e.axisChrome,e.legendLayout),d=Fe(e.axisChrome?.topAxis,e.legendLayout);if("left"===o)return{x:Math.max(c,e.margin.left-a-r-s),y:e.margin.top,width:r,height:l};if("top"===o)return{x:e.margin.left,y:e.margin.top-d-s-l,width:r,height:l};if("bottom"===o){const t=e.totalHeight-e.margin.bottom;return{x:e.margin.left,y:Math.max(t+s,Math.min(t+u+s,e.totalHeight-l)),width:r,height:l}}return{x:Math.min(e.totalWidth-r-c,e.totalWidth-e.margin.right+a+s),y:e.margin.top,width:r,height:l}}function We(t){const e=Math.max(1,t?.swatchSize??ye),o=Math.max(e,t?.rowHeight??xe);return{swatchSize:e,labelGap:Math.max(0,t?.labelGap??ge),itemGap:Math.max(0,t?.itemGap??me),rowHeight:o,align:"left"===t?.align?"start":"right"===t?.align?"end":t?.align??"start",maxWidth:t?.maxWidth}}function Ye(t,e){let o=24;return t.map(({hasLabel:t,itemCount:i})=>{o+=5;const n=o;let r;o+=8,t&&(o+=16,r=o,o+=8);const s=o;return o+=i*e+8,{lineY:n,labelY:r,itemsY:s,endY:o}})}function qe(t,e,o,i,n){if(t)return t;if(o&&"object"==typeof o&&!Array.isArray(o)){const t=ct(o,i);if(t)return t}let r;if(Array.isArray(o))r=o;else if(e&&e.length>0)r=e;else if("string"==typeof o){const t=tt[o];Array.isArray(t)&&(r=t)}return r&&0!==r.length?null!=i?(n.has(i)||n.set(i,n.size),r[n.get(i)%r.length]):r[0]:ot}function Xe(t,e,o){return"function"==typeof t?t(e,o):e[t]}function Ge(t,e){if(!t?.length)return;const o=new Map(e.map((t,e)=>[g(t),e]));return t.map(t=>{const e={...t},i=i=>{if(!(i in t))return;const n=o.get(g(t[i]));void 0!==n&&(e[i]=n)};return i("x"),i("x0"),i("x1"),"string"!=typeof t.type||"x-threshold"!==t.type&&"x"!==t.type||i("value"),e})}var Ve,He=c(require("react")),Ue=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0});function Ke(t,e,o,i,n){const r=1-n;return r*r*r*t+3*r*r*n*e+3*r*n*n*o+n*n*n*i}function Ze(t,e,o,i,n){const r=1-n;return 3*r*r*(e-t)+6*r*n*(o-e)+3*n*n*(i-o)}function Qe(t,e,o,i,n){const r=[],s=(t.x+e.x)/2;for(let a=0;n>=a;a++){const c=a/n;let l,u,d,h;"linear"===i?(l=t.x+(e.x-t.x)*c,u=t.y+(e.y-t.y)*c,d=e.x-t.x,h=e.y-t.y):(l=Ke(t.x,s,s,e.x,c),u=Ke(t.y,t.y,e.y,e.y,c),d=Ze(t.x,s,s,e.x,c),h=Ze(t.y,t.y,e.y,e.y,c)),r.push({x:l,y:u,dx:d,dy:h,radius:t.radius+(e.radius-t.radius)*c,datumIndex:.5>c?o:o+1})}return r}function Je(t,e={}){const o=[],i=[],n=[];if(2>t.length)return{topPath:o,bottomPath:i,datumIndices:n};const r=e.curve??"smooth",s=Math.max(2,Math.floor(e.samplesPerSegment??12));for(let e=0;t.length-1>e;e++){const a=Qe(t[e],t[e+1],e,r,s);for(let t=0===e?0:1;a.length>t;t++){const e=a[t],r=Math.hypot(e.dx,e.dy)||1,s=-e.dy/r,c=e.dx/r,l=Math.max(0,e.radius);o.push([e.x+s*l,e.y+c*l]),i.push([e.x-s*l,e.y-c*l]),n.push(e.datumIndex)}}return{topPath:o,bottomPath:i,datumIndices:n}}var to=require("react/jsx-runtime");function eo({datum:t,x:e,y:o,side:i,color:n,highlighted:r,labelStyle:s}){const a=function(){const t=(Ve??(Ve=He.createContext(null)),Ve);return He.useContext(t)??Ue}(),c=a.isActive&&!a.predicate(t),l="function"==typeof s?s(t.__bumpRaw):s;return(0,to.jsx)("text",{className:"semiotic-bump-label",x:e+("end"===i?8:-8),y:o,dy:"0.35em",textAnchor:"end"===i?"start":"end",fill:n,fillOpacity:c?.16:1,fontWeight:r?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...l},children:t.__bumpSeries})}function oo(t,e,o){const[i,n]=e,[r,s]=o;return n===i?(r+s)/2:r+(s-r)*Math.max(0,Math.min(1,(t-i)/(n-i)))}function io(t){const e=t.__bumpXValue instanceof Date?t.__bumpXValue.getTime():Number(t.__bumpXValue);return{value:t.__bumpValue,x:Number.isFinite(e)?e:void 0,y:t.__bumpValue,category:t.__bumpSeries}}function no(t){const e=t.config,o=new Map;for(const e of t.data){const t=o.get(e.__bumpSeries)??[];t.push(e),o.set(e.__bumpSeries,t)}const i=e.seriesOrder.filter(t=>o.has(t)).sort((t,i)=>(o.get(t)?.[0]?.__bumpHighlighted?1:0)-(o.get(i)?.[0]?.__bumpHighlighted?1:0)||e.seriesOrder.indexOf(t)-e.seriesOrder.indexOf(i)),n=[],r=[],s=[];for(const r of i){const i=(o.get(r)??[]).sort((t,e)=>t.x-e.x);if(2>i.length)continue;const a=i[0].__bumpHighlighted,c=(e.colorMap&&ct(e.colorMap,r))??t.resolveColor(i[0].__bumpSeries,i[0]),l=e.color??(a?c:e.neutralColor??t.theme.semantic.textSecondary??t.theme.semantic.border??c),u=i.map(o=>({x:t.scales.x(o.x),y:t.scales.y(o.y),radius:e.ribbon?oo(o.__bumpValue,e.valueExtent,e.ribbonSizeRange)/2:Math.max(.5,e.lineWidth/2)})),d=Je(u,{curve:e.curve,samplesPerSegment:e.samplesPerSegment}),h={fill:l,fillOpacity:1,opacity:a?e.ribbon?e.ribbonOpacity:e.lineOpacity:Math.min(e.ribbon?e.ribbonOpacity:e.lineOpacity,.58)};e.styleRules?.length&&Object.assign(h,xt(i[0].__bumpRaw,e.styleRules,io(i[0]))),e.areaStyle&&Object.assign(h,e.areaStyle(i[0].__bumpRaw)??{}),void 0!==e.stroke&&(h.stroke=e.stroke),void 0!==e.strokeWidth&&(h.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(h.opacity=e.opacity),n.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(t=>i[t]),accessibleDatum:i.map(t=>t.__bumpRaw),accessibility:{label:r+" ranking trajectory",tableFields:i.map(t=>t.__bumpRaw)},group:r,interactive:!0}),e.showPoints&&i.forEach((t,o)=>{const i={fill:l,stroke:"none",opacity:a?1:.75};e.styleRules?.length&&Object.assign(i,xt(t.__bumpRaw,e.styleRules,io(t))),e.pointStyle&&Object.assign(i,e.pointStyle(t.__bumpRaw)??{}),void 0!==e.stroke&&(i.stroke=e.stroke),void 0!==e.strokeWidth&&(i.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(i.opacity=e.opacity),n.push({type:"point",x:u[o].x,y:u[o].y,r:i.r??e.pointRadius,style:i,datum:t,accessibleDatum:t.__bumpRaw,accessibility:{label:`${r}, rank ${t.__bumpRank}, value ${t.__bumpValue}`},pointId:`${r}:${t.x}`})});const f=!0===e.showLabels?"end":e.showLabels,p=(t,o,i)=>{const n=null==e.labelPriorityAccessor?void 0:"function"==typeof e.labelPriorityAccessor?e.labelPriorityAccessor(t.__bumpRaw):Number(t.__bumpRaw[e.labelPriorityAccessor]);s.push({id:`${r}\0${i}`,datum:t,x:u[o].x,y:u[o].y,side:i,rank:t.__bumpRank,highlighted:a,priority:Number.isFinite(n)?n:void 0,color:"string"==typeof h.fill?h.fill:l})};"start"!==f&&"both"!==f||p(i[0],0,"start"),"end"!==f&&"both"!==f&&"auto"!==f||p(i.at(-1),i.length-1,"end")}const a=function(t,e,o,i){const n=Math.max(1,Math.floor(e/18)),r="auto"===o?Number.isFinite(i)&&(i??0)>=0?Math.min(n,Math.floor(i)):n:1/0,s=t.map((t,e)=>({candidate:t,index:e})).sort((t,e)=>(e.candidate.priority??0)-(t.candidate.priority??0)||Number(e.candidate.highlighted)-Number(t.candidate.highlighted)||t.candidate.rank-e.candidate.rank||t.index-e.index),a=[];for(const{candidate:t}of s){if(a.length>=r)break;a.some(e=>e.side===t.side&&14>Math.abs(e.y-t.y))||a.push(t)}return new Set(a.map(t=>t.id))}(s,t.dimensions.plot.height,"auto"!==(!0===e.showLabels?"end":e.showLabels)||"auto",e.maxLabels);for(const t of s)a.has(t.id)&&r.push((0,to.jsx)(eo,{datum:t.datum,x:t.x,y:t.y,side:t.side,color:t.color,highlighted:t.highlighted,labelStyle:e.labelStyle},t.id));return{nodes:n,overlays:r.length?(0,to.jsx)("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(t,e)=>{const o=function(t){const e=Array.isArray(t.datum)?t.datum[0]:t.datum;return e&&"object"==typeof e&&"__bumpSeries"in e?e:void 0}(t);if(e?.isActive&&o&&!e.predicate(o))return{opacity:.14}}}}var ro={frameType:"xy",layout:{margin:t=>({top:20,right:!1===t.showLabels?24:110,bottom:48,left:48})},buildProps:(t,e,o,i,n)=>{const r=function(t,e={}){const o=e.xAccessor??"x",i=e.yAccessor??"y",n=e.lineBy??"series",r=e.rankDirection??"descending",s=[],a=new Map,c=new Map,l=[],u=new Map;let d=1/0,h=-1/0;t.forEach((t,e)=>{const r=Xe(o,t,e),f=g(r);let p=a.get(f);null==p&&(p=s.length,a.set(f,p),s.push(r),c.set(p,[]));const y=Xe(n,t,e)+"";u.has(y)||(u.set(y,l.length),l.push(y));const m=Number(Xe(i,t,e));Number.isFinite(m)&&(d=Math.min(d,m),h=Math.max(h,m),c.get(p)?.push({datum:t,inputIndex:e,series:y,value:m}))});const f=[],p=new Map,y=new Map;for(let t=0;s.length>t;t++){const e=c.get(t)??[];e.sort((t,e)=>("descending"===r?e.value-t.value:t.value-e.value)||(u.get(t.series)??0)-(u.get(e.series)??0)),e.forEach((e,o)=>{const i=o+1;f.push({datum:e.datum,xIndex:t,xValue:s[t],series:e.series,value:e.value,rank:i}),p.set(e.series,(p.get(e.series)??0)+i),y.set(e.series,(y.get(e.series)??0)+1)})}const m=l.length+1,x=[...l].sort((t,e)=>{const o=y.get(t)??0,i=y.get(e)??0;return((p.get(t)??0)+(s.length-o)*m)/Math.max(1,s.length)-((p.get(e)??0)+(s.length-i)*m)/Math.max(1,s.length)||(u.get(t)??0)-(u.get(e)??0)}),b=new Set(x.slice(0,null==e.highlightTop?x.length:Math.max(0,Math.floor(e.highlightTop))));return{data:f.map(t=>{const e=b.has(t.series);return{...t.datum,x:t.xIndex,y:t.rank,__bumpRaw:t.datum,__bumpSeries:t.series,__bumpColorGroup:e?t.series:"Other",__bumpValue:t.value,__bumpRank:t.rank,__bumpXValue:t.xValue,__bumpHighlighted:e}}),xValues:s,seriesOrder:l,overallOrder:x,valueExtent:d===1/0?[0,0]:[d,h]}}(Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],{xAccessor:n.xAccessor,yAccessor:n.yAccessor,lineBy:n.lineBy,rankDirection:n.rankDirection,highlightTop:"number"==typeof n.highlightTop?n.highlightTop:void 0}),s=Math.max(1,r.seriesOrder.length),a=Ot(i.theme),c=function(t){const{seriesOrder:e,overallOrder:o,highlightTop:i,color:n,colorScheme:r,neutralColor:s,themeCategorical:a,themeNeutral:c}=t;if(null==i&&null==n)return r;const l=new Set(o.slice(0,null==i?o.length:Math.max(0,Math.floor(i)))),u=new Map,d={};for(const t of e)Object.defineProperty(d,t,{configurable:!0,enumerable:!0,writable:!0,value:n??(l.has(t)?qe(void 0,a,r,t,u):s??c??"#b8bec8")});return d}({seriesOrder:r.seriesOrder,overallOrder:r.overallOrder,highlightTop:"number"==typeof n.highlightTop?n.highlightTop:void 0,color:"string"==typeof n.color?n.color:void 0,colorScheme:o,neutralColor:"string"==typeof n.neutralColor?n.neutralColor:void 0,themeCategorical:a.colors.categorical,themeNeutral:a.colors.textSecondary}),l={ribbon:!0===n.ribbon,curve:"linear"===n.curve?"linear":"smooth",samplesPerSegment:"number"==typeof n.samplesPerSegment?n.samplesPerSegment:12,ribbonSizeRange:Array.isArray(n.ribbonSizeRange)?n.ribbonSizeRange:[4,28],valueExtent:r.valueExtent,seriesOrder:r.seriesOrder,lineWidth:"number"==typeof n.lineWidth?n.lineWidth:3,ribbonOpacity:"number"==typeof n.ribbonOpacity?n.ribbonOpacity:.82,lineOpacity:"number"==typeof n.lineOpacity?n.lineOpacity:.9,neutralColor:"string"==typeof n.neutralColor?n.neutralColor:void 0,color:"string"==typeof n.color?n.color:void 0,colorMap:c&&"object"==typeof c&&!Array.isArray(c)?c:void 0,stroke:"string"==typeof n.stroke?n.stroke:void 0,strokeWidth:"number"==typeof n.strokeWidth?n.strokeWidth:void 0,opacity:"number"==typeof n.opacity?n.opacity:void 0,styleRules:n.styleRules,areaStyle:i.areaStyle,pointStyle:i.pointStyle,labelStyle:n.labelStyle,showPoints:!0===n.showPoints,pointRadius:"number"==typeof n.pointRadius?n.pointRadius:3,showLabels:n.showLabels??!0,labelPriorityAccessor:n.labelPriorityAccessor,maxLabels:"number"==typeof n.maxLabels?n.maxLabels:void 0},u=i.xFormat,d=(t,e)=>{if(0===r.xValues.length)return"";const o=r.xValues[Math.max(0,Math.min(r.xValues.length-1,Math.round(Number(t))))];return u?u(o,e):(o instanceof Date?o.toLocaleDateString():o)+""},h=r.xValues.map((t,e)=>e),f=Array.from({length:s},(t,e)=>e+1),p=i.axes??[{orient:"left",tickValues:f,tickFormat:t=>t+"",label:i.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:i.xLabel,tickAnchor:"edges"}];return{...i,chartType:"custom",data:r.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,r.xValues.length-1)],yExtent:[s+.5,.5],customLayout:no,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:p,axisExtent:"exact",showAxes:i.showAxes??!0,showLegend:i.showLegend??!1,annotations:Ge(i.annotations,r.xValues)}}};function so(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Ot(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrAreaColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrAreaColorBy:e(t)})):r,u=e?lt(l,c,a):void 0,d=!1!==n.showLine,h="number"==typeof n.lineWidth?n.lineWidth:2,f="number"==typeof n.areaOpacity?n.areaOpacity:.7,p=ft(n.yAccessor),y=n.styleRules;return(t,o)=>{const i=e&&u?at(t,e,u):"string"==typeof n.color?n.color:ot,r={fill:i,fillOpacity:f,stroke:d?i:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(r,xt(t,y,{value:p(t),category:o})),void 0!==n.stroke&&(r.stroke=n.stroke),void 0!==n.strokeWidth&&(r.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(r.opacity=n.opacity),r}}function ao(t,e,o,i,n){if(!n.showPoints)return;const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Ot(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrPointColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrPointColorBy:e(t)})):r,u=e?lt(l,c,a):void 0,d="number"==typeof n.pointRadius?n.pointRadius:3;return t=>{const o=e&&u?at(t,e,u):"string"==typeof n.color?n.color:ot;return{r:d,fill:o,stroke:"none"}}}var co={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=e||n.lineBy,s=n.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",c=Ot(i.theme).colors.categorical,l=function(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Ot(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrLineColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrLineColorBy:e(t)})):r,u=e?lt(l,c,a):void 0,d=pt(n.xAccessor,n.yAccessor),h=function(t){const{lineWidth:e=2,colorBy:o,colorScale:i,color:n,resolveStroke:r,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=t;return(t,u)=>{const d={strokeWidth:e},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return r?f=r(t,u):o?i&&(f=at(t,o,i)):f=n||ot,void 0!==f&&(d.stroke=f,h&&(d.fill=f,d.fillOpacity=a)),c?.length&&Object.assign(d,xt(t,c,l?l(t,u):{value:void 0,category:u})),d}}({lineWidth:"number"==typeof n.lineWidth?n.lineWidth:2,colorBy:e,colorScale:u,color:"string"==typeof n.color?n.color:void 0,fillArea:n.fillArea,areaOpacity:"number"==typeof n.areaOpacity?n.areaOpacity:.3,styleRules:n.styleRules,ruleContext:d});return ht(h,{stroke:"string"==typeof n.stroke?n.stroke:void 0,strokeWidth:"number"==typeof n.strokeWidth?n.strokeWidth:void 0,opacity:"number"==typeof n.opacity?n.opacity:void 0})}(t,r,o,i,n),u=te({data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",lineBy:n.lineBy,colorBy:r,colorScheme:o,color:"string"==typeof n.color?n.color:void 0,forecast:n.forecast,anomaly:n.anomaly,gapStrategy:n.gapStrategy,directLabel:n.directLabel,annotations:i.annotations,themeCategorical:c,baseLineStyle:l}),d=i.pointStyle||ao(u.data,u.colorAccessor,o,i,n);let h=i.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const f=(!n.directLabel||void 0!==i.showLegend)&&(i.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:o,lineStyle:u.lineStyle||l,...Array.isArray(s)&&{areaGroups:s},...s&&null!=n.areaOpacity&&{areaOpacity:n.areaOpacity},...null!=n.band&&{band:n.band},...i,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!i.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},lo={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=Array.isArray(t)?P(t):[],s=n.timeAccessor||"time",a=n.valueAccessor||"value",c=n.categoryAccessor,l=n.valueExtent||i.yExtent,u="down"===n.direction?function({data:t,valueAccessor:e,timeAccessor:o,binSize:i,valueExtent:n,extentPadding:r}){if(n)return[n[1],n[0]];if(!t||0===t.length)return;const s=new Map;for(const n of t){const t=Ft(n,o,"time"),r=Ft(n,e,"value");if(null==t||null==r)continue;const a=Math.floor(t/i)*i;s.set(a,(s.get(a)??0)+r)}let a=0;for(const t of s.values())a=Math.max(a,t);return[a>0?a+a*(r??.1):1,0]}({data:r,timeAccessor:s,valueAccessor:a,binSize:Number(n.binSize),valueExtent:l,extentPadding:n.extentPadding}):l,d={...void 0!==n.fill&&{fill:n.fill},...void 0!==n.stroke&&{stroke:n.stroke},...void 0!==n.strokeWidth&&{strokeWidth:n.strokeWidth},...void 0!==n.opacity&&{opacity:n.opacity},...void 0!==n.cursor&&{cursor:n.cursor},...void 0!==n.gap&&{gap:n.gap}};return{chartType:"bar",data:r,...i,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,r.length),arrowOfTime:n.arrowOfTime||"right",timeAccessor:s,valueAccessor:a,xExtent:n.timeExtent||i.xExtent,yExtent:u,extentPadding:n.extentPadding??i.extentPadding,binSize:n.binSize,categoryAccessor:c,barColors:n.colors||i.barColors,colorScheme:n.colors||i.colorScheme,barStyle:i.barStyle||d,showLegend:i.showLegend??!!c}}},uo={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=e||n.areaBy,s=te({data:Array.isArray(t)?P(t):[],xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",lineBy:n.areaBy,forecast:n.forecast,anomaly:n.anomaly,annotations:i.annotations,themeCategorical:Ot(i.theme).colors.categorical}),a=function({data:t,safeData:e,areaBy:o,lineDataAccessor:i}){if(null==t)return[];const n=void 0!==e[0]?.[i];if(!n&&!o)return e;let r;if(n)r=e;else{const t=e.reduce((t,e)=>{const n="function"==typeof o?o(e):e[o],r=n+"";if(!t[r]){const e={[i]:[]};"string"==typeof o&&(e[o]=n),t[r]=e}return t[r][i].push(e),t},{});r=Object.values(t)}return r.flatMap(t=>{const e=Array.isArray(t[i])?t[i]:[];return"string"==typeof o?e.map(e=>({...e,[o]:e[o]??t[o]})):e})}({data:t,safeData:s.data,areaBy:n.areaBy,lineDataAccessor:n.lineDataAccessor||"coordinates"}),c=function(t){if(t)return Array.isArray(t)?{stops:t.map(({at:t,color:e,opacity:o})=>({offset:t/100,color:e,...null!=o&&{opacity:o}}))}:Array.isArray(t.stops)?t:void 0}(n.semanticGradient),l=c?.stops.length?{stops:c.stops.map(t=>({...t,offset:1-t.offset})).sort((t,e)=>t.offset-e.offset)}:kt(i.gradientFill),u=!1!==n.semanticLine?function(t){const e=t?.stops.filter(t=>"string"==typeof t.color&&Number.isFinite(t.offset)).map(({offset:t,color:e,opacity:o})=>({offset:Math.max(0,Math.min(1,t)),color:e,...Number.isFinite(o)&&{opacity:Math.max(0,Math.min(1,o))}})).sort((t,e)=>t.offset-e.offset);if(!e?.length)return;const o=e[0];return o.offset>0?[{...o,offset:0},...e]:e}(c):void 0,d=i.pointStyle||ao(a,r,o,i,n);return{chartType:"area",data:a,xAccessor:s.xAccessor,yAccessor:s.yAccessor,y0Accessor:n.y0Accessor,groupAccessor:n.areaBy||void 0,colorAccessor:r,colorScheme:o,...i,...s.annotations.length>0&&{annotations:s.annotations},...s.yExtent&&!i.yExtent&&{yExtent:s.yExtent},...void 0!==l&&{gradientFill:l},...u&&{semanticLineStops:u},lineStyle:i.lineStyle||so(a,r,o,i,n),...d&&{pointStyle:d}}}},ho={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=n.xAccessor||"x",s=n.seriesAAccessor||"a",a=n.seriesBAccessor||"b",c=t=>Mt(At(r,"x",t)),l=t=>Mt(At(s,"a",t)),u=t=>Mt(At(a,"b",t)),d=n.seriesAColor||"var(--semiotic-danger, #dc2626)",h=n.seriesBColor||"var(--semiotic-info, #2563eb)",f=n.areaOpacity??.6,p=n.lineWidth??1.5,y=!1!==n.showLines,g=!1!==i.showLegend,m=n.seriesALabel||"A",x=n.seriesBLabel||"B",b=i.legendPosition||"right",v=function(t,e,o,i){if(!t.length)return[];const n=t.filter(t=>Number.isFinite(e(t))).sort((t,o)=>e(t)-e(o)),r=[];let s=0,a=null,c=null,l=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;n.length>t;t++){const r=n[t],p=e(r),y=o(r),g=i(r);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let t,e;if(l.length>0)t=l[0].x,e=l[0].y;else{const o=y-c.a-(g-c.b);if(0!==o){const i=Math.max(0,Math.min(1,(c.b-c.a)/o));t=c.x+i*(p-c.x),e=c.a+i*(y-c.a)}else t=c.x,e=c.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const t of l)f(t,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:r})}for(const t of l)f(t,a??"A");return r}(Array.isArray(t)?t:[],c,l,u),w=[];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),o=l(t),i=u(t);Number.isFinite(o)&&w.push({__x:e,__y:o,__diffSegment:"line-A"}),Number.isFinite(i)&&w.push({__x:e,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(t=>t.__diffSegment))),areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?d:h,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:n.curve||"linear",...i,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},fo={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=e||n.areaBy,s="string"==typeof r&&Array.isArray(t)?lt(t,r,o):void 0,a="number"==typeof n.areaOpacity?n.areaOpacity:.7,c=i.lineStyle||(t=>{const e=null==r?void 0:at(t,r,s),o=n.showLine??!0,i={fill:n.color??e,stroke:o?n.stroke??e:"none",...o?{strokeWidth:n.strokeWidth??n.lineWidth??2}:{},fillOpacity:a,...null==n.opacity?{}:{opacity:n.opacity}},c=n.styleRules;if(c?.length){const e=ft(n.yAccessor),o=r?"function"==typeof r?(r(t)??"")+"":(t[r]??"")+"":void 0;Object.assign(i,xt(t,c,{value:e(t),category:o}))}return i}),l=n.normalize?"zero":n.baseline??"zero",u=i.pointStyle||ao(t,r,o,i,n);return{chartType:"stackedarea",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.areaBy,colorAccessor:r,colorScheme:o,normalize:n.normalize,baseline:l,stackOrder:n.stackOrder,lineStyle:c,...i,...u&&{pointStyle:u},curve:i.curve??n.curve??"monotoneX",showLegend:i.showLegend??!!r}}},po={frameType:"xy",buildProps:(t,e,o,i,n)=>{const[r]=i.size??[600,400];return{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,...i,scalePadding:i.scalePadding??Math.max(2,Math.min(12,Math.round(r/40))),extentPadding:i.extentPadding??(r>200?.1:.02)}}},yo={frameType:"xy",buildProps:(t,e,o,i,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",h=c.strokeWidth??1,f=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=M.createElement,y=a?[(t,e,o)=>{if(!e?.x||!e?.y)return null;const i=o.width,n=o.height,c=null!=r?e.x(r):i/2,y=null!=s?e.y(s):n/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(i,c)),m=Math.max(0,Math.min(n,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:i-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:n-m},{c:a.bottomRight,x:g,y:m,w:i-g,h:n-m}],b=l?[p("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:i-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:n-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:i-8,y:n-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(M.Fragment,null,...x.map((t,e)=>t.w>0&&t.h>0?p("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),p("line",{key:"vc",x1:g,y1:0,x2:g,y2:n,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:i,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[3,15],colorScheme:o,pointStyle:i.pointStyle||n.pointStyle||ee(t,e,o,i,n),...i,showLegend:i.showLegend??!!e,...y&&{svgPreRenderers:y}}}},go={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const o=e.xAccessor||"x",i=e.yAccessor||"y",n=e.orderAccessor?[...t].sort((t,o)=>null==t||"object"!=typeof t?1:null==o||"object"!=typeof o?-1:Mt(At(e.orderAccessor,"order",t))-Mt(At(e.orderAccessor,"order",o))):t,r=new WeakMap;let s=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=Mt(At(o,"x",t)),n=Mt(At(i,"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=Mt(At(o,"x",t)),n=Mt(At(i,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&r.set(t,{idx:a++,total:s})}return{data:n,orderMap:r}}(t,n),s=te({data:r.data,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",forecast:n.forecast,anomaly:n.anomaly,annotations:i.annotations,themeCategorical:Ot(i.theme).colors.categorical}),a=jt(s.annotations,n.regression),c=n.pointRadius??4,l=pt(n.xAccessor,n.yAccessor),u=n.styleRules,d=[t=>{const e=t.filter(t=>"point"===t.type&&"number"==typeof t.x&&"number"==typeof t.y);if(2>e.length)return null;const o=[];for(let t=0;e.length-1>t;t++){const i=e[t],n=e[t+1],r=_t(t,e.length);100>e.length&&o.push(M.createElement("line",{key:"halo-"+t,x1:i.x,y1:i.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:c+2,strokeLinecap:"round",opacity:.5})),o.push(M.createElement("line",{key:"segment-"+t,x1:i.x,y1:i.y,x2:n.x,y2:n.y,stroke:r,strokeWidth:c,strokeLinecap:"round"}))}return M.createElement(M.Fragment,null,...o)}];return{chartType:"scatter",data:s.data,xAccessor:s.xAccessor,yAccessor:s.yAccessor,colorAccessor:e,colorScheme:o,pointStyle:ht(t=>{const e=r.orderMap.get(t),o=e?.idx??0,i=e?.total??1,n={fill:i>0?_t(o,i):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1};return u?.length&&Object.assign(n,xt(t,u,l(t))),n},Pt(n)),...i,...a&&a.length>0&&{annotations:a},...s.yExtent&&!i.yExtent&&{yExtent:s.yExtent},svgPreRenderers:d}}},mo={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=n.frameProps&&"object"==typeof n.frameProps?n.frameProps:void 0,s=Number.isFinite(n.cellBorderWidth)?Math.max(0,n.cellBorderWidth):1,a=("string"==typeof r?.colorScheme?r.colorScheme:void 0)??o,c=null!=r&&Object.hasOwn(r,"heatmapColorScale"),l=r?.heatmapColorScale,u=c?"function"==typeof l?l:void 0:"custom"===a&&"function"==typeof n.customColorScale?n.customColorScale:void 0;return{chartType:"heatmap",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",valueAccessor:n.valueAccessor,showValues:n.showValues,heatmapValueFormat:n.valueFormat,areaStyle:()=>({stroke:n.cellBorderColor??"#fff",strokeWidth:s}),...i,...void 0!==a&&{colorScheme:a},...u&&{heatmapColorScale:u}}}};function xo(t){return Math.max(0,Math.min(1,t))}function bo(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 o=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const t=[Number(o[1]),Number(o[2]),Number(o[3])];if(t.every(Number.isFinite))return t}return null}function vo(t,e,o){const i=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(o)}`}function wo(t,e,o){const i=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:xo(t.offset),color:t.color??o,opacity:null==t.opacity?1:xo(t.opacity)})).sort((t,e)=>t.offset-e.offset);if(0===i.length)return"#999999";const n=t=>{if(1===t.opacity)return t.color;const e=bo(t.color);return e?`rgba(${e[0]},${e[1]},${e[2]},${t.opacity})`:t.color};if(1===i.length)return n(i[0]);const r=xo(e);if(i[0].offset>=r)return n(i[0]);if(r>=i[i.length-1].offset)return n(i[i.length-1]);for(let t=0;i.length-1>t;t++){const e=i[t],o=i[t+1];if(e.offset>r||r>o.offset)continue;const s=o.offset-e.offset,a=s>0?(r-e.offset)/s:0,c=bo(e.color),l=bo(o.color);if(!c||!l)return n(.5>a?e:o);const[u,d,h]=c,[f,p,y]=l,g=u+(f-u)*a,m=d+(p-d)*a,x=h+(y-h)*a,b=e.opacity+(o.opacity-e.opacity)*a;return 1===b?vo(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return n(i[i.length-1])}function ko(t,e,o){return null==o?`${t}-${e}`:`${t}-${e}-${o}`}var So=require("react/jsx-runtime");function Ao(t=240){const e=360-t,o=180+e/2,i=o*Math.PI/180;return{sweepRad:t*Math.PI/180,gapDeg:e,startAngleDeg:o,startAngleRad:i,offsetRad:-Math.PI/2+i}}require("react");var Mo={RdBu:V,PiYG:H,PRGn:U,BrBG:K,RdYlBu:Z,RdYlGn:Q,Spectral:J},_o="__likert_neutral_neg",Po="__likert_neutral_pos";function jo(t,e){if("function"==typeof t)return t;const o=t||e;return t=>t[o]}var Lo=c(require("react"));function $o(t){return kt(t)}function Ro(t,e,o,i,n){const r=Ot(i.theme).colors.categorical,s=o??i.colorScheme,a=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],c="string"==typeof e?e:"__ssrColorBy",l="function"==typeof e?a.map(t=>({...t,__ssrColorBy:e(t)})):a,u=e?lt(l,c,s??r):void 0,d=qe("string"==typeof n.color?n.color:void 0,r,s,void 0,new Map),h=ft(n.valueAccessor),f=n.styleRules,p=i.pieceStyle;return(t,o)=>{const i={fill:e&&u?at(t,e,u):d};return f?.length&&Object.assign(i,xt(t,f,{value:h(t),category:o})),"function"==typeof p?Object.assign(i,p(t,o)||{}):p&&"object"==typeof p&&Object.assign(i,p),void 0!==n.stroke&&(i.stroke=n.stroke),void 0!==n.strokeWidth&&(i.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(i.opacity=n.opacity),i}}function Co(t,e,o,i,n){const r=Ro(t,e,o,i,n);return(t,e)=>{const o=r(t,e);return void 0===o.fillOpacity&&(o.fillOpacity=.8),void 0===o.stroke&&(o.stroke=o.fill),o}}function Io(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s="string"==typeof e?e:"__ssrViolinColorBy",a="function"==typeof e?r.map(t=>({...t,__ssrViolinColorBy:e(t)})):r,c=Ot(i.theme).colors.categorical,l=o??i.colorScheme,u=e?lt(a,s,l??c):void 0,d=qe("string"==typeof n.color?n.color:void 0,c,l,void 0,new Map);return t=>{const o=e&&u?at(t,e,u):d;return{fill:o,fillOpacity:.6,stroke:n.stroke??o,...void 0!==n.strokeWidth&&{strokeWidth:n.strokeWidth},...void 0!==n.opacity&&{opacity:n.opacity}}}}function To(t,e,o,i,n){const r=Ro(t,e,o,i,n),s="number"==typeof n.dotRadius?n.dotRadius:5;return(t,e)=>({r:s,fillOpacity:.8,...r(t,e)})}function Oo(t,e,o,i,n){const r=Ro(t,e,o,i,n),s=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],a=n.sizeBy,c=Array.isArray(n.sizeRange)?n.sizeRange:[3,8],l=a?s.map(t=>"function"==typeof a?a(t):Number(t[a])).filter(Number.isFinite):[],u=l.length?Nt(l):void 0,d="number"==typeof n.pointRadius?n.pointRadius:4,h="number"==typeof n.pointOpacity?n.pointOpacity:.7;return(t,e)=>({r:a?ut(t,a,c,u):d,fillOpacity:h,...r(t,e)})}var zo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=jt(i.annotations,n.regression);return{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:o,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,...r&&{annotations:r},gradientFill:$o(i.gradientFill),pieceStyle:Ro(t,e,o,i,n)}}},Fo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.stackBy;return{chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.stackBy,colorAccessor:r,colorScheme:o,projection:"horizontal"===n.orientation?"horizontal":"vertical",normalize:n.normalize,oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,gradientFill:$o(i.gradientFill),pieceStyle:Ro(t,r,o,i,n),showLegend:i.showLegend??!!r}}},No={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.groupBy;return{chartType:"clusterbar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",groupBy:n.groupBy,colorAccessor:r,colorScheme:o,projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,gradientFill:$o(i.gradientFill),pieceStyle:Ro(t,r,o,i,n),showLegend:i.showLegend??!!r}}},Eo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.categoryAccessor;return{chartType:"pie",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",colorAccessor:r,colorScheme:o,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...null!=n.startAngle&&{startAngle:n.startAngle},...i,pieceStyle:Ro(t,r,o,i,n),showLegend:i.showLegend??!!r}}},Do={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(t,e,o,i,n)=>{const r=e||n.categoryAccessor;return{chartType:"donut",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",margin:i.margin??{top:50,right:40,bottom:60,left:70},innerRadius:n.innerRadius??60,colorAccessor:r,colorScheme:o,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...null!=n.startAngle&&{startAngle:n.startAngle},...i,pieceStyle:Ro(t,r,o,i,n)}}},Bo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=n.valueAccessor||"value",a=r.map(t=>Number("function"==typeof s?s(t):t[s])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:t,oAccessor:n.categoryAccessor||(t=>null==t.category?"All":t.category+""),rAccessor:s,projection:"horizontal",bins:n.bins??25,normalize:n.relative??!1,colorAccessor:e,colorScheme:o,barPadding:n.categoryPadding??20,...n.valueExtent?{rExtent:n.valueExtent}:c?{rExtent:c}:{},...i,summaryStyle:Co(t,e,o,i,n)}}},Wo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"boxplot",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:o,...null!=n.showOutliers&&{showOutliers:n.showOutliers},...null!=n.outlierRadius&&{outlierRadius:n.outlierRadius},...i,summaryStyle:i.summaryStyle||Co(t,e,o,i,n)})},Yo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"violin",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,projection:"horizontal"===n.orientation?"horizontal":"vertical",bins:n.bins??25,showIQR:n.showIQR??!0,barPadding:n.categoryPadding??20,colorScheme:o,...i,summaryStyle:i.summaryStyle||Io(t,e,o,i,n),showLegend:i.showLegend??!!e,...n.valueExtent&&{rExtent:n.valueExtent}})},qo={frameType:"ordinal",buildProps:(t,e,o,i,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:o,...i,sizeRange:n.sizeRange||[3,8],pieceStyle:i.pieceStyle||Oo(t,e,o,i,n),showLegend:i.showLegend??!!e})},Xo={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(t,e,o,i,n)=>{const r=jt(i.annotations,n.regression);return{chartType:"point",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:o,projection:"vertical"===n.orientation?"vertical":"horizontal",oSort:n.sort??"auto",barPadding:n.categoryPadding??10,...i,...r&&{annotations:r},pieceStyle:To(t,e,o,i,n),showGrid:i.showGrid??!0,showLegend:i.showLegend??!!e}}},Go={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.subcategoryAccessor;return{chartType:"swimlane",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.subcategoryAccessor,colorAccessor:r,categoryAccessor:n.categoryAccessor,subcategoryAccessor:n.subcategoryAccessor,colorScheme:o,projection:"vertical"===n.orientation?"vertical":"horizontal",...null!=n.trackFill&&{trackFill:n.trackFill},...n.valueExtent&&{rExtent:n.valueExtent},...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,gradientFill:$o(i.gradientFill),pieceStyle:i.pieceStyle||Ro(t,r,o,i,n),showLegend:i.showLegend??!!r,barPadding:n.barPadding??40}}},Vo={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"ridgeline",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:o,projection:"vertical"===n.orientation?"vertical":"horizontal",bins:n.bins??20,amplitude:n.amplitude??1.5,barPadding:n.categoryPadding??5,oSort:n.oSort??!1,...i,summaryStyle:i.summaryStyle||((r,s)=>({fillOpacity:.5,...Ro(t,e,o,i,n)(r,s)})),showLegend:i.showLegend??!!e})},Ho={frameType:"ordinal",layout:{margin:(t,e)=>({...e.marginDefaults,left:"vertical"===t.orientation?e.marginDefaults.left:Math.max(100,e.marginDefaults.left)})},buildProps:(t,e,o,i,n)=>{const r=Array.isArray(n.levels)&&n.levels.length>=2?n.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==n.orientation;let a=function(t,e,o,i,n,r){const s=new Map,a=new Set(e);for(const c of t){const t=o(c);s.has(t)||s.set(t,new Map);const l=s.get(t);if(i){const t=i(c);if(null==t||!Number.isFinite(t))continue;if(!Number.isInteger(t)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",t);continue}const o=t-1;if(0>o||o>=e.length)continue;const n=e[o];l.set(n,(l.get(n)||0)+1)}else if(n&&r){const t=n(c),e=r(c);if(!a.has(t))continue;l.set(t,(l.get(t)||0)+(Number.isFinite(e)?e:0))}}const c=[];for(const[t,o]of s){let i=0;for(const t of e)i+=o.get(t)||0;if(0!==i)for(let n=0;e.length>n;n++){const r=e[n],s=o.get(r)||0;c.push({__likertCategory:t,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/i*100,__likertLevelIndex:n})}}return c}(Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],r,jo(n.categoryAccessor,"question"),n.levelAccessor?null:jo(n.valueAccessor,"score"),n.levelAccessor?jo(n.levelAccessor,"level"):null,n.levelAccessor?jo(n.countAccessor,"count"):null);s&&(a=function(t,e){const o=e.length,i=o%2!=0,n=Math.floor(o/2),r=new Map;for(const e of t){const t=r.get(e.__likertCategory)||[];t.push(e),r.set(e.__likertCategory,t)}const s=[];for(const[,t]of r){const e=new Map;let r,a;for(const o of t)o.__likertLevel===_o?r=o:o.__likertLevel===Po?a=o:e.set(o.__likertLevelIndex,o);i&&r&&s.push(r);for(let t=n-1;t>=0;t--){const o=e.get(t);o&&s.push(o)}i&&a&&s.push(a);for(let t=i?n+1:n;o>t;t++){const o=e.get(t);o&&s.push(o)}}return s}(function(t,e){const o=e.length,i=o%2!=0,n=Math.floor(o/2),r=[];for(const e of t){const t=e.__likertLevelIndex;if(i&&t===n){const t=e.__likertPct/2;r.push({...e,__likertLevel:_o,__likertPct:-t}),r.push({...e,__likertLevel:Po,__likertPct:t})}else r.push(n>t?{...e,__likertPct:-e.__likertPct}:e)}return r}(a,r),r));const c=Ot(i.theme).colors.diverging,l=Array.isArray(o)&&o.length>=r.length?o:function(t,e){if(0>=t)return[];if(e&&Object.prototype.hasOwnProperty.call(Mo,e)){const o=Mo[e];if(1===t)return[o(.5)];const i=[];for(let e=0;t>e;e++)i.push(o(e/(t-1)));return i}const o=["#da1e28","#ff8389","#ffb3b8"],i=["#a6c8ff","#4589ff","#0043ce"],n="#a8a8a8";if(1===t)return[n];const r=t%2!=0,s=Math.floor(t/2),a=[];for(let t=0;s>t;t++)a.push(o[Math.min(Math.floor(t*o.length/s),o.length-1)]);r&&a.push(n);for(let t=0;s>t;t++)a.push(i[Math.min(Math.floor(t*i.length/s),i.length-1)]);return a}(r.length,c),u=new Map(r.map((t,e)=>[t,l[e]||"#888"])),d=r.length%2&&u.get(r[Math.floor(r.length/2)])||"#888",h="function"==typeof n.valueFormat?n.valueFormat:t=>Math.abs(Number(t)).toFixed(0)+"%",f=re(!1===i.showLegend?void 0:{legendGroups:[{label:"",items:r.map(t=>({label:t})),styleFn:t=>({fill:u.get(t.label)||"#888"})}]},i.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:n.barPadding,showGrid:i.showGrid,oLabel:n.categoryLabel,rLabel:n.valueLabel||(s?void 0:"Percentage"),rFormat:h,...n.categoryFormat&&{oFormat:n.categoryFormat},...n.valueExtent&&{rExtent:n.valueExtent},...i,pieceStyle:ht(t=>{const e=t.__likertLevel||t.data?.__likertLevel;return{fill:e===_o||e===Po?d:u.get((t.__likertLevelLabel||t.data?.__likertLevelLabel||e)+"")||"#888"}},Pt(n)),showLegend:i.showLegend??!0,legendPosition:i.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},Uo={frameType:"ordinal",layout:{margin:(t,e)=>"vertical"===t.orientation?{top:e.title?60:40,right:20,bottom:60,left:60}:{top:e.title?40:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r="vertical"===n.orientation,s=e||n.categoryAccessor;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:n.stepAccessor||"step",rAccessor:n.valueAccessor||"value",colorAccessor:s,categoryAccessor:n.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:n.connectorAccessor,connectorStyle:n.connectorStyle,...!r&&null!=n.connectorOpacity&&{connectorOpacity:n.connectorOpacity},barPadding:r?40:0,colorScheme:o,...i,showAxes:r&&!1!==i.showAxes,showGrid:r,pieceStyle:Ro(t,s,o,i,n),showLabels:n.showLabels??!0}}},Ko={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(t,{theme:e}){const o=t.__gauge;if(!o)return null;const i=(o.startAngleDeg+(o.gMax===o.gMin?0:(Math.max(o.gMin,Math.min(o.gMax,o.value??o.gMin))-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,n=o.needleColor||e.colors.text,r=o.showScaleLabels?(o.thresholds||[]).filter(t=>t.value>o.gMin&&o.gMax>t.value):[];return(0,So.jsxs)(So.Fragment,{children:[o.showNeedle&&(0,So.jsxs)(So.Fragment,{children:[(0,So.jsx)("line",{x1:o.centerX,y1:o.centerY,x2:o.centerX+o.needleLength*Math.cos(i),y2:o.centerY+o.needleLength*Math.sin(i),stroke:n,strokeWidth:2.5,strokeLinecap:"round"}),(0,So.jsx)("circle",{cx:o.centerX,cy:o.centerY,r:4,fill:n})]}),null!=o.contextValue&&(0,So.jsx)("text",{x:o.centerX,y:o.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:o.valueFontSize,fontWeight:700,fill:n,children:o.contextValue}),r.map((t,i)=>{const n=(o.startAngleDeg+(o.gMax===o.gMin?0:(t.value-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,r=o.innerRadius-1,s=o.radius+1,a=o.radius+10,c=((n+Math.PI/2)/(2*Math.PI)*12+12)%12,l=c>=11||1>c?"middle":5>c?"start":7>c?"middle":"end",u=c>=11||1>c?"auto":5>c?"middle":7>c?"hanging":"middle";return(0,So.jsxs)("g",{children:[(0,So.jsx)("line",{x1:o.centerX+Math.cos(n)*r,y1:o.centerY+Math.sin(n)*r,x2:o.centerX+Math.cos(n)*s,y2:o.centerY+Math.sin(n)*s,stroke:e.colors.border,strokeWidth:2,strokeLinecap:"round"}),(0,So.jsx)("text",{x:o.centerX+Math.cos(n)*a,y:o.centerY+Math.sin(n)*a,textAnchor:l,dominantBaseline:u,fill:e.colors.textSecondary,fontSize:10,children:t.label||t.value+""})]},"gauge-label-"+i)})]})},buildProps:(t,e,o,i,n)=>{const r=n.min??0,s=n.max??100,a=n.sweep??240,c=n.arcWidth??.3,l=!1!==n.showNeedle,u=!1!==n.fillZones,{startAngleDeg:d}=Ao(a),h=n.thresholds||[{value:s,color:n.color||"#4e79a7"}],f=St(i.gradientFill),p=function(t){const{min:e,max:o,value:i,thresholds:n,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,d=o-e||1,h=(Math.max(e,Math.min(o,i))-e)/d;let f=n&&n.length>0?[...n].sort((t,e)=>t.value-e.value):[{value:o,color:r||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(o,t.value))})),o>f[f.length-1].value&&f.push({value:o,color:f[f.length-1].color});const p=!!l&&l.stops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?h:1,e=ko("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)),o=Math.max(1,Math.min(e,Math.round(t*e))),i=[];for(let e=0;o>e;e++)i.push(wo(l.stops,t*(e+.5)/o,r||f[0]?.color||"#007bff"));const n=ko("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:i}}),g.set(n,{fill:i[0]||s})}}else{let t=e;for(let o=0;f.length>o;o++){const i=f[o],n=(i.value-t)/d,r=(t-e)/d,c=(i.value-e)/d,l=Math.max(0,(a?Math.min(h,c):c)-r),u=a?Math.max(0,n-l):0;if(l>0){const t=ko("fill",o);y.push({category:t,value:l,_zone:i.label||"Zone "+(o+1),_isFill:!0}),g.set(t,{fill:i.color})}if(u>0){const t=ko("bg",o);y.push({category:t,value:u,_zone:i.label||"Zone "+(o+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=i.value}}if(c&&n&&n.length>0)for(const t of n)t.value>e&&o>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:h,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==n.showScaleLabels,gradientFill:f}),[y,g]=i.size||[300,250],m=function(t=240){const{sweepRad:e,offsetRad:o}=Ao(t),i=[[Math.cos(o),Math.sin(o)],[Math.cos(o+e),Math.sin(o+e)],[0,0]];for(let t=0;2*Math.PI>t;t+=Math.PI/2)((t-o)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>e+.001||i.push([Math.cos(t),Math.sin(t)]);const n=i.map(t=>t[0]),r=i.map(t=>t[1]),[s,a]=Nt(n),[c,l]=Nt(r);return{minX:s,maxX:a,minY:c,maxY:l,width:a-s,height:l-c,cx:(s+a)/2,cy:(c+l)/2}}(a),x=Math.min(10,Math.max(1,Math.min(y,g)/12)),b=Math.max(4,Math.min((y-2*x)/m.width,(g-2*x)/m.height)-2),v=Math.max(0,Math.min(b-1.5,b*(1-c))),w=y/2-m.cx*b,k=g/2-m.cy*b,S=2*(b+4),A=Math.max(r,Math.min(s,n.value??r)),M="function"==typeof n.valueFormat?n.valueFormat(A):Math.round(A)+"",_=n.centerContent??i.centerContent,P=null!=_?"function"==typeof _?_(A,r,s):_:"sparkline"===n.mode||"context"===n.mode?void 0:Lo.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},Lo.createElement("div",{style:{fontSize:Math.max(16,.3*b),fontWeight:700,color:"var(--semiotic-text, #333)"}},M),!1!==n.showScaleLabels&&Lo.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${r} – ${s}`));return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:v,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:ht(p.pieceStyle,Pt(n)),...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...i,size:[y,g],margin:{top:k-S/2,bottom:g-k-S/2,left:w-S/2,right:y-w-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:A,startAngleDeg:d,thresholds:h,centerX:w,centerY:k,radius:b,innerRadius:v,showScaleLabels:!1!==n.showScaleLabels,needleLength:v>20?v-8:b-1,showNeedle:l,needleColor:n.needleColor,..."context"===n.mode&&null==_&&{contextValue:M,contextValueY:k-.2*v,valueFontSize:Math.max(12,Math.min(22,.28*b))}}}}},Zo=require("d3-scale"),Qo={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function Jo(t="static"){return Qo[t]??Qo.static}var ti=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function ei(t){return"fatal"===t.severity||"warn"===t.severity?t.severity:ti.has(t.kind)?"fatal":"warn"}function oi(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`:"duplicate-node"===t.kind?`node id "${t.id}" is duplicated`:"duplicate-edge"===t.kind?`edge id "${t.id}" is duplicated`:"invalid-system-time"===t.kind?`edge ${t.id} has an invalid systemInTime or systemOutTime`:t.kind}function ii(t){const{desired:e,minGaps:o,weights:i}=t,n=e.length;if(0===n)return[];if(o.length!==Math.max(0,n-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const r=Array(n).fill(0);for(let t=1;n>t;t++)r[t]=r[t-1]+Math.max(0,Number.isFinite(o[t-1])?o[t-1]:0);const s=[];for(let t=0;n>t;t++){const o=Math.max(Number.EPSILON,Number.isFinite(i?.[t])?i[t]:1),n=(Number.isFinite(e[t])?e[t]:0)-r[t];for(s.push({start:t,end:t,weight:o,mean:n});s.length>1;){const t=s[s.length-1],e=s[s.length-2];if(t.mean>=e.mean)break;const o=e.weight+t.weight;s.splice(s.length-2,2,{start:e.start,end:t.end,weight:o,mean:(e.mean*e.weight+t.mean*t.weight)/o})}}const a=Number.isFinite(t.min)?t.min:-1/0,c=Number.isFinite(t.max)?t.max-r[n-1]:1/0,l=a>c?a:c,u=Array(n);for(const t of s){const e=Math.max(a,Math.min(l,t.mean));for(let o=t.start;t.end>=o;o++)u[o]=e+r[o]}return u}function ni(t,e){let o=0,i=t.length-1,n=-1;for(;i>=o;){const r=o+i>>>1;t[r].at>e?i=r-1:(n=r,o=r+1)}return 0>n?{at:e,before:0,after:0}:t[n]}function ri(t,e=0){if(0===t.length)return{adjacentClearance:[],positions:[]};const o=[],i=[0];for(let n=0;t.length-1>n;n++){const r=t[n],s=t[n+1],a=[...new Set([...r.map(t=>t.at),...s.map(t=>t.at)])].sort((t,e)=>t-e);let c=0;for(const t of a){const e=ni(r,t),o=ni(s,t);c=Math.max(c,e.after+o.before)}o.push(c),i.push(i[i.length-1]+c+e)}return{adjacentClearance:o,positions:i}}function si(t,e,o,i={}){let n=[...t];if(1>=n.length)return n;let r=[...n],s=o(n),a=1;const c=Math.max(0,i.passes??6),l=Math.max(1,i.maxEvaluations??1/0);for(let t=0;c>t&&l>a;t++){const t=new Map(n.map((t,e)=>[t,e])),c=new Map,l=new Map;for(const o of e){const e=t.get(o.source),i=t.get(o.target);if(null==e||null==i)continue;const n=Number.isFinite(o.weight)&&o.weight>0?o.weight:1;c.set(o.source,(c.get(o.source)??0)+i*n),l.set(o.source,(l.get(o.source)??0)+n),c.set(o.target,(c.get(o.target)??0)+e*n),l.set(o.target,(l.get(o.target)??0)+n)}n=n.map((t,e)=>({item:t,index:e,barycenter:(c.get(t)??e)/(l.get(t)??1)})).sort((t,e)=>t.barycenter-e.barycenter||(i.compare?.(t.item,e.item)??t.index-e.index)).map(t=>t.item);const u=o(n);if(a++,s>u)s=u,r=[...n];else if(u===s)break}return r}function ai(t,e,o={}){const i=[...t],n=i.length;if(1>=n||n>(o.maxItems??8))return i;const r=Math.max(1,o.maxEvaluations??1/0);let s=0,a=[...i],c=1/0;const l=()=>{if(s>=r)return;const t=e(i);s++,c>t&&(c=t,a=[...i])};l();const u=Array(n).fill(0);let d=0;for(;n>d&&r>s;)if(d>u[d]){const t=d%2==0?0:u[d];[i[t],i[d]]=[i[d],i[t]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function ci(){return Object.create(null)}function li(t,e){return e>t?-1:t>e?1:0}function ui(t){return t.occupants.map(t=>t.id).sort(li).join("\0")}function di(t,e,o=0){return t.slice(0,-1).map((i,n)=>null!=i.group&&i.group===t[n+1].group?o:e)}function hi(t,e){return t.map(t=>{const o=new Map;for(const i of t.occupants){const t=e[i.id];if(t)for(const e of t.samples){const t=o.get(e.t)??{before:0,after:0},i=e.boundaryOffset??0;o.set(e.t,{before:Math.max(t.before,e.topMass-i),after:Math.max(t.after,e.botMass+i)})}}return[...o].sort((t,e)=>t[0]-e[0]).map(([t,e])=>({at:t,...e}))})}function fi(t,e,o){if(0===t.length)return[];const{padding:i,plotH:n,valueScale:r}=o,s=o.stackValueScale??r,a=di(t,i,o.groupPadding??0),c=[i+t[0].peak.topPeak*s];for(let o=1;t.length>o;o++)c.push(c[o-1]+e[o-1]*s+a[o-1]);const l=c[c.length-1]+t[t.length-1].peak.botPeak*s+i;if(l>n&&l>0){const t=n/l;for(let e=0;c.length>e;e++)c[e]*=t}return c}function pi(t,e){const o=(t.boundaryOffset??0)*e,i=t.value*e;if("out"===t.kind){const n=t.sideMassBefore*e;return o+("top"===t.side?i/2-n:n-i/2)}const n=t.sideMassAfter*e;return o+("top"===t.side?i/2-n:n-i/2)}function yi(t,e,o,i,n,r){const s=r.adjacentClearance?[...r.adjacentClearance]:ri(hi(i,o)).adjacentClearance,a=fi(i,s,r);let c="hug"===r.lanePlacement?function(t,e,o,i,n,r,s){const a=t.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=di(t,c,s.groupPadding??0),h=n.map((t,e)=>t*u+d[e]),f=c+t[0].peak.topPeak*u,p=l-c-t[a-1].peak.botPeak*u;if(h.reduce((t,e)=>t+e,0)+1e-6>=p-f)return fi(t,n,s);let y=1===a?[(f+p)/2]:[...r];for(let t=0;12>t;t++){const t=Array(a).fill(0),n=Array(a).fill(0);for(const r of o){const o=e[r.source],s=e[r.target];if(null==o||null==s||o===s)continue;const a=i[r.source]?.localAttachments.get(r.id),c=i[r.target]?.localAttachments.get(r.id);if(!a||!c)continue;const l=r.value>0&&Number.isFinite(r.value)?r.value:1,d=pi(a,u),h=pi(c,u);t[o]+=(y[s]+h-d)*l,n[o]+=l,t[s]+=(y[o]+d-h)*l,n[s]+=l}const r=ii({desired:y.map((e,o)=>0===n[o]?e:.45*e+t[o]/n[o]*.55),minGaps:h,weights:n.map(t=>Math.max(1,t)),min:f,max:p});let s=0;for(let t=0;a>t;t++)s=Math.max(s,Math.abs(r[t]-y[t]));if(y=r,.01>s)break}return y}(i,n,e,o,s,a,r):[...a];if("hug"===r.lanePlacement){const o=e=>{const o=ci();for(const i of t)o[i.id]=e[n[i.id]];return o};gi(o(c),e)>gi(o(a),e)+1e-6&&(c=[...a])}const l=ci();for(const e of t)l[e.id]=c[n[e.id]];let u=1/0,d=-1/0;for(const e of t){const t=l[e.id],i=o[e.id];Number.isFinite(t)&&i&&(u=Math.min(u,t-i.topPeak*r.valueScale),d=Math.max(d,t+i.botPeak*r.valueScale))}return{adjacentClearance:s,centerlines:l,slotCenter:c,stackCenter:a,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&r.plotH>0?Math.max(0,Math.min(1,(d-u)/r.plotH)):0}}function gi(t,e){let o=0;for(const i of e){const e=t[i.source],n=t[i.target];Number.isFinite(e)&&Number.isFinite(n)&&(o+=Math.abs(e-n)*(i.value>0?i.value:1))}return o}function mi(t,e){const o=t?.samples;if(!o||0===o.length||o[0].t>e)return{top:0,bot:0};let i=0,n=o.length-1,r=0;for(;n>=i;){const t=i+n>>>1;o[t].t>e?n=t-1:(r=t,i=t+1)}const s=o[r].boundaryOffset??0;return{top:o[r].topMass-s,bot:o[r].botMass+s}}function xi(t,e,o,i,n){const r=1-n;return r*r*r*t+3*r*r*n*e+3*r*n*n*o+n*n*n*i}function bi(t,e){let o=0,i=1;for(let n=0;28>n;n++){const n=(o+i)/2;t>xi(0,e,e,1,n)?o=n:i=n}return(o+i)/2}function vi(t,e,o){const i=e+pi(t,o),n=t.value*o/2;return[i-n,i+n]}function wi(t,e,o,i){return Math.max(0,Math.min(e,i)-Math.max(t,o))/Math.max(1e-9,e-t)}function ki(t,e,o,i,n,r,s){const{valueScale:a,domain:c,mode:l="quality"}=s,u="source"===s.ribbonLane?.85:"target"===s.ribbonLane?.15:.5;let d=0;for(const s of t){const t=i[s.source],h=i[s.target];if(null==t||null==h||2>Math.abs(t-h))continue;const f=e[s.source]?.localAttachments.get(s.id),p=e[s.target]?.localAttachments.get(s.id);if(!f||!p)continue;const y=Math.max(s.startTime,c?.[0]??-1/0),g=Math.min(s.endTime,c?.[1]??1/0);if(y>=g)continue;const[m,x]=vi(f,n[s.source],a),[b,v]=vi(p,n[s.target],a),w=Math.min(t,h)+1,k=Math.max(t,h)-1;for(let t=w;k>=t;t++){const i=o[t];if(!i)continue;const c=[y,g];if("quality"===l)for(const t of i.occupants)for(const o of e[t.id]?.samples??[])o.t>y&&g>o.t&&c.push(o.t);const h=t=>{const o=bi((t-y)/(g-y),u),c=xi(m,m,b,b,o),l=xi(x,x,v,v,o);let d=0;for(const o of i.occupants){if(o.id===s.source||o.id===s.target)continue;const i=r[o.id];if(null!=i?.start&&i.start>t)continue;if(null!=i?.end&&t>i.end)continue;const u=mi(e[o.id],t),h=n[o.id];d=Math.max(d,wi(c,l,h-u.top*a,h+u.bot*a))}return d},f=[...new Set(c)].sort((t,e)=>t-e);let p=0;for(let t=0;f.length-1>t;t++){const e=f[t],o=f[t+1]-e;p+=(h(e+.25*o)+h(e+.5*o)+h(e+.75*o))/3*o}d+=p/(g-y)*(s.value>0?s.value:1)}}return d}function Si(t,e,o,i,n,r,s,a,c,l,u="both",d){return{crossings:t,weightedLength:e,pixelLength:gi(s,o),transitOcclusion:ki(o,i,n,r,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function Ai(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Mi(t,e){return t.map(t=>({t:Ai(t.t,e),topMass:t.topMass,botMass:t.botMass,...null!=t.boundaryOffset&&{boundaryOffset:t.boundaryOffset}}))}function _i(t,e,o){const i=e+(t.boundaryOffset??0)*o,n=t.value*o;if("out"===t.kind){const e=t.sideMassBefore*o;if("top"===t.side){const t=i-e;return[t,t+n]}const r=i+e;return[r-n,r]}const r=t.sideMassAfter*o;if("top"===t.side){const t=i-r;return[t,t+n]}const s=i+r;return[s-n,s]}function Pi(t,e,o,i,n="temporal"){const r=e.incoming[t.id],s=e.outgoing[t.id],a=[];for(const t of r)a.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:o.get(t.id).targetSide});for(const t of s)a.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:o.get(t.id).sourceSide});const c={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{a.sort((t,e)=>t.time-e.time||(t.phase??0)-(e.phase??0)||(t.sequence??0)-(e.sequence??0)||(c[t.kind]??99)-(c[e.kind]??99)||((t,e)=>{if(!i||!t.edge||!e.edge||t.kind!==e.kind||t.side!==e.side)return 0;if("out"===t.kind){if(t.edge.target===e.edge.target&&t.edge.endTime===e.edge.endTime)return 0;const o=i.get(t.edge.id)?.target,n=i.get(e.edge.id)?.target;return"number"==typeof o&&Number.isFinite(o)&&"number"==typeof n&&Number.isFinite(n)&&o!==n?"top"===t.side?o-n:n-o:0}if("in"===t.kind){if(t.edge.source===e.edge.source&&t.edge.startTime===e.edge.startTime)return 0;const o=i.get(t.edge.id)?.source,n=i.get(e.edge.id)?.source;return"number"==typeof o&&Number.isFinite(o)&&"number"==typeof n&&Number.isFinite(n)&&o!==n?"top"===t.side?n-o:o-n:0}return 0})(t,e)||li(t.edge?.id??"",e.edge?.id??"")||li(t.side,e.side)||t.delta-e.delta)},u=a.length?function(t,e=1/0){let o=e;for(const e of t)o>e&&(o=e);return o}(a.map(t=>t.time)):null,d=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;l();let f=null,p=0;for(const t of a)t.time!==f&&(f=t.time,p=0),t.sequence=p++;const y=t=>({time:t.time,phase:0,sequence:t.sequence??0}),g=[];let m=0,x=0;for(const t of a)if("out"===t.kind){const e=Math.abs(t.delta);let o=e-("top"===t.side?m:x);if(o>0){const e="top"===t.side?"bot":"top",i=Math.min(o,"top"===e?m:x);if(i>0){const n=y(t);g.push({...n,delta:-i,kind:"transfer-out",side:e}),g.push({...n,delta:+i,kind:"transfer-in",side:t.side}),"top"===e?m-=i:x-=i,"top"===t.side?m+=i:x+=i,o-=i}o>0&&null!==h&&(g.push({time:h,delta:+o,kind:"create",side:t.side}),"top"===t.side?m+=o:x+=o)}"top"===t.side?m-=e:x-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?m+=e:x+=e}a.push(...g),l();let b=0,v=0,w=0,k=0,S=0,A=0;const M=[],_=new Map,P=t=>{M.push({t:t,topMass:b,botMass:v,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},j=()=>{k=Math.max(k,b+v),S=Math.max(S,b-w),A=Math.max(A,v+w)};for(const t of a){if("transfer-out"!==t.kind&&"transfer-in"!==t.kind&&P(t.time),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?b:v;_.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===t.side?b+=t.delta:v+=t.delta,"transfer-in"===t.kind?(w+="top"===t.side?t.delta:-t.delta,j(),P(t.time)):"transfer-out"!==t.kind&&(j(),"out"!==t.kind||b+v>1e-12||(w=0),P(t.time))}const L=[];let $=0;for(;M.length>$;){let t=$;for(;M.length>t+1&&M[t+1].t===M[$].t;)t++;L.push(M[$]);for(let e=$+1;t>=e;e++){const t=L[L.length-1];M[e].topMass===t.topMass&&M[e].botMass===t.botMass&&(M[e].boundaryOffset??0)===(t.boundaryOffset??0)||L.push(M[e])}$=t+1}const R=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let C=null;for(const t of s)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===C||C>t.systemInTime)&&(C=t.systemInTime);let I=null;for(const t of r)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===I||t.systemOutTime>I)&&(I=t.systemOutTime);if(L.length>0){const t=L[L.length-1],e=Math.max(null!=R?R:-1/0,null!=I?I:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&L.push({t:e,topMass:t.topMass,botMass:t.botMass,...null!=t.boundaryOffset&&{boundaryOffset:t.boundaryOffset}});const o=L[0],i=L.find(t=>t.topMass+t.botMass>0);let n,r=1/0;null!=d&&Number.isFinite(d)&&o.t>d&&o.topMass+o.botMass>0&&(r=d,n=o),i&&null!=C&&Number.isFinite(C)&&i.t>C&&r>C&&(r=C,n=i),n&&Number.isFinite(r)&&L.unshift({t:r,topMass:n.topMass,botMass:n.botMass,...null!=n.boundaryOffset&&{boundaryOffset:n.boundaryOffset}})}let T=L;if("max"===n&&null!=d&&null!=R&&R>d){let t,e=0;for(const o of L){const i=o.topMass+o.botMass;i>e&&(e=i,t=o)}if(t){const e={topMass:t.topMass,botMass:t.botMass,...null!=t.boundaryOffset&&{boundaryOffset:t.boundaryOffset}};T=[...L.filter(t=>d>t.t),{t:d,...e},{t:R,...e},...L.filter(t=>t.t>R)]}}return{samples:T,peak:k,topPeak:S,botPeak:A,localAttachments:_}}function ji(t){const e=ci();return t.forEach((t,o)=>{for(const i of t.occupants)e[i.id]=o}),e}function Li(t,e,o){t.splice(0,t.length,...o);const i=ji(o);for(const t of Object.keys(e))delete e[t];Object.assign(e,i)}function $i(t){const e=new Map,o=[];t.forEach((t,i)=>{if(!t.group)return void o.push({anchor:i,stableId:ui(t),slots:[t]});const n=e.get(t.group)??{indexes:[],slots:[]};n.indexes.push(i),n.slots.push(t),e.set(t.group,n)});for(const[t,i]of e)o.push({anchor:i.indexes.reduce((t,e)=>t+e,0)/i.indexes.length,stableId:`${t}\0${i.slots.map(ui).join("\0")}`,slots:i.slots});return o.sort((t,e)=>t.anchor-e.anchor||li(t.stableId,e.stableId))}function Ri(t){return t.some(t=>t.group)?$i(t).flatMap(t=>t.slots):[...t]}function Ci(t){return t.flatMap(t=>t.slots)}function Ii(t,e,o){const i=new Map;return t.forEach((t,e)=>{for(const o of t.slots)i.set(o,e)}),t.map((t,n)=>{if(1>=t.slots.length)return t;const r=new Map;for(const e of t.slots)r.set(e,0);for(const t of e){const e=i.get(t.source),o=i.get(t.target);if(null==e||null==o)continue;const s=Number.isFinite(t.weight)&&t.weight>0?t.weight:1;if(e===n&&o!==n){const e=o>n?1:-1;r.set(t.source,(r.get(t.source)??0)+s*e)}else if(o===n&&e!==n){const o=e>n?1:-1;r.set(t.target,(r.get(t.target)??0)+s*o)}}const s=[...t.slots].sort((t,e)=>(r.get(t)??0)-(r.get(e)??0)||o(t,e));return{...t,slots:s}})}function Ti(t,e){t.some(t=>t.group)&&Li(t,e,Ri(t))}function Oi(t,e){return t.source!==e.source&&t.target!==e.target&&t.source!==e.target&&t.target!==e.source&&Math.min(t.endTime,e.endTime)>Math.max(t.startTime,e.startTime)}function zi(t,e){return function(t,e,o=()=>!0){let i=0;for(let n=0;t.length>n;n++){const[r,s]=e(t[n]);for(let a=n+1;t.length>a;a++){if(!o(t[n],t[a]))continue;const[c,l]=e(t[a]);0>(r-c)*(s-l)&&i++}}return i}(e,e=>[t[e.source],t[e.target]],Oi)}function Fi(t,e){let o=0;for(const i of e){const e=t[i.source],n=t[i.target];null!=e&&null!=n&&(o+=Math.abs(e-n)*(i.value>0?i.value:1))}return o}function Ni(t,e,o){const[i,n]=o.get(t.first),[r,s]=o.get(t.second);return 0>(e.get(i)-e.get(r))*(e.get(n)-e.get(s))?1:0}var Ei=t=>{let e=1;for(let o=2;t>=o;o++)e*=o;return e},Di=828*Ei(8),Bi=3e3;function Wi(t,e,o,i,n,r,s){const a=[...n],c=new Map(n.map(t=>[t,ui(t)])),l=new Map;for(const t of n)for(const e of t.occupants)l.set(e.id,t);const u=new Map,d=[];for(const t of e){const e=l.get(t.source),o=l.get(t.target);e&&o&&(u.set(t,[e,o]),e!==o&&d.push({source:e,target:o,weight:t.value}))}const h=[];for(let t=0;e.length>t;t++)if(u.has(e[t]))for(let o=t+1;e.length>o;o++){if(!u.has(e[o])||!Oi(e[t],e[o]))continue;const i=new Set([...u.get(e[t]),...u.get(e[o])]);h.push({index:h.length,first:e[t],second:e[o],involvedSlots:i})}const f=new Map;for(const t of n)f.set(t,[]);for(const t of h)for(const e of t.involvedSlots)f.get(e)?.push(t);const p=new Uint32Array(h.length);let y=0;const g=e.reduce((t,e)=>t+(e.value>0?e.value:1),0),m=s.plotH/Math.max(1,n.length),x=n.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),b=Math.max(1,g)*(Math.max(1,s.plotH)+m*Math.max(x,n.length)+1e-6*Math.max(1,n.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=new Map,S=(t,e)=>{let i=k.get(t);i||(i=new Map,k.set(t,i));const n=i.get(e);if(null!=n)return n;const r=function(t,e,o){return ri(hi([t,e],o)).adjacentClearance[0]??0}(t,e,o);return i.set(e,r),r},A=new Map(n.map((t,e)=>[t,e])),M=e.flatMap(t=>{const e=u.get(t);return e?[{source:A.get(e[0]),target:A.get(e[1]),weight:t.value>0?t.value:1}]:[]}),_=new Map;for(const t of e){const e=u.get(t);e&&_.set(t,{source:A.get(e[0]),target:A.get(e[1])})}const P=new Map,j=new Map,L=new Map,$=(t,e,o)=>{t.has(e)||t.set(e,new Set),t.get(e).add(o)};for(const t of e)$(P,t.source,t.target),$(j,t.target,t.source),$(L,t.source,t.target),$(L,t.target,t.source);const R=e.flatMap(t=>{if(!(t=>1===P.get(t.source)?.size&&P.get(t.source).has(t.target)||1===L.get(t.source)?.size||1===L.get(t.target)?.size)(t))return[];const e=_.get(t);return e&&e.source!==e.target?[{source:e.source,target:e.target,weight:t.value>0?t.value:1}]:[]}),C=t=>{let e=0;for(const o of R)e+=Math.max(0,Math.abs(t[o.source]-t[o.target])-1)*o.weight;return e*v},I=t=>{const e=new Int16Array(n.length);for(let o=0;t.length>o;o++)e[A.get(t[o])]=o;return C(e)},T=h.map(t=>{const e=_.get(t.first),o=_.get(t.second);return[e.source,e.target,o.source,o.target]}),O=new Int16Array(n.length),z=new Float64Array(n.length),F=new Float64Array(n.length+1),N=t=>{for(let e=0;t.length>e;e++)O[A.get(t[e])]=e;let e=0;for(const[t,o,i,n]of T)0>(O[t]-O[i])*(O[o]-O[n])&&e++;if(t.length>0){const e=A.get(t[0]);z[e]=s.padding+t[0].peak.topPeak*s.valueScale;for(let e=1;t.length>e;e++){const o=A.get(t[e-1]),i=A.get(t[e]);z[i]=z[o]+S(t[e-1],t[e])*s.valueScale+s.padding}const o=A.get(t[t.length-1]),i=z[o]+t[t.length-1].peak.botPeak*s.valueScale+s.padding;if(i>s.plotH&&i>0){const t=s.plotH/i;for(let e=0;z.length>e;e++)z[e]*=t}}F[0]=0;for(let e=0;t.length>e;e++)F[e+1]=F[e]+t[e].peak.topPeak+t[e].peak.botPeak;let o=0,i=0,n=0;for(const t of M){const e=O[t.source],r=O[t.target];if(o+=Math.abs(e-r)*t.weight,i+=Math.abs(z[t.source]-z[t.target])*t.weight,Math.abs(e-r)>=2){const o=Math.min(e,r)+1;n+=(F[Math.max(e,r)]-F[o])*t.weight}}return e*b+i+n*m+C(O)+1e-6*o},E=(t,o)=>{const i=Array(t.length+1).fill(0);for(let e=0;t.length>e;e++)i[e+1]=i[e]+t[e].peak.topPeak+t[e].peak.botPeak;let n=0;for(const t of e){const e=o[t.source],r=o[t.target];if(null==e||null==r||2>Math.abs(e-r))continue;const s=Math.min(e,r)+1;n+=(i[Math.max(e,r)]-i[s])*(t.value>0?t.value:1)}return n},D=i=>{const n=ji(i),r=i.slice(0,-1).map((t,e)=>S(t,i[e+1])),a=yi(t,e,o,i,n,{plotH:s.plotH,padding:s.padding,valueScale:s.valueScale,lanePlacement:s.lanePlacement??"stack",groupPadding:s.groupPadding,adjacentClearance:r});return{map:n,geometry:a,weightedLength:Fi(n,e),pixelLength:gi(a.centerlines,e),transitOcclusion:E(i,n)}},B=(t,e,o)=>({crossings:t,weightedLength:e.weightedLength,pixelLength:e.pixelLength,transitOcclusion:e.transitOcclusion,cost:t*b+e.pixelLength+e.transitOcclusion*m+I(o)+1e-6*e.weightedLength}),W=(t,e)=>{let o=e;if(null==o){const e=new Map(t.map((t,e)=>[t,e]));o=h.reduce((t,o)=>t+Ni(o,e,u),0),w.fullCrossing++}return B(o,D(t),t)},Y=(t,n,r="quality")=>{let a=n;if(null==a){const e=new Map(t.map((t,e)=>[t,e]));a=h.reduce((t,o)=>t+Ni(o,e,u),0),w.fullCrossing++}const c=D(t);return B(a,{...c,transitOcclusion:ki(e,o,t,c.map,c.geometry.centerlines,i,{valueScale:s.valueScale,ribbonLane:s.ribbonLane,domain:s.domain,mode:r})},t)};let q=[...a];const X=(t,e)=>li(c.get(t),c.get(e)),G=function(t){const e=new Set;for(const o of t)if(o.group){if(e.has(o.group))return!0;e.add(o.group)}return!1}(q),V=t=>{const e=(t=>{const e=si(t,d,t=>W(t).cost,{passes:6,compare:X,maxEvaluations:Bi});let o=W(e),i=Bi;for(let t=0;6>t&&i>0;t++){let n=!1;const r=Array.from({length:e.length-1},(t,e)=>e);t%2==1&&r.reverse();for(const t of r){if(0>=i--)break;const r=e[t],s=e[t+1],a=new Map(e.map((t,e)=>[t,e]));let c=0;const l=[];y++;for(const t of[...f.get(r)??[],...f.get(s)??[]])p[t.index]!==y&&(p[t.index]=y,l.push(t),c+=Ni(t,a,u));[e[t],e[t+1]]=[s,r];const d=new Map(a);d.set(r,t+1),d.set(s,t);let h=0;for(const t of l)h+=Ni(t,d,u);w.localCrossing+=l.length;const g=W(e,o.crossings-c+h);o.cost>g.cost?(o=g,n=!0):[e[t],e[t+1]]=[r,s]}if(!n)break}return e})(t);if((t.length>8?1/0:Ei(t.length)*(t.length+M.length+T.length))>Di)return e;const o=ai(t,N,{maxItems:8,maxEvaluations:5e4}),i=Y(o),n=Y(e);return i.crossings!==n.crossings&&n.crossings>i.crossings?o:e},H="geometry-refine"===s.mode;if(H||"crossing-min"!==s.laneOrder&&"crossing-min+inside-out"!==s.laneOrder){if(!H&&"inside-out"===s.laneOrder)if(G){const t=$i(q),e=t=>t.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),o=[...t].sort((t,o)=>e(o)-e(t)||li(t.stableId,o.stableId)),i=Array(o.length);let n=Math.floor((o.length-1)/2)-1,r=Math.floor((o.length-1)/2)+1;o.length>0&&(i[Math.floor((o.length-1)/2)]=o[0]);for(let t=1;o.length>t;t++)t%2==1&&o.length>r||0>n?i[r++]=o[t]:i[n--]=o[t];q=Ci(i)}else{const t=[...q].sort((t,e)=>e.peak.topPeak+e.peak.botPeak-(t.peak.topPeak+t.peak.botPeak)||X(t,e)),e=Array(t.length);let o=Math.floor((t.length-1)/2)-1,i=Math.floor((t.length-1)/2)+1;t.length>0&&(e[Math.floor((t.length-1)/2)]=t[0]);for(let n=1;t.length>n;n++)n%2==1&&t.length>i||0>o?e[i++]=t[n]:e[o--]=t[n];q=e}}else q=G?(t=>{let e=$i(t);if(1>=e.length)return Ci(e);const o=t=>W(Ci(t)).cost;e=$i(V(t)),e=Ii(e,d,X);const i=function(t,e){const o=new Map;for(const e of t)for(const t of e.slots)o.set(t,e);const i=new Map;for(const t of e){const e=o.get(t.source),n=o.get(t.target);if(!e||!n||e===n)continue;const r=Number.isFinite(t.weight)&&t.weight>0?t.weight:1,s=n.stableId>e.stableId?`${e.stableId}\0${n.stableId}`:`${n.stableId}\0${e.stableId}`,a=i.get(s);a?a.weight=(a.weight??0)+r:i.set(s,{source:e,target:n,weight:r})}return[...i.values()]}(e,d);e=si(e,i,o,{passes:6,compare:(t,e)=>li(t.stableId,e.stableId),maxEvaluations:Bi}),e=function(t,e,o={}){const i=[...t];if(1>=i.length)return i;let n=e(i),r=1;const s=Math.max(0,o.passes??6),a=Math.max(1,o.maxEvaluations??1/0);for(let t=0;s>t&&a>r;t++){let t=!1;for(let o=0;i.length-1>o&&a>r;o++){[i[o],i[o+1]]=[i[o+1],i[o]];const s=e(i);r++,n>s?(n=s,t=!0):[i[o],i[o+1]]=[i[o+1],i[o]]}if(!t)break}return i}(e,o,{passes:8,maxEvaluations:Bi});const n=e.length>8?1/0:Ei(e.length)*(e.length+M.length+T.length);if(Di>=n){const t=ai(e,t=>N(Ci(t)),{maxItems:8,maxEvaluations:5e4}),o=Ci(t),i=Ci(e),n=Y(o),r=Y(i);n.crossings!==r.crossings?e=r.crossings>n.crossings?t:e:r.cost>n.cost&&(e=t)}return e=Ii(e,d,X),Ci(e)})(q):V(q);if(!H&&"crossing-min+inside-out"===s.laneOrder&&q.length>1)if(G){const t=$i(q);let e=W(Ci(t)),o=Ci(t),i=e;const n=Math.floor((t.length-1)/2),r=t=>t.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),s=[...t].sort((t,e)=>r(e)-r(t)||li(t.stableId,e.stableId));for(const r of s){const s=t.indexOf(r);if(s===n)continue;t.splice(s,1),t.splice(n,0,r);const a=Ci(t),c=W(a);c.cost>e.cost?(t.splice(n,1),t.splice(s,0,r)):(e=c,i.cost>c.cost&&(o=a,i=c))}q=o}else{let t=W(q),e=[...q],o=t;const i=Math.floor((q.length-1)/2),n=[...q].sort((t,e)=>e.peak.topPeak+e.peak.botPeak-(t.peak.topPeak+t.peak.botPeak)||X(t,e));for(const r of n){const n=q.indexOf(r);if(n===i)continue;q.splice(n,1),q.splice(i,0,r);const s=W(q);s.cost>t.cost?(q.splice(i,1),q.splice(n,0,r)):(t=s,o.cost>s.cost&&(e=[...q],o=s))}q=e}if((H||"crossing-min"===s.laneOrder||"crossing-min+inside-out"===s.laneOrder)&&q.length>1)if(G){let t=$i(q),e=Y(Ci(t),void 0,"score");for(let o=0;6>o&&t.length>1;o++){let o=!1;for(let i=0;t.length-1>i;i++){[t[i],t[i+1]]=[t[i+1],t[i]];const n=Ci(t),r=Y(n,void 0,"score");e.cost>r.cost?(q=n,e=r,o=!0):[t[i],t[i+1]]=[t[i+1],t[i]]}if(!o)break}t=Ii($i(q),d,X),q=Ci(t)}else{let t=Y(q,void 0,"score");for(let e=0;q.length-1>e;e++){const o=q[e],i=q[e+1],n=new Map(q.map((t,e)=>[t,e]));let r=0;const s=[];y++;for(const t of[...f.get(o)??[],...f.get(i)??[]])p[t.index]!==y&&(p[t.index]=y,s.push(t),r+=Ni(t,n,u));[q[e],q[e+1]]=[i,o];const a=new Map(n);a.set(o,e+1),a.set(i,e);let c=0;for(const t of s)c+=Ni(t,a,u);w.localCrossing+=s.length;const l=Y(q,t.crossings-r+c,"score");t.cost>l.cost?t=l:[q[e],q[e+1]]=[o,i]}}const U=Ri(a);q=Ri(q);let K=Y(q);const Z=Y(U);if(H){const t=I(U),e=I(q);(K.crossings>Z.crossings||K.crossings===Z.crossings&&e>t+1e-9||K.cost>Z.cost)&&(q=U,K=Z)}else K.cost>Z.cost&&(q=U,K=Z);const Q=function({order:t,after:e,nodes:o,edges:i,outgoingPartners:n,incomingPartners:r,slotForNode:s,averageGap:a,evaluate:c}){const l=(o,n)=>{const r=[...new Set(n.map(e=>t.indexOf(e)))].sort((t,e)=>t-e),s=t.indexOf(o),l=r[0],u=r[r.length-1];if(3>r.length||!r.includes(s)||u-l+1!==r.length||1>=Math.abs(2*s-l-u))return;const d=[...t];d.splice(s,1),d.splice(l+u>>1,0,o);const h=Ri(d),f=c(h),p=new Set(o.occupants.map(t=>t.id)),y=new Set(n.flatMap(t=>t.occupants.map(t=>t.id))),g=i.reduce((t,e)=>p.has(e.source)&&y.has(e.target)||p.has(e.target)&&y.has(e.source)?t+(e.value>0?e.value:1):t,0);(function(t,e,o=0){return e.crossings>t.crossings||t.crossings===e.crossings&&e.cost+o>=t.cost})(f,e,Math.abs(2*s-l-u)*a*Math.max(1,g))&&(t=h,e=f)};for(const[t,e]of n)r.has(t)||3>e.size||l(s.get(t),[...e].map(t=>s.get(t)));for(const t of o){const e=s.get(t.id);t.group||!e.group||3>(r.get(t.id)?.size??0)||l(e,[...r.get(t.id)??[]].map(t=>s.get(t)).filter(t=>t===e||t.group===e.group).filter((t,e,o)=>o.indexOf(t)===e))}return{order:t,after:e}}({order:q,after:K,nodes:t,edges:e,outgoingPartners:P,incomingPartners:j,slotForNode:l,averageGap:m,evaluate:Y});return q=Q.order,K=Q.after,Li(n,r,q),{before:Z,after:K,initialOrder:a.map(t=>c.get(t)),evaluations:w}}function Yi(t,e,o){const i=t.map(t=>{const i=t.occupants.map(t=>({id:t.id,end:o[t.id]?.end??t.end}));let n=0,r=0;for(const t of i){const o=e[t.id];n=Math.max(n,o?.topPeak||0),r=Math.max(r,o?.botPeak||0)}return{occupants:i,peak:{topPeak:n,botPeak:r},...null!=t.group?{group:t.group}:{}}}),n=ci();return i.forEach((t,e)=>{for(const o of t.occupants)n[o.id]=e}),{slots:i,slotByNode:n}}var qi=new Map,Xi=1e5,Gi=1e-9;function Vi(t,e){return null!=t.start&&null!=t.end&&null!=e.start&&null!=e.end&&!(e.start>=t.end||t.start>=e.end)}function Hi(t,e){return li(t,e)>0?`${e}\0${t}`:`${t}\0${e}`}function Ui(t){const e=new Map,o=new Map;for(const i of t)o.has(i.source)||o.set(i.source,new Set),e.has(i.target)||e.set(i.target,new Set),o.get(i.source).add(i.target),e.get(i.target).add(i.source);return{incoming:new Map([...e].map(([t,e])=>[t,e.size])),outgoing:new Map([...o].map(([t,e])=>[t,e.size]))}}function Ki(t){const e=new Map,o=new Map,i=(t,e,o,i)=>{let n=t.get(e);n||(n=new Map,t.set(e,n)),n.set(o,(n.get(o)??0)+i)};for(const n of t){const t=n.value>0&&Number.isFinite(n.value)?n.value:1;i(e,n.source,n.target,t),i(o,n.target,n.source,t)}const n=new Map,r=t=>{if(n.has(t))return;const i=e.get(t),r=o.get(t),s=new Map;for(const[t,e]of i??[])s.set(t,(s.get(t)??0)+e);for(const[t,e]of r??[])s.set(t,(s.get(t)??0)+e);if(1===s.size){const[e,o]=[...s][0];n.set(t,{partner:e,weight:o})}};for(const e of t)r(e.source),r(e.target);return n}function Zi(t,e,o){const i=o.get(t),n=o.get(e);return!i||!n||i.partner===n.partner||i.partner===e||n.partner===t}function Qi(t,e,o){return!!o.has(t)&&e.some(e=>!Zi(t,e,o))}function Ji(t,e){return(t.value>0&&Number.isFinite(t.value)?t.value:1)*(1+(1===e.outgoing.get(t.source)?1:0)+(1===e.incoming.get(t.target)?1:0))}function tn(t,e,o,i){if(12>=t.length||1>=i.slotCount)return i.assignment;const n=new Map(t.map((t,e)=>[t,e])),r=Array.from({length:t.length},()=>new Map),s=Ui(o);for(const t of o){const e=n.get(t.source),o=n.get(t.target);if(null==e||null==o||e===o)continue;const i=Ji(t,s);r[e].set(o,(r[e].get(o)??0)+i),r[o].set(e,(r[o].get(e)??0)+i)}const a=Ki(o),c=t.map(t=>a.get(t)?.weight??0),l=Array.from({length:t.length},()=>new Map);let u=0;for(let o=0;t.length-1>o&&5e4>u;o++)if(a.has(t[o]))for(let i=o+1;t.length>i;i++){if(!a.has(t[i]))continue;if(e.conflicts(t[o],t[i]))continue;u++;const n=Math.min(c[o],c[i])||Math.max(c[o],c[i]),r=Zi(t[o],t[i],a)?n:-n;if(Math.abs(r)>Gi&&(l[o].set(i,r),l[i].set(o,r),u>=5e4))break}const d=[...i.assignment],h=Array.from({length:i.slotCount},()=>[]);d.forEach((t,e)=>h[t].push(e));const f=(t,e,o)=>{const i=d[e],n=d[o];let r=0;const s=new Set;for(const a of[e,o])for(const[c,l]of t[a]){const t=c>a?`${a}:${c}`:`${c}:${a}`;if(s.has(t))continue;s.add(t);const u=(a===e?n:i)===(c===e?n:c===o?i:d[c]);d[a]===d[c]!==u&&(r+=u?l:-l)}return r},p=(t,e,o)=>{let i=0;for(const[n,r]of t[e]){const t=o===d[n];d[e]===d[n]!==t&&(i+=t?r:-r)}return i},y=(t,e)=>t>Gi||Gi>=Math.abs(t)&&e>Gi,g=(t,e,o,i)=>t>o+Gi||Gi>=Math.abs(t-o)&&e>i+Gi;let m=0;for(let o=0;32>o&&Xi>m;o++){let o=null,i=-1,n=-1,s=-1,a=-1/0,c=-1/0;for(let u=0;t.length>u;u++){for(let f=0;h.length>f&&m++<Xi;f++){if(f===d[u])continue;if(!h[f].every(o=>!e.conflicts(t[u],t[o])))continue;const m=p(r,u,f),x=p(l,u,f);y(m,x)&&g(m,x,a,c)&&(o="move",i=u,n=-1,s=f,a=m,c=x)}if(m>=Xi)break}for(let u=0;t.length-1>u;u++){for(let p=u+1;t.length>p&&m++<Xi;p++){const m=d[u],x=d[p];if(m===x)continue;if(!h[x].every(o=>o===p||!e.conflicts(t[u],t[o])))continue;if(!h[m].every(o=>o===u||!e.conflicts(t[p],t[o])))continue;const b=f(r,u,p),v=f(l,u,p);y(b,v)&&g(b,v,a,c)&&(o="swap",i=u,n=p,s=-1,a=b,c=v)}if(m>=Xi)break}if(null==o||-1===i)break;if("move"===o){const t=d[i];h[t].splice(h[t].indexOf(i),1),h[s].push(i),d[i]=s;continue}const u=d[i],x=d[n];h[u].splice(h[u].indexOf(i),1,n),h[x].splice(h[x].indexOf(n),1,i),d[i]=x,d[n]=u}return d}function en(t,e){let o=1/0,i=-1/0;for(const e of t?.samples??[])e.topMass+e.botMass>1e-9&&(o=Math.min(o,e.t),i=Math.max(i,e.t));return Number.isFinite(o)&&Number.isFinite(i)?(null!=e.start&&(o=Math.max(o,e.start)),null!=e.end&&(i=Math.min(i,e.end)),o>i?{start:null,end:null}:{start:o,end:i}):{start:null,end:null}}function on(t,e,o,i){const n=function(t,e,o,i){return`${t.map(t=>{const e=o[t.id],n=i[t.id];return[t.id,t.group??"",t.xExtent?.[0]??"",t.xExtent?.[1]??"",e?.topPeak??0,e?.botPeak??0,n?.start??"",n?.end??""].join(":")}).join("|")}#${e.map(t=>[t.id,t.source,t.target,t.value,t.startTime,t.endTime].join(":")).join("|")}`}(t,e,o,i),r=qi.get(n);if(r)return Yi(r.slots,o,i);const s=ci();for(const e of t)s[e.id]=en(o[e.id],i[e.id]);const a=function(t,e){return t.filter(t=>null!=e[t.id].start).sort((t,o)=>e[t.id].start-e[o.id].start||e[t.id].end-e[o.id].end||li(t.id,o.id)).map(t=>t.id)}(t,s),c=new Map(t.map(t=>[t.id,t])),l=new Map(t.map(t=>[t.id,t.group||void 0])),u=Ki(e),d=function(t,e,o,i,n,r){const s=new Set,a=new Map(t.map(t=>[t,new Set])),c=new Map(t.map(t=>[t,new Set]));for(const t of i)s.add(Hi(t.source,t.target)),a.get(t.target)?.add(t.source),c.get(t.source)?.add(t.target);const l=new Map,u=new Set,d=(t,e)=>{for(let o=0;t.length>o;o++)for(let i=o+1;t.length>i;i++){const n=Hi(t[o],t[i]);e instanceof Map?e.set(n,[t[o],t[i]]):e.add(n)}};for(const t of c.values())d([...t],l);for(const t of a.values())d([...t],u);const h=new Set;for(const[t,[i,n]]of l)u.has(t)&&(Vi(e[i],e[n])||Vi(o[i],o[n])&&(h.add(i),h.add(n)));return{conflicts:(t,o)=>{const i=n.get(t),a=n.get(o);return null!=i&&null!=a&&i!==a||!(null!=i==(null!=a)||s.has(Hi(t,o))||r.has(t)&&r.has(o)&&Zi(t,o,r))||!!Vi(e[t],e[o])||!(!h.has(t)&&!h.has(o))&&!s.has(Hi(t,o))}}}(a,s,i,e,l,u),h=function(t,e,o=new Map){const i=[],n=[];for(const r of t){let t=i.findIndex(t=>t.every(t=>!e.conflicts(r,t))&&!Qi(r,t,o));-1!==t||o.has(r)||(t=i.findIndex(t=>t.every(t=>!e.conflicts(r,t)))),-1===t&&(t=i.length,i.push([])),i[t].push(r),n.push(t)}return{assignment:n,slotCount:i.length}}(a,d,u),f=function(t,e,o,i){if(0===t.length||t.length>12||1>=i.slotCount)return i.assignment;const n=new Map(t.map((t,e)=>[t,e])),r=Array.from({length:t.length},()=>new Float64Array(t.length)),s=Array.from({length:t.length},()=>new Map),a=Array.from({length:t.length},()=>new Map),c=Ui(o);for(const t of o){const e=n.get(t.source),o=n.get(t.target);if(null==e||null==o||e===o)continue;const i=Ji(t,c);r[e][o]+=i,r[o][e]+=i,a[e].set(o,(a[e].get(o)??0)+i),s[o].set(e,(s[o].get(e)??0)+i)}const l=Ki(o),u=t.map(t=>l.get(t)?.weight??0),d=Array.from({length:t.length},()=>new Float64Array(t.length));for(let e=0;t.length>e;e++)for(let o=e+1;t.length>o;o++){for(const[t,i]of s[e])d[e][o]+=Math.min(i,s[o].get(t)??0);for(const[t,i]of a[e])d[e][o]+=Math.min(i,a[o].get(t)??0);if(l.has(t[e])&&l.has(t[o])){const i=Math.min(u[e],u[o])||Math.max(u[e],u[o]);d[e][o]+=Zi(t[e],t[o],l)?i:-i}d[o][e]=d[e][o]}let h=[...i.assignment],f=(e=>{let o=0,i=0;for(let n=0;t.length>n;n++)for(let s=n+1;t.length>s;s++)e[n]===e[s]&&(o+=r[n][s],i+=d[n][s]);return{flow:o,affinity:i}})(h),p=0;const y=Array(t.length).fill(-1),g=Array.from({length:i.slotCount},()=>[]),m=(o,n,s,a)=>{if(p>=75e3)return;if(o===t.length)return p++,void((s>f.flow||s===f.flow&&a>f.affinity||s===f.flow&&a===f.affinity&&function(t,e){for(let o=0;Math.min(t.length,e.length)>o;o++)if(t[o]!==e[o])return e[o]>t[o];return e.length>t.length}(y,h))&&(h=[...y],f={flow:s,affinity:a}));const c=Math.min(n+1,i.slotCount-1);for(let i=0;c>=i;i++){if(g[i].some(i=>e.conflicts(t[o],t[i])))continue;let c=0,l=0;for(const t of g[i])c+=r[o][t],l+=d[o][t];if(y[o]=i,g[i].push(o),m(o+1,Math.max(n,i),s+c,a+l),g[i].pop(),y[o]=-1,p>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}(a,d,e,{...h,assignment:tn(a,d,e,h)}),p=new Map,y=f.map(t=>(p.has(t)||p.set(t,p.size),p.get(t))),g=Array.from({length:p.size||(t.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=ci();a.forEach((t,e)=>{const o=y[e],i=g[o];i.occupants.push({id:t,end:s[t].end??-1/0});const n=c.get(t)?.group;n&&(i.group=n),m[t]=o});for(const e of[...t].sort((t,e)=>li(t.id,e.id)))null==m[e.id]&&(g[0].occupants.push({id:e.id,end:-1/0}),m[e.id]=0);for(const t of g){t.occupants.sort((t,e)=>(s[t.id].start??1/0)-(s[e.id].start??1/0)||li(t.id,e.id));for(const e of t.occupants){const i=o[e.id];t.peak.topPeak=Math.max(t.peak.topPeak,i?.topPeak||0),t.peak.botPeak=Math.max(t.peak.botPeak,i?.botPeak||0)}}const x={slots:g,slotByNode:m};return function(t,e){for(qi.has(t)&&qi.delete(t),qi.set(t,{slots:e.slots.map(t=>({occupants:t.occupants.map(t=>({...t})),peak:{...t.peak},...null!=t.group?{group:t.group}:{}})),slotByNode:Object.assign(ci(),e.slotByNode)});qi.size>12;){const t=qi.keys().next().value;if(null==t)break;qi.delete(t)}}(n,x),x}function nn(t){return t.topMass+t.botMass}function rn(t,e){const o=t.samples.filter(t=>t.t===e);if(o.length>0)return o.reduce((t,e)=>nn(e)<nn(t)?t:e,o[0]);let i=null;for(const o of t.samples){if(o.t>e)break;i=o}return i}function sn(t,e,o,i,n,r,s=0){const a=new Map;for(const o of t){if(!o.group||!e[o.id])continue;const t=a.get(o.group)??[];t.push(o),a.set(o.group,t)}if(0===a.size||0>=r)return e;const c=Object.fromEntries(Object.entries(e).map(([t,e])=>[t,{...e,samples:e.samples.map(t=>({...t})),localAttachments:new Map([...e.localAttachments].map(([t,e])=>[t,{...e}]))}]));for(const[t,l]of a){const a=o.map((t,e)=>({slot:t,index:e})).filter(({slot:e})=>e.group===t);if(0===a.length)continue;const u=a[0].slot,d=a.at(-1).slot,h=n[u.occupants[0]?.id],f=n[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;const p=(h-u.peak.topPeak*r+(f+d.peak.botPeak*r))/2,y=[...new Set(l.flatMap(t=>e[t.id].samples.map(t=>t.t)))].sort((t,e)=>t-e),g=new Map;for(const t of l)g.set(t.id,new Map);for(const t of y){const o=new Map;for(const n of l){const r=rn(e[n.id],t);if(!r||1e-9>=nn(r))continue;const s=i[n.id];if(null==s)continue;const a=o.get(s)??[];a.push({node:n,sample:r}),o.set(s,a)}const a=[...o].sort((t,e)=>t[0]-e[0]).map(([t,e])=>({slot:t,active:e,mass:Math.max(...e.map(({sample:t})=>nn(t)))}));if(0===a.length)continue;let c=p-(a.reduce((t,e)=>t+e.mass,0)*r+Math.max(0,s)*Math.max(0,a.length-1))/2;for(const e of a){for(const{node:o,sample:i}of e.active){const e=(c-n[o.id])/r+i.topMass-(i.boundaryOffset??0);g.get(o.id).set(t,e)}c+=e.mass*r+Math.max(0,s)}}for(const t of l){const o=e[t.id],i=c[t.id],n=g.get(t.id),r=[];for(const t of y){const e=n.get(t),i=o.samples.filter(e=>e.t===t);if(i.length>0){r.push(...i.map(t=>({...t,...null!=e?{boundaryOffset:(t.boundaryOffset??0)+e}:{}})));continue}const s=rn(o,t);null!=e&&s&&nn(s)>1e-9&&r.push({...s,t:t,boundaryOffset:(s.boundaryOffset??0)+e})}i.samples=r,i.localAttachments=new Map([...o.localAttachments].map(([t,e])=>{const o=n.get(e.time);return[t,{...e,...null!=o?{boundaryOffset:(e.boundaryOffset??0)+o}:{}}]}))}}return c}function an(t,e,o,i,n){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=n,y=ci(),g=ci();for(const e of t)y[e.id]=o[e.id].topPeak||0,g[e.id]=o[e.id].botPeak||0;const m="half"===u,x=ci();for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,o=Array.isArray(e.xExtent)?e.xExtent[1]:null;let n=null!=t&&Number.isFinite(t)?t:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const t of i.outgoing[e.id]){n>t.startTime&&(n=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&n>t.systemInTime&&(n=t.systemInTime);const e=m?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of i.incoming[e.id]){const e=m?(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)}x[e.id]={start:Number.isFinite(n)?n:null,end:Number.isFinite(r)?r:null}}let b=ci(),v=[],w=[];if(n.frozenSlots){const t=Yi(n.frozenSlots,o,x);v=t.slots,b=t.slotByNode,w=v.map(ui)}else if("reuse"===c){const i=on(t,e,o,x);v=i.slots,b=i.slotByNode}else t.forEach((t,e)=>{v.push({occupants:[{id:t.id,end:x[t.id]?.end??-1/0}],peak:{topPeak:y[t.id],botPeak:g[t.id]},...t.group?{group:t.group}:{}}),b[t.id]=e});Ti(v,b),0===w.length&&(w=v.map(ui));let k=null;n.frozenSlots||(n.fixedSlotOrder?function(t,e,o){const i=new Map(o.map((t,e)=>[t,e]));Li(t,e,[...t].sort((t,e)=>(i.get(ui(t))??1/0)-(i.get(ui(e))??1/0)||li(ui(t),ui(e))))}(v,b,n.fixedSlotOrder):n.runOrdering&&l&&"insertion"!==l&&(k=Wi(t,e,o,x,v,b,{plotH:r,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:f,domain:p}))),Ti(v,b);const S=yi(t,e,o,v,b,{plotH:r,padding:s,valueScale:a,stackValueScale:n.stackValueScale,lanePlacement:d,groupPadding:h}),A=0===v.length?0:v[0].peak.topPeak+S.adjacentClearance.reduce((t,e)=>t+e,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,P=k?.before.weightedLength??null,j=k?.after.weightedLength??null;return{effectiveSlotsHeight:A,centerlines:S.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:S.slotCenter,stackCenter:S.stackCenter,verticalUtilization:S.verticalUtilization,selectedSlotOrder:v.map(ui),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:P,lengthAfter:j}}function cn(t){const{sx:e,sTop:o,sBot:i,tx:n,tTop:r,tBot:s,cp1X:a,cp2X:c}=t,l=(o+i)/2,u=(r+s)/2;return{pathD:[`M${e},${o}`,`C${a},${o} ${c},${r} ${n},${r}`,`L${n},${s}`,`C${c},${s} ${a},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:n,y:u}],halfWidth:(i-o)/2}}}function ln(t,e,o,i,n,r,s,a,c={}){const l=n,u=t=>a?Math.max(a[0],Math.min(a[1],t)):t;let d=r(u(t.time));const h=r(u(o.time)),f=t.value*l,p=o.value*l,y=e+(t.boundaryOffset??0)*l,g=i+(o.boundaryOffset??0)*l,m=t.sideMassBefore*l,x=o.sideMassAfter*l;let b,v,w,k;"top"===t.side?(b=y-m,v=b+f):(v=y+m,b=v-f),"top"===o.side?(w=g-x,k=w+p):(k=g+x,w=k-p);const S=c.sourceRunwayStart,A=c.minRun,M=Math.abs((w+k)/2-(b+v)/2),_=h-d,P="number"==typeof S&&Number.isFinite(S),j="number"==typeof A&&Number.isFinite(A)&&A>0;if(P&&M>1e-9&&_>0&&("auto"===A||j)){const e="source"===s?.85:"target"===s?.15:.5,o="auto"===A?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(e*e,(1-e)*(1-e))))):A;if(o>_){const e=r(u(Math.min(S,t.time)));Number.isFinite(e)&&(d=Math.min(d,Math.max(Math.min(d,e),h-o)))}}const L="source"===s?d+.85*(h-d):"target"===s?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:b,sBot:v,tx:h,tTop:w,tBot:k,cp1X:L,cp2X:L}}function un(t){return Math.max(18,11*t.length*.58)}function dn(t){const e=1.22*un(t.labelText)+4;return"start"===t.labelAnchor?[t.labelX,t.labelX+e]:"middle"===t.labelAnchor?[t.labelX-e/2,t.labelX+e/2]:[t.labelX-e,t.labelX]}function hn(t,e){const o=t.labelX-un(t.labelText),i=e.labelX-un(e.labelText);return e.labelX+3>=o&&t.labelX+3>=i}var fn=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function pn(t){return t.replace(fn,(t,e,o)=>`${o},${e}`)}function yn(t){if(!t)return;const e=t=>({x:t.y,y:t.x});return{...t,...t.points&&{points:t.points.map(e)},...t.segments&&{segments:t.segments.map(t=>t.map(e))}}}function gn(t){return{...t,pathD:pn(t.pathD),y0:t.x0,y1:t.x1,x0:0,x1:0}}var mn=require("react/jsx-runtime");function xn(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function bn(t,e){const{background:o="transparent",stroke:i="#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,mn.jsxs)("pattern",{id:e,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[o&&"transparent"!==o&&(0,mn.jsx)("rect",{width:c,height:c,fill:o}),(0,mn.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:i,strokeWidth:n,strokeOpacity:a}),(0,mn.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:i,strokeWidth:n,strokeOpacity:a})]},e)}function vn(t){const{nodes:e,edges:o,domain:i,plotW:n,plotH:r,ribbonLane:s,ribbonMinRun:a=0,edgeOpacity:c,colorOf:l,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:x,usageMode:b="static"}=t,v="vertical"===d?r:n,w="vertical"===d?n:r,k=function(t,e,o,i={}){const n=Jo(i.usageMode??"static"),r=[],s=new Set;for(const e of t)s.has(e.id)&&r.push({kind:"duplicate-node",id:e.id,severity:n.duplicateIds}),s.add(e.id);const a=new Set,c=Array.isArray(o)&&2===o.length,l=c&&Number.isFinite(o[0])&&Number.isFinite(o[1]);c&&l&&l&&o[1]>=o[0]||r.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]||r.push({kind:"invalid-node-time",id:e.id}));for(const t of e)a.has(t.id)&&r.push({kind:"duplicate-edge",id:t.id,severity:n.duplicateIds}),a.add(t.id),s.has(t.source)||r.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),s.has(t.target)||r.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?((null!=t.systemInTime&&!Number.isFinite(t.systemInTime)||null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime))&&r.push({kind:"invalid-system-time",id:t.id,severity:"warn"}),Number.isFinite(t.value)&&t.value>0||r.push({kind:"invalid-value",id:t.id}),t.startTime>t.endTime&&r.push({kind:"backward-edge",severity:"fatal",id:t.id,source:t.source,target:t.target})):r.push({kind:"invalid-edge-time",id:t.id});return r}(e,o,i,{usageMode:b}),{fatal:S,warnings:A}=function(t){const e=[],o=[];for(const i of t)"fatal"===ei(i)?e.push(i):o.push(i);return{fatal:e,warnings:o}}(k),M=function(t,e,o="static"){if("strip"!==Jo(o).invalidSystemTime)return t;const i=new Set(e.filter(t=>"invalid-system-time"===t.kind).map(t=>t.id));return 0===i.size?t:t.map(t=>{if(!i.has(t.id))return t;const e={...t};return null==e.systemInTime||Number.isFinite(e.systemInTime)||delete e.systemInTime,null==e.systemOutTime||Number.isFinite(e.systemOutTime)||delete e.systemOutTime,e})}(o,k,b),_=(0,Zo.scaleTime)().domain(i).range([0,v]);if(S.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:S,warnings:A,xScale:_};const P=function(t,e,o){const{plotH:i,pairing:n="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half",maxValueScale:c,lanePlacement:l="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=o,p=Number.isFinite(d)?Math.max(0,d):0,y=function(t,e){const o=ci(),i=ci();for(const e of t)o[e.id]=[],i[e.id]=[];for(const t of e)i[t.source]&&i[t.source].push(t),o[t.target]&&o[t.target].push(t);return{incoming:o,outgoing:i}}(t,e),g=function(t,e,o,i="temporal"){const n="temporal"===i?(t,e)=>t.endTime-e.endTime||li(t.id,e.id):(t,e)=>e.value-t.value||li(t.id,e.id),r="temporal"===i?(t,e)=>t.startTime-e.startTime||li(t.id,e.id):(t,e)=>e.value-t.value||li(t.id,e.id),s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const o=new Map;for(const i of t){const t=i[e];o.has(t)||o.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const n=o.get(t);n.edges.push(i),n.total+=i.value,n.earliestStart=Math.min(n.earliestStart,i.startTime),n.latestEnd=Math.max(n.latestEnd,i.endTime)}const s=[...o.values()];s.sort("temporal"===i?(t,o)=>"target"===e?t.earliestStart-o.earliestStart||li(t.partner,o.partner):t.latestEnd-o.latestEnd||li(t.partner,o.partner):(t,e)=>e.total-t.total||li(t.partner,e.partner));for(const t of s)t.edges.sort("target"===e?r:n);return s};for(const e of t){const t=o.outgoing[e.id],i=o.incoming[e.id];if(0===i.length)a(t,"target").forEach((t,e)=>{const o=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=o});else if(0===t.length)a(i,"source").forEach((t,e)=>{const o=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=o});else{const e=a(i,"source"),o=a(t,"target"),n=Math.max(e.length,o.length);for(let t=0;n>t;t++){const i=t%2==0?"top":"bot";if(e[t])for(const o of e[t].edges)s.get(o.id).targetSide=i;if(o[t])for(const e of o[t].edges)s.get(e.id).sourceSide=i}}}return s}(t,e,y,n);let m=ci();for(const e of t)m[e.id]=Pi(e,y,g,void 0,u);const x=an(t,e,m,y,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),b=x.slots.map(t=>({occupants:t.occupants.map(t=>({...t})),peak:{...t.peak},...null!=t.group?{group:t.group}:{}})),v=new Set;for(const t of e){const e=x.slotByNode[t.source],o=x.slotByNode[t.target];if(void 0===e||void 0===o)continue;const i=g.get(t.id);e!==o?e>o?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(v.add(t.id),i.sourceSide="bot",i.targetSide="bot")}for(const e of t){const t=y.outgoing[e.id],o=y.incoming[e.id],i=new Set(t.map(t=>g.get(t.id).sourceSide)),n=new Set(o.map(t=>g.get(t.id).targetSide));if(1===i.size&&o.length>0){const t=[...i][0];for(const e of o)x.slotByNode[e.source]===x.slotByNode[e.target]&&(g.get(e.id).targetSide=t)}if(1===n.size&&t.length>0){const e=[...n][0];for(const o of t)x.slotByNode[o.source]===x.slotByNode[o.target]&&(g.get(o.id).sourceSide=e)}}!function(t,e,o){const i=new Map,n=[];for(const e of t)n.push({time:e.startTime,kind:"out",edge:e}),n.push({time:e.endTime,kind:"in",edge:e});n.sort((t,e)=>t.time-e.time||(t.kind===e.kind?0:"in"===t.kind?-1:1)||("out"===t.kind?e.edge.value-t.edge.value:0)||li(t.edge.id,e.edge.id));const r=t=>{let e=i.get(t);return e||(e={top:0,bot:0},i.set(t,e)),e},s=(t,e,o)=>{const i="top"===e?"bot":"top",n=Math.min(o,t[e]);t[e]-=n;const r=o-n;r>0&&(t[i]=Math.max(0,t[i]-r))};for(const t of n){const{edge:i}=t;if("in"===t.kind){const t=e.get(i.id)?.targetSide??"bot";r(i.target)[t]+=i.value;continue}const n=r(i.source),a=e.get(i.id);let c=a.sourceSide??"bot";if(o[i.source]===o[i.target]){const t=n.top>=i.value,e=n.bot>=i.value;t!==e?c=t?"top":"bot":t||e||n.top===n.bot||(c=n.top>n.bot?"top":"bot"),a.sourceSide=c,a.targetSide=c}s(n,c,i.value)}}(e,g,x.slotByNode),function(t,e,o,i){for(const n of t){const t=e.incoming[n.id],r=e.outgoing[n.id];if(0===t.length||0===r.length)continue;const s=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const i of t)"top"===o.get(i.id).targetSide?e.inTop+=i.value:e.inBot+=i.value;for(const t of r)"top"===o.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},a=(t,e)=>{const n=s(),a="top"===t?n.outTop-n.inTop:n.outBot-n.inBot,c="top"===e?n.inTop-n.outTop:n.inBot-n.outBot;if(0>=a||0>=c)return!1;const l=Math.min(a,c),u=r.filter(e=>!i.has(e.id)&&o.get(e.id).sourceSide===t&&l>=e.value).sort((t,e)=>e.value-t.value||li(t.id,e.id));return 0!==u.length&&(o.get(u[0].id).sourceSide=e,!0)};let c=r.length+1;for(;c-- >0&&(a("top","bot")||a("bot","top")););}}(t,y,g,v),m=ci();for(const e of t)m[e.id]=Pi(e,y,g,void 0,u);const w=an(t,e,m,y,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),S=w.slots.slice(0,-1).reduce((t,e,o)=>t+(null!=e.group&&e.group===w.slots[o+1].group?1:0),0),A=Math.max(1,w.slots.length+1-S),M=Math.min(12,Math.max(0,.35*i-S*p)/A),_=2*M+di(w.slots,M,p).reduce((t,e)=>t+e,0),P=k>0?Math.max(0,(i-_)/k):1,j=Number.isFinite(c)&&c>0?Math.min(P,c):P;let L=an(t,e,m,y,{plotH:i,padding:M,valueScale:j,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:l,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P});const $=Number.isFinite(c)&&c>0&&P>c+1e-12;if("insertion"!==s&&("hug"===l||$)&&L.slots.length>1&&(Wi(t,e,m,L.laneLifetime,L.slots,L.slotByNode,{plotH:i,padding:M,valueScale:j,groupPadding:p,laneOrder:s,ribbonLane:h,domain:f,lanePlacement:l,mode:"geometry-refine"}),L=an(t,e,m,y,{plotH:i,padding:M,valueScale:j,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:L.slots,fixedSlotOrder:L.slots.map(ui),lanePlacement:l,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P})),function(t,e){const o=(t,o)=>{for(const i of t){const t=new Map;for(const n of i){const i=`${("out"===o?e.get(n.id)?.sourceSide:e.get(n.id)?.targetSide)??""}\0${"out"===o?n.startTime:n.endTime}`,r="out"===o?`${n.target}\0${n.endTime}`:`${n.source}\0${n.startTime}`,s=t.get(i);if(null!=s&&s!==r)return!0;t.set(i,r)}}return!1};return o(Object.values(t.outgoing),"out")||o(Object.values(t.incoming),"in")}(y,g)){const o=function(t,e,o,i){const n=new Map;for(const r of t){const t=e[r.source]?.localAttachments.get(r.id),s=e[r.target]?.localAttachments.get(r.id),a=o[r.source],c=o[r.target];if(!(t&&s&&Number.isFinite(a)&&Number.isFinite(c)))continue;const l=_i(t,a,i),u=_i(s,c,i);n.set(r.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return n}(e,m,L.centerlines,j);m=ci();for(const e of t)m[e.id]=Pi(e,y,g,o,u);L=an(t,e,m,y,{plotH:i,padding:M,valueScale:j,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:L.slots,fixedSlotOrder:L.slots.map(ui),lanePlacement:l,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:P})}const R=new Map(x.initialSlotOrder.map((t,e)=>[t,e])),C=[...L.slots].sort((t,e)=>(R.get(ui(t))??1/0)-(R.get(ui(e))??1/0)||li(ui(t),ui(e))),I=ci();C.forEach((t,e)=>{for(const o of t.occupants)I[o.id]=e});const T=yi(t,e,m,C,I,{plotH:i,padding:M,valueScale:j,stackValueScale:P,lanePlacement:"stack",groupPadding:p}),O=sn(t,m,C,I,T.centerlines,j,p),z=Si(zi(I,e),Fi(I,e),e,O,C,I,T.centerlines,L.laneLifetime,j,T.verticalUtilization,h,f);m=sn(t,m,L.slots,L.slotByNode,L.centerlines,j,p);const F=Si(zi(L.slotByNode,e),Fi(L.slotByNode,e),e,m,L.slots,L.slotByNode,L.centerlines,L.laneLifetime,j,L.verticalUtilization,h,f);return{nodeData:m,sides:g,valueScale:j,padding:M,compressedPadding:12>M,centerlines:L.centerlines,laneLifetime:L.laneLifetime,slots:L.slots,slotByNode:L.slotByNode,crossingsBefore:"insertion"===s?null:z.crossings,crossingsAfter:"insertion"===s?null:F.crossings,lengthBefore:"insertion"===s?null:z.weightedLength,lengthAfter:"insertion"===s?null:F.weightedLength,layoutQualityBefore:z,layoutQuality:F}}(e,M,{plotH:w,...u,ribbonLane:s,domain:i}),{centerlines:j,nodeData:L,valueScale:$}=P,R=yt(m,x),C=[],I=[],T=0===a?new Map:function(t,e,o){const i=new Set(e.map(t=>t.target)),n=new Map(t.map(t=>[t.id,t])),r=new Map;for(const t of e){if(i.has(t.source))continue;const e=r.get(t.source)??[];e.push(t),r.set(t.source,e)}const s=new Map;for(const e of t){if(!e.group)continue;const t=s.get(e.group)??[];t.push(e),s.set(e.group,t)}const a=new Set;for(const[t,e]of s){const o=e.flatMap(t=>r.get(t.id)??[]),n=new Set(o.map(t=>t.startTime));o.length>0&&1===n.size&&e.every(t=>{const e=t.xExtent?.[0],n=o[0].startTime;return!i.has(t.id)&&(r.get(t.id)?.length??0)>0&&Number.isFinite(e)&&n>e})&&a.add(t)}const c=new Map;for(const[t,e]of r){const i=n.get(t);if(i?.group&&!a.has(i.group))continue;const r=i?.xExtent?.[0],s=[...e].sort((t,e)=>t.startTime-e.startTime||t.id.localeCompare(e.id)),l=s[0]?.startTime-1;let u=null;for(let t=0;s.length>t;){const e=s[t].startTime;let i=t+1;for(;s.length>i&&s[i].startTime===e;)i++;for(let e=t;i>e;e++){const t=s[e],i=Number.isFinite(r)&&t.startTime>r,n=Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime;if(!i&&!n)continue;let a=o[0];i&&(a=Math.max(a,r)),n&&(a=Math.max(a,t.systemInTime)),!i&&n&&Number.isFinite(l)&&(a=Math.max(a,l)),null!=u&&(a=Math.max(a,u)),t.startTime>a&&c.set(t.id,a)}u=e,t=i}}for(const[t,e]of s){if(!a.has(t))continue;const o=e.flatMap(t=>r.get(t.id)??[]);if(!o.every(t=>c.has(t.id))){for(const t of o)c.delete(t.id);continue}const i=Math.max(...o.map(t=>c.get(t.id)));for(const t of o)c.set(t.id,i)}return c}(e,M,i),O=new Map(e.filter(t=>t.group).map(t=>[t.id,t.group])),z=new Map;for(const t of M){const e=L[t.source]?.localAttachments.get(t.id),o=L[t.target]?.localAttachments.get(t.id);e&&o&&z.set(t.id,ln(e,j[t.source],o,j[t.target],$,_,s,i,{minRun:a,sourceRunwayStart:T.get(t.id)}))}const F=function(t,e,o,i,n,r){const s=new Map(e),a=new Map;for(const e of t){const t=r?.get(e.source),o=null==t?"node:"+e.source:"group:"+t,i=a.get(o)??new Map,n=i.get(e.startTime)??[];n.push(e),i.set(e.startTime,n),a.set(o,i)}for(const t of a.values())for(const[r,a]of t){if(!a.some(t=>o.has(t.id)))continue;const t=a.map(t=>e.get(t.id));if(t.some(t=>null==t))continue;const c=i(r),l=Math.min(...t.map(t=>t.sx));if(l>=c-1e-9)continue;const u=Math.max(...a.map(t=>{const e=o.get(t.id);return null==e?c:Math.min(c,i(e))})),d=Math.min(c,Math.max(l,u));for(const t of a){const o=e.get(t.id),i=d+(o.tx-d)*("source"===n?.85:"target"===n?.15:.5);s.set(t.id,{...o,sx:d,cp1X:i,cp2X:i})}}return s}(M,z,T,_,s,O),N=function(t,e,o,i,n){const r=new Map;for(const s of t){if(!o.has(s.id))continue;const t=e.get(s.id);if(!t||t.sx>=i(s.startTime)-1e-9)continue;const a=n(t.sx);Number.isFinite(a)&&s.startTime>a&&r.set(s.id,a)}return r}(M,F,T,_,t=>i[0]+t/v*(i[1]-i[0])),E=function(t,e,o){const i=new Map,n=new Map;for(const[t,e]of o??[]){const o=n.get(e)??[];o.push(t),n.set(e,o)}for(const r of t){const t=e.get(r.id);if(null==t||!Number.isFinite(t)||t>=r.startTime)continue;const s=o?.get(r.source),a=null==s?[r.source]:n.get(s)??[r.source];for(const e of a){const o=i.get(e)??new Map,n=o.get(r.startTime);o.set(r.startTime,null==n?t:Math.min(n,t)),i.set(e,o)}}return i}(M,N,O);e.forEach((t,e)=>{const o=L[t.id];if(!o||0===o.samples.length)return;const n=(r=o.samples,(s=E.get(t.id))&&0!==s.size?r.map(t=>{const e=s.get(t.t);return null==e?t:{...t,t:e}}):r);var r,s;const a=function(t,e,o,i,n){if(0===t.length)return null;const r=Mi(t,n),s=t=>e+(r[t].boundaryOffset??0)*o,a=t=>s(t)-r[t].topMass*o,c=t=>s(t)+r[t].botMass*o;let l=`M${i(r[0].t)},${a(0)}`;for(let t=1;r.length>t;t++)l+=` L${i(r[t].t)},${a(t)}`;l+=` L${i(r[r.length-1].t)},${c(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${i(r[t].t)},${c(t)}`;return l+" Z"}(n,j[t.id],$,_,i);if(!a)return;const c=Mi(n,i),u=c.find(t=>t.topMass+t.botMass>0)||c[0],h=j[t.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*$/2;let f,p,y=l(t.id,e),m=y,x=.5;const b=t.__raw??t;if(g&&g.length>0){const t=xt(b,g,R(b));"string"==typeof t.fill?y=t.fill:null!=t.fill&&xn(t.fill)&&(p=t.fill,y=t.fill.background&&"transparent"!==t.fill.background?t.fill.background:y),"string"==typeof t.stroke&&(m=t.stroke),"number"==typeof t.strokeWidth&&(x=t.strokeWidth),"number"==typeof t.fillOpacity&&(f=t.fillOpacity),"number"==typeof t.opacity&&null==f&&(f=t.opacity)}const v=function(t,e,o,i,n,r){const s=o.nodeData[t];if(!s||0===s.samples.length)return[];const a=o.valueScale,c=o.centerlines[t],l=Mi(s.samples,n),u=l.find(t=>t.topMass+t.botMass>0)||l[0],d=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],h=i(u.t),f=i(d.t),p=t=>i(Ai(t,n)),y=[],g=(t,e,o,i)=>`M${t},${e} L${o},${e} L${o},${i} L${t},${i} Z`;for(const o of e){if(o.source===t&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const t=s.localAttachments.get(o.id),e=r?.get(o.id)??o.startTime;if(t&&"out"===t.kind&&e>o.systemInTime){const i=p(o.systemInTime),r=p(e),s=null!=n&&n[0]>o.systemInTime,l=s?i:i-20,u=s?Math.min(r,i+20):i,d=Math.max(h,l);if(r>d){const[e,o]=_i(t,c,a);y.push({pathD:g(d,e,r,o),x0:l,x1:u,from:0,to:1})}}}if(o.target===t&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const t=s.localAttachments.get(o.id);if(t&&"in"===t.kind&&o.systemOutTime>o.endTime){const e=p(o.systemOutTime),i=p(o.endTime),n=e+20,r=Math.min(f,n);if(r>i){const[o,s]=_i(t,c,a);y.push({pathD:g(i,o,r,s),x0:e,x1:n,from:1,to:0})}}}}return y}(t.id,M,P,_,i,N);C.push({id:t.id,pathD:a,fill:y,stroke:m,strokeWidth:x,...null!=f&&{fillOpacity:f},...p&&{hatchFill:p},...v.length>0&&{gradientStubs:v},rawDatum:b,labelX:_("vertical"===d&&t.xExtent?t.xExtent[0]:u.t)-4,labelY:h,labelText:t.label??t.id})});const D=new Map;e.forEach((t,e)=>D.set(t.id,e)),M.forEach(t=>{const e=F.get(t.id);if(!e)return;const o=D.get(t.source)??0,i=l(t.source,o),{pathD:n,bezier:r}=cn(e),s=t.__raw??t,a="function"==typeof c?Number(c(s)):c,u=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.35;I.push({id:t.id,pathD:n,fill:i,opacity:u,rawDatum:s,bezier:r})});const B=function(t,e,o){const i=t.map(t=>({...t})),n=new Map;for(const t of i){const o=e[t.id];if(null==o)continue;const i=n.get(o)??[];i.push(t),n.set(o,i)}const r=t=>{if(2>t.length)return;const e=t.reduce((t,e)=>t+e.labelY,0)/t.length,i=(t.length-1)/2;t.forEach((t,n)=>{t.labelY=Math.max(8,Math.min(o-8,e+16*(n-i)))})};for(const t of n.values()){t.sort((t,e)=>t.labelX-e.labelX||t.id.localeCompare(e.id));let e=[],o=-1/0;for(const i of t){const t=i.labelX-un(i.labelText);e.length>0&&t>o+3&&(r(e),e=[],o=-1/0),e.push(i),o=Math.max(o,i.labelX)}r(e)}return function(t,e){const o=[...t].sort((t,e)=>t.labelY-e.labelY||t.labelX-e.labelX||t.id.localeCompare(e.id));for(let t=0;3>t;t+=1){for(let t=0;o.length>t;t+=1){let e=8;for(let i=0;t>i;i+=1)hn(o[t],o[i])&&(e=Math.max(e,o[i].labelY+16));o[t].labelY=Math.max(o[t].labelY,e)}for(let t=o.length-1;t>=0;t-=1){let i=e-8;for(let e=t+1;o.length>e;e+=1)hn(o[t],o[e])&&(i=Math.min(i,o[e].labelY-16));o[t].labelY=Math.min(o[t].labelY,i)}}}(i,o),i}(C,P.slotByNode,w).map(t=>function(t,e){return"horizontal"===e?t:{...t,pathD:pn(t.pathD),gradientStubs:t.gradientStubs?.map(gn),labelX:t.labelY,labelY:t.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(t,d)),W="vertical"===d?function(t,e,o){const i=t.map(t=>({...t}));for(const t of i){const o=1.22*un(t.labelText)+4;t.labelX=e-4>o?Math.max(o/2+2,Math.min(e-o/2-2,t.labelX)):e/2}const n=[],r=[...i].sort((t,e)=>t.labelY-e.labelY||t.labelX-e.labelX);for(const t of r){const e=n[n.length-1];!e||Math.abs(e[0].labelY-t.labelY)>14?n.push([t]):e.push(t)}for(const t of n){t.sort((t,e)=>t.labelX-e.labelX||t.id.localeCompare(e.id));const e=[],i=new Map;for(const o of t){const[t,n]=dn(o);let r=e.findIndex(e=>t>e+8);-1===r&&(r=e.length),e[r]=n,i.set(o,r)}const n=t.reduce((t,e)=>t+e.labelY,0)/t.length,r=14*e.length+8>n;for(const e of t){const t=i.get(e)??0;e.labelY=r?Math.min(o-8,12+14*t):Math.max(8,n-14*t)}}return i}(B,n,r):B,Y=new Map;if(null!=f)for(const t of e){const e=t.__raw??t,o="function"==typeof f?f(e):Number(e[f]);Number.isFinite(o)&&Y.set(t.id,o)}const q=function(t,e,o,i,n={}){if(!1===i)return t.map(t=>({...t,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===i)return t.map(t=>({...t,labelDeferred:!1,labelFullText:void 0}));let r=Math.max(4,Math.min(t.length,Math.floor(Math.max(1,e*o)/14e3)));Number.isFinite(n.maxLabels)&&n.maxLabels>=0&&(r=Math.min(r,Math.floor(n.maxLabels)));const s=t.map((t,e)=>{const o=n.priorityById?.get(t.id),i=Math.abs(t.labelY);return{band:t,index:e,score:null!=o&&Number.isFinite(o)?1e6*o+un(t.labelText):un(t.labelText)+.01*i}}).filter(t=>t.band.labelText.trim().length>0).sort((t,e)=>e.score-t.score||t.index-e.index||t.band.id.localeCompare(e.band.id)),a=new Set(s.slice(0,r).map(t=>t.band.id));return t.map(t=>a.has(t.id)||0===t.labelText.trim().length?{...t,labelDeferred:!1,labelFullText:void 0}:{...t,labelFullText:t.labelText,labelText:"",labelDeferred:!0})}(W,n,r,h,{...Y.size>0&&{priorityById:Y},...null!=p&&{maxLabels:p}});return{layout:P,layoutConfig:{bands:q,ribbons:I.map(t=>function(t,e){return"horizontal"===e?t:{...t,pathD:pn(t.pathD),bezier:yn(t.bezier)}}(t,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:A,xScale:_}}var wn=require("react/jsx-runtime"),kn="var(--semiotic-grid, #94a3b8)",Sn="var(--semiotic-text-secondary, #475569)",An="var(--semiotic-text-secondary, #94a3b8)",Mn=.22;function _n(t,e,o){return!e?.isActive||e.predicate(function(t,e){return"scene"===e?t:t.data}(t,o))}var Pn=t=>{const{bands:e=[],ribbons:o=[],showLabels:i=!0,selectionDatum:n="raw"}=t.config,r=t.selection??null,s=[];for(const t of o){const e={__kind:"ribbon",data:t.rawDatum,id:t.id},o=!_n(e,r,n);s.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:o?Math.min(t.opacity,Mn):t.opacity,stroke:"none"},datum:e})}for(const t of e){if(!t.gradientStubs)continue;const e=!_n({__kind:"band",data:t.rawDatum,id:t.id},r,n);for(let o=0;t.gradientStubs.length>o;o++){const i=t.gradientStubs[o];s.push({type:"bezier",pathD:i.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:e?Mn:t.fillOpacity??.86,stroke:"none"},_gradient:{x0:i.x0,x1:i.x1,...null!=i.y0&&{y0:i.y0},...null!=i.y1&&{y1:i.y1},from:i.from,to:i.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${o}`}})}}for(const t of e){const e=!(!t.gradientStubs||0>=t.gradientStubs.length),o={__kind:"band",data:t.rawDatum,id:t.id},i=!_n(o,r,n);s.push({type:"bezier",pathD:t.pathD,style:{...e?{fill:"none"}:{fill:t.hatchFill??t.fill,fillOpacity:i?Mn:t.fillOpacity??.86},stroke:t.stroke??("string"==typeof t.fill?t.fill:"#666"),strokeWidth:t.strokeWidth??.5,...i&&e?{opacity:Mn}:{}},datum:o})}const a=i?e.flatMap(t=>{const e=t.labelDeferred&&t.labelFullText?.trim(),o=t.labelText.trim().length>0,i=e&&r?.isActive&&_n({__kind:"band",data:t.rawDatum,id:t.id},r,n),s=o?t.labelText:i?t.labelFullText:"";return s.trim()?[{x:t.labelX,y:t.labelY,text:s,anchor:t.labelAnchor??"end",baseline:t.labelBaseline??"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:s,labels:a}};function jn(t,e){if(!t)return[];const o=[],i=t=>{o.push(t);const n="function"==typeof e?e(t):t[e];n&&Array.isArray(n)&&n.forEach(i)};return i(t),o}function Ln(t,e,o,i){if(t&&t.length>0)return t;const n=new Set;return e.forEach(t=>{const e="function"==typeof o?o(t):t[o],r="function"==typeof i?i(t):t[i];n.add(e),n.add(r)}),Array.from(n).map(t=>({id:t}))}function $n(t,e,o={}){return ht(e?"function"==typeof e?o=>({...t(o),...e(o)??{}}):o=>({...t(o),...e}):t,o)}var Rn={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{if(!(e||Array.isArray(n.styleRules)&&n.styleRules.length>0||i.nodeStyle||n.nodeStyle||dt(Pt(n))))return{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:o,...i};const r=Array.isArray(n.edges)?n.edges:[],s=Array.isArray(n.nodes)&&n.nodes.length>0?n.nodes:Ln([],r,n.sourceAccessor||"source",n.targetAccessor||"target"),a=Ot(i.theme).colors.categorical,c=it(o,a),l="string"==typeof e?e:"__ssrChordColorBy",u="function"==typeof e?s.map(t=>({...t,__ssrChordColorBy:e(t)})):s,d=e?lt(u,l,o??i.colorScheme??a):void 0,h=new Map,f=n.nodeIdAccessor||n.nodeIDAccessor||"id",p=(t,o)=>{const i=t?.data||t;let r;if(e)r=at(i,e,d);else{const e=(t.id??i?.[f]??"")+"";h.has(e)||h.set(e,h.size);const n=t.index??o??h.get(e);r=c[n%c.length]}return{fill:r,stroke:n.stroke??"black",strokeWidth:n.strokeWidth??1,...void 0!==n.opacity&&{opacity:n.opacity}}},y=vt(n.styleRules,e,n.valueAccessor);return{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:o,nodeStyle:ht(n.nodeStyle||(y?(t,e)=>({...p(t,e),...y(t,e)}):p),Pt(n)),...i}}},Cn={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=function(t){if(void 0!==t.edgeStyle)return t.edgeStyle;const{edgeWidth:e,edgeColor:o,edgeOpacity:i}=t,n=t.strokeWidth??1;return void 0!==e||void 0!==o||void 0!==i||void 0!==t.stroke||void 0!==t.strokeWidth||void 0!==t.opacity?r=>{const s=r?.data||r;let a=n;if("number"==typeof e)a=e;else if("function"==typeof e)a=e(s);else if("string"==typeof e){const t=s?.[e],o="number"==typeof t?t:Number(t);a=Number.isFinite(o)&&o>0?o:n}return{stroke:o??t.stroke??"#999",strokeWidth:a,opacity:i??t.opacity??.6}}:void 0}(n),s=Ot(i.theme).colors.categorical,a=new Map,c=n.nodeStyle??(t=>({fill:e?at(t?.data||t,e,void 0):qe(void 0,s,o,void 0,a),..."number"==typeof n.nodeSize&&{r:n.nodeSize}})),l=vt(n.styleRules,e,"number"==typeof n.nodeSize?void 0:n.nodeSize),u=ht(l?(t,e)=>({...c(t),...l(t,e)}):c,{stroke:n.nodeStroke??n.stroke,strokeWidth:n.nodeStrokeWidth??n.strokeWidth,opacity:n.opacity});return{chartType:"force",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,colorBy:e,colorScheme:o,iterations:n.iterations,forceStrength:n.forceStrength,showLabels:n.showLabels??!1,nodeLabel:n.nodeLabel,nodeSize:n.nodeSize??8,nodeSizeRange:n.nodeSizeRange,nodeStyle:u,edgeStyle:r,...i}}},In={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=Ot(i.theme).colors.categorical,s=new Map,a=jn(t??null,n.childrenAccessor),c="function"==typeof e?e:null,l=c?a.map(t=>({__ssrCirclePackColorBy:c(t)})):a,u=c?"__ssrCirclePackColorBy":"string"==typeof e?e:void 0,d=e&&u?lt(l,u,o??i.colorScheme??r):void 0,h=i.nodeStyle||n.nodeStyle;return{chartType:"circlepack",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,nodeLabel:n.showLabels??i.showLabels?n.nodeLabel||n.nodeIdAccessor:void 0,...null!=n.padding&&{padding:n.padding},colorScheme:o,...i,nodeStyle:$n(t=>{const i=t?.data||t;return{fill:n.colorByDepth?rt[Number(t?.depth||0)%rt.length]:e?c?at({__ssrCirclePackColorBy:c(i)},"__ssrCirclePackColorBy",d??void 0):at(i,e,d??void 0):qe(void 0,r,o,void 0,s),fillOpacity:n.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},h,Pt(n))}}},Tn={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=t??n.data,s=n.childrenAccessor||"children",a=n.nodeIdAccessor||n.nodeIDAccessor||"name",c=Ot(i.theme).colors.categorical,l=o??i.colorScheme??c,u=it(l,c),d=jn(r,s),h="__ssrOrbitColorBy",f="function"==typeof e?e:null,p=e?lt(f?d.map(t=>({[h]:f(t)})):d,f?h:e,l):void 0;return{chartType:"orbit",data:r,childrenAccessor:s,nodeIDAccessor:a,colorBy:e,colorScheme:l,colorByDepth:n.colorByDepth??!1,nodeSize:n.nodeRadius??6,nodeLabel:n.showLabels?a:void 0,showLabels:n.showLabels??!1,orbitMode:n.orbitMode??"flat",orbitSize:n.orbitSize??2.95,orbitSpeed:n.speed??.25,orbitRevolution:n.revolution,orbitRevolutionStyle:n.revolutionStyle,orbitEccentricity:n.eccentricity??1,orbitShowRings:n.showRings??!0,orbitAnimated:!1,nodeStyle:ht(t=>{const o=t.data||t,i=Number(t.depth??0);return{fill:n.colorByDepth?0===i?u[0]:rt[i%rt.length]:e?f?at({[h]:f(o)},h,p):at(o,e,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===i?1:.85}},Pt(n)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...i}}},On={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(t,e,o,i,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",d=n.endTimeAccessor||"endTime",h=n.systemInTimeAccessor,f=n.systemOutTimeAccessor,p=n.xExtentAccessor||"xExtent",y=n.groupBy,g=n.edgeIdAccessor||"id",m=(t,e)=>"function"==typeof t?t(e):e[t],x=Array.isArray(n.edges)?n.edges:[],b=Array.isArray(n.nodes)?n.nodes:[],v=b.length>0?b:Ln([],x,s,a),w=[r(n.domain?.[0]),r(n.domain?.[1])],k=v.map(t=>{const e=m(l,t)+"",o=m(p,t),i=n.nodeLabel?m(n.nodeLabel,t):e,s={id:e,label:null==i?e:i+"",__raw:t},a=y?m(y,t):null;if(null!=a&&a+""!=""&&(s.group=a+""),Array.isArray(o)&&2===o.length){const t=r(o[0]),e=r(o[1]);Number.isFinite(t)&&Number.isFinite(e)&&(s.xExtent=[t,e])}return s}),S=x.map((t,e)=>{const o=m(g,t),i={id:null!=o?o+"":`${m(s,t)}-${m(a,t)}-${e}`,source:m(s,t)+"",target:m(a,t)+"",value:Number(m(c,t)),startTime:r(m(u,t)),endTime:r(m(d,t)),__raw:t};if(h){const e=r(m(h,t));Number.isFinite(e)&&(i.systemInTime=e)}if(f){const e=r(m(f,t));Number.isFinite(e)&&(i.systemOutTime=e)}return i}),[A,M]=i.size??[600,400],_=i.margin,P="vertical"===n.orientation?"vertical":"horizontal",j=function(t,e,o,i="horizontal"){return"vertical"===i?{top:t?38:e?28:16,right:24,bottom:24,left:o?72:24}:{top:t?30:e?24:8,right:80,bottom:o?28:8,left:80}}(!!i.title,!!n.showQualityReadout,Array.isArray(n.axisTicks)&&n.axisTicks.length>0,P),L={...j,..._},$=(i.showLegend??!!e)&&!!e,R=i.legendPosition??"right";$&&("right"===R?L.right=Math.max(L.right,140):"left"===R?L.left=Math.max(L.left,140):"top"===R?L.top=Math.max(L.top,50):"bottom"===R&&(L.bottom=Math.max(L.bottom,80)));const I=L,T=A-I.left-I.right,O=M-I.top-I.bottom,z=it(o,Ot(i.theme).colors.categorical,C),F="function"==typeof e?e:null,N=F?v.map(t=>({_cat:F(t)})):v,E=F?"_cat":"string"==typeof e?e:void 0,D=o??[...z],B=E?lt(N,E,D):null,W=new Map;for(const t of k)W.set(t.id,t.__raw);const Y=(t,o)=>{if(e&&W.has(t)){const o=W.get(t);return F?at({_cat:F(o)},"_cat",B??void 0):at(o,"string"==typeof e?e:"id",B??void 0)}return z[o%z.length]},q=re($&&e?(()=>{const t=new Map;v.forEach((o,i)=>{const n=m(e,o),r=null==n?"":n+"";r&&!t.has(r)&&t.set(r,{label:r,color:Y(m(l,o)+"",i)})});const o=Array.from(t.values());return o.length>0?{legendGroups:[{type:"fill",label:"",items:o,styleFn:t=>{const e=t.color||"#333";return{fill:e,stroke:e}}}]}:void 0})():void 0,i.legend),X=!1!==n.showLabels&&("auto"!==n.showLabels||"auto"),{layout:G,layoutConfig:V,issues:H,xScale:U}=vn({nodes:k,edges:S,domain:w,plotW:T,plotH:O,orientation:P,ribbonLane:n.ribbonLane||"both",ribbonMinRun:"auto"===n.ribbonMinRun||"number"==typeof n.ribbonMinRun?n.ribbonMinRun:0,edgeOpacity:"number"==typeof n.edgeOpacity?n.edgeOpacity:.35,colorOf:Y,showLabels:X,styleRules:n.styleRules,colorBy:e,valueAccessor:c,layoutOpts:{pairing:n.pairing||"temporal",packing:n.packing||"reuse",laneOrder:n.laneOrder||"crossing-min",lifetimeMode:n.lifetimeMode||"half",maxValueScale:"number"==typeof n.maxValueScale?n.maxValueScale:void 0,lanePlacement:n.lanePlacement||"stack",nodeSizing:n.nodeSizing||"temporal",groupPadding:"number"==typeof n.groupPadding?n.groupPadding:0}});if(H.length>0){const t=H.map(oi).join("; ");throw Error("ProcessSankey: data invalid — "+t)}const K=G?function(t){const e=t.layout,o=t.nodes,i=t.orientation,n=t.plotW,r=t.plotH,s=t.timelineExtent,a=t.axisTicks,c=t.showQualityReadout??!1,l=t.showLaneRails??!1,u=(t.warnings??[]).slice(0,3),d=t.timeFormat,h=t.colorOf,f=t.toTime,p=t.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:S}=e;let A=null,M=null;for(const t of o){const e=g[t.id];if(!e||null===e.start||null===e.end)continue;const o=p(e.start),i=p(e.end);(null===A||A>o)&&(A=o),(null===M||i>M)&&(M=i)}const _=t=>Math.max(0,Math.min(s,t)),P=_(A??0),j=Math.max(P,_(M??s)),L=a.map((t,e)=>({tick:t,index:e,coordinate:p(f(t.date))})).filter(({coordinate:t})=>t>=P-.5&&j+.5>=t),$=null!==(w??null)&&null!=k&&null!=S,R=c&&($||u.length>0)?(0,wn.jsxs)("g",{fill:An,fontSize:10,textAnchor:"end",children:[$&&(0,wn.jsxs)(wn.Fragment,{children:[(0,wn.jsxs)("text",{x:n,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(S.pixelLength)]}),(0,wn.jsxs)("text",{x:n,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",S.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*S.verticalUtilization),"%"]})]}),u.map((t,e)=>(0,wn.jsxs)("text",{x:n,y:$?10+11*e:11*e-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",t]},"warn-"+e))]}):null,C=b?(0,wn.jsx)("text",{x:n,y:"vertical"===i?-3:2,fontSize:10,fill:An,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,I=(t,e)=>h?h(t,e):kn;return(0,wn.jsxs)("g","vertical"===i?{children:[R,C,L.map(({index:t,coordinate:e})=>(0,wn.jsx)("line",{x1:0,y1:e,x2:n,y2:e,stroke:kn,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)),l&&o.map((t,e)=>{const o=g[t.id];if(!o||null===o.start)return null;const i=m[t.id],n=i?{topPeak:i.topPeak,botPeak:i.botPeak}:{topPeak:0,botPeak:0},r=y[t.id]+(n.botPeak-n.topPeak)*x/2,s=p(o.start),a=p(o.end),c=I(t.id,e);return(0,wn.jsxs)("g",{children:[(0,wn.jsx)("line",{x1:r,y1:s,x2:r,y2:a,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,wn.jsx)("line",{x1:r-4,y1:s,x2:r+4,y2:s,stroke:c,strokeOpacity:.5}),(0,wn.jsx)("line",{x1:r-4,y1:a,x2:r+4,y2:a,stroke:c,strokeOpacity:.5})]},"lane-"+t.id)}),(0,wn.jsx)("line",{x1:-4,y1:P,x2:-4,y2:j,stroke:kn}),L.map(({tick:t,index:e,coordinate:o})=>{const i=f(t.date),n=null!=t.label?t.label:d?d(new Date(i)):"";return(0,wn.jsxs)("g",{transform:`translate(-4,${o})`,children:[(0,wn.jsx)("line",{x2:-6,stroke:kn}),(0,wn.jsx)("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:Sn,children:n})]},e)})]}:{children:[R,C,L.map(({index:t,coordinate:e})=>(0,wn.jsx)("line",{x1:e,y1:0,x2:e,y2:r,stroke:kn,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)),l&&o.map((t,e)=>{const o=g[t.id];if(!o||null===o.start)return null;const i=m[t.id],n=i?{topPeak:i.topPeak,botPeak:i.botPeak}:{topPeak:0,botPeak:0},r=y[t.id]+(n.botPeak-n.topPeak)*x/2,s=p(o.start),a=p(o.end),c=I(t.id,e);return(0,wn.jsxs)("g",{children:[(0,wn.jsx)("line",{x1:s,y1:r,x2:a,y2:r,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,wn.jsx)("line",{x1:s,y1:r-4,x2:s,y2:r+4,stroke:c,strokeOpacity:.5}),(0,wn.jsx)("line",{x1:a,y1:r-4,x2:a,y2:r+4,stroke:c,strokeOpacity:.5})]},"lane-"+t.id)}),(0,wn.jsx)("line",{x1:P,y1:r+4,x2:j,y2:r+4,stroke:kn}),L.map(({tick:t,index:e,coordinate:o})=>{const i=f(t.date),n=null!=t.label?t.label:d?d(new Date(i)):"";return(0,wn.jsxs)("g",{transform:`translate(${o},${r+4})`,children:[(0,wn.jsx)("line",{y2:6,stroke:kn}),(0,wn.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:Sn,children:n})]},e)})]})}({layout:G,nodes:k,orientation:P,plotW:T,plotH:O,timelineExtent:"vertical"===P?O:T,axisTicks:Array.isArray(n.axisTicks)?n.axisTicks.map(t=>({date:t.date,label:t.label})):[],showQualityReadout:!!n.showQualityReadout,showLaneRails:!!n.showLaneRails,timeFormat:"function"==typeof n.timeFormat?t=>n.timeFormat(t):void 0,colorOf:Y,toTime:t=>r(t),xScale:t=>Number(U(t))}):void 0;return{chartType:"force",nodes:v,edges:x,customNetworkLayout:Pn,layoutConfig:V,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:e,colorScheme:o,...K&&{backgroundGraphics:K},...i,showLegend:$,...q&&{legend:q,legendPosition:R},__legendIncludesAutomatic:!0,margin:I}}},zn={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(t,e,o,i,n)=>{const r=Array.isArray(n.nodes)?n.nodes:Ln([],Array.isArray(n.edges)?n.edges:[],n.sourceAccessor||"source",n.targetAccessor||"target"),s=Ot(i.theme).colors.categorical,a=new Map,c="string"==typeof e?e:"__ssrSankeyColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrSankeyColorBy:e(t)})):r,u=e?lt(l,c,o??i.colorScheme??s):void 0,d=t=>({fill:e?at(t?.data||t,e,u):qe(void 0,s,o,void 0,a),stroke:n.stroke??"black",strokeWidth:n.strokeWidth??1,...void 0!==n.opacity&&{opacity:n.opacity}}),h=vt(n.styleRules,e,n.valueAccessor),f=h?(t,e)=>({...d(t),...h(t,e)}):d,p=function({edgeColorBy:t,colorBy:e,colorScale:o,nodeStyleFn:i,edgeOpacity:n,baseStyle:r={}}){return s=>{const a={fillOpacity:n,...r};if("function"==typeof t)a.fill=t(s);else if("source"===t){const t="object"==typeof s.source?s.source:null;e&&t?a.fill=at(t.data||t,e,o):t&&(a.fill=i(t,t.index).fill)}else if("target"===t){const t="object"==typeof s.target?s.target:null;e&&t?a.fill=at(t.data||t,e,o):t&&(a.fill=i(t,t.index).fill)}else"gradient"===t&&(a.fill="#999",a.fillOpacity=.7*n);return a}}({edgeColorBy:n.edgeColorBy??"source",colorBy:e,colorScale:u,nodeStyleFn:f,edgeOpacity:n.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{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:ht(n.nodeStyle||f,Pt(n)),edgeStyle:ht(n.edgeStyle||p,Pt(n)),colorScheme:o,...i}}},Fn={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=Ot(i.theme).colors.categorical,s=new Map,a=jn(t??null,n.childrenAccessor),c="function"==typeof e?e:null,l=c?a.map(t=>({__ssrTreeColorBy:c(t)})):a,u=c?"__ssrTreeColorBy":"string"==typeof e?e:void 0,d=e&&u?lt(l,u,o??i.colorScheme??r):void 0,h=i.nodeStyle||n.nodeStyle;return{chartType:"cluster"===n.layout?"cluster":"tree",data:t,childrenAccessor:n.childrenAccessor,colorBy:e,colorByDepth:n.colorByDepth,orientation:n.orientation,showLabels:n.showLabels,nodeLabel:!1!==n.showLabels?n.nodeLabel||n.nodeIdAccessor:void 0,colorScheme:o,...i,nodeStyle:$n(t=>{const i=t?.data||t;return{fill:n.colorByDepth?rt[Number(t?.depth||0)%rt.length]:e?c?at({__ssrTreeColorBy:c(i)},"__ssrTreeColorBy",d??void 0):at(i,e,d??void 0):qe(void 0,r,o,void 0,s),stroke:n.stroke??"black",strokeWidth:n.strokeWidth??1,...void 0!==n.opacity&&{opacity:n.opacity}}},h,Pt(n))}}},Nn={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=Ot(i.theme).colors.categorical,s=new Map,a=jn(t??null,n.childrenAccessor),c="function"==typeof e?e:null,l=c?a.map(t=>({__ssrTreemapColorBy:c(t)})):a,u=c?"__ssrTreemapColorBy":"string"==typeof e?e:void 0,d=e&&u?lt(l,u,o??i.colorScheme??r):void 0,h=n.showLabels??i.showLabels,f=n.labelMode,p=void 0!==n.paddingTop?n.paddingTop:i.paddingTop,y=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,g=i.nodeStyle||n.nodeStyle;return{chartType:"treemap",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,labelMode:f,nodeLabel:h?n.nodeLabel||n.nodeIdAccessor:void 0,...null!=n.padding&&{padding:n.padding},...null!=y&&{paddingTop:y},colorScheme:o,...i,nodeStyle:$n(t=>{const i=t?.data||t;return{fill:n.colorByDepth?rt[Number(t?.depth||0)%rt.length]:e?c?at({__ssrTreemapColorBy:c(i)},"__ssrTreemapColorBy",d??void 0):at(i,e,d??void 0):qe(void 0,r,o,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},g,Pt(n))}}},En={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},Dn=require("d3-scale");function Bn(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}var Wn={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r="string"==typeof o?o:"blues",s=function(t,e,o){if(!Array.isArray(t))return;const i=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let n=1/0,r=-1/0;for(const e of t){const t=i(e);null!=t&&isFinite(t)&&(n>t&&(n=t),t>r&&(r=t))}const s=[Number.isFinite(n)?n:0,Number.isFinite(r)?r:1],a=(0,Dn.scaleSequential)(G(o)).domain(s);return{domain:s,colorScale:t=>a(t),valueAccessor:i}}(n.areas,n.valueAccessor,r),a=n.areaStyle??function(t,e){if(t)return o=>{const i=t.valueAccessor(o);return{fill:null!=i&&isFinite(i)?t.colorScale(i):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:e}}}(s,n.areaOpacity??1),c=n.styleRules?bt(a,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},Bn):a,l=!1!==i.showLegend&&s?{gradient:{colorFn:s.colorScale,domain:s.domain,label:"string"==typeof n.valueAccessor?n.valueAccessor:"value"}}:void 0;return{areas:n.areas,projection:n.projection||"equalEarth",areaStyle:c,valueAccessor:n.valueAccessor,colorScheme:r,graticule:n.graticule,fitPadding:n.fitPadding,...i,...void 0===i.legend&&l?{legend:l}:{}}}},Yn={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r=t||n.points,s=n.pointStyle??function(t,e,o,i){const n=Array.isArray(t)?t:[];let r,s;if(e){const t="string"==typeof e?e:"__geoColorBy",i="string"==typeof e?n:n.map(t=>({...t,__geoColorBy:e(t)}));r=lt(i,t,o)}if(i.sizeBy){const t=n.map("function"==typeof i.sizeBy?i.sizeBy:t=>t?.[i.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=Nt(t))}return t=>({fill:e&&r?at(t,e,r):ot,fillOpacity:i.fillOpacity,stroke:"#fff",strokeWidth:i.strokeWidth,r:i.sizeBy?ut(t,i.sizeBy,i.sizeRange,s):i.pointRadius??6})}(r,e,o,{sizeBy:n.sizeBy,sizeRange:n.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=n.styleRules?bt(s,n.styleRules,yt(e,n.sizeBy)):s;return{points:r,xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",areas:n.areas,areaStyle:n.areaStyle||En,pointStyle:a,sizeBy:n.sizeBy,colorBy:e,colorScheme:o,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,...i}}},qn={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,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],d="function"==typeof l?l:t=>t[l],h=(n.nodes||[]).map(t=>({...t,x:u(t),y:d(t)})),f=new Map;for(const t of h)f.set(t[s]+"",t);const p=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+""),o=f.get(t.target+"");return e&&o?{...t,coordinates:[{x:e.x,y:e.y},{x:o.x,y:o.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?lt(g.map(t=>({[m]:p(t)})),m,o||"category10"):lt(g,p,o||"category10"):null,b=t=>p&&x?at(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:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:n.lineType||"geo",flowStyle:n.flowStyle||"basic",areas:n.areas,areaStyle:n.areaStyle||En,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,colorScheme:o,lineStyle:t=>{const e=Number(t?.[a]),o=Number.isFinite(e)?e:v,i=S+Math.max(0,Math.min(1,k>0?(o-v)/k:0))*M;return{stroke:b(t),strokeWidth:i,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}},Xn=c(require("react"));function Gn(t){const[e,o]=t,i=160>e||116>o,n=i?Math.min(12,Math.max(2,.08*e)):32,r=i?Math.min(8,Math.max(2,.12*o)):24,s=i?r:34;return{width:e,height:o,plot:{x:n,y:r,width:Math.max(1,e-2*n),height:Math.max(1,o-r-s)}}}function Vn(t){const e=(t??"")+"";if(!e)return"#4e79a7";const o=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let i=0;for(let t=0;e.length>t;t+=1)i=31*i+e.charCodeAt(t)>>>0;return o[i%o.length]}function Hn(t,e="#4e79a7",o){const i=o?.styleRules,n=!!i&&i.length>0,r=n?ft(o?.valueAccessor):void 0;return o=>{const s=o.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,c={fill:null==a?e:Vn(a),stroke:"#111827",strokeWidth:1,opacity:.9};return n&&s&&Object.assign(c,xt(s,i,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function Un(t,e,o,i){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:o},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...i}}}function Kn(t,e,o){return"function"==typeof o?o(t,e):t[o]}function Zn(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 Qn(t,e,o){return Math.max(e,Math.min(o,t))}function Jn(t,e){const o=Zn(t);return null!=o&&o>0?o:e}function tr(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function er(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 or=require("d3-scale");function ir(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 nr={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},rr=1e-9,sr=.005;function ar(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function cr(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 lr(t,e,o){return Math.max(e,Math.min(o,t))}function ur(t,e,o){return Math.min(t??o,e??o)}function dr(t,e,o){return lr(Math.max(t??o,e??o),0,1)}function hr(t){return 0>t?-1:1}function fr(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,o=t.shape.height/2;return{minX:t.x-e,minY:t.y-o,maxX:t.x+e,maxY:t.y+o}}function pr(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,o=e.height/2;return{minX:e.x-t,minY:e.y-o,maxX:e.x+t,maxY:e.y+o}}const o=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-o,minY:Math.min(e.y1,e.y2)-o,maxX:Math.max(e.x1,e.x2)+o,maxY:Math.max(e.y1,e.y2)+o}}function yr(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function gr(t,e,o,i,n,r,s,a){const c=n-t,l=(o+s)/2-Math.abs(c);if(0>=l)return null;const u=r-e,d=(i+a)/2-Math.abs(u);return d>0?d>l?{nx:hr(c),ny:0,penetration:l}:{nx:0,ny:hr(u),penetration:d}:null}function mr(t,e,o,i,n,r,s){const a=r/2,c=s/2,l=t-lr(t,i-a,i+a),u=e-lr(e,n-c,n+c),d=l*l+u*u;if(d>o*o)return null;if(rr>=d){const r=Math.abs(t-(i-a)),s=Math.abs(t-(i+a)),l=Math.abs(e-(n-c)),u=Math.abs(e-(n+c)),d=Math.min(r,s,l,u);return d===r?{nx:-1,ny:0,penetration:o+r}:d===s?{nx:1,ny:0,penetration:o+s}:d===l?{nx:0,ny:-1,penetration:o+l}:{nx:0,ny:1,penetration:o+u}}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:o-h}}function xr(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,o,i,n,r){const s=i-t,a=n-e,c=o+r,l=s*s+a*a;if(l>=c*c)return null;if(rr>=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 gr(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 o=mr(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return o?{nx:-o.nx,ny:-o.ny,penetration:o.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?mr(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function br(t,e){const o=e.shape;return"aabb"===o.type?"circle"===t.shape.type?mr(t.x,t.y,t.shape.radius,o.x,o.y,o.width,o.height):gr(o.x,o.y,o.width,o.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,o,i,n,r,s,a=0){const c=r-i,l=s-n,u=c*c+l*l,d=u>rr?lr(((t-i)*c+(e-n)*l)/u,0,1):0,h=o+a/2,f=t-(i+c*d),p=e-(n+l*d),y=f*f+p*p;if(y>=h*h)return null;if(rr>=y){const t=Math.sqrt(u);return t>rr?{nx:-l/t,ny:c/t,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,o.x1,o.y1,o.x2,o.y2,o.thickness??0)}function vr(t,e){return`${t}\0${e}`}function wr(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function kr(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:ar(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function Sr(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 Ar(t){return{id:t.id,shape:cr(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:Sr(t.bodyFilter),index:t.index}}function Mr(t,e){return!!e?.some(e=>Object.is(t,e))}function _r(t,e){return function(t,e){if(!e)return!0;if("function"==typeof e)return e(t);const o=function(t,e){if(!e)return;let o=t;for(const t of e.split(".")){if(null==o||"object"!=typeof o)return;if(!Object.prototype.hasOwnProperty.call(o,t))return;o=o[t]}return o}(t,e.property);return!("equals"in e&&!Object.is(o,e.equals)||"notEquals"in e&&Object.is(o,e.notEquals)||e.oneOf&&!Mr(o,e.oneOf)||e.notOneOf&&Mr(o,e.notOneOf))}(e,t.bodyFilter)}var Pr=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={...nr,...t},this.random=ir(this.options.seed)}init(t={}){this.options={...nr,...t},this.random=ir(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(rr,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:ar(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))wr(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:cr(e.shape),bodyFilter:Sr(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,o){const i=this.bodies.get(t);i&&(i.vx+=e/i.mass,i.vy+=o/i.mass,this.wake(i))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const o=this.sortedBodies();for(const t of o)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const i=this.options.maxVelocity;for(const t of o)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,i>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>i){const o=i/e;t.vx*=o,t.vy*=o}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(o),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(o,n,0===t),this.resolveColliders(o,r,0===t);this.updateSensors(o),this.updateSleeping(o,e)}settle(t=1200,e=this.options.fixedDt){let o=0;for(;t>o&&!this.allSleeping();)this.step(e),o+=1;return o}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:ar(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(wr)}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(kr),colliders:this.sortedColliders().map(Ar),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=ir(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=kr(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=Ar(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 o=this.bodies.get(e.bodyId);if(!o||o.sleeping)continue;const i="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!i)continue;const n=i.x-o.x,r=i.y-o.y,s=Math.sqrt(n*n+r*r);if(rr>=s)continue;const a=n/s,c=r/s,l=(s-e.restLength)*e.stiffness+((("vx"in i?i.vx:0)-o.vx)*a+(("vy"in i?i.vy:0)-o.vy)*c)*e.damping;o.vx+=l*a*t/o.mass,o.vy+=l*c*t/o.mass}}resolveBodyPairs(t,e,o){for(const i of e){const[e,n]=i.split(":").map(Number),r=t[e],s=t[n];if(!r||!s)continue;const a=xr(r,s);a&&(this.resolveDynamicCollision(r,s,a),o&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),o=new Map;for(let i=0;t.length>i;i+=1){if(!1===t[i].bodyCollisions)continue;const n=fr(t[i]),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=o.get(n);r?r.push(i):o.set(n,[i])}}const i=new Set;for(const e of Array.from(o.keys()).sort()){const n=o.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let o=e+1;n.length>o;o+=1){const r=n[e],s=n[o];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&yr(fr(t[r]),fr(t[s]))&&i.add(`${r}:${s}`)}}return Array.from(i).sort((t,e)=>{const[o,i]=t.split(":").map(Number),[n,r]=e.split(":").map(Number);return o===n?i-r:o-n})}resolveDynamicCollision(t,e,o){t.sleeping&&this.contactOpposesGravity(o.nx,o.ny)&&this.supportedThisStep.add(e.id),e.sleeping&&this.contactOpposesGravity(-o.nx,-o.ny)&&this.supportedThisStep.add(t.id);const i=t.sleeping?0:1/t.mass,n=e.sleeping?0:1/e.mass,r=i+n;if(rr>=r)return;const s=Math.max(0,o.penetration-sr)/r;t.x-=o.nx*s*i,t.y-=o.ny*s*i,e.x+=o.nx*s*n,e.y+=o.ny*s*n;const a=(e.vx-t.vx)*o.nx+(e.vy-t.vy)*o.ny;if(a>0)return;const c=Math.abs(a),l=-(1+ur(t.restitution,e.restitution,this.options.restitution))*a/r,u=l*o.nx,d=l*o.ny;t.vx-=u*i,t.vy-=d*i,e.vx+=u*n,e.vy+=d*n,this.applyFriction(t,e,o,l,i,n),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,o,i,n,r){const s=-o.ny,a=o.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=n+r;if(rr>=Math.abs(c)||rr>=l)return;const u=dr(t.friction,e.friction,this.options.friction),d=lr(-c/l,-i*u,i*u),h=d*s,f=d*a;t.vx-=h*n,t.vy-=f*n,e.vx+=h*r,e.vy+=f*r}resolveColliders(t,e,o){for(const i of t)for(const t of e){if(!_r(t,i))continue;if(!yr(fr(i),pr(t)))continue;const e=br(i,t);e&&(this.resolveStaticCollision(i,t,e),this.contactOpposesGravity(e.nx,e.ny)&&this.supportedThisStep.add(i.id),o&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,o){t.x+=o.nx*Math.max(0,o.penetration-sr),t.y+=o.ny*Math.max(0,o.penetration-sr);const i=t.vx*o.nx+t.vy*o.ny;if(0>i){const n=ur(t.restitution,e.restitution,this.options.restitution);t.vx-=(1+n)*i*o.nx,t.vy-=(1+n)*i*o.ny;const r=-o.ny,s=o.nx,a=t.vx*r+t.vy*s,c=dr(t.friction,e.friction,this.options.friction);t.vx-=a*r*c,t.vy-=a*s*c}}updateSensors(t){const e=new Set,o=this.sortedColliders().filter(t=>t.sensor);for(const i of t){const t=fr(i);for(const n of o){if(!_r(n,i))continue;if(!yr(t,pr(n)))continue;if(!br(i,n))continue;const o=vr(n.id,i.id);e.add(o),this.activeSensors.has(o)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:o,bodyId:i}=wr(t);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:o})}this.activeSensors=e}updateSleeping(t,e){const o=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of t)Math.sqrt(i.vx*i.vx+i.vy*i.vy)>=this.options.sleepSpeed||Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY))>=this.options.sleepSpeed*e||o&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=e,i.sleeping||this.options.sleepAfter>i.sleepTime||(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}contactOpposesGravity(t,e){const{x:o,y:i}=this.options.gravity,n=Math.hypot(o,i);return 1e-9>=n||-.2>(t*o+e*i)/n}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},jr=class{constructor(t={}){this.id="builtin",this.capabilities={...(new Pr).capabilities,engine:"builtin"},this.world=new Pr(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,o){this.world.applyImpulse(t,e,o)}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 Lr(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new jr(t)}(e)}var $r=["binId","targetBin","category","windowIndex","lane","group"];function Rr(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 o=e-t.mean;t.mean+=o/t.count,t.m2+=o*(e-t.mean)}function Cr(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 Ir(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 Tr(t,e){if(null!=t[e])return t[e];const o=t.datum;return o&&"object"==typeof o?o[e]:void 0}function Or(t,e,o){return"function"==typeof t?t(e,o):"string"==typeof t?Tr(e,t):void 0}function zr(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Fr(t){const e=Cr(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:Cr(t.x),y:Cr(t.y),value:e}}var Nr=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 o=zr(Or(this.config.binAccessor,t,e))??function(t){for(const e of $r){const o=zr(Tr(t,e));if(o)return o}return"sediment"}(t),i=zr(Or(this.config.labelAccessor,t,e))??o,n=function(t,e,o){if("number"==typeof t)return t;const i="function"==typeof t?t(e,o):"string"==typeof t?Tr(e,t):1,n="number"==typeof i?i:Number(i);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(o);return s||(s={id:o,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(o,s)),s.label=i,s.lastBodyId=t.id,s.lastDatum=t.datum,Rr(s.x,t.x),Rr(s.y,t.y),Rr(s.value,n),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),Fr(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Fr)}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:Ir(e.x),y:Ir(e.y),value:Ir(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 Er(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var Dr={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},Br={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Wr(t={},e=Br){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 Yr(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function qr(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 Xr(t,e){if(null!=t[e])return t[e];const o=t.datum;return o&&"object"==typeof o?o[e]:void 0}function Gr(t){return{...Yr(t),sequence:t.sequence,spawnAt:t.spawnAt}}function Vr(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 Hr(t){return!1!==t&&{...t}}function Ur(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function Kr(t){return{...t,gravity:{...t.gravity}}}function Zr(t,e,o,i){if("circle"===t.shape.type){const n=t.x-e,r=t.y-o,s=t.shape.radius+i,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(o-t.y)-t.shape.height/2,0),s=n*n+r*r;return s>i*i?null:s}function Qr(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function Jr(t,e={}){const{idPrefix:o="plot",includeFloor:i=!0,includeCeiling:n=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,d=t.y+t.height/2;return i&&l.push({id:o+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),n&&l.push({id:o+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),r&&l.push({id:o+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:d,width:a,height:t.height+2*c}}),s&&l.push({id:o+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:d,width:a,height:t.height+2*c}}),l}function ts(t){const{idPrefix:e="bin",count:o,domainStart:i,domainStep:n,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?o:o-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&o>t)continue;const s=r(i+t*n);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let t=0;o>t;t+=1){const o=i+t*n,s=o+n;if(s>=d)continue;const a=r(o),l=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}var es={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 os(t,e){const o={...t};for(const t of e)o[es[t]]++;return o}function is(t,e,o){const i=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:i,revisions:os(o,i)}}var ns=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=is({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 o=is(t,e,this.revisions);this.revisions=o.revisions,this.latest=o;for(const t of[...this.listeners])t();return o}},rs=require("d3-quadtree"),ss=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,o,i,n,r=0,s){const a=this.ensure(t,e);if(!a)return null;let c=null,l=1/0;const u=Math.max(0,s?.searchRadius??Math.max(0,r)+this.maxSearchRadius),d=i-u,h=i+u,f=n-u,p=n+u;return a.visit((t,e,a,u,y)=>{if(d>u||e>h||f>y||a>p)return!0;if(t.length)return!1;let g=t;for(;g;){const t=g.data;if(t&&(!s?.include||s.include(t))){const e=s?.distanceSquared?s.distanceSquared(t,i,n):Zr(t,i,n,Math.max(0,r));null!=e&&(l>e||e===l&&o.indexOf(t.id)>o.indexOf(c?.id??""))&&(c=t,l=e)}g=g.next}return!1}),c}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const o=t.readState();return 0===o.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=o.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,rs.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o),this.revision=e,this.tree)}},as=["data","scene-geometry","data-paint","accessibility","evidence"],cs=["scene-geometry","data-paint","accessibility","evidence"],ls=["overlay","accessibility","evidence"],us=(t,e)=>({retainedData:t,invalidations:e}),ds=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hs=["scene-geometry","data-paint","accessibility","evidence"],fs=[],ps={engine:us("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:us("preserve",hs),colliders:us("preserve",hs),sediment:us("preserve",hs),bodyBudget:us("preserve",ds),bodyLimit:us("preserve",ds),eviction:us("preserve",ds),fixedDt:us("preserve",fs),maxDeltaSeconds:us("preserve",fs),maxSubsteps:us("preserve",fs),settleStepLimit:us("preserve",fs),timeScale:us("preserve",fs),observation:us("preserve",fs)},ys=us("preserve",ds);function gs(t){let e="preserve";const o=new Set;for(const i of t){const t=ps[i]??ys;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}var ms=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function xs(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&ms.every(o=>t[o]===e[o])}function bs(t,e,o,i){return t||!e?"paused":o||!i?"running":"settled"}var vs=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(t){this.speed=function(t){const e=t?.sleepSpeed;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:8}(t)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(t,e,o){if(o>0)return void(this.seconds=0);const i=t.readState(this.scratch),n=this.speed*this.speed;let r=!0;for(const t of i)if(!t.sleeping&&t.vx*t.vx+t.vy*t.vy>=n){r=!1;break}this.seconds=r?this.seconds+Math.max(0,e):0}},ws=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new ss,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new ns,this.simulationState="settled",this.visible=!0,this.quiescence=new vs;const{bodyBudget:e,colliders:o,engine:i,kernel:n,observation:r,sediment:s,...a}=t;this.config={...Dr,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=i,this.observation=Wr(r),this.sediment=new Nr(s??!1),this.world=Lr(i,{fixedDt:this.config.fixedDt,...n}),this.quiescence.setKernelOptions(n),o&&this.world.setColliders(Vr(o))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(o=>"kernel"===o?!xs(t.kernel,e.kernel):t[o]!==e[o])}(t,this.configInput),{colliders:o,bodyBudget:i,engine:n,kernel:r,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=Lr(n,t.options),this.world.restore(t),this.revision+=1}if(r&&!xs(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.quiescence.setKernelOptions(e),this.revision+=1}s&&(this.observation=Wr(s,this.observation)),this.sediment.updateConfig(a),o&&(this.world.setColliders(Vr(o)),this.revision+=1),this.configInput={...this.configInput,...t};const l=gs(e);this.updateResults.record({kind:"config",keys:e},l.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(Vr(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},gs(["colliders"]).invalidations)}enqueue(t,e){const o=Array.isArray(t)?t:[t],i=e?function(t,e={}){const o=qr(e.startAt)??0,i=e.pacing??"immediate";if("arrival"===i){const i=t.map((t,o)=>function(t,e,o){return"function"==typeof o?qr(o(t,e)):"string"==typeof o?qr(Xr(t,o)):qr(t.spawnAt)??qr(Xr(t,"arrivalTime"))??qr(Xr(t,"timestamp"))??qr(Xr(t,"time"))??qr(Xr(t,"eventTime"))}(t,o,e.timeAccessor)),n=i.filter(t=>null!=t),r=n.length>0?Math.min(...n):0,s=qr(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const n=i[e],s=null==n?0:Math.max(0,n-r);return{...Yr(t),spawnAt:o+s/a}})}if("object"==typeof i){const e=qr(i.ratePerSec);if(e&&e>0)return t.map((t,i)=>({...Yr(t),spawnAt:o+i/e}))}return t.map(t=>({...Yr(t),spawnAt:o}))}(o,{...e,startAt:e.startAt??this.elapsedSeconds}):o;for(const t of i)this.queue.push({...Yr(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Ur),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?as:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(Yr(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},as)}materializeDueSpawns(){const t=this.revision,e=[],o=[];return this.spawnDue(e,o),0===e.length||(this.observeBodyBudget(o),this.evictOverflow(o),this.syncSimulationState(o),this.revision+=1,this.updateResults.record({kind:"enqueue",count:e.length},this.revision!==t?as:[])),e}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.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},as)}tick(t){const e=this.revision,o=[],i=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,o,i,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(o,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);i.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)),this.quiescence.refresh(this.world,a,o.length),(u>0||o.length>0||i.length>0||n.length>0||r.length>0)&&(this.revision+=1);const d=this.result(u,o,i,n,r,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?o.length||i.length||n.length?as:cs:[]),d}settle(t=this.config.settleStepLimit){return this.runSettle(t,!1).steps}settleWithObservations(t=this.config.settleStepLimit){return this.runSettle(t,!0)}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:t=>{this.elapsedSeconds+=t},spawnDue:(t,e)=>this.spawnDue(t,e),observeBodyBudget:t=>this.observeBodyBudget(t),evictOverflow:t=>this.evictOverflow(t),step:t=>this.world.step(t),drainEvents:()=>this.world.events(),observeKernelEvents:(t,e)=>this.observeKernelEvents(t,e),observeSensorTransitions:t=>this.observeSensorTransitions(t),refreshQuiescence:(t,e)=>this.quiescence.refresh(this.world,t,e)}}runSettle(t,e){const o=this.revision,i=[],n=[],r=[],s=[],a=e?[]:void 0;if(e&&(this.paused||!this.visible)){const t=this.result(0,i,n,r,s,a??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,a);const c=this.observeBodyBudget(a),l=this.evictOverflow(a);n.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(a),i.length>0&&this.quiescence.reset();const u=e?{spawned:i,evicted:n,sedimented:r,events:s,observations:a}:{spawned:i},{steps:d,budget:h}=function(t,e,o){let i,n=0;for(;e>n&&(t.queueSize()>0||!t.atRest());){t.advanceTime(t.fixedDt);const e=[];if(t.spawnDue(e,o.observations),e.length>0){o.spawned.push(...e),i=t.observeBodyBudget(o.observations);const n=t.evictOverflow(o.observations);o.evicted?.push(...n.evicted),o.sedimented?.push(...n.sedimented)}t.step(t.fixedDt);const r=t.drainEvents();o.events&&(o.events.push(...r),t.observeKernelEvents(r,o.observations),t.observeSensorTransitions(o.observations)),n+=1,t.refreshQuiescence(t.fixedDt,e.length)}return{steps:n,budget:i}}(this.settleHost(),t,u),f=i.length+n.length+r.length>0;(d>0||f||s.length>0)&&(this.revision+=1);const p=this.result(d,i,n,r,s,a??[],void 0,h??c);return this.updateResults.record({kind:"settle",count:d},this.revision===o?[]:f?as:cs),p}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:o=0,binWidth:i=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*(i+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:o-l,width:i,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,o=0,i){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,o,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:o,chartId:i,...n}=t,r={...n,timestamp:e??this.elapsedSeconds,chartType:o??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}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?ls:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?ls:[])}remove(t){const e=new Set(t),o=new Set(this.liveBodyOrder),i=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>o.has(t)||i.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?as:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},cs),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},cs)}applyImpulse(t,e,o){this.world.applyImpulse(t,e,o),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},cs)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,o,i)=>t.applyImpulse(e,o,i),clear:()=>t.clear(),hitTest:(e,o,i)=>t.hitTest(e,o,i),pause:()=>t.setPaused(!0),push:(e,o)=>t.enqueue(e,o),pushMany:(e,o)=>t.enqueue(e,o),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:Hr(this.bodyBudget),config:{...this.config,kernel:Kr(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Gr),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:Hr(t.bodyBudget??{}),kernel:Kr(t.world.options)},this.bodyBudget=Hr(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(t.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(Gr).sort(Ur),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??bs(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"},as)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const o=this.queue.shift();if(!o)return;this.spawnOne(o,e),t.push(o.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 o=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:o?.datum??t.datum,x:o?.x??t.x,y:o?.y??t.y},e)}result(t,e,o,i,n,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:o,events:n,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!this.atRest()),sleeping:c,sedimented:i,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,o){if(0===e.length)return;const i=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=i.get(t.bodyId);o.emit({type:"physics-settle",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.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,o){const i=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===i.size&&0===e.size)return i;const n=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:i,bodyId:r}=Qr(e),s=o.observation.sensors[i],a=n.get(r);o.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:s?.binId??i})};for(const t of Array.from(i).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())i.has(t)||r("exit",t);return i}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const o of t)e.has(Qr(o).bodyId)&&t.delete(o)}(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)),o=Math.max(0,Math.floor(t.queuedBodies??0)),i=e+o,n=Er(t.bodyLimit),r=Er(t.engineMaxBodiesHint),s=function(t,e,o){if(!1===o)return;const i=Er(o?.warnAt);return null!=i?i:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,r,t.options),a=null==n?0:Math.max(0,e-n),c=a>0?"overflow":null==s||s>i?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:i,queuedBodies:o,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 o=`${e.state}:${e.action}`;return o===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=o,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=bs(this.paused,this.visible,this.queue.length>0,this.atRest());if(e===this.simulationState)return;const o=this.simulationState;this.simulationState=e,function(t,e,o){o.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||o.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,simulationState:e,previousSimulationState:t})}(o,e,this.observationContext(t))}evictOverflow(t){const{evicted:e,sedimented:o,liveBodyOrder:i}=function(t,e,o,i,n,r){const s={evicted:[],sedimented:[],liveBodyOrder:n};if(!1===o)return s;const a=Math.max(0,Math.floor(i));if(!Number.isFinite(a))return s;const c=n.length-a;if(0>=c)return s;const l=function(t,e,o){if("sleeping-first"!==e)return o.slice();const i=new Map(t.readState().map(t=>[t.id,t.sleeping])),n=[],r=[];for(const t of o)i.get(t)?n.push(t):r.push(t);return[...n,...r]}(t,o,n),u=l.slice(0,c);if(0===u.length)return s;const d=function(t,e,o,i){const n=new Map(t.readState().map(t=>[t.id,t])),r=[];for(const t of o){const o=n.get(t);if(!o)continue;const s=e.add(o);s&&(r.push(t),i.emit({type:"physics-sediment",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t,datum:o.datum,x:o.x,y:o.y,binId:s.id,count:s.count,total:s.total}))}return r}(t,e,u,r);t.remove(u);const h=new Set(u);return{evicted:u,sedimented:d,liveBodyOrder:n.filter(t=>!h.has(t))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(t));return e.length>0&&(this.liveBodyOrder=i,this.removeActiveSensorPairsForBodies(new Set(e))),{evicted:e,sedimented:o}}};var ks=require("d3-scale");function Ss(t){const{count:e,idPrefix:o,wallThickness:i,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:`${o}-wall-${e}`,shape:{type:"aabb",x:n(e),y:c+l/2,width:i,height:l}}})}function As(t,e,o){const i=t.width/Math.max(1,e),n=Math.max(2,2*o),r=Math.min(.7*i,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(r/n));return{laneWidth:i,tubeWidth:r,ballDiameter:n,perRow:s,centerX:e=>t.x+(e+.5)*i,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*n}}var Ms=require("d3-scale");function _s(t){if(Array.isArray(t)&&t.length>=2){const e=Zn(t[0]),o=Zn(t[1]);return null!=e&&null!=o?{x:e,y:o}:null}if(t&&"object"==typeof t){const e=t,o=Zn(e.x),i=Zn(e.y);return null!=o&&null!=i?{x:o,y:i}:null}return null}function Ps(t){return Array.isArray(t)?t.map(_s).filter(t=>null!=t):[]}function js(t,e,o){return"normalized"===o?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:Qn(t.x,e.plot.x,e.plot.x+e.plot.width),y:Qn(t.y,e.plot.y,e.plot.y+e.plot.height)}}function Ls(t){let e=0;for(let o=1;t.length>o;o+=1)e+=Math.hypot(t[o].x-t[o-1].x,t[o].y-t[o-1].y);return e}function $s(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const o=Qn(e,0,1)*Ls(t);let i=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(i+s>=o){const t=(o-i)/s;return{x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t}}i+=s}}return{...t[t.length-1]}}function Rs(t,e){const o=$s(t,Math.max(0,e-.02)),i=$s(t,Math.min(1,e+.02)),n=i.x-o.x,r=i.y-o.y,s=Math.hypot(n,r)||1;return{x:n/s,y:r/s}}function Cs(t,e,o){return Math.max(e,Math.min(o,t))}function Is(t,e,o,i,n,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:o,x2:i,y2:n,thickness:r.thickness??8}}}function Ts(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,o=t.y,i=t.width,n=t.height,{type:"aabb",x:e,y:o,width:i,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,o,i,n}function Os(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ts({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function zs(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}}var Fs=require("d3-scale");function Ns(t,e,o){return it(t,e,o)}function Es(t,e){const o=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>o&&ct(o,t)||"#4e79a7":e=>{if(o){const t=ct(o,e);if(t)return t}let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return t[Math.abs(i)%t.length]??"#4e79a7"}}function Ds(t,e){const o=e.config??{},i=(e.sensors??[]).map(t=>({...t,sensor:!0})),n=[...e.colliders??[],...i],r=[...t.colliders??[],...o.colliders??[],...n];return{...t,...o,observation:{...t.observation,...o.observation},...r.length>0&&{colliders:r}}}function Bs(t){const e=Vs(t);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:e.top,x2:e.left,y2:t.floorY,thickness:e.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:e.top,x2:t.width-e.rightInset,y2:e.top,thickness:e.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:t.floorY,x2:t.width-e.rightInset,y2:t.floorY,thickness:e.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-e.rightInset,y1:e.top,x2:t.width-e.rightInset,y2:t.floorY,thickness:e.thickness}}]}function Ws(t,e,o,i){return o?"function"==typeof o?o(t,e):t[o]??i:i}function Ys(t){return`gauntlet:${t}:core`}function qs(t,e){return`gauntlet:${t}:positive:${e}`}function Xs(t,e,o){return`gauntlet:${t}:negative:${e}:${o}`}var Gs={left:28,top:76,rightInset:30,thickness:8};function Vs(t){const e=t.height??t.floorY+36;if(t.width>=220&&e>=160)return Gs;const o=Math.max(1,Math.min(t.width,e)),i=Math.max(2,.04*t.width);return{left:i,top:Math.max(2,.08*e),rightInset:i,thickness:Math.max(1,Math.min(4,.04*o))}}function Hs(t){return Math.max(.12,Math.min(1,t.width/500,(t.height??t.floorY+36)/260))}function Us(t,e,o,i){const n=Vs(i),r=Math.max(2,o+2),s=n.top+n.thickness/2+r,a=i.floorY-r,c=(t,e,o)=>e>o?(e+o)/2:Math.max(e,Math.min(o,t));return{x:c(t,n.left+n.thickness/2+r,i.width-n.rightInset-n.thickness/2-r),y:c(e,s,a)}}function Ks(t,e,o=1){const i=[...t].sort((t,e)=>t.localeCompare(e)),n=Math.max(0,i.indexOf(e));return{angle:.82*-Math.PI+(i.length>1?n/(i.length-1):.5)*Math.PI*.64,index:n,radius:(48+n%2*6)*o}}function Zs(t,e,o){const i=t.activePositiveIds.reduce((t,o)=>t+(e.get(o)?.value??1),0),n=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(o.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*r-1.2*t.delay-5*n))}function Qs(t){const e=function(t,e,o){const[i,n]=t,r=220>i||160>n,s=Math.round(.48*n),a=r?n-Math.max(3,Math.min(12,.1*n)):n-36,c=(e??[]).filter(t=>!1!==t.enabled),l=Math.max(1,c.length),u=.22*i,d=l>1?(.78*i-u)/(l-1):0,h=r?Math.max(Math.round(.12*i),.08*i+6):Math.max(Math.round(.14*i),110);return{crashY:a-(r?Math.min(o,Math.max(3,.22*n)):o),floorY:a,gates:c.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(u+e*d),width:t.width??Math.max(r?8:54,Math.round(.07*i))})),graveyardX:Math.round(i*(r?.72:.84)),graveyardY:a-4,height:n,routeY:s,socketX:Math.round(i*(r?.82:.92)),startX:h,width:i}}(t.size??[900,520],t.gates,t.crashOffset??30),o=t.positiveProperties??[],i=new Map(o.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,o,i,n){const r=Ws(t,e,o.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=i.map(t=>t.id),a=[...Ws(t,e,o.positiveAccessor,s)],c=[...Ws(t,e,o.negativeAccessor,[])].filter(t=>n.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Ws(t,e,o.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Ws(t,e,o.startTimeAccessor,0))||0),stage:"project filed",viability:Ws(t,e,o.initialViability,100)}}(e,s,r,o,n);return{...a,viability:t.viability?.(a,{negativeProperties:n,positiveProperties:i})??Zs(a,i,n)}}),a=s.flatMap((o,r)=>{const s=function(t,e,o,i){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}}(o),r=i?.(t,e,o)??{};return{...n,...r,startY:r.startY??r.routeY??n.startY,socketY:r.socketY??r.routeY??n.socketY,graveyardY:r.graveyardY??n.graveyardY}}(o,r,e,t.projectPlacement);return function(t,e,o,i,n,r,s){const a=Hs(o),c=Math.max(3,28*a),l=i.startX,u=i.startY+(i.startY===o.routeY?38*e*a:0),d=s?.(t,e,o,i)??{},h=d.x??l,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},y=[{...d,id:Ys(t.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??t.startedAt,datum:p}],g=Us(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,o);y[0].x=g.x,y[0].y=g.y;for(const e of t.activePositiveIds){const i=n.get(e);if(!i)continue;const r=Ks(t.activePositiveIds,e,a),s=i.radius??Math.max(2,10*a),c=Us(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,o);y.push({id:qs(t.id,e),x:c.x,y:c.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:i,sourceDatum:t.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:Ys(t.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+r.index%2*4)*a),...i.spring??{}}]})}return t.negativeIds.forEach((e,i)=>{const n=r.get(e);n&&y.push(function(t,e,o,i,n,r,s){const a=Hs(r),c=e.radius??Math.max(2,7.2*a),l=Us(i+(o%4*12-12)*a,n+(54+12*Math.floor(o/4))*a,c,r);return{id:Xs(t.id,e.id,o),x:l.x,y:l.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:Ys(t.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+o%4*3)*a),...e.spring??{}}]}}(t,n,i,g.x,g.y,o,d.spawnAt??t.startedAt))}),y}(o,r,e,s,i,n,t.coreBody)});return{layout:e,states:s,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:Bs(e)}}}function Js(t=[]){const e=Object.create(null);for(const[o,i]of t)e[o]=i;return e}function ta(...t){const e=Js();for(const o of t)for(const[t,i]of Object.entries(o??{}))e[t]=i;return e}function ea(t){return ta(t)}function oa(t){return t.map(t=>({...t,sourceIds:t.sourceIds?[...t.sourceIds]:void 0,productIds:t.productIds?[...t.productIds]:void 0,relationIds:t.relationIds?[...t.relationIds]:void 0,outletIds:t.outletIds?[...t.outletIds]:void 0}))}function ia(t){const e=Js(Object.entries(t.components).map(([t,e])=>[t,{...e,initialMetrics:ea(e.initialMetrics),metrics:ea(e.metrics),productIds:[...e.productIds],history:oa(e.history)}])),o=Js(Object.entries(t.products).map(([t,e])=>[t,{...e,metrics:ea(e.metrics),sourceIds:[...e.sourceIds],history:oa(e.history)}])),i=Js(Object.entries(t.relations).map(([t,e])=>[t,{...e,sourceIds:[...e.sourceIds],metrics:e.metrics?ea(e.metrics):void 0}]));return{...t,eventsApplied:[...t.eventsApplied],components:e,products:o,relations:i,input:{amount:t.input.amount,metrics:ea(t.input.metrics)},metrics:ea(t.metrics),loss:{amount:t.loss.amount,metrics:ea(t.loss.metrics)},history:oa(t.history)}}var na=1e-9;function ra(t,e){return e>t?-1:t>e?1:0}function sa(t,e,o,i,n){return{severity:t,code:e,message:o,path:i,ids:n?[...n]:void 0}}function aa(t){const e=new Set,o=new Set;for(const i of t)e.has(i)&&o.add(i),e.add(i);return[...o].sort(ra)}function ca(t,e){return t?Object.entries(t).flatMap(([t,o])=>Number.isFinite(o)?[]:[sa("error","invalid-metric",`Metric "${t}" must be a finite number.`,`${e}.${t}`)]):[]}function la(t,e){for(const[o,i]of Object.entries(e))t[o]=Number(t[o]??0)+i}function ua(t,e,o="selector"){const i=[],n=Object.values(t.components),r=new Set(n.map(t=>t.id)),s=(e.ids??[]).filter(t=>!r.has(t));if(s.length&&i.push(sa("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,o+".ids",s)),void 0===e.count||Number.isInteger(e.count)&&e.count>=0||i.push(sa("error","invalid-selector-count","Selector count must be a non-negative integer.",o+".count")),i.some(t=>"error"===t.severity))return{ids:[],diagnostics:i};const a=e.ids?new Set(e.ids):null,c=e.categories?new Set(e.categories):null,l=e.statuses?new Set(e.statuses):null,u=e.outletIds?new Set(e.outletIds):null;let d=n.filter(t=>!a||a.has(t.id)).filter(t=>!c||c.has(t.category)).filter(t=>!l||l.has(t.status)).filter(t=>!u||void 0!==t.outletId&&u.has(t.outletId)).map(t=>t.id).sort(ra);return void 0!==e.count&&(d=d.slice(0,e.count)),d.length||i.push(sa("warning","empty-selector","Selector matched no source components.",o)),{ids:d,diagnostics:i}}function da(t,e,o={}){return{eventId:t.event.id,effectType:e.type,phaseId:t.context.phaseId,authoredAt:t.context.authoredAt,appliedAt:t.context.appliedAt,label:t.event.label,summary:t.event.summary,...o}}function ha(t,e){const o={...e,eventId:t.event.id};t.materializations.push(o),t.observations.push({...o,phaseId:t.context.phaseId,authoredAt:t.context.authoredAt,appliedAt:t.context.appliedAt})}function fa(t,e,o){return!(void 0!==e&&!t.outletIds.has(e)&&(t.diagnostics.push(sa("error","unknown-outlet",`Unknown outlet "${e}".`,o,[e])),1))}function pa(t,e,o){const i=aa(e);e.length||t.diagnostics.push(sa("error","empty-source-list","A product requires at least one source component.",o)),i.length&&t.diagnostics.push(sa("error","duplicate-source",`Source ids may appear only once: ${i.join(", ")}.`,o,i));const n=e.filter(e=>!t.state.components[e]);n.length&&t.diagnostics.push(sa("error","unknown-component",`Unknown source component id${1===n.length?"":"s"}: ${n.join(", ")}.`,o,n));const r=e.filter(e=>(t.state.components[e]?.productIds.length??0)>0);r.length&&t.diagnostics.push(sa("error","source-already-assigned",`Source component${1===r.length?" is":"s are"} already assigned: ${r.join(", ")}.`,o,r));const s=e.filter(e=>"consumed"===t.state.components[e]?.status&&!r.includes(e));return s.length&&t.diagnostics.push(sa("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,o,s)),t.diagnostics.some(t=>"error"===t.severity)?null:e.map(e=>t.state.components[e])}function ya(t,e,o,i,n){const r=i?.amount??0;(!Number.isFinite(r)||0>r||r>e+na)&&t.diagnostics.push(sa("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",n+".amount")),t.diagnostics.push(...ca(i?.metrics,n+".metrics"));for(const[e,r]of Object.entries(i?.metrics??{}))(0>r||r>Number(o[e]??0)+na)&&t.diagnostics.push(sa("error","invalid-metric-loss",`Metric loss "${e}" must be non-negative and no greater than its sources.`,`${n}.metrics.${e}`));return!t.diagnostics.some(t=>"error"===t.severity)}function ga(t,e,o,i,n,r,s){return{id:t.id,label:t.label??t.id,description:t.description,category:t.category??"product",color:t.color,order:t.order,declaredAmount:t.amount,amount:r&&void 0!==t.amount?t.amount:o,metrics:r&&t.metrics?ta(i,t.metrics):ea(i),status:r?"complete":"forming",sourceIds:[...e],outletId:r?t.outletId??(n.outletIds.has("product")?"product":void 0):void 0,createdByEventId:n.event.id,createdAt:n.context.appliedAt,completedByEventId:r?n.event.id:void 0,completedAt:r?n.context.appliedAt:void 0,history:[s]}}function ma(t,e,o,i){void 0!==e.amount&&Math.abs(e.amount-o)>na&&t.diagnostics.push(sa("warning","declared-product-amount-mismatch",`Product "${e.id}" declares ${e.amount}, while its sources yield ${o}.`,i,[e.id]))}function xa(t,e,o){const i=`events.${t.event.id}.effects.${o}`,n=t.state;if("set-state"===e.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(e.state)||t.diagnostics.push(sa("error","invalid-component-state",`set-state cannot assign "${e.state+""}".`,i+".state")),t.diagnostics.push(...ca(e.metricsDelta,i+".metricsDelta")),fa(t,e.outletId,i+".outletId");const o=ua(n,e.select,i+".select");t.diagnostics.push(...o.diagnostics);const r=o.ids.filter(t=>n.components[t].productIds.length);if(r.length&&t.diagnostics.push(sa("error","source-already-assigned",`Assigned source components cannot be retargeted: ${r.join(", ")}.`,i+".select",r)),t.diagnostics.some(t=>"error"===t.severity))return;const s=da(t,e,{sourceIds:o.ids,outletIds:e.outletId?[e.outletId]:void 0});for(const t of o.ids){const o=n.components[t];o.status=e.state,o.outletId=e.outletId,o.reason=e.reason,e.metricsDelta&&la(o.metrics,e.metricsDelta),o.history.push(s)}return n.history.push(s),void(o.ids.length&&ha(t,{type:"retarget-component",sourceIds:o.ids,outletIds:e.outletId?[e.outletId]:void 0}))}if("set-relation"===e.type){const{relation:o}=e;o.id&&!n.relations[o.id]||t.diagnostics.push(sa("error","duplicate-relation",`Relation id "${o.id}" is missing or already active.`,i+".relation.id",[o.id]));const r=function(t,e,o){const i=aa(e),n=e.filter(e=>!t.state.components[e]);return 2>e.length&&t.diagnostics.push(sa("error","insufficient-relation-sources","A relation requires at least two source components.",o)),i.length&&t.diagnostics.push(sa("error","duplicate-source",`Relation source ids must be unique: ${i.join(", ")}.`,o,i)),n.length&&t.diagnostics.push(sa("error","unknown-component",`Relation references unknown source component${1===n.length?"":"s"}: ${n.join(", ")}.`,o,n)),t.diagnostics.some(t=>"error"===t.severity)?null:e.map(e=>t.state.components[e])}(t,o.sourceIds,i+".relation.sourceIds");if(t.diagnostics.push(...ca(o.metrics,i+".relation.metrics")),!r||t.diagnostics.some(t=>"error"===t.severity))return;n.relations[o.id]={...o,sourceIds:[...o.sourceIds],metrics:o.metrics?ea(o.metrics):void 0,status:"active",createdByEventId:t.event.id,createdAt:t.context.appliedAt};const s=da(t,e,{sourceIds:[...o.sourceIds],relationIds:[o.id]});return n.history.push(s),void ha(t,{type:"activate-relation",sourceIds:[...o.sourceIds],relationIds:[o.id]})}if("resolve-relation"===e.type){const o=aa(e.relationIds),r=e.relationIds.filter(t=>!n.relations[t]),s=e.relationIds.filter(t=>"resolved"===n.relations[t]?.status);if(o.length&&t.diagnostics.push(sa("error","duplicate-relation","Relation ids must be unique.",i+".relationIds",o)),r.length&&t.diagnostics.push(sa("error","unknown-relation",`Unknown relation: ${r.join(", ")}.`,i+".relationIds",r)),s.length&&t.diagnostics.push(sa("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,i+".relationIds",s)),t.diagnostics.some(t=>"error"===t.severity))return;for(const o of e.relationIds){const i=n.relations[o];i.status="resolved",i.resolution=e.resolution,i.resolvedByEventId=t.event.id,i.resolvedAt=t.context.appliedAt,i.reason=e.reason}const a=da(t,e,{relationIds:[...e.relationIds]});return n.history.push(a),void ha(t,{type:"resolve-relation",relationIds:[...e.relationIds]})}if("combine"===e.type||"contribute"===e.type){const o=t.productDefinitions.get(e.productId);o||t.diagnostics.push(sa("error","unknown-product",`Product "${e.productId}" has no declared mold.`,i+".productId",[e.productId]));const r=n.products[e.productId];"combine"===e.type&&r&&t.diagnostics.push(sa("error","duplicate-product",`Product "${e.productId}" has already been formed.`,i+".productId",[e.productId])),"contribute"!==e.type||r&&"forming"===r.status||t.diagnostics.push(sa("error","product-not-forming",`Contributions require an existing forming product "${e.productId}".`,i+".productId",[e.productId]));const s=pa(t,e.sourceIds,i+".sourceIds"),a="contribute"===e.type&&r?[...r.sourceIds,...e.sourceIds]:e.sourceIds,c=function(t,e,o,i){if(!e?.length)return[];const n=aa(e),r=e.filter(e=>!t.state.relations[e]),s=e.filter(e=>"resolved"===t.state.relations[e]?.status),a=new Set(o),c=e.filter(e=>(t.state.relations[e]?.sourceIds??[]).some(t=>!a.has(t)));return n.length&&t.diagnostics.push(sa("error","duplicate-relation","Basis relations must be unique.",i,n)),r.length&&t.diagnostics.push(sa("error","unknown-relation",`Unknown basis relation: ${r.join(", ")}.`,i,r)),s.length&&t.diagnostics.push(sa("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,i,s)),c.length&&t.diagnostics.push(sa("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,i,c)),t.diagnostics.some(t=>"error"===t.severity)?null:e.map(e=>t.state.relations[e])}(t,e.basisRelationIds,a,i+".basisRelationIds");if(!s||!c||!o||t.diagnostics.some(t=>"error"===t.severity))return;const l=s.reduce((t,e)=>t+e.amount,0),u=function(t){const e=Js();for(const o of t)la(e,o.metrics);return e}(s);if(!ya(t,l,u,e.loss,i+".loss"))return;const d=l-(e.loss?.amount??0);!function(t,e,o){t.state.loss.amount+=o?.amount??0;for(const[i,n]of Object.entries(o?.metrics??{}))e[i]=Number(e[i]??0)-n,t.state.loss.metrics[i]=Number(t.state.loss.metrics[i]??0)+n}(t,u,e.loss);const h="combine"===e.type&&!1!==e.complete,f=da(t,e,{sourceIds:[...e.sourceIds],productIds:[e.productId],relationIds:e.basisRelationIds?[...e.basisRelationIds]:void 0});let p;if("combine"===e.type){if(h&&ma(t,o,d,i+".productId"),p=ga(o,e.sourceIds,d,u,t,h,f),h&&!fa(t,p.outletId,i+".productId"))return;n.products[e.productId]=p}else p=r,p.sourceIds.push(...e.sourceIds),p.amount+=d,la(p.metrics,u),p.history.push(f);for(const t of s)t.productIds=[e.productId],t.status="consumed",t.outletId=void 0,t.history.push(f);return n.history.push(f),function(t,e){if(e.length){for(const o of e)o.status="resolved",o.resolution="combined",o.resolvedByEventId=t.event.id,o.resolvedAt=t.context.appliedAt;ha(t,{type:"resolve-relation",relationIds:e.map(t=>t.id)})}}(t,c),ha(t,{type:"combine"===e.type?"form-product":"update-product",sourceIds:[...e.sourceIds],productIds:[e.productId],relationIds:e.basisRelationIds?[...e.basisRelationIds]:void 0,outletIds:p.outletId?[p.outletId]:void 0}),void(h&&ha(t,{type:"complete-product",sourceIds:[...p.sourceIds],productIds:[p.id],outletIds:p.outletId?[p.outletId]:void 0}))}if("complete-product"===e.type){const o=n.products[e.productId];return o?void function(t,e,o,i,n,r){const s=t.productDefinitions.get(e.id),a=o??s?.outletId??(t.outletIds.has("product")?"product":void 0);if(!fa(t,a,r+".outletId"))return;if("complete"===e.status)return void t.diagnostics.push(sa("error","product-already-complete",`Product "${e.id}" is already complete.`,r,[e.id]));s&&(ma(t,s,e.amount,r+".productId"),void 0!==s.amount&&(e.amount=s.amount),s.metrics&&(e.metrics=ta(e.metrics,s.metrics))),e.status="complete",e.outletId=a,e.reason=i,e.completedByEventId=t.event.id,e.completedAt=t.context.appliedAt;const c=da(t,n,{sourceIds:[...e.sourceIds],productIds:[e.id],outletIds:a?[a]:void 0});e.history.push(c),t.state.history.push(c),ha(t,{type:"complete-product",sourceIds:[...e.sourceIds],productIds:[e.id],outletIds:a?[a]:void 0})}(t,o,e.outletId,e.reason,e,i):void t.diagnostics.push(sa("error","unknown-product-state",`Product "${e.productId}" has not been formed.`,i+".productId",[e.productId]))}if("split"===e.type){const o=pa(t,[e.sourceId],i+".sourceId");e.products.length||t.diagnostics.push(sa("error","empty-split","A split requires at least one product allocation.",i+".products"));const r=e.products.map(t=>t.productId),s=aa(r);s.length&&t.diagnostics.push(sa("error","duplicate-product","Split product ids must be unique.",i+".products",s));const a=r.map(e=>t.productDefinitions.get(e)),c=r.filter((t,e)=>!a[e]),l=r.filter(t=>n.products[t]);c.length&&t.diagnostics.push(sa("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,i+".products",c)),l.length&&t.diagnostics.push(sa("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,i+".products",l));for(const[o,n]of e.products.entries())void 0===n.amount||Number.isFinite(n.amount)&&n.amount>=0||t.diagnostics.push(sa("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${i}.products.${o}.amount`)),t.diagnostics.push(...ca(n.metrics,`${i}.products.${o}.metrics`));if(!o?.length||t.diagnostics.some(t=>"error"===t.severity))return;const u=o[0];if(!ya(t,u.amount,u.metrics,e.loss,i+".loss"))return;const d=u.amount-(e.loss?.amount??0),h=e.products.map((t,e)=>t.amount??a[e]?.amount),f=h.filter(t=>void 0!==t).length;if(0!==f&&f!==h.length)return void t.diagnostics.push(sa("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",i+".products"));const p=f?h:e.products.map(()=>d/e.products.length),y=p.reduce((t,e)=>t+e,0);if(Math.abs(y-d)>na)return void t.diagnostics.push(sa("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,i+".products"));const g=ea(u.metrics);for(const[t,o]of Object.entries(e.loss?.metrics??{}))g[t]=Number(g[t]??0)-o;const m=da(t,e,{sourceIds:[u.id],productIds:r});if(e.products.forEach((o,r)=>{const s=a[r],c=d>na?p[r]/d:1/e.products.length,l=Js(Object.entries(g).map(([t,e])=>[t,e*c])),h=o.metrics??s.metrics??l,f=ga({...s,amount:p[r],metrics:h},[u.id],p[r],ea(h),t,!0,m);fa(t,f.outletId,`${i}.products.${r}.productId`)&&(n.products[f.id]=f)}),t.diagnostics.some(t=>"error"===t.severity))return;u.productIds=r,u.status="consumed",u.outletId=void 0,u.history.push(m),n.loss.amount+=e.loss?.amount??0;for(const[t,o]of Object.entries(e.loss?.metrics??{}))n.loss.metrics[t]=Number(n.loss.metrics[t]??0)+o;n.history.push(m),ha(t,{type:"split-source",sourceIds:[u.id],productIds:r});for(const e of r)ha(t,{type:"complete-product",sourceIds:[u.id],productIds:[e],outletIds:n.products[e].outletId?[n.products[e].outletId]:void 0});return}if("eject"===e.type){fa(t,e.outletId,i+".outletId");const o=ua(n,e.select,i+".select");t.diagnostics.push(...o.diagnostics);const r=o.ids.filter(t=>n.components[t].productIds.length);if(r.length&&t.diagnostics.push(sa("error","source-already-assigned",`Assigned source components cannot be ejected: ${r.join(", ")}.`,i+".select",r)),t.diagnostics.some(t=>"error"===t.severity))return;const s=da(t,e,{sourceIds:o.ids,outletIds:[e.outletId]});for(const t of o.ids){const o=n.components[t];o.status=e.state??"ejected",o.outletId=e.outletId,o.reason=e.reason,o.history.push(s)}return n.history.push(s),void(o.ids.length&&ha(t,{type:"retarget-component",sourceIds:o.ids,outletIds:[e.outletId]}))}if("set-metric"===e.type){if(t.diagnostics.push(...ca(e.metricsDelta,i+".metricsDelta")),t.diagnostics.some(t=>"error"===t.severity))return;let o,r;if("run"===e.target)la(n.metrics,e.metricsDelta);else if("components"in e.target){const r=ua(n,e.target.components,i+".target.components");if(t.diagnostics.push(...r.diagnostics),t.diagnostics.some(t=>"error"===t.severity))return;o=r.ids;for(const t of r.ids)la(n.components[t].metrics,e.metricsDelta)}else{r=[...e.target.productIds];const o=aa(r),s=r.filter(t=>!n.products[t]);if(o.length&&t.diagnostics.push(sa("error","duplicate-product","Metric target product ids must be unique.",i+".target.productIds",o)),s.length&&t.diagnostics.push(sa("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,i+".target.productIds",s)),t.diagnostics.some(t=>"error"===t.severity))return;for(const t of r)la(n.products[t].metrics,e.metricsDelta)}return void n.history.push(da(t,e,{sourceIds:o,productIds:r}))}e.outcome.trim()?(n.outcome=e.outcome,n.summary=e.summary,n.history.push(da(t,e)),t.observations.push({type:"crucible-outcome",eventId:t.event.id,phaseId:t.context.phaseId,authoredAt:t.context.authoredAt,appliedAt:t.context.appliedAt,outcome:e.outcome})):t.diagnostics.push(sa("error","invalid-outcome","Outcome must be a non-empty string.",i+".outcome"))}function ba(t,e,o){if(t.eventsApplied.includes(e.id))return{applied:!1,state:t,materializations:[],observations:[],diagnostics:[sa("warning","duplicate-event-application",`Event "${e.id}" has already been applied.`,"events."+e.id,[e.id])]};const i=ia(t),n={state:i,event:e,context:o,productDefinitions:new Map(o.products.map(t=>[t.id,t])),outletIds:new Set(o.outlets.map(t=>t.id)),diagnostics:[],materializations:[],observations:[]};for(const[o,i]of e.effects.entries())if(xa(n,i,o),n.diagnostics.some(t=>"error"===t.severity))return{applied:!1,state:t,materializations:[],observations:[],diagnostics:n.diagnostics};return i.elapsed=Math.max(i.elapsed,o.appliedAt),i.phaseId=o.phaseId,i.eventsApplied.push(e.id),n.observations.unshift({type:"crucible-event",eventId:e.id,phaseId:o.phaseId,authoredAt:o.authoredAt,appliedAt:o.appliedAt}),{applied:!0,state:i,materializations:n.materializations,observations:n.observations,diagnostics:n.diagnostics}}var va=[900,520],wa=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],ka=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Sa=1e-9;function Aa(t,e){return e>t?-1:t>e?1:0}function Ma(t,e,o,i,n){return{severity:t,code:e,message:o,path:i,ids:n?[...n]:void 0}}function _a(t){const e=new Set,o=new Set;for(const i of t)e.has(i)&&o.add(i),e.add(i);return[...o].sort(Aa)}function Pa(t){const e="number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function ja(t,e,o,i,n,r){if(!o)return i;try{return("function"==typeof o?o(t,e):t[o])??i}catch(t){return n.push(Ma("error","accessor-error",`Accessor threw: ${t instanceof Error?t.message:t+""}.`,r)),i}}function La(t,e,o){if(!t||"object"!=typeof t||Array.isArray(t))return null!=t&&e.push(Ma("error","invalid-metrics","Metrics must be a numeric object.",o)),Js();const i=Js();for(const[n,r]of Object.entries(t)){const t=Pa(r);null!=t?i[n]=t:e.push(Ma("error","invalid-metric",`Metric "${n}" must be finite.`,`${o}.${n}`))}return i}function $a(t){return t.map((t,e)=>({outlet:t,index:e})).sort((t,e)=>(t.outlet.order??t.index)-(e.outlet.order??e.index)||t.index-e.index).map(({outlet:t})=>({...t}))}function Ra(t){const{id:e,orientation:o,fixed:i,start:n,end:r,openings:s,thickness:a,friction:c,restitution:l}=t,u=function(t,e,o){const i=o.map(([o,i])=>[Math.max(t,Math.min(o,i)),Math.min(e,Math.max(o,i))]).filter(([t,e])=>e>t+Sa).sort((t,e)=>t[0]-e[0]||t[1]-e[1]),n=[];let r=t;for(const[t,e]of i)t>r+Sa&&n.push([r,t]),r=Math.max(r,e);return e>r+Sa&&n.push([r,e]),n}(n,r,s);return u.map(([t,n],r)=>({id:1===u.length?e:`${e}:${r}`,friction:c,restitution:l,shape:"horizontal"===o?{type:"segment",x1:t,y1:i,x2:n,y2:i,thickness:a}:{type:"segment",x1:i,y1:t,x2:i,y2:n,thickness:a}}))}function Ca(t){let e=2166136261;for(let o=0;t.length>o;o+=1)e^=t.charCodeAt(o),e=Math.imul(e,16777619);return e>>>0}function Ia(t){return"number"==typeof t&&Number.isFinite(t)?t>>>0:"string"==typeof t?Ca(t):1}function Ta(t,e){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:e.map(t=>({...t,shape:{...t.shape}})),observation:{chartType:"crucible"},kernel:{seed:Ia(t),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function Oa(t){return"crucible:component:"+encodeURIComponent(t)}function za(t,e,o,i){if(void 0!==o&&Number.isFinite(o)&&o>0)return o;const n=Math.min(...e,t),r=Math.max(...e,t);return r-n>Sa?i[0]+(i[1]-i[0])*Math.sqrt(Math.max(0,t-n)/(r-n)):(i[0]+i[1])/2}function Fa(t,e){const o=Math.max(.25,Math.min(1,e.width/900,e.height/520)),i=t?.[0]??7*o,n=t?.[1]??18*o,r=Math.max(1,Math.min(i,n));return[r,Math.max(r,Math.max(i,n))]}function Na(t,e){if(!t)return[];const o=Math.min(t,Math.max(1,Math.ceil(Math.sqrt(t*Math.max(.5,e.width/Math.max(1,e.height)))))),i=Math.max(1,Math.ceil(t/o));return Array.from({length:t},(t,n)=>({x:e.x+e.width/o*(n%o+.5),y:e.y+(Math.floor(n/o)+.5)*(e.height/i)}))}function Ea(t){return t.outletId?t.outletId:"failed"===t.status?"failed":"recovered"===t.status?"recovered":"retained"===t.status?"retained":"ejected"===t.status?"residue":void 0}function Da(t,e){return t.outlets.find(t=>t.id===e)||{x:t.chamber.x+.18*t.chamber.width,y:t.chamber.y+.2*t.chamber.height,width:.64*t.chamber.width,height:.6*t.chamber.height}}function Ba(t,e,o={}){const i=Object.values(t.products).sort((t,e)=>Aa(t.id,e.id)),n=Object.values(t.components).sort((t,e)=>Aa(t.id,e.id)),r=[...n.map(t=>t.amount),...i.map(t=>t.amount)],s=Fa(o.radiusRange,e),a=function(t,e){const o=new Map;for(const e of t){const t=e.outletId??"__chamber__",i=o.get(t)??[];i.push(e),o.set(t,i)}const i=new Map;for(const[t,n]of o){n.sort((t,e)=>(t.order??Number.MAX_SAFE_INTEGER)-(e.order??Number.MAX_SAFE_INTEGER)||Aa(t.id,e.id));const o=Na(n.length,Da(e,"__chamber__"===t?void 0:t));n.forEach((t,e)=>i.set(t.id,o[e]))}return i}(i,e),c=i.map(t=>{const i=a.get(t.id)??{x:e.chamber.x+e.chamber.width/2,y:e.chamber.y+e.chamber.height/2},n=1.28*za(t.amount,r,o.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:t.id,product:t};return{id:(l=t.id,"crucible:product:"+encodeURIComponent(l)),x:i.x,y:i.y,mass:Math.max(.25,n*n*.018),bodyCollisions:!1,shape:{type:"circle",radius:n},datum:c};var l}),l=new Map;for(const t of n.filter(t=>!t.productIds.length)){const e=Ea(t)??"__chamber__",o=l.get(e)??[];o.push(t),l.set(e,o)}const u=new Map;for(const[t,o]of l){const i=Na(o.length,Da(e,"__chamber__"===t?void 0:t));o.forEach((t,e)=>u.set(t.id,i[e]))}return[...n.map(t=>{let i=u.get(t.id);if(t.productIds.length){const o=t.productIds.map(t=>a.get(t)).filter(t=>!!t);if(o.length){i={x:o.reduce((t,e)=>t+e.x,0)/o.length,y:o.reduce((t,e)=>t+e.y,0)/o.length};const n=Ca(t.id)/4294967295*Math.PI*2,r=Math.min(20,Math.max(4,.012*e.width));i={x:i.x+Math.cos(n)*r,y:i.y+Math.sin(n)*r}}}i??(i={x:e.chamber.x+e.chamber.width/2,y:e.chamber.y+e.chamber.height/2});const n=za(t.amount,r,o.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:t.id,sourceDatum:t.datum};return{id:Oa(t.id),x:i.x,y:i.y,mass:Math.max(.25,n*n*.015),shape:{type:"circle",radius:n},datum:c}}),...c]}var Wa=Ba;function Ya(t){return Array.isArray(t)?t.map(Ya):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&"function"!=typeof t).sort(([t],[e])=>Aa(t,e)).map(([t,e])=>[t,Ya(e)])):t}function qa(t,e=t.duration){const o=function(t,e){const o=Pa(e)??0,i=Math.max(0,Math.min(t.duration,o));if(!t.phases.length)return{elapsed:i,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const n=i>=t.duration-Sa,r=n?t.phases[t.phases.length-1]:t.phases.find(t=>i>=t.start&&t.end>i)??t.phases[0];return{elapsed:i,phaseId:r.id,phaseIndex:r.index,phaseElapsed:n?r.duration:Math.max(0,i-r.start),complete:n}}(t,e);let i=ia(t.initialState);const n=[],r=[],s=[];for(const e of t.events){if(e.authoredAt>o.elapsed+Sa)break;const a=ba(i,e,{phaseId:e.phaseId,authoredAt:e.authoredAt,appliedAt:e.authoredAt,products:t.products,outlets:t.outlets});n.push(...a.diagnostics),r.push(...a.materializations),s.push(...a.observations),a.applied&&(i=a.state)}return i.elapsed=o.elapsed,i.phaseId=o.phaseId,i.phaseIndex=o.phaseIndex,i.phaseElapsed=o.phaseElapsed,i.complete=o.complete,o.complete&&"in_process"===i.outcome&&(i.outcome="complete"),i.playing=!1,{state:i,diagnostics:n,materializations:r,observations:s}}function Xa(t){const e=function(t){const e=[];t.length||e.push(Ma("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const o=_a(t.map(t=>t.id));o.length&&e.push(Ma("error","duplicate-phase-id",`Phase ids must be unique: ${o.join(", ")}.`,"phases",o));let i=0;return{phases:t.map((t,o)=>{const n=Pa(t.duration),r=null!=n&&n>0?n:0;t.id.trim()||e.push(Ma("error","invalid-phase-id","Phase ids may not be empty.",`phases.${o}.id`)),null!=n&&n>0||e.push(Ma("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${o}.duration`,[t.id])),void 0===t.intensity||Number.isFinite(t.intensity)||e.push(Ma("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${o}.intensity`,[t.id]));const s={...t,duration:r,intensity:void 0===t.intensity?.5:Number.isFinite(t.intensity)?Math.max(0,Math.min(1,t.intensity)):.5,motion:t.motion??"hold",index:o,start:i,end:i+r};return i=s.end,s}),diagnostics:e}}(t.phases),o=e.phases.at(-1)?.end??0,i=$a(t.outlets??wa),n=(t.products??[]).map(t=>({...t,metrics:t.metrics?ta(t.metrics):void 0})),r=function(t,e,o){const i=[],n=_a(t.map(t=>t.id));n.length&&i.push(Ma("error","duplicate-event-id",`Event ids must be unique: ${n.join(", ")}.`,"events",n));const r=[];return t.forEach((t,n)=>{let s,a,c;if(t.id.trim()||i.push(Ma("error","invalid-event-id","Event ids may not be empty.",`events.${n}.id`)),"time"in t.at&&void 0!==t.at.time){const r=Pa(t.at.time);if(null==r||0>r||r>o+Sa)return void i.push(Ma("error","event-time-out-of-range",`Event time must fall between 0 and ${o}.`,`events.${n}.at.time`,[t.id]));s=Math.max(0,Math.min(o,r));const l=function(t,e,o){const i=t.find(t=>Sa>=Math.abs(t.start-o));if(i)return{phase:i,boundaryRank:1};const n=t.find(t=>o>=t.start&&t.end>o);return n?{phase:n,boundaryRank:0}:Sa>=Math.abs(o-e)&&t.length?{phase:t[t.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(e,o,s);a=l.phase,c=l.boundaryRank}else{if(a=e.find(e=>e.id===t.at.phaseId),!a)return void i.push(Ma("error","unknown-event-phase",`Event references unknown phase "${t.at.phaseId}".`,`events.${n}.at.phaseId`,[t.id,t.at.phaseId]));const o=t.at.progress??0;if(!Number.isFinite(o)||0>o||o>1)return void i.push(Ma("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${n}.at.progress`,[t.id]));s=a.start+a.duration*o,c=0===o?1:0}a?r.push({...t,index:n,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):i.push(Ma("error","event-without-phase","Event could not be assigned to a phase.",`events.${n}.at`,[t.id]))}),r.sort((t,e)=>t.authoredAt-e.authoredAt||t.boundaryRank-e.boundaryRank||t.index-e.index),{events:r,diagnostics:i}}(t.events??[],e.phases,o),s=function(t){const e=[],o=Js(),i=[];let n=0;const r=Js();t.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((ja(s,a,t.idAccessor,c,e,`data.${a}.id`)??c)+"").trim();if(!l)return void e.push(Ma("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));i.push(l);const u=Pa(ja(s,a,t.amountAccessor,1,e,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&e.push(Ma("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=La(ja(s,a,t.metricsAccessor,{},e,`data.${a}.metrics`),e,`data.${a}.metrics`),f=ja(s,a,t.initialStateAccessor,"active",e,`data.${a}.status`),p=ka.has(f)?f:"active";ka.has(f)||e.push(Ma("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${a}.status`,[l]));const y=ja(s,a,t.labelAccessor,(s.label??s.name??l)+"",e,`data.${a}.label`)+"",g=ja(s,a,t.categoryAccessor,"component",e,`data.${a}.category`)+"";Object.hasOwn(o,l)||(o[l]={id:l,label:y,category:g,datum:s,status:p,initialAmount:d,amount:d,initialMetrics:ta(h),metrics:ta(h),productIds:[],history:[]},n+=d,function(t,e){for(const[o,i]of Object.entries(e))t[o]=Number(t[o]??0)+i}(r,h))});const s=_a(i);s.length&&e.push(Ma("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=La(t.metrics??{},e,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:t.phases[0]?.id??"",phaseIndex:t.phases.length?0:-1,playing:!1,complete:0===t.phases.length,outcome:"in_process",eventsApplied:[],components:o,products:Js(),relations:Js(),input:{amount:n,metrics:r},metrics:a,loss:{amount:0,metrics:Js()},history:[]},diagnostics:e}}(t),a=function(t=va,e=wa){const o=Math.max(1,Pa(t[0])??900),i=Math.max(1,Pa(t[1])??520),n=360>o||260>i,r=n?Math.max(4,.035*Math.min(o,i)):20,s=n?Math.max(10,.075*i):34,a={x:r,y:r,width:Math.max(1,o-2*r),height:s},c=n?Math.max(16,.14*i):Math.min(78,.16*i),l={x:r,y:i-r-c,width:Math.max(1,o-2*r),height:c},u=n?Math.max(12,.08*o):Math.min(150,.17*o),d=a.y+a.height+(n?12:38),h=l.y-(n?10:34),f={x:u,y:d,width:Math.max(24,o-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,n?84:180)),y={x:f.x+(f.width-p)/2,y:f.y-(n?10:24),width:p,height:n?12:28},g=$a(e),m={left:g.filter(t=>"left"===(t.side??"bottom")),right:g.filter(t=>"right"===t.side),bottom:g.filter(t=>"bottom"===(t.side??"bottom"))},x=[],b=(t,e)=>{const i=Math.max(8,u-1.5*r),s=f.height/Math.max(1,e.length);e.forEach((e,a)=>{x.push({...e,side:t,x:"left"===t?r:o-r-i,y:f.y+a*s,width:i,height:Math.max(8,s-(n?2:8))})})};b("left",m.left),b("right",m.right);const v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((t,e)=>{x.push({...t,side:"bottom",x:f.x+e*v,y:f.y+f.height+(n?2:7),width:Math.max(8,v-(n?2:8)),height:Math.max(8,l.y-f.y-f.height-(n?4:12))})}),x.sort((t,e)=>g.findIndex(e=>e.id===t.id)-g.findIndex(t=>t.id===e.id)),{width:o,height:i,phaseRail:a,chamber:f,mouth:y,projection:l,outlets:x}}(t.size??va,i),c=function(t){const{chamber:e,mouth:o}=t,i=Math.max(2,Math.min(10,.018*Math.min(t.width,t.height))),n=Math.max(e.x,o.x),r=Math.min(e.x+e.width,o.x+o.width),s={left:t.outlets.filter(t=>"left"===t.side),right:t.outlets.filter(t=>"right"===t.side),bottom:t.outlets.filter(t=>"bottom"===t.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:e.x,y1:e.y,x2:n,y2:e.y,thickness:i}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:r,y1:e.y,x2:e.x+e.width,y2:e.y,thickness:i}}];a.push(...Ra({id:"crucible:wall:left",orientation:"vertical",fixed:e.x,start:e.y,end:e.y+e.height,openings:s.left.map(t=>[t.y,t.y+t.height]),thickness:i,friction:.46,restitution:.12}),...Ra({id:"crucible:wall:right",orientation:"vertical",fixed:e.x+e.width,start:e.y,end:e.y+e.height,openings:s.right.map(t=>[t.y,t.y+t.height]),thickness:i,friction:.46,restitution:.12}),...Ra({id:"crucible:wall:bottom",orientation:"horizontal",fixed:e.y+e.height,start:e.x,end:e.x+e.width,openings:s.bottom.map(t=>[t.x,t.x+t.width]),thickness:i,friction:.5,restitution:.08}));for(const e of t.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(e.id),sensor:!0,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+e.height/2,width:e.width,height:e.height}});return a}(a),l=function(t,e){const o=[],i=new Set(e.map(t=>t.id)),n=_a(e.map(t=>t.id)),r=_a(t.map(t=>t.id));return n.length&&o.push(Ma("error","duplicate-outlet-id",`Outlet ids must be unique: ${n.join(", ")}.`,"outlets",n)),r.length&&o.push(Ma("error","duplicate-product-id",`Product ids must be unique: ${r.join(", ")}.`,"products",r)),e.forEach((t,e)=>{t.id.trim()||o.push(Ma("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${e}.id`)),void 0===t.order||Number.isFinite(t.order)||o.push(Ma("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${e}.order`,[t.id]))}),t.forEach((t,e)=>{t.id.trim()||o.push(Ma("error","invalid-product-id","Product ids may not be empty.",`products.${e}.id`)),void 0===t.amount||Number.isFinite(t.amount)&&t.amount>=0||o.push(Ma("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${e}.amount`,[t.id])),void 0===t.outletId||i.has(t.outletId)||o.push(Ma("error","unknown-outlet",`Product "${t.id}" references unknown outlet "${t.outletId}".`,`products.${e}.outletId`,[t.outletId])),La(t.metrics??{},o,`products.${e}.metrics`)}),o}(n,i),u=(d={seed:t.seed??1,components:Object.values(s.state.components).sort((t,e)=>Aa(t.id,e.id)).map(t=>({id:t.id,label:t.label,category:t.category,amount:t.amount,metrics:t.metrics,status:t.status})),phases:e.phases.map(({id:t,duration:e,label:o,description:i,intensity:n,motion:r,color:s,metrics:a})=>({id:t,duration:e,label:o,description:i,intensity:n,motion:r,color:s,metrics:a})),products:n,outlets:i,events:r.events.map(({id:t,label:e,description:o,summary:i,authoredAt:n,phaseId:r,boundaryRank:s,effects:a})=>({id:t,label:e,description:o,summary:i,authoredAt:n,phaseId:r,boundaryRank:s,effects:a}))},JSON.stringify(Ya(d)));var d;const h=function(t,e,o={}){const i=Object.values(t.components).sort((t,e)=>Aa(t.id,e.id)),n=i.map(t=>t.amount),r=Fa(o.radiusRange,e),s=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}}(Ia(o.seed)),a=e.mouth.x+e.mouth.width/2,c=e.chamber.y+Math.max(18,.18*e.chamber.height),l=Math.max(4,.28*e.chamber.width),u=Math.max(4,.12*e.chamber.height);return i.map((t,e)=>{const d=e/Math.max(1,i.length)*Math.PI*2+.18*(s()-.5),h=za(t.amount,n,o.bodyRadius,r),f={__crucible:!0,kind:"component",semanticId:t.id,sourceDatum:t.datum};return{id:Oa(t.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}(s.state,a,{seed:t.seed,bodyRadius:t.bodyRadius,radiusRange:t.radiusRange}),f=[...e.diagnostics,...r.diagnostics,...s.diagnostics,...l],p={phases:e.phases,events:r.events,products:n,outlets:i,duration:o,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:Ta(t.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:f},y=qa(p),g=Object.values(y.state.products).filter(t=>"forming"===t.status).map(t=>t.id),m=g.length?[Ma("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return p.terminalState=y.state,p.terminalSpawns=Wa(y.state,a,{seed:t.seed,bodyRadius:t.bodyRadius,radiusRange:t.radiusRange}),p.diagnostics=[...f,...y.diagnostics,...m],p}var Ga=c(require("react")),Va=require("d3-shape");function Ha(t){switch(t){case"monotoneX":return Va.curveMonotoneX;case"monotoneY":return Va.curveMonotoneY;case"cardinal":return Va.curveCardinal;case"catmullRom":return Va.curveCatmullRom;case"step":return Va.curveStep;case"stepBefore":return Va.curveStepBefore;case"stepAfter":return Va.curveStepAfter;case"basis":return Va.curveBasis;case"natural":return Va.curveNatural;default:return null}}var Ua=require("react/jsx-runtime");function Ka(t){return Number.isFinite(t)?1e3>Math.abs(t)?Number.isInteger(t)?t+"":t.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):t.toLocaleString():"0"}function Za(t,e,o,i){const n=t.datum;if(!n?.__crucible)return;const r="circle"===t.shape.type?t.shape.radius:8,s="string"==typeof e.fill?e.fill:"product"===n.kind?"#b8792d":"#356b63",a="string"==typeof e.stroke?e.stroke:"#26323a",c="number"==typeof e.strokeWidth?e.strokeWidth:1.25,l="number"==typeof e.opacity?e.opacity:.96,u=i?`${i}-crucible-body-${o}`:"crucible-body-"+o;if("product"===n.kind){const e=Array.from({length:6},(e,o)=>{const i=-Math.PI/2+o/6*Math.PI*2;return`${t.x+Math.cos(i)*r},${t.y+Math.sin(i)*r}`}).join(" "),o=u+"-glow";return(0,Ua.jsxs)(Ga.Fragment,{children:[(0,Ua.jsx)("defs",{children:(0,Ua.jsx)("filter",{id:o,x:"-60%",y:"-60%",width:"220%",height:"220%",children:(0,Ua.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:s,floodOpacity:"0.8"})})}),(0,Ua.jsx)("polygon",{points:e,fill:s,stroke:a,strokeWidth:c,opacity:l,filter:`url(#${o})`}),(0,Ua.jsx)("circle",{cx:t.x,cy:t.y,r:Math.max(2,.36*r),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:c,opacity:.72*l})]},u)}return(0,Ua.jsxs)(Ga.Fragment,{children:[(0,Ua.jsx)("circle",{cx:t.x,cy:t.y,r:r,fill:s,stroke:a,strokeWidth:c,opacity:l}),(0,Ua.jsx)("circle",{cx:t.x-.25*r,cy:t.y-.28*r,r:Math.max(1,.18*r),fill:"rgba(255,255,255,0.34)"})]},u)}var Qa=require("react/jsx-runtime"),Ja="var(--semiotic-text, #26323a)",tc="var(--semiotic-text-secondary, #6c7377)",ec="var(--semiotic-primary, #b8792d)",oc="var(--semiotic-danger, #9f3d35)",ic="var(--semiotic-success, #356b63)";function nc(t){const{x:e,y:o,width:i,height:n}=t.chamber,r=Math.min(.14*i,48),s=o+n;return[`M ${e} ${o}`,`L ${e+r} ${s-.16*n}`,`Q ${e+i/2} ${s+.1*n} ${e+i-r} ${s-.16*n}`,`L ${e+i} ${o}`].join(" ")}function rc({layout:t,phases:e,state:o,compact:i=!1}){const n=Math.max(1,e.reduce((t,e)=>t+Math.max(0,e.duration),0));return(0,Qa.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[(0,Qa.jsxs)("defs",{children:[(0,Qa.jsxs)("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Qa.jsx)("stop",{offset:"0",stopColor:ec,stopOpacity:"0.03"}),(0,Qa.jsx)("stop",{offset:"0.66",stopColor:ec,stopOpacity:"0.1"}),(0,Qa.jsx)("stop",{offset:"1",stopColor:oc,stopOpacity:"0.18"})]}),(0,Qa.jsx)("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:(0,Qa.jsx)("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:Ja,strokeOpacity:"0.08",strokeWidth:"1"})})]}),(0,Qa.jsx)("rect",{x:t.chamber.x,y:t.chamber.y,width:t.chamber.width,height:t.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:Ja,strokeOpacity:"0.52",strokeWidth:i?1:2.2}),(0,Qa.jsx)("path",{d:nc(t),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),(0,Qa.jsx)("line",{x1:t.mouth.x,x2:t.mouth.x+t.mouth.width,y1:t.mouth.y,y2:t.mouth.y,stroke:Ja,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:i?2:5}),i?null:(0,Qa.jsx)("g",{"data-testid":"crucible-phase-rail",children:e.map((i,r)=>{const s=e.slice(0,r).reduce((t,e)=>t+Math.max(0,e.duration),0),a=t.phaseRail.x+s/n*t.phaseRail.width,c=Math.max(0,i.duration)/n*t.phaseRail.width,l=i.id===o.phaseId,u=o.phaseIndex>r||o.complete;return(0,Qa.jsxs)("g",{children:[(0,Qa.jsx)("rect",{x:a,y:t.phaseRail.y,width:Math.max(1,c-2),height:t.phaseRail.height,rx:2,fill:l?i.color??ec:u?ic:Ja,fillOpacity:l?.68:u?.28:.09}),46>c?null:(0,Qa.jsx)("text",{x:a+c/2,y:t.phaseRail.y+t.phaseRail.height+13,fill:l?Ja:tc,fontFamily:"system-ui, sans-serif",fontSize:8.5,fontWeight:l?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(i.label??i.id).toUpperCase()})]},i.id)})}),t.outlets.map(t=>(0,Qa.jsxs)("g",{children:[(0,Qa.jsx)("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:3,fill:t.color??("left"===t.side?oc:ic),fillOpacity:"0.1",stroke:t.color??("left"===t.side?oc:ic),strokeDasharray:"3 3",strokeOpacity:"0.62"}),i?null:(0,Qa.jsx)("text",{x:t.x+t.width/2,y:t.y+Math.min(13,t.height/2+3),fill:tc,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(t.label??t.id).toUpperCase()})]},t.id))]})}function sc({rows:t,layout:e,projection:o,amountLabel:i}){if(!t.length)return null;const n=o.measure??"count",r=t.map(t=>Math.max(0,function(t,e){return"count"===e?t.count:"amount"===e?t.amount:Number(t.metrics[e]??0)}(t,n))),s=Math.max(1,...r),a=e.projection.width/Math.max(1,t.length),c=e.projection.height>48?21:4,l=Math.max(5,e.projection.height-c-5);return(0,Qa.jsx)("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:t.map((t,o)=>{const u=r[o],d=Math.max(u>0?2:0,u/s*l),h=e.projection.x+o*a+.18*a;return(0,Qa.jsxs)("g",{children:[(0,Qa.jsx)("rect",{x:h,y:e.projection.y+l-d,width:Math.max(3,.64*a),height:d,rx:2,fill:"failed"===t.status||"ejected"===t.status?oc:"complete"===t.status?ec:ic,fillOpacity:"0.68"}),c>4&&a>=34?(0,Qa.jsxs)(Qa.Fragment,{children:[(0,Qa.jsx)("text",{x:h+.32*a,y:e.projection.y+l+10,fill:tc,fontFamily:"system-ui, sans-serif",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:t.label.length>13?t.label.slice(0,12)+"…":t.label}),(0,Qa.jsxs)("text",{x:h+.32*a,y:e.projection.y+l+19,fill:Ja,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:850,textAnchor:"middle",children:[Ka(u),"amount"===n&&i?" "+i:""]})]}):null]},t.key)})})}function ac(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}var cc=require("react/jsx-runtime");function lc(t,e,o,i,n){const r=Array.isArray(n)?n:n?[n]:[];if(!1!==o||0!==r.length)return({size:n})=>{const s=[Number(n[0])||700,Number(n[1])||420],a=Gn(s),c=Math.max(2,Math.round(e)),l=a.plot.width/c,u=a.plot.y+a.plot.height,d=Math.max(1,...t.map(t=>t.value)),h=!1!==o,[f,p]=i?.valueExtent??[0,c],y=p===f?1:p-f,g=t.map((t,e)=>{const o=u-t.value/d*a.plot.height*.9;return`${0===e?"M":"L"} ${(a.plot.x+(e+.5)*l).toFixed(1)} ${o.toFixed(1)}`}).join(" ");return(0,cc.jsxs)("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:s[0],height:s[1],viewBox:`0 0 ${s[0]} ${s[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?(0,cc.jsxs)(cc.Fragment,{children:[Array.from({length:c+1},(t,e)=>{const o=a.plot.x+e*l;return(0,cc.jsx)("line",{"data-testid":"galton-board-bin-wall",x1:o,x2:o,y1:a.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+e)}),(0,cc.jsx)("line",{x1:a.plot.x,x2:a.plot.x+a.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,cc.jsx)("path",{d:g,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),t.map((t,e)=>t.value>0?(0,cc.jsx)("text",{x:a.plot.x+(e+.5)*l,y:Math.max(a.plot.y+10,u-t.value/d*a.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:t.value},`${t.label}-${e}`):null)]}):null,r.map((t,e)=>{const o=Number(t.value);if(!Number.isFinite(o))return null;const i=a.plot.x+Math.max(0,Math.min(1,(o-f)/y))*a.plot.width,n=t.color??"var(--semiotic-warning, #f28e2b)",r="bottom"===t.labelPosition?Math.min(s[1]-8,u+16):a.plot.y+16;return(0,cc.jsxs)("g",{className:t.className,"data-testid":"galton-board-reference-line",children:[(0,cc.jsx)("line",{x1:i,x2:i,y1:a.plot.y+8,y2:u-4,stroke:n,strokeDasharray:t.strokeDasharray??"6 5",strokeWidth:t.strokeWidth??2}),null==t.label?null:(0,cc.jsx)("text",{x:Math.min(a.plot.x+a.plot.width-4,i+6),y:r,fill:n,fontSize:10,fontWeight:700,children:t.label})]},`galton-reference-${e}-${o}`)})]})}}function uc(t,e,o){if(!1!==o&&e)return({size:o})=>{const i=[Number(o[0])||760,Number(o[1])||360],n=Gn(i),r=Math.max(1,e.windowCount),s=e.plot??n.plot,a=e.gutter??{x:s.x,y:s.y,width:0,height:s.height},c=e.windowPlot??s,l=c.width/r,u=s.y+s.height,d=s.y+.48*s.height,h=e.lidSegments[0]?.y1??d,f=e.windowStart,p=e.windowStart+r*e.windowSize,y=c.x+Math.max(0,Math.min(1,p===f?0:(e.watermarkValue-f)/(p-f)))*c.width;return(0,cc.jsxs)("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,cc.jsx)("rect",{x:s.x,y:s.y,width:s.width,height:s.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),a.width>0?(0,cc.jsxs)("g",{children:[(0,cc.jsx)("rect",{x:a.x,y:h,width:a.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.55,strokeWidth:1}),(0,cc.jsx)("text",{x:a.x+a.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:"gutter"})]}):null,Array.from({length:r},(o,n)=>{const r=t[n],s=c.x+n*l,a=e.closedWindowCount>n,h=r?.secondary??0;return(0,cc.jsxs)("g",{children:[(0,cc.jsx)("rect",{x:s,y:d,width:l,height:u-d,fill:a?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:a?.08:.06,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.68,strokeWidth:1}),a?e.lidSegments.filter(t=>t.windowIndex===n).map(t=>(0,cc.jsx)("line",{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},t.id)):null,(0,cc.jsxs)("text",{x:s+l/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:[r?.value??0,h?` / ${h} late`:""]}),(0,cc.jsx)("text",{x:s+l/2,y:Math.min(i[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:r?.label??""})]},"window-"+n)}),e.lidSegments.filter(t=>null==t.windowIndex).map(t=>(0,cc.jsx)("line",{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},t.id)),(0,cc.jsx)("line",{x1:s.x,x2:s.x+s.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,cc.jsx)("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:s.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),(0,cc.jsxs)("text",{x:Math.min(s.x+s.width-4,y+6),y:s.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*e.watermarkValue)/100]}),e.lateCount>0?(0,cc.jsxs)("text",{x:a.x+a.width/2,y:s.y+32,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[e.lateCount," late"]}):null]})}}function dc(t,e,o){if(!1!==o&&0!==t.length)return({size:o})=>{const i=[Number(o[0])||700,Number(o[1])||380],n=Gn(i),r=As(n.plot,t.length,e),s=n.plot.y+n.plot.height;return(0,cc.jsxs)("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,cc.jsx)("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),t.map((t,e)=>{const o=Math.min(n.plot.height,r.pileHeight(t.value)),a=r.tubeWidth,c=r.centerX(e),l=s-o;return(0,cc.jsxs)("g",{children:[(0,cc.jsx)("rect",{x:c-a/2,y:l,width:a,height:o,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),(0,cc.jsx)("text",{x:c,y:Math.max(n.plot.y+12,l-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:t.value}),(0,cc.jsx)("text",{x:c,y:Math.min(i[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:t.label})]},`${t.label}-${e}`)})]})}}function hc(t){return t.toLocaleString(void 0,Math.abs(t)>=1e3||.01>Math.abs(t)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function fc(t,e){if(!1!==e&&t)return({size:e})=>{const o=[Number(e[0])||700,Number(e[1])||360],i=Gn(o),n=i.plot.y+i.plot.height,[r,s]=t.xExtent,a=r+(s-r)/2,c=[{label:hc(r),x:t.xRange[0]},{label:hc(a),x:t.xRange[0]+(t.xRange[1]-t.xRange[0])/2},{label:hc(s),x:t.xRange[1]}];return(0,cc.jsxs)("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[t.groups.map(t=>(0,cc.jsxs)("g",{children:[(0,cc.jsx)("line",{x1:i.plot.x,x2:i.plot.x+i.plot.width,y1:t.y,y2:t.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),(0,cc.jsx)("text",{x:i.plot.x+4,y:t.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:t.label}),(0,cc.jsxs)("text",{x:i.plot.x+i.plot.width-4,y:t.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",t.count]})]},t.label)),(0,cc.jsx)("line",{x1:t.xRange[0],x2:t.xRange[1],y1:n,y2:n,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),c.map(t=>(0,cc.jsxs)("g",{children:[(0,cc.jsx)("line",{x1:t.x,x2:t.x,y1:n,y2:n+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),(0,cc.jsx)("text",{x:t.x,y:Math.min(o[1]-8,n+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:t.label})]},`${t.label}-${t.x}`))]})}}var pc=require("react/jsx-runtime"),yc={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}};function gc(t,e,o){return Math.max(e,Math.min(o,t))}function mc(t){return 6.2*t.length}function xc(t,e){const o=t.trim();if(e>=o.length)return o;if(1>=e)return o.slice(0,1);const i=o.split(/\s+/).filter(Boolean).map(t=>t[0]).join("").toUpperCase();return i.length>1&&e>=i.length?i:e>3?o.slice(0,Math.max(1,e-2))+"..":o.slice(0,e).toUpperCase()}function bc(t,e,o="auto"){const i=Math.max(1,Math.floor(e/6.2)),n="compact"===o?xc(t,i):"full"===o?t:mc(t)>e?xc(t,i):t;return{text:n,textLength:mc(n)>e?Math.max(4,e):void 0}}var vc=require("react/jsx-runtime");function wc(t,e,o={},i){if(!1===e||!t)return;const{volume:n,stages:r,groups:s,groupCompletion:a}=t,c=new Map(n.stages.map(t=>[t.id,t])),l=new Map(a.map(t=>[t.id,t]));return({size:t})=>{const e=Number(t[0])||n.width,a=Number(t[1])||n.height,u=r.map(t=>{const e=c.get(t.id),i=o["process-stage-"+t.id];return{id:t.id,label:t.label,x0:e?.x0??t.x-t.width/2,x1:(e?.x0??t.x-t.width/2)+(e?.width??t.width),x:t.x,width:e?.width??t.width,count:t.count,capacity:t.capacity,absorb:t.absorb,portalTarget:t.portalTarget,queueDepth:i?.queueDepth,processed:i?.processedCount}}),d=s.map(t=>{const e=l.get(t.id);return{id:t.id,label:t.label??t.id,x:t.anchor?.x??t.x??0,y:t.anchor?.y??t.y??0,absorbed:e?.absorbed,total:e?.total,complete:e?.complete}});return function(t,e={}){const{showFlowSpine:o=!0,showStageCounts:i=!0,showCapacityBadges:n=!0,showGroupSockets:r=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=e,{width:l,height:u,left:d,right:h,topY:f,bottomY:p,midY:y,stages:g,groups:m=[]}=t,x=p-f;return(0,pc.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,pc.jsx)("defs",{children:(0,pc.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,pc.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,pc.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,pc.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,pc.jsx)("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),o?(0,pc.jsx)("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((t,e)=>{const o=function(t){return t.absorb?"absorb":t.portalTarget?"portal":null!=t.capacity?"capacity":"flow"}(t),r=yc[o],c=Math.max(12,t.width-8),l=gc(c-8,22,88),d=bc(t.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,m=function(t){if(null!=t.capacity){const e=null!=t.queueDepth?" · q "+t.queueDepth:"";return t.capacityLabel?`${t.capacityLabel}${e}`:`cap ${Number.isInteger(t.capacity)?t.capacity+"":t.capacity.toFixed(1)}${e}`}return t.absorb?"absorb":t.portalTarget?"portal":"flow"}(t),b=bc(m,Math.max(16,c-10),"auto"),v=n&&!1!==t.showBadge&&c>=32,w=null!=t.count?`n=${t.count}${null!=t.processed?" done "+t.processed:""}`:"",k=bc(w,Math.max(16,c-8),"auto"),S=Math.max(30,f-15),A=S-13;return(0,pc.jsxs)("g",{"data-stage":t.id,"data-role":o,children:[(0,pc.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:t.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:a?"none":r.fill,stroke:r.stroke,strokeWidth:a?1.85:"flow"===o?1:1.6}),g.length-1>e?(0,pc.jsx)("polygon",{points:`${t.x1-2},${y-7} ${t.x1+8},${y} ${t.x1-2},${y+7}`,fill:r.accent,opacity:.85}):null,h?(0,pc.jsxs)(pc.Fragment,{children:[(0,pc.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:t.x-l/2,y:A,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:r.stroke}),(0,pc.jsxs)("text",{x:t.x,y:S,textAnchor:"middle",fill:r.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,pc.jsx)("title",{children:t.label}),d.text]})]}):null,v?(0,pc.jsxs)("text",{x:t.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,pc.jsx)("title",{children:m}),b.text]}):null,i&&null!=t.count?(0,pc.jsxs)("text",{x:t.x,y:Math.min(u-8,p+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[(0,pc.jsx)("title",{children:w}),k.text]}):null]},t.id)}),r?m.map((t,e)=>{const o=t.total??0,i=t.absorbed??0,n=t.complete??(o>0&&i>=o),r=!n&&o>0&&i/o>=.75,s=n?"rgba(52, 211, 153, 0.35)":r?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=n?"#34d399":r?"#fbbf24":"var(--semiotic-border, #64748b)",c=o>0?`${i}/${o}${n?" shipped":r?" almost":""}`:"feature "+(e+1),l=gc(Math.max(54,mc(t.label)+18,mc(c)+16),54,104),u=bc(t.label,l-12,"auto"),d=bc(c,l-12,"auto");return(0,pc.jsxs)("g",{"data-group":t.id,children:[(0,pc.jsx)("rect",{x:t.x-l/2,y:t.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),(0,pc.jsxs)("text",{x:t.x,y:t.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,pc.jsx)("title",{children:t.label}),u.text]}),(0,pc.jsxs)("text",{x:t.x,y:t.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,pc.jsx)("title",{children:c}),d.text]})]},t.id)}):null]})}({width:e,height:a,left:n.left,right:n.right,topY:n.topY,bottomY:n.bottomY,midY:n.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...i})}}function kc(t,e,o){if(!1===o||!e||0===t.length)return;const i=new Map(e.volume.stages.map(t=>[t.id,t]));return({size:o})=>{const n=[Number(o[0])||e.volume.width,Number(o[1])||e.volume.height],r=Gn(n),s=Math.max(1,...t.map(t=>t.value)),a=Math.min(48,.18*r.plot.height),c=r.plot.y+6;return(0,vc.jsx)("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:e.stages.map((e,o)=>{const n=t[o];if(!n)return null;const r=i.get(e.id);if(!r)return null;const l=Math.max(2,n.value/s*a),u=Math.max(8,.35*r.width);return(0,vc.jsx)("rect",{x:r.x-u/2,y:c,width:u,height:l,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},e.id)})})}}function Sc(t){return t.map((t,e)=>`${0===e?"M":"L"} ${t.x} ${t.y}`).join(" ")}var Ac=require("react/jsx-runtime");function Mc(t,e){const{showNodeLabels:o,showSensors:i,showStaticFlow:n}=e;if(t&&(n||i||o))return({size:e})=>{const r=[Number(e[0])||760,Number(e[1])||420],s=Math.max(1,...t.links.map(t=>t.throughput)),a=new Set(t.nodes.map(t=>t.sensorId));return(0,Ac.jsxs)("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[n?t.links.map(t=>{const e=3+t.throughput/s*16,o=t.path[Math.floor(t.path.length/2)];return(0,Ac.jsxs)("g",{children:[(0,Ac.jsx)("path",{d:Sc(t.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:e+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),(0,Ac.jsx)("path",{d:Sc(t.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),o?(0,Ac.jsx)("text",{x:o.x,y:o.y-e/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:(i=t.throughput,i.toLocaleString(void 0,1e3>Math.abs(i)?{maximumFractionDigits:1}:{maximumFractionDigits:0}))}):null]},t.id);var i}):null,t.nodes.map(t=>(0,Ac.jsxs)("g",{children:[i&&a.has(t.sensorId)?(0,Ac.jsx)("rect",{"data-testid":"physical-flow-sensor-overlay",x:t.x-12,y:t.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,n?(0,Ac.jsx)("circle",{cx:t.x,cy:t.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,o?(0,Ac.jsx)("text",{x:t.x,y:t.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:t.label}):null]},t.id))]})}}var _c=require("react/jsx-runtime");function Pc({layout:t,compact:e,showLabels:o}){const i=e?Math.round(.14*t.height):Math.max(80,t.routeY-180),n=e?Math.max(6,Math.round(.72*t.height)):Math.min(360,t.height-170);return(0,_c.jsx)(_c.Fragment,{children:t.gates.map(r=>(0,_c.jsxs)("g",{children:[(0,_c.jsx)("rect",{x:r.x-r.width/2,y:i,width:r.width,height:n,rx:e?2:12,fill:r.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:r.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),o?(0,_c.jsx)("text",{x:r.x,y:Math.max(64,t.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:r.label??r.id}):null]},r.id))})}function jc({layout:t,states:e,compact:o=!1}){return o?(0,_c.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:(0,_c.jsx)(Pc,{layout:t,compact:!0,showLabels:!1})}):(0,_c.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,_c.jsx)("path",{d:`M ${t.startX-42} ${t.routeY} C ${.24*t.width} ${t.routeY-70}, ${.42*t.width} ${t.routeY+78}, ${.58*t.width} ${t.routeY} S ${.78*t.width} ${t.routeY-82}, ${t.socketX+36} ${t.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),(0,_c.jsx)("line",{x1:Math.round(.06*t.width),x2:Math.round(.94*t.width),y1:t.crashY,y2:t.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),(0,_c.jsx)("text",{x:Math.round(.07*t.width),y:t.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),(0,_c.jsx)(Pc,{layout:t,compact:!1,showLabels:!0}),(0,_c.jsxs)("g",{children:[(0,_c.jsx)("rect",{x:t.socketX-52,y:t.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),(0,_c.jsx)("text",{x:t.socketX,y:t.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,_c.jsxs)("g",{children:[(0,_c.jsx)("rect",{x:t.graveyardX-82,y:t.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),(0,_c.jsx)("text",{x:t.graveyardX,y:t.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,_c.jsx)("text",{x:t.graveyardX,y:t.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:e.some(t=>t.killed)?"lift shut off":"too heavy or too small"})]})]})}function Lc({states:t,layout:e}){const o=function(t){return t.map(t=>({label:t.id,value:Math.max(0,Number(t.viability)||0),outcome:t.outcome||t.stage||"in-process"}))}(t);if(!o.length)return null;const i=Math.max(1,...o.map(t=>t.value)),n=Math.max(40,(e.width-80)/o.length);return(0,_c.jsxs)("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,_c.jsx)("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),o.map((t,e)=>{const o=40+e*n,r=Math.max(2,t.value/i*28),s=/kill|crash|block|grave/i.test(t.outcome);return(0,_c.jsxs)("g",{children:[(0,_c.jsx)("rect",{x:o+.18*n,y:28-r+22,width:Math.max(10,.45*n),height:r,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),(0,_c.jsx)("text",{x:o+.4*n,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:t.label})]},t.label)})]})}var $c={margin:(t,e)=>e.compactMode?"sparkline"===t.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}};function Rc(t){return t.map(t=>({...t,spawnAt:void 0}))}function Cc(t,e){return t?e?o=>Xn.createElement(Xn.Fragment,null,"function"==typeof t?t(o):t,"function"==typeof e?e(o):e):t:e}function Ic(t,e,o){const i=e[o];return"boolean"==typeof i?i:!0!==t.__compactMode}var Tc=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function Oc(t){let e=2166136261;for(let o=0;t.length>o;o+=1)e^=t.charCodeAt(o),e=Math.imul(e,16777619);return Tc[(e>>>0)%Tc.length]}var zc={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(t,e,o,i,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,...i,showAxes:!1,margin:i.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:ro,LineChart:co,AreaChart:uo,DifferenceChart:ho,StackedAreaChart:fo,Scatterplot:oe,CandlestickChart:po,BubbleChart:ie,ConnectedScatterplot:go,QuadrantChart:yo,Heatmap:mo,TemporalHistogram:lo,XYCustomChart:{frameType:"xy",buildProps:(t,e,o,i,n)=>({chartType:"custom",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:o,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...i,showAxes:n.frameProps?.showAxes??n.showAxes??!1,showLegend:i.showLegend??!!e})},BarChart:zo,StackedBarChart:Fo,GroupedBarChart:No,PieChart:Eo,DonutChart:Do,Histogram:Bo,BoxPlot:Wo,ViolinPlot:Yo,SwarmPlot:qo,DotPlot:Xo,SwimlaneChart:Go,RidgelinePlot:Vo,LikertChart:Ho,FunnelChart:Uo,GaugeChart:Ko,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"custom",data:t,oAccessor:n.categoryAccessor||n.oAccessor||"category",rAccessor:n.valueAccessor||n.rAccessor||"value",projection:n.projection||"vertical",colorAccessor:e,colorScheme:o,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...i,showAxes:n.frameProps?.showAxes??n.showAxes??!1})},ForceDirectedGraph:Cn,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(t,e,o,i,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:o,customNetworkLayout:n.layout||n.customNetworkLayout,layoutConfig:n.layoutConfig,...i})},SankeyDiagram:zn,ProcessSankey:On,ChordDiagram:Rn,TreeDiagram:Fn,Treemap:Nn,CirclePack:In,OrbitDiagram:Tn,ChoroplethMap:Wn,ProportionalSymbolMap:Yn,FlowMap:qn,GeoCustomChart:{frameType:"geo",buildProps:(t,e,o,i,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:o,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.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)),o=Math.max(1,Math.round(t.pegRows??e-1)),i=Math.max(1,Math.round(t.count??Math.max(64,4*e))),n=Qn(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=er(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:i},(t,e)=>{let i=0;for(let t=0;o>t;t+=1)r()<n&&(i+=1);const a=o/2;return{id:`${s}-${e}`,value:i,mechanical:!0,pegRows:o,branchProbability:n,pathRights:i,side:a>i?"left":i>a?"right":"center"}})}({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:a}):Array.isArray(t)?t:[],d=function(t){const{data:e,valueAccessor:o,bins:i,ballRadius:n,seed:r,size:s,valueExtent:a}=t,c=Gn(s),l=e.map((t,e)=>Zn(Kn(t,e,o))).filter(t=>null!=t),u=function(t){if(!t)return;const e=Zn(t[0]),o=Zn(t[1]);return null!=e&&null!=o?e>o?[o,e]:[e,o]: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,or.scaleLinear)().domain([0,i]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:i},()=>0),g=[];e.forEach((t,e)=>{const r=Zn(Kn(t,e,o));if(null==r)return;const s=Math.max(0,Math.min(i-1,Math.floor((r-d)/f*i)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:c.plot.y+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:Un(r,[...Jr({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...ts({idPrefix:"galton-bin",count:i,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:i,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??4,seed:a,size:r,valueExtent:l?[0,c]:void 0});return{...i,config:d.config,initialSpawns:Rc(d.initialSpawns),projectionRows:d.projectionRows,foregroundGraphics:Cc(lc(d.projectionRows,s,Ic(i,n,"showProjection"),d.metadata,n.referenceLines),i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,400],s=function(t){const{data:e,timeAccessor:o,arrivalAccessor:i,windows:n,watermark:r,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=t,d=Gn(c),h=e.map((t,e)=>Zn(Kn(t,e,o))).filter(t=>null!=t),f=Zn(l?.[0]),p=Zn(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):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=h.length?Math.max(...h):0,k="function"==typeof r?r(w):Zn(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 o=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:o,height:t.plot.height},windowPlot:{x:t.plot.x+o,y:t.plot.y,width:Math.max(40,t.plot.width-o),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(d,s),M=b+v*n.size,_=(0,ks.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),j=[];e.forEach((t,e)=>{const r=Zn(Kn(t,e,o));if(null==r)return;const a=Zn(Kn(t,e,i))??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,j.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(r))),y:d.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...t,eventTime:r,arrivalTime:a,windowIndex:c,late:l}})});const L=d.plot.y+d.plot.height,$=function(t,e){const o=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!o)return[];const i=t.windowStart,n=t.windowStart+t.windowCount*t.windowSize,r=(0,ks.scaleLinear)().domain([i,n]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+o*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;o>e;e+=1){const o=t.windowStart+e*t.windowSize,i=o+t.windowSize,n=r(o),s=r(i);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:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:n.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Un(a,[...Jr({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Ss({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?$[0]?.y1:$[t-1]?.y2??$[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:L,wallThickness:6}),...$.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:j,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:$,lateCount:P.reduce((t,e)=>t+e.secondary,0),plot:d.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{...i,config:s.config,initialSpawns:Rc(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:Cc(uc(s.projectionRows,s.metadata,Ic(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||n.timeAccessor||"time"})}}},UnitPileChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,400],s="mechanical"===n.mode,a=function(t){const{data:e,categoryAccessor:o,valueAccessor:i,unitValue:n,ballRadius:r,seed:s,size:a}=t,c=Jn(n,1),l=Gn(a),u=[],d=new Map,h=new Map,f=[];function p(t){let e=d.get(t);return null==e&&(e=u.length,u.push(t),d.set(t,e)),e}e.forEach((t,e)=>{p((Kn(t,e,o)??"unknown")+"")});const y=Math.max(1,u.length),g=As(l.plot,y,r),m=Math.max(0,g.tubeWidth/2-r-1),x=u.map(()=>[]);e.forEach((t,e)=>{const n=(Kn(t,e,o)??"unknown")+"",s=p(n),a=i?Zn(Kn(t,e,i)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let o=0;u>o;o+=1){const i=h.get(n)??0,a=g.perRow>1?((g.perRow>1?i%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(n,i+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${o}`,x:d+a,y:l.plot.y+r+2,vx:(o%3-1)*r/2,vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,category:n,unitIndex:o}})}});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=[...Jr({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 o of[-1,1])w.push({id:`pile-tube-${t}-${0>o?"l":"r"}`,shape:{type:"aabb",x:e+o*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:Un(s,w,"UnitPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:h.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),o=e.length?e:["Intake"],i=Math.max(o.length,Math.round(t.count??Math.max(48,12*o.length))),n=Jn(t.unitValue,1),r=er(t.seed??1),s=t.idPrefix??"mechanical-pile",a=o.map(()=>.65+.9*r()),c=a.reduce((t,e)=>t+e,0)||1,l=i-o.length,u=a.map(t=>t/c*l),d=u.map(t=>1+Math.floor(t));let h=i-d.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;h>0;t=(t+1)%f.length)d[f[t].index]+=1,h-=1;return o.map((t,e)=>({id:`${s}-${e}`,category:t,value:d[e]*n,mechanical:!0,unitCount:d[e],unitValue:n,share:d[e]/i}))}({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{...i,config:a.config,initialSpawns:Rc(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:Cc(dc(a.projectionRows,n.ballRadius??5,Ic(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,360],s=function(t){const{data:e,xAccessor:o,groupAccessor:i,radiusAccessor:n,pointRadius:r,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,d=Gn(a),h=er(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=Zn(Kn(t,e,o));if(null==s)return;const a=i?(Kn(t,e,i)??"All")+"":"All",c=n?Zn(Kn(t,e,n)):null,l=Qn(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?Zn(c[0]):null,x=c?Zn(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const t=k;k=w,w=t}const S=Math.max(r,...f.map(t=>t.radius)),A=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,_=(0,Ms.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),j=Math.min(Math.max(28,3*S),d.plot.height/4),L=d.plot.y+j,$=Math.max(0,d.plot.y+d.plot.height-j-L),R=t=>{const e=y.get(t)??0;return 1===P?d.plot.y+.54*d.plot.height:L+e/(P-1)*$},C=new Map,I=f.map((t,e)=>{C.set(t.group,(C.get(t.group)??0)+1);const o=_(t.value),i=R(t.group),n=(h()-.5)*t.radius*1.6,r=(h()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?o+n:Qn(o+(e%9-4)*t.radius*2.5,A,M),y:u?i+r:d.plot.y-18-e%12*t.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:o,targetY:i},springs:[{target:{type:"point",x:o,y:i},restLength:0,stiffness:34,damping:5.5}]}});return{config:Un(s,Jr({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:I,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:R(t),count:C.get(t)??0})),plot:d.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{...i,config:s.config,initialSpawns:Rc(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:Cc(fc(s.metadata,Ic(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy||n.groupAccessor,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[900,420],s=Array.isArray(n.stages)?n.stages:[],a=function(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const o=t.size,i=Gn(o),n=Qn(t.ballRadius??6,2,18),r=t.seed??1,s=er(r),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,d=t.workAccessor,h=t.radiusAccessor,f=t.groupCompletion??(l?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",o=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height)),n=t.padX??46,r=t.padY??72,s=n,a=o-n,c=r,l=i-Math.max(24,Math.round(.45*r)),u=(c+l)/2,d=Math.max(1,l-c),h=Cs(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Cs(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,S=t.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Cs(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 j=S.map((t,e)=>{const o=P,i=e===S.length-1?a:P+(t.share??1)/M*_;return P=i,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:o,x1:i,x:(o+i)/2,width:i-o,y:u,height:d}}),L=j[A],$=L.x0,R=L.x1,C=(t,o)=>{if("lane"===e)return"top"===o?c:l;if("funnel"===e){const e=Cs((t-s)/Math.max(1,a-s),0,1);return"top"===o?c+(m-c)*e:l+(x-l)*e}if($>=t){const e=Cs((t-s)/Math.max(1,$-s),0,1);return"top"===o?c+(m-c)*e:l+(x-l)*e}if(R>=t)return"top"===o?m:x;const i=Cs((t-R)/Math.max(1,a-R),0,1);return"top"===o?m+(c-m)*i:x+(l-x)*i},I=j.map(t=>{const e=Math.min(C(t.x0,"top"),C(t.x1,"top")),o=Math.max(C(t.x0,"bottom"),C(t.x1,"bottom"));return{...t,y:(e+o)/2,height:Math.max(1,o-e)}}),T={thickness:k,friction:v,restitution:w},O=[];"lane"===e?O.push(Is(b+"-top",s,c,a,c,T),Is(b+"-bottom",s,l,a,l,T),Is(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),Is(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)})):"funnel"===e?O.push(Is(b+"-top",s,c,a,m,T),Is(b+"-bottom",s,l,a,x,T),Is(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),Is(b+"-right",a,m,a,x,{...T,thickness:Math.max(6,k)})):O.push(Is(b+"-left-top",s,c,$,m,T),Is(b+"-left-bottom",s,l,$,x,T),Is(b+"-center-top",$,m,R,m,T),Is(b+"-center-bottom",$,x,R,x,T),Is(b+"-right-top",R,m,a,c,T),Is(b+"-right-bottom",R,x,a,l,T),Is(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),Is(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)}));const z=t.membraneDampingScale??.5,F=s,N=Math.max(1,("bowtie"===e?$:a)-F),E=(t.membranes??[]).map(t=>{const e=F+Cs(t.offset,0,1)*N,o=t.width??18+18*t.cost,i=d-16,n=u+.25*(t.wobble??0);return{...t,x:e,y:n,width:o,height:i}}),D=!1===t.includeMembraneRegions?[]:E.map(t=>function(t){const e=t.dampingScale??.5,o=t.energyScale??1,i=Cs(t.cost,0,2);return{...Ts({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:i,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i*e,energyDelta:-i*o}}({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??z,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:o,height:i,padX:n,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:$,centerRight:R,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:I,membranes:E,colliders:O,regionEffects:D,boundaryY:C}}({width:o[0],height:o[1],shape:"lane",padX:Math.max(28,i.plot.x),padY:Math.max(36,i.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],S=new Set(e.filter(t=>t.absorb).map(t=>t.id)),A=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const o={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{...Ts({...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"}}({...o,kind:t.kind??"sink",force:zs(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...o.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return i={...o,kind:t.kind??"force-field",force:zs(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...o.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Ts({...i,kind:i.kind??"force-field",attributes:{primitive:"portal",targetStage:i.targetStage,..."object"==typeof i.attributes&&i.attributes?i.attributes:{}}}),force:i.force,impulseOnEnter:i.impulseOnEnter,damping:i.damping??.08}}var i;if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ts({...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}}({...o,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:zs(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...o.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,o=t.baseDamping??.08,i=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Ts({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o+e*i,energyDelta:n?-e*n:void 0,force:t.force}}({...o,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:zs(t.force,8),attributes:{...o.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Os({...o,kind:t.kind??"force-field",force:zs(t.force,14),damping:t.damping??.02,attributes:{...o.attributes,primitive:"routeSurface"}}):function(t){return{...Ts({...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}}({...o,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...o.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Os({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 o=(a?Kn(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",i=(Kn(t,e,c)??w)+"",r=b.has(i)?i:w;M.set(r,(M.get(r)??0)+1);const s=l?(Kn(t,e,l)??"")+"":void 0,f=s&&u?(Kn(t,e,u)??s)+"":s,p=d?Zn(Kn(t,e,d))??1:1,y=h?Zn(Kn(t,e,h)):null,g=Qn(null!=y&&y>0?y:n,2,18);_.push({datum:t,id:o,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const P=new Map,j=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&&j.set(t.groupId,t.groupLabel)}const L=Qn(t.groupAnchorAlong??.55,.15,.9),$=x.left+(x.right-x.left)*L,R=Array.from(P.keys()),C=R.map((t,o)=>{const i=P.get(t)??[],n=R.length>1?x.topY+28+o/Math.max(1,R.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,o=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:o,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:o},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:j.get(t)??t,bodyIds:i,anchor:{x:$,y:n},x:$,y:n,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),I=function(t,e){const o=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],i=e.filter(t=>!o.has(t)),n=e.length-i.length,r=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s&&Object.prototype.hasOwnProperty.call(o=s,i=t)?o[i]:void 0;var o,i;return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:1},c=e.reduce((t,e)=>t+a(e),0),l=e.reduce((t,e)=>t+(o.has(e)?a(e):0),0),u=t.completion?.threshold,d="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:r,complete:e.length>0&&("anyAbsorbed"===r?n>0:"threshold"===r?l>=(d??c):0===i.length),absorbed:n,total:e.length,absorbedValue:l,totalValue:c,threshold:d,missing:i}})}(C,_.filter(t=>S.has(t.stageId)).map(t=>t.id)),T=new Map(C.map(t=>[t.id,t])),O=_.map((t,e)=>{const o=v.get(t.stageId)??k,i=o.x+(s()-.5)*Math.min(24,.2*o.width),n=x.boundaryY(i,"top")+t.radius+10,r=x.boundaryY(i,"bottom")-t.radius-10,a=r>n?n+s()*Math.max(1,r-n):x.midY,c=g?i:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:i,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=T.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}}}),z={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},F=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),N=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:z,initialSpawns:O,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:F,metadata:{kind:"process-flow",plot:i.plot,volume:x,stages:N,groups:C,groupCompletion:I,regionEffects:A}}}({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{...i,config:a.config,initialSpawns:Rc(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,backgroundGraphics:Cc(wc(a.metadata,Ic(i,n,"showChrome"),{},n.chromeOptions),i.backgroundGraphics),foregroundGraphics:Cc(kc(a.projectionRows,a.metadata,Ic(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy||n.groupBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.workAccessor||n.stageAccessor||"stage"})}}},GauntletChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[900,520],s=Qs({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{...i,config:s.config,initialSpawns:Rc(s.initialSpawns),projectionRows:[],backgroundGraphics:Cc(Ic(i,n,"showChrome")?Xn.createElement(jc,{layout:s.layout,states:s.states,compact:!0===i.__compactMode}):void 0,i.backgroundGraphics),foregroundGraphics:Cc(Ic(i,n,"showProjection")?Xn.createElement(Lc,{layout:s.layout,states:s.states}):void 0,i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy)}}},CrucibleChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[900,520],s=Xa({data:Array.isArray(t)?t:[],phases:Array.isArray(n.phases)?n.phases:[],products:Array.isArray(n.products)?n.products:void 0,outlets:Array.isArray(n.outlets)?n.outlets:void 0,events:Array.isArray(n.events)?n.events:void 0,idAccessor:n.idAccessor,labelAccessor:n.labelAccessor,categoryAccessor:n.categoryAccessor,amountAccessor:n.amountAccessor,metricsAccessor:n.metricsAccessor,initialStateAccessor:n.initialStateAccessor,metrics:n.metrics,size:r,seed:n.seed,bodyRadius:"number"==typeof n.bodyRadius?n.bodyRadius:void 0,radiusRange:n.radiusRange}),a="snapshot"===n.playback?function(t,e){if(void 0===e)return t.duration;if("number"==typeof e)return Math.max(0,Math.min(t.duration,Pa(e)??0));const o=t.phases.find(t=>t.id===e.phaseId);if(!o)return t.duration;const i=Math.max(0,Math.min(1,Pa(e.progress??0)??0));return o.start+o.duration*i}(s,n.snapshotAt):s.duration,c=qa(s,a).state,l=n.projection&&"object"==typeof n.projection?n.projection:{groupBy:"outlet",measure:"count"},u=function(t,e={}){const o=e.groupBy??"outlet",i=new Map,n=t=>{const e=function(t,e){return"product"===e?"product"===t.kind?t.id:"unassigned":"outlet"===e?t.outletId??"unassigned":"category"===e?t.category:t.status}({...t,status:t.status??"active"},o),n=i.get(e);if(n)return n.count+=1,n.amount+=t.amount,void la(n.metrics,t.metrics);i.set(e,{key:e,label:"product"===o&&"product"===t.kind?t.label:e,count:1,amount:t.amount,metrics:ea(t.metrics),status:"status"===o?t.status:void 0,outletId:"outlet"===o?t.outletId:void 0,category:"category"===o?t.category:void 0,productId:"product"===o&&"product"===t.kind?t.id:void 0})};for(const e of Object.values(t.components))e.productIds.length||"consumed"===e.status||n({kind:"component",id:e.id,label:e.label,status:e.status,outletId:e.outletId,category:e.category,amount:e.amount,metrics:e.metrics});for(const e of Object.values(t.products))n({kind:"product",id:e.id,label:e.label,status:e.status,outletId:e.outletId,category:e.category,amount:e.amount,metrics:e.metrics});const r=new Map((e.order??[]).map((t,e)=>[t,e]));return[...i.values()].sort((t,e)=>(r.get(t.key)??Number.MAX_SAFE_INTEGER)-(r.get(e.key)??Number.MAX_SAFE_INTEGER)||ra(t.key,e.key))}(c,l),d=l.measure??"count",h=function(t,e={}){const o=e.bodies??[],i=Math.max(0,e.recentBodyLimit??6),n=new Map;for(const t of o){const o=e.getContainerId?.(t);if(!o)continue;const i=n.get(o);i?i.push(t):n.set(o,[t])}const r=t.map(t=>{const o=n.get(t.id)??[],r=Math.max(0,Math.floor(t.count??o.length)),s=o.slice(Math.max(0,o.length-i)).map(t=>({id:t.id,label:e.getBodyLabel?.(t)??ac(t),datum:t.datum}));return{id:t.id,label:t.label,count:r,share:0,secondary:t.secondary,secondaryLabel:t.secondaryLabel,observed:t.observed,bodyIds:o.map(t=>t.id),recentBodies:s,metadata:t.metadata}}),s=r.reduce((t,e)=>t+e.count,0);return r.map(t=>({...t,share:s>0?t.count/s:0}))}(u.map(t=>({id:t.key,label:t.label,count:t.count,secondary:"count"===d||"amount"===d?t.amount:Number(t.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?n.amountLabel??"amount":d,metadata:{amount:t.amount,metrics:t.metrics,status:t.status,outletId:t.outletId,category:t.category,productId:t.productId}}))),f={seed:n.seed,bodyRadius:"number"==typeof n.bodyRadius?n.bodyRadius:void 0,radiusRange:n.radiusRange},p=e??n.colorBy??"category",y=!1===n.showChrome?null:Xn.createElement(rc,{layout:s.layout,phases:s.phases,state:c,compact:520>r[0]||360>r[1]}),g=!1===n.showProjection?null:Xn.createElement(sc,{rows:u,layout:s.layout,projection:l,amountLabel:n.amountLabel});return{...i,config:s.config,initialSpawns:Rc(Ba(c,s.layout,f)),projectionRows:h,bodyStyle:t=>function(t,e,o,i){const n=t.datum,r={stroke:i.stroke??("product"===n?.kind?"#fffaf0":"#26323a"),strokeWidth:i.strokeWidth??("product"===n?.kind?1.8:1.1),opacity:i.opacity??.96};if(!n?.__crucible)return{...r,fill:i.color??"#b8792d"};if("product"===n.kind){const t=e.products[n.semanticId];return{...r,fill:i.color??t?.color??Oc(t?.id??n.semanticId)}}const s=e.components[n.semanticId];if(!s)return{...r,fill:i.color??"#356b63"};let a;return a="status"===o?s.status:"outlet"===o?s.outletId??"in chamber":"product"===o?s.productIds[0]??"unalloyed":"category"===o||null==o?s.category:"function"==typeof o?(o(s.datum)??"unassigned")+"":(s.datum[o+""]??"unassigned")+"",{...r,fill:i.color??Oc(a)}}(t,c,p,n),getBodyLabel:t=>function(t,e){const o=t.datum;if(o?.__crucible)return"product"===o.kind?e.products[o.semanticId]?.label:e.components[o.semanticId]?.label}(t,c),renderBodySVG:Za,backgroundGraphics:Cc(y,i.backgroundGraphics),foregroundGraphics:Cc(g,i.foregroundGraphics)}}},PacketFlowChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:o,links:i,maxParticles:n,nodeIdAccessor:r,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=Gn(y),v=er(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 o=(Kn(t,e,r)??t.id??e)+"",i=Zn(Kn(t,e,s)),n=Zn(Kn(t,e,a));if(null!=i&&null!=n){const t={x:i,y:n};w.set(o,t),S.push(t)}k.set(o,(t.label??t.name??o)+"")});const M=[];i.forEach((t,e)=>{const o=A(Kn(t,e,g)),i=A(Kn(t,e,m)),n=Math.max(0,Zn(Kn(t,e,x))??0),r=Ps(d?Kn(t,e,d):void 0),s=r.length?r:Ps(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${o}-${i}-${e}`)+"",link:t,index:e,source:o,target:i,throughput:n,rawPath:s})});const _=(j=S,"normalized"===(P=e)||"pixels"===P?P:j.length>0&&j.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var P,j;const L=new Map;for(const[t,e]of w)L.set(t,js(e,b,_));const $=[];for(const t of M){let e=t.rawPath.map(t=>js(t,b,_));if(2>e.length){const o=L.get(t.source),i=L.get(t.target);o&&i&&(e=[o,i])}else L.has(t.source)||L.set(t.source,e[0]),L.has(t.target)||L.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),$.push({...t,path:e,packetCount:0}))}const R=Jn(u,.12),C=Math.max(1,Math.round(n)),I=$.map(t=>Math.max(1,Math.round(t.throughput*R))),T=I.reduce((t,e)=>t+e,0),O=T>C?C/T:1;$.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(I[e]*O))});let z=$.reduce((t,e)=>t+e.packetCount,0);for(;z>C;){const t=$.reduce((t,e,o)=>e.packetCount>1&&(-1===t||e.packetCount>$[t].packetCount)?o:t,-1);if(-1===t)break;$[t].packetCount-=1,z-=1}const F=new Map,N=new Map,E=[],D=Jn(o,90),B=Jn(l,4);$.forEach((t,e)=>{F.set(t.target,(F.get(t.target)??0)+t.throughput),N.set(t.source,(N.get(t.source)??0)+t.throughput);const o=Ls(t.path);for(let i=0;t.packetCount>i;i+=1){const n=(i+.5)/t.packetCount,r=f?n:Qn(.12+.84*n+.04*(v()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*v())),a=$s(t.path,s),c=$s(t.path,r),l=Rs(t.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*B*1.5;E.push({id:`${t.id}-packet-${i}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*D+10*(v()-.5),vy:f?0:l.y*D+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+i/32,shape:{type:"circle",radius:B},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:i,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:o,flowRouteId:t.id,flowSpeed:D,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*B,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*B),Y=Array.from(L,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+tr(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=Un(p,[...Jr({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PacketFlowChart",{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=C,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(L,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+tr(t),incoming:F.get(t)??0,outgoing:N.get(t)??0})),H=$.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:E,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:E.length,totalThroughput:$.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{...i,config:s.config,initialSpawns:Rc(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:Cc(Mc(s.metadata,{showNodeLabels:!1!==n.showNodeLabels,showSensors:!1!==n.showSensors,showStaticFlow:!1!==n.showStaticFlow}),i.foregroundGraphics),bodyStyle:Hn(e||n.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",layout:$c,buildProps:(t,e,o,i,n)=>{const r=i.size??[700,380],s=Ot(i.theme),a=function(t){const e=function(t,e,o){const i=t?.observation;return{...t,observation:{...i,chartId:e??i?.chartId??"physics-custom",chartType:i?.chartType??"PhysicsCustomChart",onObservation:o??i?.onObservation}}}(t.config,t.chartId,t.onObservation),o=Ns(t.colorScheme,t.themeCategorical,C),i=Gn(t.size),n={data:t.data,scales:{x:(0,Fs.scaleLinear)().domain(t.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:(0,Fs.scaleLinear)().domain(t.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:t.semantic,categorical:[...o]},resolveColor:Es(o,t.colorScheme),config:t.layoutConfig??{},world:new ws(e)},r=t.skipLayout?{}:t.layout(n)??{},s=function(t,e){if(!e?.length)return t;const o=new Map;for(const t of e){const{bodyId:e,...i}=t,n=o.get(e)??[];n.push(i),o.set(e,n)}return t.map(t=>{const e=o.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Ds(e,r),context:n,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}({chartId:n.chartId,colorScheme:o,config:n.config,data:Array.isArray(t)?t:[],layout:n.layout,layoutConfig:n.layoutConfig,semantic:It(s)??{},size:r,themeCategorical:s.colors.categorical,xExtent:n.xExtent,yExtent:n.yExtent});return{...i,config:a.config,initialSpawns:Rc(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??Hn(e||n.colorBy),backgroundGraphics:Cc(i.backgroundGraphics,a.result.backgroundOverlays),foregroundGraphics:Cc(i.foregroundGraphics,a.result.overlays)}}}};function Fc(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function Nc(t){if(!t||2>t.length)return;const e=Fc(t[0]),o=Fc(t[t.length-1]);return null!==e&&null!==o?[e,o]:void 0}function Ec(t){const{count:e,byType:o}=function(t){const e={};for(const o of t){const t="string"==typeof o?.type&&o.type.length>0?o.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),i=0===e,n=[...t.extraWarnings??[]];i&&!n.includes("EMPTY_SCENE")&&n.push("EMPTY_SCENE"),t.annotationRender&&t.annotationRender.unrenderedCount>0&&!n.includes("UNRENDERED_ANNOTATIONS")&&n.push("UNRENDERED_ANNOTATIONS");const r=Array.isArray(t.annotations)?t.annotations.length:0,s=t.margin,a=s?{x:s.left,y:s.top,width:t.width-s.left-s.right,height:t.height-s.top-s.bottom}:void 0;return{component:"",frameType:t.frameType,status:i?"empty":"ok",empty:i,markCount:e,markCountByType:o,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:t.annotationRender?.renderedCount??r,...t.annotationRender?{annotationInputCount:t.annotationRender.inputCount,unrenderedAnnotationCount:t.annotationRender.unrenderedCount,...t.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:t.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:n,semanticStatus:"not-assessed",semanticDiagnostics:[],...s?{margin:s}:{},...a?{plot:a}:{}}}var Dc=c(require("react")),Bc=c(require("react-dom/server")),Wc=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 o of t){const t=this.push(o);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 o=0;this._size>o;o++)t(this.buffer[(e+o)%this._capacity],o)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)t[o]=this.buffer[(e+o)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let o=0,i=[];e.length>t&&(o=e.length-t,i=e.slice(0,o)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=o;e.length>t;t++)this.push(e[t]);return i}update(t,e){const o=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++){const r=(i+n)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},o.push(t),this.buffer[r]=e(s)}}return o}remove(t){const e=[],o=[];if(this.forEach(i=>{t(i)?o.push(i):e.push(i)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return o}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}},Yc=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 o of t){const t=e?e(o):o;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 qc(t,e){return t===e}function Xc(t,e){if("function"==typeof t)return e=>+t(e);const o=t||e;return t=>+t[o]}function Gc(t,e){if("function"==typeof t)return t;const o=t||e;return t=>t[o]}function Vc(t,e){return"function"==typeof t?e=>t(e)+"":t?e=>e[t]+"":e?t=>t[e]+"":void 0}function Hc(t){return t?"function"==typeof t?t:e=>e[t]||e.id:null}function Uc(t){return"string"==typeof t?t:t.id}var Kc=/^\d{4}-\d{1,2}$/;function Zc(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const o=Kc.test(e)?e+"-01":e;if(o===e&&10>e.length)return NaN;const i=Date.parse(o);return Number.isFinite(i)?i:NaN}function Qc(t){return t instanceof Date?t.getTime():"string"==typeof t?Zc(t):+t}function Jc(t){return new Set(Array.isArray(t)?t:[t])}function tl(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function el(t,e){return Math.min((t-e.startTime)/e.duration,1)}function ol(t,e,o){return t+(e-t)*o}function il(){return"undefined"!=typeof performance?performance.now():Date.now()}function nl(t,e,o){if(1>=o)return 1;const i=o-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 o=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>o?1:e;if("exponential"===t.type){const i=t.halfLife??t.extent/2;return e+Math.pow(.5,o/(i>0?i:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-o/t.extent))*(1-e)}({age:i-e,extent:i,type:t.type,halfLife:t.halfLife??o/2,threshold:t.stepThreshold??.5*o,minOpacity:t.minOpacity??.1})}function rl(t){const e=new Map;for(let o=0;t.length>o;o++)e.set(t[o],o);return e}function sl(t,e,o){const i=t.duration??500,n=o-e;return i>n?1-n/i:0}function al(t,e,o,i){let n=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,n=!0),t._pulseColor!==o&&(t._pulseColor=o,n=!0),t._pulseGlowRadius!==i&&(t._pulseGlowRadius=i,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 cl(t,e,o=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const i=t.duration??500,n=e.peek();return null!=n&&i>o-n}function ll(t,e,o){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 o=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${o}:${i}`;if(null!=o&&null!=i)return`p:${o}:${i}`}return"p:"+o;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+o;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??o}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+o:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function ul(t){return t?null!=t.opacity?t.opacity:null!=t.fillOpacity?t.fillOpacity:1:1}function dl(t,e,o,i,n,r){const s=[];for(const n of t){const t=o(n),r=i(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 hl(t,e,o,i,n,r,s,a){const c=[];for(const r of t){const t=o(r),s=i(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),rawY:s})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length),d=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],d[t]=e.rawY}return{type:"area",topPath:l,bottomPath:u,rawValues:d,style:r,datum:t,group:s}}function fl(t,e,o,i){const n=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const n of e)t+=o(n,i)||0;n.set(i,-t/2)}else if("wiggle"===i){t.length>0&&n.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];let a=0,c=0,l=0;for(const t of e){const e=o(t,s)||0;a+=(2*l+e)*(e-(o(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 i=0;for(const r of t){let t=0;for(const i of e)t+=o(i,r)||0;i+=(n.get(r)??0)+t/2}const r=i/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 pl(t,e,o,i,n,r,s){const a=o(t),c=i(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:n,style:r,datum:t};return void 0!==s&&(l.pointId=s),l}function yl(t,e,o,i,n,r,s,a){const c=o(t),l=i(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:n,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function gl(t,e,o,i,n,r,s){return{type:"rect",x:t,y:e,w:o,h:i,style:n,datum:r,group:s}}function ml(t,e,o,i,n,r,s){const a={type:"heatcell",x:t,y:e,w:o,h:i,fill:n,datum:r};return void 0!==s?.value&&(a.value=s.value),s?.showValues&&(a.showValues=!0,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function xl(t,e,o,i){return"function"==typeof e.style?e.style(i||{},o):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(o,i)}function bl(t,e,o,i){if(!t.scales)return null;const n=[],r=[];for(const o of e){const e=t.getX(o);if(!Number.isFinite(e))continue;const s=i.getTop(o),a=i.getBottom(o);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,...t.config.curve&&"linear"!==t.config.curve&&{curve:t.config.curve},style:xl(t,i,o,e[0]),datum:e,group:o,interactive:i.interactive}}function vl(t){const e=[],o=[];if(!t)return{perSeries:e,aggregate:o};for(const i of t)i.perSeries?e.push(i):o.push(i);return{perSeries:e,aggregate:o}}function wl(t,e,o){const i=[];for(const n of o){const o=bl(t,e,"__ribbon_aggregate",n);o&&i.push(o)}return i}function kl(t,e,o,i){const n=[];for(const r of i){const i=bl(t,e,o,r);i&&n.push(i)}return n}function Sl(t,e,o,i){if(!t.config.pointStyle)return;const n=i??t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const r of i.data){let i=t.config.pointStyle(r);!i.fill&&e&&(i={...i,fill:e});const s=i.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,c=pl(r,t.scales,t.getX,n,s,i,a);c&&o.push(c)}}}function Al(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}function Ml(t){return kt(t)}var _l=require("d3-shape"),Pl={circle:_l.symbolCircle,square:_l.symbolSquare,triangle:_l.symbolTriangle,diamond:_l.symbolDiamond,star:_l.symbolStar,cross:_l.symbolCross,wye:_l.symbolWye},jl=new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),Ll=["circle","triangle","diamond","star","square","chevron","cross","wye"];function $l(t,e,o){if(o)return o;const i=t??"circle";if("chevron"===i)return function(t){const e=1.5*Rl(t),o=.92*e;return`M0,${-e}L${o},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-o},${(.78*e).toFixed(3)}Z`}(e);const n=Object.prototype.hasOwnProperty.call(Pl,i)?Pl[i]:_l.symbolCircle;return(0,_l.symbol)(n,Math.max(1,e))()??""}function Rl(t){return Math.sqrt(Math.max(1,t)/Math.PI)}function Cl(t,e){const o=new Map;let i=0;return n=>{const r=t(n)+"",s=e&&Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(s&&jl.has(s))return s;let a=o.get(r);return a||(a=Ll[i%Ll.length],i++,o.set(r,a)),a}}var Il=new Map;function Tl(t){const e=Object.prototype.hasOwnProperty.call(X,t)?t:"blues";let o=Il.get(e);if(o)return o;o=Array(256);const i=G(e);for(let t=0;256>t;t++)o[t]=i(t/255);return Il.set(e,o),o}function Ol(t,e,o){const i=o.config.areaStyle?.(e);return i&&("string"==typeof i.fill&&(t.fill=i.fill),t.style=i),t}function zl(t,e,o,i,n){const r=new Map;for(const s of t){const t=e(s),a=o(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/i)*i;let l=r.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},r.set(c,l)),l.total+=a,n){const t=n(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return r}function Fl(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:o,overlays:i,warned:n}=t;Nl(i)&&0===o.length&&El(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.`),o.length>0&&o.every(t=>null==t.datum)&&El(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 Nl(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Nl))}function El(t,e,o){t.has(e)||(t.add(e),console.warn(o))}function Dl(t,e,o,i){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:o?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:o,affectedRevision:i}}function Bl(t,e){const o="function"==typeof t?t:o=>o[t||e];return t=>{const e=o(t);return null==e?NaN:+e}}function Wl(t){const e=[],o=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=Bl(o&&t.valueAccessor||t.yAccessor,o?"value":"y");if(t.boundsAccessor){const o=Xc(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const n=o(t);return Number.isFinite(n)&&0!==n?e+n:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const n=o(t);return Number.isFinite(n)&&0!==n?e-n:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const o=Array.isArray(t.band)?t.band:[t.band];for(const t of o)e.push({kind:"band",getTop:Bl(t.y1Accessor,"y1"),getBottom:Bl(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}var Yl=require("d3-scale");function ql(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Xl(t,e,o){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return(0,Yl.scaleLog)().domain(t).range(o).clamp(!0)}return"symlog"===t?(0,Yl.scaleSymlog)().domain(e).range(o):"time"===t?(0,Yl.scaleTime)().domain([new Date(e[0]),new Date(e[1])]).range(o):(0,Yl.scaleLinear)().domain(e).range(o)}function Gl(t,e,o){e>t.capacity&&(t.resize(e),o&&e>o.capacity&&o.resize(e))}function Vl(t,e){const o=new Wc(t.capacity);return t.forEach(()=>o.push(e)),o}function Hl(t,e,o,i){const n=t.push(e);return o&&o.push(i),n}function Ul(t,e,o){if(!e||0===e.size)return;const i=new Set;if(t.forEach((t,e)=>{o(t)&&i.add(e)}),0===i.size)return;const n=e.toArray();e.clear();for(let t=0;n.length>t;t++)i.has(t)||e.push(n[t])}var Kl=new WeakMap;function Zl(){return this.updateResults.last}function Ql(){return this.updateResults.last}function Jl(t){return this.updateResults.subscribe(t)}function tu(t){this.config.layoutSelection=t}function eu(){Kl.set(this,!0)}function ou(){const t=!0===Kl.get(this);return Kl.delete(this),t}function iu(t){Object.assign(t.prototype,{getLastUpdateResult:Zl,getUpdateSnapshot:Ql,subscribeUpdateResult:Jl,setLayoutSelection:tu,markStylePaintPending:eu,consumeStylePaintPending:ou})}var nu=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ru=["scene-style","data-paint","accessibility","evidence"],su=(t,e)=>({retainedData:t,invalidations:e}),au=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],cu=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],lu=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],uu=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],du=["scene-geometry","data-paint","accessibility","evidence"],hu=["scene-style","data-paint","accessibility","evidence"],fu=[],pu={chartType:su("rebuild",au),runtimeMode:su("rebuild",au),xAccessor:su("rebuild",au),yAccessor:su("rebuild",au),timeAccessor:su("rebuild",au),valueAccessor:su("rebuild",au),y0Accessor:su("rebuild",au),boundsAccessor:su("rebuild",au),band:su("rebuild",au),openAccessor:su("rebuild",au),highAccessor:su("rebuild",au),lowAccessor:su("rebuild",au),closeAccessor:su("rebuild",au),candlestickRangeMode:su("rebuild",au),accessorRevision:su("rebuild",au),groupAccessor:su("rebuild",cu),categoryAccessor:su("rebuild",cu),lineDataAccessor:su("rebuild",cu),colorAccessor:su("rebuild",hu),sizeAccessor:su("rebuild",du),symbolAccessor:su("rebuild",du),pointIdAccessor:su("rebuild",du),xScaleType:su("preserve",lu),yScaleType:su("preserve",lu),xExtent:su("preserve",lu),yExtent:su("preserve",lu),extentPadding:su("preserve",lu),scalePadding:su("preserve",lu),axisExtent:su("preserve",lu),yAxisExtent:su("preserve",lu),binSize:su("preserve",lu),normalize:su("preserve",lu),heatmapAggregation:su("preserve",lu),heatmapXBins:su("preserve",lu),heatmapYBins:su("preserve",lu),arrowOfTime:su("preserve",uu),baseline:su("preserve",uu),stackOrder:su("preserve",uu),sizeRange:su("preserve",uu),curve:su("preserve",uu),areaGroups:su("preserve",uu),customLayout:su("preserve",uu),layoutConfig:su("preserve",uu),layoutMargin:su("preserve",uu),symbolMap:su("preserve",du),showValues:su("preserve",du),heatmapValueFormat:su("preserve",du),lineStyle:su("preserve",hu),pointStyle:su("preserve",hu),areaStyle:su("preserve",hu),barStyle:su("preserve",hu),swarmStyle:su("preserve",hu),waterfallStyle:su("preserve",hu),candlestickStyle:su("preserve",hu),boundsStyle:su("preserve",hu),gradientFill:su("preserve",hu),lineGradient:su("preserve",hu),semanticLineStops:su("preserve",hu),colorScheme:su("preserve",hu),themeCategorical:su("preserve",hu),themeSemantic:su("preserve",hu),themeSequential:su("preserve",hu),themeDiverging:su("preserve",hu),barColors:su("preserve",hu),decay:su("preserve",hu),pulse:su("preserve",hu),staleness:su("preserve",hu),layoutSelection:su("preserve",hu),annotations:su("preserve",["overlay","accessibility","evidence"]),windowSize:su("preserve",fu),windowMode:su("preserve",fu),maxCapacity:su("preserve",fu),clock:su("preserve",fu),transition:su("preserve",fu),introAnimation:su("preserve",fu),onLayoutError:su("preserve",fu)},yu=su("preserve",uu),gu=class{constructor(){this.tracker=new ns}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}},nu)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},ru):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const o=new Set;for(const i of t){const t=pu[i]??yu;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},mu=require("d3-quadtree"),xu=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 o=0,i=0;for(const t of e)"point"===t.type&&!1!==t.interactive&&(o++,t.r>i&&(i=t.r));if(this.maxRadius=i,500>=o)return void(this.tree=null);const n=Array(o);let r=0;for(const t of e)"point"===t.type&&!1!==t.interactive&&(n[r++]=t);this.tree=(0,mu.quadtree)().x(t=>t.x).y(t=>t.y).addAll(n)}},bu=class t{constructor(t){if(this.xExtent=new Yc,this.yExtent=new Yc,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 gu,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 xu,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,o)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,o,i,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;o.length>e;e++)t.set(o[e],e);return t})();for(const o of e){if("line"===o.type)continue;if("area"===o.type){const e=Array.isArray(o.datum)?o.datum:[o.datum];let n=0,a=!1;for(const o of e){const e=l.get(o);if(null==e)continue;a=!0;const s=i.get(e);if(null==s)continue;const c=sl(t,s,r);c>n&&(n=c)}a&&(c=al(o,n,s)||c);continue}const e=l.get(o.datum);if(null==e)continue;const n=i.get(e);c=al(o,null==n?0:sl(t,n,r),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),o),this.config=t,this.buffer=new Wc(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Xc(t.timeAccessor||t.xAccessor,"time"),this.getY=Xc(t.valueAccessor||t.yAccessor,"value")):(this.getX=Xc(t.xAccessor,"x"),this.getY=Xc(t.yAccessor,"y")),this.getGroup=Vc(t.groupAccessor),this.getCategory=Vc(t.categoryAccessor),this.getSize=t.sizeAccessor?Xc(t.sizeAccessor,"size"):void 0,this.getColor=Vc(t.colorAccessor),this.getSymbol=Vc(t.symbolAccessor),this.getY0=t.y0Accessor?Xc(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Wl(t),this.getPointId=Vc(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,o=null!=t.closeAccessor;this.getOpen=e?Xc(t.openAccessor,"open"):void 0,this.getHigh=Xc(t.highAccessor,"high"),this.getLow=Xc(t.lowAccessor,"low"),this.getClose=o?Xc(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!o}t.pulse&&(this.timestampBuffer=new Wc(t.windowSize))}currentTime(){return this.config.clock?.()??il()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Vl(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 o=e.getTop(t),i=e.getBottom(t);Number.isFinite(o)&&this.yExtent.push(o),Number.isFinite(i)&&this.yExtent.push(i)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const o=e.getTop(t),i=e.getBottom(t);Number.isFinite(o)&&this.yExtent.evict(o),Number.isFinite(i)&&this.yExtent.evict(i)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=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 o=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=o?Xc(this.config.timeAccessor||this.config.xAccessor,"time"):Xc(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],o=this.config.xAccessor,i="function"==typeof o?o(e):e[o||"x"],n=i instanceof Date,r="string"==typeof i&&Number.isFinite(Zc(i));if(this.xIsDate=n||r,r){const t="string"==typeof o?o:void 0;this.getX=t?e=>Qc(e[t]):t=>Qc(o(t))}}Gl(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const o of t.inserts)Hl(this.buffer,o,this.timestampBuffer,e),this.xExtent.push(this.getX(o)),this.pushDatumYExtent(o)}else for(const o 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=Hl(this.buffer,o,this.timestampBuffer,e);this.xExtent.push(this.getX(o)),this.pushDatumYExtent(o),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:o}=this,i=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(o,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.yExtent.extent;let a=ql(this.xExtent.extent,e.xExtent),c=ql(s,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===(e.yAxisExtent??e.axisExtent);if("stackedarea"===e.chartType&&!l&&o.size>0){const t=function(t){const{config:e,groups:o,getX:i,getY:n}=t,r="exact"===(e.yAxisExtent??e.axisExtent);if(e.normalize){const o=[0,r?1:1+e.extentPadding];return{yDomain:o,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:o}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,d=new Map;for(const t of o){const e=new Map;let o=0;for(const r of t.data){const t=i(r),s=n(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),o+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),d.set(t.key,o)}const h=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===h)p=o.map(t=>t.key);else if("insideOut"===h){const t=[...o].map(t=>t.key).sort((t,e)=>{const o=(d.get(e)??0)-(d.get(t)??0);return 0!==o?o:f(t,e)}),e=[],i=[];let n=0,r=0;for(const o of t)r>n?(e.push(o),n+=d.get(o)??0):(i.push(o),r+=d.get(o)??0);p=[...i.reverse(),...e]}else p="asc"===h?o.map(t=>t.key).sort((t,e)=>{const o=(d.get(t)??0)-(d.get(e)??0);return 0!==o?o:f(t,e)}):"desc"===h?o.map(t=>t.key).sort((t,e)=>{const o=(d.get(e)??0)-(d.get(t)??0);return 0!==o?o:f(t,e)}):o.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),o=fl(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let i=1/0,n=-1/0;for(const e of t){const t=o.get(e)??0,r=u.get(e)??0;i>t&&(i=t),t+r>n&&(n=t+r)}Number.isFinite(i)&&Number.isFinite(n)||(i=0,n=0);const s=n-i,l=r?0:s>0?s*e.extentPadding:1;y=[i-l,n+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[o,i]=function(t,e,o){let i=0,n=0;for(const r of t){let t=0,s=0;for(const i of e){const e=o(i,r)||0;0>e?s+=e:t+=e}i>s&&(i=s),t>n&&(n=t)}return[i,n]}(t,p,(t,e)=>a.get(t)?.get(e)||0),n=i-o,s=r?0:n>0?n*e.extentPadding:1;y=[o-s,i+s]}else y=[0,l+(r?0:l>0?l*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:o.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&o.size>0?c=function(t,e,o,i,n,r,s){const[,a]=function(t,e,o,i,n){const r=zl(t,e,o,i,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,o,i,n);return[0,s?a:a+a*r]}(o,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,d):"waterfall"===e.chartType&&!l&&o.size>0?c=function(t,e,o,i){const[n,r]=function(t,e){let o=0,i=0,n=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(n+=t,o>n&&(o=n),n>i&&(i=n))}return[o,i]}(t,e),s=r-n,a=i?0:s>0?s*o:1;return[Math.min(0,n-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(o,this.getY,e.extentPadding,d):l||c[0]===1/0||(c=function(t,e,o){if(!o.length)return t;let[i,n]=t;for(const t of e)for(const e of o){const o=e.getTop(t),r=e.getBottom(t);Number.isFinite(o)&&(i>o&&(i=o),o>n&&(n=o)),Number.isFinite(r)&&(i>r&&(i=r),r>n&&(n=r))}return[i,n]}(c,r,this.resolvedRibbons),c=function(t,e){const o=t[1]-t[0],i=e.exactMode?0:o>0?o*e.extentPadding:1,n=[null!=e.userMin?t[0]:t[0]-i,null!=e.userMax?t[1]:t[1]+i];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:d,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));c=function(t,e,o){if(!e||o)return t;const i=e[0],n=e[1];return null==i&&null==n?t:[null!=i?i:t[0],null!=n?n:t[1]]}(c,e.yExtent,!!l),({xDomain:a,yDomain:c}=function(t,e,o){let i=t,n=e;if(i[0]===1/0||i[1]===-1/0)if("time"===o){const t=Date.now();i=[t-864e5,t]}else i=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:i,yDomain:n}}(a,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:o,xDomain:i,yDomain:n}=t,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(o.width,o.height)/2-1));if(r){const t="left"===e.arrowOfTime?[o.width-s,s]:[s,o.width-s];return{x:(0,Yl.scaleLinear)().domain(i).range(t),y:Xl(e.yScaleType,n,[o.height-s,s])}}return{x:Xl(e.xScaleType,i,[s,o.width-s]),y:Xl(e.yScaleType,n,[o.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.lastLayout=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=h,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,o=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=o;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=o;for(const i of t.bottomPath)i[0]*=e,i[1]*=o;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*o,width:t.clipRect.width*e,height:t.clipRect.height*o}),t.strokeColorBands&&(t.strokeColorBands=t.strokeColorBands.map(t=>({...t,y:t.y*o,height:t.height*o})));break;case"point":case"glyph":t.x*=e,t.y*=o;break;case"rect":case"heatcell":t.x*=e,t.y*=o,t.w*=e,t.h*=o;break;case"candlestick":t.x*=e,t.openY*=o,t.closeY*=o,t.highY*=o,t.lowY*=o}const i=this.scales.x.domain(),n=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=Xl,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,r[0]>r[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,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:o,scales:i}=this;if(!i)return[];if(o.customLayout){const n={data:e,scales:i,dimensions:{width:t.width,height:t.height,margin:o.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:o.themeCategorical??nt},resolveColor:(t,e)=>{const i=this.resolveGroupColor(t);if(i)return i;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:o.themeSemantic?.primary??"#4e79a7"},config:o.layoutConfig??{},selection:o.layoutSelection??null};let r;try{r=o.customLayout(n)}catch(t){const e=null!==this.lastCustomLayoutResult,i=Dl("xy",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{o.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const s=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,o.layoutSelection??null)}return Fl({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:i,config:o,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(o.chartType){case"line":return function(t,e){const o=t.groupData(e),i=[],n=t.config.annotations?.filter(Al).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=vl(t.ribbons);if(r.length>0&&i.push(...wl(t,e,r)),n.length>0)for(const e of o)i.push(...kl(t,e.data,e.key,n))}for(const e of o){const o=t.resolveLineStyle(e.key,e.data[0]),r=dl(e.data,t.scales,t.getX,t.getY,o,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),i.push(r)}return Sl(t,o,i),i}(n,e);case"area":return function(t,e){const o=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=vl(t.ribbons);if(r.length>0&&i.push(...wl(t,e,r)),n.length>0)for(const e of o)i.push(...kl(t,e.data,e.key,n))}const n=t.scales.y.domain(),r=n[0],s=t.config.semanticLineStops?.filter(t=>Number.isFinite(t.offset)).map(t=>({value:n[0]+Math.max(0,Math.min(1,t.offset))*(n[1]-n[0]),color:t.color,opacity:t.opacity,thresholdType:"greater"})).sort((t,e)=>t.value-e.value),a=s&&s.length>0?(()=>{const e=s.reduce((t,e)=>(t.at(-1)?.value===e.value?t[t.length-1]=e:t.push(e),t),[]),o=[{from:n[0],to:e[0].value,color:e[0].color,opacity:e[0].opacity}];for(let t=0;e.length>t;t++)o.push({from:e[t].value,to:e[t+1]?.value??n[1],color:e[t].color,opacity:e[t].opacity});return o.map(({from:e,to:o,color:i,opacity:n})=>{const r=t.scales.y(e),s=t.scales.y(o);return{y:Math.min(r,s),height:Math.abs(s-r),color:i,...null!=n&&{opacity:n}}}).filter(t=>t.height>0)})():void 0,c=t.getY0?e=>{const o=t.getY0(e);return null==o?r:o}:void 0;for(const e of o){const o=t.resolveAreaStyle(e.key,e.data[0]),n=hl(e.data,t.scales,t.getX,t.getY,r,o,e.key,c),l=Ml(t.config.gradientFill);l&&(n.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),s&&s.length>0&&(n.colorThresholds=s,n.strokeColorBands=a),i.push(n)}return Sl(t,o,i),i}(n,e);case"mixed":return function(t,e){const o=t.groupData(e),i=[],n=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=vl(t.ribbons);if(r.length>0&&i.push(...wl(t,e,r)),n.length>0)for(const e of o)i.push(...kl(t,e.data,e.key,n))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const o=t.getY0(e);return null==o?r:o}:void 0;for(const e of o)if(n.has(e.key)){const o=t.resolveAreaStyle(e.key,e.data[0]),n=hl(e.data,t.scales,t.getX,t.getY,r,o,e.key,s),a=Ml(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),i.push(n)}else{const o=t.resolveLineStyle(e.key,e.data[0]),n=dl(e.data,t.scales,t.getX,t.getY,o,e.key);t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),i.push(n)}return Sl(t,o,i),i}(n,e);case"stackedarea":return function(t,e){const o=t.groupData(e),i=t.config.stackOrder??"key",n=()=>o.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===i);else if("key"===i)n();else if("asc"===i||"desc"===i||"insideOut"===i){const e=new Map;for(const i of o){let o=0;for(const e of i.data){const i=t.getX(e),n=t.getY(e);Number.isFinite(i)&&Number.isFinite(n)&&(o+=n)}e.set(i.key,o)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===i)o.sort((t,o)=>{const i=(e.get(t.key)??0)-(e.get(o.key)??0);return 0!==i?i:n(t.key,o.key)});else if("desc"===i)o.sort((t,o)=>{const i=(e.get(o.key)??0)-(e.get(t.key)??0);return 0!==i?i:n(t.key,o.key)});else{const t=[...o].sort((t,o)=>{const i=(e.get(o.key)??0)-(e.get(t.key)??0);return 0!==i?i:n(t.key,o.key)}),i=[],r=[];let s=0,a=0;for(const o of t)a>s?(i.push(o),s+=e.get(o.key)??0):(r.push(o),a+=e.get(o.key)??0);o.length=0,o.push(...r.reverse(),...i)}}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,o,i,n,r,s,a="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=o(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=o(n),r=i(n);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let d;if(r){d=new Map;for(const e of l){let o=0;for(const i of t)o+=u.get(i.key)?.get(e)||0;d.set(e,o||1)}}const h=fl(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!r,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of l)g.set(t,h.get(t)??0),m.set(t,0),x.set(t,0);for(const o of t){const t=u.get(o.key),i=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:c,style:n(o.key,o.data[0]),datum:o.data,group:o.key};s&&(t.curve=s),p.push(t)}a=[],c=[]};for(const o of l){const n=t.has(o);let s,l,u=n?t.get(o):0;if(r&&n&&(u/=d.get(o)),!n||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(o),l=s+u,m.set(o,l)):(s=x.get(o),l=s+u,x.set(o,l)):(s=g.get(o),l=s+u,g.set(o,l));const p=e.x(o);c.push([p,e.y(s)]),a.push([p,e.y(l)]),i.set(o,l)}h(),y.set(o.key,i)}return{nodes:p,stackedTops:y}}(o,t.scales,t.getX,t.getY,(e,o)=>t.resolveAreaStyle(e,o),t.config.normalize,r,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const i of o){const o=c.get(i.key);if(o)for(const n of i.data){const i=t.getX(n),r=t.getY(n);null==i||Number.isNaN(i)||null==r||Number.isNaN(r)||!o.has(i)||e.set(n,o.get(i))}}const i=o=>e.get(o)??t.getY(o);Sl(t,o,l,i)}return l}(n,e);case"scatter":case"bubble":return function(t,e){const o=[],i="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let r=null;if(t.getSize&&!t.config.pointStyle){const o=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(o.length>0){let t=1/0,e=-1/0;for(const i of o)t>i&&(t=i),i>e&&(e=i);r=o=>t===e?(n[0]+n[1])/2:n[0]+(o-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=c?Cl(c,t.config.symbolMap):null;for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},c=e.r||i;if(r&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(c=r(e))}if(s&&t.getColor&&!e.fill){const o=t.getColor(n);o&&s.has(o)&&(e={...e,fill:s.get(o)})}const u=t.getPointId?t.getPointId(n)+"":void 0;if(l){const i=l(n),r=yl(n,t.scales,t.getX,t.getY,Math.PI*c*c,i,e,u);r&&o.push(r)}else{const i=pl(n,t.scales,t.getX,t.getY,c,e,u);i&&o.push(i)}}return o}(n,e);case"heatmap":return function(t,e,o){if(t.config.heatmapAggregation)return function(t,e,o){const i=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=Xc(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),d=(c-a||1)/i,h=(u-l||1)/n,f=i*n;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let o=0;e.length>o;o++){const r=e[o],c=t.getX(r),u=t.getY(r);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),i-1),g=Math.min(Math.floor((u-l)/h),n-1);if(0>f||0>g)continue;const m=g*i+f;p[m]++;const x=s(r);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===p[t])continue;let e;switch(r){case"sum":e=y[t];break;case"mean":e=y[t]/p[t];break;default:e=p[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,b=t.config.heatmapColorScale,v=b?void 0:Tl("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),w=255/x,k=o.width/i,S=o.height/n,A=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let e=0;n>e;e++){const o=e*i;for(let s=0;i>s;s++){const i=o+s;if(0===p[i])continue;let c;switch(r){case"sum":c=y[i];break;case"mean":c=y[i]/p[i];break;default:c=p[i]}const u=Math.min((c-g)*w+.5|0,255),f=b?b(c):v[u],m={xi:s,yi:e,value:c,count:p[i],sum:y[i],xCenter:a+(s+.5)*d,yCenter:l+(e+.5)*h,agg:r};_.push(Ol(ml(s*k,(n-1-e)*S,k,S,f,m,A?{value:c,showValues:!0,valueFormat:M}:{value:c}),m,t))}}return _}(t,e,o);if(0===e.length)return[];const i=Xc(t.config.valueAccessor,"value"),n=Gc(t.config.xAccessor,"x"),r=Gc(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 o=e[t],i=n(o),u=r(o);c[t]=i,l[t]=u,s.has(i)||s.set(i,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(p){h.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;h.length>t;t++)s.set(h[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 o=e[t],n=s.get(c[t]),r=a.get(l[t]);if(void 0===n||void 0===r)continue;const d=i(o),h=r*u+n,f=b.get(h);let p;void 0!==f?p=f:(p=v++,b.set(h,p)),g[p]=h,m[p]=d,x[p]=o}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=t.config.heatmapColorScale,A=S?void 0:Tl("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),M=255/(k-w||1),_=o.width/u,P=o.height/d,j=t.config.showValues,L=t.config.heatmapValueFormat,$=[];for(let e=0;v>e;e++){const o=m[e];if(!isFinite(o))continue;const i=g[e],n=i%u,r=(i-n)/u,s=Math.min((o-w)*M+.5|0,255),a=S?S(o):A[s],c=x[e];$.push(Ol(ml(n*_,(d-1-r)*P,_,P,a,c,j?{value:o,showValues:!0,valueFormat:L}:{value:o}),c,t))}return $}(n,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=zl(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let i=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const o of t.categories.keys())e.add(o);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?i=t.barCategoryCache.order:(i=[...a,...s],t.barCategoryCache={key:c,order:i})}const n=[],r=t.scales,[s,a]=r.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity),c?.cursor&&(h.cursor=c.cursor);for(const e of o.values()){const o=Math.max(e.start,s),u=Math.min(e.end,a);if(o>=u)continue;const f=r.x(o),p=r.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(i&&e.categories.size>0){let o=0;for(const s of i){const i=e.categories.get(s)||0;if(0===i)continue;const a=r.y(o),u=r.y(o+i),d=Math.min(a,u),f=Math.abs(a-u),p=(t.config.barColors?ct(t.config.barColors,s):void 0)??c?.fill??l??"#4e79a7",y={binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:i},g=t.config.areaStyle?.(y)??{};n.push(gl(m,d,x,f,{fill:p,...h,...g},y,s)),o+=i}}else{const o=r.y(0),i=r.y(e.total),s=Math.min(o,i),a=Math.abs(o-i),u=c?.fill||l||"#007bff",d={binStart:e.start,binEnd:e.end,total:e.total},f=t.config.areaStyle?.(d)??{};n.push(gl(m,s,x,a,{fill:u,...h,...f},d))}}const f=new Set;for(const t of o.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 o=[],i=t.config.swarmStyle||{},n=i.radius??3,r=i.fill??t.config.themeSemantic?.primary??"#007bff",s=i.opacity??.7,a=i.stroke,c=i.strokeWidth,l=i.cursor;for(const i of e){const e=t.getX(i),u=t.getY(i);if(null==u||Number.isNaN(u))continue;const d=t.scales.x(e),h=t.scales.y(u);let f=r;if(t.getCategory){const e=t.getCategory(i)+"";f=(t.config.barColors?ct(t.config.barColors,e):void 0)??f}const{r:p,...y}=t.config.pointStyle?.(i)??{},g={type:"point",x:d,y:h,r:p??n,style:{fill:f,opacity:s,stroke:a,strokeWidth:c,cursor:l,...y},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),o.push(g)}return o}(n,e);case"waterfall":return function(t,e,o){const i=[],n=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const o=t.getY(e),i=t.getX(e);return null!=o&&!Number.isNaN(o)&&null!=i&&isFinite(i)});if(0===s.length)return i;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,d=r?.strokeWidth,h=r?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-y:e>0?y-t.getX(s[e-1]):0;const b=n.x(y),v=0!==x?n.x(y+x):b+o.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=0>g?c:a,j={...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth},L={fill:P,stroke:u,strokeWidth:d,opacity:h,cursor:r?.cursor,...t.config.areaStyle?.(j)};i.push(gl(w,M,k,_,L,j)),f=m}return i}(n,e,t);case"candlestick":return function(t,e,o){if(!t.getHigh||!t.getLow||!t.scales)return[];const i=t.config.candlestickRangeMode??!1;if(!(i||t.getOpen&&t.getClose))return[];const n=[],r=t.config.candlestickStyle||{},s=r.rangeColor||"#6366f1",a=i?s:r.upColor||"#28a745",c=i?s:r.downColor||"#dc3545",l=i?s:r.wickColor||"#333",u=r.wickWidth||(i?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=r.bodyWidth??0;if(null==r.bodyWidth)if(d.length>1){let e=1/0;for(let o=1;d.length>o;o++){const i=Math.abs(t.scales.x(d[o])-t.scales.x(d[o-1]));i>0&&e>i&&(e=i)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const s of e){const e=t.getX(s);if(null==e||Number.isNaN(e))continue;const d=t.getHigh(s),f=t.getLow(s);if(null==d||Number.isNaN(d)||null==f||Number.isNaN(f))continue;const p=i?d:t.getOpen(s),y=i?f:t.getClose(s);if(!i&&[p,y].some(t=>null==t||Number.isNaN(t)))continue;const g=y>=p,m={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(p),closeY:t.scales.y(y),highY:t.scales.y(d),lowY:t.scales.y(f),bodyWidth:h,upColor:a,downColor:c,wickColor:l,wickWidth:u,isUp:g,style:{cursor:r.cursor},datum:s};i&&(m.isRange=!0,m.dotRadius=Math.max(2,Math.min(h/2,.12*o.height))),n.push(m)}return n}(n,e,t);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,o,i){const n=t.boundsStyle;if("function"==typeof n)return n(o||{},e);if(n&&"object"==typeof n)return n;const r=i(e,o);return{fill:r.stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none",cursor:r.cursor}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const o=this.config.decay;return o&&e>1?nl(o,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=rl(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,o,i=rl(o)){const n=o.length;if(n>1)for(const o of e){if("line"===o.type){const e=Array.isArray(o.datum)?o.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let o=0;e.length>o;o++){const a=i.get(e[o]);null!=a?(r[o]=nl(t,a,n),1>r[o]&&(s=!0)):r[o]=1}s&&(o._decayOpacities=r);continue}if("area"===o.type){const e=Array.isArray(o.datum)?o.datum:[],r=o.topPath?o.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let o=0;e.length>o;o++){const r=i.get(e[o]);null!=r?(s[o]=nl(t,r,n),1>s[o]&&(a=!0)):s[o]=1}a&&(o._decayOpacities=s)}else{let s=1;for(const o of e){const e=i.get(o);if(null!=e){const o=nl(t,e,n);s>o&&(s=o)}}if(1>s){const t=Array(r);t.fill(s),o._decayOpacities=t}}continue}const e=i.get(o.datum);if(null==e)continue;const r=nl(t,e,n);"candlestick"===o.type?o._decayOpacity=r:o.style={...o.style,opacity:(o.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&&cl(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,o,i){o.clear(),i.clear();for(let n=0;e.length>n;n++){const r=e[n],s=ll(t,r,n);s&&("point"===r.type?o.set(s,{x:r.x,y:r.y,r:r.r,opacity:ul(r.style)}):"glyph"===r.type?o.set(s,{x:r.x,y:r.y,r:r.size,opacity:ul(r.style),glyph:r.glyph}):"rect"===r.type||"heatcell"===r.type?o.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:ul(r.style)}):"candlestick"===r.type?o.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:ul(r.style)}):"line"===r.type?i.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&i.set(s,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const o=this.scene[e],i=ll(this.transitionContext,o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:0,opacity:0}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:t,w:o.w,h:0,opacity:o.style.opacity??1}):"heatcell"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:0}):"line"===o.type?(o._introClipFraction=0,this.prevPathMap.set(i,{path:o.path.map(t=>[t[0],t[1]]),opacity:o.style.opacity})):"area"===o.type&&(o._introClipFraction=0,this.prevPathMap.set(i,{topPath:o.topPath.map(t=>[t[0],t[1]]),bottomPath:o.bottomPath.map(t=>[t[0],t[1]]),opacity:o.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,o,i,n,r=il()){if(0===i.size&&0===n.size)return o;const s=e.duration??300;if(o.exitNodes.length>0){const t=new Set(o.exitNodes);o.scene=o.scene.filter(e=>!t.has(e)),o.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let e=0;o.scene.length>e;e++){const r=o.scene[e],s=ll(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=i.get(s);if("point"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=ul(r.style),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=ul(r.style),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=ul(r.style),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=ul(r.style),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=ul(r.style),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=ul(r.style),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=ul(r.style),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=ul(r.style),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=ul(r.style),(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=ul(r.style),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 i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};o.exitNodes.push(i),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};o.exitNodes.push(i),a=!0}for(const[t,e]of i)if(!c.has(t)){if(t.startsWith("p:"))o.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)o.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:"))o.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:"))o.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const i=e.openY??e.y;o.exitNodes.push({type:"candlestick",x:e.x,openY:i,closeY:e.closeY??i,highY:e.highY??i,lowY:e.lowY??i,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),a&&(o.activeTransition={startTime:r,duration:s}),o}(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},o=function(t,e,o,i){if(!o.activeTransition)return!1;const n=el(t,o.activeTransition),r=tl(n,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of o.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style.opacity=ol(o?o.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=ol(o.x,t._targetX,r),t.y=ol(o.y,t._targetY,r),void 0!==t._targetR&&void 0!==o.r&&(t.r=ol(o.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style.opacity=ol(o?o.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=ol(o.x,t._targetX,r),t.y=ol(o.y,t._targetY,r),void 0!==t._targetR&&void 0!==o.r&&(t.size=ol(o.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style.opacity=ol(o?o.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=ol(o.x,t._targetX,r),t.y=ol(o.y,t._targetY,r),void 0!==o.w&&(t.w=ol(o.w,t._targetW,r)),void 0!==o.h&&(t.h=ol(o.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style={...t.style||{},opacity:ol(o?o.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=ol(o.x,t._targetX,r),t.y=ol(o.y,t._targetY,r),void 0!==o.w&&(t.w=ol(o.w,t._targetW,r)),void 0!==o.h&&(t.h=ol(o.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style={...t.style||{},opacity:ol(o?o.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=ol(o.x,t._targetX,r),void 0!==o.openY&&(t.openY=ol(o.openY,t._targetOpenY,r)),void 0!==o.closeY&&(t.closeY=ol(o.closeY,t._targetCloseY,r)),void 0!==o.highY&&(t.highY=ol(o.highY,t._targetHighY,r)),void 0!==o.lowY&&(t.lowY=ol(o.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:ol(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,o=t._targetPath;if(e&&o&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=ol(e[i][0],o[i][0],r),t.path[i][1]=ol(e[i][1],o[i][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:ol(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,o=t._prevBottomPath,i=t._targetTopPath,n=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let o=0;t.topPath.length>o;o++)t.topPath[o][0]=ol(e[o][0],i[o][0],r),t.topPath[o][1]=ol(e[o][1],i[o][1],r);if(o&&n&&o.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=ol(o[e][0],n[e][0],r),t.bottomPath[e][1]=ol(o[e][1],n[e][1],r)}}if(n>=1){for(const t of o.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 o=0;t.path.length>o;o++)t.path[o]=e[o];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,o=t._targetBottomPath;if(e)for(let o=0;t.topPath.length>o;o++)t.topPath[o]=e[o];if(o)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=o[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(o.exitNodes.length>0){const t=new Set(o.exitNodes);o.scene=o.scene.filter(e=>!t.has(e)),o.exitNodes=[]}return o.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,o}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,function(t){for(const e of t){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type)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("glyph"===e.type)void 0!==e._targetX&&(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||"heatcell"===e.type)void 0!==e._targetX&&(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)void 0!==e._targetX&&(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||"area"===e.type){if(e._introClipFraction=void 0,"line"===e.type&&e._targetPath){for(let t=0;e.path.length>t;t++)e.path[t]=e._targetPath[t];e._prevPath=void 0,e._targetPath=void 0}if("area"===e.type){if(e._targetTopPath)for(let t=0;e.topPath.length>t;t++)e.topPath[t]=e._targetTopPath[t];if(e._targetBottomPath)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=e._targetBottomPath[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}}}(this.scene),this.exitNodes=[]}groupData(t){const{result:e,cache:o}=function(t,e,o,i){if(i&&i.version===o&&i.group===e&&i.data===t)return{result:i.result,cache:i};let n;if(e){const o=new Map;for(const i of t){const t=e(i);o.has(t)||o.set(t,[]),o.get(t).push(i)}n=Array.from(o.entries()).map(([t,e])=>({key:t,data:e}))}else n=[{key:"_default",data:t}];return{result:n,cache:{version:o,group:e,data:t,result:n}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=o,e}resolveColorMap(t){const{map:e,cache:o}=function(t,e,o,i,n){if(n&&n.version===i)return{map:n.map,cache:n};const r=new Set;if(e)for(const o of t){const t=e(o);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(n&&n.key===a){const t={...n,version:i};return{map:t.map,cache:t}}const c=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical||nt,l=new Map;for(let t=0;s.length>t;t++)l.set(s[t],c[t%c.length]);return{map:l,cache:{key:a,map:l,version:i}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=o,e}resolveLineStyle(t,e){return function(t,e,o,i){const n=t.lineStyle;if("function"==typeof n){const t=n(o||{},e);if(t&&!t.stroke&&e){const o=i(e);if(o)return{...t,stroke:o}}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,cursor:n.cursor}:{stroke:i(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,o,i){if(t.areaStyle){const n=t.areaStyle(o||{});if(n&&!n.fill&&e){const t=i(e);if(t)return{...n,fill:t,stroke:n.stroke||t}}return n}const n=t.lineStyle;if("function"==typeof n){const t=n(o||{},e);if(t&&!t.fill&&e){const o=i(e);if(o)return{...t,fill:o,stroke:t.stroke||o}}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,cursor:n.cursor};const s=i(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:o,groupColorCounter:i}=function(t){const{group:e,colorMapCache:o,groupColorMap:i,groupColorMapCap:n,config:r}=t;let{groupColorCounter:s}=t;if(o){const t=o.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=i.get(e);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(r.colorScheme)&&r.colorScheme.length>0?r.colorScheme:null)||(Array.isArray(r.themeCategorical)&&r.themeCategorical.length>0?r.themeCategorical:null)||nt;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,i.set(e,l),i.size>n){const t=i.keys().next().value;void 0!==t&&i.delete(t)}return{color:l,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=i,o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Jc(t),o=this.getPointId,i=t=>e.has(o(t));Ul(this.buffer,this.timestampBuffer,i);const n=this.buffer.remove(i);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 o=Jc(t),i=this.getPointId,n=new Set;this.buffer.forEach((t,e)=>{o.has(i(t))&&n.add(e)});const r=this.buffer.update(t=>o.has(i(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{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 o=this._customRestyle;if(o)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},n=o(i,e);i.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},o=Object.keys(t).filter(o=>t[o]!==e[o]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let i=!1,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,o=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=r||!qc(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!qc(o,s);(a||c)&&(t?(this.getX=Xc(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Xc(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Xc(this.config.xAccessor,"x"),this.getY=Xc(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Wl(this.config)),i=!0,n=!0)}if("groupAccessor"in t&&!qc(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Vc(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in t&&!qc(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Vc(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in t&&!qc(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Xc(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in t&&!qc(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Vc(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in t&&!qc(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Vc(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in t&&!qc(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?Xc(this.config.y0Accessor,"y0"):void 0,i=!0,n=!0),("boundsAccessor"in t&&!qc(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=Wl(this.config),i=!0,n=!0),"pointIdAccessor"in t&&!qc(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Vc(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!qc(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!qc(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!qc(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!qc(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Xc(this.config.openAccessor,"open"):void 0,this.getHigh=Xc(this.config.highAccessor,"high"),this.getLow=Xc(this.config.lowAccessor,"low"),this.getClose=e?Xc(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,i=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(i=!0,n=!0),!i){const o=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of o)if(t[n]!==e[n]){i=!0;break}}i&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};bu.GROUP_COLOR_MAP_CAP=1e3;var vu=bu;iu(vu);var wu=c(require("react")),ku=require("d3-shape");function Su(t,e,o){let i=o;for(const o of e)"lesser"===o.thresholdType?o.value>t&&(i=o.color):t>o.value&&(i=o.color);return i}var Au=[40,40],Mu=[.5,.5];function _u(t,e){const[o,i]=t.viewBox??Au,[n,r]=t.anchor??Mu,s=i>0?i:1,a=Math.max(0,e)/s,c=(o>0?o:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-n*c,offsetY:-r*l}}function Pu(t,e,o,i){if("none"!==t)return"color"===t||null==t?e??i:"accent"===t?o:t}function ju(t,e){const o=_u(t,e);return{centerDx:o.offsetX+o.width/2,centerDy:o.offsetY+o.height/2,halfWidth:o.width/2,halfHeight:o.height/2,radius:Math.hypot(o.width,o.height)/2}}var Lu=require("react/jsx-runtime"),$u={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Ru(t,e="#4e79a7"){return xn(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function Cu(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function Iu(t,e,o,i){const n=t.glyph;if(!n?.parts?.length||0>=t.size)return null;const r=_u(n,t.size);if(0>=r.scale)return null;const s=`translate(${e},${o})${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,o=0,i="horizontal"){const[n,r]=t.viewBox??Au,s=Math.min(1,Math.max(0,o)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===i?{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?Cu(i+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),d=e=>n.parts.map((o,i)=>{const n=e?"none"===o.fill?void 0:e:Pu(o.fill,a,t.accent),r=e?o.stroke&&"none"!==o.stroke?e:void 0:Pu(o.stroke??"none",a,t.accent);return n||r?(0,Lu.jsx)("path",{d:o.d,fill:n??"none",stroke:r,strokeWidth:r?o.strokeWidth??1:void 0,strokeLinecap:o.strokeLinecap,strokeLinejoin:o.strokeLinejoin,opacity:o.opacity},i):null});return(0,Lu.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,Lu.jsx)("clipPath",{id:l,children:(0,Lu.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?(0,Lu.jsx)("g",{children:d(t.ghostColor)}):null,c&&l?(0,Lu.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},i)}function Tu(t,e){const o=t.filter(t=>Number.isFinite(t.offset)&&(null==t.opacity||Number.isFinite(t.opacity))).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color??e,opacity:null==t.opacity?void 0:Math.max(0,Math.min(1,t.opacity))}));return 2>o.length?null:o.map((t,e)=>(0,Lu.jsx)("stop",{offset:t.offset,stopColor:t.color,stopOpacity:t.opacity},e))}function Ou(t,e,o){const i=$l(t.symbolType,t.size,t.path);return(0,Lu.jsx)("path",{d:i,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?Ru(t.style.fill):"none",fillOpacity:t.style.fillOpacity,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${o??""}symbol-${e}`)}c(require("react"));var zu=require("react/jsx-runtime");function Fu(t){if(!1!==t?.interactive)return t?.style?.cursor}function Nu(t,e,o){const i=Fu(e);return i&&null!=t&&!1!==t?(0,zu.jsx)("g",{style:{cursor:i},"data-semiotic-mark-cursor":i,children:t},o):t}var Eu=c(require("react")),Du=require("d3-shape"),Bu=require("react/jsx-runtime");var Wu=c(require("react")),Yu=require("react/jsx-runtime");var qu=c(require("react")),Xu=require("d3-shape"),Gu=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function Vu(t){const{innerRadius:e,outerRadius:o,startAngle:i,endAngle:n}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=Gu(o,i),e=Gu(o,n);return`M0,0 L${t.x},${t.y} A${o},${o} 0 ${n-i>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=Gu(o,i),s=Gu(o,n),a=Gu(e,n),c=Gu(e,i),l=n-i>Math.PI?1:0;return`M${t.x},${t.y} A${o},${o} 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,(o-e)/2));if(0===s)return Vu({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,o-s))),c=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=n-i,u=t.roundStart&&t.roundEnd?l/2:l,d=!!t.roundStart&&u>a,h=!!t.roundEnd&&u>a;if(!d&&!h)return Vu({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=i+(d?a:0),p=n-(h?a:0),y=i+(d?c:0),g=n-(h?c:0),m=Gu(o,f),x=Gu(o,p),b=(o-s)*Math.cos(a),v=Gu(b,i),w=Gu(b,n),k=r?null:Gu(e,g),S=r?null:Gu(e,y),A=r?0:(e+s)*Math.cos(c),M=r?null:Gu(A,i),_=r?null:Gu(A,n),P=p-f>Math.PI?1:0,j=r?0:g-y>Math.PI?1:0;let L="";if(d)L+=`M${v.x},${v.y}`,L+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=Gu(o,i);L+=`M${t.x},${t.y}`}if(h)L+=` A${o},${o} 0 ${P} 1 ${x.x},${x.y}`,L+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=Gu(o,n);L+=` A${o},${o} 0 ${P} 1 ${t.x},${t.y}`}if(r)L+=" L0,0";else{if(h)L+=` L${_.x},${_.y}`,L+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=Gu(e,n);L+=` L${t.x},${t.y}`}if(d)L+=` A${e},${e} 0 ${j} 0 ${S.x},${S.y}`,L+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=Gu(e,i);L+=` A${e},${e} 0 ${j} 0 ${t.x},${t.y}`}}return L+=" Z",L}var Hu=require("react/jsx-runtime");function Uu(t){return 1e6>t?1e4>t?1e3>t?t+"":(t/1e3).toFixed(1)+"K":(t/1e3).toFixed(0)+"K":(t/1e6).toFixed(1)+"M"}function Ku(t,e){const o=t.datum;if(!o)return null;const i=[],n=o.__funnelStepLabel,r=Number(o.__funnelStepLabelX),s=Number(o.__funnelStepLabelY),a=Number(o.__funnelRowWidth);"string"!=typeof n||!Number.isFinite(r)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*n.length+16>a||i.push((0,Hu.jsx)("text",{x:r,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:n},e+"-funnel-step"));const c=Number(o.__funnelValue),l=Number(o.__funnelValueLabelX),u=Number(o.__funnelValueLabelY),d=Number(o.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&d>=60){const t=Number(o.__funnelPercent);let n=!0!==o.__funnelIsFirstStep&&Number.isFinite(t)?`${Uu(c)} (${.05>Math.abs(t-Math.round(t))?Math.round(t):t.toFixed(1)}%)`:Uu(c);7.8*n.length+16>d&&(n=Uu(c)),7.8*n.length+16>d||i.push((0,Hu.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:n},e+"-funnel-value"))}return i.length?(0,Hu.jsx)("g",{children:i},e+"-funnel-labels"):null}function Zu(t,e,o){return Nu(function(t,e,o){const i=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",n=o=>`ord-${t.type}-${i}-${e}-${o}`,r=`ord-${t.type}-${i}-${e}`;switch(t.type){case"rect":{const e=t,o=Cu(r)+"-grad",i=function(t,e){const o=t.fillGradient;if(!o||"object"!=typeof o)return null;let i=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?(i=t.x+t.w,n=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(i=t.x,n=t.y,r=t.x+t.w,s=t.y);const a=Tu(o.stops,Ru(t.style.fill));return a?(0,Lu.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:i,y1:n,x2:r,y2:s,children:a}):null}(e,o);let n,a;if(i)a=`url(#${o})`;else if(xn(e.style.fill)){const t=Cu(r)+"-hatch";n=bn(e.style.fill,t),a=`url(#${t})`}else a=Ru(e.style.fill);const c=i||n?(0,Hu.jsxs)("defs",{children:[i,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:o,w:i,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 o=Math.min(t.w,t.h)/2,i=t=>Math.max(0,Math.min(t??0,o));return{tl:i(e.tl),tr:i(e.tr),br:i(e.br),bl:i(e.bl)}}(t);let l=`M${e+r},${o}`;return l+=` L${e+i-s},${o}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+i},${o+s}`),l+=` L${e+i},${o+n-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+i-a},${o+n}`),l+=` L${e+c},${o+n}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${o+n-c}`),l+=` L${e},${o+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${e+r},${o}`),l+=" Z",l}(e);return(0,Hu.jsxs)(qu.Fragment,{children:[c,(0,Hu.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:o,y:i,w:n,h:s}=e;let l;switch(e.roundedEdge){case"right":l=`M${o},${i} L${o+n-t},${i} A${t},${t} 0 0 1 ${o+n},${i+t} L${o+n},${i+s-t} A${t},${t} 0 0 1 ${o+n-t},${i+s} L${o},${i+s} Z`;break;case"left":l=`M${o+n},${i} L${o+t},${i} A${t},${t} 0 0 0 ${o},${i+t} L${o},${i+s-t} A${t},${t} 0 0 0 ${o+t},${i+s} L${o+n},${i+s} Z`;break;case"bottom":l=`M${o},${i} L${o+n},${i} L${o+n},${i+s-t} A${t},${t} 0 0 1 ${o+n-t},${i+s} L${o+t},${i+s} A${t},${t} 0 0 1 ${o},${i+s-t} Z`;break;default:l=`M${o},${i+s} L${o},${i+t} A${t},${t} 0 0 1 ${o+t},${i} L${o+n-t},${i} A${t},${t} 0 0 1 ${o+n},${i+t} L${o+n},${i+s} Z`}return(0,Hu.jsxs)(qu.Fragment,{children:[c,(0,Hu.jsx)("path",{d:l,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return(0,Hu.jsxs)(qu.Fragment,{children:[c,(0,Hu.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}),Ku(e,r)]},r)}case"point":{const e=t;return(0,Hu.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:Ru(e.style.fill),opacity:e.style.opacity??e.style.fillOpacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return Ou(t,e,o);case"glyph":return Iu(t,t.x,t.y,`${o??""}ord-glyph-${t.pointId??e}`);case"wedge":{const i=t;if(i._gradientBand&&i._gradientBand.colors.length>0){const t=Cu(`${o?o+"-":""}gauge-grad-${i.category||r}-${e}`),{clipPath:n,slices:s}=function(t){const e=Vu({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),o=[],i=t.colors;if(i.length>0){const e=(t.endAngle-t.startAngle)/i.length;for(let n=0;i.length>n;n++)o.push({d:Vu({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+n*e,endAngle:t.endAngle}),color:i[n]})}return{clipPath:e,slices:o}}({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,Hu.jsxs)("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[(0,Hu.jsx)("defs",{children:(0,Hu.jsx)("clipPath",{id:t,children:(0,Hu.jsx)("path",{d:n})})}),(0,Hu.jsx)("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>(0,Hu.jsx)("path",{d:t.d,fill:Ru(t.color)},e))}),i.style.stroke&&"none"!==i.style.stroke&&(0,Hu.jsx)("path",{d:n,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},r)}let n;if(i.roundedEnds)n=Vu({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const t=(0,Xu.arc)().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),n=t($u)||""}return(0,Hu.jsx)("path",{d:n,transform:`translate(${i.cx},${i.cy})`,fill:Ru(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},r)}case"boxplot":{const e=t,o=e.columnWidth/2,i=e.style.strokeWidth??1;return(0,Hu.jsxs)("g","vertical"===e.projection?{children:[(0,Hu.jsx)("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,Hu.jsx)("rect",{x:e.x-o,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:Ru(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,Hu.jsx)("line",{x1:e.x-o,y1:e.medianPos,x2:e.x+o,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2*i}),(0,Hu.jsx)("line",{x1:e.x-.5*o,y1:e.minPos,x2:e.x+.5*o,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,Hu.jsx)("line",{x1:e.x-.5*o,y1:e.maxPos,x2:e.x+.5*o,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:i})]}:{children:[(0,Hu.jsx)("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,Hu.jsx)("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-o,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:Ru(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,Hu.jsx)("line",{x1:e.medianPos,y1:e.y-o,x2:e.medianPos,y2:e.y+o,stroke:e.style.stroke||"#333",strokeWidth:2*i}),(0,Hu.jsx)("line",{x1:e.minPos,y1:e.y-.5*o,x2:e.minPos,y2:e.y+.5*o,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,Hu.jsx)("line",{x1:e.maxPos,y1:e.y-.5*o,x2:e.maxPos,y2:e.y+.5*o,stroke:e.style.stroke||"#333",strokeWidth:i})]},r)}case"violin":{const e=t,o=[(0,Hu.jsx)("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:Ru(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,i=t.x+t.width/2,r=t.y+t.height/2;e.iqrLine.isVertical?o.push((0,Hu.jsx)("line",{x1:i,y1:e.iqrLine.q1Pos,x2:i,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,Hu.jsx)("circle",{cx:i,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med"))):o.push((0,Hu.jsx)("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,Hu.jsx)("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med")))}return(0,Hu.jsx)("g",{children:o},r)}case"connector":{const e=t,o=e.style.fill&&"none"!==e.style.fill?Ru(e.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";return(0,Hu.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||o,strokeWidth:e.style.strokeWidth??1,opacity:e.style.opacity??.5},r)}case"trapezoid":{const e=t,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return(0,Hu.jsx)("polygon",{points:o,fill:Ru(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}var s}(t,e,o),t,"ordinal-cursor-"+e)}var Qu=require("react/jsx-runtime");function Ju(t,e,o,i){if(!t||2>e.length)return null;const n=Tu(t.stops,i);return n?(0,Qu.jsx)("linearGradient",{id:o,gradientUnits:"userSpaceOnUse",x1:e[0][0],y1:0,x2:e[e.length-1][0],y2:0,children:n}):null}function td(t,e,o,i=30){const n=function(t,e,o,i=30){switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const n=Ha(i.curve),r=n?(0,ku.line)().x(([t])=>t).y(([,t])=>t).curve(n)(i.path)??"":"M"+i.path.map(([t,e])=>`${t},${e}`).join("L"),s=Cu(`${o?o+"-":""}line-${e}-stroke-gradient`),a=Ju(i.strokeGradient,i.path,s,i.style.stroke||"#4e79a7");return(0,Qu.jsxs)(wu.Fragment,{children:[a&&(0,Qu.jsx)("defs",{children:a}),(0,Qu.jsx)("path",{d:r,fill:"none",stroke:a?`url(#${s})`:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})]},"line-"+e)}case"area":{const n=t;if(0===n.topPath.length)return null;const r=Ha(n.curve),s=!r||2>n.topPath.length||2>n.bottomPath.length?`M${n.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`:(0,ku.area)().x(([t])=>t).y0((t,e)=>n.bottomPath[e][1]).y1(([,t])=>t).curve(r)(n.topPath)??"",a=`${o?o+"-":""}area-${e}-hatch`,c=xn(n.style.fill)?bn(n.style.fill,a):void 0,l=Cu(`${o?o+"-":""}area-${e}-gradient`),u=function(t,e){const o=t.fillGradient;if(!o||"object"!=typeof o)return null;let i=1/0;for(const[,e]of t.topPath)i=Math.min(i,e);let n=-1/0;for(const[,e]of t.bottomPath)n=Math.max(n,e);if(!Number.isFinite(i)||!Number.isFinite(n))return null;const r=Tu(o.stops,Ru(t.style.fill));return r?(0,Qu.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:0,y1:i,x2:0,y2:n,children:r}):null}(n,l),d=u?`url(#${l})`:c?`url(#${a})`:Ru(n.style.fill),h=u?void 0:n.style.fillOpacity??n.style.opacity??.7,f=r?(0,ku.line)().x(([t])=>t).y(([,t])=>t).curve(r)(n.topPath)??"":"M"+n.topPath.map(([t,e])=>`${t},${e}`).join("L"),p=Fu(n),y=p&&i>=0?(0,Qu.jsx)("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*i),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${e}-cursor-target`):null,g=Cu(`${o?o+"-":""}area-${e}-stroke-gradient`),m=!(!n.colorThresholds?.length||!n.rawValues||n.rawValues.length!==n.topPath.length),x=!!n.strokeColorBands?.length,b=m||x?null:Ju(n.strokeGradient,n.topPath,g,n.style.stroke||"#4e79a7"),v=n.style.strokeWidth??2;let w=1/0,k=-1/0;for(const[t]of n.topPath)w>t&&(w=t),t>k&&(k=t);const S=x?n.strokeColorBands.map((t,i)=>Cu(`${o?o+"-":""}area-${e}-stroke-band-${i}`)):[],A=x?n.strokeColorBands.map((t,e)=>(0,Qu.jsx)("clipPath",{id:S[e],children:(0,Qu.jsx)("rect",{x:w-v,y:t.y,width:k-w+2*v,height:t.height})},S[e])):null,M=n.style.stroke&&"none"!==n.style.stroke?x?n.strokeColorBands.map((t,o)=>(0,Qu.jsx)("path",{d:f,fill:"none",stroke:t.color??Ru(n.style.stroke),strokeWidth:v,opacity:(n.style.opacity??1)*(t.opacity??1),clipPath:`url(#${S[o]})`},`area-${e}-stroke-band-${o}`)):m?function(t,e,o,i){if(2>t.length||e.length!==t.length||0===o.length)return[];const n=[],r=(t,e,o)=>{const i=n[n.length-1];i?.color===t?i.path.push(o):n.push({color:t,path:[e,o]})};for(let n=1;t.length>n;n++){const[s,a]=t[n-1],[c,l]=t[n],u=e[n-1],d=e[n]-u,h=[0,...0===d?[]:o.map(({value:t})=>(t-u)/d).filter(t=>t>0&&1>t&&Number.isFinite(t)).sort((t,e)=>t-e).filter((t,e,o)=>0===e||t!==o[e-1]),1];for(let t=1;h.length>t;t++){const e=h[t-1],n=h[t];r(Su(u+d*((e+n)/2),o,i),[s+(c-s)*e,a+(l-a)*e],[s+(c-s)*n,a+(l-a)*n])}}return n}(n.topPath,n.rawValues,n.colorThresholds,Ru(n.style.stroke)).map((t,o)=>(0,Qu.jsx)("path",{d:"M"+t.path.map(([t,e])=>`${t},${e}`).join("L"),fill:"none",stroke:t.color,strokeWidth:v,opacity:n.style.opacity},`area-${e}-threshold-${o}`)):(0,Qu.jsx)("path",{d:f,fill:"none",stroke:b?`url(#${g})`:Ru(n.style.stroke),strokeWidth:v,opacity:n.style.opacity}):null;if(n.clipRect){const t=`${o?o+"-":""}area-clip-${e}`;return(0,Qu.jsxs)("g",{children:[(0,Qu.jsxs)("defs",{children:[u,!u&&c,b,A,(0,Qu.jsx)("clipPath",{id:t,children:(0,Qu.jsx)("rect",{x:n.clipRect.x,y:n.clipRect.y,width:n.clipRect.width,height:n.clipRect.height})})]}),(0,Qu.jsxs)("g",{clipPath:`url(#${t})`,children:[(0,Qu.jsx)("path",{d:s,fill:d,fillOpacity:h,opacity:u?n.style.opacity:void 0,stroke:"none"}),M,y]})]},"area-"+e)}return(0,Qu.jsxs)(wu.Fragment,{children:[(u||c||b||A)&&(0,Qu.jsxs)("defs",{children:[u,!u&&c,b,A]}),(0,Qu.jsx)("path",{d:s,fill:d,fillOpacity:h,opacity:u?n.style.opacity:void 0,stroke:"none"}),M,y]},"area-"+e)}case"point":{const i=t,n=`${o?o+"-":""}point-${e}-hatch`,r=xn(i.style.fill)?bn(i.style.fill,n):void 0;return(0,Qu.jsxs)(wu.Fragment,{children:[r&&(0,Qu.jsx)("defs",{children:r}),(0,Qu.jsx)("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#${n})`:Ru(i.style.fill),opacity:i.style.opacity??i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"point-"+e)}case"symbol":return Ou(t,e);case"glyph":return Iu(t,t.x,t.y,`${o??""}glyph-${t.pointId??e}`);case"rect":{const i=t,n=`${o?o+"-":""}xyrect-${e}-hatch`,r=xn(i.style.fill)?bn(i.style.fill,n):void 0;return(0,Qu.jsxs)(wu.Fragment,{children:[r&&(0,Qu.jsx)("defs",{children:r}),(0,Qu.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:r?`url(#${n})`:Ru(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"rect-"+e)}case"heatcell":{const o=t,i={x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill,stroke:o.style?.stroke,strokeWidth:o.style?.strokeWidth,...null!=o.style?.opacity&&{opacity:o.style.opacity}};if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const t=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[n,r,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*n+.587*r+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return(0,Qu.jsxs)("g",{children:[(0,Qu.jsx)("rect",{...i}),(0,Qu.jsx)("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:t})]},"heatcell-"+e)}return(0,Qu.jsx)("rect",{...i},"heatcell-"+e)}case"candlestick":{const o=t;if(o.isRange){const t=o.dotRadius??Math.max(2,o.bodyWidth/2);return(0,Qu.jsxs)("g",{children:[(0,Qu.jsx)("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),(0,Qu.jsx)("circle",{cx:o.x,cy:o.highY,r:t,fill:o.wickColor}),(0,Qu.jsx)("circle",{cx:o.x,cy:o.lowY,r:t,fill:o.wickColor})]},"candle-"+e)}const i=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),r=o.isUp?o.upColor:o.downColor;return(0,Qu.jsxs)("g",{children:[(0,Qu.jsx)("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),(0,Qu.jsx)("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:n,fill:r,stroke:r,strokeWidth:1})]},"candle-"+e)}default:return null}}(t,e,o,i);return"area"===t.type?n:Nu(n,t,"xy-cursor-"+e)}var ed=new Set;function od(t){const{node:e,index:o,renderMode:i,fallback:n}=t,r=function(t,e){const o="function"==typeof t?t(e.datum??null,e):t;return(i=o)&&"object"==typeof i&&"string"==typeof i.id&&"function"==typeof i.cacheKey&&"function"==typeof i.drawCanvas&&"function"==typeof i.renderStaticSVG?o:void 0;var i}(i,e);if(!r)return{element:n(),renderedByBackend:!1};const s=r.renderStaticSVG({node:e,style:e.style??{},key:`${r.id}-${o}`});return null!=s?{element:Nu(s,e,`${r.id}-${o}-cursor`),renderedByBackend:!0}:(function(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const o=`${t}:${e}`;ed.has(o)||(ed.add(o),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}(r.id,e.type??"unknown"),{element:n(),renderedByBackend:!1})}function id(t){const e=[];return t.nodes.forEach((o,i)=>{const n=od({node:o,index:i,renderMode:t.renderMode,fallback:()=>t.fallback(o,i)});null!=n.element&&!1!==n.element&&e.push({node:o,index:i,...n})}),e}var nd=require("d3-scale"),rd=require("react/jsx-runtime"),sd=xe;function ad(t,e,o){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>ct(t,e)??"#999"}const i=Array.isArray(e)?e:o.colors.categorical.length>0?o.colors.categorical:C;return(0,nd.scaleOrdinal)().domain(t).range(i)}function cd(t,e,o){if(0===t.length)return;const i=ad(t,e,o);return{legendGroups:[{label:"",type:"fill",items:t.map(t=>({label:t})),styleFn:t=>({fill:i(t.label)})}]}}function ld(t){return"left"===t?"start":"right"===t?"end":t??"start"}function ud(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function dd(t){return t.typography.legendFontFamily??t.typography.fontFamily}function hd(t){return t.typography.legendFontWeight}function fd(t,e,o,i){const n=ud(i);return e+o+Math.ceil(t.length*n*.58)}function pd(t){const{categories:e,theme:o,position:i="right",totalWidth:n,margin:r,legendLayout:s}=t,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=We(s),d=a+c,h="top"===i||"bottom"===i,f=Math.max(a,n-r.left-r.right),p=e.map(t=>fd(t,a,c,o));if(h){const t=Math.max(a,s?.maxWidth??f),o=[];let i=0,n=0;p.forEach((e,r)=>{const s=0===n?e:n+l+e;n>0&&s>t?(o.push({start:i,end:r,width:n}),i=r,n=e):n=s}),e.length>0&&o.push({start:i,end:e.length,width:n});const r=ld(s?.align),c=[];return o.forEach((o,i)=>{let n="center"===r?Math.max(0,(t-o.width)/2):"end"===r?Math.max(0,t-o.width):0;for(let t=o.start;o.end>t;t++)c.push({category:e[t],width:p[t],x:n,y:i*u}),n+=p[t]+l}),{items:c,width:Math.max(0,...o.map(t=>t.width)),height:o.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}const y=Math.max(0,...p);return{items:e.map((t,e)=>({category:t,width:p[e],x:0,y:e*u})),width:y,height:e.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}function yd(t,e){if(!e||!t||0===t.length)return[];const o="function"==typeof e?e:t=>t[e],i=new Set;for(const e of t){const t=o(e);null!=t&&i.add(t+"")}return Array.from(i)}var gd=require("react/jsx-runtime");function md(t,e=120,o=8){if(!t)return[];const i=Math.max(1,Math.floor(e/o)),n=t.split(/\s+/),r=[];let s="";for(const t of n)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function xd(t,e,o,i){return"curly"===t?i?`M0,0 C${.6*o},0 ${.4*o},${e/2} ${o},${e/2} C${.4*o},${e/2} ${.6*o},${e} 0,${e}`:`M0,0 C0,${.6*o} ${e/2},${.4*o} ${e/2},${o} C${e/2},${.4*o} ${e},${.6*o} ${e},0`:i?`M0,0 L${o},0 L${o},${e} L0,${e}`:`M0,0 L0,${o} L${e},${o} L${e},0`}function bd(t,e,o,i){if(!t)return(0,gd.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,gd.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(o)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>e?"right":"left":0>o?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>e?"end":"start";const f=16,p=r?l?[r]:md(r,c):[],y=n?l?[n]:md(n,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push((0,gd.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+(r&&n?2:0))+f,style:{overflow:"visible"},children:(0,gd.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:[r&&(0,gd.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),n&&(0,gd.jsx)("div",{className:"annotation-note-label",children:n})]})},"annotation-note-html")):(p.length>0&&(x.push((0,gd.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((t,e)=>(0,gd.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,gd.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((t,e)=>(0,gd.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((r||n)&&(0!==e||0!==o))if("topBottom"===u){const t=Math.min(c,120);let e=0,o=t;"end"===h?(e=-t,o=0):"middle"===h&&(e=-t/2,o=t/2),v=(0,gd.jsx)("line",{className:"note-line",x1:e,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,o=t;"bottom"===d?(e=-t,o=0):"middle"===d&&(e=-t/2,o=t/2),v=(0,gd.jsx)("line",{className:"note-line",x1:0,x2:0,y1:e,y2:o,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>o?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>o?-(w+2):18),(0,gd.jsxs)("g",{className:"annotation-note",transform:`translate(${e},${o})`,children:[(0,gd.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function vd(t,e,o,i,n){const r=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&r.push((0,gd.jsx)("circle",{r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,i=e?.height||0;(t>0||i>0)&&r.push((0,gd.jsx)("rect",{width:t,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&r.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=i||0,s=n||0;if(void 0!==e?.x){const i=(e.x||0)-t;r.push((0,gd.jsx)("line",{x1:i,y1:(e.y1||0)-s,x2:i,y2:(e.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const i=(e.y||0)-s;r.push((0,gd.jsx)("line",{x1:(e.x1||0)-t,y1:i,x2:(e.x2||0)-t,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?r.push((0,gd.jsx)("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||r.push((0,gd.jsx)("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",i=e?.width??e?.height;void 0!==i&&r.push((0,gd.jsx)("path",{d:xd(t,i,e?.depth||30,void 0===e?.width),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,gd.jsx)("g",{className:"annotation-subject",children:r})}function wd(t,e,o,i,n,r){const s=[];let a=0,c=0;if("callout-circle"!==n&&"label"!==n||!r?.radius){if("callout-rect"===n&&r){const o=r.width||0,i=r.height||0;if(o>0||i>0){const n=o/2,r=i/2,s=t-n,l=e-r;if(0!==s||0!==l){const t=Math.abs(s),e=Math.abs(l),u=o/2,d=i/2,h=t*d>e*u?u/t:d/e;a=n+s*h,c=r+l*h}}}else if("bracket"===n&&r){const t=r.width,e=r.height,o=r.depth||30;void 0!==t?(a=t/2,c=o):void 0!==e&&(a=o,c=e/2)}}else{const o=(r.radius||0)+(r.radiusPadding||0);if(o>0&&(0!==t||0!==e)){const i=Math.atan2(e,t);a=Math.cos(i)*o,c=Math.sin(i)*o}}const l=Math.sqrt((t-a)**2+(e-c)**2);if(l>.5){const n=i||"var(--semiotic-text-secondary, currentColor)",r="curve"===o?.type;let u=Math.atan2(e-c,t-a);if(r){const i=(a+t)/2,r=(c+e)/2,d=-(e-c)/l,h=(t-a)/l,f=(o?.curve??.25)*l,p=i+d*f,y=r+h*f;s.push((0,gd.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,gd.jsx)("line",{x1:a,y1:c,x2:t,y2:e,stroke:n},"connector-line"));if("arrow"===o?.end){const t=10,e=16/180*Math.PI;s.push((0,gd.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,gd.jsx)("g",{className:"annotation-connector",children:s})}function kd(t){const{x:e=0,y:o=0,dx:i,dy:n,nx:r,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(o)?o[0]??0:o,v=new Set(Array.isArray(f)?f:[]);let w=i||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,gd.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")&&wd(w,k,c,d,S,l),!v.has("subject")&&vd(S,l,d,x,b),!v.has("note")&&bd(a,w,k,d)]})}function Sd(t){const{noteData:e}=t,{screenCoordinates:o}=e,i="string"==typeof e.type?e.type:"label",n=e.eventListeners||e.events||{};if(e.coordinates&&o){const t=e.nx||o[0][0]+(e.dx??0),n=e.ny||o[0][1]+(e.dy??0),r=o.map((o,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:o[0],y:o[1],nx:t,ny:n});return(0,gd.jsx)(kd,{"data-testid":"semiotic-annotation",...s,type:i},"multi-annotation-"+r)});return(0,gd.jsx)("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return(0,gd.jsx)(kd,{"data-testid":"semiotic-annotation",events:n,...e,type:i},s)}var Ad=require("react/jsx-runtime"),Md={secondary:0,primary:3},_d=1,Pd=2,jd=.6,Ld="0.88em",$d=.95,Rd=.72,Cd=.06,Id=".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}}",Td=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Od(t){return!0===t?._annotationDeferred}function zd(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function Fd(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function Nd(t){return Math.max(Rd,$d-t*Cd)}function Ed(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(o=t.annotation,"primary"===o?.emphasis||"secondary"===o?.emphasis?o.emphasis:null),confidence:Fd(t.annotation),readingOrder:null,rank:_d};var o}),o=e.some(t=>null!=t.emphasis||null!=t.confidence),i=t.some(t=>Od(t.annotation)),n=t.some(t=>null!=zd(t.annotation)),r=t.some(t=>"layer"===zd(t.annotation));if(!o&&!i&&!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=Pd-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Md[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:o,emphasis:i,readingOrder:n}=t,r=Od(e.annotation);let s=e.node;if("primary"===i||"secondary"===i||null!=n){const t=null==i&&null!=n;s=(0,Ad.jsx)("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i,..."secondary"===i?{opacity:jd,fontSize:Ld}:{},...t?{opacity:Nd(n),"data-annotation-reading-order":n}:{},children:e.node},"annotation-emphasis-"+o)}const a=zd(e.annotation);return a&&(s=(0,Ad.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+o)),r&&(s=(0,Ad.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+o)),s});return i&&a.unshift((0,Ad.jsx)("style",{children:Id},"annotation-disclosure-style")),r&&a.unshift((0,Ad.jsx)("style",{children:Td},"annotation-cohesion-style")),a}function Dd(t,e){const o=e.scales?.x??e.scales?.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function Bd(t,e){const o=e.scales?.y??e.scales?.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function Wd(t){return null==t?null:t+""}function Yd(t,e,o){return e.stickyPositionCache?.set(t,o),o}function qd(t,e,o){const i=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=t.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let i=o.pointNodes.length-1;i>=0;i--){const n=o.pointNodes[i];if(n.pointId===t.pointId)return Yd(e,o,{x:n.x,y:n.y})}const i=function(t){const e=t.data;if(!e||0===e.length)return null;const o=e[e.length-1],i=t.scales?.x??t.scales?.time,n=t.scales?.y??t.scales?.value;if(!i||!n)return null;const r=o[t.xAccessor||"x"],s=o[t.yAccessor||"y"];return null==r||null==s?null:{x:i(r),y:n(s)}}(o);return i?Yd(e,o,i):null}if("semantic"===i){const i=function(t,e,o){const i=function(t){return Wd(t.provenance?.stableId??t.stableId)}(t);if(!i)return null;const n=o.pointNodes?.find(t=>Wd(t.pointId)===i);if(n)return Yd(e,o,{x:n.x,y:n.y});const r=o.data?.find(t=>function(t){return Wd(t.stableId??t.id??t.provenance?.stableId)}(t)===i);if(!r)return null;const s=Dd(r,o),a=Bd(r,o);return null==s||null==a?null:Yd(e,o,{x:s,y:a})}(t,e,o);if(i)return i}let n=null,r=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);e&&(n=e.x,r=e.y)}if(null!=n&&null!=r||(n=Dd(t,o),r=Bd(t,o)),null!=n&&null!=r)return Yd(e,o,{x:n,y:r});if("sticky"===i){const t=o.stickyPositionCache?.get(e);if(t)return t}return null}var Xd=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Gd(t){return!!t&&"object"==typeof t&&Xd.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}new Set(["label","callout","callout-circle","callout-rect"]);var Vd=2e4,Hd=1;function Ud(t){return"primary"===t?.emphasis||!0===t?.defensive}function Kd(t,e,o={}){return"number"==typeof o.maxAnnotations&&Number.isFinite(o.maxAnnotations)?Math.max(0,Math.floor(o.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(o.areaPerAnnotation&&o.areaPerAnnotation>0?o.areaPerAnnotation:Vd))):1/0}function Zd(t){let e;const o=t?.emphasis;e="primary"===o?100:"secondary"===o?10:50;const i=t?.provenance?.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(e+=15*Math.max(0,Math.min(1,i))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}var Qd=32,Jd=6,th=4,eh=8,oh=72,ih=30,nh=-30,rh=8,sh=480,ah=3;var ch={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function lh(t){if(!uh(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 uh(t){return Gd(t)}function dh(t,e){if(!t)return[];const o=Math.max(1,Math.floor(e/7)),i=t.split(/\s+/).filter(Boolean),n=[];let r="";for(const t of i)r&&r.length+t.length+1>o?(n.push(r),r=t):r=r?`${r} ${t}`:t;return r&&n.push(r),n}function hh(t,e,o,i,n){const r=t+o,s=e+i;return Math.abs(o)>Math.abs(i)?{x:0>o?r-n.width-4:r+4,y:0>i?s-n.height:s,width:n.width,height:n.height}:{x:0>o?r-n.width:r,y:0>i?s-n.height-4:s+4,width:n.width,height:n.height}}function fh(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function ph(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 yh(t,e,o,i,n,r,s,a){const c=fh(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,o,i){const n=Math.max(0,i-t.x),r=Math.max(0,i-t.y);return(n+Math.max(0,t.x+t.width-(e-i)))*t.height+(r+Math.max(0,t.y+t.height-(o-i)))*t.width}(c,n,r,a);for(const t of o)l+=12*ph(c,t);for(const t of i)l+=4*ph(c,t);return l}function gh(t){const{annotations:e,context:o,defaultOffset:i=Qd,notePadding:n=Jd,markPadding:r=th,edgePadding:s=eh,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=oh,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=o.width||0,x=o.height||0,b="object"==typeof p?p:{},v=b.breakpoint??sh,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(lh):e,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const P=[],j=function(t,e){return(t.pointNodes||[]).map(t=>{const o=Math.max(1,t.r||1)+e;return{x:t.x-o,y:t.y-o,width:2*o,height:2*o}})}(o,r);let L=!1;const $=k.map((t,e)=>{if(!uh(t))return t;const r=function(t,e,o){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const i=t.pointId??t.nodeId;if(null!=i&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===i);if(t)return{x:t.x,y:t.y}}const n=t.coordinates,r=o.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 o=r([t,e]);if(o&&"number"==typeof o[0]&&"number"==typeof o[1])return{x:o[0],y:o[1]}}}return o.scales||"number"!=typeof t.x||"number"!=typeof t.y?qd(t,e,o):{x:t.x,y:t.y}}(t,e,o);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,o=[...dh("string"==typeof t.title?t.title:void 0,e),...dh("string"==typeof t.label?t.label:void 0,e)],i=o.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*i)+10),height:Math.max(18,16*o.length+6)}}(t);if(a&&("number"==typeof(d=t).dx||"number"==typeof d.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:ih,dy:nh}}(t);return P.push(fh(hh(r.x,r.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),n)),t}var d;let h=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(i)){const e=yh(hh(r.x,r.y,t.dx,t.dy,u),t,P,j,m,x,n,s);f>e&&(h=t,f=e)}if(!h)return t;const p=fh(hh(r.x,r.y,h.dx,h.dy,u),n);P.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return L=!0,{...t,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),R=L?$:k.slice();let C=R;if(h){let t=!1;const e=R.map(e=>{const o=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)<rh?t:{...t,_redundantConnector:!0}}(e);return o!==e&&(t=!0),o});C=t?e:R}{let t=!1;const e=C.map(e=>{if(!0!==e?.defensive)return e;const o=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const o="string"==typeof e.source?Object.prototype.hasOwnProperty.call(ch,e.source)?ch[e.source]:e.source:null,i="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!o&&!i)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const n=[o,i].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${n})`)?t:{...t,label:r?`${r} (${n})`:`(${n})`}}(e);return o!==e&&(t=!0),o});C=t?e:C}const I=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 ah;const o=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===o.length?ah:o.reduce((t,e)=>t+e,0)/o.length}(t);return e>2?4>e?1:.6:1.5}(g),o=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??Kd(m,x,t))*e))},{deferred:i}=function(t){const{annotations:e,width:o,height:i}=t,n=Math.max(0,t.minVisible??Hd),r=Kd(o,i,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(o=t,Gd(o))};var o}),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=>Ud(t.annotation)),l=a.filter(t=>!Ud(t.annotation)).sort((t,e)=>Zd(e.annotation)-Zd(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))),d=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),h=[],f=[];for(const{annotation:t,index:e,note:o}of s)!o||d.has(e)?h.push(t):f.push(t);return{visible:h,deferred:f,budget:r}}({annotations:C,width:m,height:x,...o});for(const t of i)I.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:sh)>=m)for(const t of C)uh(t)&&"secondary"===t.emphasis&&I.add(t);if(I.size>0)for(const t of C)!0===t?.defensive&&I.delete(t);let T;return T=0===I.size?C:A?C.map(t=>I.has(t)?{...t,_annotationDeferred:!0}:t):C.filter(t=>!I.has(t)),_?function(t,e){let o=!1;const i=t.map(t=>uh(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(o=!0,{...t,cohesion:e}):t);return o?i:t}(T,_):T}var mh=require("react/jsx-runtime"),xh="var(--semiotic-bg, #ffffff)",bh=.85;function vh(t){const{x:e,y:o,text:i,fill:n,fontSize:r=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:d}=t,h=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,mh.jsx)("text",{x:e,y:o,textAnchor:c,dominantBaseline:l,fill:n,fontSize:r,fontWeight:s,fontFamily:a,className:d,...t?{style:{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}}:{},children:i});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??xh,strokeWidth:h.haloWidth??3});const p=h.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}(i,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?o-x/2:"hanging"===l||"text-before-edge"===l?o-g:o-.8*r-g,(0,mh.jsxs)("g",{className:d,children:[(0,mh.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:h.radius??3,ry:h.radius??3,fill:h.fill??xh,fillOpacity:h.opacity??bh,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function wh(t,e,o,i){const n=function(t,e,o="#4e79a7"){if(xn(t)){const o=function(t,e){let o=2166136261;const i=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;i.length>t;t++)o^=i.charCodeAt(t),o=Math.imul(o,16777619);return`${t}-hatch-${(o>>>0).toString(36)}`}(e,t);return{fill:`url(#${o})`,def:bn(t,o)}}return t&&"string"==typeof t?{fill:t}:{fill:o}}(t.fill??t.color,e,i);return function(t,e,o,i){if(!t||"object"!=typeof t)return;const n=t;if(!Array.isArray(n.stops))return;const r=n.stops.flatMap(t=>{if(!t||"object"!=typeof t)return[];const{offset:e,color:o,opacity:n}=t;return"number"==typeof e&&Number.isFinite(e)?[{offset:Math.max(0,Math.min(1,e)),color:"string"==typeof o&&o?o:i,opacity:"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):void 0}]:[]}).sort((t,e)=>t.offset-e.offset);if(!r.length)return;const s="horizontal"===n.direction?"horizontal":"vertical"===n.direction?"vertical":o,a=e+"-gradient";return{fill:`url(#${a})`,def:(0,mn.jsx)("linearGradient",{id:a,x1:0,y1:0,x2:"horizontal"===s?"100%":0,y2:"vertical"===s?"100%":0,children:r.map((t,e)=>(0,mn.jsx)("stop",{offset:100*t.offset+"%",stopColor:t.color,stopOpacity:t.opacity},`${t.offset}-${e}`))},a)}}(t.gradient,e,o,"string"==typeof t.fill&&t.fill?t.fill:"string"==typeof t.color&&t.color?t.color:i)??n}var kh=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);function Sh(t,e,o,i){const n=function(t,e,o){const i=t.position,n="string"==typeof i&&kh.has(i)?i:"bottom-left",r=n.endsWith("left")?"left":n.endsWith("right")?"right":"center",s=n.startsWith("top")?"top":n.startsWith("bottom")?"bottom":"middle",a="top"===s?0:"bottom"===s?o:o/2;return{x:("left"===r?0:"right"===r?e:e/2)+("number"==typeof t.dx&&Number.isFinite(t.dx)?t.dx:0),y:a+("number"==typeof t.dy&&Number.isFinite(t.dy)?t.dy:0),textAnchor:"start"===t.textAnchor||"middle"===t.textAnchor||"end"===t.textAnchor?t.textAnchor:"left"===r?"start":"right"===r?"end":"middle",dominantBaseline:"auto"===t.dominantBaseline||"middle"===t.dominantBaseline||"hanging"===t.dominantBaseline?t.dominantBaseline:"top"===s?"hanging":"bottom"===s?"auto":"middle"}}(t,e,o);return{...n,fill:t.fill??t.color??i.fill,fontSize:t.fontSize??i.fontSize,fontFamily:t.fontFamily??i.fontFamily,fontWeight:t.fontWeight,fontStyle:t.fontStyle,letterSpacing:t.letterSpacing,opacity:t.opacity,className:t.className,style:{pointerEvents:"none"}}}var Ah=require("react/jsx-runtime"),Mh={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};function _h({annotation:t,width:e,height:o,defaults:i=Mh}){const n=t.label??t.text;return null==n?null:(0,Ah.jsx)("text",{...Sh(t,e,o,i),children:n})}var Ph=require("d3-hierarchy"),jh=require("d3-shape");function Lh(t,e={}){const o=function(t){const e=t.provenance,o=t.id??t.stableId??e?.stableId;return null==o||""===o?void 0:o+""}(t);return{"data-semiotic-annotation-widget":"",...o?{"data-semiotic-annotation-id":o}:{},onClickCapture(i){const n=function(t){const e=t.nativeEvent;return"touch"===e.pointerType?"touch":0===e.detail?"keyboard":"pointer"}(i);e.onAnnotationActivate?.({annotation:t,annotationId:o,chartId:e.chartId,inputType:n}),o&&e.onObservation&&e.onObservation({type:"annotation-activate",annotationId:o,inputType:n,timestamp:Date.now(),chartType:e.chartType??"unknown",chartId:e.chartId})}}}c(require("react"));var $h=require("react/jsx-runtime"),Rh={linear:jh.curveLinear,monotoneX:jh.curveMonotoneX,monotoneY:jh.curveMonotoneY,step:jh.curveStep,stepAfter:jh.curveStepAfter,stepBefore:jh.curveStepBefore,basis:jh.curveBasis,cardinal:jh.curveCardinal,catmullRom:jh.curveCatmullRom};var Ch=require("react/jsx-runtime"),Ih=16,Th=20;function Oh(t,e){return t.color||e.colors.annotation||e.colors.text}function zh(t,e,o){const i=t.labelBackground,n=e.colors.background,r=n&&"transparent"!==n?n:e.colors.surface||n;return void 0===i?"none"===o?"none":{type:"halo",fill:r}:!1===i||"none"===i?"none":!0===i||"halo"===i?{type:"halo",fill:r}:"box"===i?{type:"box",fill:r}:{fill:r,...i}}function Fh(t,e,o){return null!=t.x&&e.x?e.x(t.x):o&&null!=t[o]&&e.x?e.x(t[o]):"number"==typeof t.x?t.x:null}function Nh(t,e,o){return null!=t.y&&e.y?e.y(t.y):o&&null!=t[o]&&e.y?e.y(t[o]):"number"==typeof t.y?t.y:null}function Eh(t){const{annotations:e}=t;if(!e||0===e.length)return t.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;const o=function(t,e={}){const o=!0===e.showRetractedAnnotations,i=!0===e.showSupersededAnnotations,n=new Set;for(const e of t){const t=e?.lifecycle?.supersedes;t&&"retracted"!==e?.lifecycle?.status&&n.add(t)}return t.filter(t=>{if("retracted"===t?.lifecycle?.status&&!o)return!1;const e=t?.provenance?.stableId;return!(e&&n.has(e)&&!i)})}(e),i=t.scales.geoProjection,n=i?o.map(t=>{if(!Array.isArray(t.coordinates)||2>t.coordinates.length)return t;const e=i([Number(t.coordinates[0]),Number(t.coordinates[1])]);return e?{...t,x:e[0],y:e[1]}:t}):o,r=!!i&&!t.scales.x&&!t.scales.y,s=t=>Number(t),a=t.scales.x??(r?s:void 0),c=t.scales.y??(r?s:void 0),l=t.projection?"horizontal"===t.projection?"horizontal":"vertical":void 0,u={scales:{..."vertical"===t.projection?{x:t.scales.o??a,y:t.scales.r??c,time:t.scales.o??a,value:t.scales.r??c,o:t.scales.o}:"horizontal"===t.projection?{x:t.scales.r??a,y:t.scales.o??c,time:t.scales.r??a,value:t.scales.o??c,o:t.scales.o}:{x:a,y:c,time:a,value:c,o:t.scales.o},...i?{geoProjection:i}:{}},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,data:t.annotationData,pointNodes:t.pointNodes,frameType:t.frameType??(t.projection?"ordinal":i||t.scales.x||t.scales.y?"xy":"network"),...l?{projection:l}:{}},d=t.autoPlaceAnnotations?gh({annotations:n,context:u,..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):n,h=function(t,e,o,i){const n=[];return t.forEach((t,r)=>{let s;if(o){const n=o(t,r,i);s=null!=n?n:e(t,r,i)}else s=e(t,r,i);s&&n.push({node:s,annotation:t})}),{nodes:Ed(n),renderedAnnotations:n.map(t=>t.annotation)}}(d,(e,o,i)=>function(t,e,o,i){const{scales:n,layout:r,theme:s,xAccessor:a,yAccessor:c}=o;switch(t.type){case"frame-text":return(0,Ch.jsx)(_h,{annotation:t,width:r.width,height:r.height,defaults:{fill:s.colors.text,fontSize:11,fontFamily:s.typography.fontFamily}},"ann-frame-text-"+e);case"y-threshold":{const i=t.value??t.y;if(null==i)return null;const a=Oh(t,s),c=t.label,l=t.labelPosition||"right",u=t.strokeDasharray||"6,4",d=t.strokeWidth??1.5;if("horizontal"===o.projection&&n.r){const o=n.r(i);return null==o?null:(0,Ch.jsxs)("g",{opacity:t.opacity,children:[(0,Ch.jsx)("line",{x1:o,y1:0,x2:o,y2:r.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,Ch.jsx)(vh,{x:o+4,y:Ih,textAnchor:"start",fontSize:s.typography.tickSize,fill:a,fontFamily:s.typography.fontFamily,text:c,background:zh(t,s,"halo")})]},"ann-ythresh-"+e)}const h=n.y?n.y(i):n.r?n.r(i):null;return null==h?null:(0,Ch.jsxs)("g",{children:[(0,Ch.jsx)("line",{x1:0,y1:h,x2:r.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,Ch.jsx)(vh,{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:Th>h?Math.min(r.height-4,h+Ih):h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:s.typography.tickSize,fill:a,fontFamily:s.typography.fontFamily,text:c,background:zh(t,s,"halo")})]},"ann-ythresh-"+e)}case"x-threshold":{const i=t.value??t.x;if(null==i)return null;const a="horizontal"===o.projection&&n.r?n.r(i):n.x?n.x(i):null;if(null==a)return null;const c=Oh(t,s),l=t.label,u=t.labelPosition||"top";return(0,Ch.jsxs)("g",{opacity:t.opacity,children:[(0,Ch.jsx)("line",{x1:a,y1:0,x2:a,y2:r.height,stroke:c,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),l&&(0,Ch.jsx)(vh,{x:a>.6*r.width?a-4:a+4,y:"bottom"===u?r.height-4:"center"===u?r.height/2:Ih,textAnchor:a>.6*r.width?"end":"start",fontSize:s.typography.tickSize,fill:c,fontFamily:s.typography.fontFamily,text:l,background:zh(t,s,"halo")})]},"ann-xthresh-"+e)}case"band":{const o=n.y?.domain?.(),i=t.y0??o?.[0],a=t.y1??o?.[1],c=null!=i&&n.y?n.y(i):null,l=null!=a&&n.y?n.y(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=wh(t,"ssr-band-"+e,"vertical",Oh(t,s)),f=t.fillOpacity??.1;return(0,Ch.jsxs)("g",{opacity:t.opacity,children:[h.def&&(0,Ch.jsx)("defs",{children:h.def}),(0,Ch.jsx)("rect",{x:0,y:u,width:r.width,height:d,fill:h.fill,fillOpacity:f}),t.label&&(0,Ch.jsx)(vh,{x:r.width-4,y:Math.max(u,0)+Ih,textAnchor:"end",fontSize:s.typography.tickSize,fill:t.color||Oh(t,s),fontFamily:s.typography.fontFamily,fontWeight:"bold",text:t.label,background:zh(t,s,"halo")})]},"ann-band-"+e)}case"x-band":{const o=n.x?.domain?.(),i=t.x0??o?.[0],a=t.x1??o?.[1],c=null!=i&&n.x?n.x(i):null,l=null!=a&&n.x?n.x(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=wh(t,"ssr-xband-"+e,"horizontal",Oh(t,s)),f=t.fillOpacity??.1;return(0,Ch.jsxs)("g",{opacity:t.opacity,children:[h.def&&(0,Ch.jsx)("defs",{children:h.def}),(0,Ch.jsx)("rect",{x:u,y:0,width:d,height:r.height,fill:h.fill,fillOpacity:f}),t.label&&(0,Ch.jsx)(vh,{x:u+4,y:Ih,textAnchor:"start",fontSize:s.typography.tickSize,fill:t.color||s.colors.primary||Oh(t,s),fontFamily:s.typography.fontFamily,fontWeight:"bold",text:t.label,background:zh(t,s,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!n.o)return null;const i=n.o(t.category+"");if(null==i)return null;const a=n.o.bandwidth?n.o.bandwidth():40,c=Oh(t,s),l=t.opacity??.1,u=t.label;return(0,Ch.jsxs)("g","horizontal"===o.projection?{children:[(0,Ch.jsx)("rect",{x:0,y:i,width:r.width,height:a,fill:c,opacity:l}),u&&(0,Ch.jsx)(vh,{x:12,y:i+a/2,dominantBaseline:"middle",fill:c,fontSize:s.typography.tickSize,fontWeight:"bold",fontFamily:s.typography.fontFamily,text:u,background:zh(t,s,"none")})]}:{children:[(0,Ch.jsx)("rect",{x:i,y:0,width:a,height:r.height,fill:c,opacity:l}),u&&(0,Ch.jsx)(vh,{x:i+a/2,y:Ih,textAnchor:"middle",fill:c,fontSize:s.typography.tickSize,fontWeight:"bold",fontFamily:s.typography.fontFamily,text:u,background:zh(t,s,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const o=function(t,e,o,i){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const o=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(o)return{x:o[0],y:o[1]}}return{x:Fh(t,e,o),y:Nh(t,e,i)}}(t,n,a,c),r=null==o.x||null==o.y?qd(t,e,i):null,l=o.x??r?.x??null,u=o.y??r?.y??null;if(null==l||null==u)return null;const d="text"===t.type,h=t.dx??(d?0:30),f=t.dy??(d?0:-30),p=t.color||s.colors.text;if(!d){const o="callout"===t.type?"callout-circle":t.type,i="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return(0,Ch.jsx)(Sd,{noteData:{x:l,y:u,dx:h,dy:f,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:o,...i?{subject:i}:{},connector:t.connector||{end:"arrow"},color:p,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return(0,Ch.jsx)("g",{children:(0,Ch.jsx)("text",{x:l+h,y:u+f,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||s.typography.labelSize,fill:p,fontFamily:s.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}(e,o,t,i)??function(t,e,o){switch(t.type){case"enclose":{const i=(t.coordinates||[]).map(t=>({x:Dd({...t,type:"point"},o),y:Bd({...t,type:"point"},o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const n=(0,Ph.packEnclose)(i),r=t.padding||10;return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("circle",{cx:n.x,cy:n.y,r:n.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity??.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&(0,$h.jsx)(vh,{x:n.x,y:n.y-n.r-r-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+e)}case"rect-enclose":{const i=(t.coordinates||[]).map(t=>({x:Dd({...t,type:"point"},o),y:Bd({...t,type:"point"},o)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const n=t.padding||10,[r,s]=Nt(i.map(t=>t.x)),[a,c]=Nt(i.map(t=>t.y)),l=r-n,u=s+n,d=a-n;return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:l,y:d,width:u-l,height:c+n-d,fill:t.fill||"none",fillOpacity:t.fillOpacity??.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&(0,$h.jsx)(vh,{x:(l+u)/2,y:d-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+e)}case"highlight":{const i=o.data||[],n="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],r={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return(0,$h.jsx)("g",{children:n.map((e,i)=>{const n=Dd(e,o),s=Bd(e,o);if(null==n||null==s)return null;const a="function"==typeof t.r?t.r(e):t.r||6,c="function"==typeof t.style?t.style(e):t.style||r;return(0,$h.jsx)("circle",{cx:n,cy:s,r:a,...c},"hl-"+i)})},"ann-"+e)}case"bracket":{const i=Dd(t,o),n=Bd(t,o);return(0,$h.jsx)(Sd,{noteData:{x:i??0,y:n??0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+e)}case"trend":{const i=o.data||[];if(2>i.length)return null;const n=o.xAccessor||"x",r=o.yAccessor||"y",s="ordinal"===o.frameType,a="horizontal"===o.projection,c=s?n:null,l=s?r:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const t of i){const e=t[c];if(null==e)continue;const o=e+"";h.has(o)||(h.set(o,d.length),d.push(o))}u=i.map(t=>{const e=t[c],o=t[l];if(null==e||null==o)return null;const i=h.get(e+"");return null!=i?[i,+o]:null}).filter(t=>null!==t)}else u=i.map(t=>[t[n],t[r]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>u.length)return null;const f=o.scales?.x??o.scales?.time,p=o.scales?.y??o.scales?.value;if(!f||!p)return null;const y=t=>e=>{const o=Math.max(0,Math.floor(e)),i=Math.min(d.length-1,o+1),n=e-o,r=t(d[o]);return r+(t(d[i])-r)*n},g=f,m=p;let x;if(s)if(a){const t=y(m);x=(e,o)=>[g(o),t(e)]}else{const t=y(g);x=(e,o)=>[t(e),m(o)]}else x=(t,e)=>[g(t),m(e)];const b=t.method||"linear",v="loess"===b?function(t,e=.3){const o=t.length;if(2>o)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),n=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*o)),a=[];for(let t=0;o>t;t++){const e=n[t],i=n.map(t=>Math.abs(t-e)),c=i.slice().sort((t,e)=>t-e)[Math.min(s-1,o-1)]||1,l=[];for(let t=0;o>t;t++){const e=0===c?0:i[t]/c;l[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let t=0;o>t;t++){const e=l[t];0!==e&&(u+=e,d+=e*n[t],h+=e*r[t],f+=e*n[t]*n[t],p+=e*n[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([e,h/u]);else{const t=(u*p-d*h)/y;a.push([e,(h-t*d)/u+t*e])}}return a}(u,t.bandwidth??.3):("polynomial"===b?Wt(u,t.order||2):function(t){const e=[0,0,0,0];let o=0;for(const[i,n]of t)null!==n&&(o++,e[0]+=i,e[1]+=n,e[2]+=i*i,e[3]+=i*n);const i=o*e[2]-e[0]*e[0],n=0===i?0:Bt((o*e[3]-e[0]*e[1])/i),r=Bt(e[1]/o-n*e[0]/o);return{points:t.map(([t])=>[Bt(t),Bt(n*t+r)]),equation:[n,r]}}(u)).points,w=v.map(([t,e])=>{const[o,i]=x(t,e);return`${o},${i}`}).join(" "),k=t.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&(0,$h.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:t.label})]},"ann-"+e)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const n=o.xAccessor||"x",r=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!r||!s)return null;const a=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",l=t.filter,u=i.filter(t=>null!=t[a]&&null!=t[c]&&(!l||l(t))).sort((t,e)=>t[n]-e[n]);if(2>u.length)return null;const d=Rh[o.curve||"linear"]||jh.curveLinear,h=(0,jh.area)().x(t=>r(t[n])).y0(t=>s(t[c])).y1(t=>s(t[a])).curve(d)(u);if(!h)return null;const f=t.fill||"#6366f1",p=u[u.length-1];return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("path",{d:h,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&(0,$h.jsx)("text",{x:r(p[n])+4,y:s(p[a])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+e)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const n=o.yAccessor||"y",r=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!r||!s)return null;const a=i.map(t=>t[n]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,l=a.reduce((t,e)=>t+(e-c)**2,0)/a.length,u=Math.sqrt(l),d=t.threshold??2,h=c-d*u,f=s(c+d*u),p=s(h),y=t.fill||"#6366f1",g=t.anomalyColor||"#ef4444",m=t.anomalyRadius??6,x=i.filter(t=>{const e=t[n];return null!=e&&Math.abs(e-c)>d*u});return(0,$h.jsxs)("g",{children:[!1!==t.showBand&&(0,$h.jsx)("rect",{x:0,y:Math.min(f,p),width:o.width||0,height:Math.abs(p-f),fill:y,fillOpacity:t.fillOpacity??.1}),x.map((t,e)=>{const i=Dd(t,o),n=Bd(t,o);return null==i||null==n?null:(0,$h.jsx)("circle",{cx:i,cy:n,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+e)}),t.label&&(0,$h.jsx)("text",{x:(o.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:y,fontSize:11,children:t.label})]},"ann-"+e)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const n=o.xAccessor||"x",r=o.yAccessor||"y",s=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!s||!a)return null;const c=i.map(t=>[t[n],t[r]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let l;if("polynomial"===t.method){const e=Wt(c,t.order||2).equation;l=t=>e.reduce((e,o,i)=>e+o*Math.pow(t,i),0)}else{const t=Yt(c);if(!t)return null;l=t}const{se:u,meanX:d,ssX:h}=qt(c,l),f=c.length,p=Xt(t.confidence??.95),y=c[f-1][0],g=(y-c[0][0])/Math.max(f-1,1),m=Array.from({length:t.steps??5},(t,e)=>{const o=y+(e+1)*g,i=l(o),n=u*Math.sqrt(1+1/f+(h>0?(o-d)**2/h:0))*p;return{x:o,center:i,upper:i+n,lower:i-n}}),x=m.map(t=>`${s(t.x)},${a(t.upper)}`).join(" L"),b=m.slice().reverse().map(t=>`${s(t.x)},${a(t.lower)}`).join(" L"),v=m.map(t=>`${s(t.x)},${a(t.center)}`).join(" "),w=t.strokeColor||"#6366f1",k=m[m.length-1];return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("path",{d:`M${x} L${b} Z`,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),(0,$h.jsx)("polyline",{points:`${s(y)},${a(l(y))} ${v}`,fill:"none",stroke:w,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&k&&(0,$h.jsx)("text",{x:s(k.x)+4,y:a(k.center)-4,fill:w,fontSize:11,children:t.label})]},"ann-"+e)}case"widget":{let i,n;if(null!=t.px&&null!=t.py)i=t.px,n=t.py;else{const r=qd(t,e,o);if(!r)return null;i=r.x,n=r.y}if(!function(t,e,o,i=50){return!(-i>t||t>(o.width||0)+i||-i>e||e>(o.height||0)+i)}(i,n,o))return null;const r=t.width??32,s=t.height??32,a=t.content??(0,$h.jsx)("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return(0,$h.jsx)("foreignObject",{x:i+(t.dx??0)-r/2,y:n+(t.dy??0)-s/2,width:r,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:(0,$h.jsx)("div",{...Lh(t),style:{width:r,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:a})},"ann-"+e)}default:return null}}(e,o,i),t.svgAnnotationRules,u),f=h.nodes,p=new Map;for(const t of h.renderedAnnotations){const e="string"==typeof t.type?t.type:"unknown";p.set(e,(p.get(e)??0)+1)}const y=[];for(const t of e){const e="string"==typeof t.type?t.type:"unknown",o=p.get(e)??0;o>0?p.set(e,o-1):y.push(e)}return t.onRender?.({inputCount:e.length,eligibleCount:d.length,renderedCount:h.renderedAnnotations.length,unrenderedCount:y.length,unrenderedTypes:y}),f.length>0?(0,Ch.jsx)("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:f}):null}var Dh=require("react/jsx-runtime");function Bh(t,e,o,i="right",n,r){if(null==t||!1===t)return null;const{x:s,y:a}=Be(t,{totalWidth:e[0],totalHeight:e[1],margin:o,position:i,legendLayout:n,axisChrome:r});return(0,Dh.jsx)("g",{transform:`translate(${s}, ${a})`,children:t})}var Wh=c(require("react"));function Yh(t,e,o){if("edges"===t){if(e)return"start";if(o)return"end"}return"middle"}function qh(t,e,o){if("edges"===t){if(e)return"hanging";if(o)return"auto"}return"middle"}function Xh(t){if(0===t.length)return{min:null,max:null};let e=1/0,o=-1/0;for(const i of t)e>i.pixel&&(e=i.pixel),i.pixel>o&&(o=i.pixel);return{min:e,max:o}}function Gh(t){if(t)return"object"==typeof t?t.strokeDasharray:"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Vh(t,e){return t&&"string"!=typeof t?{stroke:t.stroke??e.stroke,strokeWidth:t.strokeWidth??e.strokeWidth,...null!=t.strokeOpacity&&{strokeOpacity:t.strokeOpacity},...t.strokeDasharray&&{strokeDasharray:t.strokeDasharray}}:{...e,..."string"==typeof t&&{strokeDasharray:Gh(t)}}}function Hh(t,e,o){if("left"===t||"right"===t){const i="left"===t?o:0,n="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const o=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*n}`,s+=`L${Math.min(o,e)},${i}`}return s}const i="bottom"===t?0:e,n="bottom"===t?1:-1,r=Math.ceil(o/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*n},${Math.min(8*t+4,o)}`,s+=`L${i},${Math.min(e,o)}`}return s}function Uh(t,e){return t?.ticks??t?.tickCount??e}function Kh(t,e,o){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Zh(t,e,o){return"exact"===o?function(t,e){const o=t.domain(),i=o[0],n=o[o.length-1],r=i instanceof Date,s=i instanceof Date?i.getTime():i,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 o=t===e-1?a:s+t*c;l[t]=r?new Date(o):o}return l}(t,e):t.ticks(e)}var Qh=require("react/jsx-runtime");function Jh(t){return"string"==typeof t||"number"==typeof t}function tf(t){const{label:e,x:o,y:i,textAlign:n,fontSize:r,fontFamily:s,color:a}=t;return(0,Qh.jsx)("foreignObject",{x:o,y:i,width:60,height:24,style:{overflow:"visible"},children:(0,Qh.jsx)("div",{style:{color:a,fontFamily:s,fontSize:r,textAlign:n,userSelect:"none"},children:e})})}function ef(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function of(t){const{values:e,scale:o,format:i}=t,n=e.map(t=>t.valueOf());return e.map((t,e)=>({value:t,pixel:o(t),label:i(t,e,n)}))}function nf(t){return"string"==typeof t?6.5*t.length:"number"==typeof t?6.5*(t+"").length:60}function rf(t){const{candidates:e,scale:o,minPixelDistance:i,includeMax:n,extentMode:r,hasExplicitTickValues:s,dedupeLabels:a=!0,includeDomainMax:c=!0,format:l}=t;let u=function(t,e){if(2>=t.length)return t;const o=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-o[o.length-1].pixel)||o.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-o[o.length-1].pixel)?o[o.length-1]=i:o.push(i),o}(e,i);if(a&&u.length>1&&(u=u.filter((t,e)=>{return 0===e||(i=u[e-1].label,!!("string"!=typeof(o=t.label)&&"number"!=typeof o||"string"!=typeof i&&"number"!=typeof i||o+""!=i+""));var o,i})),!c||!n||0===u.length||"exact"===r||s)return u;const d=o.domain(),h=d[d.length-1];if(null==h)return u;const f=o(h),p=u[u.length-1].pixel;if(1>=Math.abs(f-p))return u;const y=e.map(t=>t.value.valueOf()),g={value:h,pixel:f,label:l(h,u.length,y)};return i>Math.abs(f-p)&&u.length>1&&(u=u.slice(0,-1)),[...u,g]}function sf(t,e,o,i){return!!t&&("function"==typeof t?t(e.value,o):function(t,e){const o=ef(t);if(!o)return!1;const i=ef(e);return!i||o.getFullYear()!==i.getFullYear()||o.getMonth()!==i.getMonth()}(e.value,o>0?i[o-1].value:void 0))}var af=require("react/jsx-runtime");function cf(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function lf(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 o=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let i=0;for(let t=0;o.length>t;t++)i=31*i+o.charCodeAt(t)|0;return"c"+(i>>>0).toString(36)}function uf(t,e,o){return re(t.showLegend&&!t.__legendIncludesAutomatic?cd(e,t.colorScheme,o):void 0,t.legend)}var df={right:110,left:110,top:50,bottom:80};function hf(t,e){if(t.__autoLegendMargin)return df[e]}function ff(t,e){const o={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,reservedWidth:e.reservedWidth,axisChrome:e.axisChrome,legendDistance:se(t)||ae(t)?t.legendDistance:void 0};return se(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,o)=>({group:t,item:e,itemIndex:o,label:e.label})))).length)return null;var e;const o=function(t){const{legendGroups:e,theme:o,position:i="right",totalWidth:n,margin:r,legendLayout:s}=t,{swatchSize:a,labelGap:c,rowHeight:l}=We(s),u=a+c,d=Math.max(12,ud(o)),h="top"===i||"bottom"===i,f=Math.max(a,n-r.left-r.right);if(h){const i=Math.max(a,s?.maxWidth??f),n=ld(s?.align);let r=0,c=0;const l=[];for(const n of e){const e=n.items.map(t=>t.label),u=pd({...t,categories:e,legendLayout:{...s,maxWidth:Math.max(a,i-d-8),align:"start"}}),h=n.label?d:0,f=n.label?fd(n.label,0,0,o):0,p=h>0?h+8:0,y=p+u.width,g=Math.max(u.height,f);l.push({group:n,x:r,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,c=Math.max(c,g)}const h=l.length>0?r-12:0,p=h>i?0:"center"===n?Math.max(0,(i-h)/2):"end"===n?Math.max(0,i-h):0;return{groups:l.map(t=>({...t,x:t.x+p})),width:h,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=Ye(e.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),l);let y=0;return{groups:e.map((t,e)=>{const i=t.items.map(t=>fd(t.label,a,c,o)),n=Math.max(0,...i,t.label?fd(t.label,0,0,o):0);return y=Math.max(y,n),{group:t,x:0,y:p[e].itemsY,itemOffsetX:0,itemOffsetY:0,width:n,height:t.items.length*l,items:t.items.map((t,e)=>({category:t.label,width:i[e],x:0,y:e*l}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}(t),i="top"===t.position||"bottom"===t.position,n={legendGroups:t.legendGroups,legendDistance:t.legendDistance},r=t.reservedWidth??je(n,t.legendLayout),s=t.theme.colors.grid||t.theme.colors.textSecondary,{x:a,y:c}=Be(n,{totalWidth:t.totalWidth,totalHeight:t.totalHeight,margin:t.margin,position:t.position,legendLayout:t.legendLayout,axisChrome:t.axisChrome,reservedWidth:r});if(!i){const e=Ye(t.legendGroups.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),Math.max(o.swatchSize,t.legendLayout?.rowHeight??sd)),i=t.legendGroups.flatMap((i,n)=>{const s=e[n],a=i.type??"fill",c=[(0,rd.jsx)("line",{x1:0,y1:s.lineY,x2:r,y2:s.lineY,stroke:"gray"},"legend-group-neatline-"+n)];return i.label&&null!=s.labelY&&c.push((0,rd.jsx)("text",{y:s.labelY,fontSize:ud(t.theme),fill:t.theme.colors.text,fontFamily:dd(t.theme),children:i.label},"legend-group-label-"+n)),c.push((0,rd.jsx)("g",{transform:`translate(0,${s.itemsY})`,children:i.items.map((e,r)=>{const s=i.styleFn(e,r),c="function"==typeof a?a(e):"line"===a?(0,rd.jsx)("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:s}):(0,rd.jsx)("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:s});return(0,rd.jsxs)("g",{transform:`translate(0,${r*Math.max(o.swatchSize,t.legendLayout?.rowHeight??sd)})`,children:[c,(0,rd.jsx)("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:ud(t.theme),fill:t.theme.colors.text,fontFamily:dd(t.theme),children:e.label})]},`legend-${n}-${r}`)})},"legend-group-"+n)),c});return(0,rd.jsx)("g",{className:"semiotic-legend",transform:`translate(${a},${c})`,"data-orientation":"vertical",fontWeight:hd(t.theme),children:i})}const l=o.groups.flatMap((e,n)=>{const{group:r}=e,a=r.type??"fill",c=[];if(r.label&&c.push((0,rd.jsx)("text",i?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:ud(t.theme),fill:t.theme.colors.text,fontFamily:dd(t.theme),children:r.label}:{x:e.x,y:e.y+ud(t.theme),fontSize:ud(t.theme),fill:t.theme.colors.text,fontFamily:dd(t.theme),children:r.label},"legend-group-label-"+n)),c.push(...e.items.map((i,s)=>{const c=r.items[s],l=r.styleFn(c,s),u="function"==typeof a?a(c):"line"===a?(0,rd.jsx)("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:l}):(0,rd.jsx)("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:l});return(0,rd.jsxs)("g",{transform:`translate(${e.x+e.itemOffsetX+i.x},${e.y+e.itemOffsetY+i.y})`,children:[u,(0,rd.jsx)("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:ud(t.theme),fill:t.theme.colors.text,fontFamily:dd(t.theme),children:i.category})]},`legend-${n}-${s}`)})),i&&o.groups.length-1>n){const t=e.x+e.width+6;c.push((0,rd.jsx)("line",{x1:t,y1:0,x2:t,y2:o.height,stroke:s},"legend-group-separator-"+n))}return c});return(0,rd.jsx)("g",{className:"semiotic-legend",transform:`translate(${a},${c})`,"data-orientation":i?"horizontal":"vertical",fontWeight:hd(t.theme),children:l})}({...o,legendGroups:t.legendGroups}):ae(t)?function(t){const e=function(t){const e="top"===t.position||"bottom"===t.position,o=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??o,200),height:t.gradient.label?Me:_e,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?Ae+108:108,swatchSize:14}}(t),o="top"===t.position||"bottom"===t.position,i={gradient:t.gradient,legendDistance:t.legendDistance},n=je(i),r=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=t.gradient.format||(t=>Math.round(100*t)/100+""),{x:a,y:c}=Be(i,{totalWidth:t.totalWidth,totalHeight:t.totalHeight,margin:t.margin,position:t.position,legendLayout:t.legendLayout,axisChrome:t.axisChrome,reservedWidth:n}),l=Array.from({length:17},(e,i)=>{const n=i/16;return(0,rd.jsx)("stop",{offset:100*n+"%",stopColor:t.gradient.colorFn(o?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]))},i)});if(o){const o=12,i=t.gradient.label?Se:void 0,n=t.gradient.label?Ae:0;return(0,rd.jsxs)("g",{className:"semiotic-legend",transform:`translate(${a},${c})`,fontWeight:hd(t.theme),children:[(0,rd.jsx)("defs",{children:(0,rd.jsx)("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),t.gradient.label&&(0,rd.jsx)("text",{x:e.width/2,y:i,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:dd(t.theme),children:t.gradient.label}),(0,rd.jsx)("rect",{x:0,y:n,width:e.width,height:o,fill:`url(#${r})`,rx:2}),(0,rd.jsx)("text",{x:0,y:n+o+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:dd(t.theme),children:s(t.gradient.domain[0])}),(0,rd.jsx)("text",{x:e.width,y:n+o+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:dd(t.theme),children:s(t.gradient.domain[1])})]})}const u=t.gradient.label?Se:void 0,d=t.gradient.label?Ae:0;return(0,rd.jsxs)("g",{className:"semiotic-legend",transform:`translate(${a},${c})`,fontWeight:hd(t.theme),children:[(0,rd.jsx)("defs",{children:(0,rd.jsx)("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),t.gradient.label&&(0,rd.jsx)("text",{x:0,y:u,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:dd(t.theme),children:t.gradient.label}),(0,rd.jsx)("rect",{x:0,y:d,width:14,height:100,fill:`url(#${r})`,rx:2}),(0,rd.jsx)("text",{x:19,y:d+10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:dd(t.theme),children:s(t.gradient.domain[1])}),(0,rd.jsx)("text",{x:19,y:d+100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:dd(t.theme),children:s(t.gradient.domain[0])})]})}({...o,gradient:t.gradient}):null}function pf(t,e){const{props:o,categories:i,theme:n,size:r,hasTitle:s}=e,a=o.legendPosition||"right",c={...t},l={theme:n,position:a,size:r,hasTitle:s,legendLayout:o.legendLayout,axisChrome:o.axisChrome,minimumMargin:hf(o,a)};if(null!=o.legend){const e=uf(o,i,n);null!=e&&!1!==e&&function(t,e){De(t,{legend:e.legend,position:e.position||"right",size:e.size,hasTitle:e.hasTitle,legendLayout:e.legendLayout,minimumMargin:e.minimumMargin,axisChrome:e.axisChrome})}(t,{...l,legend:e})}else o.showLegend&&i.length>0&&function(t,e){if(0===e.categories.length)return;const o=e.position||"right";De(t,{legend:cd(e.categories,e.colorScheme,e.theme),position:o,size:e.size,hasTitle:e.hasTitle,legendLayout:e.legendLayout,minimumMargin:e.minimumMargin,axisChrome:e.axisChrome})}(t,{...l,categories:i,colorScheme:o.colorScheme});return ke(t,c,r,a),a}function yf(t){const{props:e,categories:o,theme:i,size:n,margin:r,hasTitle:s}=t,a=e.legendPosition||"right",c={theme:i,position:a,size:n,margin:r,hasTitle:s,legendLayout:e.legendLayout,axisChrome:e.axisChrome,idPrefix:e._idPrefix};if(null!=e.legend){const t=uf(e,o,i);if(Wh.isValidElement(t))return Bh(t,n,r,a,e.legendLayout,e.axisChrome);return ff(t,c)||(se(t)||ae(t)?null:Bh(t??null,n,r,a,e.legendLayout,e.axisChrome))}return e.showLegend&&0!==o.length?function(t){const{categories:e,colorScheme:o,theme:i,position:n="right",totalWidth:r,totalHeight:s,margin:a}=t;if(!e||0===e.length)return null;const c=ad(e,o,i),l="top"===n||"bottom"===n,u=pd(t),d={...cd(e,o,i),legendDistance:t.legendDistance},h=t.reservedWidth??je(d,t.legendLayout),{x:f,y:p}=Be(d,{totalWidth:r,totalHeight:s,margin:a,position:n,legendLayout:t.legendLayout,axisChrome:t.axisChrome,reservedWidth:h});if(l){const t=u.items.map((t,e)=>(0,rd.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,rd.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(t.category),rx:u.swatchRadius}),(0,rd.jsx)("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:ud(i),fill:i.colors.text,fontFamily:dd(i),children:t.category})]},"legend-"+e));return(0,rd.jsx)("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,fontWeight:hd(i),children:t})}const y=Ye([{hasLabel:!1,itemCount:e.length}],Math.max(u.swatchSize,t.legendLayout?.rowHeight??sd))[0],g=u.items.map((t,e)=>(0,rd.jsxs)("g",{transform:`translate(${t.x},${t.y+y.itemsY})`,children:[(0,rd.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(t.category),rx:u.swatchRadius}),(0,rd.jsx)("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:ud(i),fill:i.colors.text,fontFamily:dd(i),children:t.category})]},"legend-"+e));return(0,rd.jsxs)("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,fontWeight:hd(i),children:[(0,rd.jsx)("line",{x1:0,y1:y.lineY,x2:h,y2:y.lineY,stroke:"gray"}),g]})}({categories:o,colorScheme:e.colorScheme,theme:i,position:a,totalWidth:n[0],totalHeight:n[1],margin:r,hasTitle:s,legendLayout:e.legendLayout,axisChrome:e.axisChrome,idPrefix:e._idPrefix}):null}var gf=Kh;function mf(t,e){const o=zt(e.theme),i=e.background??o.background,n=e.idPrefix?e.idPrefix+"-":"",r="string"==typeof e.title?e.title:void 0,s=r?n+"semiotic-title":void 0,a=e.description?n+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return(0,af.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[r&&(0,af.jsx)("title",{id:s,children:r}),e.description&&(0,af.jsx)("desc",{id:a,children:e.description}),e.defs&&(0,af.jsx)("defs",{children:e.defs}),i&&"transparent"!==i&&(0,af.jsx)("rect",{x:0,y:0,width:e.width,height:e.height,fill:i}),(0,af.jsx)("g",{id:n+"data-area",transform:e.innerTransform,children:t}),r&&(0,af.jsx)("text",{id:n+"chart-title",x:e.width/2,y:de,textAnchor:"middle",fontSize:o.titleFontSize,fontWeight:o.titleFontWeight,fill:o.text,fontFamily:o.titleFontFamily,children:r}),e.legend&&(0,af.jsx)("g",{id:n+"legend",children:e.legend}),e.outerElements]})}var xf=require("react/jsx-runtime");function bf(t,e,o,i){return"function"==typeof t?t({size:e,margin:o,scales:i}):t}var vf={top:50,right:40,bottom:60,left:70},wf={top:20,right:80,bottom:20,left:80},kf={top:40,right:40,bottom:40,left:40},Sf=new Set(["chord","force","circlepack","orbit"]),Af=require("react/jsx-runtime"),Mf=require("react/jsx-runtime");function _f(t,e){const o=Ot(t.theme),i=t.size||[500,300],n=pe({...vf,...t.margin},t.title),r=he(t.title),s=function(t,e){if(!e||0===t.length)return t;if(!t.some(t=>null!=t&&"object"==typeof t&&Array.isArray(t[e])))return t;const o=[];for(const i of t){if(null==i||"object"!=typeof i)continue;const t=i[e];if(!Array.isArray(t))continue;const n=i.label??i.id??i.key;for(const e of t)null!=e&&"object"==typeof e&&o.push(null==n?e:{...e,_lineGroup:n})}return o}(P(t.data),t.lineDataAccessor),a=t.showLegend?yd(s,t.colorAccessor||t.groupAccessor||t.categoryAccessor):[],c=function(t){const e=t.axes?.find(t=>"bottom"===t.orient),o=t.axes?.find(t=>"top"===t.orient),i=t.axes?.find(t=>"left"===t.orient),n=t.axes?.find(t=>"right"===t.orient),r=!o||!!e,s=!!o&&!e,a=!n||!!i,c=!!n,l=!1!==t.showAxes;return{hasAxis:l&&r,hasAxisLabel:l&&r&&!!(e?.label??t.xLabel),rotatedTicks:l&&r&&(t.rotatedTicks??!!e?.autoRotate),topAxis:s?{hasAxis:l,hasAxisLabel:l&&!!(o?.label??t.xLabel),rotatedTicks:l&&(t.rotatedTicks??!!o?.autoRotate)}:void 0,leftAxis:a?{hasAxis:l,hasAxisLabel:l&&!!(i?.label??t.yLabel)}:void 0,rightAxis:c?{hasAxis:l,hasAxisLabel:l&&!!(n?.label??t.yLabelRight??t.yLabel)}:void 0}}({showAxes:t.showAxes,xLabel:t.xLabel,yLabel:t.yLabel,yLabelRight:t.yLabelRight,axes:t.axes});pf(n,{props:{...t,axisChrome:c},categories:a,theme:o,size:i,hasTitle:r});const l=yf({props:{...t,axisChrome:c},categories:a,theme:o,size:i,margin:n,hasTitle:r}),u=i[0]-n.left-n.right,d=i[1]-n.top-n.bottom,h="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),f=t.colorScheme||o.colors.categorical,p=(t.axes?.find(t=>"left"===t.orient)??t.axes?.find(t=>"right"===t.orient))?.extent??t.axisExtent,y={chartType:t.chartType,runtimeMode:h?"streaming":"bounded",windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:h?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:t.xAccessor,yAccessor: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||(t.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,axisExtent:t.axisExtent,yAxisExtent:p,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,baseline:t.baseline,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,band:t.band,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:kt(t.gradientFill),lineGradient:St(t.lineGradient),semanticLineStops:t.semanticLineStops,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:f,themeCategorical:o.colors.categorical,themeSequential:o.colors.sequential,themeDiverging:o.colors.diverging,themeSemantic:It(o),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors,showValues:t.showValues,heatmapValueFormat:t.heatmapValueFormat,heatmapColorScale:t.heatmapColorScale,heatmapAggregation:t.heatmapAggregation,heatmapXBins:t.heatmapXBins,heatmapYBins:t.heatmapYBins,pointIdAccessor:t.pointIdAccessor,onLayoutError:t.onLayoutError},g=new vu(y);t.data&&g.ingest({inserts:s,bounded:!0}),g.computeScene({width:u,height:d});const m=bf(t.backgroundGraphics,i,n,g.scales),x=bf(t.foregroundGraphics,i,n,g.scales);if(!g.scales){let r;const a=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:s,scales:{},layout:{width:u,height:d},theme:o,idPrefix:t._idPrefix,onRender:t=>{r=t}}):null;return e&&(e.evidence=Ec({frameType:"xy",width:i[0],height:i[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:r,extraWarnings:g.scales?[]:["NO_SCALES"],margin:n})),Bc.renderToStaticMarkup(mf(m||x||t.annotations?(0,Mf.jsxs)(Mf.Fragment,{children:[m,a,x]}):null,{width:i[0],height:i[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:u,innerHeight:d,legend:l,idPrefix:t._idPrefix}))}const b=t._idPrefix,v=id({nodes:g.scene,renderMode:t.renderMode,fallback:(e,o)=>td(e,o,b,t.hoverRadius??30)}),w=t.showGrid?function(t,e,o,i,n,r,s){const{grid:a}=zt(o),c=i?i+"-":"",l=r?.find(t=>"bottom"===t.orient),u=r?.find(t=>"top"===t.orient),d=r?.find(t=>"left"===t.orient),h=r?.find(t=>"right"===t.orient),f=l??u,p=d??h,y=f?.extent??n,g=p?.extent??n,m="exact"===y?5:Math.min(5,Math.max(2,Math.floor(e.width/70))),x="exact"===g?5:Math.min(5,Math.max(2,Math.floor(e.height/30))),b=f?.tickValues??Zh(t.x,Uh(f,m),y),v=f?.tickFormat||s?.xFormat||s?.tickFormatTime||Kh,w=of({values:b,scale:t.x,format:v}),k=w.reduce((t,e)=>Math.max(t,nf(e.label)),0),S=rf({candidates:w,scale:t.x,minPixelDistance:f?.autoRotate?Math.max(20,Math.min(k+8,55)):Math.max(55,k+8),includeMax:f?.includeMax,extentMode:y,hasExplicitTickValues:!!f?.tickValues,format:v}),A=p?.tickValues??Zh(t.y,Uh(p,x),g),M=p?.tickFormat||s?.yFormat||s?.tickFormatValue||Kh,_=t=>M(t),P=rf({candidates:of({values:A,scale:t.y,format:_}),scale:t.y,minPixelDistance:22,includeMax:p?.includeMax,extentMode:g,hasExplicitTickValues:!!p?.tickValues,format:_}),j=!1!==f?.grid,L=!1!==p?.grid,$=Gh(f?.gridStyle),R=Gh(p?.gridStyle),C=Vh(f?.gridStyle,{stroke:a,strokeWidth:.5}),I=Vh(p?.gridStyle,{stroke:a,strokeWidth:.5});return(0,xf.jsxs)("g",{id:c+"grid",className:"semiotic-grid",opacity:.8,children:[j&&S.map((t,o)=>(0,xf.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:e.height,...C,strokeDasharray:$??C.strokeDasharray},"gx-"+o)),L&&P.map((t,o)=>(0,xf.jsx)("line",{x1:0,y1:t.pixel,x2:e.width,y2:t.pixel,...I,strokeDasharray:R??I.strokeDasharray},"gy-"+o))]})}(g.scales,{width:u,height:d},o,b,t.axisExtent,t.axes,t):null,k=v.map(t=>t.element),S=lf(t)+"-plot-clip",A=!1!==t.showAxes,M=A?function(t,e,o,i,n,r,s,a=!1){const c=zt(i),l=o.legendPosition??"right",u=$e(o.legendLayout,s?.leftAxis),d=$e(o.legendLayout,s?.rightAxis),h=a&&"left"===l&&u>0?u:r?.left??o.margin?.left??40,f=a&&"right"===l&&d>0?d:r?.right??o.margin?.right??40,p=o.axes?.find(t=>"bottom"===t.orient),y=o.axes?.find(t=>"top"===t.orient),g=o.axes?.find(t=>"left"===t.orient),m=o.axes?.find(t=>"right"===t.orient),x=p??y,b=g??m,v=p?"bottom":y?"top":"bottom",w=g?"left":m?"right":"left",k="top"===v?0:e.height,S="right"===w?e.width:0,A="top"===v?-1:1,M="right"===w?1:-1,_=x?.extent??o.axisExtent,P=b?.extent??o.axisExtent,j="exact"===_?5:Math.min(5,Math.max(2,Math.floor(e.width/70))),L="exact"===P?5:Math.min(5,Math.max(2,Math.floor(e.height/30))),$=x?.tickValues??Zh(t.x,Uh(x,j),_),R=x?.tickFormat||o.xFormat||o.tickFormatTime||gf,C=of({values:$,scale:t.x,format:R}),I=C.reduce((t,e)=>Math.max(t,nf(e.label)),0),T=rf({candidates:C,scale:t.x,minPixelDistance:x?.autoRotate?Math.max(20,Math.min(I+8,55)):Math.max(55,I+8),includeMax:x?.includeMax,extentMode:_,hasExplicitTickValues:!!x?.tickValues,format:R}),O=b?.tickValues??Zh(t.y,Uh(b,L),P),z=b?.tickFormat||o.yFormat||o.tickFormatValue||gf,F=t=>z(t),N=rf({candidates:of({values:O,scale:t.y,format:F}),scale:t.y,minPixelDistance:22,includeMax:b?.includeMax,extentMode:P,hasExplicitTickValues:!!b?.tickValues,format:F}),E=!!(x?.autoRotate&&T.length>1&&e.width/Math.max(T.length-1,1)<T.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8),D=Xh(T),B=Xh(N),W=x?.label??o.xLabel,Y=b?.label??("right"===w?o.yLabelRight??o.yLabel:o.yLabel),q=Vh(x?.axisStyle,{stroke:c.border,strokeWidth:1}),X=Vh(b?.axisStyle,{stroke:c.border,strokeWidth:1}),G="right"===w?e.width+f-15:15-h;return(0,af.jsxs)("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[!1!==x?.baseline&&!x?.jaggedBase&&(0,af.jsx)("line",{x1:0,y1:k,x2:e.width,y2:k,...q}),x?.jaggedBase&&(0,af.jsx)("path",{d:Hh(v,e.width,e.height),fill:"none",...q}),T.map((t,e)=>{const o=sf(x?.landmarkTicks,t,e,T);return(0,af.jsxs)("g",{transform:`translate(${t.pixel},${k})`,children:[(0,af.jsx)("line",{y2:5*A,...q}),Jh(t.label)?(0,af.jsx)("text",{y:A*(E?12:18),textAnchor:E?"end":Yh(x?.tickAnchor,t.pixel===D.min,t.pixel===D.max),fontWeight:o?600:400,fontSize:o?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,transform:E?"top"===v?"rotate(45)":"rotate(-45)":void 0,children:t.label}):tf({label:t.label,x:-30,y:"top"===v?-30:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"xtick-"+e)}),W&&(0,af.jsx)("text",{x:e.width/2,y:"top"===v?-(E?58:40):e.height+(E?58:40),textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:W}),!1!==b?.baseline&&!b?.jaggedBase&&(0,af.jsx)("line",{x1:S,y1:0,x2:S,y2:e.height,...X}),b?.jaggedBase&&(0,af.jsx)("path",{d:Hh(w,e.width,e.height),fill:"none",...X}),N.map((t,e)=>{const o=sf(b?.landmarkTicks,t,e,N);return(0,af.jsxs)("g",{transform:`translate(${S},${t.pixel})`,children:[(0,af.jsx)("line",{x2:5*M,...X}),Jh(t.label)?(0,af.jsx)("text",{x:8*M,textAnchor:"right"===w?"start":"end",dominantBaseline:qh(b?.tickAnchor,t.pixel===B.min,t.pixel===B.max),fontWeight:o?600:400,fontSize:o?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:t.label}):tf({label:t.label,x:"right"===w?8:-68,y:-12,textAlign:"right"===w?"left":"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"ytick-"+e)}),Y&&(0,af.jsx)("text",{x:G,y:e.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(${"right"===w?90:-90}, ${G}, ${e.height/2})`,children:Y})]})}(g.scales,{width:u,height:d},t,o,b,n,c,!!l):null,_=A?function(t){const{scales:e,layout:o,props:i,theme:n,leftAxis:r,rightAxis:s,margin:a,axisChrome:c,hasRenderedLegend:l}=t;if(!r||!s)return null;const u=zt(n),d=s.extent??i.axisExtent,h="exact"===d?Math.max(2,Uh(s,5)):Math.min(Uh(s,5),Math.max(2,Math.floor(o.height/30))),f=s.tickValues??Zh(e.y,h,d),p=s.tickFormat||i.yFormat||i.tickFormatValue||Kh,y=t=>p(t),g=rf({candidates:of({values:f,scale:e.y,format:y}),scale:e.y,minPixelDistance:22,includeMax:s.includeMax,extentMode:d,hasExplicitTickValues:!!s.tickValues,format:y}),m=Xh(g),x=s.label??i.yLabelRight,b=Vh(s.axisStyle,{stroke:u.border,strokeWidth:1}),v=i.legendPosition??"right",w=$e(i.legendLayout,c?.rightAxis),k=o.width+(l&&"right"===v&&w>0?w:a.right)-15;return(0,Af.jsxs)("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==s.baseline&&!s.jaggedBase&&(0,Af.jsx)("line",{x1:o.width,y1:0,x2:o.width,y2:o.height,...b}),s.jaggedBase&&(0,Af.jsx)("path",{d:Hh("right",o.width,o.height),fill:"none",...b}),g.map((t,e)=>{const i=sf(s.landmarkTicks,t,e,g);return(0,Af.jsxs)("g",{transform:`translate(${o.width},${t.pixel})`,children:[(0,Af.jsx)("line",{x2:5,...b}),Jh(t.label)?(0,Af.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:qh(s.tickAnchor,t.pixel===m.min,t.pixel===m.max),fontWeight:i?600:400,fontSize:i?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:t.label}):tf({label:t.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+e)}),x&&(0,Af.jsx)("text",{x:k,y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${k}, ${o.height/2})`,children:x})]})}({scales:g.scales,layout:{width:u,height:d},props:t,theme:o,leftAxis:t.axes?.find(t=>"left"===t.orient),rightAxis:t.axes?.find(t=>"right"===t.orient),margin:n,axisChrome:c,hasRenderedLegend:!!l}):null;let j;const L=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:s,scales:{x:g.scales.x,y:g.scales.y},layout:{width:u,height:d},theme:o,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:b,onRender:t=>{j=t}}):null;e&&(e.evidence=Ec({frameType:"xy",width:i[0],height:i[1],marks:v.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:j,xDomain:Nc(g.scales.x?.domain?.()),yDomain:Nc(g.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0,margin:n}));const $=t.svgPreRenderers&&g.scales?t.svgPreRenderers.map((t,e)=>{try{return(0,Mf.jsx)(Dc.Fragment,{children:t(g.scene,g.scales,{width:u,height:d})},"pre-"+e)}catch{return null}}).filter(Boolean):null;return Bc.renderToStaticMarkup(mf((0,Mf.jsxs)(Mf.Fragment,{children:[m,$,w,(0,Mf.jsx)("defs",{children:(0,Mf.jsx)("clipPath",{id:S,children:(0,Mf.jsx)("rect",{x:0,y:0,width:u,height:d})})}),(0,Mf.jsx)("g",{clipPath:`url(#${S})`,children:k}),M,_,L,x,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:u,innerHeight:d,legend:l,idPrefix:t._idPrefix}))}var Pf=c(require("react")),jf=c(require("react-dom/server")),Lf=require("d3-scale"),$f=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,o){if(e&&"function"==typeof t.pieceStyle){const i=t.pieceStyle(e,o);return i&&!i.fill&&o?{...i,fill:this.getColorFromScheme(t,o)}:i}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&o?{fill:ct(t.barColors,o)??"#007bff"}:{fill:o?this.getColorFromScheme(t,o):"#007bff"}}resolveSummaryStyle(t,e,o){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,o):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const o=this.colorSchemeMap.get(e);if(o)return o;const i=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||nt,n=i[this.colorSchemeIndex%i.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,n),n}};function Rf(t,e,o){const i="function"==typeof t?t(o?e.w:e.h):t;return"number"==typeof i&&Number.isFinite(i)?Math.max(0,i):0}function Cf(t){const e=t.getSymbol;return e?Cl(e,t.config.symbolMap):null}function If(t,e,o,i,n,r,s){t.push(e?{type:"symbol",x:i,y:n,size:Math.PI*r*r,symbolType:e(o),style:s,datum:o}:{type:"point",x:i,y:n,r:r,style:s,datum:o})}function Tf(t,e){const{columns:o,config:i,resolvePieceStyle:n}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(o),h=d.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!h&&d.length>1&&(i.cornerRadius??0)>0;for(let t=0;d.length>t;t++){const e=d[t],o=e.pieceData[0],u="number"==typeof o?._pctStart?o._pctStart:e.pctStart,h=c+u*l,p=c+(u+("number"==typeof o?._pct?o._pct:e.pct))*l,y=n(e.pieceData[0],e.name),g=0===t,m=t===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:y,datum:o?._nonInteractive?null:e.pieceData,category:e.name};o?._roundedEnds?x.roundedEnds=o._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),o?._gradientBand&&(x._gradientBand=o._gradientBand),r.push(x)}return r}var Of=require("d3-array");function zf(t){const e=t.length,o=t[0],i=t[e-1];return{n:e,min:o,q1:(0,Of.quantile)(t,.25)??o,median:(0,Of.quantile)(t,.5)??(o+i)/2,q3:(0,Of.quantile)(t,.75)??i,max:i,mean:t.reduce((t,e)=>t+e,0)/e}}var Ff=require("d3-scale"),Nf={bar:function(t,e){const{scales:o,columns:i,config:n,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=o,u=[],d="vertical"===l,h="horizontal"===l,f=n.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(i))for(const o of e.pieceData){const e=s(o);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(i)){const e=new Map;for(const o of t.pieceData){const t=s?s(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t);i.total+=r(o),i.pieces.push(o)}let o=0;if(f)for(const t of e.values())o+=Math.abs(t.total);let i=0,n=0;for(const r of p){const l=e.get(r);if(!l)continue;let p=l.total;f&&o>0&&(p/=o);const y=a(l.pieces[0],s?r:t.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name};if(d){const e=c(0>p?n:i+p),o=0>p?c(n+p)-c(n):c(i)-c(i+p);u.push(gl(t.x,e,t.width,Math.abs(o),y,g,r)),0>p?n+=p:i+=p}else if(h){const e=c(0>p?n+p:i),o=0>p?c(n)-c(n+p):c(i+p)-c(i);u.push(gl(e,t.x,Math.abs(o),t.width,y,g,r)),0>p?n+=p:i+=p}}}const y="vertical"===l;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(void 0!==n.roundedTop){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const o=e.datum?.category||"";t.has(o)||t.set(o,[]),t.get(o).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),o=e.filter(t=>0>(t.datum?.__aggregateValue??0));if(t.length>0){const e=t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e),o=Rf(n.roundedTop,e,y);o>0&&(e.roundedTop=o)}if(o.length>0){const t=o.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e),e=Rf(n.roundedTop,t,y);e>0&&(t.roundedTop=e)}}}return u},clusterbar:function(t,e){const{scales:o,columns:i,config:n,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=o,u=[],d="vertical"===l,h=[],f=new Set;for(const t of Object.values(i))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const p=h.length||1;for(const t of Object.values(i)){const e=t.width/p,o=.2*e,i=e-o,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;h.length>s;s++){const l=n.get(h[s])||[];for(const n of l){const l=r(n),f=a(n,h[s]);if(d){const r=t.x+s*e+o/2,a=c(0),d=c(l);u.push(gl(r,Math.min(a,d),i,Math.abs(a-d),f,n,h[s]))}else{const r=t.x+s*e+o/2,a=c(0),d=c(l);u.push(gl(Math.min(a,d),r,Math.abs(d-a),i,f,n,h[s]))}}}}for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum),o=Rf(n.roundedTop,t,d);o>0&&(t.roundedTop=o),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}return u},point:function(t,e){const{scales:o,columns:i,getR:n,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:c}=o,l=[],u="vertical"===c,d="radial"===c,h=r.length>0,f=Cf(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(i))for(const e of t.pieceData){const o=e.__rIndex??0,i=e.__rValue??n(e),c=h&&r[o]||a,g=s(e,t.name),m=g.r||5;let x,b;if(d){const e=y+(t.pctStart+t.pct/2)*p,o=c(i);x=Math.cos(e)*o,b=Math.sin(e)*o}else u?(x=t.middle,b=c(i)):(x=c(i),b=t.middle);If(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:o,columns:i,getR:n,resolvePieceStyle:r}=t,{r:s,projection:a}=o,c=[],l="vertical"===a,u=Cf(t);for(const t of Object.values(i)){const e=t.width/2;for(let o=0;t.pieceData.length>o;o++){const i=t.pieceData[o],a=n(i),d=r(i,t.name),h=d.r||4,f=(7919*o%100/100-.5)*e*.8;If(c,u,i,l?t.middle+f:s(a),l?s(a):t.middle+f,h,d)}}return c},pie:Tf,donut:Tf,boxplot:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=o,l=[],u="vertical"===c,d=!1!==n.showOutliers;for(const e of Object.values(i)){const o=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===o.length)continue;const i=o[0],n=o[o.length-1],c=(0,Of.quantile)(o,.25)??i,h=(0,Of.quantile)(o,.5)??(i+n)/2,f=(0,Of.quantile)(o,.75)??n,p=f-c,y=c-1.5*p,g=f+1.5*p,m=o.find(t=>t>=y)??i,x=[...o].reverse().find(t=>g>=t)??n,b=s(e.pieceData[0],e.name),v=[];if(d)for(const t of e.pieceData){const o=r(t);if(y>o||o>g){const i=u?e.middle:a(o),n=u?a(o):e.middle;v.push({px:i,py:n,value:o,datum:t})}}if(l.push({type:"boxplot",x:u?e.middle:0,y:u?0:e.middle,projection:u?"vertical":"horizontal",columnWidth:.6*e.width,minPos:a(m),q1Pos:a(c),medianPos:a(h),q3Pos:a(f),maxPos:a(x),stats:{n:o.length,min:m,q1:c,median:h,q3:f,max:x,mean:o.reduce((t,e)=>t+e,0)/o.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),d)for(const e of v)l.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:b.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:b.cursor},datum:e.datum})}return l},violin:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=o,l=[],u="vertical"===c,d=n.bins||20,h=!1!==n.showIQR;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],n=(i-o)/d||1,c=Array(d).fill(0);for(const t of e)c[Math.min(Math.floor((t-o)/n),d-1)]++;const f=Et(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(o)}`;for(let e=0;d>e;e++){const i=a(o+(e+.5)*n);y+=` L ${t.middle+c[e]/f*p} ${i}`}y+=` L ${t.middle} ${a(i)}`;for(let e=d-1;e>=0;e--){const i=a(o+(e+.5)*n);y+=` L ${t.middle-c[e]/f*p} ${i}`}y+=" Z"}else{y=`M ${a(o)} ${t.middle}`;for(let e=0;d>e;e++)y+=` L ${a(o+(e+.5)*n)} ${t.middle-c[e]/f*p}`;y+=` L ${a(i)} ${t.middle}`;for(let e=d-1;e>=0;e--)y+=` L ${a(o+(e+.5)*n)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(h&&e.length>=4){const n=(0,Of.quantile)(e,.25)??o,r=(0,Of.quantile)(e,.5)??(o+i)/2,s=(0,Of.quantile)(e,.75)??i;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(i),a(o)),width:t.width,height:Math.abs(a(i)-a(o))}:{x:Math.min(a(o),a(i)),y:t.x,width:Math.abs(a(i)-a(o)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:zf(e),style:g,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a}=o,c=[],l=n.bins||25,u=n.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[o,i]=Nt(e),n=null!=h&&isFinite(h)?h:o,d=null!=f&&isFinite(f)?f:i,p=(d-n)/l||1,y=Array(l).fill(0);for(const t of e)n>t||t>d||y[Math.min(Math.floor((t-n)/p),l-1)]++;const g=e.length,m=Et(y,1),x=s(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===y[e])continue;const o=(u?y[e]/g:y[e]/m)*t.width*.9,i=a(n+e*p),r=a(n+(e+1)*p);c.push(gl(Math.min(i,r),t.x+t.width-o,Math.abs(r-i),o,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:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=o,l=[],u=n.bins||20,d="horizontal"===c,h=n.amplitude||1.5;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],n=(i-o)/u||1,c=Array(u).fill(0);for(const t of e)o>t||t>i||c[Math.min(Math.floor((t-o)/n),u-1)]++;const f=Et(c,1),p=s(t.pieceData[0],t.name),y=t.width*h;let g;if(d){const e=t.x+t.width;g=`M ${a(o)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(o+(t+.5)*n)} ${e-c[t]/f*y}`;g+=` L ${a(i)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(o)}`;for(let t=0;u>t;t++){const i=a(o+(t+.5)*n);g+=` L ${e+c[t]/f*y} ${i}`}g+=` L ${e} ${a(i)} Z`}const m=d?{x:Math.min(a(o),a(i)),y:t.x,width:Math.abs(a(i)-a(o)),height:t.width}:{x:t.x,y:Math.min(a(i),a(o)),width:t.width,height:Math.abs(a(i)-a(o))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:zf(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:o,columns:i,getRawRange:n,resolvePieceStyle:r}=t,{r:s,projection:a}=o,c=[],l="horizontal"===a;for(const t of Object.values(i))for(const e of t.pieceData){const o=n(e);if(!o)continue;const[i,a]=o,u=r(e,t.name);if(l){const o=s(Math.min(i,a)),n=s(Math.max(i,a));c.push(gl(o,t.x,n-o,t.width,u,e,t.name))}else{const o=s(Math.max(i,a)),n=s(Math.min(i,a));c.push(gl(t.x,o,t.width,n-o,u,e,t.name))}}return c},funnel:function(t,e){const{columns:o,getR:i,getStack:n,resolvePieceStyle:r}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>o[t]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const t of l)for(const e of t.pieceData){const t=n?n(e):"_default";d.has(t)||(d.add(t),u.push(t))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let o=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=i(r);s.total+=a,s.pieces.push(r),o+=a}f.push({col:t,groups:e,stepTotal:o}),h||o>p&&(p=o)}if(h)for(const t of f){let e=0,o=0;for(let i=0;u.length>i;i++){const n=t.groups.get(u[i]);n&&(i%2==0?e+=n.total:o+=n.total)}const i=Math.max(e,o);i>p&&(p=i)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*e.width,x=(0,Ff.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 o=f[e],i=o.col,n=0===e,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(h){let t=0;for(const e of u){const i=o.groups.get(e);i&&(t+=x(i.total))}let e=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=o.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?e:l-b;v?e+=b:l-=b;const k=r(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:i.name,__funnelIsFirstStep:n,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(gl(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const t=o.stepTotal,e=x(t),l=a-e/2,h=u[0],f="_default"!==h,y=o.groups.get(h)?.pieces[0]??i.pieceData[0],b=f?h:i.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:i.name,__funnelIsFirstStep:n,category:f?h:i.name};c&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(gl(l,p,e,d,v,k,b)),m.set(h,{x:l,y:p,w:e,h:d})}if(e>0&&v.size>0){const e=h?u:[u[0]];for(const n of e){const e=v.get(n),a=m.get(n);if(!e||!a)continue;const c=(()=>{const t=o.groups.get(n);return r(t?t.pieces[0]:i.pieceData[0],"_default"===n?i.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,cursor:c.cursor},datum:o.groups.get(n)?.pieces[0]??i.pieceData[0],category:"_default"===n?i.name:n};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:o,getR:i,getStack:n,resolvePieceStyle:r,scales:s}=t,a=[],c=s.o.domain().map(t=>o[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 d=l.length>1&&"_default"!==l[0],h=[];for(const t of c){const e=new Map;let o=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=i(r);s.total+=a,s.pieces.push(r),o+=a}h.push({col:t,groups:e,stepTotal:o})}const f=new Map;for(const t of l){const e=h[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let t=0;h.length>t;t++){const e=h[t],o=e.col,i=0===t,n=t>0?h[t-1]:null,s=o.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const h=l[t],y=e.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=n?.groups.get(h),v=i?0:Math.max(0,(b?.total??g)-g),w=o.x+t*s+c/2,k=p(g),S=p(0)-k,A=r(y.pieces[0],d?h:o.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:o.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(gl(w,k,u,S,A,M,d?h:o.name)),v>0){const t=p(g+v),e=k-t,i={...A},n={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:o.name};a.push(gl(w,t,u,e,i,n,d?h:o.name))}}}return a},swimlane:function(t,e){const{scales:o,columns:i,getR:n,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:c}=o,l=[],u="horizontal"===c,d=t.config.gradientFill,h=u?"left":"bottom",f=new Map,p=e=>{const o=f.get(e);if(void 0!==o)return o;const i="function"==typeof t.config.roundedTop?t.config.roundedTop(e.width):t.config.roundedTop,n="number"==typeof i&&Number.isFinite(i)?Math.max(0,i):0;return f.set(e,n),n},y=t.config.trackFill;if(y){const t="string"==typeof y?y:y.color,e="string"==typeof y?1:y.opacity??1,[o,n]=a.range(),r=Math.min(o,n),s=Math.abs(n-o);for(const o of Object.values(i)){const i={fill:t,opacity:e},n=u?gl(r,o.x,s,o.width,i,null,"__track__"):gl(o.x,r,o.width,s,i,null,"__track__"),a=p(o);a>0&&(n.cornerRadii={tl:a,tr:a,br:a,bl:a}),l.push(n)}}for(const t of Object.values(i)){let e=0;const o=l.length,i=p(t);for(const o of t.pieceData){const i=Math.abs(n(o));if(0===i)continue;const c=r?r(o):t.name,f=s(o,c);let p;if(u){const n=a(e),r=a(e+i);p=gl(n,t.x,r-n,t.width,f,o,c)}else{const n=a(e+i),r=a(e);p=gl(t.x,n,t.width,r-n,f,o,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),e+=i}if(i>0&&l.length>o){const t=l.slice(o),e=t[0],n=t[t.length-1];1===t.length?e.cornerRadii={tl:i,tr:i,br:i,bl:i}:u?(e.cornerRadii={tl:i,bl:i},n.cornerRadii={tr:i,br:i}):(e.cornerRadii={bl:i,br:i},n.cornerRadii={tl:i,tr:i})}}return l}},Ef=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Df=["scene-style","data-paint","accessibility","evidence"],Bf=(t,e)=>({retainedData:t,invalidations:e}),Wf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qf=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xf=["scene-geometry","data-paint","accessibility","evidence"],Gf=["scene-style","data-paint","accessibility","evidence"],Vf=[],Hf={chartType:Bf("rebuild",Wf),runtimeMode:Bf("rebuild",Wf),categoryAccessor:Bf("rebuild",Wf),valueAccessor:Bf("rebuild",Wf),oAccessor:Bf("rebuild",Wf),rAccessor:Bf("rebuild",Wf),stackBy:Bf("rebuild",Wf),groupBy:Bf("rebuild",Wf),timeAccessor:Bf("rebuild",Wf),accessorRevision:Bf("rebuild",Wf),colorAccessor:Bf("rebuild",Gf),symbolAccessor:Bf("rebuild",Xf),connectorAccessor:Bf("rebuild",Xf),dataIdAccessor:Bf("rebuild",Xf),projection:Bf("preserve",Yf),extentPadding:Bf("preserve",Yf),axisExtent:Bf("preserve",Yf),rExtent:Bf("preserve",Yf),oExtent:Bf("preserve",Yf),multiAxis:Bf("preserve",Yf),normalize:Bf("preserve",Yf),bins:Bf("preserve",Yf),oSort:Bf("preserve",qf),barPadding:Bf("preserve",qf),roundedTop:Bf("preserve",qf),baselinePadding:Bf("preserve",qf),innerRadius:Bf("preserve",qf),cornerRadius:Bf("preserve",qf),startAngle:Bf("preserve",qf),sweepAngle:Bf("preserve",qf),trackFill:Bf("preserve",qf),showOutliers:Bf("preserve",qf),showIQR:Bf("preserve",qf),amplitude:Bf("preserve",qf),connectorOpacity:Bf("preserve",qf),showLabels:Bf("preserve",qf),dynamicColumnWidth:Bf("rebuild",qf),customLayout:Bf("preserve",qf),layoutConfig:Bf("preserve",qf),layoutMargin:Bf("preserve",qf),symbolMap:Bf("preserve",Xf),pieceStyle:Bf("preserve",Gf),summaryStyle:Bf("preserve",Gf),connectorStyle:Bf("preserve",Gf),gradientFill:Bf("preserve",Gf),colorScheme:Bf("preserve",Gf),themeCategorical:Bf("preserve",Gf),themeSemantic:Bf("preserve",Gf),themeSequential:Bf("preserve",Gf),themeDiverging:Bf("preserve",Gf),barColors:Bf("preserve",Gf),decay:Bf("preserve",Gf),pulse:Bf("preserve",Gf),staleness:Bf("preserve",Gf),layoutSelection:Bf("preserve",Gf),windowSize:Bf("preserve",Vf),windowMode:Bf("preserve",Vf),clock:Bf("preserve",Vf),transition:Bf("preserve",Vf),introAnimation:Bf("preserve",Vf),onLayoutError:Bf("preserve",Vf)},Uf=Bf("preserve",qf),Kf=class{constructor(){this.tracker=new ns}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}},Ef)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Df):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const o=new Set;for(const i of t){const t=Hf[i]??Uf;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},Zf=require("d3-quadtree"),Qf=class{constructor(t){this.rExtent=new Yc,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Kf,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new $f,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 Wc(t.windowSize),this.getO=Vc(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>Xc(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Yc)):(this.getR=Xc(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Vc(t.stackBy),this.getGroup=Vc(t.groupBy),this.getColor=Vc(t.colorAccessor),this.getSymbol=Vc(t.symbolAccessor),this.getConnector=Vc(t.connectorAccessor),this.getDataId=Vc(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new Wc(t.windowSize))}syncPulseTimestampBuffer(){var t,e,o,i;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,o=this.timestampBuffer,i=this.currentTime(),t?null!=o&&o.capacity===e.capacity&&o.size===e.size?o:Vl(e,i):null)}currentTime(){return this.config.clock?.()??il()}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(),Gl(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const o of t.inserts)Hl(this.buffer,o,this.timestampBuffer,e),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of t.inserts){const t=Hl(this.buffer,o,this.timestampBuffer,e);this.categories.add(this.getO(o)),this.pushValueExtent(o),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 o="function"==typeof e?e(t):t[e];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(t){const{config:e,buffer:o}=this,i=this.scales,n=this.multiScales,r=this.columns;if(0===o.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(o,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(d){f=(0,Lf.scaleBand)().domain(c).range([0,1]).padding(0);const o=Math.min(t.width,t.height)/2,i=e.innerRadius||0;p=(0,Lf.scaleLinear)().domain(l).range([i,o])}else u?(f=(0,Lf.scaleBand)().domain(c).range([0,t.height]).padding(h),p=(0,Lf.scaleLinear)().domain(l).range([0,t.width])):(f=(0,Lf.scaleBand)().domain(c).range([0,t.width]).padding(h),p=(0,Lf.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((i,n)=>{const r=this.rExtents[n];r.dirty&&r.recalculate(o,i);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(e.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Lf.scaleLinear)().domain([s,a]).range([0,t.width]):(0,Lf.scaleLinear)().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,o)=>({...t,__rIndex:o,__rValue:e(t),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(y,c,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=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,o=Array.isArray(e)?e[t]:e;return"string"==typeof o?o:"value"+t}resolveCategories(t){const e=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===e?void 0:e;let n=null;if(o){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(o&&void 0===i){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===i)return r;if("function"==typeof i)return r.sort(i);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===i?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:o,projection:i,normalize:n,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=t,f=s;if("radial"===i&&("pie"===o||"donut"===o))return[0,1];let p=0,y=0;if("bar"===o&&d&&n)p=0,y=1;else if("bar"===o&&d){const t=new Map,o=new Map;for(const i of e){const e=l(i),n=u(i);0>n?o.set(e,(o.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 o.values())p>t&&(p=t)}else if("bar"===o){const t=new Map;for(const o of e){const e=l(o),i=u(o);t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===o){const t=new Map;for(const o of e){const e=l(o),i=Math.abs(u(o));t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===o||"bar-funnel"===o)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=h[0],e=h[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(y=r[1]));const g="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==o&&"exact"!==c){const t=y-p,e=t>0?t*f:1,i=g&&!a&&0===p,n=g&&!a&&0===y||"swimlane"===o;null!=r?.[0]||i||(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,o,i,n){return function(t){const{data:e,oExtent:o,oScale:i,projection:n,layout:r,dynamicColumnWidth:s,getO:a,getR:c}=t,l=Object.create(null),u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let d=0;if("radial"===n)for(const t of e)d+=Math.abs(c(t));let h=null;if(s&&"radial"!==n){h=new Map;let t=0;for(const e of o){const o=u.get(e)||[];let i;i="string"==typeof s?o.reduce((t,e)=>t+(Number(e[s])||0),0):s(o),h.set(e,i),t+=i}const e=("horizontal"===n?r.height:r.width)-i.padding()*i.step()*o.length;if(t>0)for(const[o,i]of h)h.set(o,i/t*e)}let f=0,p=0;for(const t of o){const e=u.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(c(e)),0),n=d>0?o/d:0;let r,s;h?(r=p,s=h.get(t)||i.bandwidth(),p+=s+i.padding()*i.step()):(r=i(t)??0,s=i.bandwidth()),l[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:i.padding()*i.step(),pieceData:e,pct:n,pctStart:f},f+=n}return l}({data:t,oExtent:e,oScale:o,projection:i,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 o=this.buildLayoutContext(t,e);let i;try{i=this.config.customLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,o=Dl("ordinal",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.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=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const n=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.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 Fl({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 o=this.getSceneContext(),i=Nf[this.config.chartType];let n=i?i(o,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:o,config:i,getConnector:n,getO:r}=t;if(!n||!o)return[];const s=[],{projection:a}=o,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const o=n(e);if(!o)continue;let i,s;"point"===t.type?(i=t.x,s=t.y):(i=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:s,datum:e,category:r(e)})}const l=o.o.domain(),u=i.connectorStyle;for(const[e,o]of c)if(o.length>=2){o.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;o.length-1>i;i++){const n=o[i],r=o[i+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}(o,n);n=[...t,...n]}return n}buildLayoutContext(t,e){const o=this.config,i=o.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Ns(o.colorScheme,o.themeCategorical,nt),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:i,plot:"radial"===r.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:o.themeSemantic??{},categorical:[...n]},resolveColor:Es(n,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}computeDecayOpacity(t,e){const o=this.config.decay;return o&&e>1?nl(o,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=rl(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 o="function"==typeof e,i=o?null:e||"category",n=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=o?e(s):s[i],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,o=0;for(const i of t)"point"===i.type&&!1!==i.interactive&&(e++,i.r>o&&(o=i.r));if(500>=e)return{quadtree:null,maxRadius:o};const i=Array(e);let n=0;for(const e of t)"point"===e.type&&!1!==e.interactive&&(i[n++]=e);return{maxRadius:o,quadtree:(0,Zf.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const o=e.length;if(1>=o)return;const i=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=i.get(e.datum);if(null==t)continue;const n=this.computeDecayOpacity(t,o);e.style={...e.style,opacity:(e.style?.opacity??1)*n}}}applyPulse(t,e,o=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,o,i,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 i=0;for(const s of n(e)??[]){const e=o.get(s);null!=e&&(i=Math.max(i,sl(t,e,r)))}c=al(l,i,s)||c;continue}if(null==l.datum)continue;const e=i.get(l.datum);if(null==e)continue;const u=o.get(e);c=al(l,null==u?0:sl(t,u,r),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),o)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&cl(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,o="horizontal"!==this.scales?.projection;let i;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,o?{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}:{x:e,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===i&&(i=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:i,endAngle:i,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const o=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,i=e.get(o)||0;return e.set(o,i+1),`${o}:${i}`}if("rect"===t.type){const o=t.datum?null!=t.datum.category&&""!==t.datum.category?t.datum.category+"":(this.getO(t.datum)??"")+"":"",i=`r:${t.group||""}:${o}`,n=e.get(i)||0;return e.set(i,n+1),0===n?i:`${i}:${n}`}return"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 o=this.scene[e],i=this.getNodeKey(o,t);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity??o.style.fillOpacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity??o.style.fillOpacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.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 o=new Set,i=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=this.getNodeKey(n,i);if(!r)continue;n._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===n.type)s?(o.add(r),n._targetOpacity=n.style.opacity??n.style.fillOpacity??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??n.style.fillOpacity??1,n._targetR=n.r,n.r=0,n.style={...n.style,opacity:0},e=!0);else if("rect"===n.type)s?(o.add(r),n._targetOpacity=n.style.opacity??n.style.fillOpacity??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??n.style.fillOpacity??1,n.style={...n.style,opacity:0},e=!0);else if("wedge"===n.type)if(s)o.add(r),n._targetOpacity=n.style.opacity??n.style.fillOpacity??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??n.style.fillOpacity??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,i]of this.prevPositionMap)if(!o.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((i.startAngle??0)+(i.endAngle??0))/2,o={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}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=el(t,this.activeTransition),o=tl(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style.opacity=ol(i?i.opacity??1:0,t._targetOpacity,o)}const i=this.prevPositionMap.get(e);void 0!==t._targetX&&i&&(t.x=ol(i.x,t._targetX,o),t.y=ol(i.y,t._targetY,o)),void 0!==t._targetR&&void 0!==i?.r&&(t.r=ol(i.r,t._targetR,o))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style.opacity=ol(i?i.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=ol(i.x,t._targetX,o),t.y=ol(i.y,t._targetY,o),void 0!==i.w&&(t.w=ol(i.w,t._targetW,o),t.h=ol(i.h,t._targetH,o))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style={...t.style,opacity:ol(i?i.opacity??1:0,t._targetOpacity,o)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=ol(i.startAngle,t._targetStartAngle,o),t.endAngle=ol(i.endAngle,t._targetEndAngle,o))}}}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,function(t){for(const e of t){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}"point"===e.type?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):void 0!==e._targetR&&(e.r=e._targetR,e._targetR=void 0):"rect"===e.type?void 0!==e._targetX&&(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):"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0)}}(this.scene),this.exitNodes=[]}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=Jc(t),o=this.getDataId,i=t=>e.has(o(t));Ul(this.buffer,this.timestampBuffer,i);const n=this.buffer.remove(i);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 o=Jc(t),i=this.getDataId,n=new Set;this.buffer.forEach((t,e)=>{o.has(i(t))&&n.add(e)});const r=this.buffer.update(t=>o.has(i(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),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 o=this._customRestyle;if(o)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},n=o(i,e);i.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),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},o=Object.keys(t).filter(o=>t[o]!==e[o]);"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&&!qc(t.colorAccessor,e.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in t&&!qc(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!qc(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in t||"oAccessor"in t)&&(qc(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=Vc(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let n=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,o=e.valueAccessor||e.rAccessor,i=Array.isArray(t)?t:[t],r=Array.isArray(o)?o:[o];if(n=i.length!==r.length||i.some((t,e)=>!qc(t,r[e])),n){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>Xc(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Yc)):(this.getR=Xc(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!qc(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?Vc(this.config.stackBy):void 0),"groupBy"in t&&!qc(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?Vc(this.config.groupBy):void 0),"colorAccessor"in t&&!qc(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Vc(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!qc(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Vc(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!qc(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Vc(this.config.connectorAccessor):void 0),(i||n||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};iu(Qf);var Jf=c(require("react")),tp=require("react/jsx-runtime");function ep(t){return"connector"===t.node.type}function op(t,e,o,i){if(2>t.length)return null;const n=t[0].node,r=n.style.fill;if(!r||"none"===r)return null;const s=Cu(`${e?e+"-":""}connector-${o}-${i}-hatch`),a=xn(r)?bn(r,s):null,c=[`${n.x1},${n.y1}`,...t.map(({node:t})=>`${t.x2},${t.y2}`)].join(" ");return Nu((0,tp.jsxs)(Jf.Fragment,{children:[a&&(0,tp.jsx)("defs",{children:a}),(0,tp.jsx)("polygon",{points:c,fill:a?`url(#${s})`:Ru(r,"#999"),opacity:n.style.fillOpacity??n.style.opacity??.3,"data-semiotic-connector-fill":n.group||"_default"})]}),n,`ordinal-connector-fill-${o}-${i}`)}function ip(t,e,o){const i=new Map;for(const e of t){if(!ep(e))continue;const t=e.node.group||"_default",o=i.get(t);o?o.push(e):i.set(t,[e])}if(0===i.size)return;const n=Array.from(i.values()).map((t,i)=>(0,tp.jsxs)("g",{children:[op(t,e,o,i),t.map(t=>t.element)]},`ordinal-connectors-${o}-${i}`)),r=t[0],s=ep(r)?null:r.element;for(const t of i.values())for(const e of t)e.element=null;r.element=(0,tp.jsxs)(Jf.Fragment,{children:[n,s]},"ordinal-connector-run-"+o)}function np(t){const e=id({nodes:t.nodes,renderMode:t.renderMode,fallback:(e,o)=>Zu(e,o,t.idPrefix)});let o=0;for(let i=0;e.length>i;){if(e[i].renderedByBackend){i++;continue}let n=i+1;for(;e.length>n&&!e[n].renderedByBackend;)n++;ip(e.slice(i,n),t.idPrefix,o++),i=n}return e}var rp=require("react/jsx-runtime"),sp=require("react/jsx-runtime"),ap=new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);function cp(t,e){const o=Ot(t.theme),i=t.size||[500,400],n=pe({...vf,...t.margin},t.title),r=he(t.title),s=P(t.data),a=t.showLegend?yd(s,t.colorAccessor||t.stackBy||t.groupBy):[],c=function(t){const e=t.projection??"vertical",o=!1!==t.showAxes&&"radial"!==e;return{hasAxis:o,hasAxisLabel:o&&("horizontal"===e?t.hasValueLabel:t.hasCategoryLabel),leftAxis:{hasAxis:o,hasAxisLabel:o&&("horizontal"===e?t.hasCategoryLabel:t.hasValueLabel)}}}({showAxes:t.showAxes,projection:t.projection,hasCategoryLabel:!(!t.categoryLabel&&!t.oLabel),hasValueLabel:!(!t.valueLabel&&!t.rLabel)});pf(n,{props:{...t,axisChrome:c},categories:a,theme:o,size:i,hasTitle:r});const l=yf({props:{...t,axisChrome:c},categories:a,theme:o,size:i,margin:n,hasTitle:r}),u=i[0]-n.left-n.right,d=i[1]-n.top-n.bottom,h=t.projection||"vertical",f="radial"===h,p=t.colorScheme||o.colors.categorical,y={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:kt(t.gradientFill),symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,multiAxis:t.multiAxis,baselinePadding:t.baselinePadding,trackFill:t.trackFill,connectorOpacity:t.connectorOpacity,showLabels:t.showLabels,colorScheme:p,themeCategorical:o.colors.categorical,themeSemantic:It(o),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},g=new Qf(y);t.data&&g.ingest({inserts:s,bounded:!0}),g.computeScene({width:u,height:d});const m=bf(t.backgroundGraphics,i,n,g.scales),x=bf(t.foregroundGraphics,i,n,g.scales);if(!g.scales){let r;const a=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:s,scales:{},layout:{width:u,height:d},theme:o,projection:h,idPrefix:t._idPrefix,onRender:t=>{r=t}}):null;return e&&(e.evidence=Ec({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:r,extraWarnings:g.scales?[]:["NO_SCALES"],margin:n})),jf.renderToStaticMarkup(mf(m||x||t.annotations?(0,sp.jsxs)(sp.Fragment,{children:[m,a,x,g.customLayoutOverlays]}):null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:u,innerHeight:d,legend:l,idPrefix:t._idPrefix}))}const b=t._idPrefix,v=t.showGrid?function(t,e,o,i,n){const r=t.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=zt(o),a=i?i+"-":"",c="vertical"===r.projection,l=Zh(r.r,5,n);return(0,af.jsx)("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((t,o)=>{const i=r.r(t);return(0,af.jsx)("line",{x1:0,y1:i,x2:e.width,y2:i,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((t,o)=>{const i=r.r(t);return(0,af.jsx)("line",{x1:i,y1:0,x2:i,y2:e.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(g,{width:u,height:d},o,b,t.axisExtent):null;let w=null;if(g.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=lf(t),i=new Set;for(const t of g.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&i.add("string"==typeof t.style.fill?t.style.fill:"#666");w=Array.from(i).map((t,i)=>function(t){const{id:e,background:o="transparent",stroke:i="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return(0,rp.jsxs)("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[o&&"transparent"!==o&&(0,rp.jsx)("rect",{width:a,height:a,fill:o}),(0,rp.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:n}),(0,rp.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:i,strokeWidth:n})]},e)}({id:`funnel-hatch-${e}-${i}`,background:t,stroke:"transparent"===o.colors.background?"#fff":o.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(i).forEach((t,o)=>n.set(t,`funnel-hatch-${e}-${o}`));for(const t of g.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 k=np({nodes:g.scene,renderMode:t.renderMode,idPrefix:b}),S=k.map(t=>t.element),A=!1!==t.showAxes?function(t,e,o,i,n,r,s,a=!1){const c=t.scales;if(!c)return null;if("radial"===c.projection)return null;const l=zt(i),u="vertical"===c.projection,d=t.columns,h=o.categoryFormat||o.oFormat,f=o.valueFormat||o.rFormat,p=o.categoryLabel||o.oLabel,y=o.valueLabel||o.rLabel,g=o.legendPosition??"right",m=$e(o.legendLayout,s?.leftAxis),x=a&&"left"===g&&m>0?m:r?.left??o.margin?.left??40,b=Object.values(d).map((t,e)=>({pixel:t.middle,label:h?h(t.name,e):t.name})),v=Zh(c.r,5,o.axisExtent).map(t=>({pixel:c.r(t),label:(f||gf)(t)}));return(0,sp.jsxs)("g",u?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[(0,sp.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:l.border,strokeWidth:1}),b.map((t,o)=>(0,sp.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,sp.jsx)("line",{y2:5,stroke:l.border,strokeWidth:1}),Jh(t.label)?(0,sp.jsx)("text",{y:18,textAnchor:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:t.label}):tf({label:t.label,x:-30,y:6,textAlign:"center",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"oxtick-"+o)),p&&(0,sp.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:p}),(0,sp.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:l.border,strokeWidth:1}),v.map((t,e)=>(0,sp.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,sp.jsx)("line",{x2:-5,stroke:l.border,strokeWidth:1}),(0,sp.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:t.label})]},"oytick-"+e)),y&&(0,sp.jsx)("text",{x:15-x,y:e.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(-90, ${15-x}, ${e.height/2})`,children:y})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[(0,sp.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:l.border,strokeWidth:1}),v.map((t,o)=>(0,sp.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,sp.jsx)("line",{y2:5,stroke:l.border,strokeWidth:1}),(0,sp.jsx)("text",{y:18,textAnchor:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:t.label})]},"oxtick-"+o)),y&&(0,sp.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:y}),(0,sp.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:l.border,strokeWidth:1}),b.map((t,e)=>(0,sp.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,sp.jsx)("line",{x2:-5,stroke:l.border,strokeWidth:1}),Jh(t.label)?(0,sp.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:t.label}):tf({label:t.label,x:-68,y:-12,textAlign:"right",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"oytick-"+e)),p&&(0,sp.jsx)("text",{x:15-x,y:e.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(-90, ${15-x}, ${e.height/2})`,children:p})]})}(g,{width:u,height:d},t,o,b,n,c,!!l):null;let M;const _=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:s,scales:{o:g.scales.o,r:g.scales.r,y:"vertical"===g.scales.projection?g.scales.r:void 0},layout:{width:u,height:d},theme:o,projection:h,xAccessor:"string"==typeof t.oAccessor?t.oAccessor:void 0,yAccessor:"string"==typeof t.rAccessor?t.rAccessor:void 0,idPrefix:b,onRender:t=>{M=t}}):null;if(e){const o=g.scales.o?.domain?.();e.evidence=Ec({frameType:"ordinal",width:i[0],height:i[1],marks:k.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:M,yDomain:Nc(g.scales.r?.domain?.()),categories:Array.isArray(o)?o.map(String):void 0,margin:n})}const j=f&&t.centerContent?function(t,e,o){if(!Pf.isValidElement(t))return null;if("string"!=typeof t.type||!ap.has(t.type))return null;const i=t,n="text"===i.type?Pf.cloneElement(i,{x:i.props.x??0,y:i.props.y??0,textAnchor:i.props.textAnchor??"middle",dominantBaseline:i.props.dominantBaseline??"middle"}):i;return(0,sp.jsx)("g",{className:"semiotic-radial-center-content",transform:`translate(${e},${o})`,pointerEvents:"none",children:n})}(t.centerContent,n.left+u/2,n.top+d/2):null,L=f&&t.centerContent?j??(0,sp.jsx)("foreignObject",{x:n.left,y:n.top,width:u,height:d,pointerEvents:"none",children:(0,sp.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:t.centerContent})}):null,$=(0,sp.jsxs)(sp.Fragment,{children:[v,S,A,_,x,g.customLayoutOverlays]});return jf.renderToStaticMarkup(mf((0,sp.jsxs)(sp.Fragment,f?{children:[m?(0,sp.jsx)("g",{transform:`translate(${-u/2},${-d/2})`,children:m}):null,$]}:{children:[m,$]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:f?`translate(${n.left+u/2},${n.top+d/2})`:`translate(${n.left},${n.top})`,innerWidth:u,innerHeight:d,legend:l,defs:w,outerElements:L,idPrefix:t._idPrefix}))}var lp=c(require("react-dom/server"));function up(t,e){var o=t.get(e);if(!o)throw Error("missing: "+e);return o}function dp(t,e){var o,i=[],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,i,d=!1;for(n.push(t),r[t]=!0,e=0;a[t].length>e;e++)(i=a[t][e])===o?(u(o,n),d=!0):r[i]||(d=l(i));if(d)c(t);else for(e=0;a[t].length>e;e++){var h=s[i=a[t][e]];h||(s[i]=h={}),h[i]=!0}return n.pop(),d}function u(t,o){var n=[].concat(o).concat(t);e?e(n):i.push(n)}function d(e){!function(e){for(var o=0;t.length>o;o++)o>=e&&t[o]||(t[o]=[]),t[o]=t[o].filter(function(t){return t>=e})}(e);for(var o,i=function(t){for(var e=t.length,o=Array(e),i=Array(e),n=Array(e),r=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)o[c]=-1,i[c]=0,n[c]=!1,r[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(e){var c=[e],l=[e];for(o[e]=i[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>o[y]){o[y]=i[y]=u,n[y]=!0,u+=1,c.push(y),l.push(y);break}n[y]&&(i[e]=0|Math.min(i[e],i[y])),0>s[y]||a[e].push(s[y])}r[e]=p}else{if(i[e]===o[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]=d.length,b===e){c.length=p;break}}d.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];h.push(v)}l.pop()}}}for(c=0;e>c;++c)0>o[c]&&f(c);for(c=0;h.length>c;c++){var p=h[c];if(0!==p.length){p.sort(function(t,e){return t-e}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);h[c]=l}}return{components:d,adjacencyList:h}}(t),n=i.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],o=s);var c=n[o];return!!c&&{leastVertex:r,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}o=0;for(var h=t.length;h>o;){var f=d(o);if(o=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(o),o+=1}else o=h}return e?void 0:i}function hp(t){return t.y0-t.y1>0?"up":"down"}function fp(t,e){return e(t.source)==e(t.target)}function pp(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var o=0;return t.target.targetLinks.forEach(function(t){o=t.circular?o+1:o}),1>=e&&1>=o}function yp(t){return t.target.x0-t.source.x1}function gp(t,e){var o=xp(t),i=yp(e)/Math.tan(o);return"up"==hp(t)?t.y1-i:t.y1+i}function mp(t,e){var o=xp(t),i=yp(e)/Math.tan(o);return"up"==hp(t)?t.y1+i:t.y1-i}function xp(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function bp(t,e){return e(t)}function vp(t){return kp(t.source)}function wp(t){return kp(t.target)}function kp(t){return(t.y0+t.y1)/2}function Sp(t){return t.virtual?0:t.value}function Ap(t,e){var o=0;t.sourceLinks.forEach(function(t){o=t.circular&&!fp(t,e)?o+1:o});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!fp(t,e)?i+1:i}),o+i}function Mp(t){return t.target.depth}function _p(t,e){return t.sourceLinks.length?t.depth:e-1}function Pp(t,e){return t.y0-e.y0}function jp(t,e){return e.y0-t.y0}function Lp(t,e){return t.y1-e.y1}function $p(t,e){return e.y1-t.y1}function Rp(t,e){return Ip(t.source,e.source)||t.index-e.index}function Cp(t,e){return Ip(t.target,e.target)||t.index-e.index}function Ip(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Tp(t,e){return Op(t)==Op(e)?"bottom"==t.circularLinkType?jp(t,e):Pp(t,e):Op(e)-Op(t)}function Op(t){return t.target.column-t.source.column}function zp(t,e){return Fp(t)==Fp(e)}function Fp(t){return t.y0-t.y1>0?"up":"down"}var Np=require("d3-array");function Ep(t,e,o,i,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,Np.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}),Dp(r.links.filter(function(t){return"top"==t.circularLinkType}),e,o),Dp(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,o),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,fp(t,e)&&pp(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+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?jp:Pp);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+n*o+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?$p:Lp),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+n*o+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,o=t.y0,i=t.target.x0,n=t.y1,r=(e+i)/2;return"M"+e+","+o+"C"+r+","+o+" "+r+","+n+" "+i+","+n}(t)}),r}function Dp(t,e,o){t.sort(Tp);var i=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(fp(t,e)&&pp(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Bp(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+o;r=c>r?c:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function Bp(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}var Wp=require("d3-array");function Yp(t){return function(){return t}}function qp(t){return t.index}function Xp(t){return t.nodes}function Gp(t){return t.links}function Vp(t,e,o){var i=(0,Wp.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(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 o,i,n,r=(i=0,n=0,(o=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=kp(t.source)*e,i+=e}}),o.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=kp(t.target)*e,i+=e}}),i>0?n/i:NaN);a.set(t,{bc:r,idx:e})}),n.sort(function(t,e){var o=a.get(t),i=a.get(e),n=o.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(n)||isNaN(r)?isNaN(n)?isNaN(r)?o.idx-i.idx:1:-1:n-r})}else n.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ap(e,o)-Ap(t,o):"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==i.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Ap(e,o)?(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 Hp(t,e,o,i,n,r){var s=(0,Wp.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,o),u();function l(e,o){var i=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&&Ap(n,o)>0){var c=(0,Wp.mean)(n.sourceLinks,wp),l=(0,Wp.mean)(n.targetLinks,vp),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-kp(n))*e*.3;n.y0+=d,n.y1+=d}}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==i-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 h=(0,Wp.mean)(n.sourceLinks,wp),f=(0,Wp.mean)(n.targetLinks,vp),p=((h&&f?(h+f)/2:h||f)-kp(n))*e;n.y0+=p,n.y1+=p}})})}function u(){s.forEach(function(o){var r,s,a,c=t.y0,l=o.length;for(o.sort(e||Ip),a=0;l>a;++a)(s=c-(r=o[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+i;if((s=c-i-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=o[a]).y1+n-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function Up(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Cp),t.targetLinks.sort(Rp)}),t.nodes.forEach(function(t){var e=t.y0,o=e,i=t.y1,n=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=o+t.width/2,o+=t.width)})})}function Kp(){var t=0,e=0,o=1,i=1,n=24,r=8,s=null,a=qp,c=_p,l=void 0,u=32,d=2,h=Xp,f=Gp;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=o,h.y1=i,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var o=function(t,e){var o=new Map;return(0,Wp.group)(t,e).forEach(function(t,e){o.set(e,t[0])}),o}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,n=t.target;"object"!=typeof i&&(i=t.source=up(o,i)),"object"!=typeof n&&(n=t.target=up(o,n)),i.sourceLinks.push(t),n.targetLinks.push(t)})}(h,a),function(t,e){var o=0;if(null==e){for(var i=[],n=0;t.links.length>n;n++){var r=t.links[n],s=r.source.index,a=r.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=dp(i);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,i=t.source.index;e===i||l[i]&&l[i][e]?(t.circular=!0,t.circularLinkID=o++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=o++)})}(h,l),function(t,e){var o=0,i=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:i>o?"top":"bottom","top"==n.circularLinkType?o++:i++,t.nodes.forEach(function(t){bp(t,e)!=bp(n.source,e)&&bp(t,e)!=bp(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),fp(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max((0,Wp.sum)(t.sourceLinks,Sp),(0,Wp.sum)(t.targetLinks,Sp)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,o){var i,n,r;if(null!=e){t.nodes.sort(function(t,o){return e(t)<e(o)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(i=t.nodes,n=[],r=0;i.length;++r,i=n,n=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(i=t.nodes,n=[],r=0;i.length;++r,i=n,n=[])i.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?o(t,r):t.column})}(h,l,c);var f=r;if(null!==s){var p=(0,Wp.groups)(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=(0,Wp.max)(p,function(t){return t.length});y>1&&(f=Math.max(1,(i-e)*s/(y-1)))}(function(t,e,o){var i=(0,Wp.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,Wp.min)(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/(0,Wp.sum)(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var r=(0,Wp.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-o)/r),e.x1=e.x0+o}:function(e){e.x0=t.x0,e.x1=e.x0+o})})(h,f,n),Vp(h,l,a),Hp(h,l,a,f,f,u),Up(h),Ep(h,a,d,10,8),Vp(h,l,a),Hp(h,l,a,f,f,u),Up(h),Ep(h,a,d,10,8),function(t,e){let o=t;o.nodes.forEach(function(t){t.y+(t.y1-t.y0)>o.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-o.y1));var i=o.links.filter(function(o){return bp(o.source,e)==bp(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!zp(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var o=gp(e,t);return t.y1-o}if(e.target.column>t.target.column)return gp(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,o){if("bottom"==e.circularLinkType){for(var r=o+1,s=0;n>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(h,a),function(t,e){let o=t;o.nodes.forEach(function(t){var i=o.links.filter(function(o){return bp(o.target,e)==bp(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!zp(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var o=mp(e,t);return t.y0-o}if(e.source.column>t.source.column)return mp(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,o){if("bottom"==e.circularLinkType){for(var r=o+1,s=0;n>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(h,a),function(t){var e=t.nodes,o=t.links,i=!1,n=!1;if(o.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==i||0==n){let i=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=(0,Wp.min)(e,function(t){return t.y0}),s=(0,Wp.max)(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1)}),o.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,o=i(t.y0)-t.y0;t.y0=i(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+o}),t.targetLinks.forEach(function(t){t.y1=t.y1+o})})}}(h),Ep(h,a,d,10,8)}(p),p}return p.update=function(t){return Up(t),Ep(t,a,d,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?(h="function"==typeof t?t:Yp(t),p):h},p.links=function(t){return arguments.length?(f="function"==typeof t?t:Yp(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Yp(t),p):a},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Yp(t),p):c},p.nodeSort=function(t){return arguments.length?(l=t,p):l},p.iterations=function(t){return arguments.length?(u=+t,p):u},p.circularLinkGap=function(t){return arguments.length?(d=+t,p):d},p.extent=function(n){return arguments.length?(t=+n[0][0],e=+n[0][1],o=+n[1][0],i=+n[1][1],p):[[t,e],[o,i]]},p.size=function(n){return arguments.length?(t=e=0,o=+n[0],i=+n[1],p):[o-t,i-e]},p}var Zp=require("d3-interpolate"),Qp=(require("d3-shape"),.5),Jp=t=>{let e,o,i,n,r,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,o=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=(0,Zp.interpolateNumber)(r,s),c=a(Qp),l=a(.5),`M${e},${r}C${e},${c} ${o},${l} ${o},${s}L${i},${s}C${i},${l} ${n},${c} ${n},${r}Z`;const u=t.sankeyWidth/2,d=(0,Zp.interpolateNumber)(t.source.x1,t.target.x0),{pathD:h}=cn({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:d(Qp),cp2X:d(.5)});return h};function ty(t){const e=t.sankeyWidth/2,o=(t._circularWidth??t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const o=i.sourceX,n=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-o))),c=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${o},${n-e}L${o+a},${n-e}L${o+a},${n+e}L${o},${n+e}ZM${r},${s-e}L${r-c},${s-e}L${r-c},${s+e}L${r},${s+e}Z`}const n=i.sourceX,r=i.sourceY,s=i.targetX,a=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,h=Math.max(4,Math.min(o,15));return`M${n},${r-d*e}L${c},${r-d*e}L${c+o},${r-d*e+d*h}L${c+o},${u+d*o-d*h}L${c+o-h},${u+d*o}L${l-o+h},${u+d*o}L${l-o},${u+d*o-d*h}L${l-o},${a-d*e+d*h}L${l-o+h},${a-d*e}L${s},${a-d*e}L${s},${a+d*e}L${l+o},${a+d*e}L${l+o},${u-d*o}L${c-o},${u-d*o}L${c-o},${r+d*e}L${n},${r+d*e}Z`}var ey=new Set,oy=new WeakMap;function iy(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let o=oy.get(t);if(o){const t=o.get(e);if(t)return t}else o=new Map,oy.set(t,o);const i=new Proxy(t,{get(t,o,i){if("string"==typeof o&&!(o in t)&&t.data&&o in t.data){const t=`${e}:${o}`;ey.has(t)||(ey.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,o,i)}});return o.set(e,i),i}var ny={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(Mp))-1:0},justify:_p},ry={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,o,i){if(0===t.length)return;const n="vertical"===o.orientation?"down":"right",r=o.nodeAlign||"justify",s=o.nodeWidth??15,a=o.nodePaddingRatio??.05,c=o.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:Uc(t.source),target:Uc(t.target),value:Math.sqrt(Math.max(1,t.value||1))}));let d;d="down"===n?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const h=Kp().extent(d).links(u).nodes(l).nodeAlign(ny[r]||_p).nodeId(t=>t.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let t=1/0,e=-1/0,o=1/0,n=-1/0;for(const i of l)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),o>i.y0&&(o=i.y0),i.y1>n&&(n=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(i._circularWidth??i.width??0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),o>r.verticalFullExtent-s&&(o=r.verticalFullExtent-s),r.verticalFullExtent+s>n&&(n=r.verticalFullExtent+s)}const r=e-t,s=n-o,a=i[0],c=i[1];if(r>0&&s>0&&(0>t||0>o||e>a||n>c)){const e=Math.min(a/r,c/s),i=-t*e+(a-r*e)/2,n=-o*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+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 o=t.circularPathData;o.sourceX=o.sourceX*e+i,o.targetX=o.targetX*e+i,o.sourceY=o.sourceY*e+n,o.targetY=o.targetY*e+n,o.rightFullExtent=o.rightFullExtent*e+i,o.leftFullExtent=o.leftFullExtent*e+i,o.verticalFullExtent=o.verticalFullExtent*e+n,o.rightInnerExtent=o.rightInnerExtent*e+i,o.leftInnerExtent=o.leftInnerExtent*e+i,o.verticalRightInnerExtent=o.verticalRightInnerExtent*e+n,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*e+n,o.rightSmallArcRadius*=e,o.rightLargeArcRadius*=e,o.leftSmallArcRadius*=e,o.leftLargeArcRadius*=e,o.sourceWidth*=e,o.rightNodeBuffer*=e,o.leftNodeBuffer*=e,o.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)if(t._edgeKey)p.set(t._edgeKey,t);else{const e=Uc(t.source),o=Uc(t.target);p.set(`${e}\0${o}`,t)}for(const t of u){const e=Uc(t.source),o=Uc(t.target),i=p.get(t._edgeKey?t._edgeKey:`${e}\0${o}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=t.width??0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=n;const r=f.get(e),s=f.get(o);r&&(i.source=r),s&&(i.target=s)}}},buildScene(t,e,o,i){const n="vertical"===o.orientation?"down":"right",r=o.nodeStyle,s=o.edgeStyle,a=o.edgeOpacity??.5,c=o.edgeColorBy||"source",l=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:C,u=new Map;t.forEach((t,e)=>{u.set(t.id,l[e%l.length])});const d=[],h=[],f=[],p=new Map;for(const e of t){const t=e.x1-e.x0,o=e.y1-e.y0;if(0>=t||0>=o)continue;const i=r?r(iy(e,"nodeStyle")):{},s={fill:i.fill||u.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity,cursor:i.cursor};p.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),d.push("down"===n?{type:"rect",x:e.y0,y:e.x0,w:o,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:o,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n=o.themeSemantic?.border||o.themeSemantic?.secondary||"#999";n="function"==typeof c?c(t)||n:"target"===c?p.get(i.id)||u.get(i.id)||n:p.get(e.id)||u.get(e.id)||n;const r=s?s(iy(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,o=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=r.fill||n;h.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-o}L${e.sourceX+i},${e.sourceY-o}L${e.sourceX+i},${e.sourceY+o}L${e.sourceX},${e.sourceY+o}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),h.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-o}L${e.targetX-s},${e.targetY-o}L${e.targetX-s},${e.targetY+o}L${e.targetX},${e.targetY+o}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;(l=t.circular&&t.circularPathData?ty(t):Jp(t),l)&&h.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,cursor:r.cursor},datum:t})}if(!1!==o.showLabels){const e=Hc(o.nodeLabel);for(const o of t){const t=o.x1-o.x0,r=o.y1-o.y0;if(0>=t||0>=r)continue;const s=e?e(o):o.id;if(!s)continue;let a,c,l;"down"===n?(a=o.y0+(o.y1-o.y0)/2,c=o.x1+14,l="start"):(i[0]/2>o.x0+t/2?(a=o.x0-6,l="end"):(a=o.x1+6,l="start"),c=o.y0+r/2),f.push({x:a,y:c,text:s+"",anchor:"down"===n?"middle":l,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}},sy=require("d3-force"),ay=require("d3-scale"),cy={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,o,i){if(0===t.length)return;const n=o.forceStrength??.1,r=i[0]/2,s=i[1]/2,a=Math.max(.1,Math.min(1,Math.min(i[0],i[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=o.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),o=l?.get(e.id);t?u++:o?(e.x=o.x,e.y=o.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const o=new Map;for(const e of t)o.set(e.id,e);for(const t of d){const i=ly(t.id,e,o);if(i.length>0){let e=0,o=0;for(const t of i)e+=t.x,o+=t.y;const n=uy(t.id),r=n%360*(Math.PI/180),s=(10+n%20)*a;t.x=e/i.length+s*Math.cos(r),t.y=o/i.length+s*Math.sin(r)}else{const e=uy(t.id),o=e%360*(Math.PI/180),i=(15+e%30)*a;t.x=r+i*Math.cos(o),t.y=s+i*Math.sin(o)}}}else{const e=2.399963229728653;for(let o=0;t.length>o;o++){const i=t[o];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(o+.5)*a,n=o*e;i.x=r+t*Math.cos(n),i.y=s+t*Math.sin(n)}}}const f=o.__skipForceSimulation||0===o.iterations?0:h?40:o.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),p=dy(o.nodeSize,o.nodeSizeRange,t),y=t=>p(t);if(f>0){const l=new Map,u=new Map;for(const e of t)l.set(e.id,0),u.set(e.id,e);for(const t of e){const e=Uc(t.source),o=Uc(t.target);l.set(e,(l.get(e)??0)+1),l.set(o,(l.get(o)??0)+1)}const d=(0,sy.forceLink)().strength(t=>{const e=t.weight,o=Uc(t.source),i=Uc(t.target),r=Math.max(1,Math.min(l.get(o)??1,l.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?u.get(t.source):t.source,o="string"==typeof t.target?u.get(t.target):t.target,i=(e?y(e):0)+(o?y(o):0)+Math.max(6,12*a);return Math.max(16,40*a,i)}).id(t=>t.id),p=(0,sy.forceSimulation)();if(void 0===o.random&&void 0===o.seed||p.randomSource(o.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}}(o.seed)),p.force("charge",(0,sy.forceManyBody)().strength(t=>{const e=l.get(t.id)??0;return-15*a*y(t)*Math.sqrt(e+1)})).force("collide",(0,sy.forceCollide)(t=>y(t)+3*a).strength(.9).iterations(2)).force("center",(0,sy.forceCenter)(r,s).strength(.8)).force("x",(0,sy.forceX)(r).strength(c)).force("y",(0,sy.forceY)(s).strength(c)).force("bounds",function(t,e,o=2,i=.6){let n=[];const r=r=>{const s=i*Math.max(r,.2);for(const i of n){const n=i.x??t[0]/2,r=i.y??t[1]/2,a=i.vx??0,c=i.vy??0,l=e(i)+o,u=Math.min(t[0]/2,l),d=Math.max(t[0]/2,t[0]-l),h=Math.min(t[1]/2,l),f=Math.max(t[1]/2,t[1]-l),p=n+a,y=r+c;u>p?i.vx=a+(u-p)*s:p>d&&(i.vx=a+(d-p)*s),h>y?i.vy=c+(h-y)*s:y>f&&(i.vy=c+(f-y)*s)}};return r.initialize=t=>{n=t},r}(i,y)),p.nodes(t),e.length>0){const t=e.map(t=>({...t,source:Uc(t.source),target:Uc(t.target)}));d.links(t),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let t=0;f>t;++t)p.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=y(e),o=f>0?2:0,n=Math.min(i[0]/2,t+o),r=Math.min(i[1]/2,t+o);e.x=Math.max(n,Math.min(i[0]-n,e.x)),e.y=Math.max(r,Math.min(i[1]-r,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,o,i){const n=o.nodeStyle,r=o.edgeStyle,s=dy(o.nodeSize,o.nodeSizeRange,t),a=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:C,c=new Map;t.forEach((t,e)=>{c.set(t.id,a[e%a.length])});const l=[],u=[],d=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(iy(e,"nodeSize")),i=n?n(iy(e,"nodeStyle")):{},r={fill:i.fill||c.get(e.id)||o.themeSemantic?.primary||"#007bff",stroke:i.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity,cursor:i.cursor};l.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const h=new Map;for(const e of t)h.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:h.get(t.source),i="object"==typeof t.target?t.target:h.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const n=r?r(iy(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:n.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6,cursor:n.cursor},datum:t})}if(!1!==o.showLabels){const e=Hc(o.nodeLabel);for(const o of t){if(null==o.x||null==o.y)continue;const t=e?e(o):o.id;if(!t)continue;const i=s(iy(o,"nodeSize"));d.push({x:o.x,y:o.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:l,sceneEdges:u,labels:d}}};function ly(t,e,o){const i=[];for(const n of e){const e=Uc(n.source),r=Uc(n.target);let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=o.get(s);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function uy(t){let e=0;for(let o=0;t.length>o;o++)e=(e<<5)-e+t.charCodeAt(o)|0;return Math.abs(e)}function dy(t,e,o){if(o.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const i=e||[5,20],n=[];for(const e of o){const o=e.data?.[t];"number"==typeof o&&n.push(o)}if(0===n.length)return()=>i[0];const[r,s]=Nt(n);if(r===s)return()=>(i[0]+i[1])/2;const a=(0,ay.scaleLinear)().domain([r,s]).range(i).clamp(!0);return e=>{const o=e.data?.[t];return null==o||"number"!=typeof o?i[0]:a(o)}}var hy=require("d3-chord"),fy=require("d3-shape"),py=C,yy={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,o,i){if(0===t.length)return;const{padAngle:n=.01,groupWidth:r=20,sortGroups:s}=o,a=Math.min(i[0],i[1])/2,c=a-r,l=i[0]/2,u=i[1]/2,d=(h=o.valueAccessor)?"function"==typeof h?h:t=>t[h]??1:t=>t.value??1;var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e=Uc(t.source),o=Uc(t.target),i=f.get(e),n=f.get(o);if(void 0===i||void 0===n)continue;const r=d(t);y[i][n]=r}const g=(0,hy.chord)().padAngle(n);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,fy.arc)().innerRadius(c).outerRadius(a);for(const e of x){const o=t[e.index],i=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});o.x=i[0]+l,o.y=i[1]+u,o.__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=Uc(t.source),o=Uc(t.target),i=v.get(e),n=v.get(o);i&&(t.source=i),n&&(t.target=n)}const w=new Map;for(const t of e){const e=Uc(t.source),o=Uc(t.target);w.set(`${e}\0${o}`,t)}for(const e of m){const o=t[e.source.index].id,i=t[e.target.index].id,n=w.get(`${o}\0${i}`)||w.get(`${i}\0${o}`);n&&(n.__chordData=e)}},buildScene(t,e,o,i){const{groupWidth:n=20,edgeOpacity:r=.5}=o,s=Math.min(i[0],i[1])/2,a=s-n,c=i[0]/2,l=i[1]/2,u=o.nodeStyle,d=o.edgeStyle,h=o.edgeColorBy||"source",f=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:py,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=(0,hy.ribbon)().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const o=t[e],i=o.__arcData;if(!i)continue;let n;if(u){const t=u(iy(o,"nodeStyle"));n=("string"==typeof t.fill?t.fill:void 0)||p.get(o.id)||f[e%f.length]}else n=p.get(o.id)||f[e%f.length];const r=u?u(iy(o,"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:n,stroke:r.stroke||"black",strokeWidth:r.strokeWidth??1,opacity:r.opacity,cursor:r.cursor},datum:o,id:o.id,label:o.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=y(e);if(!i)continue;const n=gy(i,c,l);let s=o.themeSemantic?.border||o.themeSemantic?.secondary||"#999";if(d){const e=d(iy(t,"edgeStyle"));s=("string"==typeof e.fill?e.fill:void 0)||s}else{const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;"target"===h&&o?s=p.get(o.id)||s:e&&(s=p.get(e.id)||s)}const a=d?d(iy(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,cursor:a.cursor},datum:t})}if(!1!==o.showLabels){const e=Hc(o.nodeLabel),i=s+12;for(const o of t){const t=o.__arcData;if(!t)continue;const n=e?e(o):o.id;if(!n)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*i,y:l+Math.sin(s)*i,text:n+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:x}}};function gy(t,e,o){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const n=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(n.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)n.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(n.push(Number(i[r])+o+""),r++);else if("C"===t)for(n.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)n.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(n.push(Number(i[r])+o+""),r++);else if("Q"===t)for(n.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)n.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(n.push(Number(i[r])+o+""),r++);else if("A"===t)for(n.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&(n.push(Number(i[r])+e+""),r++),i.length>r&&(n.push(Number(i[r])+o+""),r++);else"Z"===t||"z"===t?(n.push(t),r++):(n.push(i[r]),r++)}return n.join(" ")}var my=require("d3-hierarchy"),xy=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function by(t){const[e,o,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*o+.114*i>150?"#222":"#fff"}function vy(t,e,o){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+o}function wy(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 ky(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:xy}function Sy(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 Ay(t,e,o,i,n){if("horizontal"===n){const n=(t+o)/2;return`M ${t},${e} C ${n},${e} ${n},${i} ${o},${i}`}if("radial"===n){const n=(t+o)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+i)/2} T ${o},${i}`}{const n=(e+i)/2;return`M ${t},${e} C ${t},${n} ${o},${n} ${o},${i}`}}var My={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,o,i){const n=o.__hierarchyRoot;if(!n)return;const r=o.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(o.childrenAccessor),a=o.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=(0,my.hierarchy)(n,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,d]=i;switch(r){case"tree":!function(t,e,o,i){const n=e.treeOrientation||"vertical",r=(0,my.tree)();r.size("horizontal"===n?[i,o]:"radial"===n?[2*Math.PI,Math.min(o,i)/2*.8]:[o,i]),r(t)}(l,o,u,d);break;case"cluster":!function(t,e,o,i){const n=e.treeOrientation||"vertical",r=(0,my.cluster)();r.size("horizontal"===n?[i,o]:"radial"===n?[2*Math.PI,Math.min(o,i)/2*.8]:[o,i]),r(t)}(l,o,u,d);break;case"treemap":!function(t,e,o,i){const n=e.padding??4,r=e.paddingTop??0,s=(0,my.treemap)().size([o,i]).tile(my.treemapBinary).padding(n);r>0&&s.paddingTop(r),s(t)}(l,o,u,d);break;case"circlepack":!function(t,e,o,i){const n=e.padding??4;(0,my.pack)().size([o,i]).padding(n)(t)}(l,o,u,d);break;case"partition":!function(t,e,o,i){(0,my.partition)().size([o,i]).padding(e.padding??1)(t)}(l,o,u,d)}const h=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;h.length>e;e++){const i=h[e],n={id:vy(i,o,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===r||"cluster"===r?_y(n,i,o):"treemap"===r||"partition"===r?Py(n,i):"circlepack"===r&&jy(n,i),n.__hierarchyNode=i,t.push(n),f.set(i,n)}if("tree"===r||"cluster"===r)for(const t of h)if(t.parent){const o=f.get(t.parent),i=f.get(t);o&&i&&e.push({source:o,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,o,i){const n=o.nodeStyle||(()=>({})),r=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(t,e,o,i,n,r){const s=[],a=[],c=[],l=o.treeOrientation||"vertical",u="radial"===l,d=i[0]/2,h=i[1]/2,f="number"==typeof(p=o.nodeSize)?p:5;var p;for(const e of t){let t=e.x,i=e.y;u&&(t+=d,i+=h);const r=n(iy(e,"nodeStyle"));let a=r.fill||Sy(o);if(o.colorByDepth&&void 0!==e.depth){const t=ky(o);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:i,r:f,style:{fill:a,stroke:r.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity,cursor:r.cursor},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=o.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n=e.x,s=e.y,c=i.x,f=i.y;u&&(n+=d,s+=h,c+=d,f+=h);const p=Ay(n,s,c,f,l),g=r(iy(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y,cursor:g.cursor},datum:t})}if(!1!==o.showLabels){const e=wy(o.nodeLabel);for(const o of t){const t=e?e(o):o.id;if(!t)continue;let i,n,r,s=o.x,a=o.y;if(u&&(s+=d,a+=h),u){const t=s-d,e=a-h,o=Math.sqrt(t*t+e*e);o>0?(i=s+t/o*10,n=a+e/o*10,r=0>t?"end":"start"):(i=s,n=a-12,r="middle")}else"horizontal"===l?(o.data?.children&&0!==o.data.children.length?(i=s-f-6,r="end"):(i=s+f+6,r="start"),n=a):(i=s,n=a+f+14,r="middle");c.push({x:i,y:n,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,o,i,n,r);case"treemap":case"partition":return function(t,e,o,i){const n=[],r=[];for(const o of t){const t=o.x1-o.x0,r=o.y1-o.y0;if(0>=t||0>=r)continue;const s=i(iy(o,"nodeStyle"));let a=s.fill||Sy(e);if(e.colorByDepth&&void 0!==o.depth){const t=ky(e);a=t[o.depth%t.length]}n.push({type:"rect",x:o.x0,y:o.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity,fillOpacity:s.fillOpacity,strokeOpacity:s.strokeOpacity,cursor:s.cursor},datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==e.showLabels){const o=wy(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=o?o(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let d=i(iy(a,"nodeStyle")).fill||Sy(e);if(e.colorByDepth&&void 0!==a.depth){const t=ky(e);d=t[a.depth%t.length]}const h="string"==typeof d?by(d):e.themeSemantic?.text??"#000";r.push(l?{x:a.x0+t/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,o,0,n);case"circlepack":return function(t,e,o,i){const n=[],r=[];for(const o of t){const t=o.__radius??5;if(0>=t)continue;const r=i(iy(o,"nodeStyle"));let s=r.fill||Sy(e);if(e.colorByDepth&&void 0!==o.depth){const t=ky(e);s=t[o.depth%t.length]}n.push({type:"circle",cx:o.x,cy:o.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7,cursor:r.cursor},datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==e.showLabels){const o=wy(e.nodeLabel);for(const n of t){const t=n.__radius??5,s=o?o(n):n.id;if(!s)continue;if(15>t)continue;const a=!(n.data?.children&&n.data.children.length>0);let c=i(iy(n,"nodeStyle")).fill||Sy(e);if(e.colorByDepth&&void 0!==n.depth){const t=ky(e);c=t[n.depth%t.length]}if(a){const o="string"==typeof c?by(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:o})}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,o,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function _y(t,e,o){const i=o.treeOrientation||"vertical";if("radial"===i){const o=e.x,i=e.y;t.x=i*Math.cos(o-Math.PI/2),t.y=i*Math.sin(o-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Py(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 jy(t,e){const o=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}var Ly=require("d3-shape");function $y(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var Ry={sankey:ry,force:cy,chord:yy,tree:My,cluster:My,treemap:My,circlepack:My,partition:My,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,o,i){const n=o.__hierarchyRoot;n&&function(t,e,o,i,n){const r=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(o.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(o.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),c=o.orbitSize??2.95,l=o.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=$y(o);h.metaMap.clear(),i.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));i.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,o,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:o,depth:y,data:e,parentId:o},M=g?f/u(A)*S:f*S,_=(0,Ly.pie)().value(t=>{const e=r(t)?.length;return e?4:1}).sort(null)(w),P=d(A);for(let e=0;w.length>e;e++){const r=(_[e].startAngle+_[e].endAngle)/2,a=w[e],u=p(s(a)),d=c+M*Math.sin(r),f=l+M*Math.cos(r)*P;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:r,depth:y,parentId:o,eccentricity:P}),n.push({source:o,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:u}}),t(a,u,d,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(n,i,o,t,e)},buildScene(t,e,o,i){const n=o.nodeStyle,r=o.edgeStyle,s=o.nodeSize,a="number"==typeof s?()=>s:"function"==typeof s?s:()=>6,c=[],l=[],u=[];if(!1!==o.orbitShowRings){const e=$y(o),i=new Map;for(const e of t)i.set(e.id,e);const n=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const o=`${t.parentId}:${t.ring}`;n.has(o)||n.set(o,{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:o,ecc:i}]of n)for(let n=0;r>n;n++){const a=n/r*Math.PI*2,c=(n+1)/r*Math.PI*2;l.push({type:"line",x1:t+o*Math.sin(a),y1:e+o*Math.cos(a)*i,x2:t+o*Math.sin(c),y2:e+o*Math.cos(c)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=a(iy(e,"nodeSize")),i=n?n(iy(e,"nodeStyle")):{};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:i.fill||o.themeSemantic?.primary||"#6366f1",stroke:i.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??(0===(e.depth??0)?1:.85),cursor:i.cursor},datum:e,id:e.id,label:e.id,depth:e.depth})}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==o.x)continue;const i=r?r(iy(t,"edgeStyle")):{};l.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:i.stroke||"rgba(128,128,128,0.35)",strokeWidth:i.strokeWidth??.5,opacity:i.opacity??1,cursor:i.cursor},datum:t})}if(o.showLabels){const e=o.nodeLabel;for(const o of t){const t=a(iy(o,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(o):e?o.data?.[e]??o.id:o.id;u.push({x:o.x,y:o.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(t,e,o,i,n)=>!1!==o.orbitAnimated&&(function(t,e){const o=$y(e),i=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())-o.startTime)/1e3,s=i*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=a.get(t.parentId);if(!i)continue;const c=t.angle+r*s*n({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(c),e.y=i.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,o),!0)}};function Cy(t){const e=t.id??t.datum?.id??t.datum?.data?.id??t.datum?.data?.name;return null==e?void 0:e+""}function Iy(t){if("glyph"===t.type&&t.glyph&&"number"==typeof t.size){const e=t.cx??t.x,o=t.cy??t.y;if("number"!=typeof e||"number"!=typeof o)return null;const i=ju(t.glyph,t.size);return{x:e+i.centerDx,y:o+i.centerDy,r:Math.max(1,i.radius)}}const e=t.cx??(null!=t.x&&null!=t.w?t.x+t.w/2:t.x),o=t.cy??(null!=t.y&&null!=t.h?t.y+t.h/2:t.y);return"number"!=typeof e||"number"!=typeof o?null:{x:e,y:o,r:"number"==typeof t.r?Math.max(1,t.r):"number"==typeof t.outerR?Math.max(1,t.outerR):"number"==typeof t.size?Math.max(1,Rl(t.size)):Math.max(1,t.w??0,t.h??0)/2}}function Ty(t){if(!t)return;const e=[];for(const o of t){const t=Iy(o);t&&e.push({pointId:Cy(o),...t})}return e}var Oy=require("react/jsx-runtime");function zy(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var Fy=new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);function Ny(t){return t.map(t=>{const e=t.datum&&"object"==typeof t.datum?t.datum:{},o=e.data&&"object"==typeof e.data?e.data:e,i="cx"in t?t.cx:t.x+t.w/2,n="cy"in t?t.cy:t.y+t.h/2;return{...o,...null==o.id&&null!=t.id?{id:t.id}:{},x:i,y:n}})}function Ey(t,e){const o=Ot(t.theme),i=t.chartType||"force",n=t.size||[500,500],r=function(t){return Sf.has(t)?kf:wf}(i),s=pe({...r,...t.margin},t.title),a=he(t.title),c=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;if(!e)return[];const i=P(t.nodes||[]);if(i.length>0)return yd(i,e);const n=Array.isArray(t.edges)?P(t.edges):[];if(0===n.length)return[];const r=zy(t.sourceAccessor,"source"),s=zy(t.targetAccessor,"target");return yd(Array.from(new Set(n.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[];pf(s,{props:t,categories:c,theme:o,size:n,hasTitle:a});const l=yf({props:t,categories:c,theme:o,size:n,margin:s,hasTitle:a}),u=n[0]-s.left-s.right,d=n[1]-s.top-s.bottom,h=bf(t.backgroundGraphics,n,s,null),f=bf(t.foregroundGraphics,n,s,null),p=()=>{let i;const r=t=>Number(t),a=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{x:r,y:r},layout:{width:u,height:d},theme:o,frameType:"network",idPrefix:t._idPrefix,onRender:t=>{i=t}}):null;return e&&(e.evidence=(e=>Ec({frameType:"network",width:n[0],height:n[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:e,nodeCount:0,edgeCount:0,margin:s}))(i)),lp.renderToStaticMarkup(mf(h||f||t.annotations?(0,Oy.jsxs)(Oy.Fragment,{children:[h,a,f]}):null,{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:d,legend:l,idPrefix:t._idPrefix}))},y=function(t){return Ry[t]}(i);if(!y&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);const g={chartType:i,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,labelMode:t.labelMode,colorBy:t.colorBy,colorScheme:t.colorScheme||o.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,orbitMode:t.orbitMode,orbitSize:t.orbitSize,orbitSpeed:t.orbitSpeed,orbitRevolution:t.orbitRevolution,orbitRevolutionStyle:t.orbitRevolutionStyle,orbitEccentricity:t.orbitEccentricity,orbitShowRings:t.orbitShowRings,orbitAnimated:!1,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let m,x;if(Fy.has(i)){const e=t.data||t.edges;if(!e||Array.isArray(e))return p();g.__hierarchyRoot=e,m=[],x=[]}else{const e=P(t.nodes||[]),o=Array.isArray(t.edges)?P(t.edges):[];if(0===e.length&&0===o.length)return p();if(x=function(t,e){const o=zy(e.sourceAccessor,"source"),i=zy(e.targetAccessor,"target"),n=zy(e.valueAccessor,"value");return t.map(t=>{const e=Number(n(t));return{source:o(t)+"",target:i(t)+"",value:Number.isFinite(e)?e:1,y0:0,y1:0,sankeyWidth:0,data:t}})}(o,g),0===e.length&&x.length>0){const t=new Set;for(const e of x){const o=cf(e.source),i=cf(e.target);o&&t.add(o),i&&t.add(i)}m=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 m=function(t,e){const o=zy(e.nodeIDAccessor,"id");return t.map(t=>({id:o(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}))}(e,g)}let b=[],v=[],w=[],k=null;if(g.customNetworkLayout){const t=g.colorScheme,e=Ns(t,o.colors.categorical,C),i=Es(e,t),n={nodes:m,edges:x,dimensions:{width:u,height:d,plot:{x:0,y:0,width:u,height:d}},theme:{semantic:o.colors,categorical:[...e]},resolveColor:i,config:g.layoutConfig??{}},r=g.customNetworkLayout(n);b=r.sceneNodes??[],v=r.sceneEdges??[],w=r.labels??[],k=r.overlays??null}else if(y){y.computeLayout(m,x,g,[u,d]);const t=y.buildScene(m,x,g,[u,d]);b=t.sceneNodes,v=t.sceneEdges,w=t.labels}const S=zt(o);for(const t of w)t.fill||(t.fill=S.text);const A=id({nodes:v,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){return Nu(function(t,e){switch(t.type){case"line":return(0,Bu.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 o=t,i=`net-bezier-${e}-hatch`,n=xn(o.style.fill)?bn(o.style.fill,i):void 0;return(0,Bu.jsxs)(Eu.Fragment,{children:[n&&(0,Bu.jsx)("defs",{children:n}),(0,Bu.jsx)("path",{d:o.pathD,fill:n?`url(#${i})`:Ru(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-edge-"+e)}case"ribbon":{const o=t,i=`net-ribbon-${e}-hatch`,n=xn(o.style.fill)?bn(o.style.fill,i):void 0;return(0,Bu.jsxs)(Eu.Fragment,{children:[n&&(0,Bu.jsx)("defs",{children:n}),(0,Bu.jsx)("path",{d:o.pathD,fill:n?`url(#${i})`:Ru(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-edge-"+e)}case"curved":{const o=t;return(0,Bu.jsx)("path",{d:o.pathD,fill:Ru(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth??1,opacity:o.style.opacity},"net-edge-"+e)}default:return null}}(t,e),t,"network-edge-cursor-"+e)}(t,e)}),M=id({nodes:b,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){return Nu(function(t,e){switch(t.type){case"circle":{const o=t,i=xn(o.style.fill)?bn(o.style.fill,`net-circle-${e}-hatch`):void 0;return(0,Bu.jsxs)(Eu.Fragment,{children:[i&&(0,Bu.jsx)("defs",{children:i}),(0,Bu.jsx)("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:i?`url(#net-circle-${e}-hatch)`:Ru(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity})]},"net-circle-"+e)}case"rect":{const o=t,i=xn(o.style.fill)?bn(o.style.fill,`net-rect-${e}-hatch`):void 0;return(0,Bu.jsxs)(Eu.Fragment,{children:[i&&(0,Bu.jsx)("defs",{children:i}),(0,Bu.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#net-rect-${e}-hatch)`:Ru(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity})]},"net-rect-"+e)}case"arc":{const o=t,i=(0,Du.arc)().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)($u)||"",n=xn(o.style.fill)?bn(o.style.fill,`net-arc-${e}-hatch`):void 0;return(0,Bu.jsxs)(Eu.Fragment,{children:[n&&(0,Bu.jsx)("defs",{children:n}),(0,Bu.jsx)("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:n?`url(#net-arc-${e}-hatch)`:Ru(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity})]},"net-arc-"+e)}case"symbol":{const o=t,i=$l(o.symbolType,o.size,o.path);return(0,Bu.jsx)("path",{d:i,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?Ru(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity},"net-symbol-"+e)}case"glyph":return Iu(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e),t,"network-node-cursor-"+e)}(t,e)}),_=A.map(t=>t.element),j=M.map(t=>t.element),L=w.map((t,e)=>function(t,e){return(0,Bu.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);let $;const R=t=>Number(t),I=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{x:R,y:R},layout:{width:u,height:d},theme:o,frameType:"network",annotationData:Ny(b),pointNodes:Ty(b),idPrefix:t._idPrefix,onRender:t=>{$=t}}):null;return e&&(e.evidence=Ec({frameType:"network",width:n[0],height:n[1],marks:[...M.map(({node:t})=>({type:"node:"+(t.type??"node")})),...A.map(({node:t})=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,annotationRender:$,nodeCount:M.length,edgeCount:A.length,margin:s})),lp.renderToStaticMarkup(mf((0,Oy.jsxs)(Oy.Fragment,{children:[h,_,j,L,I,f,k]}),{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:u,innerHeight:d,legend:l,idPrefix:t._idPrefix}))}var Dy=c(require("react-dom/server")),By=require("d3-geo"),Wy=require("d3-quadtree"),Yy=require("d3-geo"),qy={mercator:Yy.geoMercator,equalEarth:Yy.geoEqualEarth,albersUsa:Yy.geoAlbersUsa,orthographic:Yy.geoOrthographic,naturalEarth:Yy.geoNaturalEarth1,equirectangular:Yy.geoEquirectangular};function Xy(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Gy(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Vy(t,e,o){return t?"function"==typeof t?{...o,...t(e)}:{...o,...t}:{...o}}function Hy(t,e){if(2>t.length)return[t];const o=.4*e,i=[];let n=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>o?(2>n.length||i.push(n),n=[r]):n.push(r)}return 2>n.length||i.push(n),i}function Uy(t,e,o=24){const i=e[0]-t[0],n=e[1]-t[1],r=Math.sqrt(i*i+n*n);if(0===r)return[t,e];const s=-n/r,a=i/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,d=[];for(let i=0;o>=i;i++){const n=i/o,r=1-n;d.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 d}function Ky(t,e){if(2>t.length)return t;const o=e/2+1,i=[];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;i.push([n[0]+s/a*o,n[1]+-r/a*o])}return i}function Zy(t,e,o,i,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 Qy=require("d3-scale");var Jy=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],tg=["scene-style","data-paint","accessibility","evidence"],eg=(t,e)=>({retainedData:t,invalidations:e}),og=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ig=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ng=["scene-geometry","data-paint","accessibility","evidence"],rg=["scene-style","data-paint","accessibility","evidence"],sg=["overlay","accessibility","evidence"],ag=[],cg={xAccessor:eg("rebuild",og),yAccessor:eg("rebuild",og),lineDataAccessor:eg("rebuild",og),pointIdAccessor:eg("rebuild",ng),lineIdAccessor:eg("rebuild",ng),windowSize:eg("rebuild",og),projection:eg("preserve",ig),projectionExtent:eg("preserve",ig),fitPadding:eg("preserve",ig),lineType:eg("preserve",ig),flowStyle:eg("preserve",ig),graticule:eg("preserve",ig),projectionTransform:eg("preserve",ig),customLayout:eg("preserve",ig),layoutConfig:eg("preserve",ig),layoutMargin:eg("preserve",ig),areaStyle:eg("preserve",rg),pointStyle:eg("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:eg("preserve",rg),colorScheme:eg("preserve",rg),themeCategorical:eg("preserve",rg),themeDiverging:eg("preserve",rg),themeSemantic:eg("preserve",rg),themeSequential:eg("preserve",rg),decay:eg("preserve",rg),pulse:eg("preserve",rg),layoutSelection:eg("preserve",rg),annotations:eg("preserve",sg),autoPlaceAnnotations:eg("preserve",sg),clock:eg("preserve",ag),transition:eg("preserve",ag),introAnimation:eg("preserve",ag),onLayoutError:eg("preserve",ag)},lg=eg("preserve",ig),ug=class{constructor(){this.tracker=new ns}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}},Jy)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},tg):this.recordNoop("restyle")}recordConfig(t,e={}){const o=function(t){let e="preserve";const o=new Set;for(const i of t){const t=cg[i]??lg;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}(t),i=new Set(o.invalidations);return e.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:t},i)}},dg=require("d3-geo");function hg(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 fg=class t{constructor(t){this.updateResults=new ug,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:hg(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??il()}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(),o=this.timestampBuffer?.toArray()??[],i=e.slice(-t),n=o.slice(-i.length),r=this.currentTime();this.pointBuffer=new Wc(t),this.timestampBuffer=new Wc(t),i.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:hg(t.fitPadding)}:t}(t),o=this.config,i=this.getConfiguredWindowSize(),n=Object.keys(e).filter(t=>e[t]!==o[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==i;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(),o=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],n=o.slice(-e),r=i.slice(-n.length),s=this.currentTime();this.pointBuffer=new Wc(e),this.timestampBuffer=new Wc(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();Hl(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 o of t)Hl(this.pointBuffer,o,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 o="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]),n=[];return this.lineData=this.lineData.filter(t=>!i.has(o(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 o="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(o(t)+"");Ul(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=>!i.has(o(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 o of this.scene){const i=this._baseStyles.get(o)??o.style,n=e(o,t);o.style=n?{...i,...n}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,o=this.projection,i=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,Yy.geoEqualEarth)();if("string"==typeof t){const e=qy[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),(0,Yy.geoEqualEarth)())}if("object"==typeof t&&"type"in t){const e=qy[t.type],o=e?e():(0,Yy.geoEqualEarth)();return t.rotate&&"rotate"in o&&o.rotate(t.rotate),t.center&&"center"in o&&o.center(t.center),o}return t}(e.projection),this.geoPath=(0,By.geoPath)(this.projection),this.fitProjection(t),this.geoPath=(0,By.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=o,this.geoPath=i,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,o=t.height/2,i=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:o}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,o=this.config,i=[...this.areas],n=Xy(o.xAccessor,"lon"),r=Xy(o.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[n(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=Gy(o.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)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==i.length){if(o.projectionExtent){const[[i,n],[r,s]]=o.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,n],[i,s],[r,s],[r,n],[i,n]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const i=o.fitPadding??0,n=Math.min(t.width,t.height);e.scale(n/2-n*i),e.translate([t.width/2,t.height/2])}else{const n=o.fitPadding??0,r=t.width*n,s=t.height*n;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:i})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const o=this.projection;if(!o)return;const i=this.geoPath,n=this.scales,r=o.scale(),s=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*t.k),o.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=(0,By.geoPath)(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(t,e)=>o([t,e]),invertedPoint:(t,e)=>o.invert?o.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(s),this.currentZoom=a,this.geoPath=i,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 o=this.projection;if(!o)return;const i=this.geoPath,n=this.scales,r=o.scale(),s=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*t),o.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=(0,By.geoPath)(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(t,e)=>o([t,e]),invertedPoint:(t,e)=>o.invert?o.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(s),this.currentZoom=a,this.geoPath=i,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 o=this.projection;if(!o||!o.rotate)return;const i=this.geoPath,n=this.scales,r=[...o.rotate()];o.rotate(t),this.geoPath=(0,By.geoPath)(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(t,e)=>o([t,e]),invertedPoint:(t,e)=>o.invert?o.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(r),this.geoPath=i,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)}hasProjection(){return null!=this.projection}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,o=0;for(const t of this.scene)"point"===t.type&&!1!==t.interactive&&(o++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const i=Array(o);let n=0;for(const t of this.scene)"point"===t.type&&!1!==t.interactive&&(i[n++]=t);this._quadtree=(0,Wy.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,o=this.projection,i=this.geoPath;if(e.customLayout&&this.scales){const o=e.layoutMargin??{top:0,right:0,bottom:0,left:0},i=Ns(e.colorScheme,e.themeCategorical,nt),n={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:o,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...i]},resolveColor:Es(i,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(n)}catch(t){const o=null!==this.lastCustomLayoutResult,i=Dl("geo",t,o,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return o?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 Fl({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:o,areas:i,points:n,lines:r,layout:s}){const a=Xy(t.xAccessor,"lon"),c=Xy(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),d=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),h=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,i=(0,dg.geoGraticule)();e.step&&i.step(e.step);const n=o(i())||"";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 i){const i=o(e);if(!i)continue;const n=o.centroid(e),r=o.bounds(e),s=o.area(e);l.push({type:"geoarea",pathData:i,centroid:n,bounds:r,screenArea:s,style:Vy(t.areaStyle,e,u),datum:e,interactive:!0})}const f=Gy(t.lineDataAccessor);for(const o of r){const i=f(o);if(!i||2>i.length)continue;let n=[];if("geo"===t.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[a(i[e]),c(i[e])];for(let o=0;t.length-1>o;o++){const i=t[o],r=t[o+1],s=(0,dg.geoDistance)(i,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,dg.geoInterpolate)(i,r);for(let t=0;a>=t;t++){if(o>0&&0===t)continue;const i=e(c(t/a));null!=i&&n.push(i)}}}else for(let t=0;i.length>t;t++){const o=i[t],r=e([a(o),c(o)]);null!=r&&n.push(r)}if(2>n.length)continue;const r=Vy(t.lineStyle,o,d),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>n.length||"arc"!==t.flowStyle?2!==i.length||2>n.length||"offset"!==t.flowStyle||(n="geo"===t.lineType?Ky(n,u):Zy(n[0],n[n.length-1],0,0,u)):n=Uy(n[0],n[n.length-1]);const h=Hy(n,s.width);if(h.length>1)for(const t of h)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:o});else l.push({type:"line",path:2>n.length&&h[0]||n,style:r,datum:o})}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 o of n){const i=a(o),n=c(o);if(null!=g&&(0,dg.geoDistance)([i,n],b)>g)continue;const r=e([i,n]);if(!r)continue;const s=t.pointStyle?t.pointStyle(o):{...h},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:o,pointId:p?p(o)+"":void 0};l.push(u)}return l}({config:e,projection:o,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const o=function(t,e,o,i){const n=t.filter(t=>"point"===t.type);if(2>n.length)return null;const r=e.strength??1,s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,a="strip"===e.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,l="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],u=n.find(t=>t.datum&&c(t.datum)+""==e.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const d=Et(n.map(t=>t.datum?Number(l(t.datum)):NaN).filter(t=>isFinite(t)&&t>=0),1);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const o=t[e];"geoarea"===o.type&&o.interactive&&t.splice(e,1)}const h="strip"===a?function(t,e,o,i,n){const r=Math.max(3,Math.min(8,.35*n.height)),s=Math.max(1,n.width-2*r),a=n.height/2,c=(0,Qy.scaleLinear)().domain([0,i]).range([0,s]);e.x=r,e.y=a;const l=[];for(const n of t){if(n===e)continue;if(!n.datum){n.x=r,n.y=a;continue}const t=Number(o(n.datum)),s=r+(isFinite(t)&&t>=0&&i>0?c(t):0);n.x=s,n.y=a,l.push({node:n,x:s})}l.sort((t,e)=>t.x-e.x);const u=Math.max(0,Math.min(n.height/2-1,6));let d=0;for(;l.length>d;){let t=d+1;for(;l.length>t&&3>Math.abs(l[t].x-l[d].x);)t++;const e=t-d;if(e>1&&u>0)for(let t=0;e>t;t++)l[d+t].node.y=a+(t-(e-1)/2)*Math.min(2.5,2*u/Math.max(1,e-1));d=t}return{cx:r,cy:a,maxCost:i,availableRadius:s,layout:"strip"}}(n,u,l,d,o):function(t,e,o,i,n,r){const s=e.x,a=e.y,c=r.width/2,l=r.height/2,u=Math.min(r.width,r.height)/2,d=(0,Qy.scaleLinear)().domain([0,i]).range([0,u]);for(const r of t){if(r===e)continue;if(!r.datum)continue;const t=r.x,u=r.y,h=Math.atan2(u-a,t-s),f=Math.hypot(t-s,u-a),p=Number(o(r.datum)),y=isFinite(p)&&p>=0?i>0?d(p):0:f,g=c+Math.cos(h)*y,m=l+Math.sin(h)*y;r.x=t+(g-t)*n,r.y=u+(m-u)*n}return e.x=s+(c-s)*n,e.y=a+(l-a)*n,{cx:e.x,cy:e.y,maxCost:i,availableRadius:u,layout:"radial"}}(n,u,l,d,s,o),f=t.filter(t=>"line"===t.type);if(f.length>0){const t=new Map;for(const e of n)null!=e.pointId&&t.set(e.pointId+"",[e.x,e.y]);for(const o of f){const i=o.datum?.source,n=o.datum?.target;if(null!=i&&null!=n){const r=t.get(i+""),s=t.get(n+"");if(r&&s)if("fractional"===e.lineMode&&o.path.length>2){const t=o.path[0],e=o.path[o.path.length-1],i=[r[0]-t[0],r[1]-t[1]],n=[s[0]-e[0],s[1]-e[1]],a=[0];for(let t=1;o.path.length>t;t++)a.push(a[t-1]+Math.hypot(o.path[t][0]-o.path[t-1][0],o.path[t][1]-o.path[t-1][1]));const c=a[a.length-1];o.path=o.path.map((t,e)=>{const r=c>0?a[e]/c:e/(o.path.length-1);return[t[0]+i[0]*(1-r)+n[0]*r,t[1]+i[1]*(1-r)+n[1]*r]})}else o.path=[r,s]}}}return h}(this.scene,t,e,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const o=this.scene.filter(t=>"point"===t.type);for(let i=0;o.length>i;i++){const n=nl(t,i,e);o[i]._decayOpacity=n,o[i].style={...o[i].style,opacity:n}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const o=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray(),n=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let s=!1;for(let a=0;o.length>a&&i.length>a;a++){const c=sl(e,i[a],t);s=al(o[a],c,n,r)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&cl(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 o=new Map;for(const e of t)"point"===e.type&&e.pointId&&o.set(e.pointId,[e.x,e.y]);const i=this.scene.filter(t=>"point"===t.type);let n=!1;for(const t of i)if(t.pointId){const e=o.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 i)t.pointId&&!o.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??t.style?.fillOpacity??1,t.style={...t.style,opacity:0},n=!0);n&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null;for(const t of this.scene)"point"===t.type&&(null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0),null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0))}advanceTransition(t){if(!this.activeTransition)return!1;const e=el(t,this.activeTransition),o=tl(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ol(t.x,t._targetX,o),t.y=ol(e,t._targetY,o)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*o})}if(e>=1){for(const t of i)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};fg.QUADTREE_THRESHOLD=500;var pg=fg;function yg(t){if(!t)return;const e=[];for(const o of t)if("point"===o.type)e.push(o);else if("glyph"===o.type){const t=o,i=ju(t.glyph,t.size);e.push({pointId:t.pointId,x:t.x+i.centerDx,y:t.y+i.centerDy,r:i.radius})}return e}iu(pg);var gg=require("react/jsx-runtime");function mg(t,e){const o=Ot(t.theme),i=t.size||[t.width||600,t.height||400],n=pe({top:10,right:10,bottom:10,left:10,...t.margin},t.title),r=he(t.title),s=Array.isArray(t.areas)?P(t.areas):t.areas,a=P(t.points),c=P(t.lines),l=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;return yd(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof e?s.map(t=>({...t.properties||{},...t})):s:[],e)})():[];pf(n,{props:t,categories:l,theme:o,size:i,hasTitle:r});const u=yf({props:t,categories:l,theme:o,size:i,margin:n,hasTitle:r}),d=i[0]-(n.left??0)-(n.right??0),h=i[1]-(n.top??0)-(n.bottom??0),f={projection:t.projection||"equalEarth",projectionExtent:t.projectionExtent,xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineIdAccessor:t.lineIdAccessor,lineType:t.lineType,flowStyle:t.flowStyle,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,colorScheme:t.colorScheme,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,onLayoutError:t.onLayoutError,themeCategorical:o.colors.categorical,themeSemantic:It(o),themeSequential:o.colors.sequential,themeDiverging:o.colors.diverging},p=new pg(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)}t.points&&p.setPoints(a),t.lines&&p.setLines(c),p.computeScene({width:d,height:h});const y=bf(t.backgroundGraphics,i,n,p.scales),g=bf(t.foregroundGraphics,i,n,p.scales),m=id({nodes:p.scene,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){return Nu(function(t,e){switch(t.type){case"geoarea":{const o=t;if(!o.pathData)return null;const i=xn(o.style.fill)?bn(o.style.fill,`geoarea-${e}-hatch`):void 0;return(0,Yu.jsxs)(Wu.Fragment,{children:[i&&(0,Yu.jsx)("defs",{children:i}),(0,Yu.jsx)("path",{d:o.pathData,fill:i?`url(#geoarea-${e}-hatch)`:Ru(o.style.fill,"#e0e0e0"),fillOpacity:o.style.fillOpacity??1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth??.5,strokeDasharray:o.style.strokeDasharray,opacity:o._decayOpacity??1})]},"geoarea-"+e)}case"point":{const o=t,i=xn(o.style.fill)?bn(o.style.fill,`geopoint-${e}-hatch`):void 0;return(0,Yu.jsxs)(Wu.Fragment,{children:[i&&(0,Yu.jsx)("defs",{children:i}),(0,Yu.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#geopoint-${e}-hatch)`:Ru(o.style.fill),fillOpacity:o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o._decayOpacity??o.style.opacity??1})]},"point-"+e)}case"line":{const o=t;if(2>o.path.length)return null;const i="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return(0,Yu.jsx)("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth??1.5,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity??1},"line-"+e)}case"glyph":return Iu(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(t,e),t,"geo-cursor-"+e)}(t,e)});if(0===m.length){let r;const s=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:d,height:h},theme:o,pointNodes:yg(p.scene),idPrefix:t._idPrefix,onRender:t=>{r=t}}):null;return e&&(e.evidence=Ec({frameType:"geo",width:i[0],height:i[1],marks:m.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:r,legendItems:l.length>0?l.length:null!=t.legend?1:void 0,margin:n})),Dy.renderToStaticMarkup(mf(y||g||t.annotations||p.customLayoutOverlays?(0,gg.jsxs)(gg.Fragment,{children:[y,s,g,p.customLayoutOverlays]}):null,{width:i[0],height:i[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:t._idPrefix}))}const x=m.map(t=>t.element);let b;const v=t.annotations?Eh({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:d,height:h},theme:o,pointNodes:yg(p.scene),idPrefix:t._idPrefix,onRender:t=>{b=t}}):null;return e&&(e.evidence=Ec({frameType:"geo",width:i[0],height:i[1],marks:m.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:b,legendItems:l.length>0?l.length:null!=t.legend?1:void 0,margin:n})),Dy.renderToStaticMarkup(mf((0,gg.jsxs)(gg.Fragment,{children:[y,x,v,g,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:t._idPrefix}))}var xg=c(require("react-dom/server"));function bg(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 vg={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function wg(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 kg(t,e,o){const i="function"==typeof e?e(t,o):e;return{...vg,...i??{}}}function Sg(t,e={},o="settled"){return t.map((t,i)=>function(t,e={},o={index:0,simulationState:"settled"}){const i=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),n={label:e.getBodyLabel?.(t)??wg(t)},r={style:kg(t,e.bodyStyle,o),datum:i,accessibleDatum:i,accessibility:n,_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,...r}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...r}}(t,e,{index:i,simulationState:o}))}var Ag=require("react/jsx-runtime"),Mg={top:0,right:0,bottom:0,left:0};function _g(t,e,o){return"function"==typeof t?t({size:e,margin:o}):t}function Pg(t,e={}){const{element:o,scene:i,evidence:n}=function(t,e={}){const{width:o=640,height:i=360,title:n,description:r,background:s,backgroundGraphics:a,backgroundGraphicsBackdrop:c,className:l,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:y,...g}=e,m=function(t,e={}){const o=t.settle(e.maxSteps),i=t.readBodies(),n=t.snapshot(),r=Sg(i,e,n.simulationState),s=function(t,e={}){const o=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),i=o.filter(t=>t.sleeping).length,n=t.queue.length,r=t.sediment.reduce((t,e)=>t+e.count,0),s="settled"===t.simulationState&&0===n&&i===o.length,a=[];n>0&&a.push("PHYSICS_QUEUE_UNDRAINED");const c=null!=e.charge&&Number.isFinite(e.charge)?function(t,e,o,i){const n=t-(e+o+i);return{charge:t,live:e,queued:o,sedimented:i,unaccounted:n,balanced:0===n}}(e.charge,o.length,n,r):void 0;return c&&!c.balanced&&a.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:o.length,sleepingCount:i,settled:s,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:bg(e.projectionRows),queuedCount:n,sedimentedCount:r,...c?{ledger:c}:{},warnings:a}}(n,{bodies:i,projectionRows:e.projectionRows,stepsRun:o,charge:e.charge});return{snapshot:n,bodies:i,sceneNodes:r,evidence:s,stepsRun:o}}(t,g),x={...Mg,...h},b=[o,i],v=_g(a,b,x),w=_g(u,b,x),k=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(d),S=n?k+"-title":void 0,A=r?k+"-desc":void 0,M=[S,A].filter(Boolean).join(" ")||void 0,_=x.left||x.top?`translate(${x.left},${x.top})`:void 0,P=Math.max(1,o-x.left-x.right),j=Math.max(1,i-x.top-x.bottom),L=k+"-plot-clip",$=_&&null!=v?(0,Ag.jsx)("g",{transform:_,children:v}):v;return{element:(0,Ag.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:l??"stream-physics-frame",width:o,height:i,viewBox:`0 0 ${o} ${i}`,role:"img","aria-labelledby":M,style:f,children:[n&&(0,Ag.jsx)("title",{id:S,children:n}),r&&(0,Ag.jsx)("desc",{id:A,children:r}),(0,Ag.jsx)("defs",{children:(0,Ag.jsx)("clipPath",{id:L,children:(0,Ag.jsx)("rect",{width:P,height:j})})}),c&&"transparent"!==c?(0,Ag.jsx)("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:o,height:i,fill:c}):null,!a&&s&&"transparent"!==s?(0,Ag.jsx)("rect",{x:0,y:0,width:o,height:i,fill:s}):null,$,(0,Ag.jsx)("g",{id:k+"-data-area",transform:_,clipPath:`url(#${L})`,children:m.sceneNodes.map((t,e)=>{const o=m.bodies[e],i=o&&p?p(o,t.style??{},e,k):void 0;return null!=i?Nu(i,t,e):td(t,e,k)})}),w,y?.(m)]}),scene:m,evidence:m.evidence}}(t,e);return{svg:xg.renderToStaticMarkup(o),scene:i,evidence:n}}function jg(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function Lg(t,e){const o="sensor"===t.physics?e.sensorThickness:e.barrierThickness;return Math.max(0,jg(t.thickness)??jg(o)??jg(e.thickness)??4)}function $g(t){return t.sensorId??"stream-region-"+t.id}function Rg(t){const e=$g(t),o={bodyFilter:t.bodyFilter,friction:t.friction,restitution:t.restitution};if("boundary"===t.collider&&"aabb"===t.shape.type){const i=t.colliderThickness??8,n=t.shape.x-t.shape.width/2,r=t.shape.x+t.shape.width/2,s=t.shape.y-t.shape.height/2,a=t.shape.y+t.shape.height/2;return[{...o,id:e+"-top",shape:{type:"segment",x1:n,y1:s,x2:r,y2:s,thickness:i}},{...o,id:e+"-right",shape:{type:"segment",x1:r,y1:s,x2:r,y2:a,thickness:i}},{...o,id:e+"-bottom",shape:{type:"segment",x1:r,y1:a,x2:n,y2:a,thickness:i}},{...o,id:e+"-left",shape:{type:"segment",x1:n,y1:a,x2:n,y2:s,thickness:i}}]}return t.collider?[{...o,id:e+"-collider",shape:t.shape}]:[]}var Cg=require("react/jsx-runtime");function Ig({title:t,totalWidth:e,marginTop:o}){return t?"string"!=typeof t?(0,Cg.jsx)("foreignObject",{x:0,y:0,width:e,height:o,children:t}):(0,Cg.jsx)("text",{x:e/2,y:de,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:t}):null}var Tg=require("d3-scale");function Og(t){return"circle"===t.shape.type?t.shape.radius:Math.max(t.shape.width,t.shape.height)/2}var zg=require("react/jsx-runtime");var Fg={top:0,right:0,bottom:0,left:0};function Ng(t,e){const o=t.size??[t.width??600,t.height??400],i=Ot(t.theme),n=void 0===t.theme?{}:function(t){const e={"--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-cell-border":t.colors.cellBorder||t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily,"--semiotic-secondary":t.colors.secondary||t.colors.primary,"--semiotic-surface":t.colors.surface||t.colors.background};t.colors.categorical.forEach((t,o)=>{e["--semiotic-category-"+(o+1)]=t}),t.colors.focus&&(e["--semiotic-focus"]=t.colors.focus),t.colors.selection&&(e["--semiotic-selection-color"]=t.colors.selection),null!=t.colors.selectionOpacity&&(e["--semiotic-selection-opacity"]=t.colors.selectionOpacity+""),t.colors.diverging&&(e["--semiotic-diverging"]=t.colors.diverging),t.colors.annotation&&(e["--semiotic-annotation-color"]=t.colors.annotation),t.colors.success&&(e["--semiotic-success"]=t.colors.success),t.colors.danger&&(e["--semiotic-danger"]=t.colors.danger),t.colors.warning&&(e["--semiotic-warning"]=t.colors.warning),t.colors.error&&(e["--semiotic-error"]=t.colors.error),t.colors.info&&(e["--semiotic-info"]=t.colors.info),t.tooltip?.background&&(e["--semiotic-tooltip-bg"]=t.tooltip.background),t.tooltip?.text&&(e["--semiotic-tooltip-text"]=t.tooltip.text),t.tooltip?.borderRadius&&(e["--semiotic-tooltip-radius"]=t.tooltip.borderRadius),t.tooltip?.fontSize&&(e["--semiotic-tooltip-font-size"]=t.tooltip.fontSize),t.tooltip?.shadow&&(e["--semiotic-tooltip-shadow"]=t.tooltip.shadow),t.borderRadius&&(e["--semiotic-border-radius"]=t.borderRadius);const o=t.typography.legendSize??t.typography.labelSize;null!=o&&(e["--semiotic-legend-font-size"]=o+"px"),null!=t.typography.legendFontFamily&&(e["--semiotic-legend-font-family"]=t.typography.legendFontFamily),null!=t.typography.legendFontWeight&&(e["--semiotic-legend-font-weight"]=t.typography.legendFontWeight+"");const i=t.typography.titleFontSize??t.typography.titleSize;return null!=i&&(e["--semiotic-title-font-size"]=i+"px"),null!=t.typography.titleFontFamily&&(e["--semiotic-title-font-family"]=t.typography.titleFontFamily),null!=t.typography.titleFontWeight&&(e["--semiotic-title-font-weight"]=t.typography.titleFontWeight+""),null!=t.typography.tickFontFamily&&(e["--semiotic-tick-font-family"]=t.typography.tickFontFamily),null!=t.typography.tickSize&&(e["--semiotic-tick-font-size"]=t.typography.tickSize+"px"),null!=t.typography.labelSize&&(e["--semiotic-axis-label-font-size"]=t.typography.labelSize+"px"),e}(i),r=t.bodyStyle,s=!1,a=t.legendPosition??"right",c=fe({...Fg,...t.margin},s,!!t.legend&&"top"===a);if(t.legend){const e={...c};De(c,{legend:t.legend,position:a,size:o,hasTitle:s,legendLayout:t.legendLayout}),ke(c,e,o,a)}let l;const u=function({annotations:t,chartId:e,chartType:o,config:i,onRegionObservation:n,regionEffects:r,seed:s,size:a}){const c=function(t=[],e={}){const o=e.idPrefix?e.idPrefix+"-":"",i=[];for(const n of t){if("barrier"!==n.physics&&"sensor"!==n.physics)continue;const t=n.axis??e.defaultAxis??"x",r=Lg(n,e),s=n.colliderId??`${o}${n.id}`;let a;if("x"===t){const t=jg(n.x),o=jg(n.y1)??jg(e.plotBounds?.y)??jg(n.y),i=jg(n.y2)??(e.plotBounds?e.plotBounds.y+e.plotBounds.height:void 0)??jg(n.y);if(null==t||null==o||null==i)continue;a={type:"segment",x1:t,y1:o,x2:t,y2:i,thickness:r}}else{const t=jg(n.y),o=jg(n.x1)??jg(e.plotBounds?.x)??jg(n.x),i=jg(n.x2)??(e.plotBounds?e.plotBounds.x+e.plotBounds.width:void 0)??jg(n.x);if(null==t||null==o||null==i)continue;a={type:"segment",x1:o,y1:t,x2:i,y2:t,thickness:r}}i.push({id:s,shape:a,sensor:"sensor"===n.physics,..."barrier"!==n.physics||null==n.restitution&&null==e.barrierRestitution?{}:{restitution:jg(n.restitution)??jg(e.barrierRestitution)},..."barrier"!==n.physics||null==n.friction&&null==e.barrierFriction?{}:{friction:jg(n.friction)??jg(e.barrierFriction)}})}return i}((t??[]).filter(t=>"barrier"===t.physics||"sensor"===t.physics),{idPrefix:e?e+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:a[0],height:a[1]}}),l=void 0===s||void 0!==i?.kernel?.seed?i:{...i,kernel:{...i?.kernel,seed:s}},u=r.flatMap(t=>[{id:$g(t),sensor:!0,shape:t.shape,bodyFilter:t.bodyFilter,friction:t.friction,restitution:t.restitution},...Rg(t)]),d=Object.fromEntries(r.map(t=>[$g(t),{binId:t.binId??t.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=l?.observation,f=r.length>0;return f||u.length>0||c.length>0||null!=e||h?{...l,colliders:[...l?.colliders??[],...u,...c],observation:{...h,chartId:e??h?.chartId,chartType:h?.chartType??o,sensors:{...h?.sensors??{},...d},onObservation:t=>{f&&n(t),h?.onObservation?.(t)}}}:l}({annotations:t.annotations,chartId:t.chartId,chartType:"StreamPhysicsFrame",config:t.config,onRegionObservation:()=>{},regionEffects:t.regionEffects??[],seed:t.seed,size:[Math.max(1,o[0]-c.left-c.right),Math.max(1,o[1]-c.top-c.bottom)]}),d=new ws(u);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&d.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const h=Pg(d,{...t,width:o[0],height:o[1],background:t.background??i.colors.background,bodyStyle:(t,e)=>({fill:i.colors.primary,stroke:i.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof r?r(t,e):r}),style:{...n,fontFamily:i.typography.fontFamily,...t.style},charge:t.charge,idPrefix:t.idPrefix??t._idPrefix??"physics",margin:c,renderChrome:e=>{const n=function(t,e,o,i,n){const r=Math.max(1,o[0]-i.left-i.right),s=Math.max(1,o[1]-i.top-i.bottom),a=function(t){return t?.length?t.map(t=>null!=t.pointId||null==t.bodyId?t:{...t,pointId:t.bodyId+""}):t}(e.annotations),c=function(t){const{width:e,height:o,pointNodes:i=[],data:n}=t;return{scales:{x:(0,Tg.scaleLinear)().domain([0,Math.max(1,e)]).range([0,Math.max(1,e)]),y:(0,Tg.scaleLinear)().domain([0,Math.max(1,o)]).range([0,Math.max(1,o)])},width:e,height:o,frameType:"network",pointNodes:i,data:n,xAccessor:"x",yAccessor:"y"}}({width:r,height:s,pointNodes:(l=t.bodies,l.map(t=>({pointId:t.id,x:t.x,y:t.y,r:Math.max(1,Og(t))})))});var l;const u=c.scales?.x,d=c.scales?.y;if(!u||!d)throw Error("Physics annotation context requires pixel scales");let h;const f=Eh({annotations:a,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:u,y:d},layout:{width:r,height:s},theme:n,frameType:"network",xAccessor:c.xAccessor,yAccessor:c.yAccessor,pointNodes:c.pointNodes,svgAnnotationRules:e.svgAnnotationRules,onRender:t=>{h=t}}),p=e.legend?ff(e.legend,{theme:n,position:e.legendPosition,size:[o[0],o[1]],margin:i,hasTitle:!!e.title,legendLayout:e.legendLayout})??Bh(e.legend,o,i,e.legendPosition,e.legendLayout):null;return{annotationRender:h,node:(0,zg.jsxs)("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:o[0],height:o[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,zg.jsx)("g",{transform:`translate(${i.left},${i.top})`,children:f}),(0,zg.jsx)(Ig,{title:e.title,totalWidth:o[0],marginTop:Math.max(i.top,28)}),p]})}}(e,t,o,c,i);return l=n.annotationRender,n.node}});return e&&(e.evidence=Ec({frameType:"physics",width:o[0],height:o[1],marks:h.scene.sceneNodes,title:t.title,description:t.description,annotations:t.annotations,annotationRender:l,extraWarnings:[...0===h.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...h.scene.evidence.warnings]})),h.svg}var Eg=c(require("react-dom/server"));var Dg=require("react/jsx-runtime"),Bg={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}};function Wg(t,e){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:e}var Yg={BigNumber:function(t,e){const o="presentation"===t.mode||"inline"===t.mode||"thumbnail"===t.mode?t.mode:"tile",i=Bg[o],n=Wg(t.width,i.width),r=Wg(t.height,i.height),s="number"==typeof t.padding&&Number.isFinite(t.padding)?Math.max(0,t.padding):i.padding,a="center"===t.align||"end"===t.align||"start"===t.align?t.align:i.align,c="center"===a?"middle":"end"===a?"end":"start",l="center"===a?n/2:"end"===a?n-s:s,u=Ot(t.theme),d="number"==typeof t.value&&Number.isFinite(t.value)?t.value:void 0,h=function(t,e={}){if("function"==typeof t)return t;const o=e.locale??"en-US";if("currency"===t){const t=e.precision??2,i=new Intl.NumberFormat(o,{style:"currency",currency:e.currency??"USD",maximumFractionDigits:t,minimumFractionDigits:t});return t=>i.format(t)}if("percent"===t){const t=new Intl.NumberFormat(o,{style:"percent",maximumFractionDigits:e.precision??1,minimumFractionDigits:0});return e=>t.format(e)}if("compact"===t){const t=new Intl.NumberFormat(o,{notation:"compact",maximumFractionDigits:e.precision??1,minimumFractionDigits:0});return e=>t.format(e)}if("duration"===t)return t=>function(t){if(!Number.isFinite(t))return t+"";const e=0>t?"-":"",o=Math.abs(t);if(1e3>o)return`${e}${Math.round(o)}ms`;const i=o/1e3;if(60>i)return`${e}${n=i,Math.round(100*n)/100+""}s`;var n;const r=i/60;if(60>r){const t=Math.floor(r),o=Math.round(i-60*t);return 0===o?`${e}${t}m`:`${e}${t}m ${o}s`}const s=r/60;if(24>s){const t=Math.floor(s),o=Math.round(r-60*t);return 0===o?`${e}${t}h`:`${e}${t}h ${o}m`}const a=Math.floor(s/24),c=Math.round(s-24*a);return 0===c?`${e}${a}d`:`${e}${a}d ${c}h`}(t);const i=new Intl.NumberFormat(o,{notation:e.notation??"standard",maximumFractionDigits:e.precision??0,minimumFractionDigits:0});return t=>i.format(t)}("string"==typeof t.format||"function"==typeof t.format?t.format:"number",{locale:"string"==typeof t.locale?t.locale:void 0,currency:"string"==typeof t.currency?t.currency:void 0,precision:"number"==typeof t.precision?t.precision:void 0}),f=void 0===d?"No value":(p=h(d),`${("string"==typeof t.prefix?t.prefix:void 0)??""}${p}${("string"==typeof t.suffix?t.suffix:void 0)??""}`);var p;const y=void 0===d?void 0:function(t,e){if(!e||0===e.length)return null;if(!Number.isFinite(t))return null;const o=e.filter(t=>Number.isFinite(t.at)||t.at===-1/0).slice().sort((t,e)=>t.at-e.at);let i=null;for(const e of o){if(e.at>t)break;i=e}return i}(d,t.thresholds),g="string"==typeof t.color?t.color:function(t,e,o){return e||("success"===t?o.colors.success??"#2ca02c":"warning"===t?o.colors.warning??"#b26a00":"danger"===t?o.colors.danger??"#d62728":"info"===t?o.colors.info??o.colors.primary:o.colors.text)}(y?.level??"neutral",y?.color,u),m="string"==typeof t.label?t.label:void 0,x="string"==typeof t.caption?t.caption:void 0,b="string"==typeof t.unit?t.unit:void 0,v=void 0===d?void 0:function(t,e,o){const i=t.comparison&&"object"==typeof t.comparison?t.comparison:void 0,n=i&&"number"==typeof i.value&&Number.isFinite(i.value)?i.value:void 0,r=("number"==typeof t.delta&&Number.isFinite(t.delta)?t.delta:void 0)??(void 0===n?void 0:e-n);if(void 0===r)return;const s=function(t,e){return Number.isFinite(t)?0===t?e(0):`${t>0?"+":"−"}${e(Math.abs(t))}`:""}(r,o);return`${s}${i&&"string"==typeof i.label?" "+i.label:""}`}(t,d,h),w=void 0===d?void 0:function(t,e,o){const i=t.target&&"object"==typeof t.target?t.target:void 0;if(!i||"number"!=typeof i.value||!Number.isFinite(i.value))return;const n="string"==typeof i.label?" "+i.label:"";return 0===i.value?`target ${o(i.value)}${n}`:`${new Intl.NumberFormat("string"==typeof t.locale?t.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(e/i.value)} of ${o(i.value)}${n}`}(t,d,h),k=[v,w,y?.label].filter(Boolean).join(" · "),S="string"==typeof t.description&&t.description||[m,f,b,k].filter(Boolean).join(", "),A="string"==typeof t.background?t.background:u.colors.surface??u.colors.background,M="string"==typeof t.borderColor?t.borderColor:u.colors.border,_=s+i.labelSize,P=_+i.captionSize+4,j="presentation"===o?r/2+.32*i.valueSize:"thumbnail"===o?r/2+.34*i.valueSize:Math.min(r-s-(k?26:4),(i.showHeader&&(m||x)?x?P+10:_+14:s)+i.valueSize),L=l+("start"===c?Math.max(i.valueSize,f.length*i.valueSize*.55):0),$=Eg.renderToStaticMarkup((0,Dg.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:r,viewBox:`0 0 ${n} ${r}`,role:"img","aria-label":S,"data-semiotic-component":"BigNumber",children:[(0,Dg.jsx)("title",{children:m??f}),"string"==typeof t.description&&(0,Dg.jsx)("desc",{children:t.description}),(0,Dg.jsx)("rect",{x:i.border?.5:0,y:i.border?.5:0,width:i.border?n-1:n,height:i.border?r-1:r,rx:i.border?8:0,fill:A,stroke:i.border?M:"none"}),i.showHeader&&m&&(0,Dg.jsx)("text",{x:l,y:_,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.labelSize,fontWeight:600,fill:u.colors.text,children:m}),i.showHeader&&x&&(0,Dg.jsx)("text",{x:l,y:P,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.captionSize,fill:u.colors.textSecondary,children:x}),(0,Dg.jsx)("text",{x:l,y:j,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:g,"data-mark-type":"value",children:f}),b&&void 0!==d&&"start"===c&&(0,Dg.jsx)("text",{x:L+6,y:j,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*i.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:b}),i.showDetail&&k&&(0,Dg.jsx)("text",{x:l,y:Math.min(r-s,j+i.detailSize+10),textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.detailSize,fill:u.colors.textSecondary,children:k})]}));return e&&(e.evidence=Ec({frameType:"value",width:n,height:r,marks:void 0===d?[]:[{type:"value"}],title:m,description:S})),$}};function qg(t,e,o){return Yg[t](e,o)}var Xg=require("react/jsx-runtime");function Gg(t,e){switch(t){case"xy":return _f(e);case"ordinal":return cp(e);case"network":return Ey(e);case"geo":return mg(e);case"physics":return Ng(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Vg(t){return _f(t)}function Hg(t){return cp(t)}function Ug(t){return Ey(t)}function Kg(t){return mg(t)}var Zg=new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),Qg=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi;function Jg(t,e){const o=Number(t);if(!Number.isFinite(o))return t;const i=10**e,n=Math.round((o+Number.EPSILON)*i)/i;return Object.is(n,-0)?"0":n+""}function tm(t,e){const o=function(t){if(Number.isFinite(t))return Math.max(0,Math.min(8,Math.floor(t)))}(e);return void 0===o?t:t.replace(/<[^>]+>/g,t=>t.replace(/\s([\w:-]+)="([^"]*)"/g,(t,e,i)=>!Zg.has(e)||/\b(?:var|calc|url)\(/i.test(i)?t:` ${e}="${function(t,e){const o=RegExp(Qg.source,Qg.flags);let i,n="",r=0,s=!1;for(;i=o.exec(t);){const o=t.slice(r,i.index);n+=s&&0===o.length?" ":o,n+=Jg(i[0],e),r=i.index+i[0].length,s=!0}return n+t.slice(r)}(i,o)}"`))}var em=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],om=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function im(t,e){const o={};for(const i of e)void 0!==t[i]&&(o[i]=t[i]);return o}function nm(t,e,o){return sm(t,e,o).svg}function rm(t,e,o){const i={},{svg:n,frameType:r}=sm(t,e,o,i),s=i.evidence??Ec({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,S(s,t,e),{svg:n,evidence:s}}function sm(t,e,o,i){if(Object.prototype.hasOwnProperty.call(Yg,t))return{svg:tm(qg(t,e,i),o?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(zc,t))throw Error(`Unknown chart component: "${t}". Run \`npx semiotic-ai --list\` for supported chart types.`);const n=zc[t];var r;const s=function(t,e,o){const i=p[t||"primary"],n=t&&"primary"!==t||!o?.width?i.width:o.width,r=t&&"primary"!==t||!o?.height?i.height:o.height,s=function(t,e,o=t.responsiveRules){if(!Array.isArray(o)||0===o.length)return{props:t,matches:[]};const i=o.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:o}=t,i=e.width,n=e.height,r=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),s=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof o.minWidth&&o.minWidth>i||"number"==typeof o.maxWidth&&i>o.maxWidth||"number"==typeof o.minHeight&&("number"!=typeof n||o.minHeight>n)||"number"==typeof o.maxHeight&&("number"!=typeof n||n>o.maxHeight)||"number"==typeof o.minAspectRatio&&("number"!=typeof r||o.minAspectRatio>r)||"number"==typeof o.maxAspectRatio&&("number"!=typeof r||r>o.maxAspectRatio)||o.orientation&&s!==o.orientation)}(t.rule,e)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:i.reduce((t,e)=>function(t,e){const o={...t,...e};for(const i of["margin","frameProps","mobileSemantics","style"])u(t[i])&&u(e[i])&&(o[i]={...t[i],...e[i]});return"string"==typeof t.className&&"string"==typeof e.className&&(o.className=`${t.className} ${e.className}`),o}(t,e.rule.transform),t),matches:i}}({...e,mode:t},{width:e.width??n,height:e.height??r}).props,a=s.mode||t||"primary",c=p[a],l="context"===a||"sparkline"===a,d="primary"===a&&o?.width?o.width:c.width;return{mode:a,width:s.width??d,height:s.height??("primary"===a&&o?.height?o.height:c.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:y(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:f(s.mobileInteraction,{mode:a,width:s.width??d,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(n.layout?.mode??("string"==typeof(r=e.mode)&&Object.prototype.hasOwnProperty.call(p,r)?e.mode:void 0),{...n.layout?.modeDefaults,...im(e,om)},n.layout?.primarySize),{data:a,theme:c,background:l,className:d,annotations:h,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=e,{width:w,height:k}=s,S=[w,k],M=v.frameProps||{},_=n.layout?.margin,P="function"==typeof _?_(e,s):_??s.marginDefaults,j=void 0!==g?g:M.margin,L=function(t){if(null==t)return;if("number"==typeof t)return{top:t,right:t,bottom:t,left:t};const e={};return"number"==typeof t.top&&(e.top=t.top),"number"==typeof t.right&&(e.right=t.right),"number"==typeof t.bottom&&(e.bottom=t.bottom),"number"==typeof t.left&&(e.left=t.left),e}(j),$="number"==typeof j?{top:j,right:j,bottom:j,left:j}:{...P,...L},R=im(v,em),C=t=>M[t]??s[t],I={...M,...R,theme:c,title:s.title,description:s.description,showAxes:C("showAxes"),showLegend:C("showLegend"),showLabels:C("showLabels"),showGrid:C("showGrid"),xLabel:C("xLabel"),yLabel:C("yLabel"),categoryLabel:C("categoryLabel"),valueLabel:C("valueLabel"),background:l,className:d,annotations:h,size:S,margin:$,__compactMode:s.compactMode,__autoLegendMargin:!0,...void 0!==m&&{colorScheme:m},...void 0!==b&&{legendPosition:b},_idPrefix:v._idPrefix},T=n.buildProps(a,x,m,I,v);let O;switch(n.frameType){case"xy":O=_f(T,i);break;case"ordinal":O=cp(T,i);break;case"network":O=Ey(T,i);break;case"geo":O=mg(T,i);break;case"physics":O=Ng(T,i)}const z=n.renderOverlay?.(T,{theme:Ot(c)});if(null!=z){const t=A.renderToStaticMarkup((0,Xg.jsx)(Xg.Fragment,{children:z})),e=O.lastIndexOf("</svg>");O=0>e?`${O}${t}`:`${O.slice(0,e)}${t}${O.slice(e)}`}return{svg:tm(O,o?.precision),frameType:n.frameType}}async function am(t,e,o={}){const{format:i="png",scale:n=1,background:r}=o;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?Gg(t,e):nm(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"===i?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function cm(t,e={}){const{title:o,subtitle:i,theme:n,width:r=1200,height:s,layout:a={},background:c}=e,l=zt(Ot(n)),u=a.columns||2,d=a.gap??16;let h=0;o&&(h+=30),i&&(h+=20),h>0&&(h+=10);const f=Math.floor((r-d-d*(u-1))/u),p=[];let y=0,g=h+d,m=0;for(const e of t){const t=Math.min(e.colSpan||1,u),o=e.props.height||300;y+t>u&&(g+=m+d,y=0,m=0),p.push({chart:e,x:d/2+y*(f+d),y:g,w:f*t+d*(t-1),h:o}),m=Math.max(m,o),y+=t}const x=s||g+m+d,b=p.map((t,e)=>{const{chart:o,x:i,y:r,w:s,h:a}=t,c={...o.props,width:s,height:a,theme:n,_idPrefix:"chart-"+e};let l;return l=o.component?nm(o.component,c):o.frameType?Gg(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Xg.jsx)("g",{transform:`translate(${i},${r})`,children:(0,Xg.jsx)("foreignObject",{width:s,height:a,children:(0,Xg.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+e)});return A.renderToStaticMarkup((0,Xg.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:x,role:"img","aria-label":o||"Dashboard",style:{fontFamily:l.fontFamily},children:[o&&(0,Xg.jsx)("title",{children:o}),c&&(0,Xg.jsx)("rect",{x:0,y:0,width:r,height:x,fill:c}),o&&(0,Xg.jsx)("text",{x:r/2,y:24,textAnchor:"middle",fontSize:l.titleFontSize+4,fontWeight:l.titleFontWeight,fill:l.text,fontFamily:l.titleFontFamily,children:o}),i&&(0,Xg.jsx)("text",{x:r/2,y:o?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),b]}))}var lm=c(require("react-dom/server")),um=require("react/jsx-runtime");function dm(t,e,o,i={}){const{stepSize:n,windowSize:r,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=o.width||600,p=o.height||400,y=Ot(o.theme),g={...o,...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=pe({top:20,right:20,bottom:30,left:40,...o.margin},o.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let i=0;x.length>i;i++){const n=x[i],s=e.slice(r?Math.max(0,n-r):0,n),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:o.projection||"vertical",oAccessor:o.oAccessor||o.categoryAccessor||"category",rAccessor:o.rAccessor||o.valueAccessor||"value",colorAccessor:o.colorAccessor||o.colorBy,stackBy:o.stackBy,groupBy:o.groupBy,connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,barPadding:o.barPadding,innerRadius:o.innerRadius,normalize:o.normalize,bins:o.bins,colorScheme:o.colorScheme||y.colors.categorical,...h&&{decay:h}},c=new Qf(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(mm(c.scene,f,p,y,g))}else for(let i=0;x.length>i;i++){const n=x[i],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:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:o.colorAccessor||o.colorBy,groupAccessor:o.groupAccessor||o.lineBy,lineDataAccessor:o.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:o.colorScheme||y.colors.categorical,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,sizeAccessor:o.sizeAccessor||o.sizeBy,sizeRange:o.sizeRange,...h&&{decay:h},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new vu(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(gm(b.scene,f,p,y,g,v)),l>0&&i>0&&b.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/l*t),S.push(gm(b.scene,f,p,y,g,v))}}return S}function hm(t,e,o={}){return e.map(e=>{try{return nm(t,{...o,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${o.width||e.width||600}" height="${o.height||e.height||400}"></svg>`}})}function fm(t,e,o){const i=e.size??[e.width??600,e.height??400],n=Ot(e.theme),r=zt(n),s=e.background||n.colors.background,a=e.idPrefix??"physics-gif",c=e.title?`${a}-title-${o}`:void 0,l=e.description?`${a}-desc-${o}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=Sg(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),h=(0,um.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:r.fontFamily},children:[e.title&&(0,um.jsx)("title",{id:c,children:e.title}),e.description&&(0,um.jsx)("desc",{id:l,children:e.description}),s&&"transparent"!==s?(0,um.jsx)("rect",{x:0,y:0,width:i[0],height:i[1],fill:s}):null,(0,um.jsx)("g",{id:`${a}-frame-${o}`,children:d.map((t,e)=>td(t,e,`${a}-${o}`))})]});return lm.renderToStaticMarkup(h)}function pm(t,e={}){const{fps:o=12,frameCount:i,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,o)/l)),d=i??Math.max(1,Math.ceil(n*Math.max(1,o))),h=c?{...t,background:c}:t,f=new ws(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push(fm(f,h,0)));d>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(fm(f,h,p.length))}return p}function ym(t,e){const o=t.background||e.colors.background;return o&&"transparent"!==o?o:null}function gm(t,e,o,i,n,r){const s=zt(i),a=pe({top:20,right:20,bottom:30,left:40,...n.margin},n.title),c=e-a.left-a.right,l=o-a.top-a.bottom,u=ym(n,i),d=n.renderMode,h=t.map((t,e)=>od({node:t,index:e,renderMode:d,fallback:()=>td(t,e)}).element).filter(Boolean),f=function(t,e,o,i,n,r){if(!t||0===t.length)return null;const s=zt(i),a=[];for(let i=0;t.length>i;i++){const c=t[i];if("y-threshold"===c.type&&null!=c.value){let t=null;if(r)t=r(c.value);else if(n){const[e,i]=n,r=i-e;if(0===r)continue;t=o-(c.value-e)/r*o}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,um.jsxs)("g",{children:[(0,um.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,um.jsx)("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(o-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-"+i))}}return a.length>0?(0,um.jsx)(um.Fragment,{children:a}):null}(n.annotations,c,l,i,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 lm.renderToStaticMarkup((0,um.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:o,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,um.jsx)("title",{id:g,children:p}),y&&(0,um.jsx)("desc",{id:m,children:y}),u&&(0,um.jsx)("rect",{x:0,y:0,width:e,height:o,fill:u}),(0,um.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,h]}),p&&(0,um.jsx)("text",{x:e/2,y:de,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:p})]}))}function mm(t,e,o,i,n){const r=zt(i),s=pe({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+(o-s.top-s.bottom)/2:s.top,u=ym(n,i),d=np({nodes:t,renderMode:n.renderMode,idPrefix:n.idPrefix}).map(t=>t.element),h="string"==typeof n.title?n.title:void 0,f="string"==typeof n.description?n.description:void 0,p=h?"semiotic-title":void 0,y=f?"semiotic-desc":void 0,g=[p,y].filter(Boolean).join(" ")||void 0;return lm.renderToStaticMarkup((0,um.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:o,role:"img","aria-labelledby":g,style:{fontFamily:r.fontFamily},children:[h&&(0,um.jsx)("title",{id:p,children:h}),f&&(0,um.jsx)("desc",{id:y,children:f}),u&&(0,um.jsx)("rect",{x:0,y:0,width:e,height:o,fill:u}),(0,um.jsx)("g",{transform:`translate(${c},${l})`,children:d}),h&&(0,um.jsx)("text",{x:e/2,y:de,textAnchor:"middle",fontSize:r.titleFontSize,fontWeight:r.titleFontWeight,fill:r.text,fontFamily:r.titleFontFamily,children:h})]}))}async function xm(t,e,o,i={}){const{fps:n=12,loop:r=!0,scale:s=1,background:a}=i,c=o.width||600,l=o.height||400,u=dm(t,e,a?{...o,background:a}:o,i);if(0===u.length)throw Error("No frames generated — check that data is not empty");return vm(u,c,l,{fps:n,loop:r,scale:s})}async function bm(t,e={}){const{fps:o=12,loop:i=!0,scale:n=1}=e,r=t.size??[t.width??600,t.height??400],s=pm(t,e);if(0===s.length)throw Error("No physics frames generated");return vm(s,r[0],r[1],{fps:o,loop:i,scale:n})}async function vm(t,e,o,i={}){const{fps:n=12,loop:r=!0,scale:s=1}=i,a=Math.round(e*s),c=Math.round(o*s);let l,u,d,h;try{const t="sharp",e=await import(t);l=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await import(t),o=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!o)throw Error("gifenc did not expose its encoder functions");u=o.GIFEncoder,d=o.quantize,h=o.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 o=t[e],i=await l(Buffer.from(o),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),n=new Uint8Array(i),u=d(n,256),y=h(n,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|
|
1
|
+
function t(t){const e=t?.find(t=>"bottom"===t.orient),o=t?.find(t=>"top"===t.orient),i=t?.find(t=>"left"===t.orient),n=t?.find(t=>"right"===t.orient);return{bottomAxis:e,topAxis:o,leftAxis:i,rightAxis:n,xAxis:e??o,yAxis:i??n,xOrient:e||!o?"bottom":"top",yOrient:i||!n?"left":"right"}}function e(t){let e=6;for(let o=1;t.length>o;o++){const i=Math.abs(t[o]-t[o-1]);i>0&&Number.isFinite(i)&&(e=Math.max(e,Math.ceil(Math.log10(Math.max(Math.abs(t[o]),Math.abs(t[o-1]))/i))+1))}const o=Math.min(17,e);return t=>Number.isInteger(t)?t+"":Number(t.toPrecision(o))+""}function o(...t){let e;for(const o of t)o&&(e=i(e)&&i(o)?{legendGroups:[...e.legendGroups,...o.legendGroups],legendDistance:o.legendDistance??e.legendDistance}:o);return e}function i(t){return"object"==typeof t&&null!==t&&"legendGroups"in t&&Array.isArray(t.legendGroups)}function n(t){return"object"==typeof t&&null!==t&&"gradient"in t}function r(t){return"string"==typeof t&&t.length>0}function s(t,e,o=!1){const i=o?e?Vh:Gh:e?Xh:0;return i>t.top?{...t,top:i}:t}function a(t,e){return s(t,r(e))}function c(t,e,o,i,n=8){const r=i,s="left"===i?"right":"right"===i?"left":"top"===i?"bottom":"top",a=Math.max(e[r],Math.max(0,("left"===i||"right"===i?o[0]:o[1])-n)-t[s]);t[r]>a&&(t[r]=a)}function l(t){return Math.ceil(7*t.length)}function u(t,o){if(i(t)){const e=v(o);let i=Jh;for(const o of t.legendGroups){o.label&&(i=Math.max(i,l(o.label)));for(const t of o.items)i=Math.max(i,e.swatchSize+e.labelGap+l(t.label))}return i}if(n(t)){const{gradient:o}=t,i=o.format||e(o.domain),n=Math.max(l(i(o.domain[0])),l(i(o.domain[1]))),r=o.label?l(o.label):0;return Math.max(Jh,19+n,r)}return Jh}function d(t){return(i(t)||n(t))&&Number.isFinite(t.legendDistance)?Math.max(0,t.legendDistance):tf}function h(t,e){return null!=t?.sideGutter?Math.max(0,t.sideGutter):e?.hasAxis?e.hasAxisLabel?df:uf:0}function f(t){return Math.max(0,t?.edgeGutter??ef)}function p(t,e){return null!=e?.axisGutter?Math.max(0,e.axisGutter):t?.hasAxis?t.hasAxisLabel?t.rotatedTicks?lf:cf:af:0}function y(e){const{bottomAxis:o,topAxis:i,leftAxis:n,rightAxis:r}=t(e.axes),s=!(i&&!o||!1===o?.visible),a=!!i&&!o&&!1!==i.visible,c=!(r&&!n||!1===n?.visible),l=!!r&&!1!==r.visible,u=!1!==e.showAxes;return{hasAxis:u&&s,hasAxisLabel:u&&s&&!!(o?.label??e.xLabel),rotatedTicks:u&&s&&(e.rotatedTicks??!!o?.autoRotate),topAxis:a?{hasAxis:u,hasAxisLabel:u&&!!(i?.label??e.xLabel),rotatedTicks:u&&(e.rotatedTicks??!!i?.autoRotate)}:void 0,leftAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??e.yLabel)}:void 0,rightAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??e.yLabelRight??e.yLabel)}:void 0}}function g(t,e,o){if(n(t))return t.gradient.label?rf:sf;if(!i(t))return 20;const r=v(o),s=Math.max(1,o?.maxWidth??e);let a=r.rowHeight;for(const e of t.legendGroups){let t=0,o=0;for(const i of e.items){const e=r.swatchSize+r.labelGap+l(i.label),n=0===o?e:o+r.itemGap+e;o>0&&n>s?(t+=1,o=e):o=n}e.items.length>0&&(t+=1),a=Math.max(a,t*r.rowHeight,e.label?l(e.label):0)}return a+(t.legendGroups.length>1?16:0)}function m(t,e,o){return u(t,e)+d(t)+h(e,o)+f(e)}function x(t,e){const{legend:o}=e;if(!o)return;const i=e.position??"right",n=g(o,Math.max(1,e.size[0]-t.left-t.right),e.legendLayout)+d(o)+p("bottom"===i?e.axisChrome:"top"===i?e.axisChrome?.topAxis:void 0,e.legendLayout)+("top"===i&&e.hasTitle?24:0),r=Math.max(e.minimumMargin??0,"top"===i?e.hasTitle?Vh:Gh:0);"right"===i?t.right=Math.max(t.right,r,m(o,e.legendLayout,e.axisChrome?.rightAxis)):"left"===i?t.left=Math.max(t.left,r,m(o,e.legendLayout,e.axisChrome?.leftAxis)):"top"===i?t.top=Math.max(t.top,r,n):t.bottom=Math.max(t.bottom,r,n)}function b(t,e){const o=e.position??"right",i="top"===o||"bottom"===o,n=Math.max(0,e.totalWidth-e.margin.left-e.margin.right),r=Math.max(1,i?e.legendLayout?.maxWidth??n:e.reservedWidth??u(t,e.legendLayout)),s=d(t),a=h(e.legendLayout,"left"===o?e.axisChrome?.leftAxis:e.axisChrome?.rightAxis),c=f(e.legendLayout),l=g(t,n,e.legendLayout),y=p(e.axisChrome,e.legendLayout),m=p(e.axisChrome?.topAxis,e.legendLayout);if("left"===o)return{x:Math.max(c,e.margin.left-a-r-s),y:e.margin.top,width:r,height:l};if("top"===o)return{x:e.margin.left,y:e.margin.top-m-s-l,width:r,height:l};if("bottom"===o){const t=e.totalHeight-e.margin.bottom;return{x:e.margin.left,y:Math.max(t+s,Math.min(t+y+s,e.totalHeight-l)),width:r,height:l}}return{x:Math.min(e.totalWidth-r-c,e.totalWidth-e.margin.right+a+s),y:e.margin.top,width:r,height:l}}function v(t){const e=Math.max(1,t?.swatchSize??Uh),o=Math.max(e,t?.rowHeight??Qh);return{swatchSize:e,labelGap:Math.max(0,t?.labelGap??Kh),itemGap:Math.max(0,t?.itemGap??Zh),rowHeight:o,align:"left"===t?.align?"start":"right"===t?.align?"end":t?.align??"start",maxWidth:t?.maxWidth}}function w(t,e){let o=24;return t.map(({hasLabel:t,itemCount:i})=>{o+=5;const n=o;let r;o+=8,t&&(o+=16,r=o,o+=8);const s=o;return o+=i*e+8,{lineY:n,labelY:r,itemsY:s,endY:o}})}function k(t,e,o=!1){const i={...t};for(const t of e??[])!1!==t.visible||"top"===t.orient&&o||(i[t.orient]=0);return i}function A(t){let e=0;for(;t.length>e;){const o=/^\s+/.exec(t.slice(e));o&&(e+=o[0].length);const i=t.startsWith("\x3c!--",e)?"--\x3e":t.startsWith("<?",e)?"?>":void 0;if(i){const o=t.indexOf(i,e+2);if(0>o)return;e=o+i.length;continue}if(/^<!DOCTYPE\s/i.test(t.slice(e))){let o="",i=0,n=e+9;for(;t.length>n;n+=1){const e=t[n];if(o)e===o&&(o="");else if(t.startsWith("\x3c!--",n)){const e=t.indexOf("--\x3e",n+4);if(0>e)return;n=e+2}else if('"'===e||"'"===e)o=e;else if("["===e)i+=1;else if("]"===e)i-=1;else if(">"===e&&0===i)break}if(n===t.length)return;e=n+1;continue}break}const o=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(t.slice(e));if(!o)return;const i=o[2].endsWith("/"),n=i?o[2].slice(0,-1):o[2];return n.replace(hf,"").trim()?void 0:{start:e,end:e+o[0].length,name:o[1],attributes:n,selfClosing:i}}function S(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function M(t){return t.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(t,e)=>{if(!e.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[e];const o=e.startsWith("#x")?parseInt(e.slice(2),16):Number(e.slice(1));return o>0&&1114111>=o?String.fromCodePoint(o):t})}function _(t,e){for(const o of t.attributes.matchAll(hf))if(o[1]===e)return M(o[2]??o[3])}function $(t,e){const o=A(t);if(!o)return t;const i=new Map(Object.entries(e));let n=o.attributes.replace(hf,(t,e)=>{const o=i.get(e);return void 0===o?t:(i.delete(e),` ${e}="${S(o)}"`)});for(const[t,e]of i)n+=` ${t}="${S(e)}"`;return`${t.slice(0,o.start)}<${o.name}${n}${o.selfClosing?"/":""}>${t.slice(o.end)}`}function P(t,e){const o=A(t);if(!o)return e;const i=t=>{const i=_(o,t),n=i&&/^[0-9]+(?:\.[0-9]+)?$/.test(i)?Number(i):NaN;return Number.isFinite(n)&&n>0?n:e[t]};return{width:i("width"),height:i("height")}}function j(t,e){const o=A(t);return o?$(t,{width:"100%",height:"100%",...void 0===_(o,"viewBox")?{viewBox:`0 0 ${e.width} ${e.height}`}:{},...void 0===_(o,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):t}function I(t){return null==t?"null":Array.isArray(t)?`[${t.map(I).join(",")}]`:t instanceof Date?JSON.stringify(t):"object"==typeof t?`{${Object.entries(t).filter(([,t])=>void 0!==t).sort(([t],[e])=>e>t?-1:t>e?1:0).map(([t,e])=>`${JSON.stringify(t)}:${I(e)}`).join(",")}}`:JSON.stringify(t)}function L(t){const e=[...yf],o=Array.from((new TextEncoder).encode(t)),i=8*o.length;for(o.push(128);o.length%64!=56;)o.push(0);const n=Math.floor(i/4294967296),r=i>>>0;o.push(n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r);const s=[];for(let t=0;o.length>t;t+=4)s.push((o[t]<<24|o[t+1]<<16|o[t+2]<<8|o[t+3])>>>0);for(let t=0;s.length>t;t+=16){const o=[...s.slice(t,t+16)];for(let t=16;64>t;t+=1){const e=ff(o[t-15],7)^ff(o[t-15],18)^o[t-15]>>>3,i=ff(o[t-2],17)^ff(o[t-2],19)^o[t-2]>>>10;o[t]=o[t-16]+e+o[t-7]+i>>>0}let[i,n,r,a,c,l,u,d]=e;for(let t=0;64>t;t+=1){const e=d+(ff(c,6)^ff(c,11)^ff(c,25))+(c&l^~c&u)+gf[t]+o[t]>>>0,s=i&n^i&r^n&r;d=u,u=l,l=c,c=a+e>>>0,a=r,r=n,n=i,i=e+((ff(i,2)^ff(i,13)^ff(i,22))+s>>>0)>>>0}const h=[i,n,r,a,c,l,u,d];for(let t=0;8>t;t+=1)e[t]=e[t]+h[t]>>>0}return e.map(t=>t.toString(16).padStart(8,"0")).join("")}function R(t,e){return`${t}[Symbol(${e.description??""})]`}function T(t,e){if(!/^(0|[1-9][0-9]*)$/.test(t))return!1;const o=Number(t);return Number.isSafeInteger(o)&&o>=0&&e>o}function C(t,e){return"number"==typeof e?`${t}[${e}]`:t?`${t}.${e}`:e}function O(t){return t.sort((t,e)=>{const o=JSON.stringify(t),i=JSON.stringify(e);return i>o?-1:o>i?1:0})}function F(t,e,o){if(null===t)return null;if(t instanceof Date){const i=t.getTime();return Number.isFinite(i)?{$type:"date",value:t.toISOString()}:void o.excluded.push(e)}switch(typeof t){case"string":case"boolean":return t;case"number":return Number.isNaN(t)?{$type:"number",value:"NaN"}:t===1/0?{$type:"number",value:"Infinity"}:t===-1/0?{$type:"number",value:"-Infinity"}:Object.is(t,-0)?{$type:"number",value:"-0"}:t;case"bigint":return{$type:"bigint",value:""+t};case"undefined":case"function":case"symbol":return void o.excluded.push(e);case"object":{const i=t;if(o.ancestors.has(i))return void o.excluded.push(e);o.ancestors.add(i);try{if(Array.isArray(t)){for(const i of Reflect.ownKeys(t))"length"===i||"string"==typeof i&&T(i,t.length)||o.excluded.push("symbol"==typeof i?R(e,i):C(e,i));return Array.from({length:t.length},(i,n)=>{const r=C(e,n),s=Object.getOwnPropertyDescriptor(t,n+"");if(!s||!("value"in s)||!s.enumerable)return o.excluded.push(r),null;const a=F(s.value,r,o);return void 0===a?null:a})}const i={},n=Object.getPrototypeOf(t);if(n!==Object.prototype&&null!==n)return void o.excluded.push(e);const r=[];for(const i of Reflect.ownKeys(t)){if("symbol"==typeof i){o.excluded.push(R(e,i));continue}const n=Object.getOwnPropertyDescriptor(t,i);n&&"value"in n&&n.enumerable?r.push(i):o.excluded.push(C(e,i))}for(const n of r.sort()){const r=Object.getOwnPropertyDescriptor(t,n),s=F(r&&"value"in r?r.value:void 0,C(e,n),o);void 0!==s&&Object.defineProperty(i,n,{value:s,enumerable:!0,configurable:!0,writable:!0})}return i}finally{o.ancestors.delete(i)}}default:return void o.excluded.push(e)}}function D(t,e=new Set){if(null===t)return["null"];if(t instanceof Date)return Number.isFinite(t.getTime())?["date",t.toISOString()]:["excluded"];switch(typeof t){case"string":return["string",t];case"boolean":return["boolean",t];case"number":return["number",Number.isNaN(t)?"NaN":t===1/0?"Infinity":t===-1/0?"-Infinity":Object.is(t,-0)?"-0":t+""];case"bigint":return["bigint",""+t];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(e.has(t))return["excluded"];e.add(t);try{const o=o=>{const i="symbol"==typeof o?["symbol-key",o.description??""]:["string-key",o],n=Object.getOwnPropertyDescriptor(t,o);return n?"value"in n?[i,"data",!!n.enumerable,D(n.value,e)]:[i,"accessor",!!n.enumerable,!!n.get,!!n.set]:[i,"missing"]};if(Array.isArray(t)){return["array",Array.from({length:t.length},(e,i)=>{const n=i+"";return Object.prototype.hasOwnProperty.call(t,n)?o(n):["hole"]}),O(Reflect.ownKeys(t).filter(e=>"length"!==e&&!("string"==typeof e&&T(e,t.length))).map(o))]}const i=Object.getPrototypeOf(t);return[i!==Object.prototype&&null!==i?"non-json-object":"object",O(Reflect.ownKeys(t).map(o))]}finally{e.delete(t)}default:return["excluded"]}}function N(t){const e={excluded:[],ancestors:new Set},o=F(t,"$",e)??null;return{value:o,text:JSON.stringify(o),excludedPaths:e.excluded}}function z(t){const e=N(t),o=L(JSON.stringify(["semiotic-value-fingerprint","v2",D(t)]));return{...e,algorithm:"sha256",digest:o,fingerprint:"sha256:"+o}}function E(t,e){return"number"==typeof e?`${t}[${e}]`:`${t}.${e}`}function B(t,e){return`${t}[Symbol(${e.description??""})]`}function W(t,e){if(!/^(0|[1-9][0-9]*)$/.test(t))return!1;const o=Number(t);return Number.isSafeInteger(o)&&o>=0&&e>o}function Y(t,e){try{return Object.getOwnPropertyDescriptor(t,e)}catch{return}}function q(t,e,o,i){const n=Y(t,e);return n&&"value"in n&&n.enumerable?X(n.value,o,i):[o]}function X(t,e="$",o=new Set){if(null===t||"string"==typeof t||"boolean"==typeof t)return[];if("number"==typeof t)return Number.isFinite(t)&&!Object.is(t,-0)?[]:[e];if("object"!=typeof t)return[e];if(o.has(t))return[e];let i,n,r;try{r=Array.isArray(t),i=Object.getPrototypeOf(t),n=Reflect.ownKeys(t)}catch{return[e]}if(i!==(r?Array.prototype:Object.prototype)&&null!==i)return[e];o.add(t);const s=[];try{if(r){const i=Y(t,"length")?.value;if(!Number.isSafeInteger(i)||0>i)return[E(e,"length")];for(const t of n)"length"===t||"string"==typeof t&&W(t,i)||s.push("symbol"==typeof t?B(e,t):E(e,t));for(let n=0;i>n;n+=1)s.push(...q(t,n+"",E(e,n),o))}else for(const i of n)"symbol"!=typeof i?s.push(...q(t,i,E(e,i),o)):s.push(B(e,i));return s}catch{return[e]}finally{o.delete(t)}}function G(t,e,o,i){Q(t,Object.keys(e),o,i);for(const[n,r]of Object.entries(e))r.values?(r.required||void 0!==t[n])&&tt(t,n,o,r.values,i):r.required?J(t,n,o,i):rt(t,n,o,i)}function V(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function H(t,e,o,i){void 0===t[e]||"number"==typeof t[e]&&Number.isFinite(t[e])||i.push({path:`${o}.${e}`,message:"Expected a finite number."})}function U(t,e,o,i){void 0!==t[e]&&"boolean"!=typeof t[e]&&i.push({path:`${o}.${e}`,message:"Expected a boolean."})}function K(t){return null===t||"string"==typeof t||"boolean"==typeof t||("number"==typeof t?Number.isFinite(t):Array.isArray(t)?t.every(K):V(t)&&Object.values(t).every(K))}function Z(t,e,o,i){void 0===t[e]||V(t[e])&&K(t[e])||i.push({path:`${o}.${e}`,message:"Expected a JSON object."})}function Q(t,e,o,i){const n=new Set(e);for(const e of Object.keys(t))n.has(e)||i.push({path:`${o}.${e}`,message:"Unexpected property."})}function J(t,e,o,i){"string"==typeof t[e]&&t[e]||i.push({path:`${o}.${e}`,message:"Expected a non-empty string."})}function tt(t,e,o,i,n){"string"==typeof t[e]&&i.includes(t[e])||n.push({path:`${o}.${e}`,message:`Expected one of: ${i.join(", ")}.`})}function et(t,e,o,i){const n=t[e];if(void 0!==n){if(V(n))return n;i.push({path:`${o}.${e}`,message:"Expected an object."})}}function ot(t,e,o,i){const n=t[e];if(void 0!==n){if(Array.isArray(n))return n;i.push({path:`${o}.${e}`,message:"Expected an array."})}}function it(t,e,o){t?.some(t=>"string"!=typeof t||!t)&&o.push({path:e,message:"Expected non-empty string values."})}function nt(t,e,o,i,n){void 0!==t[e]&&tt(t,e,o,i,n)}function rt(t,e,o,i){void 0!==t[e]&&"string"!=typeof t[e]&&i.push({path:`${o}.${e}`,message:"Expected a string."})}function st(t,e,o){V(t)?(Q(t,["id","name","kind"],e,o),J(t,"kind",e,o),rt(t,"id",e,o),rt(t,"name",e,o)):o.push({path:e,message:"Expected an actor object."})}function at(t){for(const e of Object.values(t))Object.freeze(e.suppliedBy),Object.freeze(e);return Object.freeze(t)}function ct(t){try{return function(t){const e=[],o=[];if(!V(t))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:o};const i=X(t);if(i.length>0)return{valid:!1,errors:i.map(t=>({path:t,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:o};if(Q(t,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",e),t.contractVersion!==mf&&e.push({path:"$.contractVersion",message:`Expected contract version ${mf}.`}),V(t.artifact)){Q(t.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",e),J(t.artifact,"id","$.artifact",e),tt(t.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],e);for(const o of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])rt(t.artifact,o,"$.artifact",e)}else e.push({path:"$.artifact",message:"Expected an artifact identity object."});if(V(t.purpose))if(Array.isArray(t.purpose.intents)){Q(t.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",e),t.purpose.intents.forEach((t,o)=>{V(t)&&"string"==typeof t.id&&t.id||e.push({path:`$.purpose.intents[${o}].id`,message:"Expected a non-empty intent identifier."}),V(t)&&Q(t,["id","strength","source","rationale"],`$.purpose.intents[${o}]`,e),V(t)&&void 0!==t.strength&&tt(t,"strength",`$.purpose.intents[${o}]`,["primary","secondary"],e),V(t)&&(nt(t,"source",`$.purpose.intents[${o}]`,["author","derived","model-proposal","import"],e),rt(t,"rationale",`$.purpose.intents[${o}]`,e))});for(const o of["allowedUses","prohibitedUses"])it(ot(t.purpose,o,"$.purpose",e),"$.purpose."+o,e);nt(t.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],e),rt(t.purpose,"communicativeAct","$.purpose",e),rt(t.purpose,"decisionContext","$.purpose",e)}else e.push({path:"$.purpose.intents",message:"Expected an intent array."});else e.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(t.claims)?t.claims.forEach((t,o)=>{if(!V(t))return void e.push({path:`$.claims[${o}]`,message:"Expected a claim object."});Q(t,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${o}]`,e),J(t,"id",`$.claims[${o}]`,e),tt(t,"kind",`$.claims[${o}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],e),tt(t,"status",`$.claims[${o}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],e),Array.isArray(t.evidenceIds)?t.evidenceIds.some(t=>"string"!=typeof t||!t)&&e.push({path:`$.claims[${o}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):e.push({path:`$.claims[${o}].evidenceIds`,message:"Expected an evidence identifier array."}),it(ot(t,"supersedes",`$.claims[${o}]`,e),`$.claims[${o}].supersedes`,e),rt(t,"text",`$.claims[${o}]`,e),rt(t,"asOf",`$.claims[${o}]`,e),Z(t,"scope",`$.claims[${o}]`,e),it(ot(t,"tags",`$.claims[${o}]`,e),`$.claims[${o}].tags`,e),void 0!==t.authoredBy&&st(t.authoredBy,`$.claims[${o}].authoredBy`,e);const i=et(t,"review",`$.claims[${o}]`,e);i&&(Q(i,["status","reviewer","reviewedAt","rationale"],`$.claims[${o}].review`,e),tt(i,"status",`$.claims[${o}].review`,["proposed","reviewed","approved","rejected"],e),void 0!==i.reviewer&&st(i.reviewer,`$.claims[${o}].review.reviewer`,e),rt(i,"reviewedAt",`$.claims[${o}].review`,e),rt(i,"rationale",`$.claims[${o}].review`,e));const n=et(t,"uncertainty",`$.claims[${o}]`,e);if(n){Q(n,["kind","lower","upper","confidence","unit","description"],`$.claims[${o}].uncertainty`,e),tt(n,"kind",`$.claims[${o}].uncertainty`,["interval","distribution","qualitative","unknown"],e);for(const t of["lower","upper","confidence"])H(n,t,`$.claims[${o}].uncertainty`,e);rt(n,"unit",`$.claims[${o}].uncertainty`,e),rt(n,"description",`$.claims[${o}].uncertainty`,e)}}):e.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(t.evidence)?t.evidence.forEach((t,o)=>{if(!V(t))return void e.push({path:`$.evidence[${o}]`,message:"Expected an evidence object."});Q(t,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${o}]`,e),J(t,"id",`$.evidence[${o}]`,e),tt(t,"role",`$.evidence[${o}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],e);for(const i of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])rt(t,i,`$.evidence[${o}]`,e);Z(t,"scope",`$.evidence[${o}]`,e);const i=et(t,"source",`$.evidence[${o}]`,e);if(i){Q(i,["name","uri","version","retrievedAt","publisher"],`$.evidence[${o}].source`,e);for(const t of["name","uri","version","retrievedAt","publisher"])rt(i,t,`$.evidence[${o}].source`,e)}const n=et(t,"transformation",`$.evidence[${o}]`,e);if(n){Q(n,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${o}].transformation`,e),J(n,"id",`$.evidence[${o}].transformation`,e),tt(n,"kind",`$.evidence[${o}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],e);const t=ot(n,"inputEvidenceIds",`$.evidence[${o}].transformation`,e);t?it(t,`$.evidence[${o}].transformation.inputEvidenceIds`,e):e.push({path:`$.evidence[${o}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),it(ot(n,"assumptions",`$.evidence[${o}].transformation`,e),`$.evidence[${o}].transformation.assumptions`,e),rt(n,"description",`$.evidence[${o}].transformation`,e),rt(n,"implementation",`$.evidence[${o}].transformation`,e),rt(n,"performedAt",`$.evidence[${o}].transformation`,e),Z(n,"parameters",`$.evidence[${o}].transformation`,e),void 0!==n.performedBy&&st(n.performedBy,`$.evidence[${o}].transformation.performedBy`,e)}const r=et(t,"sample",`$.evidence[${o}]`,e);if(r){Q(r,["rowCount","fields","values","truncated"],`$.evidence[${o}].sample`,e),it(ot(r,"fields",`$.evidence[${o}].sample`,e),`$.evidence[${o}].sample.fields`,e);const t=ot(r,"values",`$.evidence[${o}].sample`,e);t&&!function(t){return t.every(K)}(t)&&e.push({path:`$.evidence[${o}].sample.values`,message:"Expected JSON values."}),H(r,"rowCount",`$.evidence[${o}].sample`,e),U(r,"truncated",`$.evidence[${o}].sample`,e)}nt(t,"relationship",`$.evidence[${o}]`,["descriptive","correlational","causal","unknown"],e)}):e.push({path:"$.evidence",message:"Expected an evidence array."}),function(t,e){if(void 0===t||V(t)){if(V(t))for(const[o,i]of Object.entries(t)){const t="$.fieldStatus."+o;if(!V(i)||"string"!=typeof i.status){e.push({path:t,message:"Expected a field state with a status."});continue}Q(i,["status","reason","suppliedBy","derived","reviewedBy"],t,e),["known","unknown","manual","not-applicable"].includes(i.status)||e.push({path:t+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0===i.suppliedBy||"string"==typeof i.suppliedBy&&["author","system","model-proposal","import"].includes(i.suppliedBy)||e.push({path:t+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),rt(i,"reason",t,e),rt(i,"reviewedBy",t,e),U(i,"derived",t,e);const n=Object.prototype.hasOwnProperty.call(xf,o)?xf[o]:void 0,r="model-proposal"===i.suppliedBy,s=r&&!0===n?.modelMayPropose&&"known"!==i.status;n&&"known"===i.status&&"string"!=typeof i.suppliedBy&&e.push({path:t+".suppliedBy",message:`Known field "${o}" must identify an allowed supplier.`}),!n||"string"!=typeof i.suppliedBy||s||n.suppliedBy.includes(i.suppliedBy)||e.push({path:t+".suppliedBy",message:`Field "${o}" cannot be supplied by ${i.suppliedBy}.`}),n&&!0===i.derived&&!n.derivable&&e.push({path:t+".derived",message:`Field "${o}" cannot be marked as derived.`}),!n||!r||n.modelMayPropose&&"known"!==i.status||e.push({path:t+".suppliedBy",message:"known"===i.status?`A model proposal cannot finalize field "${o}" as known.`:`Field "${o}" does not accept model proposals.`}),"required"!==n?.humanReview||"known"!==i.status||"string"==typeof i.reviewedBy&&i.reviewedBy.trim()||e.push({path:t+".reviewedBy",message:`Known field "${o}" requires an attributable human review.`})}}else e.push({path:"$.fieldStatus",message:"Expected a field-state object."})}(t.fieldStatus,e);const n=et(t,"time","$",e);return n&&function(t,e){const o="$.time";Q(t,[...wf,...Object.keys(kf),"sources"],o,e);for(const i of wf)rt(t,i,o,e);for(const[i,n]of Object.entries(kf)){const r=et(t,i,o,e);r&&G(r,n,`${o}.${i}`,e)}ot(t,"sources",o,e)?.forEach((t,i)=>{const n=`${o}.sources[${i}]`;V(t)?G(t,Af,n,e):e.push({path:n,message:"Expected a source object."})})}(n,e),function(t,e){!function(t,e){const o=et(t,"reception","$",e);if(!o)return;Q(o,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",e);const i=ot(o,"channels","$.reception",e);i||e.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),i?.forEach((t,o)=>{const i=`$.reception.channels[${o}]`;V(t)?(Q(t,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],i,e),tt(t,"channel",i,["visual","screen-reader","sonified","agent","print","low-bandwidth"],e),nt(t,"disclosure",i,["summary","standard","detailed"],e),nt(t,"rawData",i,["deny","bounded","allow"],e),U(t,"navigation",i,e),U(t,"interactionInstructions",i,e),H(t,"tokenBudget",i,e),it(ot(t,"privacyNotes",i,e),i+".privacyNotes",e)):e.push({path:i,message:"Expected a channel object."})});for(const t of["strengths","risks","scaffolds","manualChecks"])it(ot(o,t,"$.reception",e),"$.reception."+t,e);rt(o,"audience","$.reception",e),rt(o,"description","$.reception",e),U(o,"dataFallback","$.reception",e)}(t,e),function(t,e){const o=et(t,"form","$",e);o&&(Q(o,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",e),rt(o,"chartFamily","$.form",e),rt(o,"whyThisForm","$.form",e),it(ot(o,"risks","$.form",e),"$.form.risks",e),it(ot(o,"misuse","$.form",e),"$.form.misuse",e),ot(o,"rejectedAlternatives","$.form",e)?.forEach((t,o)=>{const i=`$.form.rejectedAlternatives[${o}]`;V(t)?(Q(t,["representation","reason"],i,e),J(t,"representation",i,e),J(t,"reason",i,e)):e.push({path:i,message:"Expected an alternative object."})}))}(t,e),function(t,e){const o=et(t,"contestability","$",e);o&&(Q(o,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",e),U(o,"sourceRequestsAllowed","$.contestability",e),ot(o,"challenges","$.contestability",e)?.forEach((t,o)=>{const i=`$.contestability.challenges[${o}]`;if(V(t)){Q(t,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],i,e),J(t,"id",i,e),J(t,"claimId",i,e),J(t,"reason",i,e),tt(t,"status",i,["open","accepted","declined","resolved"],e),void 0!==t.raisedBy&&st(t.raisedBy,i+".raisedBy",e);for(const o of["raisedAt","counterclaimId","resolution"])rt(t,o,i,e)}else e.push({path:i,message:"Expected a challenge object."})}),ot(o,"corrections","$.contestability",e)?.forEach((t,o)=>{const i=`$.contestability.corrections[${o}]`;if(!V(t))return void e.push({path:i,message:"Expected a correction object."});Q(t,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],i,e),J(t,"id",i,e),J(t,"reason",i,e);const n=ot(t,"affectedClaimIds",i,e);n||e.push({path:i+".affectedClaimIds",message:"Expected an affected-claim array."}),it(n,i+".affectedClaimIds",e),it(ot(t,"replacementClaimIds",i,e),i+".replacementClaimIds",e),rt(t,"createdAt",i,e),void 0!==t.createdBy&&st(t.createdBy,i+".createdBy",e)}),ot(o,"alternativeViews","$.contestability",e)?.forEach((t,o)=>{const i=`$.contestability.alternativeViews[${o}]`;V(t)?(Q(t,["id","label","rationale"],i,e),J(t,"id",i,e),J(t,"label",i,e),rt(t,"rationale",i,e)):e.push({path:i,message:"Expected an alternative-view object."})}),ot(o,"editorialExceptions","$.contestability",e)?.forEach((t,o)=>{const i=`$.contestability.editorialExceptions[${o}]`;V(t)?(Q(t,["ruleId","rationale","owner","reviewAt"],i,e),J(t,"ruleId",i,e),J(t,"rationale",i,e),rt(t,"owner",i,e),rt(t,"reviewAt",i,e)):e.push({path:i,message:"Expected an editorial-exception object."})}))}(t,e),function(t,e){const o=et(t,"accountability","$",e);o&&(Q(o,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",e),ot(o,"authors","$.accountability",e)?.forEach((t,o)=>st(t,`$.accountability.authors[${o}]`,e)),it(ot(o,"dataSources","$.accountability",e),"$.accountability.dataSources",e),rt(o,"generatedBy","$.accountability",e),rt(o,"codeRef","$.accountability",e),ot(o,"reviews","$.accountability",e)?.forEach((t,o)=>{const i=`$.accountability.reviews[${o}]`;if(V(t)){Q(t,["id","status","reviewer","reviewedAt","rationale","policyId"],i,e),J(t,"id",i,e),tt(t,"status",i,["pending","approved","changes-requested","rejected"],e),void 0!==t.reviewer&&st(t.reviewer,i+".reviewer",e);for(const o of["reviewedAt","rationale","policyId"])rt(t,o,i,e)}else e.push({path:i,message:"Expected a review object."})}),ot(o,"actions","$.accountability",e)?.forEach((t,o)=>{const i=`$.accountability.actions[${o}]`;if(!V(t))return void e.push({path:i,message:"Expected an action object."});Q(t,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],i,e),J(t,"id",i,e),J(t,"action",i,e);const n=ot(t,"claimIds",i,e);n||e.push({path:i+".claimIds",message:"Expected a claim identifier array."}),it(n,i+".claimIds",e),void 0!==t.actor&&st(t.actor,i+".actor",e);for(const o of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])rt(t,o,i,e);nt(t,"status",i,["proposed","taken","reversed","invalidated"],e)}))}(t,e),function(t,e){const o=et(t,"inheritance","$",e);if(o){Q(o,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",e);for(const t of["requiredPaths","prohibitedExports","sourceArtifactIds"])it(ot(o,t,"$.inheritance",e),"$.inheritance."+t,e);nt(o,"privacy","$.inheritance",["public","restricted","confidential","unknown"],e),nt(o,"rawDataDefault","$.inheritance",["exclude","bounded","include"],e),nt(o,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],e)}}(t,e)}(t,e),Z(t,"extensions","$",e),Array.isArray(t.claims)&&0===t.claims.length&&o.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(t.evidence)&&0===t.evidence.length&&o.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===e.length,errors:e,warnings:o}}(t)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function lt(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function ut(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function dt(t,e={}){const o=e.mobileSemantics?.interaction,i="number"==typeof o?.targetSize?o.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,n="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,r=!!o||void 0!==i,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!n&&!r)return $f;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??i??Mf,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??Mf,standardControls:a.standardControls??!1}}function ht(t,e,o){if(!1!==e)return t;const i={...t};return"horizontal"===o?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}function ft(t){return t instanceof Date?"date:"+t.getTime():`${typeof t}:${t+""}`}function pt(t,e,o,i){const n=t??e;return"function"==typeof n?n(o,i):o[n+""]}function yt(t){return"string"==typeof t?.code&&t.code.length>0&&("warning"===t.severity||"error"===t.severity)&&"string"==typeof t.message&&t.message.length>0}function gt(t,e,o){if(t.semanticDiagnostics=[],t.semanticStatus="not-assessed",t.empty)return;const i=function(t){return function(t){return Rf.has(t)}(t)?function(t){return Rf.get(t)}(t):"BumpChart"===t?jf:void 0}(e);if(!i)return;let n;try{const e="function"==typeof i?i(o,t):function(t){const e=new Map;(Array.isArray(t.data)?t.data:[]).forEach((o,i)=>{if(!Number.isFinite(Number(pt(t.yAccessor,"y",o,i))))return;const n=ft(pt(t.xAccessor,"x",o,i)),r=e.get(n)??new Set;r.add(pt(t.lineBy,"series",o,i)+""),e.set(n,r)});const o=Array.from(e.values(),t=>t.size).sort((t,e)=>t-e);if(0===o.length)return[];const i=Math.floor(o.length/2),n={columns:o.length,median:o.length%2?o[i]:(o[i-1]+o[i])/2,max:o[o.length-1],contestedColumns:o.filter(t=>t>=2).length},r=2>n.max;return r||2>n.contestedColumns||2>n.median?[{code:r?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:r?"error":"warning",message:r?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...n}}]:[]}(o);n=Array.from(e).filter(yt)}catch{return void(t.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||t.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}t.semanticDiagnostics=n,t.semanticStatus=n.some(t=>"error"===t.severity)?"degenerate":n.some(t=>"warning"===t.severity)?"degraded":"meaningful";for(const e of n)t.warnings.includes(e.code)||t.warnings.push(e.code)}function mt(t,e,o){const i="function"==typeof e?e(t):t[(e??o)+""];if(null==i||"string"==typeof i&&""===i.trim())return null;const n=Number(i);return Number.isFinite(n)?n:null}function xt(t){if(!t)return Of;let e=!1;for(let o=0;t.length>o;o++){const i=t[o];if(null==i||"object"!=typeof i){e=!0;break}}if(!e)return t;const o=[];for(const e of t)null!=e&&"object"==typeof e&&o.push(e);return o}function bt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function vt(t,e,o){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(o)}`}function wt(t){const e=t.map(bt),o=e.length-1;return t=>{if(Number.isNaN(t)&&(t=0),0>=t){const[t,o,i]=e[0];return vt(t,o,i)}if(t>=1){const[t,i,n]=e[o];return vt(t,i,n)}const i=t*o,n=Math.floor(i),r=i-n,[s,a,c]=e[n],[l,u,d]=e[n+1];return vt(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(d-c)*r))}}function kt(t){return t&&Object.prototype.hasOwnProperty.call(Kf,t)?Kf[t]:Nf}function At(t,e,o=rp){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=Object.prototype.hasOwnProperty.call(np,t)?np[t]:void 0;if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:o}function St(t,e,o){if("function"==typeof e){const i=e(t);return o&&i&&"string"==typeof i&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||lp.has(e)}(i)?o(i):i}const i=t?.[e]+"";return o?o(i):rp[Math.abs(function(t){let e=0;for(let o=0;t.length>o;o++)e=(e<<5)-e+t.charCodeAt(o),e&=e;return Math.abs(e)}(i))%rp.length]}function Mt(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const o=t[e];return"string"==typeof o&&o.length>0?o:void 0}function _t(t,e,o="category10"){if(o&&"object"==typeof o&&!Array.isArray(o)){const t=o;return e=>Mt(t,e)??"#999"}const i=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),n=i.every(t=>!isNaN(Number(t)));if(Array.isArray(o))return(0,Ff.scaleOrdinal)().domain(i).range(o).unknown("#999");const r=Object.prototype.hasOwnProperty.call(np,o)?np[o]:np.category10;if(n&&"function"==typeof r){let t=-1/0;for(const e of i){const o=Number(e);o>t&&(t=o)}return e=>r(0===t?0:Number(e)/t)}{const t=Array.isArray(r)?r:rp;return(0,Ff.scaleOrdinal)().domain(i).range(t).unknown("#999")}}function $t(t,e,o=[3,20],i){let n;if(n="function"==typeof e?e(t):t?.[e],!i)return n;const[r,s]=i,[a,c]=o;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 Pt(t){return void 0!==t.stroke||void 0!==t.strokeWidth||void 0!==t.opacity}function jt(t,e){if(!Pt(e))return t??((...t)=>({}));const o={};return void 0!==e.stroke&&(o.stroke=e.stroke),void 0!==e.strokeWidth&&(o.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(o.opacity=e.opacity),t?(...e)=>({...t(...e)||{},...o}):(...t)=>({...o})}function It(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>Tt(e(t))}function Lt(t,e){const o=It(t),i=It(e);return(t,e)=>{const n=i(t);return{value:n,x:o(t),y:n,category:e}}}function Rt(t,e){const o=It(e??"value"),i=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=i?i(t):void 0;return{value:o(t),category:null==e?void 0:e+""}}}function Tt(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 Ct(t,e,o){const i=t.when;return void 0===i||!0===i||!1!==i&&("function"==typeof i?i(e,o):function(t,e,o){const i=null!=t.axis?o[t.axis]:null!=t.field?e[t.field]:o.value;if(void 0!==t.eq&&i!==t.eq)return!1;if(void 0!==t.ne&&i===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(i))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=Tt(i);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,o]=t.within;if(e>n||n>o)return!1}if(void 0!==t.outside){const[e,o]=t.outside;if(n>=e&&o>=n)return!1}return!0}(i,e,o))}function Ot(t,e,o){if(!e||0===e.length)return{};let i={};for(const n of e){if(!Ct(n,t,o))continue;const e="function"==typeof n.style?n.style(t,o):n.style;e&&(i={...i,...e})}return i}function Ft(t,e,o,i=t=>t){const n=t??(()=>({}));return e&&0!==e.length?(t,r)=>{const s=i(t),a={...n(t,r)};return Object.assign(a,Ot(s,e,o(s,r))),a}:n}function Dt(t,e,o,i){if(!t||0===t.length)return i;const n=Rt(e,o);return(e,o)=>{const r=e&&e.data||e,s=Ot(r,t,n(r)),a=i?i(e,o):void 0;return a?{...s,...a}:s}}function Nt(t){const{lineWidth:e=2,colorBy:o,colorScale:i,color:n,resolveStroke:r,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=t;return(t,u)=>{const d={strokeWidth:e},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return r?f=r(t,u):o?i&&(f=St(t,o,i)):f=n||sp,void 0!==f&&(d.stroke=f,h&&(d.fill=f,d.fillOpacity=a)),c?.length&&Object.assign(d,Ot(t,c,l?l(t,u):{value:void 0,category:u})),d}}function zt(t){if("A"===t.__diffWinner||"B"===t.__diffWinner)return t.__diffWinner;const e=(t.__diffSegment??"")+"";return"line-A"===e||e.endsWith("-A")?"A":"B"}function Et(t,e){return Ft(t,e,t=>{const e=Number(t.__x),o=Number(t.__y);return{value:Number.isFinite(o)?o:void 0,x:Number.isFinite(e)?e:void 0,y:Number.isFinite(o)?o:void 0,category:zt(t)}},t=>t.__sourceDatum?{...t.__sourceDatum,...t}:t)}function Bt(t){const{seriesAColor:e,seriesBColor:o,areaOpacity:i,styleRules:n}=t;return Et(t=>({fill:"A"===zt(t)?e:o,stroke:"none",fillOpacity:i}),n)}function Wt(t){const{seriesAColor:e,seriesBColor:o,lineWidth:i,styleRules:n}=t;return Et(t=>({stroke:"A"===zt(t)?e:o,strokeWidth:i,fill:"none"}),n)}function Yt(t,e=up){if(t)return!0===t?e:"stops"in t?Array.isArray(t.stops)?t:void 0:"colorStops"in t?Array.isArray(t.colorStops)?{stops:t.colorStops.map(({offset:t,color:e})=>({offset:t,color:e}))}:void 0:{stops:[{offset:0,opacity:t.topOpacity??e.stops[0]?.opacity??.8},{offset:1,opacity:t.bottomOpacity??e.stops.at(-1)?.opacity??.05}]}}function qt(t){return t?Yt(t):void 0}function Xt(t,e,o){return"function"==typeof t?t(o):o[t||e]}function Gt(t){return t instanceof Date?t.getTime():Number(t)}function Vt(t,e){return qf(1===e?.5:t/(e-1))}function Ht(t){const e={};return void 0!==t.stroke&&(e.stroke=t.stroke),void 0!==t.strokeWidth&&(e.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(e.opacity=t.opacity),e}function Ut(t,e){const o=function(t){if(!t)return;const e="boolean"==typeof t?{}:"string"==typeof t?{method:t}:t;return{type:"trend",method:e.method??"linear",...null!=e.bandwidth&&{bandwidth:e.bandwidth},...null!=e.order&&{order:e.order},...null!=e.color&&{color:e.color},...null!=e.strokeWidth&&{strokeWidth:e.strokeWidth},...null!=e.strokeDasharray&&{strokeDasharray:e.strokeDasharray},...null!=e.label&&{label:e.label}}}(e),i=Array.isArray(t)?t:void 0;return o?[o,...i??[]]:i}function Kt(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 Zt(t){if(!t)return hp;if("string"==typeof t){if("light"===t)return hp;if("dark"===t)return fp;if("high-contrast"===t)return pp;return(Object.prototype.hasOwnProperty.call(yp,e=t)?yp[e]:void 0)||hp}var e;const o="dark"===t.mode?fp:hp;return function(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:dp}}),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}({...o,...t,colors:{...o.colors,...t.colors||{}},typography:{...o.typography,...t.typography||{}},tooltip:{...o.tooltip,...t.tooltip||{}}})}function Qt(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,legendFontFamily:t.typography.legendFontFamily??t.typography.fontFamily,legendFontWeight:t.typography.legendFontWeight,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,titleFontFamily:t.typography.titleFontFamily??t.typography.fontFamily,titleFontWeight:t.typography.titleFontWeight??"bold",tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}function Jt(t){return t.axes??[{orient:"bottom",visible:!1!==t.showTimeAxis},{orient:"left",visible:!1!==t.showValueAxis}]}function te(t){let e=1/0,o=-1/0;for(const i of t)e>i&&(e=i),i>o&&(o=i);return[e,o]}function ee(t,e=-1/0){let o=e;for(const e of t)e>o&&(o=e);return o}function oe(t){const e=10**gp;return Math.round(t*e)/e}function ie(t,e=2){const o=[],i=[],n=e+1;for(let e=0;n>e;e++){let r=0;for(const[o,i]of t)null!==i&&(r+=o**e*i);o.push(r);const s=[];for(let o=0;n>o;o++){let i=0;for(const[n,r]of t)null!==r&&(i+=n**(e+o));s.push(i)}i.push(s)}i.push(o);const r=function(t,e){const o=t,i=t.length-1,n=[e];for(let t=0;i>t;t++){let e=t;for(let n=t+1;i>n;n++)Math.abs(o[t][n])>Math.abs(o[t][e])&&(e=n);for(let n=t;i+1>n;n++){const i=o[n][t];o[n][t]=o[n][e],o[n][e]=i}for(let e=t+1;i>e;e++)for(let n=i;n>=t;n--)o[n][e]-=o[n][t]*o[t][e]/o[t][t]}for(let t=i-1;t>=0;t--){let e=0;for(let r=t+1;i>r;r++)e+=o[r][t]*n[r];n[t]=(o[i][t]-e)/o[t][t]}return n}(i,n).map(oe);return{points:t.map(([t])=>[oe(t),oe(r.reduce((e,o,i)=>e+o*t**i,0))]),equation:[...r].reverse()}}function ne(t){const e=t.length;let o=0,i=0,n=0,r=0;for(const[e,s]of t)o+=e,i+=s,n+=e*e,r+=e*s;const s=e*n-o*o;if(1e-12>Math.abs(s))return null;const a=(e*r-o*i)/s,c=(i-a*o)/e;return t=>c+a*t}function re(t,e){const o=t.length,i=t.map(([t,o])=>o-e(t)).reduce((t,e)=>t+e*e,0),n=Math.sqrt(i/Math.max(o-2,1)),r=t.reduce((t,e)=>t+e[0],0)/o,s=t.reduce((t,e)=>t+(e[0]-r)**2,0);return{se:n,meanX:r,ssX:s}}function se(t){return.99>t?.95>t?.9>t?1:1.645:1.96:2.576}function ae(t,e,o,i){const n=e.uncertaintyOpacity,r=e.confidenceAccessor;if(!n&&!r)return;const s="object"==typeof n?n:{},a=s.min??.15,c=s.max??1;if(r){const e="function"==typeof r?r:t=>t[r];for(const o of t){const t=e(o);null!=t&&Number.isFinite(t)&&(o[xp]=a+Math.max(0,Math.min(1,t))*(c-a))}return}const l=t.map(t=>{const e=o(t),n=i(t);return null!=e&&null!=n&&Number.isFinite(e)&&Number.isFinite(n)?Math.abs(e-n):NaN}),u=l.filter(t=>Number.isFinite(t));if(0===u.length)return;const[d,h]=te(u),f=h-d;t.forEach((t,e)=>{const o=l[e];Number.isFinite(o)&&(t[xp]=c-(f>0?(o-d)/f:0)*(c-a))})}function ce(t,e){return"function"==typeof e?e(t):!!t[e]}function le(t,e,o){const i=t[e],n=t[o];return null==i||null==n||Number.isNaN(i)||Number.isNaN(n)}function ue(t){const e=t.xAccessor||"x",o=t.yAccessor||"y",i=t.lineBy,n=t.colorBy||i;let r=Array.isArray(t.data)?xt(t.data).filter(t=>!!t&&"object"==typeof t):[];const s=function(t,e,o){const i="function"==typeof e,n="function"==typeof o,r=i?bp:e,s=n?vp:o;return i||n?{xKey:r,yKey:s,rows:t.map(t=>{const r={...t};return i&&(r[bp]=e(t)),n&&(r[vp]=o(t)),r})}:{rows:t,xKey:r,yKey:s}}(r,e,o);r=s.rows;const a=s.xKey,c=s.yKey,l=Array.isArray(t.annotations)?[...t.annotations]:[];let u,d="string"==typeof i||"function"==typeof i?i:void 0,h=t.baseLineStyle;if(t.forecast){const e=function(t,e,o,i,n){return(r=i).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(t,e,o,i,n){const{isTraining:r,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=i,y=t.map(t=>{let e="observed";return s&&ce(t,s)?e="forecast":r&&ce(t,r)&&(e="training"),{...t,[mp]:e}}),g=i._groupBy,m=[];if(g){const t=new Map;for(const e of y){const o=e[g]??"__default";t.has(o)||t.set(o,[]),t.get(o).push(e)}const e=[];for(const[,o]of t)for(let t=0;o.length-1>t;t++)o[t][mp]!==o[t+1][mp]&&(e.push({...o[t+1],[mp]:o[t][mp]}),e.push({...o[t],[mp]:o[t+1][mp]}));m.push(...y,...e)}else for(let t=0;y.length>t;t++)m.push(y[t]),y.length-1>t&&y[t][mp]!==y[t+1][mp]&&(m.push({...y[t+1],[mp]:y[t][mp]}),m.push({...y[t],[mp]:y[t+1][mp]}));if(i.trainUnderline){const t=[];for(const e of m)"training"===e[mp]&&t.push({...e,[mp]:"training-base"});m.unshift(...t)}const x=[];if(c&&l){const t="string"==typeof c?c:"__envUpper",e="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const o of m)"function"==typeof c&&(o[t]=c(o)),"function"==typeof l&&(o[e]=l(o));x.push({type:"envelope",upperAccessor:t,lowerAccessor:e,fill:u,fillOpacity:d,label:p})}if(i.uncertaintyOpacity||i.confidenceAccessor){const t=c?"function"==typeof c?c:t=>t[c]:()=>{},e=l?"function"==typeof l?l:t=>t[l]:()=>{};ae(m.filter(t=>"forecast"===t[mp]),i,t,e)}if(a){const t=i.anomalyStyle,e={type:"highlight",filter:t=>ce(t,a)};t?(e.style=t,e.r=f):"function"==typeof h?(e.style=t=>{const e=h(t);return{stroke:e,strokeWidth:1.5,fill:e,fillOpacity:.7}},e.r=f):(e.color=h,e.r=f,e.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(e)}return n&&x.push({type:"anomaly-band",threshold:n.threshold??2,showBand:!1!==n.showBand,fill:n.bandColor||"#6366f1",fillOpacity:n.bandOpacity??.1,anomalyColor:n.anomalyColor||"#ef4444",anomalyRadius:n.anomalyRadius??6,label:n.label}),{processedData:m,annotations:x}}(t,0,0,i,n):function(t,e,o,i,n){const{trainEnd:r,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=i;if(null==r)return{processedData:t,annotations:[]};const d=[],h=[];for(const o of t)o[e]>r?h.push({...o,[mp]:"observed"}):d.push({...o,[mp]:"training"});const f=d.map(t=>[t[e],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]),p=[],y=[];if(f.length>=3){const n=f.length,r=ne(f);if(r){const{se:d,meanX:h,ssX:g}=re(f,r),m=se(a),x=ee(t.map(t=>t[e]).filter(t=>null!=t&&isFinite(t))),b=f.length>1?(f[n-1][0]-f[0][0])/(n-1):1;for(let t=1;s>=t;t++){const i=x+t*b,s=r(i),a=d*Math.sqrt(1+1/n+(g>0?(i-h)**2/g:0))*m;y.push({[e]:i,[o]:s,[mp]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}ae(y,i,t=>t.__forecastUpper,t=>t.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}p.push({type:"x-threshold",x:r,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),n&&p.push({type:"anomaly-band",threshold:n.threshold??2,showBand:!1!==n.showBand,fill:n.bandColor||"#6366f1",fillOpacity:n.bandOpacity??.1,anomalyColor:n.anomalyColor||"#ef4444",anomalyRadius:n.anomalyRadius??6,label:n.label});const g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[mp]:"observed"}),g.push(...h),y.length>0){const t=h.length>0?h[h.length-1]:d[d.length-1];t&&g.push({...t,[mp]:"forecast"}),g.push(...y)}return{processedData:g,annotations:p}}(t,e,o,i,n);var r}(r,a,c,i&&"string"==typeof i&&"object"==typeof t.forecast?{...t.forecast,_groupBy:i}:t.forecast,t.anomaly);if(r=e.processedData,l.push(...e.annotations),u=function(t,e,o){const i=o.upperBounds,n=o.lowerBounds;if(!i&&!n)return;const r="function"==typeof i?i:"string"==typeof i?t=>t[i]:null,s="function"==typeof n?n:"string"==typeof n?t=>t[n]:null;let a=1/0,c=-1/0;for(const o of t){const t=Number(o[e]);if(Number.isFinite(t)&&(a>t&&(a=t),t>c&&(c=t)),r){const t=r(o);null!=t&&Number.isFinite(t)&&(t>c&&(c=t),a>t&&(a=t))}if(s){const t=s(o);null!=t&&Number.isFinite(t)&&(a>t&&(a=t),t>c&&(c=t))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}(r,c,t.forecast),i&&"string"==typeof i?(r=r.map(t=>({...t,[wp]:`${t[i]}__${t[mp]||"observed"}`})),d=wp):d=mp,t.baseLineStyle){const e=function(t,e){const o=e.trainDasharray??"8,4",i=e.forecastDasharray??"4,4",n=e.color||"#6366f1",r=e.trainOpacity,s=e.forecastOpacity,a=e.trainStroke,c=e.trainLinecap,l=e.trainUnderline;return e=>{const u=t(e),d=e[mp];if("training"===d){let t=u.stroke;return"darken"===a?t=function(t,e=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const i=Math.round(parseInt(o[1],16)*(1-e)),n=Math.round(parseInt(o[2],16)*(1-e)),r=Math.round(parseInt(o[3],16)*(1-e));return`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):a&&(t=a),{...u,stroke:t,strokeDasharray:o,...c&&{strokeLinecap:c},...null!=r&&{strokeOpacity:r}}}if("training-base"===d){let t=u.stroke||"#666";return"lighten"===l&&(t=function(t,e=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const i=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*e),n=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*e),r=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*e);return`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}(t,.4)),{...u,stroke:t,strokeDasharray:void 0}}if("forecast"===d){const t=e[xp],o=null!=t?t:s;return{...u,stroke:n,strokeDasharray:i,...null!=o&&{strokeOpacity:o}}}return u}}(e=>t.baseLineStyle(e),t.forecast);h=t=>e(t)}}else t.anomaly&&l.push(...(f=t.anomaly,[{type:"anomaly-band",threshold:f.threshold??2,showBand:!1!==f.showBand,fill:f.bandColor||"#6366f1",fillOpacity:f.bandOpacity??.1,anomalyColor:f.anomalyColor||"#ef4444",anomalyRadius:f.anomalyRadius??6,label:f.label}]));var f;if(t.gapStrategy){if("function"==typeof d){const t=d;r=r.map(e=>({...e,__semiotic_gapGroup:t(e)})),d="__semiotic_gapGroup"}const e=function(t,e,o,i,n){const r=new Map;for(const e of t){const t=n?(e[n]??"")+"":"__single";r.has(t)||r.set(t,[]),r.get(t).push(e)}if("interpolate"===e){const t=[];for(const[,e]of r)for(const n of e)le(n,o,i)||t.push(n);return{rows:t,groupKey:n}}if("zero"===e){const t=[];for(const[,e]of r)for(const n of e)le(n,o,i)?t.push({...n,[i]:0}):t.push(n);return{rows:t,groupKey:n}}const s=[],a="_gapSegment";for(const[t,e]of r){let n=0,r=[];const c=()=>{if(0===r.length)return;const e="__single"===t?"__seg"+n:`${t}__seg${n}`;for(const t of r)s.push({...t,[a]:e});r=[],n++};for(const t of e)le(t,o,i)?c():r.push(t);c()}return{rows:s,groupKey:a}}(r,t.gapStrategy,a,c,"string"==typeof d?d:void 0);r=e.rows,e.groupKey&&(d=e.groupKey)}let p;if(t.directLabel){const e=function(t,e,o,i,n,r,s,a){if(!e||!o)return{annotations:[]};const c="object"==typeof e?e:{},l=c.position||"end",u=c.fontSize||11,d="function"==typeof o?o:t=>t[o],h=new Map;for(const e of t){const t=d(e);if(null==t)continue;const o=t+"";""!==o&&(h.has(o)||h.set(o,[]),h.get(o).push(e))}const f=new Map;for(const[t,e]of h)e.sort((t,e)=>Number(t[i])-Number(e[i])),f.set(t,"end"===l?e[e.length-1]:e[0]);const p=_t(Array.from(f.entries()).map(([t])=>({__lbl:t})),"__lbl",r??s),y=Array.from(f.entries()).map(([t,e])=>({type:"text",label:t,[i]:e[i],[n]:e[n],dx:"end"===l?6:-6,dy:0,color:p?St({__lbl:t},"__lbl",p):a||sp,fontSize:u}));y.sort((t,e)=>Number(t[n])-Number(e[n]));for(let t=1;y.length>t;t++){const e=y[t-1],o=y[t],i=Number(e[n])+e.dy;u+2>Math.abs(Number(o[n])+o.dy-i)&&(o.dy+=u+2)}const g=y.reduce((t,e)=>Math.max(t,(e.label+"").length*(.6*u)),0)+10;return{annotations:y,marginExtra:"end"===l?{right:g}:{left:g}}}(r,t.directLabel,"string"==typeof n||"function"==typeof n?n:void 0,a,c,t.colorScheme,t.themeCategorical,t.color);l.push(...e.annotations),p=e.marginExtra}return{data:r,xAccessor:"function"==typeof e?a:e,yAccessor:"function"==typeof o?c:o,groupAccessor:d,colorAccessor:n,annotations:l,lineStyle:h,yExtent:u,marginExtra:p}}function de(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Zt(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrScatterColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrScatterColorBy:e(t)})):r,u=e?_t(l,c,a):void 0,d=n.sizeBy,h=Array.isArray(n.sizeRange)?n.sizeRange:[3,15],f=d?r.map(t=>"function"==typeof d?d(t):Number(t[d])).filter(Number.isFinite):[],p=f.length?te(f):void 0,y=Lt(n.xAccessor,n.yAccessor),g=n.styleRules;return t=>{const o={fill:e&&u?St(t,e,u):"string"==typeof n.color?n.color:sp,fillOpacity:"number"==typeof n.pointOpacity?n.pointOpacity:.8,r:d?$t(t,d,h,p):"number"==typeof n.pointRadius?n.pointRadius:5};return g?.length&&Object.assign(o,Ot(t,g,y(t))),void 0!==n.stroke&&(o.stroke=n.stroke),void 0!==n.strokeWidth&&(o.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(o.opacity=n.opacity),o}}function he(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Zt(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrBubbleColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrBubbleColorBy:e(t)})):r,u=e?_t(l,c,a):void 0,d=n.sizeBy,h=Array.isArray(n.sizeRange)?n.sizeRange:[5,40],f=d?r.map(t=>"function"==typeof d?d(t):Number(t[d])).filter(Number.isFinite):[],p=f.length?te(f):void 0,y=Lt(n.xAccessor,n.yAccessor),g=n.styleRules;return t=>{const o={fill:e&&u?St(t,e,u):"string"==typeof n.color?n.color:sp,fillOpacity:"number"==typeof n.bubbleOpacity?n.bubbleOpacity:.6,r:d?$t(t,d,h,p):h[0],stroke:n.bubbleStrokeColor??"white",strokeWidth:n.bubbleStrokeWidth??1};return g?.length&&Object.assign(o,Ot(t,g,y(t))),void 0!==n.stroke&&(o.stroke=n.stroke),void 0!==n.strokeWidth&&(o.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(o.opacity=n.opacity),o}}function fe(t,e){return e?.length?(Object.defineProperty(t,Sp,{configurable:!0,enumerable:!1,value:e}),t):t}function pe(t){return t?.[Sp]}function ye(t){return t.parentLine?fe({...t.parentLine,...t},pe(t)):t}function ge(t){return fe({...t[0]},t.map(ye))}function me(t){return!!t&&pe(t)?.[0]===t}function xe(t){const e={"--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-cell-border":t.colors.cellBorder||t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily,"--semiotic-secondary":t.colors.secondary||t.colors.primary,"--semiotic-surface":t.colors.surface||t.colors.background};t.colors.categorical.forEach((t,o)=>{e["--semiotic-category-"+(o+1)]=t}),t.colors.focus&&(e["--semiotic-focus"]=t.colors.focus),t.colors.selection&&(e["--semiotic-selection-color"]=t.colors.selection),null!=t.colors.selectionOpacity&&(e["--semiotic-selection-opacity"]=t.colors.selectionOpacity+""),t.colors.diverging&&(e["--semiotic-diverging"]=t.colors.diverging),t.colors.annotation&&(e["--semiotic-annotation-color"]=t.colors.annotation),t.colors.success&&(e["--semiotic-success"]=t.colors.success),t.colors.danger&&(e["--semiotic-danger"]=t.colors.danger),t.colors.warning&&(e["--semiotic-warning"]=t.colors.warning),t.colors.error&&(e["--semiotic-error"]=t.colors.error),t.colors.info&&(e["--semiotic-info"]=t.colors.info),t.tooltip?.background&&(e["--semiotic-tooltip-bg"]=t.tooltip.background),t.tooltip?.text&&(e["--semiotic-tooltip-text"]=t.tooltip.text),t.tooltip?.borderRadius&&(e["--semiotic-tooltip-radius"]=t.tooltip.borderRadius),t.tooltip?.fontSize&&(e["--semiotic-tooltip-font-size"]=t.tooltip.fontSize),t.tooltip?.shadow&&(e["--semiotic-tooltip-shadow"]=t.tooltip.shadow),t.borderRadius&&(e["--semiotic-border-radius"]=t.borderRadius);const o=t.typography.legendSize??t.typography.labelSize;null!=o&&(e["--semiotic-legend-font-size"]=o+"px"),null!=t.typography.legendFontFamily&&(e["--semiotic-legend-font-family"]=t.typography.legendFontFamily),null!=t.typography.legendFontWeight&&(e["--semiotic-legend-font-weight"]=t.typography.legendFontWeight+"");const i=t.typography.titleFontSize??t.typography.titleSize;return null!=i&&(e["--semiotic-title-font-size"]=i+"px"),null!=t.typography.titleFontFamily&&(e["--semiotic-title-font-family"]=t.typography.titleFontFamily),null!=t.typography.titleFontWeight&&(e["--semiotic-title-font-weight"]=t.typography.titleFontWeight+""),null!=t.typography.tickFontFamily&&(e["--semiotic-tick-font-family"]=t.typography.tickFontFamily),null!=t.typography.tickSize&&(e["--semiotic-tick-font-size"]=t.typography.tickSize+"px"),null!=t.typography.labelSize&&(e["--semiotic-axis-label-font-size"]=t.typography.labelSize+"px"),e}function be(t,e,o,i,n){if(t)return t;if(o&&"object"==typeof o&&!Array.isArray(o)){const t=Mt(o,i);if(t)return t}let r;if(Array.isArray(o))r=o;else if(e&&e.length>0)r=e;else if("string"==typeof o){const t=np[o];Array.isArray(t)&&(r=t)}return r&&0!==r.length?null!=i?(n.has(i)||n.set(i,n.size),r[n.get(i)%r.length]):r[0]:sp}function ve(t,e,o){return"function"==typeof t?t(e,o):e[t]}function we(t,e){if(!t?.length)return;const o=new Map(e.map((t,e)=>[ft(t),e]));return t.map(t=>{const e={...t},i=i=>{if(!(i in t))return;const n=o.get(ft(t[i]));void 0!==n&&(e[i]=n)};return i("x"),i("x0"),i("x1"),"string"!=typeof t.type||"x-threshold"!==t.type&&"x"!==t.type||i("value"),e})}function ke(t,e,o,i,n){const r=1-n;return r*r*r*t+3*r*r*n*e+3*r*n*n*o+n*n*n*i}function Ae(t,e,o,i,n){const r=1-n;return 3*r*r*(e-t)+6*r*n*(o-e)+3*n*n*(i-o)}function Se(t,e,o,i,n){const r=[],s=(t.x+e.x)/2;for(let a=0;n>=a;a++){const c=a/n;let l,u,d,h;"linear"===i?(l=t.x+(e.x-t.x)*c,u=t.y+(e.y-t.y)*c,d=e.x-t.x,h=e.y-t.y):(l=ke(t.x,s,s,e.x,c),u=ke(t.y,t.y,e.y,e.y,c),d=Ae(t.x,s,s,e.x,c),h=Ae(t.y,t.y,e.y,e.y,c)),r.push({x:l,y:u,dx:d,dy:h,radius:t.radius+(e.radius-t.radius)*c,datumIndex:.5>c?o:o+1})}return r}function Me(t,e={}){const o=[],i=[],n=[];if(2>t.length)return{topPath:o,bottomPath:i,datumIndices:n};const r=e.curve??"smooth",s=Math.max(2,Math.floor(e.samplesPerSegment??12));for(let e=0;t.length-1>e;e++){const a=Se(t[e],t[e+1],e,r,s);for(let t=0===e?0:1;a.length>t;t++){const e=a[t],r=Math.hypot(e.dx,e.dy)||1,s=-e.dy/r,c=e.dx/r,l=Math.max(0,e.radius);o.push([e.x+s*l,e.y+c*l]),i.push([e.x-s*l,e.y-c*l]),n.push(e.datumIndex)}}return{topPath:o,bottomPath:i,datumIndices:n}}function _e({datum:t,x:e,y:o,side:i,color:n,highlighted:r,labelStyle:s}){const a=function(){const t=(qh??(qh=Mp.createContext(null)),qh);return Mp.useContext(t)??_p}(),c=a.isActive&&!a.predicate(t),l="function"==typeof s?s(t.__bumpRaw):s;return(0,$p.jsx)("text",{className:"semiotic-bump-label",x:e+("end"===i?8:-8),y:o,dy:"0.35em",textAnchor:"end"===i?"start":"end",fill:n,fillOpacity:c?.16:1,fontWeight:r?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...l},children:t.__bumpSeries})}function $e(t,e,o){const[i,n]=e,[r,s]=o;return n===i?(r+s)/2:r+(s-r)*Math.max(0,Math.min(1,(t-i)/(n-i)))}function Pe(t){const e=t.__bumpXValue instanceof Date?t.__bumpXValue.getTime():Number(t.__bumpXValue);return{value:t.__bumpValue,x:Number.isFinite(e)?e:void 0,y:t.__bumpValue,category:t.__bumpSeries}}function je(t){const e=t.config,o=new Map;for(const e of t.data){const t=o.get(e.__bumpSeries)??[];t.push(e),o.set(e.__bumpSeries,t)}const i=e.seriesOrder.filter(t=>o.has(t)).sort((t,i)=>(o.get(t)?.[0]?.__bumpHighlighted?1:0)-(o.get(i)?.[0]?.__bumpHighlighted?1:0)||e.seriesOrder.indexOf(t)-e.seriesOrder.indexOf(i)),n=[],r=[],s=[];for(const r of i){const i=(o.get(r)??[]).sort((t,e)=>t.x-e.x);if(2>i.length)continue;const a=i[0].__bumpHighlighted,c=(e.colorMap&&Mt(e.colorMap,r))??t.resolveColor(i[0].__bumpSeries,i[0]),l=e.color??(a?c:e.neutralColor??t.theme.semantic.textSecondary??t.theme.semantic.border??c),u=i.map(o=>({x:t.scales.x(o.x),y:t.scales.y(o.y),radius:e.ribbon?$e(o.__bumpValue,e.valueExtent,e.ribbonSizeRange)/2:Math.max(.5,e.lineWidth/2)})),d=Me(u,{curve:e.curve,samplesPerSegment:e.samplesPerSegment}),h={fill:l,fillOpacity:1,opacity:a?e.ribbon?e.ribbonOpacity:e.lineOpacity:Math.min(e.ribbon?e.ribbonOpacity:e.lineOpacity,.58)};e.styleRules?.length&&Object.assign(h,Ot(i[0].__bumpRaw,e.styleRules,Pe(i[0]))),e.areaStyle&&Object.assign(h,e.areaStyle(i[0].__bumpRaw)??{}),void 0!==e.stroke&&(h.stroke=e.stroke),void 0!==e.strokeWidth&&(h.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(h.opacity=e.opacity),n.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(t=>i[t]),accessibleDatum:i.map(t=>t.__bumpRaw),accessibility:{label:r+" ranking trajectory",tableFields:i.map(t=>t.__bumpRaw)},group:r,interactive:!0}),e.showPoints&&i.forEach((t,o)=>{const i={fill:l,stroke:"none",opacity:a?1:.75};e.styleRules?.length&&Object.assign(i,Ot(t.__bumpRaw,e.styleRules,Pe(t))),e.pointStyle&&Object.assign(i,e.pointStyle(t.__bumpRaw)??{}),void 0!==e.stroke&&(i.stroke=e.stroke),void 0!==e.strokeWidth&&(i.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(i.opacity=e.opacity),n.push({type:"point",x:u[o].x,y:u[o].y,r:i.r??e.pointRadius,style:i,datum:t,accessibleDatum:t.__bumpRaw,accessibility:{label:`${r}, rank ${t.__bumpRank}, value ${t.__bumpValue}`},pointId:`${r}:${t.x}`})});const f=!0===e.showLabels?"end":e.showLabels,p=(t,o,i)=>{const n=null==e.labelPriorityAccessor?void 0:"function"==typeof e.labelPriorityAccessor?e.labelPriorityAccessor(t.__bumpRaw):Number(t.__bumpRaw[e.labelPriorityAccessor]);s.push({id:`${r}\0${i}`,datum:t,x:u[o].x,y:u[o].y,side:i,rank:t.__bumpRank,highlighted:a,priority:Number.isFinite(n)?n:void 0,color:"string"==typeof h.fill?h.fill:l})};"start"!==f&&"both"!==f||p(i[0],0,"start"),"end"!==f&&"both"!==f&&"auto"!==f||p(i.at(-1),i.length-1,"end")}const a=function(t,e,o,i){const n=Math.max(1,Math.floor(e/18)),r="auto"===o?Number.isFinite(i)&&(i??0)>=0?Math.min(n,Math.floor(i)):n:1/0,s=t.map((t,e)=>({candidate:t,index:e})).sort((t,e)=>(e.candidate.priority??0)-(t.candidate.priority??0)||Number(e.candidate.highlighted)-Number(t.candidate.highlighted)||t.candidate.rank-e.candidate.rank||t.index-e.index),a=[];for(const{candidate:t}of s){if(a.length>=r)break;a.some(e=>e.side===t.side&&14>Math.abs(e.y-t.y))||a.push(t)}return new Set(a.map(t=>t.id))}(s,t.dimensions.plot.height,"auto"!==(!0===e.showLabels?"end":e.showLabels)||"auto",e.maxLabels);for(const t of s)a.has(t.id)&&r.push((0,$p.jsx)(_e,{datum:t.datum,x:t.x,y:t.y,side:t.side,color:t.color,highlighted:t.highlighted,labelStyle:e.labelStyle},t.id));return{nodes:n,overlays:r.length?(0,$p.jsx)("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(t,e)=>{const o=function(t){const e=Array.isArray(t.datum)?t.datum[0]:t.datum;return e&&"object"==typeof e&&"__bumpSeries"in e?e:void 0}(t);if(e?.isActive&&o&&!e.predicate(o))return{opacity:.14}}}}function Ie(t,e){const o=It(t),i=e.map((t,e)=>({label:t.label||"Series "+(e+1),readY:It(t.yAccessor)}));return(t,e)=>{const n=(t[Ip]??e??"")+"",r=i.find(t=>t.label===n)??i[0],s=r?.readY(t);return{value:s,x:o(t),y:s,category:n||void 0}}}function Le(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Zt(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrAreaColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrAreaColorBy:e(t)})):r,u=e?_t(l,c,a):void 0,d=!1!==n.showLine,h="number"==typeof n.lineWidth?n.lineWidth:2,f="number"==typeof n.areaOpacity?n.areaOpacity:.7,p=It(n.yAccessor),y=n.styleRules;return(t,o)=>{const i=e&&u?St(t,e,u):"string"==typeof n.color?n.color:sp,r={fill:i,fillOpacity:f,stroke:d?i:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(r,Ot(t,y,{value:p(t),category:o})),void 0!==n.stroke&&(r.stroke=n.stroke),void 0!==n.strokeWidth&&(r.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(r.opacity=n.opacity),r}}function Re(t,e,o,i,n){if(!n.showPoints)return;const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Zt(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrPointColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrPointColorBy:e(t)})):r,u=e?_t(l,c,a):void 0,d="number"==typeof n.pointRadius?n.pointRadius:3;return t=>{const o=e&&u?St(t,e,u):"string"==typeof n.color?n.color:sp;return{r:d,fill:o,stroke:"none"}}}function Te(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function Ce(t,e){if("function"==typeof t)return t;const o=t||e;return t=>t[o]}function Oe(t){return Math.max(0,Math.min(1,t))}function Fe(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 o=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const t=[Number(o[1]),Number(o[2]),Number(o[3])];if(t.every(Number.isFinite))return t}return null}function De(t,e,o){const i=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(o)}`}function Ne(t,e,o){const i=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Oe(t.offset),color:t.color??o,opacity:null==t.opacity?1:Oe(t.opacity)})).sort((t,e)=>t.offset-e.offset);if(0===i.length)return"#999999";const n=t=>{if(1===t.opacity)return t.color;const e=Fe(t.color);return e?`rgba(${e[0]},${e[1]},${e[2]},${t.opacity})`:t.color};if(1===i.length)return n(i[0]);const r=Oe(e);if(i[0].offset>=r)return n(i[0]);if(r>=i[i.length-1].offset)return n(i[i.length-1]);for(let t=0;i.length-1>t;t++){const e=i[t],o=i[t+1];if(e.offset>r||r>o.offset)continue;const s=o.offset-e.offset,a=s>0?(r-e.offset)/s:0,c=Fe(e.color),l=Fe(o.color);if(!c||!l)return n(.5>a?e:o);const[u,d,h]=c,[f,p,y]=l,g=u+(f-u)*a,m=d+(p-d)*a,x=h+(y-h)*a,b=e.opacity+(o.opacity-e.opacity)*a;return 1===b?De(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return n(i[i.length-1])}function ze(t,e,o){return null==o?`${t}-${e}`:`${t}-${e}-${o}`}function Ee(t=240){const e=360-t,o=180+e/2,i=o*Math.PI/180;return{sweepRad:t*Math.PI/180,gapDeg:e,startAngleDeg:o,startAngleRad:i,offsetRad:-Math.PI/2+i}}function Be(t){return Yt(t)}function We(t,e,o,i,n,r){const s=Zt(i.theme).colors.categorical,a=o??i.colorScheme,c=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],l="string"==typeof e?e:"__ssrColorBy",u="function"==typeof e?c.map(t=>({...t,__ssrColorBy:e(t)})):c,d=e?_t(u,l,a??s):void 0,h=be("string"==typeof n.color?n.color:void 0,s,a,void 0,new Map),f=r??It(n.valueAccessor??"value"),p=n.styleRules,y=i.pieceStyle;return(t,o)=>{const i={fill:e&&d?St(t,e,d):h};return p?.length&&Object.assign(i,Ot(t,p,{value:f(t,o),category:o})),"function"==typeof y?Object.assign(i,y(t,o)||{}):y&&"object"==typeof y&&Object.assign(i,y),void 0!==n.stroke&&(i.stroke=n.stroke),void 0!==n.strokeWidth&&(i.strokeWidth=n.strokeWidth),void 0!==n.opacity&&(i.opacity=n.opacity),i}}function Ye(t,e,o,i,n,r="median",s=.8){const a=It(n.valueAccessor??"value"),c=We(t,e,o,i,n,t=>"number"==typeof t[r]?t[r]:a(t));return(t,e)=>{const o=c(t,e);return void 0===o.fillOpacity&&(o.fillOpacity=s),void 0===o.stroke&&(o.stroke=o.fill),o}}function qe(t,e,o,i,n){return Ye(t,e,o,i,n,"median",.6)}function Xe(t,e,o,i,n){const r=We(t,e,o,i,n),s="number"==typeof n.dotRadius?n.dotRadius:5;return(t,e)=>({r:s,fillOpacity:.8,...r(t,e)})}function Ge(t,e,o,i,n){const r=We(t,e,o,i,n),s=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],a=n.sizeBy,c=Array.isArray(n.sizeRange)?n.sizeRange:[3,8],l=a?s.map(t=>"function"==typeof a?a(t):Number(t[a])).filter(Number.isFinite):[],u=l.length?te(l):void 0,d="number"==typeof n.pointRadius?n.pointRadius:4,h="number"==typeof n.pointOpacity?n.pointOpacity:.7;return(t,e)=>({r:a?$t(t,a,c,u):d,fillOpacity:h,...r(t,e)})}function Ve(t="static"){return uy[t]??uy.static}function He(t){return"fatal"===t.severity||"warn"===t.severity?t.severity:dy.has(t.kind)?"fatal":"warn"}function Ue(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`:"duplicate-node"===t.kind?`node id "${t.id}" is duplicated`:"duplicate-edge"===t.kind?`edge id "${t.id}" is duplicated`:"invalid-system-time"===t.kind?`edge ${t.id} has an invalid systemInTime or systemOutTime`:t.kind}function Ke(t){const{desired:e,minGaps:o,weights:i}=t,n=e.length;if(0===n)return[];if(o.length!==Math.max(0,n-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const r=Array(n).fill(0);for(let t=1;n>t;t++)r[t]=r[t-1]+Math.max(0,Number.isFinite(o[t-1])?o[t-1]:0);const s=[];for(let t=0;n>t;t++){const o=Math.max(Number.EPSILON,Number.isFinite(i?.[t])?i[t]:1),n=(Number.isFinite(e[t])?e[t]:0)-r[t];for(s.push({start:t,end:t,weight:o,mean:n});s.length>1;){const t=s[s.length-1],e=s[s.length-2];if(t.mean>=e.mean)break;const o=e.weight+t.weight;s.splice(s.length-2,2,{start:e.start,end:t.end,weight:o,mean:(e.mean*e.weight+t.mean*t.weight)/o})}}const a=Number.isFinite(t.min)?t.min:-1/0,c=Number.isFinite(t.max)?t.max-r[n-1]:1/0,l=a>c?a:c,u=Array(n);for(const t of s){const e=Math.max(a,Math.min(l,t.mean));for(let o=t.start;t.end>=o;o++)u[o]=e+r[o]}return u}function Ze(t,e){let o=0,i=t.length-1,n=-1;for(;i>=o;){const r=o+i>>>1;t[r].at>e?i=r-1:(n=r,o=r+1)}return 0>n?{at:e,before:0,after:0}:t[n]}function Qe(t,e=0){if(0===t.length)return{adjacentClearance:[],positions:[]};const o=[],i=[0];for(let n=0;t.length-1>n;n++){const r=t[n],s=t[n+1],a=[...new Set([...r.map(t=>t.at),...s.map(t=>t.at)])].sort((t,e)=>t-e);let c=0;for(const t of a){const e=Ze(r,t),o=Ze(s,t);c=Math.max(c,e.after+o.before)}o.push(c),i.push(i[i.length-1]+c+e)}return{adjacentClearance:o,positions:i}}function Je(t,e,o,i={}){let n=[...t];if(1>=n.length)return n;let r=[...n],s=o(n),a=1;const c=Math.max(0,i.passes??6),l=Math.max(1,i.maxEvaluations??1/0);for(let t=0;c>t&&l>a;t++){const t=new Map(n.map((t,e)=>[t,e])),c=new Map,l=new Map;for(const o of e){const e=t.get(o.source),i=t.get(o.target);if(null==e||null==i)continue;const n=Number.isFinite(o.weight)&&o.weight>0?o.weight:1;c.set(o.source,(c.get(o.source)??0)+i*n),l.set(o.source,(l.get(o.source)??0)+n),c.set(o.target,(c.get(o.target)??0)+e*n),l.set(o.target,(l.get(o.target)??0)+n)}n=n.map((t,e)=>({item:t,index:e,barycenter:(c.get(t)??e)/(l.get(t)??1)})).sort((t,e)=>t.barycenter-e.barycenter||(i.compare?.(t.item,e.item)??t.index-e.index)).map(t=>t.item);const u=o(n);if(a++,s>u)s=u,r=[...n];else if(u===s)break}return r}function to(t,e,o={}){const i=[...t],n=i.length;if(1>=n||n>(o.maxItems??8))return i;const r=Math.max(1,o.maxEvaluations??1/0);let s=0,a=[...i],c=1/0;const l=()=>{if(s>=r)return;const t=e(i);s++,c>t&&(c=t,a=[...i])};l();const u=Array(n).fill(0);let d=0;for(;n>d&&r>s;)if(d>u[d]){const t=d%2==0?0:u[d];[i[t],i[d]]=[i[d],i[t]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function eo(){return Object.create(null)}function oo(t,e){return e>t?-1:t>e?1:0}function io(t){return t.occupants.map(t=>t.id).sort(oo).join("\0")}function no(t,e,o=0){return t.slice(0,-1).map((i,n)=>null!=i.group&&i.group===t[n+1].group?o:e)}function ro(t,e){return t.map(t=>{const o=new Map;for(const i of t.occupants){const t=e[i.id];if(t)for(const e of t.samples){const t=o.get(e.t)??{before:0,after:0},i=e.boundaryOffset??0;o.set(e.t,{before:Math.max(t.before,e.topMass-i),after:Math.max(t.after,e.botMass+i)})}}return[...o].sort((t,e)=>t[0]-e[0]).map(([t,e])=>({at:t,...e}))})}function so(t,e,o){if(0===t.length)return[];const{padding:i,plotH:n,valueScale:r}=o,s=o.stackValueScale??r,a=no(t,i,o.groupPadding??0),c=[i+t[0].peak.topPeak*s];for(let o=1;t.length>o;o++)c.push(c[o-1]+e[o-1]*s+a[o-1]);const l=c[c.length-1]+t[t.length-1].peak.botPeak*s+i;if(l>n&&l>0){const t=n/l;for(let e=0;c.length>e;e++)c[e]*=t}return c}function ao(t,e){const o=(t.boundaryOffset??0)*e,i=t.value*e;if("out"===t.kind){const n=t.sideMassBefore*e;return o+("top"===t.side?i/2-n:n-i/2)}const n=t.sideMassAfter*e;return o+("top"===t.side?i/2-n:n-i/2)}function co(t,e,o,i,n,r){const s=r.adjacentClearance?[...r.adjacentClearance]:Qe(ro(i,o)).adjacentClearance,a=so(i,s,r);let c="hug"===r.lanePlacement?function(t,e,o,i,n,r,s){const a=t.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=no(t,c,s.groupPadding??0),h=n.map((t,e)=>t*u+d[e]),f=c+t[0].peak.topPeak*u,p=l-c-t[a-1].peak.botPeak*u;if(h.reduce((t,e)=>t+e,0)+1e-6>=p-f)return so(t,n,s);let y=1===a?[(f+p)/2]:[...r];for(let t=0;12>t;t++){const t=Array(a).fill(0),n=Array(a).fill(0);for(const r of o){const o=e[r.source],s=e[r.target];if(null==o||null==s||o===s)continue;const a=i[r.source]?.localAttachments.get(r.id),c=i[r.target]?.localAttachments.get(r.id);if(!a||!c)continue;const l=r.value>0&&Number.isFinite(r.value)?r.value:1,d=ao(a,u),h=ao(c,u);t[o]+=(y[s]+h-d)*l,n[o]+=l,t[s]+=(y[o]+d-h)*l,n[s]+=l}const r=Ke({desired:y.map((e,o)=>0===n[o]?e:.45*e+t[o]/n[o]*.55),minGaps:h,weights:n.map(t=>Math.max(1,t)),min:f,max:p});let s=0;for(let t=0;a>t;t++)s=Math.max(s,Math.abs(r[t]-y[t]));if(y=r,.01>s)break}return y}(i,n,e,o,s,a,r):[...a];if("hug"===r.lanePlacement){const o=e=>{const o=eo();for(const i of t)o[i.id]=e[n[i.id]];return o};lo(o(c),e)>lo(o(a),e)+1e-6&&(c=[...a])}const l=eo();for(const e of t)l[e.id]=c[n[e.id]];let u=1/0,d=-1/0;for(const e of t){const t=l[e.id],i=o[e.id];Number.isFinite(t)&&i&&(u=Math.min(u,t-i.topPeak*r.valueScale),d=Math.max(d,t+i.botPeak*r.valueScale))}return{adjacentClearance:s,centerlines:l,slotCenter:c,stackCenter:a,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&r.plotH>0?Math.max(0,Math.min(1,(d-u)/r.plotH)):0}}function lo(t,e){let o=0;for(const i of e){const e=t[i.source],n=t[i.target];Number.isFinite(e)&&Number.isFinite(n)&&(o+=Math.abs(e-n)*(i.value>0?i.value:1))}return o}function uo(t,e){const o=t?.samples;if(!o||0===o.length||o[0].t>e)return{top:0,bot:0};let i=0,n=o.length-1,r=0;for(;n>=i;){const t=i+n>>>1;o[t].t>e?n=t-1:(r=t,i=t+1)}const s=o[r].boundaryOffset??0;return{top:o[r].topMass-s,bot:o[r].botMass+s}}function ho(t,e,o,i,n){const r=1-n;return r*r*r*t+3*r*r*n*e+3*r*n*n*o+n*n*n*i}function fo(t,e){let o=0,i=1;for(let n=0;28>n;n++){const n=(o+i)/2;t>ho(0,e,e,1,n)?o=n:i=n}return(o+i)/2}function po(t,e,o){const i=e+ao(t,o),n=t.value*o/2;return[i-n,i+n]}function yo(t,e,o,i){return Math.max(0,Math.min(e,i)-Math.max(t,o))/Math.max(1e-9,e-t)}function go(t,e,o,i,n,r,s){const{valueScale:a,domain:c,mode:l="quality"}=s,u="source"===s.ribbonLane?.85:"target"===s.ribbonLane?.15:.5;let d=0;for(const s of t){const t=i[s.source],h=i[s.target];if(null==t||null==h||2>Math.abs(t-h))continue;const f=e[s.source]?.localAttachments.get(s.id),p=e[s.target]?.localAttachments.get(s.id);if(!f||!p)continue;const y=Math.max(s.startTime,c?.[0]??-1/0),g=Math.min(s.endTime,c?.[1]??1/0);if(y>=g)continue;const[m,x]=po(f,n[s.source],a),[b,v]=po(p,n[s.target],a),w=Math.min(t,h)+1,k=Math.max(t,h)-1;for(let t=w;k>=t;t++){const i=o[t];if(!i)continue;const c=[y,g];if("quality"===l)for(const t of i.occupants)for(const o of e[t.id]?.samples??[])o.t>y&&g>o.t&&c.push(o.t);const h=t=>{const o=fo((t-y)/(g-y),u),c=ho(m,m,b,b,o),l=ho(x,x,v,v,o);let d=0;for(const o of i.occupants){if(o.id===s.source||o.id===s.target)continue;const i=r[o.id];if(null!=i?.start&&i.start>t)continue;if(null!=i?.end&&t>i.end)continue;const u=uo(e[o.id],t),h=n[o.id];d=Math.max(d,yo(c,l,h-u.top*a,h+u.bot*a))}return d},f=[...new Set(c)].sort((t,e)=>t-e);let p=0;for(let t=0;f.length-1>t;t++){const e=f[t],o=f[t+1]-e;p+=(h(e+.25*o)+h(e+.5*o)+h(e+.75*o))/3*o}d+=p/(g-y)*(s.value>0?s.value:1)}}return d}function mo(t,e,o,i,n,r,s,a,c,l,u="both",d){return{crossings:t,weightedLength:e,pixelLength:lo(s,o),transitOcclusion:go(o,i,n,r,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function xo(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function bo(t,e){return t.map(t=>({t:xo(t.t,e),topMass:t.topMass,botMass:t.botMass,...null!=t.boundaryOffset&&{boundaryOffset:t.boundaryOffset}}))}function vo(t,e,o){const i=e+(t.boundaryOffset??0)*o,n=t.value*o;if("out"===t.kind){const e=t.sideMassBefore*o;if("top"===t.side){const t=i-e;return[t,t+n]}const r=i+e;return[r-n,r]}const r=t.sideMassAfter*o;if("top"===t.side){const t=i-r;return[t,t+n]}const s=i+r;return[s-n,s]}function wo(t,e,o,i,n="temporal"){const r=e.incoming[t.id],s=e.outgoing[t.id],a=[];for(const t of r)a.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:o.get(t.id).targetSide});for(const t of s)a.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:o.get(t.id).sourceSide});const c={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{a.sort((t,e)=>t.time-e.time||(t.phase??0)-(e.phase??0)||(t.sequence??0)-(e.sequence??0)||(c[t.kind]??99)-(c[e.kind]??99)||((t,e)=>{if(!i||!t.edge||!e.edge||t.kind!==e.kind||t.side!==e.side)return 0;if("out"===t.kind){if(t.edge.target===e.edge.target&&t.edge.endTime===e.edge.endTime)return 0;const o=i.get(t.edge.id)?.target,n=i.get(e.edge.id)?.target;return"number"==typeof o&&Number.isFinite(o)&&"number"==typeof n&&Number.isFinite(n)&&o!==n?"top"===t.side?o-n:n-o:0}if("in"===t.kind){if(t.edge.source===e.edge.source&&t.edge.startTime===e.edge.startTime)return 0;const o=i.get(t.edge.id)?.source,n=i.get(e.edge.id)?.source;return"number"==typeof o&&Number.isFinite(o)&&"number"==typeof n&&Number.isFinite(n)&&o!==n?"top"===t.side?n-o:o-n:0}return 0})(t,e)||oo(t.edge?.id??"",e.edge?.id??"")||oo(t.side,e.side)||t.delta-e.delta)},u=a.length?function(t,e=1/0){let o=e;for(const e of t)o>e&&(o=e);return o}(a.map(t=>t.time)):null,d=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;l();let f=null,p=0;for(const t of a)t.time!==f&&(f=t.time,p=0),t.sequence=p++;const y=t=>({time:t.time,phase:0,sequence:t.sequence??0}),g=[];let m=0,x=0;for(const t of a)if("out"===t.kind){const e=Math.abs(t.delta);let o=e-("top"===t.side?m:x);if(o>0){const e="top"===t.side?"bot":"top",i=Math.min(o,"top"===e?m:x);if(i>0){const n=y(t);g.push({...n,delta:-i,kind:"transfer-out",side:e}),g.push({...n,delta:+i,kind:"transfer-in",side:t.side}),"top"===e?m-=i:x-=i,"top"===t.side?m+=i:x+=i,o-=i}o>0&&null!==h&&(g.push({time:h,delta:+o,kind:"create",side:t.side}),"top"===t.side?m+=o:x+=o)}"top"===t.side?m-=e:x-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?m+=e:x+=e}a.push(...g),l();let b=0,v=0,w=0,k=0,A=0,S=0;const M=[],_=new Map,$=t=>{M.push({t:t,topMass:b,botMass:v,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},P=()=>{k=Math.max(k,b+v),A=Math.max(A,b-w),S=Math.max(S,v+w)};for(const t of a){if("transfer-out"!==t.kind&&"transfer-in"!==t.kind&&$(t.time),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?b:v;_.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===t.side?b+=t.delta:v+=t.delta,"transfer-in"===t.kind?(w+="top"===t.side?t.delta:-t.delta,P(),$(t.time)):"transfer-out"!==t.kind&&(P(),"out"!==t.kind||b+v>1e-12||(w=0),$(t.time))}const j=[];let I=0;for(;M.length>I;){let t=I;for(;M.length>t+1&&M[t+1].t===M[I].t;)t++;j.push(M[I]);for(let e=I+1;t>=e;e++){const t=j[j.length-1];M[e].topMass===t.topMass&&M[e].botMass===t.botMass&&(M[e].boundaryOffset??0)===(t.boundaryOffset??0)||j.push(M[e])}I=t+1}const L=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let R=null;for(const t of s)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===R||R>t.systemInTime)&&(R=t.systemInTime);let T=null;for(const t of r)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===T||t.systemOutTime>T)&&(T=t.systemOutTime);if(j.length>0){const t=j[j.length-1],e=Math.max(null!=L?L:-1/0,null!=T?T:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&j.push({t:e,topMass:t.topMass,botMass:t.botMass,...null!=t.boundaryOffset&&{boundaryOffset:t.boundaryOffset}});const o=j[0],i=j.find(t=>t.topMass+t.botMass>0);let n,r=1/0;null!=d&&Number.isFinite(d)&&o.t>d&&o.topMass+o.botMass>0&&(r=d,n=o),i&&null!=R&&Number.isFinite(R)&&i.t>R&&r>R&&(r=R,n=i),n&&Number.isFinite(r)&&j.unshift({t:r,topMass:n.topMass,botMass:n.botMass,...null!=n.boundaryOffset&&{boundaryOffset:n.boundaryOffset}})}let C=j;if("max"===n&&null!=d&&null!=L&&L>d){let t,e=0;for(const o of j){const i=o.topMass+o.botMass;i>e&&(e=i,t=o)}if(t){const e={topMass:t.topMass,botMass:t.botMass,...null!=t.boundaryOffset&&{boundaryOffset:t.boundaryOffset}};C=[...j.filter(t=>d>t.t),{t:d,...e},{t:L,...e},...j.filter(t=>t.t>L)]}}return{samples:C,peak:k,topPeak:A,botPeak:S,localAttachments:_}}function ko(t){const e=eo();return t.forEach((t,o)=>{for(const i of t.occupants)e[i.id]=o}),e}function Ao(t,e,o){t.splice(0,t.length,...o);const i=ko(o);for(const t of Object.keys(e))delete e[t];Object.assign(e,i)}function So(t){const e=new Map,o=[];t.forEach((t,i)=>{if(!t.group)return void o.push({anchor:i,stableId:io(t),slots:[t]});const n=e.get(t.group)??{indexes:[],slots:[]};n.indexes.push(i),n.slots.push(t),e.set(t.group,n)});for(const[t,i]of e)o.push({anchor:i.indexes.reduce((t,e)=>t+e,0)/i.indexes.length,stableId:`${t}\0${i.slots.map(io).join("\0")}`,slots:i.slots});return o.sort((t,e)=>t.anchor-e.anchor||oo(t.stableId,e.stableId))}function Mo(t){return t.some(t=>t.group)?So(t).flatMap(t=>t.slots):[...t]}function _o(t){return t.flatMap(t=>t.slots)}function $o(t,e,o){const i=new Map;return t.forEach((t,e)=>{for(const o of t.slots)i.set(o,e)}),t.map((t,n)=>{if(1>=t.slots.length)return t;const r=new Map;for(const e of t.slots)r.set(e,0);for(const t of e){const e=i.get(t.source),o=i.get(t.target);if(null==e||null==o)continue;const s=Number.isFinite(t.weight)&&t.weight>0?t.weight:1;if(e===n&&o!==n){const e=o>n?1:-1;r.set(t.source,(r.get(t.source)??0)+s*e)}else if(o===n&&e!==n){const o=e>n?1:-1;r.set(t.target,(r.get(t.target)??0)+s*o)}}const s=[...t.slots].sort((t,e)=>(r.get(t)??0)-(r.get(e)??0)||o(t,e));return{...t,slots:s}})}function Po(t,e){t.some(t=>t.group)&&Ao(t,e,Mo(t))}function jo(t,e){return t.source!==e.source&&t.target!==e.target&&t.source!==e.target&&t.target!==e.source&&Math.min(t.endTime,e.endTime)>Math.max(t.startTime,e.startTime)}function Io(t,e){return function(t,e,o=()=>!0){let i=0;for(let n=0;t.length>n;n++){const[r,s]=e(t[n]);for(let a=n+1;t.length>a;a++){if(!o(t[n],t[a]))continue;const[c,l]=e(t[a]);0>(r-c)*(s-l)&&i++}}return i}(e,e=>[t[e.source],t[e.target]],jo)}function Lo(t,e){let o=0;for(const i of e){const e=t[i.source],n=t[i.target];null!=e&&null!=n&&(o+=Math.abs(e-n)*(i.value>0?i.value:1))}return o}function Ro(t,e,o){const[i,n]=o.get(t.first),[r,s]=o.get(t.second);return 0>(e.get(i)-e.get(r))*(e.get(n)-e.get(s))?1:0}function To(t,e,o,i,n,r,s){const a=[...n],c=new Map(n.map(t=>[t,io(t)])),l=new Map;for(const t of n)for(const e of t.occupants)l.set(e.id,t);const u=new Map,d=[];for(const t of e){const e=l.get(t.source),o=l.get(t.target);e&&o&&(u.set(t,[e,o]),e!==o&&d.push({source:e,target:o,weight:t.value}))}const h=[];for(let t=0;e.length>t;t++)if(u.has(e[t]))for(let o=t+1;e.length>o;o++){if(!u.has(e[o])||!jo(e[t],e[o]))continue;const i=new Set([...u.get(e[t]),...u.get(e[o])]);h.push({index:h.length,first:e[t],second:e[o],involvedSlots:i})}const f=new Map;for(const t of n)f.set(t,[]);for(const t of h)for(const e of t.involvedSlots)f.get(e)?.push(t);const p=new Uint32Array(h.length);let y=0;const g=e.reduce((t,e)=>t+(e.value>0?e.value:1),0),m=s.plotH/Math.max(1,n.length),x=n.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),b=Math.max(1,g)*(Math.max(1,s.plotH)+m*Math.max(x,n.length)+1e-6*Math.max(1,n.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=new Map,A=(t,e)=>{let i=k.get(t);i||(i=new Map,k.set(t,i));const n=i.get(e);if(null!=n)return n;const r=function(t,e,o){return Qe(ro([t,e],o)).adjacentClearance[0]??0}(t,e,o);return i.set(e,r),r},S=new Map(n.map((t,e)=>[t,e])),M=e.flatMap(t=>{const e=u.get(t);return e?[{source:S.get(e[0]),target:S.get(e[1]),weight:t.value>0?t.value:1}]:[]}),_=new Map;for(const t of e){const e=u.get(t);e&&_.set(t,{source:S.get(e[0]),target:S.get(e[1])})}const $=new Map,P=new Map,j=new Map,I=(t,e,o)=>{t.has(e)||t.set(e,new Set),t.get(e).add(o)};for(const t of e)I($,t.source,t.target),I(P,t.target,t.source),I(j,t.source,t.target),I(j,t.target,t.source);const L=e.flatMap(t=>{if(!(t=>1===$.get(t.source)?.size&&$.get(t.source).has(t.target)||1===j.get(t.source)?.size||1===j.get(t.target)?.size)(t))return[];const e=_.get(t);return e&&e.source!==e.target?[{source:e.source,target:e.target,weight:t.value>0?t.value:1}]:[]}),R=t=>{let e=0;for(const o of L)e+=Math.max(0,Math.abs(t[o.source]-t[o.target])-1)*o.weight;return e*v},T=t=>{const e=new Int16Array(n.length);for(let o=0;t.length>o;o++)e[S.get(t[o])]=o;return R(e)},C=h.map(t=>{const e=_.get(t.first),o=_.get(t.second);return[e.source,e.target,o.source,o.target]}),O=new Int16Array(n.length),F=new Float64Array(n.length),D=new Float64Array(n.length+1),N=t=>{for(let e=0;t.length>e;e++)O[S.get(t[e])]=e;let e=0;for(const[t,o,i,n]of C)0>(O[t]-O[i])*(O[o]-O[n])&&e++;if(t.length>0){const e=S.get(t[0]);F[e]=s.padding+t[0].peak.topPeak*s.valueScale;for(let e=1;t.length>e;e++){const o=S.get(t[e-1]),i=S.get(t[e]);F[i]=F[o]+A(t[e-1],t[e])*s.valueScale+s.padding}const o=S.get(t[t.length-1]),i=F[o]+t[t.length-1].peak.botPeak*s.valueScale+s.padding;if(i>s.plotH&&i>0){const t=s.plotH/i;for(let e=0;F.length>e;e++)F[e]*=t}}D[0]=0;for(let e=0;t.length>e;e++)D[e+1]=D[e]+t[e].peak.topPeak+t[e].peak.botPeak;let o=0,i=0,n=0;for(const t of M){const e=O[t.source],r=O[t.target];if(o+=Math.abs(e-r)*t.weight,i+=Math.abs(F[t.source]-F[t.target])*t.weight,Math.abs(e-r)>=2){const o=Math.min(e,r)+1;n+=(D[Math.max(e,r)]-D[o])*t.weight}}return e*b+i+n*m+R(O)+1e-6*o},z=(t,o)=>{const i=Array(t.length+1).fill(0);for(let e=0;t.length>e;e++)i[e+1]=i[e]+t[e].peak.topPeak+t[e].peak.botPeak;let n=0;for(const t of e){const e=o[t.source],r=o[t.target];if(null==e||null==r||2>Math.abs(e-r))continue;const s=Math.min(e,r)+1;n+=(i[Math.max(e,r)]-i[s])*(t.value>0?t.value:1)}return n},E=i=>{const n=ko(i),r=i.slice(0,-1).map((t,e)=>A(t,i[e+1])),a=co(t,e,o,i,n,{plotH:s.plotH,padding:s.padding,valueScale:s.valueScale,lanePlacement:s.lanePlacement??"stack",groupPadding:s.groupPadding,adjacentClearance:r});return{map:n,geometry:a,weightedLength:Lo(n,e),pixelLength:lo(a.centerlines,e),transitOcclusion:z(i,n)}},B=(t,e,o)=>({crossings:t,weightedLength:e.weightedLength,pixelLength:e.pixelLength,transitOcclusion:e.transitOcclusion,cost:t*b+e.pixelLength+e.transitOcclusion*m+T(o)+1e-6*e.weightedLength}),W=(t,e)=>{let o=e;if(null==o){const e=new Map(t.map((t,e)=>[t,e]));o=h.reduce((t,o)=>t+Ro(o,e,u),0),w.fullCrossing++}return B(o,E(t),t)},Y=(t,n,r="quality")=>{let a=n;if(null==a){const e=new Map(t.map((t,e)=>[t,e]));a=h.reduce((t,o)=>t+Ro(o,e,u),0),w.fullCrossing++}const c=E(t);return B(a,{...c,transitOcclusion:go(e,o,t,c.map,c.geometry.centerlines,i,{valueScale:s.valueScale,ribbonLane:s.ribbonLane,domain:s.domain,mode:r})},t)};let q=[...a];const X=(t,e)=>oo(c.get(t),c.get(e)),G=function(t){const e=new Set;for(const o of t)if(o.group){if(e.has(o.group))return!0;e.add(o.group)}return!1}(q),V=t=>{const e=(t=>{const e=Je(t,d,t=>W(t).cost,{passes:6,compare:X,maxEvaluations:py});let o=W(e),i=py;for(let t=0;6>t&&i>0;t++){let n=!1;const r=Array.from({length:e.length-1},(t,e)=>e);t%2==1&&r.reverse();for(const t of r){if(0>=i--)break;const r=e[t],s=e[t+1],a=new Map(e.map((t,e)=>[t,e]));let c=0;const l=[];y++;for(const t of[...f.get(r)??[],...f.get(s)??[]])p[t.index]!==y&&(p[t.index]=y,l.push(t),c+=Ro(t,a,u));[e[t],e[t+1]]=[s,r];const d=new Map(a);d.set(r,t+1),d.set(s,t);let h=0;for(const t of l)h+=Ro(t,d,u);w.localCrossing+=l.length;const g=W(e,o.crossings-c+h);o.cost>g.cost?(o=g,n=!0):[e[t],e[t+1]]=[r,s]}if(!n)break}return e})(t);if((t.length>8?1/0:hy(t.length)*(t.length+M.length+C.length))>fy)return e;const o=to(t,N,{maxItems:8,maxEvaluations:5e4}),i=Y(o),n=Y(e);return i.crossings!==n.crossings&&n.crossings>i.crossings?o:e},H="geometry-refine"===s.mode;if(H||"crossing-min"!==s.laneOrder&&"crossing-min+inside-out"!==s.laneOrder){if(!H&&"inside-out"===s.laneOrder)if(G){const t=So(q),e=t=>t.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),o=[...t].sort((t,o)=>e(o)-e(t)||oo(t.stableId,o.stableId)),i=Array(o.length);let n=Math.floor((o.length-1)/2)-1,r=Math.floor((o.length-1)/2)+1;o.length>0&&(i[Math.floor((o.length-1)/2)]=o[0]);for(let t=1;o.length>t;t++)t%2==1&&o.length>r||0>n?i[r++]=o[t]:i[n--]=o[t];q=_o(i)}else{const t=[...q].sort((t,e)=>e.peak.topPeak+e.peak.botPeak-(t.peak.topPeak+t.peak.botPeak)||X(t,e)),e=Array(t.length);let o=Math.floor((t.length-1)/2)-1,i=Math.floor((t.length-1)/2)+1;t.length>0&&(e[Math.floor((t.length-1)/2)]=t[0]);for(let n=1;t.length>n;n++)n%2==1&&t.length>i||0>o?e[i++]=t[n]:e[o--]=t[n];q=e}}else q=G?(t=>{let e=So(t);if(1>=e.length)return _o(e);const o=t=>W(_o(t)).cost;e=So(V(t)),e=$o(e,d,X);const i=function(t,e){const o=new Map;for(const e of t)for(const t of e.slots)o.set(t,e);const i=new Map;for(const t of e){const e=o.get(t.source),n=o.get(t.target);if(!e||!n||e===n)continue;const r=Number.isFinite(t.weight)&&t.weight>0?t.weight:1,s=n.stableId>e.stableId?`${e.stableId}\0${n.stableId}`:`${n.stableId}\0${e.stableId}`,a=i.get(s);a?a.weight=(a.weight??0)+r:i.set(s,{source:e,target:n,weight:r})}return[...i.values()]}(e,d);e=Je(e,i,o,{passes:6,compare:(t,e)=>oo(t.stableId,e.stableId),maxEvaluations:py}),e=function(t,e,o={}){const i=[...t];if(1>=i.length)return i;let n=e(i),r=1;const s=Math.max(0,o.passes??6),a=Math.max(1,o.maxEvaluations??1/0);for(let t=0;s>t&&a>r;t++){let t=!1;for(let o=0;i.length-1>o&&a>r;o++){[i[o],i[o+1]]=[i[o+1],i[o]];const s=e(i);r++,n>s?(n=s,t=!0):[i[o],i[o+1]]=[i[o+1],i[o]]}if(!t)break}return i}(e,o,{passes:8,maxEvaluations:py});const n=e.length>8?1/0:hy(e.length)*(e.length+M.length+C.length);if(fy>=n){const t=to(e,t=>N(_o(t)),{maxItems:8,maxEvaluations:5e4}),o=_o(t),i=_o(e),n=Y(o),r=Y(i);n.crossings!==r.crossings?e=r.crossings>n.crossings?t:e:r.cost>n.cost&&(e=t)}return e=$o(e,d,X),_o(e)})(q):V(q);if(!H&&"crossing-min+inside-out"===s.laneOrder&&q.length>1)if(G){const t=So(q);let e=W(_o(t)),o=_o(t),i=e;const n=Math.floor((t.length-1)/2),r=t=>t.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),s=[...t].sort((t,e)=>r(e)-r(t)||oo(t.stableId,e.stableId));for(const r of s){const s=t.indexOf(r);if(s===n)continue;t.splice(s,1),t.splice(n,0,r);const a=_o(t),c=W(a);c.cost>e.cost?(t.splice(n,1),t.splice(s,0,r)):(e=c,i.cost>c.cost&&(o=a,i=c))}q=o}else{let t=W(q),e=[...q],o=t;const i=Math.floor((q.length-1)/2),n=[...q].sort((t,e)=>e.peak.topPeak+e.peak.botPeak-(t.peak.topPeak+t.peak.botPeak)||X(t,e));for(const r of n){const n=q.indexOf(r);if(n===i)continue;q.splice(n,1),q.splice(i,0,r);const s=W(q);s.cost>t.cost?(q.splice(i,1),q.splice(n,0,r)):(t=s,o.cost>s.cost&&(e=[...q],o=s))}q=e}if((H||"crossing-min"===s.laneOrder||"crossing-min+inside-out"===s.laneOrder)&&q.length>1)if(G){let t=So(q),e=Y(_o(t),void 0,"score");for(let o=0;6>o&&t.length>1;o++){let o=!1;for(let i=0;t.length-1>i;i++){[t[i],t[i+1]]=[t[i+1],t[i]];const n=_o(t),r=Y(n,void 0,"score");e.cost>r.cost?(q=n,e=r,o=!0):[t[i],t[i+1]]=[t[i+1],t[i]]}if(!o)break}t=$o(So(q),d,X),q=_o(t)}else{let t=Y(q,void 0,"score");for(let e=0;q.length-1>e;e++){const o=q[e],i=q[e+1],n=new Map(q.map((t,e)=>[t,e]));let r=0;const s=[];y++;for(const t of[...f.get(o)??[],...f.get(i)??[]])p[t.index]!==y&&(p[t.index]=y,s.push(t),r+=Ro(t,n,u));[q[e],q[e+1]]=[i,o];const a=new Map(n);a.set(o,e+1),a.set(i,e);let c=0;for(const t of s)c+=Ro(t,a,u);w.localCrossing+=s.length;const l=Y(q,t.crossings-r+c,"score");t.cost>l.cost?t=l:[q[e],q[e+1]]=[o,i]}}const U=Mo(a);q=Mo(q);let K=Y(q);const Z=Y(U);if(H){const t=T(U),e=T(q);(K.crossings>Z.crossings||K.crossings===Z.crossings&&e>t+1e-9||K.cost>Z.cost)&&(q=U,K=Z)}else K.cost>Z.cost&&(q=U,K=Z);const Q=function({order:t,after:e,nodes:o,edges:i,outgoingPartners:n,incomingPartners:r,slotForNode:s,averageGap:a,evaluate:c}){const l=(o,n)=>{const r=[...new Set(n.map(e=>t.indexOf(e)))].sort((t,e)=>t-e),s=t.indexOf(o),l=r[0],u=r[r.length-1];if(3>r.length||!r.includes(s)||u-l+1!==r.length||1>=Math.abs(2*s-l-u))return;const d=[...t];d.splice(s,1),d.splice(l+u>>1,0,o);const h=Mo(d),f=c(h),p=new Set(o.occupants.map(t=>t.id)),y=new Set(n.flatMap(t=>t.occupants.map(t=>t.id))),g=i.reduce((t,e)=>p.has(e.source)&&y.has(e.target)||p.has(e.target)&&y.has(e.source)?t+(e.value>0?e.value:1):t,0);(function(t,e,o=0){return e.crossings>t.crossings||t.crossings===e.crossings&&e.cost+o>=t.cost})(f,e,Math.abs(2*s-l-u)*a*Math.max(1,g))&&(t=h,e=f)};for(const[t,e]of n)r.has(t)||3>e.size||l(s.get(t),[...e].map(t=>s.get(t)));for(const t of o){const e=s.get(t.id);t.group||!e.group||3>(r.get(t.id)?.size??0)||l(e,[...r.get(t.id)??[]].map(t=>s.get(t)).filter(t=>t===e||t.group===e.group).filter((t,e,o)=>o.indexOf(t)===e))}return{order:t,after:e}}({order:q,after:K,nodes:t,edges:e,outgoingPartners:$,incomingPartners:P,slotForNode:l,averageGap:m,evaluate:Y});return q=Q.order,K=Q.after,Ao(n,r,q),{before:Z,after:K,initialOrder:a.map(t=>c.get(t)),evaluations:w}}function Co(t,e,o){const i=t.map(t=>{const i=t.occupants.map(t=>({id:t.id,end:o[t.id]?.end??t.end}));let n=0,r=0;for(const t of i){const o=e[t.id];n=Math.max(n,o?.topPeak||0),r=Math.max(r,o?.botPeak||0)}return{occupants:i,peak:{topPeak:n,botPeak:r},...null!=t.group?{group:t.group}:{}}}),n=eo();return i.forEach((t,e)=>{for(const o of t.occupants)n[o.id]=e}),{slots:i,slotByNode:n}}function Oo(t,e){return null!=t.start&&null!=t.end&&null!=e.start&&null!=e.end&&!(e.start>=t.end||t.start>=e.end)}function Fo(t,e){return oo(t,e)>0?`${e}\0${t}`:`${t}\0${e}`}function Do(t){const e=new Map,o=new Map;for(const i of t)o.has(i.source)||o.set(i.source,new Set),e.has(i.target)||e.set(i.target,new Set),o.get(i.source).add(i.target),e.get(i.target).add(i.source);return{incoming:new Map([...e].map(([t,e])=>[t,e.size])),outgoing:new Map([...o].map(([t,e])=>[t,e.size]))}}function No(t){const e=new Map,o=new Map,i=(t,e,o,i)=>{let n=t.get(e);n||(n=new Map,t.set(e,n)),n.set(o,(n.get(o)??0)+i)};for(const n of t){const t=n.value>0&&Number.isFinite(n.value)?n.value:1;i(e,n.source,n.target,t),i(o,n.target,n.source,t)}const n=new Map,r=t=>{if(n.has(t))return;const i=e.get(t),r=o.get(t),s=new Map;for(const[t,e]of i??[])s.set(t,(s.get(t)??0)+e);for(const[t,e]of r??[])s.set(t,(s.get(t)??0)+e);if(1===s.size){const[e,o]=[...s][0];n.set(t,{partner:e,weight:o})}};for(const e of t)r(e.source),r(e.target);return n}function zo(t,e,o){const i=o.get(t),n=o.get(e);return!i||!n||i.partner===n.partner||i.partner===e||n.partner===t}function Eo(t,e,o){return!!o.has(t)&&e.some(e=>!zo(t,e,o))}function Bo(t,e){return(t.value>0&&Number.isFinite(t.value)?t.value:1)*(1+(1===e.outgoing.get(t.source)?1:0)+(1===e.incoming.get(t.target)?1:0))}function Wo(t,e,o,i){if(12>=t.length||1>=i.slotCount)return i.assignment;const n=new Map(t.map((t,e)=>[t,e])),r=Array.from({length:t.length},()=>new Map),s=Do(o);for(const t of o){const e=n.get(t.source),o=n.get(t.target);if(null==e||null==o||e===o)continue;const i=Bo(t,s);r[e].set(o,(r[e].get(o)??0)+i),r[o].set(e,(r[o].get(e)??0)+i)}const a=No(o),c=t.map(t=>a.get(t)?.weight??0),l=Array.from({length:t.length},()=>new Map);let u=0;for(let o=0;t.length-1>o&&5e4>u;o++)if(a.has(t[o]))for(let i=o+1;t.length>i;i++){if(!a.has(t[i]))continue;if(e.conflicts(t[o],t[i]))continue;u++;const n=Math.min(c[o],c[i])||Math.max(c[o],c[i]),r=zo(t[o],t[i],a)?n:-n;if(Math.abs(r)>my&&(l[o].set(i,r),l[i].set(o,r),u>=5e4))break}const d=[...i.assignment],h=Array.from({length:i.slotCount},()=>[]);d.forEach((t,e)=>h[t].push(e));const f=(t,e,o)=>{const i=d[e],n=d[o];let r=0;const s=new Set;for(const a of[e,o])for(const[c,l]of t[a]){const t=c>a?`${a}:${c}`:`${c}:${a}`;if(s.has(t))continue;s.add(t);const u=(a===e?n:i)===(c===e?n:c===o?i:d[c]);d[a]===d[c]!==u&&(r+=u?l:-l)}return r},p=(t,e,o)=>{let i=0;for(const[n,r]of t[e]){const t=o===d[n];d[e]===d[n]!==t&&(i+=t?r:-r)}return i},y=(t,e)=>t>my||my>=Math.abs(t)&&e>my,g=(t,e,o,i)=>t>o+my||my>=Math.abs(t-o)&&e>i+my;let m=0;for(let o=0;32>o&&gy>m;o++){let o=null,i=-1,n=-1,s=-1,a=-1/0,c=-1/0;for(let u=0;t.length>u;u++){for(let f=0;h.length>f&&m++<gy;f++){if(f===d[u])continue;if(!h[f].every(o=>!e.conflicts(t[u],t[o])))continue;const m=p(r,u,f),x=p(l,u,f);y(m,x)&&g(m,x,a,c)&&(o="move",i=u,n=-1,s=f,a=m,c=x)}if(m>=gy)break}for(let u=0;t.length-1>u;u++){for(let p=u+1;t.length>p&&m++<gy;p++){const m=d[u],x=d[p];if(m===x)continue;if(!h[x].every(o=>o===p||!e.conflicts(t[u],t[o])))continue;if(!h[m].every(o=>o===u||!e.conflicts(t[p],t[o])))continue;const b=f(r,u,p),v=f(l,u,p);y(b,v)&&g(b,v,a,c)&&(o="swap",i=u,n=p,s=-1,a=b,c=v)}if(m>=gy)break}if(null==o||-1===i)break;if("move"===o){const t=d[i];h[t].splice(h[t].indexOf(i),1),h[s].push(i),d[i]=s;continue}const u=d[i],x=d[n];h[u].splice(h[u].indexOf(i),1,n),h[x].splice(h[x].indexOf(n),1,i),d[i]=x,d[n]=u}return d}function Yo(t,e){let o=1/0,i=-1/0;for(const e of t?.samples??[])e.topMass+e.botMass>1e-9&&(o=Math.min(o,e.t),i=Math.max(i,e.t));return Number.isFinite(o)&&Number.isFinite(i)?(null!=e.start&&(o=Math.max(o,e.start)),null!=e.end&&(i=Math.min(i,e.end)),o>i?{start:null,end:null}:{start:o,end:i}):{start:null,end:null}}function qo(t,e,o,i){const n=function(t,e,o,i){return`${t.map(t=>{const e=o[t.id],n=i[t.id];return[t.id,t.group??"",t.xExtent?.[0]??"",t.xExtent?.[1]??"",e?.topPeak??0,e?.botPeak??0,n?.start??"",n?.end??""].join(":")}).join("|")}#${e.map(t=>[t.id,t.source,t.target,t.value,t.startTime,t.endTime].join(":")).join("|")}`}(t,e,o,i),r=yy.get(n);if(r)return Co(r.slots,o,i);const s=eo();for(const e of t)s[e.id]=Yo(o[e.id],i[e.id]);const a=function(t,e){return t.filter(t=>null!=e[t.id].start).sort((t,o)=>e[t.id].start-e[o.id].start||e[t.id].end-e[o.id].end||oo(t.id,o.id)).map(t=>t.id)}(t,s),c=new Map(t.map(t=>[t.id,t])),l=new Map(t.map(t=>[t.id,t.group||void 0])),u=No(e),d=function(t,e,o,i,n,r){const s=new Set,a=new Map(t.map(t=>[t,new Set])),c=new Map(t.map(t=>[t,new Set]));for(const t of i)s.add(Fo(t.source,t.target)),a.get(t.target)?.add(t.source),c.get(t.source)?.add(t.target);const l=new Map,u=new Set,d=(t,e)=>{for(let o=0;t.length>o;o++)for(let i=o+1;t.length>i;i++){const n=Fo(t[o],t[i]);e instanceof Map?e.set(n,[t[o],t[i]]):e.add(n)}};for(const t of c.values())d([...t],l);for(const t of a.values())d([...t],u);const h=new Set;for(const[t,[i,n]]of l)u.has(t)&&(Oo(e[i],e[n])||Oo(o[i],o[n])&&(h.add(i),h.add(n)));return{conflicts:(t,o)=>{const i=n.get(t),a=n.get(o);return null!=i&&null!=a&&i!==a||!(null!=i==(null!=a)||s.has(Fo(t,o))||r.has(t)&&r.has(o)&&zo(t,o,r))||!!Oo(e[t],e[o])||!(!h.has(t)&&!h.has(o))&&!s.has(Fo(t,o))}}}(a,s,i,e,l,u),h=function(t,e,o=new Map){const i=[],n=[];for(const r of t){let t=i.findIndex(t=>t.every(t=>!e.conflicts(r,t))&&!Eo(r,t,o));-1!==t||o.has(r)||(t=i.findIndex(t=>t.every(t=>!e.conflicts(r,t)))),-1===t&&(t=i.length,i.push([])),i[t].push(r),n.push(t)}return{assignment:n,slotCount:i.length}}(a,d,u),f=function(t,e,o,i){if(0===t.length||t.length>12||1>=i.slotCount)return i.assignment;const n=new Map(t.map((t,e)=>[t,e])),r=Array.from({length:t.length},()=>new Float64Array(t.length)),s=Array.from({length:t.length},()=>new Map),a=Array.from({length:t.length},()=>new Map),c=Do(o);for(const t of o){const e=n.get(t.source),o=n.get(t.target);if(null==e||null==o||e===o)continue;const i=Bo(t,c);r[e][o]+=i,r[o][e]+=i,a[e].set(o,(a[e].get(o)??0)+i),s[o].set(e,(s[o].get(e)??0)+i)}const l=No(o),u=t.map(t=>l.get(t)?.weight??0),d=Array.from({length:t.length},()=>new Float64Array(t.length));for(let e=0;t.length>e;e++)for(let o=e+1;t.length>o;o++){for(const[t,i]of s[e])d[e][o]+=Math.min(i,s[o].get(t)??0);for(const[t,i]of a[e])d[e][o]+=Math.min(i,a[o].get(t)??0);if(l.has(t[e])&&l.has(t[o])){const i=Math.min(u[e],u[o])||Math.max(u[e],u[o]);d[e][o]+=zo(t[e],t[o],l)?i:-i}d[o][e]=d[e][o]}let h=[...i.assignment],f=(e=>{let o=0,i=0;for(let n=0;t.length>n;n++)for(let s=n+1;t.length>s;s++)e[n]===e[s]&&(o+=r[n][s],i+=d[n][s]);return{flow:o,affinity:i}})(h),p=0;const y=Array(t.length).fill(-1),g=Array.from({length:i.slotCount},()=>[]),m=(o,n,s,a)=>{if(p>=75e3)return;if(o===t.length)return p++,void((s>f.flow||s===f.flow&&a>f.affinity||s===f.flow&&a===f.affinity&&function(t,e){for(let o=0;Math.min(t.length,e.length)>o;o++)if(t[o]!==e[o])return e[o]>t[o];return e.length>t.length}(y,h))&&(h=[...y],f={flow:s,affinity:a}));const c=Math.min(n+1,i.slotCount-1);for(let i=0;c>=i;i++){if(g[i].some(i=>e.conflicts(t[o],t[i])))continue;let c=0,l=0;for(const t of g[i])c+=r[o][t],l+=d[o][t];if(y[o]=i,g[i].push(o),m(o+1,Math.max(n,i),s+c,a+l),g[i].pop(),y[o]=-1,p>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}(a,d,e,{...h,assignment:Wo(a,d,e,h)}),p=new Map,y=f.map(t=>(p.has(t)||p.set(t,p.size),p.get(t))),g=Array.from({length:p.size||(t.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=eo();a.forEach((t,e)=>{const o=y[e],i=g[o];i.occupants.push({id:t,end:s[t].end??-1/0});const n=c.get(t)?.group;n&&(i.group=n),m[t]=o});for(const e of[...t].sort((t,e)=>oo(t.id,e.id)))null==m[e.id]&&(g[0].occupants.push({id:e.id,end:-1/0}),m[e.id]=0);for(const t of g){t.occupants.sort((t,e)=>(s[t.id].start??1/0)-(s[e.id].start??1/0)||oo(t.id,e.id));for(const e of t.occupants){const i=o[e.id];t.peak.topPeak=Math.max(t.peak.topPeak,i?.topPeak||0),t.peak.botPeak=Math.max(t.peak.botPeak,i?.botPeak||0)}}const x={slots:g,slotByNode:m};return function(t,e){for(yy.has(t)&&yy.delete(t),yy.set(t,{slots:e.slots.map(t=>({occupants:t.occupants.map(t=>({...t})),peak:{...t.peak},...null!=t.group?{group:t.group}:{}})),slotByNode:Object.assign(eo(),e.slotByNode)});yy.size>12;){const t=yy.keys().next().value;if(null==t)break;yy.delete(t)}}(n,x),x}function Xo(t){return t.topMass+t.botMass}function Go(t){const e=new Map;for(const o of t.samples){if(Number.isNaN(o.t))continue;let t=e.get(o.t);t||(t=[],e.set(o.t,t)),t.push(o)}let o=0,i=-1/0;return n=>{i>n&&(o=0),i=n;const r=e.get(n);if(r){const t=r.reduce((t,e)=>Xo(e)<Xo(t)?t:e,r[0]);return{exact:r,sample:t}}for(;t.samples.length>o&&n>=t.samples[o].t;)o++;return{exact:r,sample:t.samples[o-1]??null}}}function Vo(t,e,o,i,n,r,s=0){const a=new Map;for(const o of t){if(!o.group||!e[o.id])continue;const t=a.get(o.group)??[];t.push(o),a.set(o.group,t)}if(0===a.size||0>=r)return e;const c=Object.fromEntries(Object.entries(e).map(([t,e])=>[t,{...e,samples:e.samples.map(t=>({...t})),localAttachments:new Map([...e.localAttachments].map(([t,e])=>[t,{...e}]))}]));for(const[t,l]of a){const a=o.map((t,e)=>({slot:t,index:e})).filter(({slot:e})=>e.group===t);if(0===a.length)continue;const u=a[0].slot,d=a.at(-1).slot,h=n[u.occupants[0]?.id],f=n[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;const p=(h-u.peak.topPeak*r+(f+d.peak.botPeak*r))/2,y=[...new Set(l.flatMap(t=>e[t.id].samples.map(t=>t.t)))].sort((t,e)=>t-e),g=new Map;for(const t of l)g.set(t.id,new Map);const m=new Map(l.map(t=>[t.id,Go(e[t.id])]));for(const t of y){const e=new Map;for(const o of l){const{sample:n}=m.get(o.id)(t);if(!n||1e-9>=Xo(n))continue;const r=i[o.id];if(null==r)continue;const s=e.get(r)??[];s.push({node:o,sample:n}),e.set(r,s)}const o=[...e].sort((t,e)=>t[0]-e[0]).map(([t,e])=>({slot:t,active:e,mass:Math.max(...e.map(({sample:t})=>Xo(t)))}));if(0===o.length)continue;let a=p-(o.reduce((t,e)=>t+e.mass,0)*r+Math.max(0,s)*Math.max(0,o.length-1))/2;for(const e of o){for(const{node:o,sample:i}of e.active){const e=(a-n[o.id])/r+i.topMass-(i.boundaryOffset??0);g.get(o.id).set(t,e)}a+=e.mass*r+Math.max(0,s)}}for(const t of l){const o=e[t.id],i=c[t.id],n=g.get(t.id),r=m.get(t.id),s=[];for(const t of y){const e=n.get(t),{exact:o,sample:i}=r(t);o?s.push(...o.map(t=>({...t,...null!=e?{boundaryOffset:(t.boundaryOffset??0)+e}:{}}))):null!=e&&i&&Xo(i)>1e-9&&s.push({...i,t:t,boundaryOffset:(i.boundaryOffset??0)+e})}i.samples=s,i.localAttachments=new Map([...o.localAttachments].map(([t,e])=>{const o=n.get(e.time);return[t,{...e,...null!=o?{boundaryOffset:(e.boundaryOffset??0)+o}:{}}]}))}}return c}function Ho(t,e,o,i,n){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=n,y=eo(),g=eo();for(const e of t)y[e.id]=o[e.id].topPeak||0,g[e.id]=o[e.id].botPeak||0;const m="half"===u,x=eo();for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,o=Array.isArray(e.xExtent)?e.xExtent[1]:null;let n=null!=t&&Number.isFinite(t)?t:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const t of i.outgoing[e.id]){n>t.startTime&&(n=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&n>t.systemInTime&&(n=t.systemInTime);const e=m?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of i.incoming[e.id]){const e=m?(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)}x[e.id]={start:Number.isFinite(n)?n:null,end:Number.isFinite(r)?r:null}}let b=eo(),v=[],w=[];if(n.frozenSlots){const t=Co(n.frozenSlots,o,x);v=t.slots,b=t.slotByNode,w=v.map(io)}else if("reuse"===c){const i=qo(t,e,o,x);v=i.slots,b=i.slotByNode}else t.forEach((t,e)=>{v.push({occupants:[{id:t.id,end:x[t.id]?.end??-1/0}],peak:{topPeak:y[t.id],botPeak:g[t.id]},...t.group?{group:t.group}:{}}),b[t.id]=e});Po(v,b),0===w.length&&(w=v.map(io));let k=null;n.frozenSlots||(n.fixedSlotOrder?function(t,e,o){const i=new Map(o.map((t,e)=>[t,e]));Ao(t,e,[...t].sort((t,e)=>(i.get(io(t))??1/0)-(i.get(io(e))??1/0)||oo(io(t),io(e))))}(v,b,n.fixedSlotOrder):n.runOrdering&&l&&"insertion"!==l&&(k=To(t,e,o,x,v,b,{plotH:r,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:f,domain:p}))),Po(v,b);const A=co(t,e,o,v,b,{plotH:r,padding:s,valueScale:a,stackValueScale:n.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((t,e)=>t+e,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,$=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(io),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:$,lengthAfter:P}}function Uo(t){const{sx:e,sTop:o,sBot:i,tx:n,tTop:r,tBot:s,cp1X:a,cp2X:c}=t,l=(o+i)/2,u=(r+s)/2;return{pathD:[`M${e},${o}`,`C${a},${o} ${c},${r} ${n},${r}`,`L${n},${s}`,`C${c},${s} ${a},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:n,y:u}],halfWidth:(i-o)/2}}}function Ko(t,e,o,i,n,r,s,a,c={}){const l=n,u=t=>a?Math.max(a[0],Math.min(a[1],t)):t;let d=r(u(t.time));const h=r(u(o.time)),f=t.value*l,p=o.value*l,y=e+(t.boundaryOffset??0)*l,g=i+(o.boundaryOffset??0)*l,m=t.sideMassBefore*l,x=o.sideMassAfter*l;let b,v,w,k;"top"===t.side?(b=y-m,v=b+f):(v=y+m,b=v-f),"top"===o.side?(w=g-x,k=w+p):(k=g+x,w=k-p);const A=c.sourceRunwayStart,S=c.minRun,M=Math.abs((w+k)/2-(b+v)/2),_=h-d,$="number"==typeof A&&Number.isFinite(A),P="number"==typeof S&&Number.isFinite(S)&&S>0;if($&&M>1e-9&&_>0&&("auto"===S||P)){const e="source"===s?.85:"target"===s?.15:.5,o="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(e*e,(1-e)*(1-e))))):S;if(o>_){const e=r(u(Math.min(A,t.time)));Number.isFinite(e)&&(d=Math.min(d,Math.max(Math.min(d,e),h-o)))}}const j="source"===s?d+.85*(h-d):"target"===s?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:b,sBot:v,tx:h,tTop:w,tBot:k,cp1X:j,cp2X:j}}function Zo(t){return Math.max(18,11*t.length*.58)}function Qo(t){const e=1.22*Zo(t.labelText)+4;return"start"===t.labelAnchor?[t.labelX,t.labelX+e]:"middle"===t.labelAnchor?[t.labelX-e/2,t.labelX+e/2]:[t.labelX-e,t.labelX]}function Jo(t,e){const o=t.labelX-Zo(t.labelText),i=e.labelX-Zo(e.labelText);return e.labelX+3>=o&&t.labelX+3>=i}function ti(t){return t.replace(xy,(t,e,o)=>`${o},${e}`)}function ei(t){if(!t)return;const e=t=>({x:t.y,y:t.x});return{...t,...t.points&&{points:t.points.map(e)},...t.segments&&{segments:t.segments.map(t=>t.map(e))}}}function oi(t){return{...t,pathD:ti(t.pathD),y0:t.x0,y1:t.x1,x0:0,x1:0}}function ii(t){return{type:"hatch",background:t.background,stroke:t.stroke,lineWidth:t.lineWidth,spacing:t.spacing,angle:t.angle}}function ni(t,e){if(!e)return e;const o=function(t){const e=t.trim();if(!e.startsWith("var(")||!e.endsWith(")"))return null;const o=e.slice(4,-1),i=o.indexOf(",");if(-1===i){const t=o.trim();return t.startsWith("--")?{name:t}:null}const n=o.slice(0,i).trim(),r=o.slice(i+1).trim();return n.startsWith("--")?{name:n,fallback:r||void 0}:null}(e);if(!o)return e;const i=()=>o.fallback?ni(t,o.fallback):e,n=t.canvas;if(!n)return i();let r=vy.get(n);r&&0===r.version||(r={version:0,map:new Map},vy.set(n,r));const s=r.map.get(e);if(void 0!==s)return s;const a=getComputedStyle(n).getPropertyValue(o.name).trim()||i()||e;return r.map.set(e,a),a}function ri(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function si(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}function ai(t,e){const{background:o="transparent",stroke:i="#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,wy.jsxs)("pattern",{id:e,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[o&&"transparent"!==o&&(0,wy.jsx)("rect",{width:c,height:c,fill:o}),(0,wy.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:i,strokeWidth:n,strokeOpacity:a}),(0,wy.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:i,strokeWidth:n,strokeOpacity:a})]},e)}function ci(t){const{nodes:e,edges:o,domain:i,plotW:n,plotH:r,ribbonLane:s,ribbonMinRun:a=0,edgeOpacity:c,colorOf:l,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:x,usageMode:b="static"}=t,v="vertical"===d?r:n,w="vertical"===d?n:r,k=function(t,e,o,i={}){const n=Ve(i.usageMode??"static"),r=[],s=new Set;for(const e of t)s.has(e.id)&&r.push({kind:"duplicate-node",id:e.id,severity:n.duplicateIds}),s.add(e.id);const a=new Set,c=Array.isArray(o)&&2===o.length,l=c&&Number.isFinite(o[0])&&Number.isFinite(o[1]);c&&l&&l&&o[1]>=o[0]||r.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]||r.push({kind:"invalid-node-time",id:e.id}));for(const t of e)a.has(t.id)&&r.push({kind:"duplicate-edge",id:t.id,severity:n.duplicateIds}),a.add(t.id),s.has(t.source)||r.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),s.has(t.target)||r.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?((null!=t.systemInTime&&!Number.isFinite(t.systemInTime)||null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime))&&r.push({kind:"invalid-system-time",id:t.id,severity:"warn"}),Number.isFinite(t.value)&&t.value>0||r.push({kind:"invalid-value",id:t.id}),t.startTime>t.endTime&&r.push({kind:"backward-edge",severity:"fatal",id:t.id,source:t.source,target:t.target})):r.push({kind:"invalid-edge-time",id:t.id});return r}(e,o,i,{usageMode:b}),{fatal:A,warnings:S}=function(t){const e=[],o=[];for(const i of t)"fatal"===He(i)?e.push(i):o.push(i);return{fatal:e,warnings:o}}(k),M=function(t,e,o="static"){if("strip"!==Ve(o).invalidSystemTime)return t;const i=new Set(e.filter(t=>"invalid-system-time"===t.kind).map(t=>t.id));return 0===i.size?t:t.map(t=>{if(!i.has(t.id))return t;const e={...t};return null==e.systemInTime||Number.isFinite(e.systemInTime)||delete e.systemInTime,null==e.systemOutTime||Number.isFinite(e.systemOutTime)||delete e.systemOutTime,e})}(o,k,b),_=(0,ly.scaleTime)().domain(i).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:_};const $=function(t,e,o){const{plotH:i,pairing:n="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half",maxValueScale:c,lanePlacement:l="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=o,p=Number.isFinite(d)?Math.max(0,d):0,y=function(t,e){const o=eo(),i=eo();for(const e of t)o[e.id]=[],i[e.id]=[];for(const t of e)i[t.source]&&i[t.source].push(t),o[t.target]&&o[t.target].push(t);return{incoming:o,outgoing:i}}(t,e),g=function(t,e,o,i="temporal"){const n="temporal"===i?(t,e)=>t.endTime-e.endTime||oo(t.id,e.id):(t,e)=>e.value-t.value||oo(t.id,e.id),r="temporal"===i?(t,e)=>t.startTime-e.startTime||oo(t.id,e.id):(t,e)=>e.value-t.value||oo(t.id,e.id),s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const o=new Map;for(const i of t){const t=i[e];o.has(t)||o.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const n=o.get(t);n.edges.push(i),n.total+=i.value,n.earliestStart=Math.min(n.earliestStart,i.startTime),n.latestEnd=Math.max(n.latestEnd,i.endTime)}const s=[...o.values()];s.sort("temporal"===i?(t,o)=>"target"===e?t.earliestStart-o.earliestStart||oo(t.partner,o.partner):t.latestEnd-o.latestEnd||oo(t.partner,o.partner):(t,e)=>e.total-t.total||oo(t.partner,e.partner));for(const t of s)t.edges.sort("target"===e?r:n);return s};for(const e of t){const t=o.outgoing[e.id],i=o.incoming[e.id];if(0===i.length)a(t,"target").forEach((t,e)=>{const o=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=o});else if(0===t.length)a(i,"source").forEach((t,e)=>{const o=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=o});else{const e=a(i,"source"),o=a(t,"target"),n=Math.max(e.length,o.length);for(let t=0;n>t;t++){const i=t%2==0?"top":"bot";if(e[t])for(const o of e[t].edges)s.get(o.id).targetSide=i;if(o[t])for(const e of o[t].edges)s.get(e.id).sourceSide=i}}}return s}(t,e,y,n);let m=eo();for(const e of t)m[e.id]=wo(e,y,g,void 0,u);const x=Ho(t,e,m,y,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),b=x.slots.map(t=>({occupants:t.occupants.map(t=>({...t})),peak:{...t.peak},...null!=t.group?{group:t.group}:{}})),v=new Set;for(const t of e){const e=x.slotByNode[t.source],o=x.slotByNode[t.target];if(void 0===e||void 0===o)continue;const i=g.get(t.id);e!==o?e>o?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(v.add(t.id),i.sourceSide="bot",i.targetSide="bot")}for(const e of t){const t=y.outgoing[e.id],o=y.incoming[e.id],i=new Set(t.map(t=>g.get(t.id).sourceSide)),n=new Set(o.map(t=>g.get(t.id).targetSide));if(1===i.size&&o.length>0){const t=[...i][0];for(const e of o)x.slotByNode[e.source]===x.slotByNode[e.target]&&(g.get(e.id).targetSide=t)}if(1===n.size&&t.length>0){const e=[...n][0];for(const o of t)x.slotByNode[o.source]===x.slotByNode[o.target]&&(g.get(o.id).sourceSide=e)}}!function(t,e,o){const i=new Map,n=[];for(const e of t)n.push({time:e.startTime,kind:"out",edge:e}),n.push({time:e.endTime,kind:"in",edge:e});n.sort((t,e)=>t.time-e.time||(t.kind===e.kind?0:"in"===t.kind?-1:1)||("out"===t.kind?e.edge.value-t.edge.value:0)||oo(t.edge.id,e.edge.id));const r=t=>{let e=i.get(t);return e||(e={top:0,bot:0},i.set(t,e)),e},s=(t,e,o)=>{const i="top"===e?"bot":"top",n=Math.min(o,t[e]);t[e]-=n;const r=o-n;r>0&&(t[i]=Math.max(0,t[i]-r))};for(const t of n){const{edge:i}=t;if("in"===t.kind){const t=e.get(i.id)?.targetSide??"bot";r(i.target)[t]+=i.value;continue}const n=r(i.source),a=e.get(i.id);let c=a.sourceSide??"bot";if(o[i.source]===o[i.target]){const t=n.top>=i.value,e=n.bot>=i.value;t!==e?c=t?"top":"bot":t||e||n.top===n.bot||(c=n.top>n.bot?"top":"bot"),a.sourceSide=c,a.targetSide=c}s(n,c,i.value)}}(e,g,x.slotByNode),function(t,e,o,i){for(const n of t){const t=e.incoming[n.id],r=e.outgoing[n.id];if(0===t.length||0===r.length)continue;const s=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const i of t)"top"===o.get(i.id).targetSide?e.inTop+=i.value:e.inBot+=i.value;for(const t of r)"top"===o.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},a=(t,e)=>{const n=s(),a="top"===t?n.outTop-n.inTop:n.outBot-n.inBot,c="top"===e?n.inTop-n.outTop:n.inBot-n.outBot;if(0>=a||0>=c)return!1;const l=Math.min(a,c),u=r.filter(e=>!i.has(e.id)&&o.get(e.id).sourceSide===t&&l>=e.value).sort((t,e)=>e.value-t.value||oo(t.id,e.id));return 0!==u.length&&(o.get(u[0].id).sourceSide=e,!0)};let c=r.length+1;for(;c-- >0&&(a("top","bot")||a("bot","top")););}}(t,y,g,v),m=eo();for(const e of t)m[e.id]=wo(e,y,g,void 0,u);const w=Ho(t,e,m,y,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((t,e,o)=>t+(null!=e.group&&e.group===w.slots[o+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*i-A*p)/S),_=2*M+no(w.slots,M,p).reduce((t,e)=>t+e,0),$=k>0?Math.max(0,(i-_)/k):1,P=Number.isFinite(c)&&c>0?Math.min($,c):$;let j=Ho(t,e,m,y,{plotH:i,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:l,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:$});const I=Number.isFinite(c)&&c>0&&$>c+1e-12;if("insertion"!==s&&("hug"===l||I)&&j.slots.length>1&&(To(t,e,m,j.laneLifetime,j.slots,j.slotByNode,{plotH:i,padding:M,valueScale:P,groupPadding:p,laneOrder:s,ribbonLane:h,domain:f,lanePlacement:l,mode:"geometry-refine"}),j=Ho(t,e,m,y,{plotH:i,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(io),lanePlacement:l,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:$})),function(t,e){const o=(t,o)=>{for(const i of t){const t=new Map;for(const n of i){const i=`${("out"===o?e.get(n.id)?.sourceSide:e.get(n.id)?.targetSide)??""}\0${"out"===o?n.startTime:n.endTime}`,r="out"===o?`${n.target}\0${n.endTime}`:`${n.source}\0${n.startTime}`,s=t.get(i);if(null!=s&&s!==r)return!0;t.set(i,r)}}return!1};return o(Object.values(t.outgoing),"out")||o(Object.values(t.incoming),"in")}(y,g)){const o=function(t,e,o,i){const n=new Map;for(const r of t){const t=e[r.source]?.localAttachments.get(r.id),s=e[r.target]?.localAttachments.get(r.id),a=o[r.source],c=o[r.target];if(!(t&&s&&Number.isFinite(a)&&Number.isFinite(c)))continue;const l=vo(t,a,i),u=vo(s,c,i);n.set(r.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return n}(e,m,j.centerlines,P);m=eo();for(const e of t)m[e.id]=wo(e,y,g,o,u);j=Ho(t,e,m,y,{plotH:i,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(io),lanePlacement:l,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:$})}const L=new Map(x.initialSlotOrder.map((t,e)=>[t,e])),R=[...j.slots].sort((t,e)=>(L.get(io(t))??1/0)-(L.get(io(e))??1/0)||oo(io(t),io(e))),T=eo();R.forEach((t,e)=>{for(const o of t.occupants)T[o.id]=e});const C=co(t,e,m,R,T,{plotH:i,padding:M,valueScale:P,stackValueScale:$,lanePlacement:"stack",groupPadding:p}),O=Vo(t,m,R,T,C.centerlines,P,p),F=mo(Io(T,e),Lo(T,e),e,O,R,T,C.centerlines,j.laneLifetime,P,C.verticalUtilization,h,f);m=Vo(t,m,j.slots,j.slotByNode,j.centerlines,P,p);const D=mo(Io(j.slotByNode,e),Lo(j.slotByNode,e),e,m,j.slots,j.slotByNode,j.centerlines,j.laneLifetime,P,j.verticalUtilization,h,f);return{nodeData:m,sides:g,valueScale:P,padding:M,compressedPadding:12>M,centerlines:j.centerlines,laneLifetime:j.laneLifetime,slots:j.slots,slotByNode:j.slotByNode,crossingsBefore:"insertion"===s?null:F.crossings,crossingsAfter:"insertion"===s?null:D.crossings,lengthBefore:"insertion"===s?null:F.weightedLength,lengthAfter:"insertion"===s?null:D.weightedLength,layoutQualityBefore:F,layoutQuality:D}}(e,M,{plotH:w,...u,ribbonLane:s,domain:i}),{centerlines:P,nodeData:j,valueScale:I}=$,L=Rt(m,x),R=[],T=[],C=0===a?new Map:function(t,e,o){const i=new Set(e.map(t=>t.target)),n=new Map(t.map(t=>[t.id,t])),r=new Map;for(const t of e){if(i.has(t.source))continue;const e=r.get(t.source)??[];e.push(t),r.set(t.source,e)}const s=new Map;for(const e of t){if(!e.group)continue;const t=s.get(e.group)??[];t.push(e),s.set(e.group,t)}const a=new Set;for(const[t,e]of s){const o=e.flatMap(t=>r.get(t.id)??[]),n=new Set(o.map(t=>t.startTime));o.length>0&&1===n.size&&e.every(t=>{const e=t.xExtent?.[0],n=o[0].startTime;return!i.has(t.id)&&(r.get(t.id)?.length??0)>0&&Number.isFinite(e)&&n>e})&&a.add(t)}const c=new Map;for(const[t,e]of r){const i=n.get(t);if(i?.group&&!a.has(i.group))continue;const r=i?.xExtent?.[0],s=[...e].sort((t,e)=>t.startTime-e.startTime||t.id.localeCompare(e.id)),l=s[0]?.startTime-1;let u=null;for(let t=0;s.length>t;){const e=s[t].startTime;let i=t+1;for(;s.length>i&&s[i].startTime===e;)i++;for(let e=t;i>e;e++){const t=s[e],i=Number.isFinite(r)&&t.startTime>r,n=Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime;if(!i&&!n)continue;let a=o[0];i&&(a=Math.max(a,r)),n&&(a=Math.max(a,t.systemInTime)),!i&&n&&Number.isFinite(l)&&(a=Math.max(a,l)),null!=u&&(a=Math.max(a,u)),t.startTime>a&&c.set(t.id,a)}u=e,t=i}}for(const[t,e]of s){if(!a.has(t))continue;const o=e.flatMap(t=>r.get(t.id)??[]);if(!o.every(t=>c.has(t.id))){for(const t of o)c.delete(t.id);continue}const i=Math.max(...o.map(t=>c.get(t.id)));for(const t of o)c.set(t.id,i)}return c}(e,M,i),O=new Map(e.filter(t=>t.group).map(t=>[t.id,t.group])),F=new Map;for(const t of M){const e=j[t.source]?.localAttachments.get(t.id),o=j[t.target]?.localAttachments.get(t.id);e&&o&&F.set(t.id,Ko(e,P[t.source],o,P[t.target],I,_,s,i,{minRun:a,sourceRunwayStart:C.get(t.id)}))}const D=function(t,e,o,i,n,r){const s=new Map(e),a=new Map;for(const e of t){const t=r?.get(e.source),o=null==t?"node:"+e.source:"group:"+t,i=a.get(o)??new Map,n=i.get(e.startTime)??[];n.push(e),i.set(e.startTime,n),a.set(o,i)}for(const t of a.values())for(const[r,a]of t){if(!a.some(t=>o.has(t.id)))continue;const t=a.map(t=>e.get(t.id));if(t.some(t=>null==t))continue;const c=i(r),l=Math.min(...t.map(t=>t.sx));if(l>=c-1e-9)continue;const u=Math.max(...a.map(t=>{const e=o.get(t.id);return null==e?c:Math.min(c,i(e))})),d=Math.min(c,Math.max(l,u));for(const t of a){const o=e.get(t.id),i=d+(o.tx-d)*("source"===n?.85:"target"===n?.15:.5);s.set(t.id,{...o,sx:d,cp1X:i,cp2X:i})}}return s}(M,F,C,_,s,O),N=function(t,e,o,i,n){const r=new Map;for(const s of t){if(!o.has(s.id))continue;const t=e.get(s.id);if(!t||t.sx>=i(s.startTime)-1e-9)continue;const a=n(t.sx);Number.isFinite(a)&&s.startTime>a&&r.set(s.id,a)}return r}(M,D,C,_,t=>i[0]+t/v*(i[1]-i[0])),z=function(t,e,o){const i=new Map,n=new Map;for(const[t,e]of o??[]){const o=n.get(e)??[];o.push(t),n.set(e,o)}for(const r of t){const t=e.get(r.id);if(null==t||!Number.isFinite(t)||t>=r.startTime)continue;const s=o?.get(r.source),a=null==s?[r.source]:n.get(s)??[r.source];for(const e of a){const o=i.get(e)??new Map,n=o.get(r.startTime);o.set(r.startTime,null==n?t:Math.min(n,t)),i.set(e,o)}}return i}(M,N,O);e.forEach((t,e)=>{const o=j[t.id];if(!o||0===o.samples.length)return;const n=(r=o.samples,(s=z.get(t.id))&&0!==s.size?r.map(t=>{const e=s.get(t.t);return null==e?t:{...t,t:e}}):r);var r,s;const a=function(t,e,o,i,n){if(0===t.length)return null;const r=bo(t,n),s=t=>e+(r[t].boundaryOffset??0)*o,a=t=>s(t)-r[t].topMass*o,c=t=>s(t)+r[t].botMass*o;let l=`M${i(r[0].t)},${a(0)}`;for(let t=1;r.length>t;t++)l+=` L${i(r[t].t)},${a(t)}`;l+=` L${i(r[r.length-1].t)},${c(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${i(r[t].t)},${c(t)}`;return l+" Z"}(n,P[t.id],I,_,i);if(!a)return;const c=bo(n,i),u=c.find(t=>t.topMass+t.botMass>0)||c[0],h=P[t.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*I/2;let f,p,y=l(t.id,e),m=y,x=.5;const b=t.__raw??t;if(g&&g.length>0){const t=Ot(b,g,L(b));"string"==typeof t.fill?y=t.fill:null!=t.fill&&ri(t.fill)&&(p=t.fill,y=t.fill.background&&"transparent"!==t.fill.background?t.fill.background:y),"string"==typeof t.stroke&&(m=t.stroke),"number"==typeof t.strokeWidth&&(x=t.strokeWidth),"number"==typeof t.fillOpacity&&(f=t.fillOpacity),"number"==typeof t.opacity&&null==f&&(f=t.opacity)}const v=function(t,e,o,i,n,r){const s=o.nodeData[t];if(!s||0===s.samples.length)return[];const a=o.valueScale,c=o.centerlines[t],l=bo(s.samples,n),u=l.find(t=>t.topMass+t.botMass>0)||l[0],d=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],h=i(u.t),f=i(d.t),p=t=>i(xo(t,n)),y=[],g=(t,e,o,i)=>`M${t},${e} L${o},${e} L${o},${i} L${t},${i} Z`;for(const o of e){if(o.source===t&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const t=s.localAttachments.get(o.id),e=r?.get(o.id)??o.startTime;if(t&&"out"===t.kind&&e>o.systemInTime){const i=p(o.systemInTime),r=p(e),s=null!=n&&n[0]>o.systemInTime,l=s?i:i-20,u=s?Math.min(r,i+20):i,d=Math.max(h,l);if(r>d){const[e,o]=vo(t,c,a);y.push({pathD:g(d,e,r,o),x0:l,x1:u,from:0,to:1})}}}if(o.target===t&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const t=s.localAttachments.get(o.id);if(t&&"in"===t.kind&&o.systemOutTime>o.endTime){const e=p(o.systemOutTime),i=p(o.endTime),n=e+20,r=Math.min(f,n);if(r>i){const[o,s]=vo(t,c,a);y.push({pathD:g(i,o,r,s),x0:e,x1:n,from:1,to:0})}}}}return y}(t.id,M,$,_,i,N);R.push({id:t.id,pathD:a,fill:y,stroke:m,strokeWidth:x,...null!=f&&{fillOpacity:f},...p&&{hatchFill:p},...v.length>0&&{gradientStubs:v},rawDatum:b,labelX:_("vertical"===d&&t.xExtent?t.xExtent[0]:u.t)-4,labelY:h,labelText:t.label??t.id})});const E=new Map;e.forEach((t,e)=>E.set(t.id,e)),M.forEach(t=>{const e=D.get(t.id);if(!e)return;const o=E.get(t.source)??0,i=l(t.source,o),{pathD:n,bezier:r}=Uo(e),s=t.__raw??t,a="function"==typeof c?Number(c(s)):c,u=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.35;T.push({id:t.id,pathD:n,fill:i,opacity:u,rawDatum:s,bezier:r})});const B=function(t,e,o){const i=t.map(t=>({...t})),n=new Map;for(const t of i){const o=e[t.id];if(null==o)continue;const i=n.get(o)??[];i.push(t),n.set(o,i)}const r=t=>{if(2>t.length)return;const e=t.reduce((t,e)=>t+e.labelY,0)/t.length,i=(t.length-1)/2;t.forEach((t,n)=>{t.labelY=Math.max(8,Math.min(o-8,e+16*(n-i)))})};for(const t of n.values()){t.sort((t,e)=>t.labelX-e.labelX||t.id.localeCompare(e.id));let e=[],o=-1/0;for(const i of t){const t=i.labelX-Zo(i.labelText);e.length>0&&t>o+3&&(r(e),e=[],o=-1/0),e.push(i),o=Math.max(o,i.labelX)}r(e)}return function(t,e){const o=[...t].sort((t,e)=>t.labelY-e.labelY||t.labelX-e.labelX||t.id.localeCompare(e.id));for(let t=0;3>t;t+=1){for(let t=0;o.length>t;t+=1){let e=8;for(let i=0;t>i;i+=1)Jo(o[t],o[i])&&(e=Math.max(e,o[i].labelY+16));o[t].labelY=Math.max(o[t].labelY,e)}for(let t=o.length-1;t>=0;t-=1){let i=e-8;for(let e=t+1;o.length>e;e+=1)Jo(o[t],o[e])&&(i=Math.min(i,o[e].labelY-16));o[t].labelY=Math.min(o[t].labelY,i)}}}(i,o),i}(R,$.slotByNode,w).map(t=>function(t,e){return"horizontal"===e?t:{...t,pathD:ti(t.pathD),gradientStubs:t.gradientStubs?.map(oi),labelX:t.labelY,labelY:t.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(t,d)),W="vertical"===d?function(t,e,o){const i=t.map(t=>({...t}));for(const t of i){const o=1.22*Zo(t.labelText)+4;t.labelX=e-4>o?Math.max(o/2+2,Math.min(e-o/2-2,t.labelX)):e/2}const n=[],r=[...i].sort((t,e)=>t.labelY-e.labelY||t.labelX-e.labelX);for(const t of r){const e=n[n.length-1];!e||Math.abs(e[0].labelY-t.labelY)>14?n.push([t]):e.push(t)}for(const t of n){t.sort((t,e)=>t.labelX-e.labelX||t.id.localeCompare(e.id));const e=[],i=new Map;for(const o of t){const[t,n]=Qo(o);let r=e.findIndex(e=>t>e+8);-1===r&&(r=e.length),e[r]=n,i.set(o,r)}const n=t.reduce((t,e)=>t+e.labelY,0)/t.length,r=14*e.length+8>n;for(const e of t){const t=i.get(e)??0;e.labelY=r?Math.min(o-8,12+14*t):Math.max(8,n-14*t)}}return i}(B,n,r):B,Y=new Map;if(null!=f)for(const t of e){const e=t.__raw??t,o="function"==typeof f?f(e):Number(e[f]);Number.isFinite(o)&&Y.set(t.id,o)}const q=function(t,e,o,i,n={}){if(!1===i)return t.map(t=>({...t,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===i)return t.map(t=>({...t,labelDeferred:!1,labelFullText:void 0}));let r=Math.max(4,Math.min(t.length,Math.floor(Math.max(1,e*o)/14e3)));Number.isFinite(n.maxLabels)&&n.maxLabels>=0&&(r=Math.min(r,Math.floor(n.maxLabels)));const s=t.map((t,e)=>{const o=n.priorityById?.get(t.id),i=Math.abs(t.labelY);return{band:t,index:e,score:null!=o&&Number.isFinite(o)?1e6*o+Zo(t.labelText):Zo(t.labelText)+.01*i}}).filter(t=>t.band.labelText.trim().length>0).sort((t,e)=>e.score-t.score||t.index-e.index||t.band.id.localeCompare(e.band.id)),a=new Set(s.slice(0,r).map(t=>t.band.id));return t.map(t=>a.has(t.id)||0===t.labelText.trim().length?{...t,labelDeferred:!1,labelFullText:void 0}:{...t,labelFullText:t.labelText,labelText:"",labelDeferred:!0})}(W,n,r,h,{...Y.size>0&&{priorityById:Y},...null!=p&&{maxLabels:p}});return{layout:$,layoutConfig:{bands:q,ribbons:T.map(t=>function(t,e){return"horizontal"===e?t:{...t,pathD:ti(t.pathD),bezier:ei(t.bezier)}}(t,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function li(t,e,o){return!e?.isActive||e.predicate(function(t,e){return"scene"===e?t:t.data}(t,o))}function ui(t,e){if(!t)return[];const o=[],i=t=>{o.push(t);const n="function"==typeof e?e(t):t[e];n&&Array.isArray(n)&&n.forEach(i)};return i(t),o}function di(t,e,o,i){if(t&&t.length>0)return t;const n=new Set;return e.forEach(t=>{const e="function"==typeof o?o(t):t[o],r="function"==typeof i?i(t):t[i];n.add(e),n.add(r)}),Array.from(n).map(t=>({id:t}))}function hi(t,e,o={}){return jt(e?"function"==typeof e?o=>({...t(o),...e(o)??{}}):o=>({...t(o),...e}):t,o)}function fi(t,e,o){const[i,n]=o;if(!e)return i;const[r,s]=e,a=s>r?s-r:0,c=Number(t),l=Number.isFinite(c)?c:r;return i+Math.max(0,Math.min(1,a>0?(l-r)/a:0))*(n-i)}function pi(t){const{valueAccessor:e,valueDomain:o,edgeWidthRange:i,resolveStroke:n,edgeOpacity:r,edgeLinecap:s,styleRules:a}=t,c=It(e);return Ft(t=>({stroke:n(t),strokeWidth:fi(t[e],o,i),strokeLinecap:s,opacity:r,fillOpacity:0}),a,t=>({value:c(t)}))}function yi(t,e,o,i){const n=Array.isArray(t)?t:[];let r,s;if(e){const t="string"==typeof e?e:"__geoColorBy",i="string"==typeof e?n:n.map(t=>({...t,__geoColorBy:e(t)}));r=_t(i,t,o)}if(i.sizeBy){const t=n.map("function"==typeof i.sizeBy?i.sizeBy:t=>t?.[i.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=te(t))}return t=>({fill:e&&r?St(t,e,r):sp,fillOpacity:i.fillOpacity,stroke:"#fff",strokeWidth:i.strokeWidth,r:i.sizeBy?$t(t,i.sizeBy,i.sizeRange,s):i.pointRadius??6})}function gi(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}function mi(t){return`${t.getUTCFullYear()}-${xi(t.getUTCMonth()+1)}-${xi(t.getUTCDate())}`}function xi(t){return 10>t?"0"+t:t+""}function bi(t,e={}){const o=e.baseOpacity??1;return e.highlight||e.predicate?!function(t,e){if(!e)return!0;const o=Array.isArray(e)?e:[e],i=t;for(const t of o)if(null!=t.value&&i[t.field]+""!=t.value+"")return!1;return!0}(t,e.highlight)||e.predicate&&!e.predicate(t)?e.dimOpacity??.16:Math.min(1,o+(e.brighten??0)):o}function vi(t){const e=t.fontSize??12;return null!=t.maxWidth&&t.text.length*e*.56>t.maxWidth?null:(0,Hy.jsx)("text",{className:t.className,x:t.x,y:t.y,textAnchor:t.anchor??"middle",dominantBaseline:t.baseline??"middle",fontSize:e,fontWeight:t.fontWeight,fill:t.color,style:{pointerEvents:"none"},children:t.text},t.keyId)}function wi(t){const[e,o]=t,i=160>e||116>o,n=i?Math.min(12,Math.max(2,.08*e)):32,r=i?Math.min(8,Math.max(2,.12*o)):24,s=i?r:34;return{width:e,height:o,plot:{x:n,y:r,width:Math.max(1,e-2*n),height:Math.max(1,o-r-s)}}}function ki(t){const e=(t??"")+"";if(!e)return"#4e79a7";const o=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let i=0;for(let t=0;e.length>t;t+=1)i=31*i+e.charCodeAt(t)>>>0;return o[i%o.length]}function Ai(t,e="#4e79a7",o){const i=o?.styleRules,n=!!i&&i.length>0,r=n?It(o?.valueAccessor):void 0;return o=>{const s=o.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,c={fill:null==a?e:ki(a),stroke:"#111827",strokeWidth:1,opacity:.9};return n&&s&&Object.assign(c,Ot(s,i,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function Si(t,e,o,i){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:o},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...i}}}function Mi(t,e,o){return"function"==typeof o?o(t,e):t[o]}function _i(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 $i(t,e,o){return Math.max(e,Math.min(o,t))}function Pi(t,e){const o=_i(t);return null!=o&&o>0?o:e}function ji(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Ii(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}}function Li(t,e,o=0){const i=new Set(t.filter(t=>null!=t.id).map(t=>t.id+"")),n=new Map;for(const r of t){let t=null==r.id?`${e}-${o++}`:r.id+"";for(;null==r.id&&i.has(t);)t=`${e}-${o++}`;i.add(t),n.set(t,null==r.id?{...r,id:t}:r)}return{seed:t,rows:Array.from(n.values()),nextId:o}}function Ri(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}}function Ti(t){const e=t.fixedPosition;Number.isFinite(e?.x)&&(t.x=t.prevX=e.x,t.vx=0),Number.isFinite(e?.y)&&(t.y=t.prevY=e.y,t.vy=0)}function Ci(t){if(!t)return;const e=Number.isFinite(t.x)?t.x:void 0,o=Number.isFinite(t.y)?t.y:void 0;return null==e&&null==o?void 0:{x:e,y:o}}function Oi(t,e,o){const i="x"===o?"y":"x",n=Math.abs(e[o]-t[o]),r=e[i]-t[i],s=(t,e)=>"circle"===t.shape.type?t.shape.radius:("x"===e?t.shape.width:t.shape.height)/2;let a;if("circle"===t.shape.type&&"circle"===e.shape.type){const o=t.shape.radius+e.shape.radius;a=Math.sqrt(Math.max(0,o*o-n*n))}else if("aabb"===t.shape.type&&"aabb"===e.shape.type)a=s(t,i)+s(e,i);else{const r="aabb"===t.shape.type?t:e,c=s("circle"===t.shape.type?t:e,o),l=Math.max(0,n-s(r,o));a=s(r,i)+Math.sqrt(Math.max(0,c*c-l*l))}const c=0>r?-1:1;return{nx:"x"===i?c:0,ny:"y"===i?c:0,penetration:Math.max(0,a-Math.abs(r))}}function Fi(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function Di(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 Ni(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,...t.fixedPosition?{fixedPosition:Ci(t.fixedPosition)}:{},shape:Fi(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function zi(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 Ei(t){return{id:t.id,shape:Di(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:zi(t.bodyFilter),index:t.index}}function Bi(t,e,o){return Math.max(e,Math.min(o,t))}function Wi(t,e,o){return Math.min(t??o,e??o)}function Yi(t,e,o){return Bi(Math.max(t??o,e??o),0,1)}function qi(t){return 0>t?-1:1}function Xi(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,o=t.shape.height/2;return{minX:t.x-e,minY:t.y-o,maxX:t.x+e,maxY:t.y+o}}function Gi(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,o=e.height/2;return{minX:e.x-t,minY:e.y-o,maxX:e.x+t,maxY:e.y+o}}const o=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-o,minY:Math.min(e.y1,e.y2)-o,maxX:Math.max(e.x1,e.x2)+o,maxY:Math.max(e.y1,e.y2)+o}}function Vi(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function Hi(t,e,o,i,n,r,s,a){const c=n-t,l=(o+s)/2-Math.abs(c);if(0>=l)return null;const u=r-e,d=(i+a)/2-Math.abs(u);return d>0?d>l?{nx:qi(c),ny:0,penetration:l}:{nx:0,ny:qi(u),penetration:d}:null}function Ui(t,e,o,i,n,r,s){const a=r/2,c=s/2,l=t-Bi(t,i-a,i+a),u=e-Bi(e,n-c,n+c),d=l*l+u*u;if(d>o*o)return null;if(ig>=d){const r=Math.abs(t-(i-a)),s=Math.abs(t-(i+a)),l=Math.abs(e-(n-c)),u=Math.abs(e-(n+c)),d=Math.min(r,s,l,u);return d===r?{nx:-1,ny:0,penetration:o+r}:d===s?{nx:1,ny:0,penetration:o+s}:d===l?{nx:0,ny:-1,penetration:o+l}:{nx:0,ny:1,penetration:o+u}}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:o-h}}function Ki(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,o,i,n,r){const s=i-t,a=n-e,c=o+r,l=s*s+a*a;if(l>=c*c)return null;if(ig>=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 Hi(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 o=Ui(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return o?{nx:-o.nx,ny:-o.ny,penetration:o.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?Ui(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function Zi(t,e){const o=e.shape;return"aabb"===o.type?"circle"===t.shape.type?Ui(t.x,t.y,t.shape.radius,o.x,o.y,o.width,o.height):Hi(o.x,o.y,o.width,o.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,o,i,n,r,s,a=0){const c=r-i,l=s-n,u=c*c+l*l,d=u>ig?Bi(((t-i)*c+(e-n)*l)/u,0,1):0,h=o+a/2,f=t-(i+c*d),p=e-(n+l*d),y=f*f+p*p;if(y>=h*h)return null;if(ig>=y){const t=Math.sqrt(u);return t>ig?{nx:-l/t,ny:c/t,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,o.x1,o.y1,o.x2,o.y2,o.thickness??0)}function Qi(t,e){return`${t}\0${e}`}function Ji(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function tn(t,e){return!!e?.some(e=>Object.is(t,e))}function en(t,e){return function(t,e){if(!e)return!0;if("function"==typeof e)return e(t);const o=function(t,e){if(!e)return;let o=t;for(const t of e.split(".")){if(null==o||"object"!=typeof o)return;if(!Object.prototype.hasOwnProperty.call(o,t))return;o=o[t]}return o}(t,e.property);return!("equals"in e&&!Object.is(o,e.equals)||"notEquals"in e&&Object.is(o,e.notEquals)||e.oneOf&&!tn(o,e.oneOf)||e.notOneOf&&tn(o,e.notOneOf))}(e,t.bodyFilter)}function on(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new sg(t)}(e)}function nn(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 o=e-t.mean;t.mean+=o/t.count,t.m2+=o*(e-t.mean)}function rn(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 sn(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 an(t,e){if(null!=t[e])return t[e];const o=t.datum;return o&&"object"==typeof o?o[e]:void 0}function cn(t,e,o){return"function"==typeof t?t(e,o):"string"==typeof t?an(e,t):void 0}function ln(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function un(t){const e=rn(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:rn(t.x),y:rn(t.y),value:e}}function dn(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}function hn(t={},e=ug){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 fn(t){return{...t,shape:{...t.shape},...t.fixedPosition?{fixedPosition:{...t.fixedPosition}}:{},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function pn(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 yn(t,e){if(null!=t[e])return t[e];const o=t.datum;return o&&"object"==typeof o?o[e]:void 0}function gn(t){return{...fn(t),sequence:t.sequence,spawnAt:t.spawnAt}}function mn(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 xn(t){return!1!==t&&{...t}}function bn(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function vn(t){return{...t,gravity:{...t.gravity}}}function wn(t,e,o,i){if("circle"===t.shape.type){const n=t.x-e,r=t.y-o,s=t.shape.radius+i,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(o-t.y)-t.shape.height/2,0),s=n*n+r*r;return s>i*i?null:s}function kn(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function An(t,e={}){const{idPrefix:o="plot",includeFloor:i=!0,includeCeiling:n=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,d=t.y+t.height/2;return i&&l.push({id:o+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),n&&l.push({id:o+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),r&&l.push({id:o+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:d,width:a,height:t.height+2*c}}),s&&l.push({id:o+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:d,width:a,height:t.height+2*c}}),l}function Sn(t){const{idPrefix:e="bin",count:o,domainStart:i,domainStep:n,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?o:o-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&o>t)continue;const s=r(i+t*n);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let t=0;o>t;t+=1){const o=i+t*n,s=o+n;if(s>=d)continue;const a=r(o),l=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}function Mn(t,e){const o={...t};for(const t of e)o[dg[t]]++;return o}function _n(t,e,o){const i=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:i,revisions:Mn(o,i)}}function $n(t){let e="preserve";const o=new Set;for(const i of t){const t=kg[i]??Ag;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}function Pn(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&Sg.every(o=>t[o]===e[o])}function jn(t,e,o,i){return t||!e?"paused":o||!i?"running":"settled"}function In(t,e,o,i={}){let n,r=0;for(;e>r&&!i.shouldStop?.()&&(!1===i.stopAtRest||t.queueSize()>0||!t.atRest()||i.continueWhile?.());){t.step(t.fixedDt),t.advanceTime(t.fixedDt);const e=t.drainEvents();o.events&&(o.events.push(...e),t.observeKernelEvents(e,o.observations),t.observeSensorTransitions(o.observations));const s=[];if(t.spawnDue(s,o.observations),s.length>0){o.spawned.push(...s),n=t.observeBodyBudget(o.observations);const e=t.evictOverflow(o.observations);o.evicted?.push(...e.evicted),o.sedimented?.push(...e.sedimented)}r+=1,t.refreshQuiescence(t.fixedDt,s.length),i.afterStep?.()}return{steps:r,budget:n}}function Ln(t,e,o,i){const{windowPlot:n,lidSegments:r}=t,s=r[e];return o&&!s?Math.min(n.y+n.height-i,n.y+.48*n.height+2*i+4):!o&&s?Math.min(n.y+n.height-i,Math.max(s.y1,s.y2)+2*i+4):n.y+i+2}function Rn(t,e,o,i,n){const{windowPlot:r,windowCount:s,windowStart:a,windowSize:c}=i;if(o&&e>=i.closedWindowCount)return i.gutter.x+i.gutter.width/2;const l=r.width/s,u=o?r.x:r.x+e*l,d=o?r.x+r.width:u+l,h=Math.min((d-u)/2,n+(o?0:3));return Math.max(u+h,Math.min(d-h,r.x+(t-a)/c*l))}function Tn(t,e,o){const i=t.width/Math.max(1,e),n=Math.max(2,2*o),r=Math.min(.7*i,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(r/n));return{laneWidth:i,tubeWidth:r,ballDiameter:n,perRow:s,centerX:e=>t.x+(e+.5)*i,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*n}}function Cn(t,e,o,i){const n=(e+o)/2,r=[];for(const s of t){const a=r.filter(t=>s.radius+t.radius+.5>Math.abs(s.x-t.x)),c=[n];for(const t of a){const e=Math.sqrt((s.radius+t.radius+.5)**2-(s.x-t.x)**2);c.push(t.y-e,t.y+e)}const l=.5>i()?-1:1;c.sort((t,e)=>Math.abs(t-n)-Math.abs(e-n)||l*(t-e));const u=c.find(t=>t-s.radius>=e&&o>=t+s.radius&&a.every(e=>(s.x-e.x)**2+(t-e.y)**2>=(s.radius+e.radius+.5)**2-1e-6));if(null==u){const i=Math.max(...t.map(t=>t.radius)),r=Math.max(0,o-e-2*i);return{positions:t.map((e,o)=>n+(1===t.length?0:o/(t.length-1)-.5)*r),overlapping:!0,entryOffset:0}}r.push({...s,y:u})}return{positions:r.map(t=>t.y),overlapping:!1,entryOffset:Math.max(0,Math.min(36,...r.map(t=>t.y-t.radius-e)))}}function On(t){if(Array.isArray(t)&&t.length>=2){const e=_i(t[0]),o=_i(t[1]);return null!=e&&null!=o?{x:e,y:o}:null}if(t&&"object"==typeof t){const e=t,o=_i(e.x),i=_i(e.y);return null!=o&&null!=i?{x:o,y:i}:null}return null}function Fn(t){return Array.isArray(t)?t.map(On).filter(t=>null!=t):[]}function Dn(t,e,o){return"normalized"===o?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:$i(t.x,e.plot.x,e.plot.x+e.plot.width),y:$i(t.y,e.plot.y,e.plot.y+e.plot.height)}}function Nn(t){let e=0;for(let o=1;t.length>o;o+=1)e+=Math.hypot(t[o].x-t[o-1].x,t[o].y-t[o-1].y);return e}function zn(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const o=$i(e,0,1)*Nn(t);let i=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(i+s>=o){const t=(o-i)/s;return{x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t}}i+=s}}return{...t[t.length-1]}}function En(t,e){const o=zn(t,Math.max(0,e-.02)),i=zn(t,Math.min(1,e+.02)),n=i.x-o.x,r=i.y-o.y,s=Math.hypot(n,r)||1;return{x:n/s,y:r/s}}function Bn(t,e,o){return Math.max(e,Math.min(o,t))}function Wn(t,e,o,i,n,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:o,x2:i,y2:n,thickness:r.thickness??8}}}function Yn(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,o=t.y,i=t.width,n=t.height,{type:"aabb",x:e,y:o,width:i,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,o,i,n}function qn(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Yn({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Xn(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 Gn(t,e,o){return At(t,e,o)}function Vn(t,e){const o=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>o&&Mt(o,t)||"#4e79a7":e=>{if(o){const t=Mt(o,e);if(t)return t}let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return t[Math.abs(i)%t.length]??"#4e79a7"}}function Hn(t,e){const o=e.config??{},i=(e.sensors??[]).map(t=>({...t,sensor:!0})),n=[...e.colliders??[],...i],r=[...t.colliders??[],...o.colliders??[],...n];return{...t,...o,observation:{...t.observation,...o.observation},...r.length>0&&{colliders:r}}}function Un(t){const e=tr(t);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:e.top,x2:e.left,y2:t.floorY,thickness:e.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:e.top,x2:t.width-e.rightInset,y2:e.top,thickness:e.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:t.floorY,x2:t.width-e.rightInset,y2:t.floorY,thickness:e.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-e.rightInset,y1:e.top,x2:t.width-e.rightInset,y2:t.floorY,thickness:e.thickness}}]}function Kn(t,e,o,i){return o?"function"==typeof o?o(t,e):t[o]??i:i}function Zn(t){return`gauntlet:${t}:core`}function Qn(t,e){return`gauntlet:${t}:positive:${e}`}function Jn(t,e,o){return`gauntlet:${t}:negative:${e}:${o}`}function tr(t){const e=t.height??t.floorY+36;if(t.width>=220&&e>=160)return Lg;const o=Math.max(1,Math.min(t.width,e)),i=Math.max(2,.04*t.width);return{left:i,top:Math.max(2,.08*e),rightInset:i,thickness:Math.max(1,Math.min(4,.04*o))}}function er(t){return Math.max(.12,Math.min(1,t.width/500,(t.height??t.floorY+36)/260))}function or(t,e,o,i){const n=tr(i),r=Math.max(2,o+2),s=n.top+n.thickness/2+r,a=i.floorY-r,c=(t,e,o)=>e>o?(e+o)/2:Math.max(e,Math.min(o,t));return{x:c(t,n.left+n.thickness/2+r,i.width-n.rightInset-n.thickness/2-r),y:c(e,s,a)}}function ir(t,e,o=1){const i=[...t].sort((t,e)=>t.localeCompare(e)),n=Math.max(0,i.indexOf(e));return{angle:.82*-Math.PI+(i.length>1?n/(i.length-1):.5)*Math.PI*.64,index:n,radius:(48+n%2*6)*o}}function nr(t,e,o){const i=t.activePositiveIds.reduce((t,o)=>t+(e.get(o)?.value??1),0),n=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(o.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*r-1.2*t.delay-5*n))}function rr(t){const e=function(t,e,o){const[i,n]=t,r=220>i||160>n,s=Math.round(.48*n),a=r?n-Math.max(3,Math.min(12,.1*n)):n-36,c=(e??[]).filter(t=>!1!==t.enabled),l=Math.max(1,c.length),u=.22*i,d=l>1?(.78*i-u)/(l-1):0,h=r?Math.max(Math.round(.12*i),.08*i+6):Math.max(Math.round(.14*i),110);return{crashY:a-(r?Math.min(o,Math.max(3,.22*n)):o),floorY:a,gates:c.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(u+e*d),width:t.width??Math.max(r?8:54,Math.round(.07*i))})),graveyardX:Math.round(i*(r?.72:.84)),graveyardY:a-4,height:n,routeY:s,socketX:Math.round(i*(r?.82:.92)),startX:h,width:i}}(t.size??[900,520],t.gates,t.crashOffset??30),o=t.positiveProperties??[],i=new Map(o.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,o,i,n){const r=Kn(t,e,o.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=i.map(t=>t.id),a=[...Kn(t,e,o.positiveAccessor,s)],c=[...Kn(t,e,o.negativeAccessor,[])].filter(t=>n.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Kn(t,e,o.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Kn(t,e,o.startTimeAccessor,0))||0),stage:"project filed",viability:Kn(t,e,o.initialViability,100)}}(e,s,r,o,n);return{...a,viability:t.viability?.(a,{negativeProperties:n,positiveProperties:i})??nr(a,i,n)}}),a=s.flatMap((o,r)=>{const s=function(t,e,o,i){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}}(o),r=i?.(t,e,o)??{};return{...n,...r,startY:r.startY??r.routeY??n.startY,socketY:r.socketY??r.routeY??n.socketY,graveyardY:r.graveyardY??n.graveyardY}}(o,r,e,t.projectPlacement);return function(t,e,o,i,n,r,s){const a=er(o),c=Math.max(3,28*a),l=i.startX,u=i.startY+(i.startY===o.routeY?38*e*a:0),d=s?.(t,e,o,i)??{},h=d.x??l,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},y=[{...d,id:Zn(t.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??t.startedAt,datum:p}],g=or(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,o);y[0].x=g.x,y[0].y=g.y;for(const e of t.activePositiveIds){const i=n.get(e);if(!i)continue;const r=ir(t.activePositiveIds,e,a),s=i.radius??Math.max(2,10*a),c=or(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,o);y.push({id:Qn(t.id,e),x:c.x,y:c.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:i,sourceDatum:t.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:Zn(t.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+r.index%2*4)*a),...i.spring??{}}]})}return t.negativeIds.forEach((e,i)=>{const n=r.get(e);n&&y.push(function(t,e,o,i,n,r,s){const a=er(r),c=e.radius??Math.max(2,7.2*a),l=or(i+(o%4*12-12)*a,n+(54+12*Math.floor(o/4))*a,c,r);return{id:Jn(t.id,e.id,o),x:l.x,y:l.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:Ig,projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:Zn(t.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+o%4*3)*a),...e.spring??{}}]}}(t,n,i,g.x,g.y,o,d.spawnAt??t.startedAt))}),y}(o,r,e,s,i,n,t.coreBody)});return{layout:e,states:s,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:Un(e)}}}function sr(t=[]){const e=Object.create(null);for(const[o,i]of t)e[o]=i;return e}function ar(...t){const e=sr();for(const o of t)for(const[t,i]of Object.entries(o??{}))e[t]=i;return e}function cr(t){return ar(t)}function lr(t){return t.map(t=>({...t,sourceIds:t.sourceIds?[...t.sourceIds]:void 0,productIds:t.productIds?[...t.productIds]:void 0,relationIds:t.relationIds?[...t.relationIds]:void 0,outletIds:t.outletIds?[...t.outletIds]:void 0}))}function ur(t){const e=sr(Object.entries(t.components).map(([t,e])=>[t,{...e,initialMetrics:cr(e.initialMetrics),metrics:cr(e.metrics),productIds:[...e.productIds],history:lr(e.history)}])),o=sr(Object.entries(t.products).map(([t,e])=>[t,{...e,metrics:cr(e.metrics),sourceIds:[...e.sourceIds],history:lr(e.history)}])),i=sr(Object.entries(t.relations).map(([t,e])=>[t,{...e,sourceIds:[...e.sourceIds],metrics:e.metrics?cr(e.metrics):void 0}]));return{...t,eventsApplied:[...t.eventsApplied],components:e,products:o,relations:i,input:{amount:t.input.amount,metrics:cr(t.input.metrics)},metrics:cr(t.metrics),loss:{amount:t.loss.amount,metrics:cr(t.loss.metrics)},history:lr(t.history)}}function dr(t,e){return e>t?-1:t>e?1:0}function hr(t,e,o,i,n){return{severity:t,code:e,message:o,path:i,ids:n?[...n]:void 0}}function fr(t){const e=new Set,o=new Set;for(const i of t)e.has(i)&&o.add(i),e.add(i);return[...o].sort(dr)}function pr(t,e){return t?Object.entries(t).flatMap(([t,o])=>Number.isFinite(o)?[]:[hr("error","invalid-metric",`Metric "${t}" must be a finite number.`,`${e}.${t}`)]):[]}function yr(t,e){for(const[o,i]of Object.entries(e))t[o]=Number(t[o]??0)+i}function gr(t,e,o="selector"){const i=[],n=Object.values(t.components),r=new Set(n.map(t=>t.id)),s=(e.ids??[]).filter(t=>!r.has(t));if(s.length&&i.push(hr("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,o+".ids",s)),void 0===e.count||Number.isInteger(e.count)&&e.count>=0||i.push(hr("error","invalid-selector-count","Selector count must be a non-negative integer.",o+".count")),i.some(t=>"error"===t.severity))return{ids:[],diagnostics:i};const a=e.ids?new Set(e.ids):null,c=e.categories?new Set(e.categories):null,l=e.statuses?new Set(e.statuses):null,u=e.outletIds?new Set(e.outletIds):null;let d=n.filter(t=>!a||a.has(t.id)).filter(t=>!c||c.has(t.category)).filter(t=>!l||l.has(t.status)).filter(t=>!u||void 0!==t.outletId&&u.has(t.outletId)).map(t=>t.id).sort(dr);return void 0!==e.count&&(d=d.slice(0,e.count)),d.length||i.push(hr("warning","empty-selector","Selector matched no source components.",o)),{ids:d,diagnostics:i}}function mr(t,e,o={}){return{eventId:t.event.id,effectType:e.type,phaseId:t.context.phaseId,authoredAt:t.context.authoredAt,appliedAt:t.context.appliedAt,label:t.event.label,summary:t.event.summary,...o}}function xr(t,e){const o={...e,eventId:t.event.id};t.materializations.push(o),t.observations.push({...o,phaseId:t.context.phaseId,authoredAt:t.context.authoredAt,appliedAt:t.context.appliedAt})}function br(t,e,o){return!(void 0!==e&&!t.outletIds.has(e)&&(t.diagnostics.push(hr("error","unknown-outlet",`Unknown outlet "${e}".`,o,[e])),1))}function vr(t,e,o){const i=fr(e);e.length||t.diagnostics.push(hr("error","empty-source-list","A product requires at least one source component.",o)),i.length&&t.diagnostics.push(hr("error","duplicate-source",`Source ids may appear only once: ${i.join(", ")}.`,o,i));const n=e.filter(e=>!t.state.components[e]);n.length&&t.diagnostics.push(hr("error","unknown-component",`Unknown source component id${1===n.length?"":"s"}: ${n.join(", ")}.`,o,n));const r=e.filter(e=>(t.state.components[e]?.productIds.length??0)>0);r.length&&t.diagnostics.push(hr("error","source-already-assigned",`Source component${1===r.length?" is":"s are"} already assigned: ${r.join(", ")}.`,o,r));const s=e.filter(e=>"consumed"===t.state.components[e]?.status&&!r.includes(e));return s.length&&t.diagnostics.push(hr("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,o,s)),t.diagnostics.some(t=>"error"===t.severity)?null:e.map(e=>t.state.components[e])}function wr(t,e,o,i,n){const r=i?.amount??0;(!Number.isFinite(r)||0>r||r>e+Rg)&&t.diagnostics.push(hr("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",n+".amount")),t.diagnostics.push(...pr(i?.metrics,n+".metrics"));for(const[e,r]of Object.entries(i?.metrics??{}))(0>r||r>Number(o[e]??0)+Rg)&&t.diagnostics.push(hr("error","invalid-metric-loss",`Metric loss "${e}" must be non-negative and no greater than its sources.`,`${n}.metrics.${e}`));return!t.diagnostics.some(t=>"error"===t.severity)}function kr(t,e,o,i,n,r,s){return{id:t.id,label:t.label??t.id,description:t.description,category:t.category??"product",color:t.color,order:t.order,declaredAmount:t.amount,amount:r&&void 0!==t.amount?t.amount:o,metrics:r&&t.metrics?ar(i,t.metrics):cr(i),status:r?"complete":"forming",sourceIds:[...e],outletId:r?t.outletId??(n.outletIds.has("product")?"product":void 0):void 0,createdByEventId:n.event.id,createdAt:n.context.appliedAt,completedByEventId:r?n.event.id:void 0,completedAt:r?n.context.appliedAt:void 0,history:[s]}}function Ar(t,e,o,i){void 0!==e.amount&&Math.abs(e.amount-o)>Rg&&t.diagnostics.push(hr("warning","declared-product-amount-mismatch",`Product "${e.id}" declares ${e.amount}, while its sources yield ${o}.`,i,[e.id]))}function Sr(t,e,o){const i=`events.${t.event.id}.effects.${o}`,n=t.state;if("set-state"===e.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(e.state)||t.diagnostics.push(hr("error","invalid-component-state",`set-state cannot assign "${e.state+""}".`,i+".state")),t.diagnostics.push(...pr(e.metricsDelta,i+".metricsDelta")),br(t,e.outletId,i+".outletId");const o=gr(n,e.select,i+".select");t.diagnostics.push(...o.diagnostics);const r=o.ids.filter(t=>n.components[t].productIds.length);if(r.length&&t.diagnostics.push(hr("error","source-already-assigned",`Assigned source components cannot be retargeted: ${r.join(", ")}.`,i+".select",r)),t.diagnostics.some(t=>"error"===t.severity))return;const s=mr(t,e,{sourceIds:o.ids,outletIds:e.outletId?[e.outletId]:void 0});for(const t of o.ids){const o=n.components[t];o.status=e.state,o.outletId=e.outletId,o.reason=e.reason,e.metricsDelta&&yr(o.metrics,e.metricsDelta),o.history.push(s)}return n.history.push(s),void(o.ids.length&&xr(t,{type:"retarget-component",sourceIds:o.ids,outletIds:e.outletId?[e.outletId]:void 0}))}if("set-relation"===e.type){const{relation:o}=e;o.id&&!n.relations[o.id]||t.diagnostics.push(hr("error","duplicate-relation",`Relation id "${o.id}" is missing or already active.`,i+".relation.id",[o.id]));const r=function(t,e,o){const i=fr(e),n=e.filter(e=>!t.state.components[e]);return 2>e.length&&t.diagnostics.push(hr("error","insufficient-relation-sources","A relation requires at least two source components.",o)),i.length&&t.diagnostics.push(hr("error","duplicate-source",`Relation source ids must be unique: ${i.join(", ")}.`,o,i)),n.length&&t.diagnostics.push(hr("error","unknown-component",`Relation references unknown source component${1===n.length?"":"s"}: ${n.join(", ")}.`,o,n)),t.diagnostics.some(t=>"error"===t.severity)?null:e.map(e=>t.state.components[e])}(t,o.sourceIds,i+".relation.sourceIds");if(t.diagnostics.push(...pr(o.metrics,i+".relation.metrics")),!r||t.diagnostics.some(t=>"error"===t.severity))return;n.relations[o.id]={...o,sourceIds:[...o.sourceIds],metrics:o.metrics?cr(o.metrics):void 0,status:"active",createdByEventId:t.event.id,createdAt:t.context.appliedAt};const s=mr(t,e,{sourceIds:[...o.sourceIds],relationIds:[o.id]});return n.history.push(s),void xr(t,{type:"activate-relation",sourceIds:[...o.sourceIds],relationIds:[o.id]})}if("resolve-relation"===e.type){const o=fr(e.relationIds),r=e.relationIds.filter(t=>!n.relations[t]),s=e.relationIds.filter(t=>"resolved"===n.relations[t]?.status);if(o.length&&t.diagnostics.push(hr("error","duplicate-relation","Relation ids must be unique.",i+".relationIds",o)),r.length&&t.diagnostics.push(hr("error","unknown-relation",`Unknown relation: ${r.join(", ")}.`,i+".relationIds",r)),s.length&&t.diagnostics.push(hr("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,i+".relationIds",s)),t.diagnostics.some(t=>"error"===t.severity))return;for(const o of e.relationIds){const i=n.relations[o];i.status="resolved",i.resolution=e.resolution,i.resolvedByEventId=t.event.id,i.resolvedAt=t.context.appliedAt,i.reason=e.reason}const a=mr(t,e,{relationIds:[...e.relationIds]});return n.history.push(a),void xr(t,{type:"resolve-relation",relationIds:[...e.relationIds]})}if("combine"===e.type||"contribute"===e.type){const o=t.productDefinitions.get(e.productId);o||t.diagnostics.push(hr("error","unknown-product",`Product "${e.productId}" has no declared mold.`,i+".productId",[e.productId]));const r=n.products[e.productId];"combine"===e.type&&r&&t.diagnostics.push(hr("error","duplicate-product",`Product "${e.productId}" has already been formed.`,i+".productId",[e.productId])),"contribute"!==e.type||r&&"forming"===r.status||t.diagnostics.push(hr("error","product-not-forming",`Contributions require an existing forming product "${e.productId}".`,i+".productId",[e.productId]));const s=vr(t,e.sourceIds,i+".sourceIds"),a="contribute"===e.type&&r?[...r.sourceIds,...e.sourceIds]:e.sourceIds,c=function(t,e,o,i){if(!e?.length)return[];const n=fr(e),r=e.filter(e=>!t.state.relations[e]),s=e.filter(e=>"resolved"===t.state.relations[e]?.status),a=new Set(o),c=e.filter(e=>(t.state.relations[e]?.sourceIds??[]).some(t=>!a.has(t)));return n.length&&t.diagnostics.push(hr("error","duplicate-relation","Basis relations must be unique.",i,n)),r.length&&t.diagnostics.push(hr("error","unknown-relation",`Unknown basis relation: ${r.join(", ")}.`,i,r)),s.length&&t.diagnostics.push(hr("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,i,s)),c.length&&t.diagnostics.push(hr("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,i,c)),t.diagnostics.some(t=>"error"===t.severity)?null:e.map(e=>t.state.relations[e])}(t,e.basisRelationIds,a,i+".basisRelationIds");if(!s||!c||!o||t.diagnostics.some(t=>"error"===t.severity))return;const l=s.reduce((t,e)=>t+e.amount,0),u=function(t){const e=sr();for(const o of t)yr(e,o.metrics);return e}(s);if(!wr(t,l,u,e.loss,i+".loss"))return;const d=l-(e.loss?.amount??0);!function(t,e,o){t.state.loss.amount+=o?.amount??0;for(const[i,n]of Object.entries(o?.metrics??{}))e[i]=Number(e[i]??0)-n,t.state.loss.metrics[i]=Number(t.state.loss.metrics[i]??0)+n}(t,u,e.loss);const h="combine"===e.type&&!1!==e.complete,f=mr(t,e,{sourceIds:[...e.sourceIds],productIds:[e.productId],relationIds:e.basisRelationIds?[...e.basisRelationIds]:void 0});let p;if("combine"===e.type){if(h&&Ar(t,o,d,i+".productId"),p=kr(o,e.sourceIds,d,u,t,h,f),h&&!br(t,p.outletId,i+".productId"))return;n.products[e.productId]=p}else p=r,p.sourceIds.push(...e.sourceIds),p.amount+=d,yr(p.metrics,u),p.history.push(f);for(const t of s)t.productIds=[e.productId],t.status="consumed",t.outletId=void 0,t.history.push(f);return n.history.push(f),function(t,e){if(e.length){for(const o of e)o.status="resolved",o.resolution="combined",o.resolvedByEventId=t.event.id,o.resolvedAt=t.context.appliedAt;xr(t,{type:"resolve-relation",relationIds:e.map(t=>t.id)})}}(t,c),xr(t,{type:"combine"===e.type?"form-product":"update-product",sourceIds:[...e.sourceIds],productIds:[e.productId],relationIds:e.basisRelationIds?[...e.basisRelationIds]:void 0,outletIds:p.outletId?[p.outletId]:void 0}),void(h&&xr(t,{type:"complete-product",sourceIds:[...p.sourceIds],productIds:[p.id],outletIds:p.outletId?[p.outletId]:void 0}))}if("complete-product"===e.type){const o=n.products[e.productId];return o?void function(t,e,o,i,n,r){const s=t.productDefinitions.get(e.id),a=o??s?.outletId??(t.outletIds.has("product")?"product":void 0);if(!br(t,a,r+".outletId"))return;if("complete"===e.status)return void t.diagnostics.push(hr("error","product-already-complete",`Product "${e.id}" is already complete.`,r,[e.id]));s&&(Ar(t,s,e.amount,r+".productId"),void 0!==s.amount&&(e.amount=s.amount),s.metrics&&(e.metrics=ar(e.metrics,s.metrics))),e.status="complete",e.outletId=a,e.reason=i,e.completedByEventId=t.event.id,e.completedAt=t.context.appliedAt;const c=mr(t,n,{sourceIds:[...e.sourceIds],productIds:[e.id],outletIds:a?[a]:void 0});e.history.push(c),t.state.history.push(c),xr(t,{type:"complete-product",sourceIds:[...e.sourceIds],productIds:[e.id],outletIds:a?[a]:void 0})}(t,o,e.outletId,e.reason,e,i):void t.diagnostics.push(hr("error","unknown-product-state",`Product "${e.productId}" has not been formed.`,i+".productId",[e.productId]))}if("split"===e.type){const o=vr(t,[e.sourceId],i+".sourceId");e.products.length||t.diagnostics.push(hr("error","empty-split","A split requires at least one product allocation.",i+".products"));const r=e.products.map(t=>t.productId),s=fr(r);s.length&&t.diagnostics.push(hr("error","duplicate-product","Split product ids must be unique.",i+".products",s));const a=r.map(e=>t.productDefinitions.get(e)),c=r.filter((t,e)=>!a[e]),l=r.filter(t=>n.products[t]);c.length&&t.diagnostics.push(hr("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,i+".products",c)),l.length&&t.diagnostics.push(hr("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,i+".products",l));for(const[o,n]of e.products.entries())void 0===n.amount||Number.isFinite(n.amount)&&n.amount>=0||t.diagnostics.push(hr("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${i}.products.${o}.amount`)),t.diagnostics.push(...pr(n.metrics,`${i}.products.${o}.metrics`));if(!o?.length||t.diagnostics.some(t=>"error"===t.severity))return;const u=o[0];if(!wr(t,u.amount,u.metrics,e.loss,i+".loss"))return;const d=u.amount-(e.loss?.amount??0),h=e.products.map((t,e)=>t.amount??a[e]?.amount),f=h.filter(t=>void 0!==t).length;if(0!==f&&f!==h.length)return void t.diagnostics.push(hr("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",i+".products"));const p=f?h:e.products.map(()=>d/e.products.length),y=p.reduce((t,e)=>t+e,0);if(Math.abs(y-d)>Rg)return void t.diagnostics.push(hr("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,i+".products"));const g=cr(u.metrics);for(const[t,o]of Object.entries(e.loss?.metrics??{}))g[t]=Number(g[t]??0)-o;const m=mr(t,e,{sourceIds:[u.id],productIds:r});if(e.products.forEach((o,r)=>{const s=a[r],c=d>Rg?p[r]/d:1/e.products.length,l=sr(Object.entries(g).map(([t,e])=>[t,e*c])),h=o.metrics??s.metrics??l,f=kr({...s,amount:p[r],metrics:h},[u.id],p[r],cr(h),t,!0,m);br(t,f.outletId,`${i}.products.${r}.productId`)&&(n.products[f.id]=f)}),t.diagnostics.some(t=>"error"===t.severity))return;u.productIds=r,u.status="consumed",u.outletId=void 0,u.history.push(m),n.loss.amount+=e.loss?.amount??0;for(const[t,o]of Object.entries(e.loss?.metrics??{}))n.loss.metrics[t]=Number(n.loss.metrics[t]??0)+o;n.history.push(m),xr(t,{type:"split-source",sourceIds:[u.id],productIds:r});for(const e of r)xr(t,{type:"complete-product",sourceIds:[u.id],productIds:[e],outletIds:n.products[e].outletId?[n.products[e].outletId]:void 0});return}if("eject"===e.type){br(t,e.outletId,i+".outletId");const o=gr(n,e.select,i+".select");t.diagnostics.push(...o.diagnostics);const r=o.ids.filter(t=>n.components[t].productIds.length);if(r.length&&t.diagnostics.push(hr("error","source-already-assigned",`Assigned source components cannot be ejected: ${r.join(", ")}.`,i+".select",r)),t.diagnostics.some(t=>"error"===t.severity))return;const s=mr(t,e,{sourceIds:o.ids,outletIds:[e.outletId]});for(const t of o.ids){const o=n.components[t];o.status=e.state??"ejected",o.outletId=e.outletId,o.reason=e.reason,o.history.push(s)}return n.history.push(s),void(o.ids.length&&xr(t,{type:"retarget-component",sourceIds:o.ids,outletIds:[e.outletId]}))}if("set-metric"===e.type){if(t.diagnostics.push(...pr(e.metricsDelta,i+".metricsDelta")),t.diagnostics.some(t=>"error"===t.severity))return;let o,r;if("run"===e.target)yr(n.metrics,e.metricsDelta);else if("components"in e.target){const r=gr(n,e.target.components,i+".target.components");if(t.diagnostics.push(...r.diagnostics),t.diagnostics.some(t=>"error"===t.severity))return;o=r.ids;for(const t of r.ids)yr(n.components[t].metrics,e.metricsDelta)}else{r=[...e.target.productIds];const o=fr(r),s=r.filter(t=>!n.products[t]);if(o.length&&t.diagnostics.push(hr("error","duplicate-product","Metric target product ids must be unique.",i+".target.productIds",o)),s.length&&t.diagnostics.push(hr("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,i+".target.productIds",s)),t.diagnostics.some(t=>"error"===t.severity))return;for(const t of r)yr(n.products[t].metrics,e.metricsDelta)}return void n.history.push(mr(t,e,{sourceIds:o,productIds:r}))}e.outcome.trim()?(n.outcome=e.outcome,n.summary=e.summary,n.history.push(mr(t,e)),t.observations.push({type:"crucible-outcome",eventId:t.event.id,phaseId:t.context.phaseId,authoredAt:t.context.authoredAt,appliedAt:t.context.appliedAt,outcome:e.outcome})):t.diagnostics.push(hr("error","invalid-outcome","Outcome must be a non-empty string.",i+".outcome"))}function Mr(t,e,o){if(t.eventsApplied.includes(e.id))return{applied:!1,state:t,materializations:[],observations:[],diagnostics:[hr("warning","duplicate-event-application",`Event "${e.id}" has already been applied.`,"events."+e.id,[e.id])]};const i=ur(t),n={state:i,event:e,context:o,productDefinitions:new Map(o.products.map(t=>[t.id,t])),outletIds:new Set(o.outlets.map(t=>t.id)),diagnostics:[],materializations:[],observations:[]};for(const[o,i]of e.effects.entries())if(Sr(n,i,o),n.diagnostics.some(t=>"error"===t.severity))return{applied:!1,state:t,materializations:[],observations:[],diagnostics:n.diagnostics};return i.elapsed=Math.max(i.elapsed,o.appliedAt),i.phaseId=o.phaseId,i.eventsApplied.push(e.id),n.observations.unshift({type:"crucible-event",eventId:e.id,phaseId:o.phaseId,authoredAt:o.authoredAt,appliedAt:o.appliedAt}),{applied:!0,state:i,materializations:n.materializations,observations:n.observations,diagnostics:n.diagnostics}}function _r(t,e){return e>t?-1:t>e?1:0}function $r(t,e,o,i,n){return{severity:t,code:e,message:o,path:i,ids:n?[...n]:void 0}}function Pr(t){const e=new Set,o=new Set;for(const i of t)e.has(i)&&o.add(i),e.add(i);return[...o].sort(_r)}function jr(t){const e="number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function Ir(t,e,o,i,n,r){if(!o)return i;try{return("function"==typeof o?o(t,e):t[o])??i}catch(t){return n.push($r("error","accessor-error",`Accessor threw: ${t instanceof Error?t.message:t+""}.`,r)),i}}function Lr(t,e,o){if(!t||"object"!=typeof t||Array.isArray(t))return null!=t&&e.push($r("error","invalid-metrics","Metrics must be a numeric object.",o)),sr();const i=sr();for(const[n,r]of Object.entries(t)){const t=jr(r);null!=t?i[n]=t:e.push($r("error","invalid-metric",`Metric "${n}" must be finite.`,`${o}.${n}`))}return i}function Rr(t){return t.map((t,e)=>({outlet:t,index:e})).sort((t,e)=>(t.outlet.order??t.index)-(e.outlet.order??e.index)||t.index-e.index).map(({outlet:t})=>({...t}))}function Tr(t){const{id:e,orientation:o,fixed:i,start:n,end:r,openings:s,thickness:a,friction:c,restitution:l}=t,u=function(t,e,o){const i=o.map(([o,i])=>[Math.max(t,Math.min(o,i)),Math.min(e,Math.max(o,i))]).filter(([t,e])=>e>t+Fg).sort((t,e)=>t[0]-e[0]||t[1]-e[1]),n=[];let r=t;for(const[t,e]of i)t>r+Fg&&n.push([r,t]),r=Math.max(r,e);return e>r+Fg&&n.push([r,e]),n}(n,r,s);return u.map(([t,n],r)=>({id:1===u.length?e:`${e}:${r}`,friction:c,restitution:l,shape:"horizontal"===o?{type:"segment",x1:t,y1:i,x2:n,y2:i,thickness:a}:{type:"segment",x1:i,y1:t,x2:i,y2:n,thickness:a}}))}function Cr(t){let e=2166136261;for(let o=0;t.length>o;o+=1)e^=t.charCodeAt(o),e=Math.imul(e,16777619);return e>>>0}function Or(t){return"number"==typeof t&&Number.isFinite(t)?t>>>0:"string"==typeof t?Cr(t):1}function Fr(t,e){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:e.map(t=>({...t,shape:{...t.shape}})),observation:{chartType:"crucible"},kernel:{seed:Or(t),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function Dr(t){return"crucible:component:"+encodeURIComponent(t)}function Nr(t,e,o,i){if(void 0!==o&&Number.isFinite(o)&&o>0)return o;const n=Math.min(...e,t),r=Math.max(...e,t);return r-n>Fg?i[0]+(i[1]-i[0])*Math.sqrt(Math.max(0,t-n)/(r-n)):(i[0]+i[1])/2}function zr(t,e){const o=Math.max(.25,Math.min(1,e.width/900,e.height/520)),i=t?.[0]??7*o,n=t?.[1]??18*o,r=Math.max(1,Math.min(i,n));return[r,Math.max(r,Math.max(i,n))]}function Er(t,e){if(!t)return[];const o=Math.min(t,Math.max(1,Math.ceil(Math.sqrt(t*Math.max(.5,e.width/Math.max(1,e.height)))))),i=Math.max(1,Math.ceil(t/o));return Array.from({length:t},(t,n)=>({x:e.x+e.width/o*(n%o+.5),y:e.y+(Math.floor(n/o)+.5)*(e.height/i)}))}function Br(t){return t.outletId?t.outletId:"failed"===t.status?"failed":"recovered"===t.status?"recovered":"retained"===t.status?"retained":"ejected"===t.status?"residue":void 0}function Wr(t,e){return t.outlets.find(t=>t.id===e)||{x:t.chamber.x+.18*t.chamber.width,y:t.chamber.y+.2*t.chamber.height,width:.64*t.chamber.width,height:.6*t.chamber.height}}function Yr(t,e,o={}){const i=Object.values(t.products).sort((t,e)=>_r(t.id,e.id)),n=Object.values(t.components).sort((t,e)=>_r(t.id,e.id)),r=[...n.map(t=>t.amount),...i.map(t=>t.amount)],s=zr(o.radiusRange,e),a=function(t,e){const o=new Map;for(const e of t){const t=e.outletId??"__chamber__",i=o.get(t)??[];i.push(e),o.set(t,i)}const i=new Map;for(const[t,n]of o){n.sort((t,e)=>(t.order??Number.MAX_SAFE_INTEGER)-(e.order??Number.MAX_SAFE_INTEGER)||_r(t.id,e.id));const o=Er(n.length,Wr(e,"__chamber__"===t?void 0:t));n.forEach((t,e)=>i.set(t.id,o[e]))}return i}(i,e),c=i.map(t=>{const i=a.get(t.id)??{x:e.chamber.x+e.chamber.width/2,y:e.chamber.y+e.chamber.height/2},n=1.28*Nr(t.amount,r,o.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:t.id,product:t};return{id:(l=t.id,"crucible:product:"+encodeURIComponent(l)),x:i.x,y:i.y,mass:Math.max(.25,n*n*.018),bodyCollisions:!1,shape:{type:"circle",radius:n},datum:c};var l}),l=new Map;for(const t of n.filter(t=>!t.productIds.length)){const e=Br(t)??"__chamber__",o=l.get(e)??[];o.push(t),l.set(e,o)}const u=new Map;for(const[t,o]of l){const i=Er(o.length,Wr(e,"__chamber__"===t?void 0:t));o.forEach((t,e)=>u.set(t.id,i[e]))}return[...n.map(t=>{let i=u.get(t.id);if(t.productIds.length){const o=t.productIds.map(t=>a.get(t)).filter(t=>!!t);if(o.length){i={x:o.reduce((t,e)=>t+e.x,0)/o.length,y:o.reduce((t,e)=>t+e.y,0)/o.length};const n=Cr(t.id)/4294967295*Math.PI*2,r=Math.min(20,Math.max(4,.012*e.width));i={x:i.x+Math.cos(n)*r,y:i.y+Math.sin(n)*r}}}i??(i={x:e.chamber.x+e.chamber.width/2,y:e.chamber.y+e.chamber.height/2});const n=Nr(t.amount,r,o.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:t.id,sourceDatum:t.datum};return{id:Dr(t.id),x:i.x,y:i.y,mass:Math.max(.25,n*n*.015),shape:{type:"circle",radius:n},datum:c}}),...c]}function qr(t){return Array.isArray(t)?t.map(qr):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&"function"!=typeof t).sort(([t],[e])=>_r(t,e)).map(([t,e])=>[t,qr(e)])):t}function Xr(t,e=t.duration){const o=function(t,e){const o=jr(e)??0,i=Math.max(0,Math.min(t.duration,o));if(!t.phases.length)return{elapsed:i,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const n=i>=t.duration-Fg,r=n?t.phases[t.phases.length-1]:t.phases.find(t=>i>=t.start&&t.end>i)??t.phases[0];return{elapsed:i,phaseId:r.id,phaseIndex:r.index,phaseElapsed:n?r.duration:Math.max(0,i-r.start),complete:n}}(t,e);let i=ur(t.initialState);const n=[],r=[],s=[];for(const e of t.events){if(e.authoredAt>o.elapsed+Fg)break;const a=Mr(i,e,{phaseId:e.phaseId,authoredAt:e.authoredAt,appliedAt:e.authoredAt,products:t.products,outlets:t.outlets});n.push(...a.diagnostics),r.push(...a.materializations),s.push(...a.observations),a.applied&&(i=a.state)}return i.elapsed=o.elapsed,i.phaseId=o.phaseId,i.phaseIndex=o.phaseIndex,i.phaseElapsed=o.phaseElapsed,i.complete=o.complete,o.complete&&"in_process"===i.outcome&&(i.outcome="complete"),i.playing=!1,{state:i,diagnostics:n,materializations:r,observations:s}}function Gr(t){const e=function(t){const e=[];t.length||e.push($r("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const o=Pr(t.map(t=>t.id));o.length&&e.push($r("error","duplicate-phase-id",`Phase ids must be unique: ${o.join(", ")}.`,"phases",o));let i=0;return{phases:t.map((t,o)=>{const n=jr(t.duration),r=null!=n&&n>0?n:0;t.id.trim()||e.push($r("error","invalid-phase-id","Phase ids may not be empty.",`phases.${o}.id`)),null!=n&&n>0||e.push($r("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${o}.duration`,[t.id])),void 0===t.intensity||Number.isFinite(t.intensity)||e.push($r("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${o}.intensity`,[t.id]));const s={...t,duration:r,intensity:void 0===t.intensity?.5:Number.isFinite(t.intensity)?Math.max(0,Math.min(1,t.intensity)):.5,motion:t.motion??"hold",index:o,start:i,end:i+r};return i=s.end,s}),diagnostics:e}}(t.phases),o=e.phases.at(-1)?.end??0,i=Rr(t.outlets??Cg),n=(t.products??[]).map(t=>({...t,metrics:t.metrics?ar(t.metrics):void 0})),r=function(t,e,o){const i=[],n=Pr(t.map(t=>t.id));n.length&&i.push($r("error","duplicate-event-id",`Event ids must be unique: ${n.join(", ")}.`,"events",n));const r=[];return t.forEach((t,n)=>{let s,a,c;if(t.id.trim()||i.push($r("error","invalid-event-id","Event ids may not be empty.",`events.${n}.id`)),"time"in t.at&&void 0!==t.at.time){const r=jr(t.at.time);if(null==r||0>r||r>o+Fg)return void i.push($r("error","event-time-out-of-range",`Event time must fall between 0 and ${o}.`,`events.${n}.at.time`,[t.id]));s=Math.max(0,Math.min(o,r));const l=function(t,e,o){const i=t.find(t=>Fg>=Math.abs(t.start-o));if(i)return{phase:i,boundaryRank:1};const n=t.find(t=>o>=t.start&&t.end>o);return n?{phase:n,boundaryRank:0}:Fg>=Math.abs(o-e)&&t.length?{phase:t[t.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(e,o,s);a=l.phase,c=l.boundaryRank}else{if(a=e.find(e=>e.id===t.at.phaseId),!a)return void i.push($r("error","unknown-event-phase",`Event references unknown phase "${t.at.phaseId}".`,`events.${n}.at.phaseId`,[t.id,t.at.phaseId]));const o=t.at.progress??0;if(!Number.isFinite(o)||0>o||o>1)return void i.push($r("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${n}.at.progress`,[t.id]));s=a.start+a.duration*o,c=0===o?1:0}a?r.push({...t,index:n,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):i.push($r("error","event-without-phase","Event could not be assigned to a phase.",`events.${n}.at`,[t.id]))}),r.sort((t,e)=>t.authoredAt-e.authoredAt||t.boundaryRank-e.boundaryRank||t.index-e.index),{events:r,diagnostics:i}}(t.events??[],e.phases,o),s=function(t){const e=[],o=sr(),i=[];let n=0;const r=sr();t.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((Ir(s,a,t.idAccessor,c,e,`data.${a}.id`)??c)+"").trim();if(!l)return void e.push($r("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));i.push(l);const u=jr(Ir(s,a,t.amountAccessor,1,e,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&e.push($r("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=Lr(Ir(s,a,t.metricsAccessor,{},e,`data.${a}.metrics`),e,`data.${a}.metrics`),f=Ir(s,a,t.initialStateAccessor,"active",e,`data.${a}.status`),p=Og.has(f)?f:"active";Og.has(f)||e.push($r("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${a}.status`,[l]));const y=Ir(s,a,t.labelAccessor,(s.label??s.name??l)+"",e,`data.${a}.label`)+"",g=Ir(s,a,t.categoryAccessor,"component",e,`data.${a}.category`)+"";Object.hasOwn(o,l)||(o[l]={id:l,label:y,category:g,datum:s,status:p,initialAmount:d,amount:d,initialMetrics:ar(h),metrics:ar(h),productIds:[],history:[]},n+=d,function(t,e){for(const[o,i]of Object.entries(e))t[o]=Number(t[o]??0)+i}(r,h))});const s=Pr(i);s.length&&e.push($r("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=Lr(t.metrics??{},e,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:t.phases[0]?.id??"",phaseIndex:t.phases.length?0:-1,playing:!1,complete:0===t.phases.length,outcome:"in_process",eventsApplied:[],components:o,products:sr(),relations:sr(),input:{amount:n,metrics:r},metrics:a,loss:{amount:0,metrics:sr()},history:[]},diagnostics:e}}(t),a=function(t=Tg,e=Cg){const o=Math.max(1,jr(t[0])??900),i=Math.max(1,jr(t[1])??520),n=360>o||260>i,r=n?Math.max(4,.035*Math.min(o,i)):20,s=n?Math.max(10,.075*i):34,a={x:r,y:r,width:Math.max(1,o-2*r),height:s},c=n?Math.max(16,.14*i):Math.min(78,.16*i),l={x:r,y:i-r-c,width:Math.max(1,o-2*r),height:c},u=n?Math.max(12,.08*o):Math.min(150,.17*o),d=a.y+a.height+(n?12:38),h=l.y-(n?10:34),f={x:u,y:d,width:Math.max(24,o-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,n?84:180)),y={x:f.x+(f.width-p)/2,y:f.y-(n?10:24),width:p,height:n?12:28},g=Rr(e),m={left:g.filter(t=>"left"===(t.side??"bottom")),right:g.filter(t=>"right"===t.side),bottom:g.filter(t=>"bottom"===(t.side??"bottom"))},x=[],b=(t,e)=>{const i=Math.max(8,u-1.5*r),s=f.height/Math.max(1,e.length);e.forEach((e,a)=>{x.push({...e,side:t,x:"left"===t?r:o-r-i,y:f.y+a*s,width:i,height:Math.max(8,s-(n?2:8))})})};b("left",m.left),b("right",m.right);const v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((t,e)=>{x.push({...t,side:"bottom",x:f.x+e*v,y:f.y+f.height+(n?2:7),width:Math.max(8,v-(n?2:8)),height:Math.max(8,l.y-f.y-f.height-(n?4:12))})}),x.sort((t,e)=>g.findIndex(e=>e.id===t.id)-g.findIndex(t=>t.id===e.id)),{width:o,height:i,phaseRail:a,chamber:f,mouth:y,projection:l,outlets:x}}(t.size??Tg,i),c=function(t){const{chamber:e,mouth:o}=t,i=Math.max(2,Math.min(10,.018*Math.min(t.width,t.height))),n=Math.max(e.x,o.x),r=Math.min(e.x+e.width,o.x+o.width),s={left:t.outlets.filter(t=>"left"===t.side),right:t.outlets.filter(t=>"right"===t.side),bottom:t.outlets.filter(t=>"bottom"===t.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:e.x,y1:e.y,x2:n,y2:e.y,thickness:i}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:r,y1:e.y,x2:e.x+e.width,y2:e.y,thickness:i}}];a.push(...Tr({id:"crucible:wall:left",orientation:"vertical",fixed:e.x,start:e.y,end:e.y+e.height,openings:s.left.map(t=>[t.y,t.y+t.height]),thickness:i,friction:.46,restitution:.12}),...Tr({id:"crucible:wall:right",orientation:"vertical",fixed:e.x+e.width,start:e.y,end:e.y+e.height,openings:s.right.map(t=>[t.y,t.y+t.height]),thickness:i,friction:.46,restitution:.12}),...Tr({id:"crucible:wall:bottom",orientation:"horizontal",fixed:e.y+e.height,start:e.x,end:e.x+e.width,openings:s.bottom.map(t=>[t.x,t.x+t.width]),thickness:i,friction:.5,restitution:.08}));for(const e of t.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(e.id),sensor:!0,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+e.height/2,width:e.width,height:e.height}});return a}(a),l=function(t,e){const o=[],i=new Set(e.map(t=>t.id)),n=Pr(e.map(t=>t.id)),r=Pr(t.map(t=>t.id));return n.length&&o.push($r("error","duplicate-outlet-id",`Outlet ids must be unique: ${n.join(", ")}.`,"outlets",n)),r.length&&o.push($r("error","duplicate-product-id",`Product ids must be unique: ${r.join(", ")}.`,"products",r)),e.forEach((t,e)=>{t.id.trim()||o.push($r("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${e}.id`)),void 0===t.order||Number.isFinite(t.order)||o.push($r("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${e}.order`,[t.id]))}),t.forEach((t,e)=>{t.id.trim()||o.push($r("error","invalid-product-id","Product ids may not be empty.",`products.${e}.id`)),void 0===t.amount||Number.isFinite(t.amount)&&t.amount>=0||o.push($r("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${e}.amount`,[t.id])),void 0===t.outletId||i.has(t.outletId)||o.push($r("error","unknown-outlet",`Product "${t.id}" references unknown outlet "${t.outletId}".`,`products.${e}.outletId`,[t.outletId])),Lr(t.metrics??{},o,`products.${e}.metrics`)}),o}(n,i),u=(d={seed:t.seed??1,components:Object.values(s.state.components).sort((t,e)=>_r(t.id,e.id)).map(t=>({id:t.id,label:t.label,category:t.category,amount:t.amount,metrics:t.metrics,status:t.status})),phases:e.phases.map(({id:t,duration:e,label:o,description:i,intensity:n,motion:r,color:s,metrics:a})=>({id:t,duration:e,label:o,description:i,intensity:n,motion:r,color:s,metrics:a})),products:n,outlets:i,events:r.events.map(({id:t,label:e,description:o,summary:i,authoredAt:n,phaseId:r,boundaryRank:s,effects:a})=>({id:t,label:e,description:o,summary:i,authoredAt:n,phaseId:r,boundaryRank:s,effects:a}))},JSON.stringify(qr(d)));var d;const h=function(t,e,o={}){const i=Object.values(t.components).sort((t,e)=>_r(t.id,e.id)),n=i.map(t=>t.amount),r=zr(o.radiusRange,e),s=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}}(Or(o.seed)),a=e.mouth.x+e.mouth.width/2,c=e.chamber.y+Math.max(18,.18*e.chamber.height),l=Math.max(4,.28*e.chamber.width),u=Math.max(4,.12*e.chamber.height);return i.map((t,e)=>{const d=e/Math.max(1,i.length)*Math.PI*2+.18*(s()-.5),h=Nr(t.amount,n,o.bodyRadius,r),f={__crucible:!0,kind:"component",semanticId:t.id,sourceDatum:t.datum};return{id:Dr(t.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}(s.state,a,{seed:t.seed,bodyRadius:t.bodyRadius,radiusRange:t.radiusRange}),f=[...e.diagnostics,...r.diagnostics,...s.diagnostics,...l],p={phases:e.phases,events:r.events,products:n,outlets:i,duration:o,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:Fr(t.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:f},y=Xr(p),g=Object.values(y.state.products).filter(t=>"forming"===t.status).map(t=>t.id),m=g.length?[$r("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return p.terminalState=y.state,p.terminalSpawns=Dg(y.state,a,{seed:t.seed,bodyRadius:t.bodyRadius,radiusRange:t.radiusRange}),p.diagnostics=[...f,...y.diagnostics,...m],p}function Vr(t,e){const o=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch{return t.fillStyle=o,[78,121,167]}const n=t.fillStyle;if(t.fillStyle=o,"string"!=typeof n)return[78,121,167];if(n.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(n.startsWith("#"))return[parseInt(n.slice(1,3),16),parseInt(n.slice(3,5),16),parseInt(n.slice(5,7),16)];const r=n.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}function Hr(t){switch(t){case"monotoneX":return zg.curveMonotoneX;case"monotoneY":return zg.curveMonotoneY;case"cardinal":return zg.curveCardinal;case"catmullRom":return zg.curveCatmullRom;case"step":return zg.curveStep;case"stepBefore":return zg.curveStepBefore;case"stepAfter":return zg.curveStepAfter;case"basis":return zg.curveBasis;case"natural":return zg.curveNatural;default:return null}}function Ur(t,e,o){if(null==e)return o;if(ri(e)){const i=function(t,e){const o=t.background??"transparent",i=t.stroke??"#000",n="transparent"===o||"none"===o?o:ni(e,o)||o,r=ni(e,i)||i||"#000",s="undefined"!=typeof window&&window.devicePixelRatio||1,a=`${si(t)}|${n}|${r}@${s}`,c=ky.get(a);if(void 0!==c)return c;const l=function(t={},e){const{background:o="transparent",stroke:i="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45}=t,a={background:o,stroke:i,lineWidth:n,spacing:r,angle:s},c=Math.max(8,Math.ceil(2*r));let l;try{l=function(t){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(t,t):(by||(by=document.createElement("canvas")),by.width=t,by.height=t,by)}(c)}catch{return ii(a)}const u=l.getContext("2d");if(!u)return ii(a);o&&"transparent"!==o?(u.fillStyle=o,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=i,u.lineWidth=n,u.lineCap="square";const d=s*Math.PI/180;if(45===s||-45===s){const t=s>0?1:-1;for(let e=-c;2*c>=e;e+=r)u.beginPath(),u.moveTo(e,0),u.lineTo(e+t*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);const t=2*c;for(let e=-t;t>=e;e+=r)u.beginPath(),u.moveTo(-t,e),u.lineTo(t,e),u.stroke();u.restore()}return(e||u).createPattern(l,"repeat")}({background:n,stroke:r,lineWidth:t.lineWidth,spacing:t.spacing,angle:t.angle},e),u=ri(l)?null:l;return ky.set(a,u),u}(e,t);return i||e.background&&ni(t,e.background)||o}return"string"!=typeof e?e:ni(t,e)||o}function Kr(t,e,o){const i=Ur(t,e,o);if("string"==typeof i&&i.trim().startsWith("var(")){const e=ni(t,o);return e&&!e.trim().startsWith("var(")?e:o}return i}function Zr(t,e,o,i,n,r,s){const a=e.stops.filter(t=>Number.isFinite(t.offset)&&(null==t.opacity||Number.isFinite(t.opacity)));if(2>a.length)return null;const c=t.createLinearGradient(i,n,r,s);for(const e of a)c.addColorStop(Math.max(0,Math.min(1,e.offset)),Qr(t,e,o));return c}function Qr(t,e,o){const i=e.color??o,n=ni(t,i)||i;if(null==e.opacity)return n;const r=Math.max(0,Math.min(1,e.opacity)),[s,a,c]=Vr(t,n);return`rgba(${s},${a},${c},${r})`}function Jr(t){return Number.isFinite(t)?1e3>Math.abs(t)?Number.isInteger(t)?t+"":t.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):t.toLocaleString():"0"}function ts(t,e,o,i){const n=t.datum;if(!n?.__crucible)return;const r="circle"===t.shape.type?t.shape.radius:8,s="string"==typeof e.fill?e.fill:"product"===n.kind?"#b8792d":"#356b63",a="string"==typeof e.stroke?e.stroke:"#26323a",c="number"==typeof e.strokeWidth?e.strokeWidth:1.25,l="number"==typeof e.opacity?e.opacity:.96,u=i?`${i}-crucible-body-${o}`:"crucible-body-"+o;if("product"===n.kind){const e=Array.from({length:6},(e,o)=>{const i=-Math.PI/2+o/6*Math.PI*2;return`${t.x+Math.cos(i)*r},${t.y+Math.sin(i)*r}`}).join(" "),o=u+"-glow";return(0,Eg.jsxs)(Ng.Fragment,{children:[(0,Eg.jsx)("defs",{children:(0,Eg.jsx)("filter",{id:o,x:"-60%",y:"-60%",width:"220%",height:"220%",children:(0,Eg.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:s,floodOpacity:"0.8"})})}),(0,Eg.jsx)("polygon",{points:e,fill:s,stroke:a,strokeWidth:c,opacity:l,filter:`url(#${o})`}),(0,Eg.jsx)("circle",{cx:t.x,cy:t.y,r:Math.max(2,.36*r),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:c,opacity:.72*l})]},u)}return(0,Eg.jsxs)(Ng.Fragment,{children:[(0,Eg.jsx)("circle",{cx:t.x,cy:t.y,r:r,fill:s,stroke:a,strokeWidth:c,opacity:l}),(0,Eg.jsx)("circle",{cx:t.x-.25*r,cy:t.y-.28*r,r:Math.max(1,.18*r),fill:"rgba(255,255,255,0.34)"})]},u)}function es(t){const{x:e,y:o,width:i,height:n}=t.chamber,r=Math.min(.14*i,48),s=o+n;return[`M ${e} ${o}`,`L ${e+r} ${s-.16*n}`,`Q ${e+i/2} ${s+.1*n} ${e+i-r} ${s-.16*n}`,`L ${e+i} ${o}`].join(" ")}function os({layout:t,phases:e,state:o,compact:i=!1}){const n=Math.max(1,e.reduce((t,e)=>t+Math.max(0,e.duration),0));return(0,Bg.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[(0,Bg.jsxs)("defs",{children:[(0,Bg.jsxs)("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Bg.jsx)("stop",{offset:"0",stopColor:qg,stopOpacity:"0.03"}),(0,Bg.jsx)("stop",{offset:"0.66",stopColor:qg,stopOpacity:"0.1"}),(0,Bg.jsx)("stop",{offset:"1",stopColor:Xg,stopOpacity:"0.18"})]}),(0,Bg.jsx)("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:(0,Bg.jsx)("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:Wg,strokeOpacity:"0.08",strokeWidth:"1"})})]}),(0,Bg.jsx)("rect",{x:t.chamber.x,y:t.chamber.y,width:t.chamber.width,height:t.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:Wg,strokeOpacity:"0.52",strokeWidth:i?1:2.2}),(0,Bg.jsx)("path",{d:es(t),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),(0,Bg.jsx)("line",{x1:t.mouth.x,x2:t.mouth.x+t.mouth.width,y1:t.mouth.y,y2:t.mouth.y,stroke:Wg,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:i?2:5}),i?null:(0,Bg.jsx)("g",{"data-testid":"crucible-phase-rail",children:e.map((i,r)=>{const s=e.slice(0,r).reduce((t,e)=>t+Math.max(0,e.duration),0),a=t.phaseRail.x+s/n*t.phaseRail.width,c=Math.max(0,i.duration)/n*t.phaseRail.width,l=i.id===o.phaseId,u=o.phaseIndex>r||o.complete;return(0,Bg.jsxs)("g",{children:[(0,Bg.jsx)("rect",{x:a,y:t.phaseRail.y,width:Math.max(1,c-2),height:t.phaseRail.height,rx:2,fill:l?i.color??qg:u?Gg:Wg,fillOpacity:l?.68:u?.28:.09}),46>c?null:(0,Bg.jsx)("text",{x:a+c/2,y:t.phaseRail.y+t.phaseRail.height+13,fill:l?Wg:Yg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:l?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(i.label??i.id).toUpperCase()})]},i.id)})}),t.outlets.map(t=>(0,Bg.jsxs)("g",{children:[(0,Bg.jsx)("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:3,fill:t.color??("left"===t.side?Xg:Gg),fillOpacity:"0.1",stroke:t.color??("left"===t.side?Xg:Gg),strokeDasharray:"3 3",strokeOpacity:"0.62"}),i?null:(0,Bg.jsx)("text",{x:t.x+t.width/2,y:t.y+Math.min(13,t.height/2+3),fill:Yg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(t.label??t.id).toUpperCase()})]},t.id))]})}function is({rows:t,layout:e,projection:o,amountLabel:i}){if(!t.length)return null;const n=o.measure??"count",r=t.map(t=>Math.max(0,function(t,e){return"count"===e?t.count:"amount"===e?t.amount:Number(t.metrics[e]??0)}(t,n))),s=Math.max(1,...r),a=e.projection.width/Math.max(1,t.length),c=e.projection.height>48?21:4,l=Math.max(5,e.projection.height-c-5);return(0,Bg.jsx)("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:t.map((t,o)=>{const u=r[o],d=Math.max(u>0?2:0,u/s*l),h=e.projection.x+o*a+.18*a;return(0,Bg.jsxs)("g",{children:[(0,Bg.jsx)("rect",{x:h,y:e.projection.y+l-d,width:Math.max(3,.64*a),height:d,rx:2,fill:"failed"===t.status||"ejected"===t.status?Xg:"complete"===t.status?qg:Gg,fillOpacity:"0.68"}),c>4&&a>=34?(0,Bg.jsxs)(Bg.Fragment,{children:[(0,Bg.jsx)("text",{x:h+.32*a,y:e.projection.y+l+10,fill:Yg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:t.label.length>13?t.label.slice(0,12)+"…":t.label}),(0,Bg.jsxs)("text",{x:h+.32*a,y:e.projection.y+l+19,fill:Wg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[Jr(u),"amount"===n&&i?" "+i:""]})]}):null]},t.key)})})}function ns(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 rs(t,e,o,i,n){const r=Array.isArray(n)?n:n?[n]:[];if(!1!==o||0!==r.length)return({size:n})=>{const s=[Number(n[0])||700,Number(n[1])||420],a=wi(s),c=Math.max(2,Math.round(e)),l=a.plot.width/c,u=a.plot.y+a.plot.height,d=Math.max(1,...t.map(t=>t.value)),h=!1!==o,[f,p]=i?.valueExtent??[0,c],y=p===f?1:p-f,g=t.map((t,e)=>{const o=u-t.value/d*a.plot.height*.9;return`${0===e?"M":"L"} ${(a.plot.x+(e+.5)*l).toFixed(1)} ${o.toFixed(1)}`}).join(" ");return(0,Vg.jsxs)("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:s[0],height:s[1],viewBox:`0 0 ${s[0]} ${s[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?(0,Vg.jsxs)(Vg.Fragment,{children:[Array.from({length:c+1},(t,e)=>{const o=a.plot.x+e*l;return(0,Vg.jsx)("line",{"data-testid":"galton-board-bin-wall",x1:o,x2:o,y1:a.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+e)}),(0,Vg.jsx)("line",{x1:a.plot.x,x2:a.plot.x+a.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,Vg.jsx)("path",{d:g,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),t.map((t,e)=>t.value>0?(0,Vg.jsx)("text",{x:a.plot.x+(e+.5)*l,y:Math.max(a.plot.y+10,u-t.value/d*a.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:t.value},`${t.label}-${e}`):null)]}):null,r.map((t,e)=>{const o=Number(t.value);if(!Number.isFinite(o))return null;const i=a.plot.x+Math.max(0,Math.min(1,(o-f)/y))*a.plot.width,n=t.color??"var(--semiotic-warning, #f28e2b)",r="bottom"===t.labelPosition?Math.min(s[1]-8,u+16):a.plot.y+16;return(0,Vg.jsxs)("g",{className:t.className,"data-testid":"galton-board-reference-line",children:[(0,Vg.jsx)("line",{x1:i,x2:i,y1:a.plot.y+8,y2:u-4,stroke:n,strokeDasharray:t.strokeDasharray??"6 5",strokeWidth:t.strokeWidth??2}),null==t.label?null:(0,Vg.jsx)("text",{x:Math.min(a.plot.x+a.plot.width-4,i+6),y:r,fill:n,fontSize:10,fontWeight:700,children:t.label})]},`galton-reference-${e}-${o}`)})]})}}function ss(t,e,o){if(!1!==o&&e)return({size:o})=>{const i=[Number(o[0])||760,Number(o[1])||360],n=wi(i),r=Math.max(1,e.windowCount),s=e.plot??n.plot,a=e.gutter??{x:s.x,y:s.y,width:0,height:s.height},c=e.windowPlot??s,l=c.width/r,u=s.y+s.height,d=s.y+.48*s.height,h=e.lidSegments[0]?.y1??d,f=e.windowStart,p=e.windowStart+r*e.windowSize,y=c.x+Math.max(0,Math.min(1,p===f?0:(e.watermarkValue-f)/(p-f)))*c.width;return(0,Vg.jsxs)("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,Vg.jsx)("rect",{x:s.x,y:s.y,width:s.width,height:s.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),a.width>0?(0,Vg.jsxs)("g",{children:[(0,Vg.jsx)("rect",{x:a.x,y:h,width:a.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),(0,Vg.jsxs)("text",{x:a.x+a.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[e.lateCount," late"]})]}):null,Array.from({length:r},(o,n)=>{const r=t[n],s=c.x+n*l,a=e.closedWindowCount>n;return(0,Vg.jsxs)("g",{children:[(0,Vg.jsx)("rect",{x:s,y:d,width:l,height:u-d,fill:a?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:a?.08:.06}),a?e.lidSegments.filter(t=>t.windowIndex===n).map(t=>(0,Vg.jsx)("line",{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},t.id)):null,(0,Vg.jsx)("text",{x:s+l/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:r?.value??0}),(0,Vg.jsx)("text",{x:s+l/2,y:Math.min(i[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:r?.label??""})]},"window-"+n)}),e.windowWalls?.map(({id:t,...e})=>(0,Vg.jsx)("rect",{...e,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},t)),e.lidSegments.filter(t=>null==t.windowIndex).map(t=>(0,Vg.jsx)("line",{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},t.id)),(0,Vg.jsx)("line",{x1:s.x,x2:s.x+s.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,Vg.jsx)("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:s.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),(0,Vg.jsxs)("text",{x:Math.min(s.x+s.width-4,y+6),y:s.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*e.watermarkValue)/100]})]})}}function as(t,e,o,i=1){if(!1!==o&&0!==t.length)return({size:o})=>{const n=[Number(o[0])||700,Number(o[1])||380],r=wi(n),s=Tn(r.plot,t.length,e),a=r.plot.y+r.plot.height;return(0,Vg.jsxs)("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,Vg.jsx)("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:a,y2:a,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),t.map((t,e)=>{const o=Math.min(r.plot.height,s.pileHeight(t.value/i)),c=s.tubeWidth,l=s.centerX(e),u=a-o;return(0,Vg.jsxs)("g",{children:[(0,Vg.jsx)("rect",{x:l-c/2,y:u,width:c,height:o,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),(0,Vg.jsx)("text",{x:l,y:Math.max(r.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:t.value}),(0,Vg.jsx)("text",{x:l,y:Math.min(n[1]-8,a+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:t.label})]},`${t.label}-${e}`)}),(0,Vg.jsx)("text",{x:n[0]/2,y:n[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${i}; partial circles scaled by area`})]})}}function cs(t){return t.toLocaleString(void 0,Math.abs(t)>=1e3||.01>Math.abs(t)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function ls(t,e){if(!1!==e&&t)return({size:e})=>{const o=[Number(e[0])||700,Number(e[1])||360],i=wi(o),n=i.plot.y+i.plot.height,[r,s]=t.xExtent,a=r+(s-r)/2,c=[{label:cs(r),x:t.xRange[0]},{label:cs(a),x:t.xRange[0]+(t.xRange[1]-t.xRange[0])/2},{label:cs(s),x:t.xRange[1]}];return(0,Vg.jsxs)("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[t.groups.some(t=>t.overlapping)?(0,Vg.jsx)("text",{"data-testid":"collision-swarm-overlap-warning",x:i.plot.x,y:Math.max(10,i.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:360>o[0]?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,t.groups.map(t=>(0,Vg.jsxs)("g",{children:[(0,Vg.jsx)("line",{x1:i.plot.x,x2:i.plot.x+i.plot.width,y1:t.y,y2:t.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),(0,Vg.jsx)("text",{x:i.plot.x+4,y:t.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:t.label}),(0,Vg.jsxs)("text",{x:i.plot.x+i.plot.width-4,y:t.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",t.count,t.overlapping?" · overlaps":""]})]},t.label)),(0,Vg.jsx)("line",{x1:t.xRange[0],x2:t.xRange[1],y1:n,y2:n,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),c.map(t=>(0,Vg.jsxs)("g",{children:[(0,Vg.jsx)("line",{x1:t.x,x2:t.x,y1:n,y2:n+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),(0,Vg.jsx)("text",{x:t.x,y:Math.min(o[1]-8,n+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:t.label})]},`${t.label}-${t.x}`))]})}}function us(t,e,o){return Math.max(e,Math.min(o,t))}function ds(t){return 6.2*t.length}function hs(t,e){const o=t.trim();if(e>=o.length)return o;if(1>=e)return o.slice(0,1);const i=o.split(/\s+/).filter(Boolean).map(t=>t[0]).join("").toUpperCase();return i.length>1&&e>=i.length?i:e>3?o.slice(0,Math.max(1,e-2))+"..":o.slice(0,e).toUpperCase()}function fs(t,e,o="auto"){const i=Math.max(1,Math.floor(e/6.2)),n="compact"===o?hs(t,i):"full"===o?t:ds(t)>e?hs(t,i):t;return{text:n,textLength:ds(n)>e?Math.max(4,e):void 0}}function ps(t,e,o={},i){if(!1===e||!t)return;const{volume:n,stages:r,groups:s,groupCompletion:a}=t,c=new Map(n.stages.map(t=>[t.id,t])),l=new Map(a.map(t=>[t.id,t]));return({size:t})=>{const e=Number(t[0])||n.width,a=Number(t[1])||n.height,u=r.map(t=>{const e=c.get(t.id),i=o["process-stage-"+t.id];return{id:t.id,label:t.label,x0:e?.x0??t.x-t.width/2,x1:(e?.x0??t.x-t.width/2)+(e?.width??t.width),x:t.x,width:e?.width??t.width,count:t.count,capacity:t.capacity,absorb:t.absorb,portalTarget:t.portalTarget,queueDepth:i?.queueDepth,processed:i?.processedCount}}),d=s.map(t=>{const e=l.get(t.id);return{id:t.id,label:t.label??t.id,x:t.anchor?.x??t.x??0,y:t.anchor?.y??t.y??0,absorbed:e?.absorbed,total:e?.total,complete:e?.complete}});return function(t,e={}){const{showFlowSpine:o=!0,showStageCounts:i=!0,showCapacityBadges:n=!0,showGroupSockets:r=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=e,{width:l,height:u,left:d,right:h,topY:f,bottomY:p,midY:y,stages:g,groups:m=[]}=t,x=p-f;return(0,Hg.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,Hg.jsx)("defs",{children:(0,Hg.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Hg.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,Hg.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,Hg.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,Hg.jsx)("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),o?(0,Hg.jsx)("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((t,e)=>{const o=function(t){return t.absorb?"absorb":t.portalTarget?"portal":null!=t.capacity?"capacity":"flow"}(t),r=Ug[o],c=Math.max(12,t.width-8),l=us(c-8,22,88),d=fs(t.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,m=function(t){if(null!=t.capacity){const e=null!=t.queueDepth?" · q "+t.queueDepth:"";return t.capacityLabel?`${t.capacityLabel}${e}`:`cap ${Number.isInteger(t.capacity)?t.capacity+"":t.capacity.toFixed(1)}${e}`}return t.absorb?"absorb":t.portalTarget?"portal":"flow"}(t),b=fs(m,Math.max(16,c-10),"auto"),v=n&&!1!==t.showBadge&&c>=32,w=null!=t.count?`n=${t.count}${null!=t.processed?" done "+t.processed:""}`:"",k=fs(w,Math.max(16,c-8),"auto"),A=Math.max(30,f-15),S=A-13;return(0,Hg.jsxs)("g",{"data-stage":t.id,"data-role":o,children:[(0,Hg.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:t.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:a?"none":r.fill,stroke:r.stroke,strokeWidth:a?1.85:"flow"===o?1:1.6}),g.length-1>e?(0,Hg.jsx)("polygon",{points:`${t.x1-2},${y-7} ${t.x1+8},${y} ${t.x1-2},${y+7}`,fill:r.accent,opacity:.85}):null,h?(0,Hg.jsxs)(Hg.Fragment,{children:[(0,Hg.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:t.x-l/2,y:S,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:r.stroke}),(0,Hg.jsxs)("text",{x:t.x,y:A,textAnchor:"middle",fill:r.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Hg.jsx)("title",{children:t.label}),d.text]})]}):null,v?(0,Hg.jsxs)("text",{x:t.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,Hg.jsx)("title",{children:m}),b.text]}):null,i&&null!=t.count?(0,Hg.jsxs)("text",{x:t.x,y:Math.min(u-8,p+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[(0,Hg.jsx)("title",{children:w}),k.text]}):null]},t.id)}),r?m.map((t,e)=>{const o=t.total??0,i=t.absorbed??0,n=t.complete??(o>0&&i>=o),r=!n&&o>0&&i/o>=.75,s=n?"rgba(52, 211, 153, 0.35)":r?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=n?"#34d399":r?"#fbbf24":"var(--semiotic-border, #64748b)",c=o>0?`${i}/${o}${n?" shipped":r?" almost":""}`:"feature "+(e+1),l=us(Math.max(54,ds(t.label)+18,ds(c)+16),54,104),u=fs(t.label,l-12,"auto"),d=fs(c,l-12,"auto");return(0,Hg.jsxs)("g",{"data-group":t.id,children:[(0,Hg.jsx)("rect",{x:t.x-l/2,y:t.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),(0,Hg.jsxs)("text",{x:t.x,y:t.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,Hg.jsx)("title",{children:t.label}),u.text]}),(0,Hg.jsxs)("text",{x:t.x,y:t.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Hg.jsx)("title",{children:c}),d.text]})]},t.id)}):null]})}({width:e,height:a,left:n.left,right:n.right,topY:n.topY,bottomY:n.bottomY,midY:n.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...i})}}function ys(t,e,o){if(!1===o||!e||0===t.length)return;const i=new Map(e.volume.stages.map(t=>[t.id,t]));return({size:o})=>{const n=[Number(o[0])||e.volume.width,Number(o[1])||e.volume.height],r=wi(n),s=Math.max(1,...t.map(t=>t.value)),a=Math.min(48,.18*r.plot.height),c=r.plot.y+6;return(0,Kg.jsx)("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:e.stages.map((e,o)=>{const n=t[o];if(!n)return null;const r=i.get(e.id);if(!r)return null;const l=Math.max(2,n.value/s*a),u=Math.max(8,.35*r.width);return(0,Kg.jsx)("rect",{x:r.x-u/2,y:c,width:u,height:l,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},e.id)})})}}function gs(t){return t.map((t,e)=>`${0===e?"M":"L"} ${t.x} ${t.y}`).join(" ")}function ms(t,e){const{showNodeLabels:o,showSensors:i,showStaticFlow:n}=e;if(t&&(n||i||o))return({size:e})=>{const r=[Number(e[0])||760,Number(e[1])||420],s=Math.max(1,...t.links.map(t=>t.throughput)),a=new Set(t.nodes.map(t=>t.sensorId));return(0,Zg.jsxs)("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[n?t.links.map(t=>{const e=3+t.throughput/s*16,o=t.path[Math.floor(t.path.length/2)];return(0,Zg.jsxs)("g",{children:[(0,Zg.jsx)("path",{d:gs(t.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:e+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),(0,Zg.jsx)("path",{d:gs(t.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),o?(0,Zg.jsx)("text",{x:o.x,y:o.y-e/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:(i=t.throughput,i.toLocaleString(void 0,1e3>Math.abs(i)?{maximumFractionDigits:1}:{maximumFractionDigits:0}))}):null]},t.id);var i}):null,t.nodes.map(t=>(0,Zg.jsxs)("g",{children:[i&&a.has(t.sensorId)?(0,Zg.jsx)("rect",{"data-testid":"physical-flow-sensor-overlay",x:t.x-12,y:t.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,n?(0,Zg.jsx)("circle",{cx:t.x,cy:t.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,o?(0,Zg.jsx)("text",{x:t.x,y:t.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:t.label}):null]},t.id))]})}}function xs({layout:t,compact:e,showLabels:o}){const i=e?Math.round(.14*t.height):Math.max(80,t.routeY-180),n=e?Math.max(6,Math.round(.72*t.height)):Math.min(360,t.height-170);return(0,Qg.jsx)(Qg.Fragment,{children:t.gates.map(r=>(0,Qg.jsxs)("g",{children:[(0,Qg.jsx)("rect",{x:r.x-r.width/2,y:i,width:r.width,height:n,rx:e?2:12,fill:r.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:r.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),o?(0,Qg.jsx)("text",{x:r.x,y:Math.max(64,t.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:r.label??r.id}):null]},r.id))})}function bs({layout:t,states:e,compact:o=!1}){return o?(0,Qg.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:(0,Qg.jsx)(xs,{layout:t,compact:!0,showLabels:!1})}):(0,Qg.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,Qg.jsx)("path",{d:`M ${t.startX-42} ${t.routeY} C ${.24*t.width} ${t.routeY-70}, ${.42*t.width} ${t.routeY+78}, ${.58*t.width} ${t.routeY} S ${.78*t.width} ${t.routeY-82}, ${t.socketX+36} ${t.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),(0,Qg.jsx)("line",{x1:Math.round(.06*t.width),x2:Math.round(.94*t.width),y1:t.crashY,y2:t.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),(0,Qg.jsx)("text",{x:Math.round(.07*t.width),y:t.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),(0,Qg.jsx)(xs,{layout:t,compact:!1,showLabels:!0}),(0,Qg.jsxs)("g",{children:[(0,Qg.jsx)("rect",{x:t.socketX-52,y:t.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),(0,Qg.jsx)("text",{x:t.socketX,y:t.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,Qg.jsxs)("g",{children:[(0,Qg.jsx)("rect",{x:t.graveyardX-82,y:t.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),(0,Qg.jsx)("text",{x:t.graveyardX,y:t.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,Qg.jsx)("text",{x:t.graveyardX,y:t.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:e.some(t=>t.killed)?"lift shut off":"too heavy or too small"})]})]})}function vs({states:t,layout:e}){const o=function(t){return t.map(t=>({label:t.id,value:Math.max(0,Number(t.viability)||0),outcome:t.outcome||t.stage||"in-process"}))}(t);if(!o.length)return null;const i=Math.max(1,...o.map(t=>t.value)),n=Math.max(40,(e.width-80)/o.length);return(0,Qg.jsxs)("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:e.width,height:e.height,viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,Qg.jsx)("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),o.map((t,e)=>{const o=40+e*n,r=Math.max(2,t.value/i*28),s=/kill|crash|block|grave/i.test(t.outcome);return(0,Qg.jsxs)("g",{children:[(0,Qg.jsx)("rect",{x:o+.18*n,y:28-r+22,width:Math.max(10,.45*n),height:r,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),(0,Qg.jsx)("text",{x:o+.4*n,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:t.label})]},t.label)})]})}function ws(t){return t.map(t=>({...t,spawnAt:void 0}))}function ks(t,e){return t?e?o=>tg.createElement(tg.Fragment,null,"function"==typeof t?t(o):t,"function"==typeof e?e(o):e):t:e}function As(t,e,o){const i=e[o];return"boolean"==typeof i?i:!0!==t.__compactMode}function Ss(t){let e=2166136261;for(let o=0;t.length>o;o+=1)e^=t.charCodeAt(o),e=Math.imul(e,16777619);return tm[(e>>>0)%tm.length]}function Ms(t,e){return t===e}function _s(t,e){if("function"==typeof t)return e=>+t(e);const o=t||e;return t=>+t[o]}function $s(t,e){if("function"==typeof t)return t;const o=t||e;return t=>t[o]}function Ps(t,e){return"function"==typeof t?e=>t(e)+"":t?e=>e[t]+"":e?t=>t[e]+"":void 0}function js(t){return t?"function"==typeof t?t:e=>e[t]||e.id:null}function Is(t){return"string"==typeof t?t:t.id}function Ls(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const o=ym.test(e)?e+"-01":e;if(o===e&&10>e.length)return NaN;const i=Date.parse(o);return Number.isFinite(i)?i:NaN}function Rs(t){return t instanceof Date?t.getTime():"string"==typeof t?Ls(t):+t}function Ts(t){return new Set(Array.isArray(t)?t:[t])}function Cs(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Os(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Fs(t,e,o){return t+(e-t)*o}function Ds(){return"undefined"!=typeof performance?performance.now():Date.now()}function Ns(t,e,o){if(1>=o)return 1;const i=o-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 o=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>o?1:e;if("exponential"===t.type){const i=t.halfLife??t.extent/2;return e+Math.pow(.5,o/(i>0?i:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-o/t.extent))*(1-e)}({age:i-e,extent:i,type:t.type,halfLife:t.halfLife??o/2,threshold:t.stepThreshold??.5*o,minOpacity:t.minOpacity??.1})}function zs(t){const e=new Map;for(let o=0;t.length>o;o++)e.set(t[o],o);return e}function Es(t,e,o){const i=t.duration??500,n=o-e;return i>n?1-n/i:0}function Bs(t,e,o,i){let n=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,n=!0),t._pulseColor!==o&&(t._pulseColor=o,n=!0),t._pulseGlowRadius!==i&&(t._pulseGlowRadius=i,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 Ws(t,e,o=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const i=t.duration??500,n=e.peek();return null!=n&&i>o-n}function Ys(t,e,o){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 o=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${o}:${i}`;if(null!=o&&null!=i)return`p:${o}:${i}`}return"p:"+o;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+o;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??o}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+o:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function qs(t){return t?null!=t.opacity?t.opacity:null!=t.fillOpacity?t.fillOpacity:1:1}function Xs(t){gm[t.chartType]=t}function Gs(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:o,overlays:i,warned:n}=t;Vs(i)&&0===o.length&&Hs(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.`),o.length>0&&o.every(t=>null==t.datum)&&Hs(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 Vs(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Vs))}function Hs(t,e,o){t.has(e)||(t.add(e),console.warn(o))}function Us(t){try{return{kind:"success",result:t.run()}}catch(e){const o=t.hasPreviousResult,i=function(t,e,o,i){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:o?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:o,affectedRevision:i}}(t.family,e,o,t.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${t.logLabel} threw:`,e);try{t.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return{kind:"failure",diagnostic:i,preservedLastGoodScene:o}}}function Ks(t,e){const o="function"==typeof t?t:o=>o[t||e];return t=>{const e=o(t);return null==e?NaN:+e}}function Zs(t){const e=[],o=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=Ks(o&&t.valueAccessor||t.yAccessor,o?"value":"y");if(t.boundsAccessor){const o=_s(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const n=o(t);return Number.isFinite(n)&&0!==n?e+n:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const n=o(t);return Number.isFinite(n)&&0!==n?e-n:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const o=Array.isArray(t.band)?t.band:[t.band];for(const t of o)e.push({kind:"band",getTop:Ks(t.y1Accessor,"y1"),getBottom:Ks(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}function Qs(t,e,o,i,n,r=!1){const s=new Map;for(const a of t){const t=e(a),c=o(a);if(null==t||null==c||Number.isNaN(t)||Number.isNaN(c))continue;const l=Math.floor(t/i)*i;let u=s.get(l);if(u||(u={start:l,end:l+i,total:0,categories:new Map,...r?{rows:[],categoryRows:new Map}:{}},s.set(l,u)),u.total+=c,u.rows?.push(a),n){const t=n(a);if(u.categories.set(t,(u.categories.get(t)||0)+c),u.categoryRows){let e=u.categoryRows.get(t);e||(e=[],u.categoryRows.set(t,e)),e.push(a)}}}return s}function Js(t,e,o,i,n){const r=[];for(const s of t){const t=o(s),a=i(s),c=n?n(s):0;if(!Number.isFinite(t)||!Number.isFinite(a)||!Number.isFinite(c))continue;const l=e.x(t),u=e.y(a),d=n?e.y(c):0;Number.isFinite(l)&&Number.isFinite(u)&&Number.isFinite(d)&&r.push({x:l,y:u,bottom:d,raw:a,datum:s})}r.sort((t,e)=>t.x-e.x);const s=Array(r.length),a=n?Array(r.length):[],c=Array(r.length),l=Array(r.length);for(let t=0;r.length>t;t++){const e=r[t];s[t]=[e.x,e.y],n&&(a[t]=[e.x,e.bottom]),c[t]=e.raw,l[t]=e.datum}return{topPath:s,bottomPath:a,rawValues:c,datum:l}}function ta(t,e,o,i,n,r){const{topPath:s,rawValues:a,datum:c}=Js(t,e,o,i);return{type:"line",path:s,rawValues:a,style:n,datum:c,group:r}}function ea(t,e,o,i,n,r,s,a){return{type:"area",...Js(t,e,o,i,a??(()=>n)),style:r,group:s}}function oa(t,e,o,i){const n=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const n of e)t+=o(n,i)||0;n.set(i,-t/2)}else if("wiggle"===i){t.length>0&&n.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];let a=0,c=0,l=0;for(const t of e){const e=o(t,s)||0;a+=(2*l+e)*(e-(o(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 i=0;for(const r of t){let t=0;for(const i of e)t+=o(i,r)||0;i+=(n.get(r)??0)+t/2}const r=i/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 ia(t,e,o,i,n,r,s){const a=o(t),c=i(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:n,style:r,datum:t};return void 0!==s&&(l.pointId=s),l}function na(t,e,o,i,n,r,s,a){const c=o(t),l=i(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:n,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function ra(t,e,o,i,n,r,s){return{type:"rect",x:t,y:e,w:o,h:i,style:n,datum:r,group:s}}function sa(t,e,o,i,n,r,s){const a={type:"heatcell",x:t,y:e,w:o,h:i,fill:n,datum:r};return void 0!==s?.value&&(a.value=s.value),s?.showValues&&(a.showValues=!0,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function aa(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function ca(t,e,o){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return(0,bm.scaleLog)().domain(t).range(o).clamp(!0)}return"symlog"===t?(0,bm.scaleSymlog)().domain(e).range(o):"time"===t?(0,bm.scaleTime)().domain([new Date(e[0]),new Date(e[1])]).range(o):(0,bm.scaleLinear)().domain(e).range(o)}function la(t,e){return t&&"object"==typeof t&&!Array.isArray(t)?Mt(t,e):void 0}function ua(t,e,o){e>t.capacity&&(t.resize(e),o&&e>o.capacity&&o.resize(e))}function da(t,e){const o=new fm(t.capacity);return t.forEach(()=>o.push(e)),o}function ha(t,e,o,i){const n=t.push(e);return o&&o.push(i),n}function fa(t,e,o){if(!e||0===e.size)return;const i=new Set;if(t.forEach((t,e)=>{o(t)&&i.add(e)}),0===i.size)return;const n=e.toArray();e.clear();for(let t=0;n.length>t;t++)i.has(t)||e.push(n[t])}function pa(){return this.updateResults.last}function ya(){return this.updateResults.last}function ga(t){return this.updateResults.subscribe(t)}function ma(t){this.config.layoutSelection=t}function xa(){vm.set(this,!0)}function ba(){const t=!0===vm.get(this);return vm.delete(this),t}function va(t){Object.assign(t.prototype,{getLastUpdateResult:pa,getUpdateSnapshot:ya,subscribeUpdateResult:ga,setLayoutSelection:ma,markStylePaintPending:xa,consumeStylePaintPending:ba})}function wa(t,e,o,i){return"function"==typeof e.style?e.style(i||{},o):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(o,i)}function ka(t,e,o,i){if(!t.scales)return null;const{topPath:n,bottomPath:r,datum:s}=Js(e,t.scales,t.getX,i.getTop,i.getBottom);return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,...t.config.curve&&"linear"!==t.config.curve&&{curve:t.config.curve},style:wa(t,i,o,ge(e)),datum:s,group:o,interactive:i.interactive}}function Aa(t){const e=[],o=[];if(!t)return{perSeries:e,aggregate:o};for(const i of t)i.perSeries?e.push(i):o.push(i);return{perSeries:e,aggregate:o}}function Sa(t,e,o){const i=[];for(const n of o){const o=ka(t,e,"__ribbon_aggregate",n);o&&i.push(o)}return i}function Ma(t,e,o,i){const n=[];for(const r of i){const i=ka(t,e,o,r);i&&n.push(i)}return n}function _a(t,e,o,i){if(!t.config.pointStyle)return;const n=i??t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const r of i.data){let i=t.config.pointStyle(r);!i.fill&&e&&(i={...i,fill:e});const s=i.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,c=ia(r,t.scales,t.getX,n,s,i,a);c&&o.push(c)}}}function $a(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}function Pa(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ja(t,e,o=.3){Pa(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Ia(t,e,o,i=.35){Pa(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",o?t.fill(o):t.fill())}function La(t,e,o){let i=o;for(const o of e)"lesser"===o.thresholdType?o.value>t&&(i=o.color):t>o.value&&(i=o.color);return i}function Ra(t,e,o,i){if(2>t.length||e.length!==t.length||0===o.length)return[];const n=[],r=(t,e,o)=>{const i=n[n.length-1];i?.color===t?i.path.push(o):n.push({color:t,path:[e,o]})};for(let n=1;t.length>n;n++){const[s,a]=t[n-1],[c,l]=t[n],u=e[n-1],d=e[n]-u,h=[0,...0===d?[]:o.map(({value:t})=>(t-u)/d).filter(t=>t>0&&1>t&&Number.isFinite(t)).sort((t,e)=>t-e).filter((t,e,o)=>0===e||t!==o[e-1]),1];for(let t=1;h.length>t;t++){const e=h[t-1],n=h[t];r(La(u+d*((e+n)/2),o,i),[s+(c-s)*e,a+(l-a)*e],[s+(c-s)*n,a+(l-a)*n])}}return n}function Ta(t,e){const o=Hr(e.curve);if(!o||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let o=1;e.topPath.length>o;o++)t.lineTo(e.topPath[o][0],e.topPath[o][1]);for(let o=e.bottomPath.length-1;o>=0;o--)t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]);t.closePath()}else{const i=(0,Nm.area)().x(t=>t[0]).y0((t,o)=>e.bottomPath[o][1]).y1(t=>t[1]).curve(o).context(t);t.beginPath(),i(e.topPath)}}function Ca(t,e){const o=Hr(e.curve);if(t.beginPath(),o)(0,Nm.line)().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let o=1;e.topPath.length>o;o++)t.lineTo(e.topPath[o][0],e.topPath[o][1])}}function Oa(t,e,o,i,n,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const o=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(o*o+i*i))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);t.strokeStyle=o,t.lineWidth=i,t.lineCap=r;for(let o=0;e.length-1>o;o++){const i=(s[o]+s[o+1])/2;let r=n;c>i&&(r*=i/c),c>a-i&&(r*=(a-i)/c),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[o][0],e[o][1]),t.lineTo(e[o+1][0],e[o+1][1]),t.stroke()}}function Fa(t){return Yt(t)}function Da(t,e,o){if(o)return o;const i=t??"circle";if("chevron"===i)return function(t){const e=1.5*Na(t),o=.92*e;return`M0,${-e}L${o},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-o},${(.78*e).toFixed(3)}Z`}(e);const n=Object.prototype.hasOwnProperty.call(Hm,i)?Hm[i]:Vm.symbolCircle;return(0,Vm.symbol)(n,Math.max(1,e))()??""}function Na(t){return Math.sqrt(Math.max(1,t)/Math.PI)}function za(t,e){const o=new Map;let i=0;return n=>{const r=t(n)+"",s=e&&Object.prototype.hasOwnProperty.call(e,r)?e[r]:void 0;if(s&&Um.has(s))return s;let a=o.get(r);return a||(a=Km[i%Km.length],i++,o.set(r,a)),a}}function Ea(t,e){const o=[],i="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let r=null;if(t.getSize&&!t.config.pointStyle){const o=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(o.length>0){let t=1/0,e=-1/0;for(const i of o)t>i&&(t=i),i>e&&(e=i);r=o=>t===e?(n[0]+n[1])/2:n[0]+(o-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=c?za(c,t.config.symbolMap):null;for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},c=e.r||i;if(r&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(c=r(e))}if(s&&t.getColor&&!e.fill){const o=t.getColor(n);o&&s.has(o)&&(e={...e,fill:s.get(o)})}const u=t.getPointId?t.getPointId(n)+"":void 0;if(l){const i=l(n),r=na(n,t.scales,t.getX,t.getY,Math.PI*c*c,i,e,u);r&&o.push(r)}else{const i=ia(n,t.scales,t.getX,t.getY,c,e,u);i&&o.push(i)}}return o}function Ba(t,e){const[o,i]=t.viewBox??Zm,[n,r]=t.anchor??Qm,s=i>0?i:1,a=Math.max(0,e)/s,c=(o>0?o:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-n*c,offsetY:-r*l}}function Wa(t,e,o,i){if("none"!==t)return"color"===t||null==t?e??i:"accent"===t?o:t}function Ya(t){if("undefined"==typeof Path2D)return null;Jm||(Jm=new Map);const e=Jm.get(t);if(e)return e;const o=new Path2D(t);return Jm.size>1024&&Jm.clear(),Jm.set(t,o),o}function qa(t,e,o=0,i="horizontal"){const[n,r]=t.viewBox??Zm,s=Math.min(1,Math.max(0,o)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===i?{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}}function Xa(t,e){const o=Ba(t,e);return{centerDx:o.offsetX+o.width/2,centerDy:o.offsetY+o.height/2,halfWidth:o.width/2,halfHeight:o.height/2,radius:Math.hypot(o.width,o.height)/2}}function Ga(t,e,o,i,n,r=t=>t){for(const s of e.parts){const e=Ya(s.d);if(!e)continue;const a=s.opacity??1,c=t.globalAlpha;1!==a&&(t.globalAlpha=c*a);const l=n?"none"===s.fill?void 0:n:Wa(s.fill,o,i);l&&(t.fillStyle=r(l),t.fill(e));const u=n?s.stroke&&"none"!==s.stroke?n:void 0:Wa(s.stroke??"none",o,i);u&&(t.strokeStyle=r(u),t.lineWidth=s.strokeWidth??1,t.lineCap=s.strokeLinecap??"butt",t.lineJoin=s.strokeLinejoin??"miter",t.stroke(e)),1!==a&&(t.globalAlpha=c)}}function Va(t,e,o,i,n,r){if(0>=e.size)return;const s=function(t,e,o){try{if(o)return Ya(o);const i=`${t??"circle"}:${e}`;let n=tx.get(i);return n||(n=new Path2D(Da(t,e)),tx.size>256&&tx.clear(),tx.set(i,n)),n}catch{return null}}(e.symbolType,e.size,e.path);if(!s)return;t.save(),t.translate(o,i),e.rotation&&t.rotate(e.rotation);const a=(e.style.opacity??1)*(e._decayOpacity??1);e.style.fill&&(t.globalAlpha=n*a*(e.style.fillOpacity??1),t.fillStyle=Ur(t,e.style.fill,r),t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*a,t.strokeStyle=ni(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.stroke(s)),t.restore()}function Ha(t,e,o){return e===o?128:Math.min(Math.floor(255*(t-e)/(o-e)+.5),255)}function Ua(t){const e=Object.prototype.hasOwnProperty.call(Kf,t)?t:"blues";let o=sx.get(e);if(o)return o;o=Array(rx);const i=kt(e);for(let t=0;rx>t;t++)o[t]=i(t/255);return sx.set(e,o),o}function Ka(t,e,o){const i=o.config.areaStyle?.(e);return i&&("string"==typeof i.fill&&(t.fill=i.fill),t.style=i),t}function Za(t,e,o){const i=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=_s(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),d=(c-a||1)/i,h=(u-l||1)/n,f=i*n;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f),g=t.config.trackHoverRows||me(t.config.areaStyle)?new Map:void 0;for(let o=0;e.length>o;o++){const r=e[o],c=t.getX(r),u=t.getY(r);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),i-1),m=Math.min(Math.floor((u-l)/h),n-1);if(0>f||0>m)continue;const x=m*i+f;p[x]++;const b=s(r);if(y[x]+=isFinite(b)?b:0,g){let t=g.get(x);t||(t=[],g.set(x,t)),t.push(r)}}let m=1/0,x=-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]}m>e&&(m=e),e>x&&(x=e)}if(!isFinite(m))return[];const b=t.config.heatmapColorScale,v=b?void 0:Ua("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),w=o.width/i,k=o.height/n,A=t.config.showValues,S=t.config.heatmapValueFormat,M=[];for(let e=0;n>e;e++){const o=e*i;for(let s=0;i>s;s++){const i=o+s;if(0===p[i])continue;let c;switch(r){case"sum":c=y[i];break;case"mean":c=y[i]/p[i];break;default:c=p[i]}const u=Ha(c,m,x),f=b?b(c):v[u],_=A?{value:c,showValues:!0,valueFormat:S}:{value:c},$=fe({xi:s,yi:e,value:c,count:p[i],sum:y[i],xCenter:a+(s+.5)*d,yCenter:l+(e+.5)*h,agg:r},g?.get(i));M.push(Ka(sa(s*w,(n-1-e)*k,w,k,f,$,_),$,t))}}return M}function Qa(t,e){const[o,i,n]=Vr(t,e);return.299*o+.587*i+.114*n>128?"#000":"#fff"}function Ja(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}function tc(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}function ec(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const o=Math.min(t.w,t.h)/2,i=t=>Math.max(0,Math.min(t??0,o));return{tl:i(e.tl),tr:i(e.tr),br:i(e.br),bl:i(e.bl)}}function oc(t,e){const{x:o,y:i,w:n,h:r}=e,{tl:s,tr:a,br:c,bl:l}=ec(e);t.beginPath(),t.moveTo(o+s,i),t.lineTo(o+n-a,i),a>0&&t.arcTo(o+n,i,o+n,i+a,a),t.lineTo(o+n,i+r-c),c>0&&t.arcTo(o+n,i+r,o+n-c,i+r,c),t.lineTo(o+l,i+r),l>0&&t.arcTo(o,i+r,o,i+r-l,l),t.lineTo(o,i+s),s>0&&t.arcTo(o,i,o+s,i,s),t.closePath()}function ic(t,e){const o=Ur(t,e.style.fill,ni(t,"var(--semiotic-primary, #007bff)")),i=function(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}(e);return(e.fillGradient&&"string"==typeof o?Zr(t,e.fillGradient,o,i.x0,i.y0,i.x1,i.y1):null)||o}function nc(t,e){if(!e.style.stroke||"none"===e.style.stroke)return!1;const o=e.style.strokeWidth??1;return o>0&&(t.strokeStyle=ni(t,e.style.stroke)||e.style.stroke,t.lineWidth=o,!0)}function rc(t,e){const o=e.style.icon,i=e.style.iconPadding||2,n=Math.min(e.w,e.h)-i;if(0>=n)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=n+i,s=e.x+(e.w-n)/2;for(let i=e.y+e.h-n;i>=e.y-n;i-=r)t.drawImage(o,s,i,n,n)}else{const r=n+i,s=e.y+(e.h-n)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(o,i,s,n,n)}t.restore()}function sc(t,e,o,i,n){if(0>=e.size)return;const r=e.glyph;if(!r||!r.parts?.length)return;const s=Ba(r,e.size);if(0>=s.scale)return;const a=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=a)return;const c=e=>{const o=Ur(t,e,e);return"string"==typeof o?o:e},l=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(o,i),e.rotation&&t.rotate(e.rotation),t.translate(s.offsetX,s.offsetY),t.scale(s.scale,s.scale),t.globalAlpha=n*a*(e.style.fillOpacity??1);const u=qa(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");u&&e.ghostColor&&Ga(t,r,l,e.accent,e.ghostColor,c),u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),Ga(t,r,l,e.accent,void 0,c),t.restore()}function ac(){Xs(Ym),Xs(qm),Xs(Xm),Xs(Gm),Xs(ix),Xs(nx),Xs(cx),Xs(ux),Xs(dx),Xs(fx),Xs(yx),Xs(gx)}function cc(t){const e=t.parts.filter(t=>null!=t),o={};for(const t of e)for(const[e,i]of Object.entries(t.markCountByType))o[e]=(o[e]??0)+i;for(const[e,i]of Object.entries(t.additionalMarkCountByType??{}))i>0&&(o[e]=(o[e]??0)+i);const i=Object.values(o).reduce((t,e)=>t+e,0),n=0===i,r=Array.from(new Set([...e.flatMap(t=>t.warnings),...t.extraWarnings??[],...n?["EMPTY_SCENE"]:[]])),s="string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${i} marks`;return{component:"",frameType:t.frameType,status:n?"empty":"ok",empty:n,markCount:i,markCountByType:o,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:e.reduce((t,e)=>t+e.annotationCount,0),ariaLabel:s,warnings:r,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function lc(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function uc(t){if(!t||2>t.length)return;const e=lc(t[0]),o=lc(t[t.length-1]);return null!==e&&null!==o?[e,o]:void 0}function dc(t){const{count:e,byType:o}=function(t){const e={};for(const o of t){const t="string"==typeof o?.type&&o.type.length>0?o.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),i=0===e,n=[...t.extraWarnings??[]];i&&!n.includes("EMPTY_SCENE")&&n.push("EMPTY_SCENE"),t.annotationRender&&t.annotationRender.unrenderedCount>0&&!n.includes("UNRENDERED_ANNOTATIONS")&&n.push("UNRENDERED_ANNOTATIONS");const r=Array.isArray(t.annotations)?t.annotations.length:0,s=t.margin,a=s?{x:s.left,y:s.top,width:t.width-s.left-s.right,height:t.height-s.top-s.bottom}:void 0;return{component:"",frameType:t.frameType,status:i?"empty":"ok",empty:i,markCount:e,markCountByType:o,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:t.annotationRender?.renderedCount??r,...t.annotationRender?{annotationInputCount:t.annotationRender.inputCount,unrenderedAnnotationCount:t.annotationRender.unrenderedCount,...t.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:t.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:n,semanticStatus:"not-assessed",semanticDiagnostics:[],...s?{margin:s}:{},...a?{plot:a}:{}}}function hc(t,e="#4e79a7"){return ri(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function fc(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function pc(t,e,o,i){const n=t.glyph;if(!n?.parts?.length||0>=t.size)return null;const r=Ba(n,t.size);if(0>=r.scale)return null;const s=`translate(${e},${o})${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=qa(n,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),l=c?fc(i+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),d=e=>n.parts.map((o,i)=>{const n=e?"none"===o.fill?void 0:e:Wa(o.fill,a,t.accent),r=e?o.stroke&&"none"!==o.stroke?e:void 0:Wa(o.stroke??"none",a,t.accent);return n||r?(0,vx.jsx)("path",{d:o.d,fill:n??"none",stroke:r,strokeWidth:r?o.strokeWidth??1:void 0,strokeLinecap:o.strokeLinecap,strokeLinejoin:o.strokeLinejoin,opacity:o.opacity},i):null});return(0,vx.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,vx.jsx)("clipPath",{id:l,children:(0,vx.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?(0,vx.jsx)("g",{children:d(t.ghostColor)}):null,c&&l?(0,vx.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},i)}function yc(t,e){const o=t.filter(t=>Number.isFinite(t.offset)&&(null==t.opacity||Number.isFinite(t.opacity))).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color??e,opacity:null==t.opacity?void 0:Math.max(0,Math.min(1,t.opacity))}));return 2>o.length?null:o.map((t,e)=>(0,vx.jsx)("stop",{offset:t.offset,stopColor:t.color,stopOpacity:t.opacity},e))}function gc(t,e,o){const i=Da(t.symbolType,t.size,t.path);return(0,vx.jsx)("path",{d:i,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?hc(t.style.fill):"none",fillOpacity:t.style.fillOpacity,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${o??""}symbol-${e}`)}function mc(t,e,o){const i="point"===t.type,n=i?"circle":"rect",r=i?{cx:t.x,cy:t.y,r:t.r}:{x:t.x,y:t.y,width:t.w,height:t.h},s=`${o?o+"-":""}${i?"point":"xyrect"}-${e}-hatch`,a=ri(t.style.fill)?ai(t.style.fill,s):void 0;return(0,vx.jsxs)(bx.Fragment,{children:[a&&(0,vx.jsx)("defs",{children:a}),bx.createElement(n,{...r,fill:a?`url(#${s})`:hc(t.style.fill),opacity:i?t.style.opacity??t.style.fillOpacity??.8:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},`${t.type}-${e}`)}function xc(t){if(!1!==t?.interactive)return t?.style?.cursor}function bc(t,e,o){const i=xc(e);return i&&null!=t&&!1!==t?(0,kx.jsx)("g",{style:{cursor:i},"data-semiotic-mark-cursor":i,children:t},o):t}function vc(t,e,o,i){if(!t||2>e.length)return null;const n=yc(t.stops,i);return n?(0,Ax.jsx)("linearGradient",{id:o,gradientUnits:"userSpaceOnUse",x1:e[0][0],y1:0,x2:e[e.length-1][0],y2:0,children:n}):null}function wc(t,e,o,i=30){const n=function(t,e,o,i=30){switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const n=Hr(i.curve),r=n?(0,xx.line)().x(([t])=>t).y(([,t])=>t).curve(n)(i.path)??"":"M"+i.path.map(([t,e])=>`${t},${e}`).join("L"),s=fc(`${o?o+"-":""}line-${e}-stroke-gradient`),a=vc(i.strokeGradient,i.path,s,i.style.stroke||"#4e79a7");return(0,Ax.jsxs)(mx.Fragment,{children:[a&&(0,Ax.jsx)("defs",{children:a}),(0,Ax.jsx)("path",{d:r,fill:"none",stroke:a?`url(#${s})`:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})]},"line-"+e)}case"area":{const n=t;if(0===n.topPath.length)return null;const r=Hr(n.curve),s=!r||2>n.topPath.length||2>n.bottomPath.length?`M${n.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`:(0,xx.area)().x(([t])=>t).y0((t,e)=>n.bottomPath[e][1]).y1(([,t])=>t).curve(r)(n.topPath)??"",a=`${o?o+"-":""}area-${e}-hatch`,c=ri(n.style.fill)?ai(n.style.fill,a):void 0,l=fc(`${o?o+"-":""}area-${e}-gradient`),u=function(t,e){const o=t.fillGradient;if(!o||"object"!=typeof o)return null;let i=1/0;for(const[,e]of t.topPath)i=Math.min(i,e);let n=-1/0;for(const[,e]of t.bottomPath)n=Math.max(n,e);if(!Number.isFinite(i)||!Number.isFinite(n))return null;const r=yc(o.stops,hc(t.style.fill));return r?(0,Ax.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:0,y1:i,x2:0,y2:n,children:r}):null}(n,l),d=u?`url(#${l})`:c?`url(#${a})`:hc(n.style.fill),h=u?void 0:n.style.fillOpacity??n.style.opacity??.7,f=r?(0,xx.line)().x(([t])=>t).y(([,t])=>t).curve(r)(n.topPath)??"":"M"+n.topPath.map(([t,e])=>`${t},${e}`).join("L"),p=xc(n),y=p&&i>=0?(0,Ax.jsx)("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*i),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${e}-cursor-target`):null,g=fc(`${o?o+"-":""}area-${e}-stroke-gradient`),m=!(!n.colorThresholds?.length||!n.rawValues||n.rawValues.length!==n.topPath.length),x=!!n.strokeColorBands?.length,b=m||x?null:vc(n.strokeGradient,n.topPath,g,n.style.stroke||"#4e79a7"),v=n.style.strokeWidth??2;let w=1/0,k=-1/0;for(const[t]of n.topPath)w>t&&(w=t),t>k&&(k=t);const A=x?n.strokeColorBands.map((t,i)=>fc(`${o?o+"-":""}area-${e}-stroke-band-${i}`)):[],S=x?n.strokeColorBands.map((t,e)=>(0,Ax.jsx)("clipPath",{id:A[e],children:(0,Ax.jsx)("rect",{x:w-v,y:t.y,width:k-w+2*v,height:t.height})},A[e])):null,M=n.style.stroke&&"none"!==n.style.stroke?x?n.strokeColorBands.map((t,o)=>(0,Ax.jsx)("path",{d:f,fill:"none",stroke:t.color??hc(n.style.stroke),strokeWidth:v,opacity:(n.style.opacity??1)*(t.opacity??1),clipPath:`url(#${A[o]})`},`area-${e}-stroke-band-${o}`)):m?Ra(n.topPath,n.rawValues,n.colorThresholds,hc(n.style.stroke)).map((t,o)=>(0,Ax.jsx)("path",{d:"M"+t.path.map(([t,e])=>`${t},${e}`).join("L"),fill:"none",stroke:t.color,strokeWidth:v,opacity:n.style.opacity},`area-${e}-threshold-${o}`)):(0,Ax.jsx)("path",{d:f,fill:"none",stroke:b?`url(#${g})`:hc(n.style.stroke),strokeWidth:v,opacity:n.style.opacity}):null;if(n.clipRect){const t=`${o?o+"-":""}area-clip-${e}`;return(0,Ax.jsxs)("g",{children:[(0,Ax.jsxs)("defs",{children:[u,!u&&c,b,S,(0,Ax.jsx)("clipPath",{id:t,children:(0,Ax.jsx)("rect",{x:n.clipRect.x,y:n.clipRect.y,width:n.clipRect.width,height:n.clipRect.height})})]}),(0,Ax.jsxs)("g",{clipPath:`url(#${t})`,children:[(0,Ax.jsx)("path",{d:s,fill:d,fillOpacity:h,opacity:u?n.style.opacity:void 0,stroke:"none"}),M,y]})]},"area-"+e)}return(0,Ax.jsxs)(mx.Fragment,{children:[(u||c||b||S)&&(0,Ax.jsxs)("defs",{children:[u,!u&&c,b,S]}),(0,Ax.jsx)("path",{d:s,fill:d,fillOpacity:h,opacity:u?n.style.opacity:void 0,stroke:"none"}),M,y]},"area-"+e)}case"point":case"rect":return mc(t,e,o);case"symbol":return gc(t,e);case"glyph":return pc(t,t.x,t.y,`${o??""}glyph-${t.pointId??e}`);case"heatcell":{const o=t,i={x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill,stroke:o.style?.stroke,strokeWidth:o.style?.strokeWidth,...null!=o.style?.opacity&&{opacity:o.style.opacity}};if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const t=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[n,r,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*n+.587*r+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return(0,Ax.jsxs)("g",{children:[(0,Ax.jsx)("rect",{...i}),(0,Ax.jsx)("text",{className:"semiotic-heatmap-value",x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",fontFamily:"var(--semiotic-font-family, sans-serif)",children:t})]},"heatcell-"+e)}return(0,Ax.jsx)("rect",{...i},"heatcell-"+e)}case"candlestick":{const i=t,n=`${o?o+"-":""}candle-${e}-hatch`,r=ri(i.style?.fill)?ai(i.style.fill,n):void 0,s=r?`url(#${n})`:void 0,{fill:a,...c}=i.style??{};if(i.isRange){const t=i.dotRadius??Math.max(2,i.bodyWidth/2),o=s??i.wickColor;return(0,Ax.jsxs)(mx.Fragment,{children:[r&&(0,Ax.jsx)("defs",{children:r}),(0,Ax.jsxs)("g",{style:c,children:[(0,Ax.jsx)("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth,opacity:i.style?.opacity}),(0,Ax.jsx)("circle",{cx:i.x,cy:i.highY,r:t,fill:o,opacity:i.style?.opacity}),(0,Ax.jsx)("circle",{cx:i.x,cy:i.lowY,r:t,fill:o,opacity:i.style?.opacity})]})]},"candle-"+e)}const l=Math.min(i.openY,i.closeY),u=Math.max(Math.abs(i.openY-i.closeY),1),d=i.isUp?i.upColor:i.downColor,h=s??d;return(0,Ax.jsxs)(mx.Fragment,{children:[r&&(0,Ax.jsx)("defs",{children:r}),(0,Ax.jsxs)("g",{style:c,children:[(0,Ax.jsx)("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth,opacity:i.style?.opacity}),(0,Ax.jsx)("rect",{x:i.x-i.bodyWidth/2,y:l,width:i.bodyWidth,height:u,fill:h,stroke:s?i.wickColor:d,strokeWidth:1,opacity:i.style?.opacity})]})]},"candle-"+e)}default:return null}}(t,e,o,i);return"area"===t.type?n:bc(n,t,"xy-cursor-"+e)}function kc(t){const{node:e,index:o,renderMode:i,fallback:n}=t,r=function(t,e){const o="function"==typeof t?t(e.datum??null,e):t;return(i=o)&&"object"==typeof i&&"string"==typeof i.id&&"function"==typeof i.cacheKey&&"function"==typeof i.drawCanvas&&"function"==typeof i.renderStaticSVG?o:void 0;var i}(i,e);if(!r)return{element:n(),renderedByBackend:!1};const s=r.renderStaticSVG({node:e,style:e.style??{},key:`${r.id}-${o}`});return null!=s?{element:bc(s,e,`${r.id}-${o}-cursor`),renderedByBackend:!0}:(function(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const o=`${t}:${e}`;Sx.has(o)||(Sx.add(o),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}(r.id,e.type??"unknown"),{element:n(),renderedByBackend:!1})}function Ac(t){const e=[];return t.nodes.forEach((o,i)=>{const n=kc({node:o,index:i,renderMode:t.renderMode,fallback:()=>t.fallback(o,i)});null!=n.element&&!1!==n.element&&e.push({node:o,index:i,...n})}),e}function Sc(t,e,o){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>Mt(t,e)??"#999"}const i=Array.isArray(e)?e:o.colors.categorical.length>0?o.colors.categorical:Df;return(0,Mx.scaleOrdinal)().domain(t).range(i)}function Mc(t,e,o){if(0===t.length)return;const i=Sc(t,e,o);return{legendGroups:[{label:"",type:"fill",items:t.map(t=>({label:t})),styleFn:t=>({fill:i(t.label)})}]}}function _c(t){return"left"===t?"start":"right"===t?"end":t??"start"}function $c(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function Pc(t){return t.typography.legendFontFamily??t.typography.fontFamily}function jc(t){return t.typography.legendFontWeight}function Ic(t,e,o,i){const n=$c(i);return e+o+Math.ceil(t.length*n*.58)}function Lc(t){const{categories:e,theme:o,position:i="right",totalWidth:n,margin:r,legendLayout:s}=t,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=v(s),d=a+c,h="top"===i||"bottom"===i,f=Math.max(a,n-r.left-r.right),p=e.map(t=>Ic(t,a,c,o));if(h){const t=Math.max(a,s?.maxWidth??f),o=[];let i=0,n=0;p.forEach((e,r)=>{const s=0===n?e:n+l+e;n>0&&s>t?(o.push({start:i,end:r,width:n}),i=r,n=e):n=s}),e.length>0&&o.push({start:i,end:e.length,width:n});const r=_c(s?.align),c=[];return o.forEach((o,i)=>{let n="center"===r?Math.max(0,(t-o.width)/2):"end"===r?Math.max(0,t-o.width):0;for(let t=o.start;o.end>t;t++)c.push({category:e[t],width:p[t],x:n,y:i*u}),n+=p[t]+l}),{items:c,width:o.reduce((t,e)=>Math.max(t,e.width),0),height:o.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}const y=p.reduce((t,e)=>Math.max(t,e),0);return{items:e.map((t,e)=>({category:t,width:p[e],x:0,y:e*u})),width:y,height:e.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}function Rc(t,e){if(!e||!t||0===t.length)return[];const o="function"==typeof e?e:t=>t[e],i=new Set;for(const e of t){const t=o(e);null!=t&&i.add(t+"")}return Array.from(i)}function Tc(t){const{x:e,y:o,text:i,fill:n,fontSize:r=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:d}=t,h=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{...t,type:t.type??"halo"}}(u),f=t=>(0,Px.jsx)("text",{x:e,y:o,textAnchor:c,dominantBaseline:l,fill:n,fontSize:r,fontWeight:s,fontFamily:a,className:d,...t?{style:{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}}:{},children:i});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??jx,strokeWidth:h.haloWidth??3});const p=h.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}(i,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?o-x/2:"hanging"===l||"text-before-edge"===l?o-g:o-.8*r-g,(0,Px.jsxs)("g",{className:d,children:[(0,Px.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:h.radius??3,ry:h.radius??3,fill:h.fill??jx,fillOpacity:h.opacity??Ix,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function Cc(t,e,o){if(!t)return null;const i="object"==typeof t?t:{};return(0,Lx.jsx)("circle",{className:"semiotic-threshold-end-cap",cx:e[0],cy:e[1],r:Math.max(0,i.radius??4),fill:i.fill??o})}function Oc({ann:t,position:e,vertical:o,width:i,height:n,color:r,fontSize:s=12,fontFamily:a,bold:c,background:l,dash:u="6,3",labelGap:d=4}){const h=t.labelPosition,f=e>.6*i,p=o?e+(f?-4:4):"left"===h?4:"center"===h?i/2:i-4,y=o?"bottom"===h?n-4:"center"===h?n/2:Rx:20>e?Math.min(n-4,e+Rx):e-d,g=o?f?"end":"start":"left"===h?"start":"center"===h?"middle":"end",m=o?[e,0]:[0,e],x=o?[e,n]:[i,e];return(0,Tx.jsxs)("g",{opacity:t.opacity,children:[(0,Tx.jsx)("line",{x1:m[0],y1:m[1],x2:x[0],y2:x[1],stroke:r,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||u}),Cc(t.endCap,m,r),t.label&&(0,Tx.jsx)(Tc,{x:p,y:y,text:t.label,textAnchor:g,fill:r,fontSize:s,fontFamily:a,fontWeight:c?"bold":void 0,background:l??t.labelBackground??"halo"})]})}function Fc(t){return{label:t.label,title:t.title,wrap:t.wrap||120,noWrap:"function"==typeof t._noteLayout?t.noWrap:void 0,_noteLayout:t._noteLayout}}function Dc(t){return"function"==typeof t._noteLayout?t._noteLayout(t):void 0}function Nc(t,e,o){if(!t)return[];const i=Math.max(1,Math.floor(e/o)),n=[];let r="";for(const e of t.split(/\s+/))e&&(r&&r.length+1+e.length>i?(n.push(r),r=e):r=r?`${r} ${e}`:e);return r&&n.push(r),n}function zc(t,e,o,i){return"curly"===t?i?`M0,0 C${.6*o},0 ${.4*o},${e/2} ${o},${e/2} C${.4*o},${e/2} ${.6*o},${e} 0,${e}`:`M0,0 C0,${.6*o} ${e/2},${.4*o} ${e/2},${o} C${e/2},${.4*o} ${e},${.6*o} ${e},0`:i?`M0,0 L${o},0 L${o},${e} L0,${e}`:`M0,0 L0,${o} L${e},${o} L${e},0`}function Ec(t,e,o,i){if(!t)return(0,Cx.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,Cx.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(o)?"leftRight":"topBottom");const d="topBottom"===u,h="leftRight"===u;let f=a;f&&"dynamic"!==f||(f=d?0>e?"right":"left":0>o?"bottom":"top");let p="start";d?"right"===f?p="end":"middle"===f&&(p="middle"):p=0>e?"end":"start";const y=t.useHTML||t.html,g=y?void 0:Dc(t),m=g?.lineHeight??16,x=g?.titleLines??(r?l?[r]:Nc(r,c,8):[]),b=g?.labelLines??(n?l?[n]:Nc(n,c,8):[]),v=x.length+b.length,w=h?"end"===p?-4:4:0,k=[],A=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(y)k.push((0,Cx.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===p?w-c:"middle"===p?w-c/2:w,y:-m,width:c,height:Math.max(m,v*m+(r&&n?2:0))+m,style:{overflow:"visible"},children:(0,Cx.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:m+"px",overflow:"visible",textAlign:"end"===p?"right":"middle"===p?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[r&&(0,Cx.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),n&&(0,Cx.jsx)("div",{className:"annotation-note-label",children:n})]})},"annotation-note-html"));else for(const t of[!0,!1]){const e=t?x:b;if(0===e.length)continue;const o="annotation-note-"+(t?"title":"label");k.push((0,Cx.jsx)("text",{className:o,fill:A,textAnchor:p,fontWeight:t?g?.titleFontWeight??"bold":void 0,y:t?void 0:x.length*m,children:e.map((t,e)=>(0,Cx.jsx)("tspan",{x:w,dy:0===e?0:m,children:t},e))},o))}let S=null;if((r||n)&&(0!==e||0!==o)){const t=d?g?g.width:Math.min(c,120):(x.length+b.length+(b.length>0?1:0))*m,e=d?p:f,o="end"===e||"bottom"===e?-t:"middle"===e?-t/2:0;S=(0,Cx.jsx)("line",{className:"note-line",x1:d?o:0,x2:d?o+t:0,y1:d?0:o,y2:d?0:o+t,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const M=Math.max(0,v-1)*m;let _=0;(d||h)&&(_=h&&"middle"===f?-(M+m+(b.length>0&&x.length>0?2:0))/2+m/2:0>o||h&&"bottom"===f?-(M+2):2+m);const $=0!==_?`translate(0,${_})`:void 0;return(0,Cx.jsxs)("g",{className:"annotation-note",transform:`translate(${e},${o})`,...g?.textProps,children:[(0,Cx.jsx)("g",{className:"annotation-note-content",transform:$,children:k}),S]})}function Bc(t,e,o,i,n){let r=null;const s=o||"var(--semiotic-text-secondary, currentColor)";switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&(r=(0,Cx.jsx)("circle",{r:t,fill:"none",stroke:s},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,o=e?.height||0;(t>0||o>0)&&(r=(0,Cx.jsx)("rect",{width:t,height:o,fill:"none",stroke:s},"subject-rect"));break}case"callout-custom":r=e?.custom;break;case"xy-threshold":{const t=i||0,o=n||0;let a=0,c=0,l=0,u=0;if(void 0!==e?.x)a=c=(e.x||0)-t,l=(e.y1||0)-o,u=(e.y2||0)-o;else if(void 0!==e?.y)l=u=(e.y||0)-o,a=(e.x1||0)-t,c=(e.x2||0)-t;else if(void 0!==e?.x1||void 0!==e?.x2)a=(e.x1||0)-t,c=(e.x2||0)-t;else{if(void 0===e?.y1&&void 0===e?.y2)break;l=(e.y1||0)-o,u=(e.y2||0)-o}r=(0,Cx.jsx)("line",{x1:a,y1:l,x2:c,y2:u,stroke:s,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{const t=e?.type||"curly",o=e?.width??e?.height;void 0!==o&&(r=(0,Cx.jsx)("path",{d:zc(t,o,e?.depth||30,void 0===e?.width),fill:"none",stroke:s},"bracket-path"));break}}return(0,Cx.jsx)("g",{className:"annotation-subject",children:r})}function Wc(t,e,o,i,n,r){let s,a,c=0,l=0;if("callout-circle"!==n&&"label"!==n||!r?.radius){if("callout-rect"===n&&r){const o=r.width||0,i=r.height||0;if(o>0||i>0){const n=o/2,r=i/2,s=t-n,a=e-r;if(0!==s||0!==a){const t=Math.abs(s),e=Math.abs(a),u=o/2,d=i/2,h=t*d>e*u?u/t:d/e;c=n+s*h,l=r+a*h}}}else if("bracket"===n&&r){const t=r.width,e=r.height,o=r.depth||30;void 0!==t?(c=t/2,l=o):void 0!==e&&(c=o,l=e/2)}}else{const o=(r.radius||0)+(r.radiusPadding||0);if(o>0&&(0!==t||0!==e)){const i=Math.atan2(e,t);c=Math.cos(i)*o,l=Math.sin(i)*o}}const u=t-c,d=e-l,h=Math.hypot(u,d);if(h>.5){const n=i||"var(--semiotic-text-secondary, currentColor)",r="curve"===o?.type;let f=Math.atan2(d,u);if(r){const i=(c+t)/2,r=(l+e)/2,a=-d/h,p=u/h,y=(o?.curve??.25)*h,g=i+a*y,m=r+p*y;s=(0,Cx.jsx)("path",{className:"connector-curve",d:`M${c},${l}Q${g},${m} ${t},${e}`,fill:"none",stroke:n},"connector-line"),f=Math.atan2(m-l,g-c)}else s=(0,Cx.jsx)("line",{x1:c,y1:l,x2:t,y2:e,stroke:n},"connector-line");if("arrow"===o?.end){const t=10,e=16/180*Math.PI;a=(0,Cx.jsx)("path",{d:`M${c},${l}L${c+t*Math.cos(f+e)},${l+t*Math.sin(f+e)}L${c+t*Math.cos(f-e)},${l+t*Math.sin(f-e)}Z`,fill:n,stroke:"none"},"connector-arrow")}}return(0,Cx.jsxs)("g",{className:"annotation-connector",children:[s,a]})}function Yc(t){const{x:e=0,y:o=0,dx:i,dy:n,nx:r,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(o)?o[0]??0:o,v=Array.isArray(f)?f:[];let w=i||0,k=n||0;null!=r&&(w=r-x),null!=s&&(k=s-b);const A="string"==typeof u?u:"label";if("bracket"===A&&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,Cx.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.includes("connector")&&Wc(w,k,c,d,A,l),!v.includes("subject")&&Bc(A,l,d,x,b),!v.includes("note")&&Ec(a,w,k,d)]})}function qc(t){const{noteData:e}=t,{screenCoordinates:o}=e,i="string"==typeof e.type?e.type:"label",n=e.eventListeners||e.events||{};if(e.coordinates&&o){const t=e.nx||o[0][0]+(e.dx??0),n=e.ny||o[0][1]+(e.dy??0),r=o.map((o,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:o[0],y:o[1],nx:t,ny:n});return(0,Cx.jsx)(Yc,{"data-testid":"semiotic-annotation",...s,type:i},"multi-annotation-"+r)});return(0,Cx.jsx)("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return(0,Cx.jsx)(Yc,{"data-testid":"semiotic-annotation",events:n,...e,type:i},s)}function Xc(t){return!0===t?._annotationDeferred}function Gc(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function Vc(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function Hc(t){return Math.max(Wx,Bx-t*Yx)}function Uc(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(o=t.annotation,"primary"===o?.emphasis||"secondary"===o?.emphasis?o.emphasis:null),confidence:Vc(t.annotation),readingOrder:null,rank:Dx};var o}),o=e.some(t=>null!=t.emphasis||null!=t.confidence),i=t.some(t=>Xc(t.annotation)),n=t.some(t=>null!=Gc(t.annotation)),r=t.some(t=>"layer"===Gc(t.annotation));if(!o&&!i&&!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=Nx-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Fx[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:o,emphasis:i,readingOrder:n}=t,r=Xc(e.annotation);let s=e.node;if("primary"===i||"secondary"===i||null!=n){const t=null==i&&null!=n;s=(0,Ox.jsx)("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i,..."secondary"===i?{opacity:zx,fontSize:Ex}:{},...t?{opacity:Hc(n),"data-annotation-reading-order":n}:{},children:e.node},"annotation-emphasis-"+o)}const a=Gc(e.annotation);return a&&(s=(0,Ox.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+o)),r&&(s=(0,Ox.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+o)),s});return i&&a.unshift((0,Ox.jsx)("style",{children:qx},"annotation-disclosure-style")),r&&a.unshift((0,Ox.jsx)("style",{children:Xx},"annotation-cohesion-style")),a}function Kc(t,e){const o=e.scales?.x??e.scales?.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function Zc(t,e){const o=e.scales?.y??e.scales?.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function Qc(t){return null==t?null:t+""}function Jc(t,e,o){return e.stickyPositionCache?.set(t,o),o}function tl(t,e,o){const i=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=t.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let i=o.pointNodes.length-1;i>=0;i--){const n=o.pointNodes[i];if(n.pointId===t.pointId)return Jc(e,o,{x:n.x,y:n.y})}const i=function(t){const e=t.data;if(!e||0===e.length)return null;const o=e[e.length-1],i=t.scales?.x??t.scales?.time,n=t.scales?.y??t.scales?.value;if(!i||!n)return null;const r=o[t.xAccessor||"x"],s=o[t.yAccessor||"y"];return null==r||null==s?null:{x:i(r),y:n(s)}}(o);return i?Jc(e,o,i):null}if("semantic"===i){const i=function(t,e,o){const i=function(t){return Qc(t.provenance?.stableId??t.stableId)}(t);if(!i)return null;const n=o.pointNodes?.find(t=>Qc(t.pointId)===i);if(n)return Jc(e,o,{x:n.x,y:n.y});const r=o.data?.find(t=>function(t){return Qc(t.stableId??t.id??t.provenance?.stableId)}(t)===i);if(!r)return null;const s=Kc(r,o),a=Zc(r,o);return null==s||null==a?null:Jc(e,o,{x:s,y:a})}(t,e,o);if(i)return i}let n=null,r=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);e&&(n=e.x,r=e.y)}if(null!=n&&null!=r||(n=Kc(t,o),r=Zc(t,o)),null!=n&&null!=r)return Jc(e,o,{x:n,y:r});if("sticky"===i){const t=o.stickyPositionCache?.get(e);if(t)return t}return null}function el(t){return!!t&&"object"==typeof t&&Gx.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}function ol(t){return"primary"===t?.emphasis||!0===t?.defensive}function il(t,e,o={}){return"number"==typeof o.maxAnnotations&&Number.isFinite(o.maxAnnotations)?Math.max(0,Math.floor(o.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(o.areaPerAnnotation&&o.areaPerAnnotation>0?o.areaPerAnnotation:Vx))):1/0}function nl(t){let e;const o=t?.emphasis;e="primary"===o?100:"secondary"===o?10:50;const i=t?.provenance?.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(e+=15*Math.max(0,Math.min(1,i))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}function rl(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const o="string"==typeof e.source?Object.prototype.hasOwnProperty.call(rb,e.source)?rb[e.source]:e.source:null,i="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!o&&!i)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const n=[o,i].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${n})`)?t:{...t,label:r?`${r} (${n})`:`(${n})`}}function sl(t){if(!al(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 al(t){return el(t)}function cl(t,e,o,i,n){const r=t+o,s=e+i;return Math.abs(o)>Math.abs(i)?{x:0>o?r-n.width-4:r+4,y:0>i?s-n.height:s,width:n.width,height:n.height}:{x:0>o?r-n.width:r,y:0>i?s-n.height-4:s+4,width:n.width,height:n.height}}function ll(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function ul(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 dl(t,e,o,i,n,r,s,a){const c=ll(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,o,i){const n=Math.max(0,i-t.x),r=Math.max(0,i-t.y);return(n+Math.max(0,t.x+t.width-(e-i)))*t.height+(r+Math.max(0,t.y+t.height-(o-i)))*t.width}(c,n,r,a);for(const t of o)l+=12*ul(c,t);for(const t of i)l+=4*ul(c,t);return l}function hl(t){const{annotations:e,context:o,defaultOffset:i=Ux,notePadding:n=Kx,markPadding:r=Zx,edgePadding:s=Qx,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=Jx,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=o.width||0,x=o.height||0,b="object"==typeof p?p:{},v=b.breakpoint??ib,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(sl):e,A=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,S=d||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=function(t,e){return(t.pointNodes||[]).map(t=>{const o=Math.max(1,t.r||1)+e;return{x:t.x-o,y:t.y-o,width:2*o,height:2*o}})}(o,r);let j=!1;const I=k.map((t,e)=>{if(!al(t))return t;const r=function(t,e,o){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const i=t.pointId??t.nodeId;if(null!=i&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===i);if(t)return{x:t.x,y:t.y}}const n=t.coordinates,r=o.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 o=r([t,e]);if(o&&"number"==typeof o[0]&&"number"==typeof o[1])return{x:o[0],y:o[1]}}}return o.scales||"number"!=typeof t.x||"number"!=typeof t.y?tl(t,e,o):{x:t.x,y:t.y}}(t,e,o);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=Dc(t);if(e)return{width:Math.max(24,e.width+10),height:Math.max(18,e.height+6)};const o="number"==typeof t.wrap?t.wrap:120,i=[...Nc("string"==typeof t.title?t.title:void 0,o,7),...Nc("string"==typeof t.label?t.label:void 0,o,7)],n=i.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(o,7*n)+10),height:Math.max(18,16*i.length+6)}}(!0===t.defensive?rl(t):t);if(a&&("number"==typeof(d=t).dx||"number"==typeof d.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:tb,dy:eb}}(t);return $.push(ll(cl(r.x,r.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),n)),t}var d;let h=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(i)){const e=dl(cl(r.x,r.y,t.dx,t.dy,u),t,$,P,m,x,n,s);f>e&&(h=t,f=e)}if(!h)return t;const p=ll(cl(r.x,r.y,h.dx,h.dy,u),n);$.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return j=!0,{...t,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=j?I:k.slice();let R=L;if(h){let t=!1;const e=L.map(e=>{const o=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)<ob?t:{...t,_redundantConnector:!0}}(e);return o!==e&&(t=!0),o});R=t?e:L}{let t=!1;const e=R.map(e=>{if(!0!==e?.defensive)return e;const o=rl(e);return o!==e&&(t=!0),o});R=t?e:R}const T=new Set;if(A){const t="object"==typeof A?A:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return nb;const o=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===o.length?nb:o.reduce((t,e)=>t+e,0)/o.length}(t);return e>2?4>e?1:.6:1.5}(g),o=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??il(m,x,t))*e))},{deferred:i}=function(t){const{annotations:e,width:o,height:i}=t,n=Math.max(0,t.minVisible??Hx),r=il(o,i,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(o=t,el(o))};var o}),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=>ol(t.annotation)),l=a.filter(t=>!ol(t.annotation)).sort((t,e)=>nl(e.annotation)-nl(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))),d=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),h=[],f=[];for(const{annotation:t,index:e,note:o}of s)!o||d.has(e)?h.push(t):f.push(t);return{visible:h,deferred:f,budget:r}}({annotations:R,width:m,height:x,...o});for(const t of i)T.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:ib)>=m)for(const t of R)al(t)&&"secondary"===t.emphasis&&T.add(t);if(T.size>0)for(const t of R)!0===t?.defensive&&T.delete(t);let C;return C=0===T.size?R:S?R.map(t=>T.has(t)?{...t,_annotationDeferred:!0}:t):R.filter(t=>!T.has(t)),_?function(t,e){let o=!1;const i=t.map(t=>al(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(o=!0,{...t,cohesion:e}):t);return o?i:t}(C,_):C}function fl(t,e,o,i){const n=function(t,e,o="#4e79a7"){if(ri(t)){const o=function(t,e){let o=2166136261;const i=si(e);for(let t=0;i.length>t;t++)o^=i.charCodeAt(t),o=Math.imul(o,16777619);return`${t}-hatch-${(o>>>0).toString(36)}`}(e,t);return{fill:`url(#${o})`,def:ai(t,o)}}return t&&"string"==typeof t?{fill:t}:{fill:o}}(t.fill??t.color,e,i);return function(t,e,o,i){if(!t||"object"!=typeof t)return;const n=t;if(!Array.isArray(n.stops))return;const r=n.stops.flatMap(t=>{if(!t||"object"!=typeof t)return[];const{offset:e,color:o,opacity:n}=t;return"number"==typeof e&&Number.isFinite(e)?[{offset:Math.max(0,Math.min(1,e)),color:"string"==typeof o&&o?o:i,opacity:"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):void 0}]:[]}).sort((t,e)=>t.offset-e.offset);if(!r.length)return;const s="horizontal"===n.direction?"horizontal":"vertical"===n.direction?"vertical":o,a=e+"-gradient";return{fill:`url(#${a})`,def:(0,wy.jsx)("linearGradient",{id:a,x1:0,y1:0,x2:"horizontal"===s?"100%":0,y2:"vertical"===s?"100%":0,children:r.map((t,e)=>(0,wy.jsx)("stop",{offset:100*t.offset+"%",stopColor:t.color,stopOpacity:t.opacity},`${t.offset}-${e}`))},a)}}(t.gradient,e,o,"string"==typeof t.fill&&t.fill?t.fill:"string"==typeof t.color&&t.color?t.color:i)??n}function pl(t,e,o,i){const n=function(t,e,o){const i=t.position,n="string"==typeof i&&sb.has(i)?i:"bottom-left",r=n.endsWith("left")?"left":n.endsWith("right")?"right":"center",s=n.startsWith("top")?"top":n.startsWith("bottom")?"bottom":"middle",a="top"===s?0:"bottom"===s?o:o/2;return{x:("left"===r?0:"right"===r?e:e/2)+("number"==typeof t.dx&&Number.isFinite(t.dx)?t.dx:0),y:a+("number"==typeof t.dy&&Number.isFinite(t.dy)?t.dy:0),textAnchor:"start"===t.textAnchor||"middle"===t.textAnchor||"end"===t.textAnchor?t.textAnchor:"left"===r?"start":"right"===r?"end":"middle",dominantBaseline:"auto"===t.dominantBaseline||"middle"===t.dominantBaseline||"hanging"===t.dominantBaseline?t.dominantBaseline:"top"===s?"hanging":"bottom"===s?"auto":"middle"}}(t,e,o);return{...n,fill:t.fill??t.color??i.fill,fontSize:t.fontSize??i.fontSize,fontFamily:t.fontFamily??i.fontFamily,fontWeight:t.fontWeight,fontStyle:t.fontStyle,letterSpacing:t.letterSpacing,opacity:t.opacity,className:t.className,style:{pointerEvents:"none"}}}function yl({annotation:t,width:e,height:o,defaults:i=cb}){const n=t.label??t.text;return null==n?null:(0,ab.jsx)("text",{...pl(t,e,o,i),children:n})}function gl(t,e={}){const o=function(t){const e=t.provenance,o=t.id??t.stableId??e?.stableId;return null==o||""===o?void 0:o+""}(t);return{"data-semiotic-annotation-widget":"",...o?{"data-semiotic-annotation-id":o}:{},onClickCapture(i){const n=function(t){const e=t.nativeEvent;return"touch"===e.pointerType?"touch":0===e.detail?"keyboard":"pointer"}(i);e.onAnnotationActivate?.({annotation:t,annotationId:o,chartId:e.chartId,inputType:n}),o&&e.onObservation&&e.onObservation({type:"annotation-activate",annotationId:o,inputType:n,timestamp:Date.now(),chartType:e.chartType??"unknown",chartId:e.chartId})}}}function ml(t,e){return t.color||e.colors.annotation||e.colors.text}function xl(t,e,o){const i=t.labelBackground,n=e.colors.background,r=n&&"transparent"!==n?n:e.colors.surface||n;return void 0===i?"none"===o?"none":{type:"halo",fill:r}:!1===i||"none"===i?"none":!0===i||"halo"===i?{type:"halo",fill:r}:"box"===i?{type:"box",fill:r}:{fill:r,...i}}function bl(t,e,o){return null!=t.x&&e.x?e.x(t.x):o&&null!=t[o]&&e.x?e.x(t[o]):"number"==typeof t.x?t.x:null}function vl(t,e,o){return null!=t.y&&e.y?e.y(t.y):o&&null!=t[o]&&e.y?e.y(t[o]):"number"==typeof t.y?t.y:null}function wl(t){const{annotations:e}=t;if(!e||0===e.length)return t.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;const o=function(t,e={}){const o=!0===e.showRetractedAnnotations,i=!0===e.showSupersededAnnotations,n=new Set;for(const e of t){const t=e?.lifecycle?.supersedes;t&&"retracted"!==e?.lifecycle?.status&&n.add(t)}return t.filter(t=>{if("retracted"===t?.lifecycle?.status&&!o)return!1;const e=t?.provenance?.stableId;return!(e&&n.has(e)&&!i)})}(e),i=t.scales.geoProjection,n=i?o.map(t=>{if(!Array.isArray(t.coordinates)||2>t.coordinates.length)return t;const e=i([Number(t.coordinates[0]),Number(t.coordinates[1])]);return e?{...t,x:e[0],y:e[1]}:t}):o,r=!!i&&!t.scales.x&&!t.scales.y,s=t=>Number(t),a=t.scales.x??(r?s:void 0),c=t.scales.y??(r?s:void 0),l=t.projection?"horizontal"===t.projection?"horizontal":"vertical":void 0,u={scales:{..."vertical"===t.projection?{x:t.scales.o??a,y:t.scales.r??c,time:t.scales.o??a,value:t.scales.r??c,o:t.scales.o}:"horizontal"===t.projection?{x:t.scales.r??a,y:t.scales.o??c,time:t.scales.r??a,value:t.scales.o??c,o:t.scales.o}:{x:a,y:c,time:a,value:c,o:t.scales.o},...i?{geoProjection:i}:{}},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,data:t.annotationData,pointNodes:t.pointNodes,frameType:t.frameType??(t.projection?"ordinal":i||t.scales.x||t.scales.y?"xy":"network"),...l?{projection:l}:{}},d=t.autoPlaceAnnotations?hl({annotations:n,context:u,..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):n,h=function(t,e,o,i){const n=[];return t.forEach((t,r)=>{let s;if(o){const n=o(t,r,i);s=null!=n?n:e(t,r,i)}else s=e(t,r,i);s&&n.push({node:s,annotation:t})}),{nodes:Uc(n),renderedAnnotations:n.map(t=>t.annotation)}}(d,(e,o,i)=>function(t,e,o,i){const{scales:n,layout:r,theme:s,xAccessor:a,yAccessor:c}=o;switch(t.type){case"frame-text":return(0,fb.jsx)(yl,{annotation:t,width:r.width,height:r.height,defaults:{fill:s.colors.text,fontSize:11,fontFamily:s.typography.fontFamily}},"ann-frame-text-"+e);case"y-threshold":{const i=t.value??t.y;if(null==i)return null;const a=ml(t,s),c=t.label,l=t.strokeDasharray||"6,4",u=t.strokeWidth??1.5;if("horizontal"===o.projection&&n.r){const o=n.r(i);return null==o?null:(0,fb.jsxs)("g",{opacity:t.opacity,children:[(0,fb.jsx)("line",{x1:o,y1:0,x2:o,y2:r.height,stroke:a,strokeWidth:u,strokeDasharray:l}),Cc(t.endCap,[o,0],a),c&&(0,fb.jsx)(Tc,{x:o+4,y:pb,textAnchor:"start",fontSize:s.typography.tickSize,fill:a,fontFamily:s.typography.fontFamily,text:c,background:xl(t,s,"halo")})]},"ann-ythresh-"+e)}const d=n.y?n.y(i):n.r?n.r(i):null;return null==d?null:(0,fb.jsx)(Oc,{ann:t,position:d,vertical:!1,width:r.width,height:r.height,color:a,fontSize:s.typography.tickSize,fontFamily:s.typography.fontFamily,background:xl(t,s,"halo"),dash:"6,4",labelGap:6},"ann-ythresh-"+e)}case"x-threshold":{const i=t.value??t.x;if(null==i)return null;const a="horizontal"===o.projection&&n.r?n.r(i):n.x?n.x(i):null;if(null==a)return null;const c=ml(t,s);return(0,fb.jsx)(Oc,{ann:t,position:a,vertical:!0,width:r.width,height:r.height,color:c,fontSize:s.typography.tickSize,fontFamily:s.typography.fontFamily,background:xl(t,s,"halo"),dash:"6,4"},"ann-xthresh-"+e)}case"band":{const o=n.y?.domain?.(),i=t.y0??o?.[0],a=t.y1??o?.[1],c=null!=i&&n.y?n.y(i):null,l=null!=a&&n.y?n.y(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=fl(t,"ssr-band-"+e,"vertical",ml(t,s)),f=t.fillOpacity??.1;return(0,fb.jsxs)("g",{opacity:t.opacity,children:[h.def&&(0,fb.jsx)("defs",{children:h.def}),(0,fb.jsx)("rect",{x:0,y:u,width:r.width,height:d,fill:h.fill,fillOpacity:f}),t.label&&(0,fb.jsx)(Tc,{x:r.width-4,y:Math.max(u,0)+pb,textAnchor:"end",fontSize:s.typography.tickSize,fill:t.color||ml(t,s),fontFamily:s.typography.fontFamily,fontWeight:"bold",text:t.label,background:xl(t,s,"halo")})]},"ann-band-"+e)}case"x-band":{const o=n.x?.domain?.(),i=t.x0??o?.[0],a=t.x1??o?.[1],c=null!=i&&n.x?n.x(i):null,l=null!=a&&n.x?n.x(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=fl(t,"ssr-xband-"+e,"horizontal",ml(t,s)),f=t.fillOpacity??.1;return(0,fb.jsxs)("g",{opacity:t.opacity,children:[h.def&&(0,fb.jsx)("defs",{children:h.def}),(0,fb.jsx)("rect",{x:u,y:0,width:d,height:r.height,fill:h.fill,fillOpacity:f}),t.label&&(0,fb.jsx)(Tc,{x:u+4,y:pb,textAnchor:"start",fontSize:s.typography.tickSize,fill:t.color||s.colors.primary||ml(t,s),fontFamily:s.typography.fontFamily,fontWeight:"bold",text:t.label,background:xl(t,s,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!n.o)return null;const i=n.o(t.category+"");if(null==i)return null;const a=n.o.bandwidth?n.o.bandwidth():40,c=ml(t,s),l=t.opacity??.1,u=t.label;return(0,fb.jsxs)("g","horizontal"===o.projection?{children:[(0,fb.jsx)("rect",{x:0,y:i,width:r.width,height:a,fill:c,opacity:l}),u&&(0,fb.jsx)(Tc,{x:12,y:i+a/2,dominantBaseline:"middle",fill:c,fontSize:s.typography.tickSize,fontWeight:"bold",fontFamily:s.typography.fontFamily,text:u,background:xl(t,s,"none")})]}:{children:[(0,fb.jsx)("rect",{x:i,y:0,width:a,height:r.height,fill:c,opacity:l}),u&&(0,fb.jsx)(Tc,{x:i+a/2,y:pb,textAnchor:"middle",fill:c,fontSize:s.typography.tickSize,fontWeight:"bold",fontFamily:s.typography.fontFamily,text:u,background:xl(t,s,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const o=function(t,e,o,i){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const o=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(o)return{x:o[0],y:o[1]}}return{x:bl(t,e,o),y:vl(t,e,i)}}(t,n,a,c),r=null==o.x||null==o.y?tl(t,e,i):null,l=o.x??r?.x??null,u=o.y??r?.y??null;if(null==l||null==u)return null;const d="text"===t.type,h=t.dx??(d?0:30),f=t.dy??(d?0:-30),p=t.color||s.colors.text;if(!d){const o="callout"===t.type?"callout-circle":t.type,i="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return(0,fb.jsx)(qc,{noteData:{x:l,y:u,dx:h,dy:f,note:Fc(t),type:o,...i?{subject:i}:{},connector:t.connector||{end:"arrow"},color:p,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return(0,fb.jsx)("g",{children:(0,fb.jsx)("text",{x:l+h,y:u+f,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||s.typography.labelSize,fill:p,fontFamily:s.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}(e,o,t,i)??function(t,e,o){switch(t.type){case"enclose":{const i=(t.coordinates||[]).map(t=>({x:Kc({...t,type:"point"},o),y:Zc({...t,type:"point"},o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const n=(0,lb.packEnclose)(i),r=t.padding||10;return(0,db.jsxs)("g",{children:[(0,db.jsx)("circle",{cx:n.x,cy:n.y,r:n.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity??.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&(0,db.jsx)(Tc,{x:n.x,y:n.y-n.r-r-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+e)}case"rect-enclose":{const i=(t.coordinates||[]).map(t=>({x:Kc({...t,type:"point"},o),y:Zc({...t,type:"point"},o)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const n=t.padding||10,[r,s]=te(i.map(t=>t.x)),[a,c]=te(i.map(t=>t.y)),l=r-n,u=s+n,d=a-n;return(0,db.jsxs)("g",{children:[(0,db.jsx)("rect",{x:l,y:d,width:u-l,height:c+n-d,fill:t.fill||"none",fillOpacity:t.fillOpacity??.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&(0,db.jsx)(Tc,{x:(l+u)/2,y:d-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+e)}case"highlight":{const i=o.data||[],n="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],r={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return(0,db.jsx)("g",{children:n.map((e,i)=>{const n=Kc(e,o),s=Zc(e,o);if(null==n||null==s)return null;const a="function"==typeof t.r?t.r(e):t.r||6,c="function"==typeof t.style?t.style(e):t.style||r;return(0,db.jsx)("circle",{cx:n,cy:s,r:a,...c},"hl-"+i)})},"ann-"+e)}case"bracket":{const i=Kc(t,o),n=Zc(t,o);return(0,db.jsx)(qc,{noteData:{x:i??0,y:n??0,dx:t.dx||0,dy:t.dy||0,note:Fc(t),type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+e)}case"trend":{const i=o.data||[];if(2>i.length)return null;const n=o.xAccessor||"x",r=o.yAccessor||"y",s="ordinal"===o.frameType,a="horizontal"===o.projection,c=s?n:null,l=s?r:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const t of i){const e=t[c];if(null==e)continue;const o=e+"";h.has(o)||(h.set(o,d.length),d.push(o))}u=i.map(t=>{const e=t[c],o=t[l];if(null==e||null==o)return null;const i=h.get(e+"");return null!=i?[i,+o]:null}).filter(t=>null!==t)}else u=i.map(t=>[t[n],t[r]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>u.length)return null;const f=o.scales?.x??o.scales?.time,p=o.scales?.y??o.scales?.value;if(!f||!p)return null;const y=t=>e=>{const o=Math.max(0,Math.floor(e)),i=Math.min(d.length-1,o+1),n=e-o,r=t(d[o]);return r+(t(d[i])-r)*n},g=f,m=p;let x;if(s)if(a){const t=y(m);x=(e,o)=>[g(o),t(e)]}else{const t=y(g);x=(e,o)=>[t(e),m(o)]}else x=(t,e)=>[g(t),m(e)];const b=t.method||"linear",v="loess"===b?function(t,e=.3){const o=t.length;if(2>o)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),n=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.min(o,Math.max(2,Math.ceil(e*o))),a=Number.isFinite(s)&&n.every(Number.isFinite);let c=0,l=s-1;const u=[];for(let t=0;o>t;t++){const e=n[t];let i,d=0,h=o-1;if(a){for(;o-1>l&&Math.abs(n[c]-e)>=Math.abs(n[l+1]-e);)c++,l++;const t=Math.max(Math.abs(n[c]-e),Math.abs(n[l]-e));i=t||1,t>0&&(d=c,h=l)}else i=n.map(t=>Math.abs(t-e)).sort((t,e)=>t-e)[s-1]||1;let f=0,p=0,y=0,g=0,m=0;for(let t=d;h>=t;t++){const o=Math.abs(n[t]-e)/i,s=1>o?Math.pow(1-Math.pow(o,3),3):0;0!==s&&(f+=s,p+=s*n[t],y+=s*r[t],g+=s*n[t]*n[t],m+=s*n[t]*r[t])}if(0===f){u.push([e,r[t]]);continue}const x=f*g-p*p;if(1e-12>Math.abs(x))u.push([e,y/f]);else{const t=(f*m-p*y)/x;u.push([e,(y-t*p)/f+t*e])}}return u}(u,t.bandwidth??.3):("polynomial"===b?ie(u,t.order||2):function(t){const e=[0,0,0,0];let o=0;for(const[i,n]of t)null!==n&&(o++,e[0]+=i,e[1]+=n,e[2]+=i*i,e[3]+=i*n);const i=o*e[2]-e[0]*e[0],n=0===i?0:oe((o*e[3]-e[0]*e[1])/i),r=oe(e[1]/o-n*e[0]/o);return{points:t.map(([t])=>[oe(t),oe(n*t+r)]),equation:[n,r]}}(u)).points,w=v.map(([t,e])=>{const[o,i]=x(t,e);return`${o},${i}`}).join(" "),k=t.color||"#6366f1",A=v[v.length-1],[S,M]=x(A[0],A[1]);return(0,db.jsxs)("g",{children:[(0,db.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&(0,db.jsx)("text",{x:S+4,y:M-4,fill:k,fontSize:11,children:t.label})]},"ann-"+e)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const n=o.xAccessor||"x",r=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!r||!s)return null;const a=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",l=t.filter,u=i.filter(t=>null!=t[a]&&null!=t[c]&&(!l||l(t))).sort((t,e)=>t[n]-e[n]);if(2>u.length)return null;const d=hb[o.curve||"linear"]||ub.curveLinear,h=(0,ub.area)().x(t=>r(t[n])).y0(t=>s(t[c])).y1(t=>s(t[a])).curve(d)(u);if(!h)return null;const f=t.fill||"#6366f1",p=u[u.length-1];return(0,db.jsxs)("g",{children:[(0,db.jsx)("path",{d:h,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&(0,db.jsx)("text",{x:r(p[n])+4,y:s(p[a])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+e)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const n=o.yAccessor||"y",r=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!r||!s)return null;const a=i.map(t=>t[n]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,l=a.reduce((t,e)=>t+(e-c)**2,0)/a.length,u=Math.sqrt(l),d=t.threshold??2,h=c-d*u,f=s(c+d*u),p=s(h),y=t.fill||"#6366f1",g=t.anomalyColor||"#ef4444",m=t.anomalyRadius??6,x=i.filter(t=>{const e=t[n];return null!=e&&Math.abs(e-c)>d*u});return(0,db.jsxs)("g",{children:[!1!==t.showBand&&(0,db.jsx)("rect",{x:0,y:Math.min(f,p),width:o.width||0,height:Math.abs(p-f),fill:y,fillOpacity:t.fillOpacity??.1}),x.map((t,e)=>{const i=Kc(t,o),n=Zc(t,o);return null==i||null==n?null:(0,db.jsx)("circle",{cx:i,cy:n,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+e)}),t.label&&(0,db.jsx)("text",{x:(o.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:y,fontSize:11,children:t.label})]},"ann-"+e)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const n=o.xAccessor||"x",r=o.yAccessor||"y",s=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!s||!a)return null;const c=i.map(t=>[t[n],t[r]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let l;if("polynomial"===t.method){const e=ie(c,t.order||2).equation;l=t=>e.reduce((e,o,i)=>e+o*Math.pow(t,i),0)}else{const t=ne(c);if(!t)return null;l=t}const{se:u,meanX:d,ssX:h}=re(c,l),f=c.length,p=se(t.confidence??.95),y=c[f-1][0],g=(y-c[0][0])/Math.max(f-1,1),m=Array.from({length:t.steps??5},(t,e)=>{const o=y+(e+1)*g,i=l(o),n=u*Math.sqrt(1+1/f+(h>0?(o-d)**2/h:0))*p;return{x:o,center:i,upper:i+n,lower:i-n}}),x=m.map(t=>`${s(t.x)},${a(t.upper)}`).join(" L"),b=m.slice().reverse().map(t=>`${s(t.x)},${a(t.lower)}`).join(" L"),v=m.map(t=>`${s(t.x)},${a(t.center)}`).join(" "),w=t.strokeColor||"#6366f1",k=m[m.length-1];return(0,db.jsxs)("g",{children:[(0,db.jsx)("path",{d:`M${x} L${b} Z`,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),(0,db.jsx)("polyline",{points:`${s(y)},${a(l(y))} ${v}`,fill:"none",stroke:w,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&k&&(0,db.jsx)("text",{x:s(k.x)+4,y:a(k.center)-4,fill:w,fontSize:11,children:t.label})]},"ann-"+e)}case"widget":{let i,n;if(null!=t.px&&null!=t.py)i=t.px,n=t.py;else{const r=tl(t,e,o);if(!r)return null;i=r.x,n=r.y}if(!function(t,e,o,i=50){return!(-i>t||t>(o.width||0)+i||-i>e||e>(o.height||0)+i)}(i,n,o))return null;const r=t.width??32,s=t.height??32,a=t.content??(0,db.jsx)("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return(0,db.jsx)("foreignObject",{x:i+(t.dx??0)-r/2,y:n+(t.dy??0)-s/2,width:r,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:(0,db.jsx)("div",{...gl(t),style:{width:r,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:a})},"ann-"+e)}default:return null}}(e,o,i),t.svgAnnotationRules,u),f=h.nodes,p=new Map;for(const t of h.renderedAnnotations){const e="string"==typeof t.type?t.type:"unknown";p.set(e,(p.get(e)??0)+1)}const y=[];for(const t of e){const e="string"==typeof t.type?t.type:"unknown",o=p.get(e)??0;o>0?p.set(e,o-1):y.push(e)}return t.onRender?.({inputCount:e.length,eligibleCount:d.length,renderedCount:h.renderedAnnotations.length,unrenderedCount:y.length,unrenderedTypes:y}),f.length>0?(0,fb.jsx)("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:f}):null}function kl(t,e,o,i="right",n,r){if(null==t||!1===t)return null;const{x:s,y:a}=b(t,{totalWidth:e[0],totalHeight:e[1],margin:o,position:i,legendLayout:n,axisChrome:r});return(0,yb.jsx)("g",{transform:`translate(${s}, ${a})`,children:t})}function Al(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_"),o=/^[A-Za-z_]/.test(e)?e:"c"+e,i=o+"-semiotic-title",n=o+"-semiotic-desc";return{titleId:i,descId:n,labelledBy:`${i} ${n}`}}function Sl(t,e,o){if("edges"===t){if(e)return"start";if(o)return"end"}return"middle"}function Ml(t,e,o){if("edges"===t){if(e)return"hanging";if(o)return"auto"}return"middle"}function _l(t){if(0===t.length)return{min:null,max:null};let e=1/0,o=-1/0;for(const i of t)e>i.pixel&&(e=i.pixel),i.pixel>o&&(o=i.pixel);return{min:e,max:o}}function $l(t){if(t)return"object"==typeof t?t.strokeDasharray:"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Pl(t,e){return t&&"string"!=typeof t?{stroke:t.stroke??e.stroke,strokeWidth:t.strokeWidth??e.strokeWidth,...null!=t.strokeOpacity&&{strokeOpacity:t.strokeOpacity},...t.strokeDasharray&&{strokeDasharray:t.strokeDasharray}}:{...e,..."string"==typeof t&&{strokeDasharray:$l(t)}}}function jl(t,e,o){if("left"===t||"right"===t){const i="left"===t?o:0,n="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const o=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*n}`,s+=`L${Math.min(o,e)},${i}`}return s}const i="bottom"===t?0:e,n="bottom"===t?1:-1,r=Math.ceil(o/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*n},${Math.min(8*t+4,o)}`,s+=`L${i},${Math.min(e,o)}`}return s}function Il(t,e,o){return"exact"===o?function(t,e){const o=t.domain(),i=o[0],n=o[o.length-1],r=i instanceof Date,s=i instanceof Date?i.getTime():i,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 o=t===e-1?a:s+t*c;l[t]=r?new Date(o):o}return l}(t,e):t.ticks(e)}function Ll(t){return"string"==typeof t||"number"==typeof t}function Rl(t){const{label:e,x:o,y:i,textAlign:n,fontSize:r,fontFamily:s,color:a}=t;return(0,mb.jsx)("foreignObject",{x:o,y:i,width:60,height:24,style:{overflow:"visible"},children:(0,mb.jsx)("div",{style:{color:a,fontFamily:s,fontSize:r,textAlign:n,userSelect:"none"},children:e})})}function Tl(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Cl(t,e,o,i){return!!t&&("function"==typeof t?t(e.value,o):function(t,e){const o=Tl(t);if(!o)return!1;const i=Tl(e);return!i||o.getFullYear()!==i.getFullYear()||o.getMonth()!==i.getMonth()}(e.value,o>0?i[o-1].value:void 0))}function Ol(t){const e=new Date(t instanceof Date?t.valueOf():t);return`${xb[e.getUTCMonth()]} ${e.getUTCDate()}`}function Fl(t){const e=Math.abs(t[1]-t[0]);return bb>e?t=>{const o=new Date(t instanceof Date?t.valueOf():t);let i=`${(o.getUTCHours()+"").padStart(2,"0")}:${(o.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>e&&(i+=":"+(o.getUTCSeconds()+"").padStart(2,"0")),1e4>e&&(i+="."+(o.getUTCMilliseconds()+"").padStart(3,"0")),i}:vb>e?Ol:5*vb>e?t=>{const e=new Date(t instanceof Date?t.valueOf():t);return`${xb[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t instanceof Date?t.valueOf():t).getUTCFullYear()+""}function Dl(t){return"string"==typeof t||"number"==typeof t?6.5*(t+"").length:60}function Nl(t){const{scale:o,axis:i,size:n,horizontal:r=!1,axisExtent:s}=t,a=i?.extent??s,c=o.domain(),l=function(t){return t?.ticks??t?.tickCount??5}(i),u=Math.max(2,Math.floor(n/(r?70:30))),d="exact"===a?Math.max(2,l):Math.min(l,u),h=i?.tickValues??Il(o,d,a),f=h.map(t=>t.valueOf()),p=i?.tickFormat||t.format||(c[0]instanceof Date||h[0]instanceof Date?Fl([c[0].valueOf(),c[c.length-1].valueOf()]):e(f)),y=(t,e)=>r?p(t,e,f):p(t),g=h.map((t,e)=>({value:t,pixel:o(t),label:y(t,e)}));let m=22;if(r){const t=g.reduce((t,e)=>Math.max(t,Dl(e.label)),0);m=i?.autoRotate?Math.max(20,Math.min(t+8,55)):Math.max(55,t+8)}let x=function(t,e){if(2>=t.length)return t;const o=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-o[o.length-1].pixel)||o.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-o[o.length-1].pixel)?o[o.length-1]=i:o.push(i),o}(g,m);if(x.length>1&&(x=x.filter((t,e)=>{return 0===e||(i=x[e-1].label,!!("string"!=typeof(o=t.label)&&"number"!=typeof o||"string"!=typeof i&&"number"!=typeof i||o+""!=i+""));var o,i})),i?.includeMax&&x.length>0&&"exact"!==a&&!i.tickValues){const t=c[c.length-1];if(null!=t){const e=o(t),i=Math.abs(e-x[x.length-1].pixel);if(i>1){const o=y(t,x.length);m>i&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:t,pixel:e,label:o}]}}}return x}function zl(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function El(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 o=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let i=0;for(let t=0;o.length>t;t++)i=31*i+o.charCodeAt(t)|0;return"c"+(i>>>0).toString(36)}function Bl(t,e,i){return o(t.showLegend&&!t.__legendIncludesAutomatic?Mc(e,t.colorScheme,i):void 0,t.legend)}function Wl(t,e){if(t.__autoLegendMargin)return kb[e]}function Yl(t,o){const r={theme:o.theme,position:o.position||"right",totalWidth:o.size[0],totalHeight:o.size[1],margin:o.margin,hasTitle:o.hasTitle,legendLayout:o.legendLayout,idPrefix:o.idPrefix,reservedWidth:o.reservedWidth,axisChrome:o.axisChrome,legendDistance:i(t)||n(t)?t.legendDistance:void 0};return i(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,o)=>({group:t,item:e,itemIndex:o,label:e.label})))).length)return null;var e;const o=function(t){const{legendGroups:e,theme:o,position:i="right",totalWidth:n,margin:r,legendLayout:s}=t,{swatchSize:a,labelGap:c,rowHeight:l}=v(s),u=a+c,d=Math.max(12,$c(o)),h="top"===i||"bottom"===i,f=Math.max(a,n-r.left-r.right);if(h){const i=Math.max(a,s?.maxWidth??f),n=_c(s?.align);let r=0,c=0;const l=[];for(const n of e){const e=n.items.map(t=>t.label),u=Lc({...t,categories:e,legendLayout:{...s,maxWidth:Math.max(a,i-d-8),align:"start"}}),h=n.label?d:0,f=n.label?Ic(n.label,0,0,o):0,p=h>0?h+8:0,y=p+u.width,g=Math.max(u.height,f);l.push({group:n,x:r,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,c=Math.max(c,g)}const h=l.length>0?r-12:0,p=h>i?0:"center"===n?Math.max(0,(i-h)/2):"end"===n?Math.max(0,i-h):0;return{groups:l.map(t=>({...t,x:t.x+p})),width:h,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=w(e.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),l);let y=0;return{groups:e.map((t,e)=>{const i=t.items.map(t=>Ic(t.label,a,c,o)),n=Math.max(0,...i,t.label?Ic(t.label,0,0,o):0);return y=Math.max(y,n),{group:t,x:0,y:p[e].itemsY,itemOffsetX:0,itemOffsetY:0,width:n,height:t.items.length*l,items:t.items.map((t,e)=>({category:t.label,width:i[e],x:0,y:e*l}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}(t),i="top"===t.position||"bottom"===t.position,n={legendGroups:t.legendGroups,legendDistance:t.legendDistance},r=t.reservedWidth??u(n,t.legendLayout),s=t.theme.colors.grid||t.theme.colors.textSecondary,{x:a,y:c}=b(n,{totalWidth:t.totalWidth,totalHeight:t.totalHeight,margin:t.margin,position:t.position,legendLayout:t.legendLayout,axisChrome:t.axisChrome,reservedWidth:r});if(!i){const e=w(t.legendGroups.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),Math.max(o.swatchSize,t.legendLayout?.rowHeight??$x)),i=t.legendGroups.flatMap((i,n)=>{const s=e[n],a=i.type??"fill",c=[(0,_x.jsx)("line",{x1:0,y1:s.lineY,x2:r,y2:s.lineY,stroke:"gray"},"legend-group-neatline-"+n)];return i.label&&null!=s.labelY&&c.push((0,_x.jsx)("text",{y:s.labelY,fontSize:$c(t.theme),fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:i.label},"legend-group-label-"+n)),c.push((0,_x.jsx)("g",{transform:`translate(0,${s.itemsY})`,children:i.items.map((e,r)=>{const s=i.styleFn(e,r),c="function"==typeof a?a(e):"line"===a?(0,_x.jsx)("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:s}):(0,_x.jsx)("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:s});return(0,_x.jsxs)("g",{transform:`translate(0,${r*Math.max(o.swatchSize,t.legendLayout?.rowHeight??$x)})`,children:[c,(0,_x.jsx)("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:$c(t.theme),fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:e.label})]},`legend-${n}-${r}`)})},"legend-group-"+n)),c});return(0,_x.jsx)("g",{className:"semiotic-legend",transform:`translate(${a},${c})`,"data-orientation":"vertical",fontWeight:jc(t.theme),children:i})}const l=o.groups.flatMap((e,n)=>{const{group:r}=e,a=r.type??"fill",c=[];if(r.label&&c.push((0,_x.jsx)("text",i?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:$c(t.theme),fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:r.label}:{x:e.x,y:e.y+$c(t.theme),fontSize:$c(t.theme),fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:r.label},"legend-group-label-"+n)),c.push(...e.items.map((i,s)=>{const c=r.items[s],l=r.styleFn(c,s),u="function"==typeof a?a(c):"line"===a?(0,_x.jsx)("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:l}):(0,_x.jsx)("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:l});return(0,_x.jsxs)("g",{transform:`translate(${e.x+e.itemOffsetX+i.x},${e.y+e.itemOffsetY+i.y})`,children:[u,(0,_x.jsx)("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:$c(t.theme),fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:i.category})]},`legend-${n}-${s}`)})),i&&o.groups.length-1>n){const t=e.x+e.width+6;c.push((0,_x.jsx)("line",{x1:t,y1:0,x2:t,y2:o.height,stroke:s},"legend-group-separator-"+n))}return c});return(0,_x.jsx)("g",{className:"semiotic-legend",transform:`translate(${a},${c})`,"data-orientation":i?"horizontal":"vertical",fontWeight:jc(t.theme),children:l})}({...r,legendGroups:t.legendGroups}):n(t)?function(t){const o=function(t){const e="top"===t.position||"bottom"===t.position,o=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??o,200),height:t.gradient.label?rf:sf,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?nf+108:108,swatchSize:14}}(t),i="top"===t.position||"bottom"===t.position,n={gradient:t.gradient,legendDistance:t.legendDistance},r=u(n),s=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",a=t.gradient.format||e(t.gradient.domain),{x:c,y:l}=b(n,{totalWidth:t.totalWidth,totalHeight:t.totalHeight,margin:t.margin,position:t.position,legendLayout:t.legendLayout,axisChrome:t.axisChrome,reservedWidth:r}),d=Array.from({length:17},(e,o)=>{const n=o/16;return(0,_x.jsx)("stop",{offset: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 e=12,i=t.gradient.label?of:void 0,n=t.gradient.label?nf:0;return(0,_x.jsxs)("g",{className:"semiotic-legend",transform:`translate(${c},${l})`,fontWeight:jc(t.theme),children:[(0,_x.jsx)("defs",{children:(0,_x.jsx)("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:d})}),t.gradient.label&&(0,_x.jsx)("text",{x:o.width/2,y:i,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:t.gradient.label}),(0,_x.jsx)("rect",{x:0,y:n,width:o.width,height:e,fill:`url(#${s})`,rx:2}),(0,_x.jsx)("text",{x:0,y:n+e+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:Pc(t.theme),children:a(t.gradient.domain[0])}),(0,_x.jsx)("text",{x:o.width,y:n+e+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:Pc(t.theme),children:a(t.gradient.domain[1])})]})}const h=t.gradient.label?of:void 0,f=t.gradient.label?nf:0;return(0,_x.jsxs)("g",{className:"semiotic-legend",transform:`translate(${c},${l})`,fontWeight:jc(t.theme),children:[(0,_x.jsx)("defs",{children:(0,_x.jsx)("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),t.gradient.label&&(0,_x.jsx)("text",{x:0,y:h,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:Pc(t.theme),children:t.gradient.label}),(0,_x.jsx)("rect",{x:0,y:f,width:14,height:100,fill:`url(#${s})`,rx:2}),(0,_x.jsx)("text",{x:19,y:f+10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:Pc(t.theme),children:a(t.gradient.domain[1])}),(0,_x.jsx)("text",{x:19,y:f+100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:Pc(t.theme),children:a(t.gradient.domain[0])})]})}({...r,gradient:t.gradient}):null}function ql(t,e){const{props:o,categories:i,theme:n,size:r,hasTitle:s}=e,a=o.legendPosition||"right",l={...t},u={theme:n,position:a,size:r,hasTitle:s,legendLayout:o.legendLayout,axisChrome:o.axisChrome,minimumMargin:Wl(o,a)};if(null!=o.legend){const e=Bl(o,i,n);null!=e&&!1!==e&&function(t,e){x(t,{legend:e.legend,position:e.position||"right",size:e.size,hasTitle:e.hasTitle,legendLayout:e.legendLayout,minimumMargin:e.minimumMargin,axisChrome:e.axisChrome})}(t,{...u,legend:e})}else o.showLegend&&i.length>0&&function(t,e){if(0===e.categories.length)return;const o=e.position||"right";x(t,{legend:Mc(e.categories,e.colorScheme,e.theme),position:o,size:e.size,hasTitle:e.hasTitle,legendLayout:e.legendLayout,minimumMargin:e.minimumMargin,axisChrome:e.axisChrome})}(t,{...u,categories:i,colorScheme:o.colorScheme});return c(t,l,r,a),a}function Xl(t){const{props:e,categories:o,theme:r,size:s,margin:a,hasTitle:c}=t,l=e.legendPosition||"right",d={theme:r,position:l,size:s,margin:a,hasTitle:c,legendLayout:e.legendLayout,axisChrome:e.axisChrome,idPrefix:e._idPrefix};if(null!=e.legend){const t=Bl(e,o,r);if(gb.isValidElement(t))return kl(t,s,a,l,e.legendLayout,e.axisChrome);return Yl(t,d)||(i(t)||n(t)?null:kl(t??null,s,a,l,e.legendLayout,e.axisChrome))}return e.showLegend&&0!==o.length?function(t){const{categories:e,colorScheme:o,theme:i,position:n="right",totalWidth:r,totalHeight:s,margin:a}=t;if(!e||0===e.length)return null;const c=Sc(e,o,i),l="top"===n||"bottom"===n,d=Lc(t),h={...Mc(e,o,i),legendDistance:t.legendDistance},f=t.reservedWidth??u(h,t.legendLayout),{x:p,y:y}=b(h,{totalWidth:r,totalHeight:s,margin:a,position:n,legendLayout:t.legendLayout,axisChrome:t.axisChrome,reservedWidth:f});if(l){const t=d.items.map((t,e)=>(0,_x.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,_x.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:c(t.category),rx:d.swatchRadius}),(0,_x.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:$c(i),fill:i.colors.text,fontFamily:Pc(i),children:t.category})]},"legend-"+e));return(0,_x.jsx)("g",{className:"semiotic-legend",transform:`translate(${p},${y})`,fontWeight:jc(i),children:t})}const g=w([{hasLabel:!1,itemCount:e.length}],Math.max(d.swatchSize,t.legendLayout?.rowHeight??$x))[0],m=d.items.map((t,e)=>(0,_x.jsxs)("g",{transform:`translate(${t.x},${t.y+g.itemsY})`,children:[(0,_x.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:c(t.category),rx:d.swatchRadius}),(0,_x.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:$c(i),fill:i.colors.text,fontFamily:Pc(i),children:t.category})]},"legend-"+e));return(0,_x.jsxs)("g",{className:"semiotic-legend",transform:`translate(${p},${y})`,fontWeight:jc(i),children:[(0,_x.jsx)("line",{x1:0,y1:g.lineY,x2:f,y2:g.lineY,stroke:"gray"}),m]})}({categories:o,colorScheme:e.colorScheme,theme:r,position:l,totalWidth:s[0],totalHeight:s[1],margin:a,hasTitle:c,legendLayout:e.legendLayout,axisChrome:e.axisChrome,idPrefix:e._idPrefix}):null}function Gl(t,e){const o=Qt(e.theme),i=e.background??o.background,n=e.idPrefix?e.idPrefix+"-":"",r="string"==typeof e.title?e.title:void 0,s=e.idPrefix?Al(e.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},a=r?s.titleId:void 0,c=e.description?s.descId:void 0,l=[a,c].filter(Boolean).join(" ")||void 0;return(0,wb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":l,style:{fontFamily:o.fontFamily},children:[r&&(0,wb.jsx)("title",{id:a,children:r}),e.description&&(0,wb.jsx)("desc",{id:c,children:e.description}),e.defs&&(0,wb.jsx)("defs",{children:e.defs}),i&&"transparent"!==i&&(0,wb.jsx)("rect",{x:0,y:0,width:e.width,height:e.height,fill:i}),(0,wb.jsx)("g",{id:n+"data-area",transform:e.innerTransform,children:t}),r&&(0,wb.jsx)("text",{id:n+"chart-title",x:e.width/2,y:Hh,textAnchor:"middle",fontSize:o.titleFontSize,fontWeight:o.titleFontWeight,fill:o.text,fontFamily:o.titleFontFamily,children:r}),e.legend&&(0,wb.jsx)("g",{id:n+"legend",children:e.legend}),e.outerElements]})}function Vl(t,e,o,i){return"function"==typeof t?t({size:e,margin:o,scales:i}):t}function Hl(e,o){const i=Zt(e.theme),n=e.size||[500,300],s=a({...Sb,...e.margin},e.title),c=r(e.title),l=function(t,e){if(!e||0===t.length)return t;if(!t.some(t=>null!=t&&"object"==typeof t&&Array.isArray(t[e])))return t;const o=[];for(const i of t){if(null==i||"object"!=typeof i)continue;const t=i[e];if(!Array.isArray(t))continue;const n=i.label??i.id??i.key;for(const e of t)null!=e&&"object"==typeof e&&o.push(null==n?e:{...e,_lineGroup:n})}return o}(xt(e.data),e.lineDataAccessor),u=e.showLegend?Rc(l,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],d=y({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});ql(s,{props:{...e,axisChrome:d},categories:u,theme:i,size:n,hasTitle:c});const f=Xl({props:{...e,axisChrome:d},categories:u,theme:i,size:n,margin:s,hasTitle:c}),p=n[0]-s.left-s.right,g=n[1]-s.top-s.bottom,m="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),x=e.colorScheme||i.colors.categorical,b=(e.axes?.find(t=>"left"===t.orient)??e.axes?.find(t=>"right"===t.orient))?.extent??e.axisExtent,v={chartType:e.chartType,runtimeMode:m?"streaming":"bounded",windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:m?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:e.xAccessor,yAccessor:e.yAccessor,timeAccessor:m?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor||(e.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,invertY:e.invertY,axisExtent:e.axisExtent,yAxisExtent:b,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:Yt(e.gradientFill),lineGradient:qt(e.lineGradient),semanticLineStops:e.semanticLineStops,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:x,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:Kt(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat,heatmapColorScale:e.heatmapColorScale,heatmapAggregation:e.heatmapAggregation,heatmapXBins:e.heatmapXBins,heatmapYBins:e.heatmapYBins,pointIdAccessor:e.pointIdAccessor,onLayoutError:e.onLayoutError},w=new Dm(v);e.data&&w.ingest({inserts:l,bounded:!0}),w.computeScene({width:p,height:g});const k=Vl(e.backgroundGraphics,n,s,w.scales),A=Vl(e.foregroundGraphics,n,s,w.scales);if(!w.scales){let t;const r=e.annotations?wl({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:l,scales:{},layout:{width:p,height:g},theme:i,idPrefix:e._idPrefix,onRender:e=>{t=e}}):null;return o&&(o.evidence=dc({frameType:"xy",width:n[0],height:n[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,extraWarnings:w.scales?[]:["NO_SCALES"],margin:s})),hm.renderToStaticMarkup(Gl(k||A||e.annotations?(0,jb.jsxs)(jb.Fragment,{children:[k,r,A]}):null,{width:n[0],height:n[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:p,innerHeight:g,legend:f,idPrefix:e._idPrefix}))}const S=e._idPrefix,M=Ac({nodes:w.scene,renderMode:e.renderMode,fallback:(t,o)=>wc(t,o,S,e.hoverRadius??30)}),_=!w.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:Fl(w.scales.x.domain().map(t=>t.valueOf()))},$=e.showGrid?function(t,e,o,i,n,r,s){const{grid:a}=Qt(o),c=i?i+"-":"",l=r?.find(t=>"bottom"===t.orient),u=r?.find(t=>"top"===t.orient),d=r?.find(t=>"left"===t.orient),h=r?.find(t=>"right"===t.orient),f=l??u,p=d??h,y=Nl({scale:t.x,axis:f,size:e.width,horizontal:!0,format:s?.xFormat||s?.tickFormatTime,axisExtent:n}),g=Nl({scale:t.y,axis:p,size:e.height,format:s?.yFormat||s?.tickFormatValue,axisExtent:n}),m=!1!==f?.grid,x=!1!==p?.grid,b=$l(f?.gridStyle),v=$l(p?.gridStyle),w=Pl(f?.gridStyle,{stroke:a,strokeWidth:.5}),k=Pl(p?.gridStyle,{stroke:a,strokeWidth:.5});return(0,Ab.jsxs)("g",{id:c+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((t,o)=>(0,Ab.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:e.height,...w,strokeDasharray:b??w.strokeDasharray},"gx-"+o)),x&&g.map((t,o)=>(0,Ab.jsx)("line",{x1:0,y1:t.pixel,x2:e.width,y2:t.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+o))]})}(w.scales,{width:p,height:g},i,S,e.axisExtent,e.axes,_):null,P=M.map(t=>t.element),j=El(e)+"-plot-clip",I=!1!==e.showAxes,L=I?function(e,o,i,n,r,s,a,c=!1){const l=Qt(n),u=i.legendPosition??"right",d=h(i.legendLayout,a?.leftAxis),f=h(i.legendLayout,a?.rightAxis),p=c&&"left"===u&&d>0?d:s?.left??i.margin?.left??40,y=c&&"right"===u&&f>0?f:s?.right??i.margin?.right??40,{xAxis:g,yAxis:m,xOrient:x,yOrient:b}=t(i.axes),v="top"===x?0:o.height,w="right"===b?o.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=Nl({scale:e.x,axis:g,size:o.width,horizontal:!0,format:i.xFormat||i.tickFormatTime,axisExtent:i.axisExtent}),M=Nl({scale:e.y,axis:m,size:o.height,format:i.yFormat||i.tickFormatValue,axisExtent:i.axisExtent}),_=!(!g?.autoRotate||!function(t){for(let e=1;t.length>e;e++){const o=t[e-1],i=t[e];if(Math.abs(i.pixel-o.pixel)<(Dl(o.label)+Dl(i.label))/2+8)return!0}return!1}(S)),$=_l(S),P=_l(M),j=g?.label??i.xLabel,I=m?.label??("right"===b?i.yLabelRight??i.yLabel:i.yLabel),L=Pl(g?.axisStyle,{stroke:l.border,strokeWidth:1}),R=Pl(m?.axisStyle,{stroke:l.border,strokeWidth:1}),T="right"===b?o.width+y-15:15-p;return(0,wb.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[!1!==g?.visible&&(0,wb.jsxs)("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==g?.baseline&&!g?.jaggedBase&&(0,wb.jsx)("line",{x1:0,y1:v,x2:o.width,y2:v,...L}),g?.jaggedBase&&(0,wb.jsx)("path",{d:jl(x,o.width,o.height),fill:"none",...L}),S.map((t,e)=>{const o=Cl(g?.landmarkTicks,t,e,S);return(0,wb.jsxs)("g",{transform:`translate(${t.pixel},${v})`,children:[(0,wb.jsx)("line",{y2:5*k,...L}),Ll(t.label)?(0,wb.jsx)("text",{y:k*(_?12:18),textAnchor:_?"end":Sl(g?.tickAnchor,t.pixel===$.min,t.pixel===$.max),fontWeight:o?600:400,fontSize:o?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,transform:_?"top"===x?"rotate(45)":"rotate(-45)":void 0,children:t.label}):Rl({label:t.label,x:-30,y:"top"===x?-30:6,textAlign:"center",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"xtick-"+e)}),j&&(0,wb.jsx)("text",{x:o.width/2,y:"top"===x?-(_?58:40):o.height+(_?58:40),textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:j})]}),!1!==m?.visible&&(0,wb.jsxs)("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==m?.baseline&&!m?.jaggedBase&&(0,wb.jsx)("line",{x1:w,y1:0,x2:w,y2:o.height,...R}),m?.jaggedBase&&(0,wb.jsx)("path",{d:jl(b,o.width,o.height),fill:"none",...R}),M.map((t,e)=>{const o=Cl(m?.landmarkTicks,t,e,M);return(0,wb.jsxs)("g",{transform:`translate(${w},${t.pixel})`,children:[(0,wb.jsx)("line",{x2:5*A,...R}),Ll(t.label)?(0,wb.jsx)("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:Ml(m?.tickAnchor,t.pixel===P.min,t.pixel===P.max),fontWeight:o?600:400,fontSize:o?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:t.label}):Rl({label:t.label,x:"right"===b?8:-68,y:-12,textAlign:"right"===b?"left":"right",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"ytick-"+e)}),I&&(0,wb.jsx)("text",{x:T,y:o.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${T}, ${o.height/2})`,children:I})]})]})}(w.scales,{width:p,height:g},_,i,S,s,d,!!f):null,R=I?function(t){const{scales:e,layout:o,props:i,theme:n,leftAxis:r,rightAxis:s,margin:a,axisChrome:c,hasRenderedLegend:l}=t;if(!r||!s||!1===s.visible)return null;const u=Qt(n),d=Nl({scale:e.y,axis:s,size:o.height,format:i.yFormat||i.tickFormatValue,axisExtent:i.axisExtent}),f=_l(d),p=s.label??i.yLabelRight,y=Pl(s.axisStyle,{stroke:u.border,strokeWidth:1}),g=i.legendPosition??"right",m=h(i.legendLayout,c?.rightAxis),x=o.width+(l&&"right"===g&&m>0?m:a.right)-15;return(0,Pb.jsxs)("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==s.baseline&&!s.jaggedBase&&(0,Pb.jsx)("line",{x1:o.width,y1:0,x2:o.width,y2:o.height,...y}),s.jaggedBase&&(0,Pb.jsx)("path",{d:jl("right",o.width,o.height),fill:"none",...y}),d.map((t,e)=>{const i=Cl(s.landmarkTicks,t,e,d);return(0,Pb.jsxs)("g",{transform:`translate(${o.width},${t.pixel})`,children:[(0,Pb.jsx)("line",{x2:5,...y}),Ll(t.label)?(0,Pb.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Ml(s.tickAnchor,t.pixel===f.min,t.pixel===f.max),fontWeight:i?600:400,fontSize:i?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:t.label}):Rl({label:t.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+e)}),p&&(0,Pb.jsx)("text",{x:x,y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${o.height/2})`,children:p})]})}({scales:w.scales,layout:{width:p,height:g},props:e,theme:i,leftAxis:e.axes?.find(t=>"left"===t.orient),rightAxis:e.axes?.find(t=>"right"===t.orient),margin:s,axisChrome:d,hasRenderedLegend:!!f}):null;let T;const C=e.annotations?wl({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:l,scales:{x:w.scales.x,y:w.scales.y},layout:{width:p,height:g},theme:i,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:S,onRender:t=>{T=t}}):null;o&&(o.evidence=dc({frameType:"xy",width:n[0],height:n[1],marks:M.map(t=>t.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:T,xDomain:uc(w.scales.x?.domain?.()),yDomain:uc(w.scales.y?.domain?.()),legendItems:u.length>0?u.length:void 0,margin:s}));const O=e.svgPreRenderers&&w.scales?e.svgPreRenderers.map((t,e)=>{try{return(0,jb.jsx)(dm.Fragment,{children:t(w.scene,w.scales,{width:p,height:g})},"pre-"+e)}catch{return null}}).filter(Boolean):null;return hm.renderToStaticMarkup(Gl((0,jb.jsxs)(jb.Fragment,{children:[k,O,$,(0,jb.jsx)("defs",{children:(0,jb.jsx)("clipPath",{id:j,children:(0,jb.jsx)("rect",{x:0,y:0,width:p,height:g})})}),(0,jb.jsx)("g",{clipPath:`url(#${j})`,children:P}),L,R,C,A,w.customLayoutOverlays]}),{width:n[0],height:n[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:p,innerHeight:g,legend:f,idPrefix:e._idPrefix}))}function Ul({machine:t,layout:e,runtime:o,downstreamSet:i,selectedSet:n,width:r,height:s,seed:a,reduced:c,onSelectTask:l}){const u=e.tasks.length?Math.min(...e.tasks.map(t=>t.y-t.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);return(0,Lb.jsxs)("svg",{"aria-hidden":"true",width:r,height:s,viewBox:`0 0 ${r} ${s}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[(0,Lb.jsx)("defs",{children:(0,Lb.jsx)("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:(0,Lb.jsx)("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),t.lanes.map((t,o)=>{const i=e.tasks.filter(t=>t.laneIndex===o),n=i[0]?.x??0;return(0,Lb.jsxs)("g",{children:[(0,Lb.jsx)("line",{x1:n,x2:n,y1:h,y2:s-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),(0,Lb.jsx)("text",{x:n,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:t})]},t)}),e.routes.map(t=>{const e=o.delivered.has(t.edgeID),n=o.inFlight.has(t.edgeID),r=i.has(t.targetID)||i.has(t.sourceID),s=t.points.map(t=>`${t.x},${t.y}`).join(" ");return(0,Lb.jsx)("polyline",{points:s,fill:"none",stroke:r?"var(--semiotic-selection-color, #e08a1e)":e?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:r?4:n?3:2,strokeOpacity:e||n||r?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},t.edgeID)}),e.sockets.map(t=>{const e=o.delivered.has(t.edgeID);return(0,Lb.jsxs)("g",{children:[(0,Lb.jsx)("circle",{cx:t.x,cy:t.y,r:t.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),e&&(0,Lb.jsx)("circle",{cx:t.x,cy:t.y,r:t.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},t.id)}),t.nodes.map(t=>{const r=e.taskByID.get(t.id);if(!r)return null;const s=o.completed.has(t.id),u=o.blockers.has(t.id),d=o.previewTaskID===t.id,h=n.has(t.id)||d,f=i.has(t.id),p=function(t,e){return e.completed.has(t.id)?"var(--semiotic-success, #2b8a66)":e.blockers.has(t.id)?"var(--semiotic-error, #c64035)":"in-progress"===t.status?"var(--semiotic-warning, #d18a22)":e.armed.has(t.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}(t,o),y=r.x-r.width/2,g=r.y-r.height/2,m=Math.max(2,r.height*t.progress);return(0,Lb.jsxs)("g",{children:[(0,Lb.jsxs)("g",{style:{transform:`rotate(${s?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:c?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+a+")"},children:[(0,Lb.jsx)("rect",{x:y,y:g,width:r.width,height:r.height,rx:t.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||f?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:h?4:f?3:2}),(0,Lb.jsx)("rect",{x:y+3,y:g+r.height-m+1,width:r.width-6,height:Math.max(0,m-4),rx:2,fill:p,opacity:s?.86:.46})]}),u&&(0,Lb.jsxs)("g",{opacity:d?.28:1,children:[(0,Lb.jsx)("line",{x1:y-8,x2:y+14,y1:r.y+9,y2:r.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),(0,Lb.jsx)("circle",{cx:y-8,cy:r.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),(0,Lb.jsxs)("g",{onPointerDown:()=>l(t.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[(0,Lb.jsx)("rect",{x:y,y:g,width:r.width,height:r.height,fill:"transparent"}),(0,Lb.jsx)("text",{x:r.x,y:r.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:t.label.length>24?t.label.slice(0,22)+"…":t.label}),(0,Lb.jsxs)("text",{x:r.x,y:r.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*t.progress),"% · ",s?"done":u?"blocked":o.armed.has(t.id)?"ready":"waiting"]})]})]},t.id)})]})}function Kl(t,e=0){if(t instanceof Date)return t.getTime();const o=Number(t);return Number.isFinite(o)?o:e}function Zl(t){if(null==t.completionTime)return null;const e=Kl(t.completionTime,NaN);return Number.isFinite(e)?e:null}function Ql(t,e,o,i){const n=new Set;for(const r of t.nodes){const s=t.incoming.get(r.id)??[];(i.has(r.id)||!o.has(r.id)&&s.every(t=>e.has(t.id)))&&n.add(r.id)}return n}function Jl(t,e,o={}){const i=new Set,n=[...t.get(e)??[]];for(let e=0;n.length>e;e++){const o=n[e];i.has(o)||(i.add(o),n.push(...t.get(o)??[]))}return o.includeStart&&i.add(e),i}function tu(t,e,o){return function(t,e,o){if(null!=t)return"function"==typeof t?t(e,o):"object"==typeof t&&null!==t&&"constant"in t?t.constant:e[t]}(o,t,e)}function eu(t,e){return e>t?-1:t>e?1:0}function ou(t,e){return`dependency:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function iu(t,e){return`socket:${encodeURIComponent(t)}:${e}`}function nu(t){const e=Number(t);return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}function ru(t,e,o={}){const i=new Set(o.completedTaskIDs??[]),n=[...Jl(function(t,e){const o=new Map;for(const e of t)o.set(e.id,new Set);for(const t of e)o.has(t.source)||o.set(t.source,new Set),o.has(t.target)||o.set(t.target,new Set),o.get(t.source).add(t.target);return o}(t.nodes,t.edges.map(t=>({source:t.sourceID,target:t.targetID}))),e)].map(e=>t.byID.get(e)).filter(t=>null!=t).filter(t=>!(o.isComplete?o.isComplete(t):i.has(t.id)||"done"===t.status)).sort((t,e)=>t.index-e.index),r=Array.from(new Set(n.map(t=>t.lane)));return{blockerID:e,downstreamTaskCount:n.length,affectedLaneCount:r.length,downstreamTaskIDs:n.map(t=>t.id),affectedLanes:r}}function su(t,e,o,i,n){return{__composite:{data:t,colorBy:e,colorScheme:o,common:i,rest:n}}}function au(t){return t.__composite}function cu(t,e){return"number"==typeof t&&Number.isFinite(t)?t:e}function lu(t,e){return Math.max(1,Math.floor(cu(t,e)))}function uu(t,e,o,i){return t.replace(/^<svg\b/,`<svg x="${e}" y="${o}" data-semiotic-composite-part="${i}"`)}function du(t,e){for(const o of t){const t=o?.[e];if(Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1])return t}}function hu(t,e){return("function"==typeof e?e(t):t[e])+""}function fu(t,e,o){const i="function"==typeof t?t(o?e.w:e.h):t;return"number"==typeof i&&Number.isFinite(i)?Math.max(0,i):0}function pu(t){const e=t.getSymbol;return e?za(e,t.config.symbolMap):null}function yu(t,e,o,i,n,r,s){t.push(e?{type:"symbol",x:i,y:n,size:Math.PI*r*r,symbolType:e(o),style:s,datum:o}:{type:"point",x:i,y:n,r:r,style:s,datum:o})}function gu(t,e){const{columns:o,config:i,resolvePieceStyle:n}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(o),h=d.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!h&&d.length>1&&(i.cornerRadius??0)>0;for(let t=0;d.length>t;t++){const e=d[t],o=e.pieceData[0],u="number"==typeof o?._pctStart?o._pctStart:e.pctStart,h=c+u*l,p=c+(u+("number"==typeof o?._pct?o._pct:e.pct))*l,y=n(e.pieceData[0],e.name),g=0===t,m=t===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:y,datum:o?._nonInteractive?null:e.pieceData,category:e.name};o?._roundedEnds?x.roundedEnds=o._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),o?._gradientBand&&(x._gradientBand=o._gradientBand),r.push(x)}return r}function mu(t,e,o){return{...t[0],...o,category:e,data:t}}function xu(t){const e=t.length,o=t[0],i=t[e-1];return{n:e,min:o,q1:(0,Yb.quantileSorted)(t,.25)??o,median:(0,Yb.quantileSorted)(t,.5)??(o+i)/2,q3:(0,Yb.quantileSorted)(t,.75)??i,max:i,mean:t.reduce((t,e)=>t+e,0)/e}}function bu(t,e,o,i,n){const r=Array(n).fill(0);for(const s of t)e>s||s>o||r[Math.min(Math.floor((s-e)/i),n-1)]++;return r}function vu(t){const{innerRadius:e,outerRadius:o,startAngle:i,endAngle:n}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=lv(o,i),e=lv(o,n);return`M0,0 L${t.x},${t.y} A${o},${o} 0 ${n-i>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=lv(o,i),s=lv(o,n),a=lv(e,n),c=lv(e,i),l=n-i>Math.PI?1:0;return`M${t.x},${t.y} A${o},${o} 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,(o-e)/2));if(0===s)return vu({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,o-s))),c=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=n-i,u=t.roundStart&&t.roundEnd?l/2:l,d=!!t.roundStart&&u>a,h=!!t.roundEnd&&u>a;if(!d&&!h)return vu({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=i+(d?a:0),p=n-(h?a:0),y=i+(d?c:0),g=n-(h?c:0),m=lv(o,f),x=lv(o,p),b=(o-s)*Math.cos(a),v=lv(b,i),w=lv(b,n),k=r?null:lv(e,g),A=r?null:lv(e,y),S=r?0:(e+s)*Math.cos(c),M=r?null:lv(S,i),_=r?null:lv(S,n),$=p-f>Math.PI?1:0,P=r?0:g-y>Math.PI?1:0;let j="";if(d)j+=`M${v.x},${v.y}`,j+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=lv(o,i);j+=`M${t.x},${t.y}`}if(h)j+=` A${o},${o} 0 ${$} 1 ${x.x},${x.y}`,j+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=lv(o,n);j+=` A${o},${o} 0 ${$} 1 ${t.x},${t.y}`}if(r)j+=" L0,0";else{if(h)j+=` L${_.x},${_.y}`,j+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=lv(e,n);j+=` L${t.x},${t.y}`}if(d)j+=` A${e},${e} 0 ${P} 0 ${A.x},${A.y}`,j+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=lv(e,i);j+=` A${e},${e} 0 ${P} 0 ${t.x},${t.y}`}}return j+=" Z",j}function wu(t){return 1e6>t?1e4>t?1e3>t?t+"":(t/1e3).toFixed(1)+"K":(t/1e3).toFixed(0)+"K":(t/1e6).toFixed(1)+"M"}function ku(t,e){const o=t.datum;if(!o)return null;const i=[],n=o.__funnelStepLabel,r=Number(o.__funnelStepLabelX),s=Number(o.__funnelStepLabelY),a=Number(o.__funnelRowWidth);"string"!=typeof n||!Number.isFinite(r)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*n.length+16>a||i.push((0,uv.jsx)("text",{x:r,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:n},e+"-funnel-step"));const c=Number(o.__funnelValue),l=Number(o.__funnelValueLabelX),u=Number(o.__funnelValueLabelY),d=Number(o.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&d>=60){const t=Number(o.__funnelPercent);let n=!0!==o.__funnelIsFirstStep&&Number.isFinite(t)?`${wu(c)} (${.05>Math.abs(t-Math.round(t))?Math.round(t):t.toFixed(1)}%)`:wu(c);7.8*n.length+16>d&&(n=wu(c)),7.8*n.length+16>d||i.push((0,uv.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:n},e+"-funnel-value"))}return i.length?(0,uv.jsx)("g",{children:i},e+"-funnel-labels"):null}function Au(t){return"connector"===t.node.type}function Su(t,e,o,i){if(2>t.length)return null;const n=t[0].node,r=n.style.fill;if(!r||"none"===r)return null;const s=fc(`${e?e+"-":""}connector-${o}-${i}-hatch`),a=ri(r)?ai(r,s):null,c=[`${n.x1},${n.y1}`,...t.map(({node:t})=>`${t.x2},${t.y2}`)].join(" ");return bc((0,dv.jsxs)(sv.Fragment,{children:[a&&(0,dv.jsx)("defs",{children:a}),(0,dv.jsx)("polygon",{points:c,fill:a?`url(#${s})`:hc(r,"#999"),opacity:n.style.fillOpacity??n.style.opacity??.3,"data-semiotic-connector-fill":n.group||"_default"})]}),n,`ordinal-connector-fill-${o}-${i}`)}function Mu(t,e,o){const i=new Map;for(const e of t){if(!Au(e))continue;const t=e.node.group||"_default",o=i.get(t);o?o.push(e):i.set(t,[e])}if(0===i.size)return;const n=Array.from(i.values()).map((t,i)=>(0,dv.jsxs)("g",{children:[Su(t,e,o,i),t.map(t=>t.element)]},`ordinal-connectors-${o}-${i}`)),r=t[0],s=Au(r)?null:r.element;for(const t of i.values())for(const e of t)e.element=null;r.element=(0,dv.jsxs)(sv.Fragment,{children:[n,s]},"ordinal-connector-run-"+o)}function _u(t){const e=Ac({nodes:t.nodes,renderMode:t.renderMode,fallback:(e,o)=>function(t,e,o){return bc(function(t,e,o){const i=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",n=o=>`ord-${t.type}-${i}-${e}-${o}`,r=`ord-${t.type}-${i}-${e}`;switch(t.type){case"rect":{const e=t,o=fc(r)+"-grad",i=function(t,e){const o=t.fillGradient;if(!o||"object"!=typeof o)return null;let i=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?(i=t.x+t.w,n=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(i=t.x,n=t.y,r=t.x+t.w,s=t.y);const a=yc(o.stops,hc(t.style.fill));return a?(0,vx.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:i,y1:n,x2:r,y2:s,children:a}):null}(e,o);let n,s;if(i)s=`url(#${o})`;else if(ri(e.style.fill)){const t=fc(r)+"-hatch";n=ai(e.style.fill,t),s=`url(#${t})`}else s=hc(e.style.fill);const a=i||n?(0,uv.jsxs)("defs",{children:[i,n]}):null;if(e.cornerRadii&&tc(e.cornerRadii)){const t=function(t){const{x:e,y:o,w:i,h:n}=t,{tl:r,tr:s,br:a,bl:c}=ec(t);let l=`M${e+r},${o}`;return l+=` L${e+i-s},${o}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+i},${o+s}`),l+=` L${e+i},${o+n-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+i-a},${o+n}`),l+=` L${e+c},${o+n}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${o+n-c}`),l+=` L${e},${o+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${e+r},${o}`),l+=" Z",l}(e);return(0,uv.jsxs)(av.Fragment,{children:[a,(0,uv.jsx)("path",{d:t,fill:s,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:o,y:i,w:n,h:c}=e;let l;switch(e.roundedEdge){case"right":l=`M${o},${i} L${o+n-t},${i} A${t},${t} 0 0 1 ${o+n},${i+t} L${o+n},${i+c-t} A${t},${t} 0 0 1 ${o+n-t},${i+c} L${o},${i+c} Z`;break;case"left":l=`M${o+n},${i} L${o+t},${i} A${t},${t} 0 0 0 ${o},${i+t} L${o},${i+c-t} A${t},${t} 0 0 0 ${o+t},${i+c} L${o+n},${i+c} Z`;break;case"bottom":l=`M${o},${i} L${o+n},${i} L${o+n},${i+c-t} A${t},${t} 0 0 1 ${o+n-t},${i+c} L${o+t},${i+c} A${t},${t} 0 0 1 ${o},${i+c-t} Z`;break;default:l=`M${o},${i+c} L${o},${i+t} A${t},${t} 0 0 1 ${o+t},${i} L${o+n-t},${i} A${t},${t} 0 0 1 ${o+n},${i+t} L${o+n},${i+c} Z`}return(0,uv.jsxs)(av.Fragment,{children:[a,(0,uv.jsx)("path",{d:l,fill:s,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return(0,uv.jsxs)(av.Fragment,{children:[a,(0,uv.jsx)("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:s,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth}),ku(e,r)]},r)}case"point":{const e=t;return(0,uv.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:hc(e.style.fill),opacity:e.style.opacity??e.style.fillOpacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return gc(t,e,o);case"glyph":return pc(t,t.x,t.y,`${o??""}ord-glyph-${t.pointId??e}`);case"wedge":{const i=t;if(i._gradientBand&&i._gradientBand.colors.length>0){const t=fc(`${o?o+"-":""}gauge-grad-${i.category||r}-${e}`),{clipPath:n,slices:s}=function(t){const e=vu({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),o=[],i=t.colors;if(i.length>0){const e=(t.endAngle-t.startAngle)/i.length;for(let n=0;i.length>n;n++)o.push({d:vu({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+n*e,endAngle:t.endAngle}),color:i[n]})}return{clipPath:e,slices:o}}({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,uv.jsxs)("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[(0,uv.jsx)("defs",{children:(0,uv.jsx)("clipPath",{id:t,children:(0,uv.jsx)("path",{d:n})})}),(0,uv.jsx)("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>(0,uv.jsx)("path",{d:t.d,fill:hc(t.color)},e))}),i.style.stroke&&"none"!==i.style.stroke&&(0,uv.jsx)("path",{d:n,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},r)}let n;if(i.roundedEnds)n=vu({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const t=(0,cv.arc)().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),n=t(wx)||""}return(0,uv.jsx)("path",{d:n,transform:`translate(${i.cx},${i.cy})`,fill:hc(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},r)}case"boxplot":{const e=t,o=e.columnWidth/2,i=e.style.strokeWidth??1;return(0,uv.jsxs)("g","vertical"===e.projection?{children:[(0,uv.jsx)("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,uv.jsx)("rect",{x:e.x-o,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:hc(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,uv.jsx)("line",{x1:e.x-o,y1:e.medianPos,x2:e.x+o,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2*i}),(0,uv.jsx)("line",{x1:e.x-.5*o,y1:e.minPos,x2:e.x+.5*o,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,uv.jsx)("line",{x1:e.x-.5*o,y1:e.maxPos,x2:e.x+.5*o,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:i})]}:{children:[(0,uv.jsx)("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,uv.jsx)("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-o,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:hc(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,uv.jsx)("line",{x1:e.medianPos,y1:e.y-o,x2:e.medianPos,y2:e.y+o,stroke:e.style.stroke||"#333",strokeWidth:2*i}),(0,uv.jsx)("line",{x1:e.minPos,y1:e.y-.5*o,x2:e.minPos,y2:e.y+.5*o,stroke:e.style.stroke||"#333",strokeWidth:i}),(0,uv.jsx)("line",{x1:e.maxPos,y1:e.y-.5*o,x2:e.maxPos,y2:e.y+.5*o,stroke:e.style.stroke||"#333",strokeWidth:i})]},r)}case"violin":{const e=t,o=[(0,uv.jsx)("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:hc(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,i=t.x+t.width/2,r=t.y+t.height/2;e.iqrLine.isVertical?o.push((0,uv.jsx)("line",{x1:i,y1:e.iqrLine.q1Pos,x2:i,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,uv.jsx)("circle",{cx:i,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med"))):o.push((0,uv.jsx)("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),(0,uv.jsx)("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med")))}return(0,uv.jsx)("g",{children:o},r)}case"connector":{const e=t,o=e.style.fill&&"none"!==e.style.fill?hc(e.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";return(0,uv.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||o,strokeWidth:e.style.strokeWidth??1,opacity:e.style.opacity??.5},r)}case"trapezoid":{const e=t,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return(0,uv.jsx)("polygon",{points:o,fill:hc(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}}(t,e,o),t,"ordinal-cursor-"+e)}(e,o,t.idPrefix)});let o=0;for(let i=0;e.length>i;){if(e[i].renderedByBackend){i++;continue}let n=i+1;for(;e.length>n&&!e[n].renderedByBackend;)n++;Mu(e.slice(i,n),t.idPrefix,o++),i=n}return e}function $u(t,o){const i=Zt(t.theme),n=t.size||[500,400],s=a({...Sb,...t.margin},t.title),c=r(t.title),l=xt(t.data),u=t.showLegend?Rc(l,t.colorAccessor||t.stackBy||t.groupBy):[],d=function(t){const e=t.projection??"vertical",o=!1!==t.showAxes&&"radial"!==e;return{hasAxis:o,hasAxisLabel:o&&("horizontal"===e?t.hasValueLabel:t.hasCategoryLabel),leftAxis:{hasAxis:o,hasAxisLabel:o&&("horizontal"===e?t.hasCategoryLabel:t.hasValueLabel)}}}({showAxes:t.showAxes,projection:t.projection,hasCategoryLabel:!(!t.categoryLabel&&!t.oLabel),hasValueLabel:!(!t.valueLabel&&!t.rLabel)});ql(s,{props:{...t,axisChrome:d},categories:u,theme:i,size:n,hasTitle:c});const f=Xl({props:{...t,axisChrome:d},categories:u,theme:i,size:n,margin:s,hasTitle:c}),p=n[0]-s.left-s.right,y=n[1]-s.top-s.bottom,g=t.projection||"vertical",m="radial"===g,x=t.colorScheme||i.colors.categorical,b={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:g,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:Yt(t.gradientFill),symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,multiAxis:t.multiAxis,baselinePadding:t.baselinePadding,trackFill:t.trackFill,connectorOpacity:t.connectorOpacity,showLabels:t.showLabels,colorScheme:x,themeCategorical:i.colors.categorical,themeSemantic:Kt(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:s,layoutSelection:t.layoutSelection,barColors:t.barColors},v=new rv(b);t.data&&v.ingest({inserts:l,bounded:!0}),v.computeScene({width:p,height:y});const w=Vl(t.backgroundGraphics,n,s,v.scales),k=Vl(t.foregroundGraphics,n,s,v.scales);if(!v.scales){let e;const r=t.annotations?wl({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:l,scales:{},layout:{width:p,height:y},theme:i,projection:g,idPrefix:t._idPrefix,onRender:t=>{e=t}}):null;return o&&(o.evidence=dc({frameType:"ordinal",width:n[0],height:n[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:e,extraWarnings:v.scales?[]:["NO_SCALES"],margin:s})),Eb.renderToStaticMarkup(Gl(w||k||t.annotations?(0,fv.jsxs)(fv.Fragment,{children:[w,r,k,v.customLayoutOverlays]}):null,{width:n[0],height:n[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:p,innerHeight:y,legend:f,idPrefix:t._idPrefix}))}const A=t._idPrefix,S=t.showGrid?function(t,e,o,i,n,r){const s=t.scales;if(!s||"radial"===s.projection)return null;const{grid:a}=Qt(o),c=i?i+"-":"",l="vertical"===s.projection,u=r??Il(s.r,5,n);return(0,wb.jsx)("g",l?{id:c+"grid",className:"semiotic-grid",opacity:.8,children:u.map((t,o)=>{const i=s.r(t);return(0,wb.jsx)("line",{x1:0,y1:i,x2:e.width,y2:i,stroke:a,strokeWidth:.5},"gr-"+o)})}:{id:c+"grid",className:"semiotic-grid",opacity:.8,children:u.map((t,o)=>{const i=s.r(t);return(0,wb.jsx)("line",{x1:i,y1:0,x2:i,y2:e.height,stroke:a,strokeWidth:.5},"gr-"+o)})})}(v,{width:p,height:y},i,A,t.axisExtent,t.rTickValues):null;let M=null;if(v.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=El(t),o=new Set;for(const t of v.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:o="transparent",stroke:i="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return(0,hv.jsxs)("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[o&&"transparent"!==o&&(0,hv.jsx)("rect",{width:a,height:a,fill:o}),(0,hv.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:n}),(0,hv.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:i,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,o)=>n.set(t,`funnel-hatch-${e}-${o}`));for(const t of v.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 _=_u({nodes:v.scene,renderMode:t.renderMode,idPrefix:A}),$=_.map(t=>t.element),P=!1!==t.showAxes?function(t,o,i,n,r,s,a,c=!1){const l=t.scales;if(!l)return null;if("radial"===l.projection)return null;const u=Qt(n),d="vertical"===l.projection,f=t.columns,p=i.categoryFormat||i.oFormat,y=i.valueFormat||i.rFormat,g=i.categoryLabel||i.oLabel,m=i.valueLabel||i.rLabel,x=i.legendPosition??"right",b=h(i.legendLayout,a?.leftAxis),v=c&&"left"===x&&b>0?b:s?.left??i.margin?.left??40,w=Object.values(f).map((t,e)=>({pixel:t.middle,label:p?p(t.name,e):t.name})),k=i.rTickValues??Il(l.r,5,i.axisExtent),A=y||e(k),S=k.map(t=>({pixel:l.r(t),label:A(t)}));return(0,fv.jsxs)("g",d?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,fv.jsx)("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:u.border,strokeWidth:1}),w.map((t,e)=>(0,fv.jsxs)("g",{transform:`translate(${t.pixel},${o.height})`,children:[(0,fv.jsx)("line",{y2:5,stroke:u.border,strokeWidth:1}),Ll(t.label)?(0,fv.jsx)("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:t.label}):Rl({label:t.label,x:-30,y:6,textAlign:"center",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oxtick-"+e)),g&&(0,fv.jsx)("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:g}),(0,fv.jsx)("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:u.border,strokeWidth:1}),S.map((t,e)=>(0,fv.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,fv.jsx)("line",{x2:-5,stroke:u.border,strokeWidth:1}),(0,fv.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:t.label})]},"oytick-"+e)),m&&(0,fv.jsx)("text",{x:15-v,y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${o.height/2})`,children:m})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,fv.jsx)("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:u.border,strokeWidth:1}),S.map((t,e)=>(0,fv.jsxs)("g",{transform:`translate(${t.pixel},${o.height})`,children:[(0,fv.jsx)("line",{y2:5,stroke:u.border,strokeWidth:1}),(0,fv.jsx)("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:t.label})]},"oxtick-"+e)),m&&(0,fv.jsx)("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:m}),(0,fv.jsx)("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:u.border,strokeWidth:1}),w.map((t,e)=>(0,fv.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,fv.jsx)("line",{x2:-5,stroke:u.border,strokeWidth:1}),Ll(t.label)?(0,fv.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:t.label}):Rl({label:t.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+e)),g&&(0,fv.jsx)("text",{x:15-v,y:o.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${o.height/2})`,children:g})]})}(v,{width:p,height:y},t,i,A,s,d,!!f):null;let j;const I=t.annotations?wl({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:l,scales:{o:v.scales.o,r:v.scales.r,y:"vertical"===v.scales.projection?v.scales.r:void 0},layout:{width:p,height:y},theme:i,projection:g,xAccessor:"string"==typeof t.oAccessor?t.oAccessor:void 0,yAccessor:"string"==typeof t.rAccessor?t.rAccessor:void 0,idPrefix:A,onRender:t=>{j=t}}):null;if(o){const e=v.scales.o?.domain?.();o.evidence=dc({frameType:"ordinal",width:n[0],height:n[1],marks:_.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:j,yDomain:uc(v.scales.r?.domain?.()),categories:Array.isArray(e)?e.map(String):void 0,margin:s})}const L=m&&t.centerContent?function(t,e,o){if(!Db.isValidElement(t))return null;if(!zb.has(t.type))return null;const i=t,n="text"===i.type?Db.cloneElement(i,{x:i.props.x??0,y:i.props.y??0,textAnchor:i.props.textAnchor??"middle",dominantBaseline:i.props.dominantBaseline??"middle"}):i;return(0,Nb.jsx)("g",{className:"semiotic-radial-center-content",transform:`translate(${e},${o})`,pointerEvents:"none",children:n})}(t.centerContent,s.left+p/2,s.top+y/2):null,R=m&&t.centerContent?L??(0,fv.jsx)("foreignObject",{x:s.left,y:s.top,width:p,height:y,pointerEvents:"none",children:(0,fv.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:t.centerContent})}):null,T=(0,fv.jsxs)(fv.Fragment,{children:[S,$,P,I,k,v.customLayoutOverlays]});return Eb.renderToStaticMarkup(Gl((0,fv.jsxs)(fv.Fragment,m?{children:[w?(0,fv.jsx)("g",{transform:`translate(${-p/2},${-y/2})`,children:w}):null,T]}:{children:[w,T]}),{width:n[0],height:n[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:m?`translate(${s.left+p/2},${s.top+y/2})`:`translate(${s.left},${s.top})`,innerWidth:p,innerHeight:y,legend:f,defs:M,outerElements:R,idPrefix:t._idPrefix}))}function Pu(t,e){yv[t]=e}function ju(t,e){var o=t.get(e);if(!o)throw Error("missing: "+e);return o}function Iu(t,e){function o(t){l[t]=!1,u.hasOwnProperty(t)&&Object.keys(u[t]).forEach(function(e){delete u[t][e],l[e]&&o(e)})}function i(t){var e,r,a=!1;for(c.push(t),l[t]=!0,e=0;d[t].length>e;e++)(r=d[t][e])===s?(n(s,c),a=!0):l[r]||(a=i(r));if(a)o(t);else for(e=0;d[t].length>e;e++){var h=u[r=d[t][e]];h||(u[r]=h={}),h[r]=!0}return c.pop(),a}function n(t,o){var i=[].concat(o).concat(t);e?e(i):a.push(i)}function r(e){!function(e){for(var o=0;t.length>o;o++)o>=e&&t[o]||(t[o]=[]),t[o]=t[o].filter(function(t){return t>=e})}(e);for(var o,i=function(t){function e(e){var o=[e],l=[e];for(i[e]=n[e]=d,r[e]=!0,d+=1;l.length>0;){var u=t[e=l[l.length-1]];if(u.length>s[e]){for(var p=s[e];u.length>p;++p){var y=u[p];if(0>i[y]){i[y]=n[y]=d,r[y]=!0,d+=1,o.push(y),l.push(y);break}r[y]&&(n[e]=0|Math.min(n[e],n[y])),0>a[y]||c[e].push(a[y])}s[e]=p}else{if(n[e]===i[e]){var g=[],m=[],x=0;for(p=o.length-1;p>=0;--p){var b=o[p];if(r[b]=!1,g.push(b),m.push(c[b]),x+=c[b].length,a[b]=h.length,b===e){o.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];f.push(v)}l.pop()}}}for(var o=t.length,i=Array(o),n=Array(o),r=Array(o),s=Array(o),a=Array(o),c=Array(o),l=0;o>l;++l)i[l]=-1,n[l]=0,r[l]=!1,s[l]=0,a[l]=-1,c[l]=[];var u,d=0,h=[],f=[];for(l=0;o>l;++l)0>i[l]&&e(l);for(l=0;f.length>l;l++){var p=f[l];if(0!==p.length){p.sort(function(t,e){return t-e}),u=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&u.push(p[y]);f[l]=u}}return{components:h,adjacencyList:f}}(t),n=i.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],o=s);var c=n[o];return!!c&&{leastVertex:r,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}var s,a=[],c=[],l=[],u={},d=[];s=0;for(var h=t.length;h>s;){var f=r(s);if(s=f.leastVertex,d=f.adjList){for(var p=0;d.length>p;p++)for(var y=0;d[p].length>y;y++){var g=d[p][y];l[+g]=!1,u[g]={}}i(s),s+=1}else s=h}return e?void 0:a}function Lu(t){return t.y0-t.y1>0?"up":"down"}function Ru(t,e){return e(t.source)==e(t.target)}function Tu(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var o=0;return t.target.targetLinks.forEach(function(t){o=t.circular?o+1:o}),1>=e&&1>=o}function Cu(t){return t.target.x0-t.source.x1}function Ou(t,e){var o=Du(t),i=Cu(e)/Math.tan(o);return"up"==Lu(t)?t.y1-i:t.y1+i}function Fu(t,e){var o=Du(t),i=Cu(e)/Math.tan(o);return"up"==Lu(t)?t.y1+i:t.y1-i}function Du(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Nu(t,e){return e(t)}function zu(t){return Bu(t.source)}function Eu(t){return Bu(t.target)}function Bu(t){return(t.y0+t.y1)/2}function Wu(t){return t.virtual?0:t.value}function Yu(t,e){var o=0;t.sourceLinks.forEach(function(t){o=t.circular&&!Ru(t,e)?o+1:o});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Ru(t,e)?i+1:i}),o+i}function qu(t){return t.target.depth}function Xu(t,e){return t.sourceLinks.length?t.depth:e-1}function Gu(t,e){return t.y0-e.y0}function Vu(t,e){return e.y0-t.y0}function Hu(t,e){return t.y1-e.y1}function Uu(t,e){return e.y1-t.y1}function Ku(t,e){return Qu(t.source,e.source)||t.index-e.index}function Zu(t,e){return Qu(t.target,e.target)||t.index-e.index}function Qu(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ju(t,e){return td(t)==td(e)?"bottom"==t.circularLinkType?Vu(t,e):Gu(t,e):td(e)-td(t)}function td(t){return t.target.column-t.source.column}function ed(t,e){return od(t)==od(e)}function od(t){return t.y0-t.y1>0?"up":"down"}function id(t,e,o,i,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,gv.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}),nd(r.links.filter(function(t){return"top"==t.circularLinkType}),e,o),nd(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,o),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Ru(t,e)&&Tu(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+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?Vu:Gu);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+n*o+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?Uu:Hu),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+n*o+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,o=t.y0,i=t.target.x0,n=t.y1,r=(e+i)/2;return"M"+e+","+o+"C"+r+","+o+" "+r+","+n+" "+i+","+n}(t)}),r}function nd(t,e,o){t.sort(Ju);var i=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(Ru(t,e)&&Tu(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&rd(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+o;r=c>r?c:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function rd(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function sd(t){return function(){return t}}function ad(t){return t.index}function cd(t){return t.nodes}function ld(t){return t.links}function ud(t,e,o){var i=(0,mv.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(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 o,i,n,r=(i=0,n=0,(o=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Bu(t.source)*e,i+=e}}),o.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Bu(t.target)*e,i+=e}}),i>0?n/i:NaN);a.set(t,{bc:r,idx:e})}),n.sort(function(t,e){var o=a.get(t),i=a.get(e),n=o.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(n)||isNaN(r)?isNaN(n)?isNaN(r)?o.idx-i.idx:1:-1:n-r})}else n.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Yu(e,o)-Yu(t,o):"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==i.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Yu(e,o)?(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 dd(t,e,o,i,n,r){function s(e,o){var i=c.length;c.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&&Yu(n,o)>0){var c=(0,mv.mean)(n.sourceLinks,Eu),l=(0,mv.mean)(n.targetLinks,zu),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-Bu(n))*e*.3;n.y0+=d,n.y1+=d}}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==i-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 h=(0,mv.mean)(n.sourceLinks,Eu),f=(0,mv.mean)(n.targetLinks,zu),p=((h&&f?(h+f)/2:h||f)-Bu(n))*e;n.y0+=p,n.y1+=p}})})}function a(){c.forEach(function(o){var r,s,a,c=t.y0,l=o.length;for(o.sort(e||Qu),a=0;l>a;++a)(s=c-(r=o[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+i;if((s=c-i-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=o[a]).y1+n-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}var c=(0,mv.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});a();for(var l=1,u=r;u>0;--u)s(l*=.99,o),a()}function hd(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Zu),t.targetLinks.sort(Ku)}),t.nodes.forEach(function(t){var e=t.y0,o=e,i=t.y1,n=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=o+t.width/2,o+=t.width)})})}function fd(){function t(){var t={nodes:p.apply(null,arguments),links:y.apply(null,arguments)};return function(t){t.x0=e,t.y0=o,t.x1=i,t.y1=n,t.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var o=function(t,e){var o=new Map;return(0,mv.group)(t,e).forEach(function(t,e){o.set(e,t[0])}),o}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,n=t.target;"object"!=typeof i&&(i=t.source=ju(o,i)),"object"!=typeof n&&(n=t.target=ju(o,n)),i.sourceLinks.push(t),n.targetLinks.push(t)})}(t,c),function(t,e){var o=0;if(null==e){for(var i=[],n=0;t.links.length>n;n++){var r=t.links[n],s=r.source.index,a=r.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=Iu(i);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,i=t.source.index;e===i||l[i]&&l[i][e]?(t.circular=!0,t.circularLinkID=o++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=o++)})}(t,u),function(t,e){var o=0,i=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:i>o?"top":"bottom","top"==n.circularLinkType?o++:i++,t.nodes.forEach(function(t){Nu(t,e)!=Nu(n.source,e)&&Nu(t,e)!=Nu(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),Ru(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(t,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max((0,mv.sum)(t.sourceLinks,Wu),(0,mv.sum)(t.targetLinks,Wu)),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)})})}(t),function(t,e,o){var i,n,r;if(null!=e){t.nodes.sort(function(t,o){return e(t)<e(o)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(i=t.nodes,n=[],r=0;i.length;++r,i=n,n=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(i=t.nodes,n=[],r=0;i.length;++r,i=n,n=[])i.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?o(t,r):t.column})}(t,u,l);var p=s;if(null!==a){var y=(0,mv.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),g=(0,mv.max)(y,function(t){return t.length});g>1&&(p=Math.max(1,(n-o)*a/(g-1)))}(function(t,e,o){var i=(0,mv.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,mv.min)(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/(0,mv.sum)(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var r=(0,mv.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-o)/r),e.x1=e.x0+o}:function(e){e.x0=t.x0,e.x1=e.x0+o})})(t,p,r),ud(t,u,c),dd(t,u,c,p,p,d),hd(t),id(t,c,h,f,8),ud(t,u,c),dd(t,u,c,p,p,d),hd(t),id(t,c,h,f,8),function(t,e){let o=t;o.nodes.forEach(function(t){t.y+(t.y1-t.y0)>o.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-o.y1));var i=o.links.filter(function(o){return Nu(o.source,e)==Nu(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ed(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var o=Ou(e,t);return t.y1-o}if(e.target.column>t.target.column)return Ou(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,o){if("bottom"==e.circularLinkType){for(var r=o+1,s=0;n>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(t,c),function(t,e){let o=t;o.nodes.forEach(function(t){var i=o.links.filter(function(o){return Nu(o.target,e)==Nu(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ed(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var o=Fu(e,t);return t.y0-o}if(e.source.column>t.source.column)return Fu(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,o){if("bottom"==e.circularLinkType){for(var r=o+1,s=0;n>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(t,c),function(t){var e=t.nodes,o=t.links,i=!1,n=!1;if(o.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==i||0==n){let i=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=(0,mv.min)(e,function(t){return t.y0}),s=(0,mv.max)(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1)}),o.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,o=i(t.y0)-t.y0;t.y0=i(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+o}),t.targetLinks.forEach(function(t){t.y1=t.y1+o})})}}(t),id(t,c,h,f,8)}(t),t}var e=0,o=0,i=1,n=1,r=24,s=8,a=null,c=ad,l=Xu,u=void 0,d=32,h=2,f=10,p=cd,y=ld;return t.update=function(t){return hd(t),id(t,c,h,f,8),t},t.nodeWidth=function(e){return arguments.length?(r=+e,t):r},t.nodePadding=function(e){return arguments.length?(s=+e,t):s},t.nodePaddingRatio=function(e){return arguments.length?(a=+e,t):a},t.nodes=function(e){return arguments.length?(p="function"==typeof e?e:sd(e),t):p},t.links=function(e){return arguments.length?(y="function"==typeof e?e:sd(e),t):y},t.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:sd(e),t):c},t.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:sd(e),t):l},t.nodeSort=function(e){return arguments.length?(u=e,t):u},t.iterations=function(e){return arguments.length?(d=+e,t):d},t.circularLinkGap=function(e){return arguments.length?(h=+e,t):h},t.extent=function(r){return arguments.length?(e=+r[0][0],o=+r[0][1],i=+r[1][0],n=+r[1][1],t):[[e,o],[i,n]]},t.size=function(r){return arguments.length?(e=o=0,i=+r[0],n=+r[1],t):[i-e,n-o]},t}function pd(t){const e=t.sankeyWidth/2,o=(t._circularWidth??t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const o=i.sourceX,n=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-o))),c=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${o},${n-e}L${o+a},${n-e}L${o+a},${n+e}L${o},${n+e}ZM${r},${s-e}L${r-c},${s-e}L${r-c},${s+e}L${r},${s+e}Z`}const n=i.sourceX,r=i.sourceY,s=i.targetX,a=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,h=Math.max(4,Math.min(o,15));return`M${n},${r-d*e}L${c},${r-d*e}L${c+o},${r-d*e+d*h}L${c+o},${u+d*o-d*h}L${c+o-h},${u+d*o}L${l-o+h},${u+d*o}L${l-o},${u+d*o-d*h}L${l-o},${a-d*e+d*h}L${l-o+h},${a-d*e}L${s},${a-d*e}L${s},${a+d*e}L${l+o},${a+d*e}L${l+o},${u-d*o}L${c-o},${u-d*o}L${c-o},${r+d*e}L${n},${r+d*e}Z`}function yd(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let o=kv.get(t);if(o){const t=o.get(e);if(t)return t}else o=new Map,kv.set(t,o);const i=new Proxy(t,{get(t,o,i){if("string"==typeof o&&!(o in t)&&t.data&&o in t.data){const t=`${e}:${o}`;wv.has(t)||(wv.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,o,i)}});return o.set(e,i),i}function gd(t,e,o){if(o.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const i=e||[5,20],n=[];for(const e of o){const o=e.data?.[t];"number"==typeof o&&n.push(o)}if(0===n.length)return()=>i[0];const[r,s]=te(n);if(r===s)return()=>(i[0]+i[1])/2;const a=(0,_v.scaleLinear)().domain([r,s]).range(i).clamp(!0);return e=>{const o=e.data?.[t];return null==o||"number"!=typeof o?i[0]:a(o)}}function md(t,e,o){const i=[];for(const n of e){const e=Is(n.source),r=Is(n.target);let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=o.get(s);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function xd(t){let e=0;for(let o=0;t.length>o;o++)e=(e<<5)-e+t.charCodeAt(o)|0;return Math.abs(e)}function bd(t,e,o){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const n=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t||"C"===t||"Q"===t)for(n.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)n.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(n.push(Number(i[r])+o+""),r++);else if("A"===t)for(n.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&n.push(i[r++]),i.length>r&&(n.push(Number(i[r])+e+""),r++),i.length>r&&(n.push(Number(i[r])+o+""),r++);else"Z"===t||"z"===t?(n.push(t),r++):(n.push(i[r]),r++)}return n.join(" ")}function vd(t){const[e,o,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*o+.114*i>150?"#222":"#fff"}function wd(t,e,o){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+o}function kd(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 Ad(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Tv}function Sd(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 Md(t,e,o,i,n){if("horizontal"===n){const n=(t+o)/2;return`M ${t},${e} C ${n},${e} ${n},${i} ${o},${i}`}if("radial"===n){const n=(t+o)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+i)/2} T ${o},${i}`}{const n=(e+i)/2;return`M ${t},${e} C ${t},${n} ${o},${n} ${o},${i}`}}function _d(t,e,o){const i=o.treeOrientation||"vertical";if("radial"===i){const o=e.x,i=e.y;t.x=i*Math.cos(o-Math.PI/2),t.y=i*Math.sin(o-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function $d(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 Pd(t,e){const o=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function jd(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}function Id(t){const e=t.id??t.datum?.id??t.datum?.data?.id??t.datum?.data?.name;return null==e?void 0:e+""}function Ld(t){if("glyph"===t.type&&t.glyph&&"number"==typeof t.size){const e=t.cx??t.x,o=t.cy??t.y;if("number"!=typeof e||"number"!=typeof o)return null;const i=Xa(t.glyph,t.size);return{x:e+i.centerDx,y:o+i.centerDy,r:Math.max(1,i.radius)}}const e=t.cx??(null!=t.x&&null!=t.w?t.x+t.w/2:t.x),o=t.cy??(null!=t.y&&null!=t.h?t.y+t.h/2:t.y);return"number"!=typeof e||"number"!=typeof o?null:{x:e,y:o,r:"number"==typeof t.r?Math.max(1,t.r):"number"==typeof t.outerR?Math.max(1,t.outerR):"number"==typeof t.size?Math.max(1,Na(t.size)):Math.max(1,t.w??0,t.h??0)/2}}function Rd(t){if(!t)return;const e=[];for(const o of t){const t=Ld(o);t&&e.push({pointId:Id(o),...t})}return e}function Td(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Cd(t){return t.map(t=>{const e=t.datum&&"object"==typeof t.datum?t.datum:{},o=e.data&&"object"==typeof e.data?e.data:e,i="cx"in t?t.cx:t.x+t.w/2,n="cy"in t?t.cy:t.y+t.h/2;return{...o,...null==o.id&&null!=t.id?{id:t.id}:{},x:i,y:n}})}function Od(t,e){const o=Zt(t.theme),i=t.chartType||"force",n=t.size||[500,500],s=function(t){return $b.has(t)?_b:Mb}(i),c=a({...s,...t.margin},t.title),l=r(t.title),u=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;if(!e)return[];const n=xt(t.nodes||[]);if(n.length>0)return Rc(n,e);if(Bv.has(i)&&t.data)return Rc(ui(t.data,t.childrenAccessor||"children"),e);const r=Array.isArray(t.edges)?xt(t.edges):[];if(0===r.length)return[];const s=Td(t.sourceAccessor,"source"),a=Td(t.targetAccessor,"target");return Rc(Array.from(new Set(r.flatMap(t=>[s(t),a(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[];ql(c,{props:t,categories:u,theme:o,size:n,hasTitle:l});const d=Xl({props:t,categories:u,theme:o,size:n,margin:c,hasTitle:l}),h=n[0]-c.left-c.right,f=n[1]-c.top-c.bottom,p=Vl(t.backgroundGraphics,n,c,null),y=Vl(t.foregroundGraphics,n,c,null),g=()=>{let i;const r=t=>Number(t),s=t.annotations?wl({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{x:r,y:r},layout:{width:h,height:f},theme:o,frameType:"network",idPrefix:t._idPrefix,onRender:t=>{i=t}}):null;return e&&(e.evidence=(e=>dc({frameType:"network",width:n[0],height:n[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:e,nodeCount:0,edgeCount:0,margin:c}))(i)),pv.renderToStaticMarkup(Gl(p||y||t.annotations?(0,Ev.jsxs)(Ev.Fragment,{children:[p,s,y]}):null,{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${c.left},${c.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:t._idPrefix}))},m=function(t){return yv[t]}(i);if(!m&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);const x={chartType:i,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,labelMode:t.labelMode,colorBy:t.colorBy,colorScheme:t.colorScheme||o.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,orbitMode:t.orbitMode,orbitSize:t.orbitSize,orbitSpeed:t.orbitSpeed,orbitRevolution:t.orbitRevolution,orbitRevolutionStyle:t.orbitRevolutionStyle,orbitEccentricity:t.orbitEccentricity,orbitShowRings:t.orbitShowRings,orbitAnimated:!1,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let b,v;if(Bv.has(i)){const e=t.data||t.edges;if(!e||Array.isArray(e))return g();x.__hierarchyRoot=e,b=[],v=[]}else{const e=xt(t.nodes||[]),o=Array.isArray(t.edges)?xt(t.edges):[];if(0===e.length&&0===o.length)return g();if(v=function(t,e){const o=Td(e.sourceAccessor,"source"),i=Td(e.targetAccessor,"target"),n=Td(e.valueAccessor,"value");return t.map((t,e)=>{const r=Number(n(t)),s=o(t)+"",a=i(t)+"";return{source:s,target:a,value:Number.isFinite(r)?r:1,y0:0,y1:0,sankeyWidth:0,data:t,_edgeKey:`${s}\0${a}\0${e}`}})}(o,x),0===e.length&&v.length>0){const t=new Set;for(const e of v){const o=zl(e.source),i=zl(e.target);o&&t.add(o),i&&t.add(i)}b=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 b=function(t,e){const o=Td(e.nodeIDAccessor,"id");return t.map(t=>({id:o(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}))}(e,x)}let w=[],k=[],A=[],S=null,M=null;if(x.customNetworkLayout){const t=x.colorScheme,e=Gn(t,o.colors.categorical,Df),i=Vn(e,t),n={nodes:b,edges:v,dimensions:{width:h,height:f,plot:{x:0,y:0,width:h,height:f}},theme:{semantic:o.colors,categorical:[...e]},resolveColor:i,config:x.layoutConfig??{}},r=x.customNetworkLayout(n);w=r.sceneNodes??[],k=r.sceneEdges??[],A=r.labels??[],S=r.backgrounds??null,M=r.overlays??null}else if(m){m.computeLayout(b,v,x,[h,f]);const t=m.buildScene(b,v,x,[h,f]);w=t.sceneNodes,k=t.sceneEdges,A=t.labels}const _=Qt(o);for(const t of A)t.fill||(t.fill=_.text);const $=Ac({nodes:k,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){return bc(function(t,e){switch(t.type){case"line":return(0,zv.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 o=t,i=`net-bezier-${e}-hatch`,n=ri(o.style.fill)?ai(o.style.fill,i):void 0;return(0,zv.jsxs)(Dv.Fragment,{children:[n&&(0,zv.jsx)("defs",{children:n}),(0,zv.jsx)("path",{d:o.pathD,fill:n?`url(#${i})`:hc(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-edge-"+e)}case"ribbon":{const o=t,i=`net-ribbon-${e}-hatch`,n=ri(o.style.fill)?ai(o.style.fill,i):void 0;return(0,zv.jsxs)(Dv.Fragment,{children:[n&&(0,zv.jsx)("defs",{children:n}),(0,zv.jsx)("path",{d:o.pathD,fill:n?`url(#${i})`:hc(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-edge-"+e)}case"curved":{const o=t;return(0,zv.jsx)("path",{d:o.pathD,fill:hc(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth??1,opacity:o.style.opacity},"net-edge-"+e)}default:return null}}(t,e),t,"network-edge-cursor-"+e)}(t,e)}),P=Ac({nodes:w,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){return bc(function(t,e){switch(t.type){case"circle":{const o=t,i=ri(o.style.fill)?ai(o.style.fill,`net-circle-${e}-hatch`):void 0;return(0,zv.jsxs)(Dv.Fragment,{children:[i&&(0,zv.jsx)("defs",{children:i}),(0,zv.jsx)("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:i?`url(#net-circle-${e}-hatch)`:hc(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity})]},"net-circle-"+e)}case"rect":{const o=t,i=ri(o.style.fill)?ai(o.style.fill,`net-rect-${e}-hatch`):void 0;return(0,zv.jsxs)(Dv.Fragment,{children:[i&&(0,zv.jsx)("defs",{children:i}),(0,zv.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#net-rect-${e}-hatch)`:hc(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity})]},"net-rect-"+e)}case"arc":{const o=t,i=(0,Nv.arc)().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(wx)||"",n=ri(o.style.fill)?ai(o.style.fill,`net-arc-${e}-hatch`):void 0;return(0,zv.jsxs)(Dv.Fragment,{children:[n&&(0,zv.jsx)("defs",{children:n}),(0,zv.jsx)("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:n?`url(#net-arc-${e}-hatch)`:hc(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity})]},"net-arc-"+e)}case"symbol":{const o=t,i=Da(o.symbolType,o.size,o.path);return(0,zv.jsx)("path",{d:i,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?hc(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,fillOpacity:o.style.fillOpacity,strokeOpacity:o.style.strokeOpacity,opacity:o.style.opacity},"net-symbol-"+e)}case"glyph":return pc(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e),t,"network-node-cursor-"+e)}(t,e)}),j=$.map(t=>t.element),I=P.map(t=>t.element),L=A.map((t,e)=>function(t,e){return(0,zv.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);let R;const T=t=>Number(t),C=t.annotations?wl({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{x:T,y:T},layout:{width:h,height:f},theme:o,frameType:"network",annotationData:Cd(w),pointNodes:Rd(w),idPrefix:t._idPrefix,onRender:t=>{R=t}}):null;return e&&(e.evidence=dc({frameType:"network",width:n[0],height:n[1],marks:[...P.map(({node:t})=>({type:"node:"+(t.type??"node")})),...$.map(({node:t})=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,annotationRender:R,nodeCount:P.length,edgeCount:$.length,margin:c})),pv.renderToStaticMarkup(Gl((0,Ev.jsxs)(Ev.Fragment,{children:[p,S,j,I,L,C,y,M]}),{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${c.left},${c.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:t._idPrefix}))}function Fd(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Dd(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Nd(t,e,o){return t?"function"==typeof t?{...o,...t(e)}:{...o,...t}:{...o}}function zd(t,e){if(2>t.length)return[t];const o=.4*e,i=[];let n=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>o?(2>n.length||i.push(n),n=[r]):n.push(r)}return 2>n.length||i.push(n),i}function Ed(t,e,o=24){const i=e[0]-t[0],n=e[1]-t[1],r=Math.sqrt(i*i+n*n);if(0===r)return[t,e];const s=-n/r,a=i/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,d=[];for(let i=0;o>=i;i++){const n=i/o,r=1-n;d.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 d}function Bd(t,e){if(2>t.length)return t;const o=e/2+1,i=[];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;i.push([n[0]+s/a*o,n[1]+-r/a*o])}return i}function Wd(t,e,o,i,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]]}function Yd(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+""}.`)}function qd(t){if(!t)return;const e=[];for(const o of t)if("point"===o.type)e.push(o);else if("glyph"===o.type){const t=o,i=Xa(t.glyph,t.size);e.push({pointId:t.pointId,x:t.x+i.centerDx,y:t.y+i.centerDy,r:i.radius})}return e}function Xd({bottomMargin:t,costLabel:e,layout:{cx:o,cy:i,maxCost:n,availableRadius:r,layout:s},ringStyle:a,ringValues:c,showNorth:l,showRingLabels:u,showRings:d}){const h="strip"===s,f={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...a};return(0,dw.jsxs)("g",h?{children:[(0,dw.jsx)("line",{x1:o,y1:i,x2:o+r,y2:i,stroke:f.stroke,strokeWidth:f.strokeWidth,strokeLinecap:"round",opacity:.85}),(0,dw.jsx)("line",{x1:o,y1:i-3.5,x2:o,y2:i+3.5,stroke:f.stroke,strokeWidth:f.strokeWidth,opacity:.9}),d&&c.map(s=>{const a=o+(n>0?s/n*r:0);return(0,dw.jsxs)("g",{children:[(0,dw.jsx)("line",{x1:a,y1:i-2.5,x2:a,y2:i+2.5,stroke:f.stroke,strokeWidth:.9,opacity:.65}),u&&(0,dw.jsxs)("text",{x:a,y:i+Math.min(10,(t??2)+8),textAnchor:"middle",fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[s,e?" "+e:""]})]},s)})]}:{children:[c.map(t=>{const s=t/n*r;return(0,dw.jsxs)("g",{children:[(0,dw.jsx)("circle",{cx:o,cy:i,r:s,fill:"none",stroke:f.stroke,strokeWidth:f.strokeWidth,strokeDasharray:f.strokeDasharray,opacity:.5}),u&&(0,dw.jsxs)("text",{x:o+s+3,y:i-2,fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[t,e?" "+e:""]})]},t)}),l&&(0,dw.jsxs)("g",{transform:"translate(24, 24)",children:[(0,dw.jsx)("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),(0,dw.jsx)("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),(0,dw.jsx)("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),(0,dw.jsx)("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),(0,dw.jsx)("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),(0,dw.jsx)("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function Gd(t,e){const o=Zt(t.theme),i=t.size||[t.width||600,t.height||400],n=a({top:10,right:10,bottom:10,left:10,...t.margin},t.title),s=r(t.title),c=Array.isArray(t.areas)?xt(t.areas):t.areas,l=xt(t.points),u=xt(t.lines),d=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;return Rc(l.length>0?l:Array.isArray(c)&&c.length>0?"string"==typeof e?c.map(t=>({...t.properties||{},...t})):c:[],e)})():[];ql(n,{props:t,categories:d,theme:o,size:i,hasTitle:s});const h=Xl({props:t,categories:d,theme:o,size:i,margin:n,hasTitle:s}),f=i[0]-(n.left??0)-(n.right??0),p=i[1]-(n.top??0)-(n.bottom??0),y={projection:t.projection||"equalEarth",projectionExtent:t.projectionExtent,xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineIdAccessor:t.lineIdAccessor,lineType:t.lineType,flowStyle:t.flowStyle,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,colorScheme:t.colorScheme,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,onLayoutError:t.onLayoutError,themeCategorical:o.colors.categorical,themeSemantic:Kt(o),themeSequential:o.colors.sequential,themeDiverging:o.colors.diverging},g=new cw(y);if(c){if("string"==typeof c)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${c}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${c}')\` before calling renderGeoToStaticSVG.`);g.setAreas(c)}t.points&&g.setPoints(l),t.lines&&g.setLines(u),g.computeScene({width:f,height:p});const m=Vl(t.backgroundGraphics,i,n,g.scales),x=Vl(t.foregroundGraphics,i,n,g.scales),b=Ac({nodes:g.scene,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){return bc(function(t,e){switch(t.type){case"geoarea":{const o=t;if(!o.pathData)return null;const i=ri(o.style.fill)?ai(o.style.fill,`geoarea-${e}-hatch`):void 0;return(0,uw.jsxs)(lw.Fragment,{children:[i&&(0,uw.jsx)("defs",{children:i}),(0,uw.jsx)("path",{d:o.pathData,fill:i?`url(#geoarea-${e}-hatch)`:hc(o.style.fill,"#e0e0e0"),fillOpacity:o.style.fillOpacity??1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth??.5,strokeDasharray:o.style.strokeDasharray,opacity:o._decayOpacity??1})]},"geoarea-"+e)}case"point":{const o=t,i=ri(o.style.fill)?ai(o.style.fill,`geopoint-${e}-hatch`):void 0;return(0,uw.jsxs)(lw.Fragment,{children:[i&&(0,uw.jsx)("defs",{children:i}),(0,uw.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#geopoint-${e}-hatch)`:hc(o.style.fill),fillOpacity:o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o._decayOpacity??o.style.opacity??1})]},"point-"+e)}case"line":{const o=t;if(2>o.path.length)return null;const i="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return(0,uw.jsx)("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth??1.5,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity??1},"line-"+e)}case"glyph":return pc(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(t,e),t,"geo-cursor-"+e)}(t,e)});if(0===b.length){let r;const s=t.annotations?wl({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([t,e])=>g.scales.projectedPoint(t,e):void 0},layout:{width:f,height:p},theme:o,pointNodes:qd(g.scene),idPrefix:t._idPrefix,onRender:t=>{r=t}}):null;return e&&(e.evidence=dc({frameType:"geo",width:i[0],height:i[1],marks:b.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:r,legendItems:d.length>0?d.length:null!=t.legend?1:void 0,margin:n})),Wv.renderToStaticMarkup(Gl(m||x||t.annotations||g.customLayoutOverlays?(0,hw.jsxs)(hw.Fragment,{children:[m,s,x,g.customLayoutOverlays]}):null,{width:i[0],height:i[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:t._idPrefix}))}const v=b.map(t=>t.element),w=t.cartogramChrome,k=g.cartogramLayout&&w?(0,hw.jsx)(Xd,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:Vd(g.cartogramLayout.maxCost,w.showRings),showRings:w.showRings??!0,showNorth:w.showNorth??!0,showRingLabels:w.showRingLabels??!0,costLabel:"string"==typeof w.costLabel?w.costLabel:void 0}):null;let A;const S=t.annotations?wl({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([t,e])=>g.scales.projectedPoint(t,e):void 0},layout:{width:f,height:p},theme:o,pointNodes:qd(g.scene),idPrefix:t._idPrefix,onRender:t=>{A=t}}):null;return e&&(e.evidence=dc({frameType:"geo",width:i[0],height:i[1],marks:b.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:A,legendItems:d.length>0?d.length:null!=t.legend?1:void 0,margin:n})),Wv.renderToStaticMarkup(Gl((0,hw.jsxs)(hw.Fragment,{children:[m,v,S,k,x,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:o,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:t._idPrefix}))}function Vd(t,e){if(!1===e||0>=t)return[];if(Array.isArray(e))return e.filter(e=>e>0&&t>=e);const o="number"==typeof e?e:Math.min(5,Math.max(2,Math.ceil(t/5))),i=t/o,n=[];for(let t=1;o>=t;t++)n.push(Math.round(i*t*10)/10);return n}function Hd(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}:{}}))}function Ud(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 Kd(t,e,o){const i="function"==typeof e?e(t,o):e;return{...pw,...i??{}}}function Zd(t,e={},o="settled"){return t.map((t,i)=>function(t,e={},o={index:0,simulationState:"settled"}){const i=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),n={label:e.getBodyLabel?.(t)??Ud(t)},r={style:Kd(t,e.bodyStyle,o),datum:i,accessibleDatum:i,accessibility:n,_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,...r}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...r}}(t,e,{index:i,simulationState:o}))}function Qd(t,e,o){return"function"==typeof t?t({size:e,margin:o}):t}function Jd(t,e={}){const{element:o,scene:i,evidence:n}=function(t,e={}){const{width:o=640,height:i=360,title:n,description:r,background:s,backgroundGraphics:a,backgroundGraphicsBackdrop:c,className:l,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:y,...g}=e,m=function(t,e={}){const o=t.settle(e.maxSteps),i=t.readBodies(),n=t.snapshot(),r=Zd(i,e,n.simulationState),s=function(t,e={}){const o=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),i=o.filter(t=>t.sleeping).length,n=t.queue.length,r=t.sediment.reduce((t,e)=>t+e.count,0),s="settled"===t.simulationState&&0===n&&i===o.length,a=[];s||a.push("PHYSICS_NOT_SETTLED"),n>0&&a.push("PHYSICS_QUEUE_UNDRAINED");const c=null!=e.charge&&Number.isFinite(e.charge)?function(t,e,o,i){const n=t-(e+o+i);return{charge:t,live:e,queued:o,sedimented:i,unaccounted:n,balanced:0===n}}(e.charge,o.length,n,r):void 0;return c&&!c.balanced&&a.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:o.length,sleepingCount:i,settled:s,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:Hd(e.projectionRows),queuedCount:n,sedimentedCount:r,...c?{ledger:c}:{},warnings:a}}(n,{bodies:i,projectionRows:e.projectionRows,stepsRun:o,charge:e.charge});return{snapshot:n,bodies:i,sceneNodes:r,evidence:s,stepsRun:o}}(t,g),x={...gw,...h},b=[o,i],v=Qd(a,b,x),w=Qd(u,b,x),k=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(d),A=n?k+"-title":void 0,S=r?k+"-desc":void 0,M=[A,S].filter(Boolean).join(" ")||void 0,_=x.left||x.top?`translate(${x.left},${x.top})`:void 0,$=Math.max(1,o-x.left-x.right),P=Math.max(1,i-x.top-x.bottom),j=k+"-plot-clip",I=_&&null!=v?(0,yw.jsx)("g",{transform:_,children:v}):v;return{element:(0,yw.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:l??"stream-physics-frame",width:o,height:i,viewBox:`0 0 ${o} ${i}`,role:"img","aria-labelledby":M,style:f,children:[n&&(0,yw.jsx)("title",{id:A,children:n}),r&&(0,yw.jsx)("desc",{id:S,children:r}),(0,yw.jsx)("defs",{children:(0,yw.jsx)("clipPath",{id:j,children:(0,yw.jsx)("rect",{width:$,height:P})})}),c&&"transparent"!==c?(0,yw.jsx)("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:o,height:i,fill:c}):null,!a&&s&&"transparent"!==s?(0,yw.jsx)("rect",{x:0,y:0,width:o,height:i,fill:s}):null,I,(0,yw.jsx)("g",{id:k+"-data-area",transform:_,clipPath:`url(#${j})`,children:m.sceneNodes.map((t,e)=>{const o=m.bodies[e],i=o&&p?p(o,t.style??{},e,k):void 0;return null!=i?bc(i,t,e):bc("point"===t.type||"rect"===t.type?mc(t,e,k):null,t,"xy-cursor-"+e)})}),w,y?.(m)]}),scene:m,evidence:m.evidence}}(t,e);return{svg:fw.renderToStaticMarkup(o),scene:i,evidence:n}}function th(t){return"number"==typeof t&&Number.isFinite(t)?t:void 0}function eh(t,e){const o="sensor"===t.physics?e.sensorThickness:e.barrierThickness;return Math.max(0,th(t.thickness)??th(o)??th(e.thickness)??4)}function oh(t){return t.sensorId??"stream-region-"+t.id}function ih(t){const e=oh(t),o={bodyFilter:t.bodyFilter,friction:t.friction,restitution:t.restitution};if("boundary"===t.collider&&"aabb"===t.shape.type){const i=t.colliderThickness??8,n=t.shape.x-t.shape.width/2,r=t.shape.x+t.shape.width/2,s=t.shape.y-t.shape.height/2,a=t.shape.y+t.shape.height/2;return[{...o,id:e+"-top",shape:{type:"segment",x1:n,y1:s,x2:r,y2:s,thickness:i}},{...o,id:e+"-right",shape:{type:"segment",x1:r,y1:s,x2:r,y2:a,thickness:i}},{...o,id:e+"-bottom",shape:{type:"segment",x1:r,y1:a,x2:n,y2:a,thickness:i}},{...o,id:e+"-left",shape:{type:"segment",x1:n,y1:a,x2:n,y2:s,thickness:i}}]}return t.collider?[{...o,id:e+"-collider",shape:t.shape}]:[]}function nh({title:t,totalWidth:e,marginTop:o}){return t?"string"!=typeof t?(0,mw.jsx)("foreignObject",{x:0,y:0,width:e,height:o,children:t}):(0,mw.jsx)("text",{x:e/2,y:Hh,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:t}):null}function rh(t){return"circle"===t.shape.type?t.shape.radius:Math.max(t.shape.width,t.shape.height)/2}function sh(t,e){const o=t.size??[t.width??600,t.height??400],i=Zt(t.theme),n=void 0===t.theme?{}:xe(i),r=t.bodyStyle,a=!1,l=t.legendPosition??"right",u=s({...vw,...t.margin},a,!!t.legend&&"top"===l);if(t.legend){const e={...u};x(u,{legend:t.legend,position:l,size:o,hasTitle:a,legendLayout:t.legendLayout}),c(u,e,o,l)}let d;const h=function({annotations:t,chartId:e,chartType:o,config:i,onRegionObservation:n,regionEffects:r,seed:s,size:a}){const c=function(t=[],e={}){const o=e.idPrefix?e.idPrefix+"-":"",i=[];for(const n of t){if("barrier"!==n.physics&&"sensor"!==n.physics)continue;const t=n.axis??e.defaultAxis??"x",r=eh(n,e),s=n.colliderId??`${o}${n.id}`;let a;if("x"===t){const t=th(n.x),o=th(n.y1)??th(e.plotBounds?.y)??th(n.y),i=th(n.y2)??(e.plotBounds?e.plotBounds.y+e.plotBounds.height:void 0)??th(n.y);if(null==t||null==o||null==i)continue;a={type:"segment",x1:t,y1:o,x2:t,y2:i,thickness:r}}else{const t=th(n.y),o=th(n.x1)??th(e.plotBounds?.x)??th(n.x),i=th(n.x2)??(e.plotBounds?e.plotBounds.x+e.plotBounds.width:void 0)??th(n.x);if(null==t||null==o||null==i)continue;a={type:"segment",x1:o,y1:t,x2:i,y2:t,thickness:r}}i.push({id:s,shape:a,sensor:"sensor"===n.physics,..."barrier"!==n.physics||null==n.restitution&&null==e.barrierRestitution?{}:{restitution:th(n.restitution)??th(e.barrierRestitution)},..."barrier"!==n.physics||null==n.friction&&null==e.barrierFriction?{}:{friction:th(n.friction)??th(e.barrierFriction)}})}return i}((t??[]).filter(t=>"barrier"===t.physics||"sensor"===t.physics),{idPrefix:e?e+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:a[0],height:a[1]}}),l=void 0===s||void 0!==i?.kernel?.seed?i:{...i,kernel:{...i?.kernel,seed:s}},u=r.flatMap(t=>[{id:oh(t),sensor:!0,shape:t.shape,bodyFilter:t.bodyFilter,friction:t.friction,restitution:t.restitution},...ih(t)]),d=Object.fromEntries(r.map(t=>[oh(t),{binId:t.binId??t.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=l?.observation,f=r.length>0;return f||u.length>0||c.length>0||null!=e||h?{...l,colliders:[...l?.colliders??[],...u,...c],observation:{...h,chartId:e??h?.chartId,chartType:h?.chartType??o,sensors:{...h?.sensors??{},...d},onObservation:t=>{f&&n(t),h?.onObservation?.(t)}}}:l}({annotations:t.annotations,chartId:t.chartId,chartType:"StreamPhysicsFrame",config:t.config,onRegionObservation:()=>{},regionEffects:t.regionEffects??[],seed:t.seed,size:[Math.max(1,o[0]-u.left-u.right),Math.max(1,o[1]-u.top-u.bottom)]}),f=new _g(h);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&f.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const p=Jd(f,{...t,width:o[0],height:o[1],background:t.background??i.colors.background,bodyStyle:(t,e)=>({fill:i.colors.primary,stroke:i.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof r?r(t,e):r}),style:{...n,fontFamily:i.typography.fontFamily,...t.style},charge:t.charge,idPrefix:t.idPrefix??t._idPrefix??"physics",margin:u,renderChrome:e=>{const n=function(t,e,o,i,n){const r=Math.max(1,o[0]-i.left-i.right),s=Math.max(1,o[1]-i.top-i.bottom),a=function(t){return t?.length?t.map(t=>null!=t.pointId||null==t.bodyId?t:{...t,pointId:t.bodyId+""}):t}(e.annotations),c=function(t){const{width:e,height:o,pointNodes:i=[],data:n}=t;return{scales:{x:(0,xw.scaleLinear)().domain([0,Math.max(1,e)]).range([0,Math.max(1,e)]),y:(0,xw.scaleLinear)().domain([0,Math.max(1,o)]).range([0,Math.max(1,o)])},width:e,height:o,frameType:"network",pointNodes:i,data:n,xAccessor:"x",yAccessor:"y"}}({width:r,height:s,pointNodes:(l=t.bodies,l.map(t=>({pointId:t.id,x:t.x,y:t.y,r:Math.max(1,rh(t))})))});var l;const u=c.scales?.x,d=c.scales?.y;if(!u||!d)throw Error("Physics annotation context requires pixel scales");let h;const f=wl({annotations:a,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:u,y:d},layout:{width:r,height:s},theme:n,frameType:"network",xAccessor:c.xAccessor,yAccessor:c.yAccessor,pointNodes:c.pointNodes,svgAnnotationRules:e.svgAnnotationRules,onRender:t=>{h=t}}),p=e.legend?Yl(e.legend,{theme:n,position:e.legendPosition,size:[o[0],o[1]],margin:i,hasTitle:!!e.title,legendLayout:e.legendLayout})??kl(e.legend,o,i,e.legendPosition,e.legendLayout):null;return{annotationRender:h,node:(0,bw.jsxs)("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:o[0],height:o[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,bw.jsx)("g",{transform:`translate(${i.left},${i.top})`,children:f}),(0,bw.jsx)(nh,{title:e.title,totalWidth:o[0],marginTop:Math.max(i.top,28)}),p]})}}(e,t,o,u,i);return d=n.annotationRender,n.node}});return e&&(e.evidence=dc({frameType:"physics",width:o[0],height:o[1],marks:p.scene.sceneNodes,title:t.title,description:t.description,annotations:t.annotations,annotationRender:d,extraWarnings:[...0===p.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...p.scene.evidence.warnings]})),p.svg}function ah(t,e){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:e}function ch(t,e,o){return Sw[t](e,o)}function lh(t,e){switch(t){case"xy":return Hl(e);case"ordinal":return $u(e);case"network":return Od(e);case"geo":return Gd(e);case"physics":return sh(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function uh(t){return Hl(t)}function dh(t){return $u(t)}function hh(t){return Od(t)}function fh(t){return Gd(t)}function ph(t,e){const o=Number(t);if(!Number.isFinite(o))return t;const i=10**e,n=Math.round((o+Number.EPSILON)*i)/i;return Object.is(n,-0)?"0":n+""}function yh(t,e){const o=function(t){if(Number.isFinite(t))return Math.max(0,Math.min(8,Math.floor(t)))}(e);return void 0===o?t:function(t){const e=A(t)?.start??0;return t.slice(0,e)+t.slice(e).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(t,e)=>e?t.replace(hf,(t,e,i,n)=>{const r=((t,e)=>{if(Pw.has(t)&&!/\b(?:var|calc|url)\(/i.test(e))return function(t,e){const o=RegExp(jw.source,jw.flags);let i,n="",r=0,s=!1;for(;i=o.exec(t);){const o=t.slice(r,i.index);n+=s&&0===o.length?" ":o,n+=ph(i[0],e),r=i.index+i[0].length,s=!0}return n+t.slice(r)}(e,o)})(e,M(i??n));return void 0===r?t:` ${e}="${S(r)}"`}):t)}(t)}function gh(t,e){const o={};for(const i of e)void 0!==t[i]&&(o[i]=t[i]);return o}function mh(t,e,o){return bh(t,e,o).svg}function xh(t,e,o){const i={},{svg:n,frameType:r}=bh(t,e,o,i),s=i.evidence??dc({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"]});if(s.component=t,s.sceneHashVersion=2,s.sceneHash=function(t,e){return L(I({kind:"semiotic.rendered-svg-scene",version:2,svg:t,frameType:e.frameType,width:e.width,height:e.height,margin:e.margin,plot:e.plot,xDomain:e.xDomain,yDomain:e.yDomain,categories:e.categories}))}(n,s),gt(s,t,e),o?.artifactContract){const i=function(t,e={}){try{return function(t,e){if(!lt(t))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const o=N(t),i=[...new Set([...o.excludedPaths,...X(t)])].sort(),n=o.value,r=function(t,e){if(!e||!lt(t)||!Array.isArray(t.evidence))return[];const o=[];return t.evidence.forEach((t,e)=>{lt(t)&&Object.prototype.hasOwnProperty.call(t,"sample")&&(delete t.sample,o.push(`$.evidence[${e}].sample`))}),o}(n,e.excludeEvidenceSamples),s=r.length?["Bounded evidence samples were excluded by the transfer policy."]:[],a=n?.contractVersion;if("string"!=typeof a||!a)return{contract:n,transfer:{status:"invalid",omittedPaths:[...i,...r],warnings:["Artifact contract is missing a string contractVersion.",...s]}};if(a!==mf)return{contract:n,transfer:{status:i.length>0?"invalid":"unsupported-version",omittedPaths:[...i,...r],warnings:[`Contract version ${a} is not interpreted by this runtime.`,...i.length>0?[`Non-JSON values could not be preserved at: ${i.join(", ")}.`]:[],...s]}};const c=ct(n),l=[...c.errors.map(({path:t,message:e})=>`${t}: ${e}`),...c.warnings.map(({path:t,message:e})=>`${t}: ${e}`),...i.length?[`Non-JSON values could not be preserved at: ${i.join(", ")}.`]:[],...s];return{contract:n,transfer:{status:!c.valid||i.length>0?"invalid":r.length>0?"excluded":"preserved",omittedPaths:[...i,...r],warnings:l}}}(t,e)}catch{const e=X(t);return{transfer:{status:"invalid",omittedPaths:e.length?e:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}(o.artifactContract,{excludeEvidenceSamples:!0});i.contract&&(s.artifactContract=i.contract),s.artifactTransfer=i.transfer,s.artifactBinding=i.contract?.contractVersion===mf&&"invalid"!==i.transfer.status?function(t,e,o,i=function(t){const e=Object.entries(t).filter(([t,e])=>Sf.includes(t)&&void 0!==e);if(0!==e.length)return 1===e.length&&"data"===e[0][0]?e[0][1]:Object.fromEntries(e)}(e)){const n=function(t){return Object.fromEntries(Object.entries(t).filter(([t])=>!Sf.includes(t)&&"recipeId"!==t))}(e),r=0===X(n).length?z(n).fingerprint:void 0,s=void 0!==i&&0===X(i).length?function(t,e=[]){if(void 0===t)return;const o=e.filter(t=>!!t.transformation).map(({id:t,transformation:e})=>({evidenceId:t,transformation:e})).sort(({evidenceId:t},{evidenceId:e})=>e>t?-1:t>e?1:0);return z(o.length>0?{data:t,transformations:o}:t).fingerprint}(i,t.evidence):void 0,a="ChartRecipe"===o&&"string"==typeof e.recipeId?e.recipeId:o,c=[],l=[];return void 0!==a&&(void 0===t.artifact.component?l.push("artifact.component"):t.artifact.component!==a&&c.push("artifact.component")),void 0===t.artifact.configFingerprint||void 0===r?l.push("artifact.configFingerprint"):t.artifact.configFingerprint!==r&&c.push("artifact.configFingerprint"),void 0!==t.artifact.dataFingerprint&&s?t.artifact.dataFingerprint!==s&&c.push("artifact.dataFingerprint"):l.push("artifact.dataFingerprint"),{status:c.length>0?"mismatch":l.length>0?"unknown":"match",mismatchPaths:c,unknownPaths:l}}(i.contract,e,t):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:n,evidence:s}}function bh(t,e,o,i){if(Object.prototype.hasOwnProperty.call(Sw,t))return{svg:yh(ch(t,e,i),o?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(Fb,t))throw Error(`Unknown chart component: "${t}". Run \`npx semiotic-ai --list\` for supported chart types.`);const n=Fb[t];var r;const s=function(t,e,o){const i=Pf[t||"primary"],n=t&&"primary"!==t||!o?.width?i.width:o.width,r=t&&"primary"!==t||!o?.height?i.height:o.height,s=function(t,e,o=t.responsiveRules){if(!Array.isArray(o)||0===o.length)return{props:t,matches:[]};const i=o.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:o}=t,i=e.width,n=e.height,r=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),s=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof o.minWidth&&o.minWidth>i||"number"==typeof o.maxWidth&&i>o.maxWidth||"number"==typeof o.minHeight&&("number"!=typeof n||o.minHeight>n)||"number"==typeof o.maxHeight&&("number"!=typeof n||n>o.maxHeight)||"number"==typeof o.minAspectRatio&&("number"!=typeof r||o.minAspectRatio>r)||"number"==typeof o.maxAspectRatio&&("number"!=typeof r||r>o.maxAspectRatio)||o.orientation&&s!==o.orientation)}(t.rule,e)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:i.reduce((t,e)=>function(t,e){const o={...t,...e};for(const i of["margin","frameProps","mobileSemantics","style"])ut(t[i])&&ut(e[i])&&(o[i]={...t[i],...e[i]});return"string"==typeof t.className&&"string"==typeof e.className&&(o.className=`${t.className} ${e.className}`),o}(t,e.rule.transform),t),matches:i}}({...e,mode:t},{width:e.width??n,height:e.height??r}).props,a=s.mode||t||"primary",c=Pf[a],l="context"===a||"sparkline"===a,u="primary"===a&&o?.width?o.width:c.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&o?.height?o.height:c.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:ht(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:dt(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(n.layout?.mode??("string"==typeof(r=e.mode)&&Object.prototype.hasOwnProperty.call(Pf,r)?e.mode:void 0),{...n.layout?.modeDefaults,...gh(e,Lw)},n.layout?.primarySize),{data:a,theme:c,background:l,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:y,...g}=e,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=n.layout?.margin,A="function"==typeof w?w(e,s):w??s.marginDefaults,S="xy"===n.frameType?k(A,g.axes??v.axes,!!s.title):A,M=void 0!==h?h:v.margin,_=function(t){if(null==t)return;if("number"==typeof t)return{top:t,right:t,bottom:t,left:t};const e={};return"number"==typeof t.top&&(e.top=t.top),"number"==typeof t.right&&(e.right=t.right),"number"==typeof t.bottom&&(e.bottom=t.bottom),"number"==typeof t.left&&(e.left=t.left),e}(M),$="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,..._},P=gh(g,Iw),j=t=>v[t]??s[t],I={...v,...P,theme:c,title:s.title,description:s.description,showAxes:j("showAxes"),showLegend:j("showLegend"),showLabels:j("showLabels"),showGrid:j("showGrid"),xLabel:j("xLabel"),yLabel:j("yLabel"),categoryLabel:j("categoryLabel"),valueLabel:j("valueLabel"),background:l,className:u,annotations:d,size:b,margin:$,__compactMode:s.compactMode,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=n.buildProps(a,p,f,I,g);let R;if(n.renderStatic)R=n.renderStatic(L,i);else switch(n.frameType){case"xy":R=Hl(L,i);break;case"ordinal":R=$u(L,i);break;case"network":R=Od(L,i);break;case"geo":R=Gd(L,i);break;case"physics":R=sh(L,i)}const T=n.renderOverlay?.(L,{theme:Zt(c)});if(null!=T){const t=Tf.renderToStaticMarkup((0,$w.jsx)($w.Fragment,{children:T})),e=R.lastIndexOf("</svg>");R=0>e?`${R}${t}`:`${R.slice(0,e)}${t}${R.slice(e)}`}return{svg:yh(R,o?.precision),frameType:n.frameType}}async function vh(t,e,o={}){const{format:i="png",scale:n=1,background:r}=o;let s,a;if(s=["xy","ordinal","network","geo","physics"].includes(t)?lh(t,e):mh(t,e),r){const t=A(s),e=t?_(t,"style"):void 0;s=$(s,{style:`${e?e+";":""}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={width:e.width||e.size?.[0]||600,height:e.height||e.size?.[1]||400},{width:l,height:u}=P(s,c),d=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*n}).resize(Math.round(l*n),Math.round(u*n));return"jpeg"===i?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()}function wh(t,e={}){return function(t,e,o){const{title:i,subtitle:n,theme:r,width:s=1200,height:a,layout:c={},background:l}=e,u=Qt(Zt(r)),d=c.columns||2,h=c.gap??16;let f=0;i&&(f+=30),n&&(f+=20),f>0&&(f+=10);const p=Math.floor((s-h-h*(d-1))/d),y=[];let g=0,m=f+h,x=0;for(const e of t){const t=Math.min(e.colSpan||1,d),i=p*t+h*(t-1),n=e.props.height||300;g+t>d&&(m+=x+h,g=0,x=0);const s=h/2+g*(p+h),a={...e.props,width:i,height:n,theme:r,_idPrefix:"chart-"+y.length},c=e.component?o.chart(e.component,a):e.frameType?o.frame(e.frameType,a):`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${n}"></svg>`,l=P(c,{width:i,height:n}),u=Math.max(n,l.height);y.push({x:s,y:m,width:i,height:u,svg:c,svgDimensions:l}),x=Math.max(x,u),g+=t}const b=a||m+x+h,v=y.map((t,e)=>(0,_w.jsx)("g",{transform:`translate(${t.x},${t.y})`,children:(0,_w.jsx)("foreignObject",{width:t.width,height:t.height,children:(0,_w.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:j(t.svg,t.svgDimensions)}})})},"dashboard-chart-"+e));return Mw.renderToStaticMarkup((0,_w.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":i||"Dashboard",style:{fontFamily:u.fontFamily},children:[i&&(0,_w.jsx)("title",{children:i}),l&&(0,_w.jsx)("rect",{x:0,y:0,width:s,height:b,fill:l}),i&&(0,_w.jsx)("text",{x:s/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:i}),n&&(0,_w.jsx)("text",{x:s/2,y:i?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:n}),v]}))}(t,e,{chart:mh,frame:lh})}function kh(t,e,o,i={}){const{stepSize:n,windowSize:r,frameCount:s,xExtent:c,yExtent:l,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:f}=i,p=o.width||600,y=o.height||400,g=Zt(o.theme),m={...o,...c&&{xExtent:c},...l&&{yExtent:l}};if(!e||0===e.length)return[];const x=n||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),b=[];for(let t=x;e.length>=t;t+=x)b.push(t);b[b.length-1]!==e.length&&b.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),w=a({top:20,right:20,bottom:30,left:40,...o.margin},o.title),k=p-w.left-w.right,A=y-w.top-w.bottom,S=[];if(v)for(let i=0;b.length>i;i++){const n=b[i],s=e.slice(r?Math.max(0,n-r):0,n),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:o.projection||"vertical",oAccessor:o.oAccessor||o.categoryAccessor||"category",rAccessor:o.rAccessor||o.valueAccessor||"value",colorAccessor:o.colorAccessor||o.colorBy,stackBy:o.stackBy,groupBy:o.groupBy,connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,barPadding:o.barPadding,innerRadius:o.innerRadius,normalize:o.normalize,bins:o.bins,colorScheme:o.colorScheme||g.colors.categorical,...f&&{decay:f}},c=new rv(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&S.push(Ih(c.scene,p,y,g,m,S.length))}else for(let i=0;b.length>i;i++){const n=b[i],s=e.slice(r?Math.max(0,n-r):0,n),a={chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:o.colorAccessor||o.colorBy,groupAccessor:o.groupAccessor||o.lineBy,lineDataAccessor:o.lineDataAccessor,xExtent:c,yExtent:l,colorScheme:o.colorScheme||g.colors.categorical,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,sizeAccessor:o.sizeAccessor||o.sizeBy,sizeRange:o.sizeRange,...f&&{decay:f},...u>0&&{transition:{duration:u*(1e3/d),easing:h}}},x=new Dm(a);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;const v=x.scales?{y:x.scales.y}:void 0;if(S.push(jh(x.scene,p,y,g,m,v,S.length)),u>0&&i>0&&x.activeTransition){const t=u*(1e3/d);for(let e=1;u>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/u*t),S.push(jh(x.scene,p,y,g,m,v,S.length))}}return S}function Ah(t,e,o={}){return e.map(e=>{try{return mh(t,{...o,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${o.width||e.width||600}" height="${o.height||e.height||400}"></svg>`}})}function Sh(t,e,o,i){const n=Al(`${t}-${e}`),r="string"==typeof o&&o.length>0?o:void 0,s="string"==typeof i&&i.length>0?i:void 0,a=r?n.titleId:void 0,c=s?n.descId:void 0;return{titleText:r,descText:s,titleId:a,descId:c,labelledBy:[a,c].filter(Boolean).join(" ")||void 0}}function Mh(t,e){return"string"==typeof t.idPrefix&&t.idPrefix.length>0?t.idPrefix:El(t)||e}function _h(t,e,o){const i=e.size??[e.width??600,e.height??400],n=Zt(e.theme),r=Qt(n),s=e.background||n.colors.background,a=e.idPrefix??"physics-gif",c=Sh(a,o,e.title,e.description),{titleId:l,descId:u,labelledBy:d}=c,h=Zd(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),f=(0,Tw.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:r.fontFamily},children:[e.title&&(0,Tw.jsx)("title",{id:l,children:e.title}),e.description&&(0,Tw.jsx)("desc",{id:u,children:e.description}),s&&"transparent"!==s?(0,Tw.jsx)("rect",{x:0,y:0,width:i[0],height:i[1],fill:s}):null,(0,Tw.jsx)("g",{id:`${a}-frame-${o}`,children:h.map((t,e)=>wc(t,e,`${a}-${o}`))})]});return Rw.renderToStaticMarkup(f)}function $h(t,e={}){const{fps:o=12,frameCount:i,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,o)/l)),d=i??Math.max(1,Math.ceil(n*Math.max(1,o))),h=c?{...t,background:c}:t,f=new _g(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push(_h(f,h,0)));d>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(_h(f,h,p.length))}return p}function Ph(t,e){const o=t.background||e.colors.background;return o&&"transparent"!==o?o:null}function jh(t,e,o,i,n,r,s=0){const c=Qt(i),l=a({top:20,right:20,bottom:30,left:40,...n.margin},n.title),u=e-l.left-l.right,d=o-l.top-l.bottom,h=Ph(n,i),f=n.renderMode,p=t.map((t,e)=>kc({node:t,index:e,renderMode:f,fallback:()=>wc(t,e)}).element).filter(Boolean),y=function(t,e,o,i,n,r){if(!t||0===t.length)return null;const s=Qt(i),a=[];for(let i=0;t.length>i;i++){const c=t[i];if("y-threshold"===c.type&&null!=c.value){let t=null;if(r)t=r(c.value);else if(n){const[e,i]=n,r=i-e;if(0===r)continue;t=o-(c.value-e)/r*o}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,Tw.jsxs)("g",{children:[(0,Tw.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,Tw.jsx)("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(o-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-"+i))}}return a.length>0?(0,Tw.jsx)(Tw.Fragment,{children:a}):null}(n.annotations,u,d,i,n.yExtent,r?.y),{titleText:g,descText:m,titleId:x,descId:b,labelledBy:v}=Sh(Mh(n,"xy-gif"),s,n.title,n.description);return Rw.renderToStaticMarkup((0,Tw.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:o,role:"img","aria-labelledby":v,style:{fontFamily:c.fontFamily},children:[g&&(0,Tw.jsx)("title",{id:x,children:g}),m&&(0,Tw.jsx)("desc",{id:b,children:m}),h&&(0,Tw.jsx)("rect",{x:0,y:0,width:e,height:o,fill:h}),(0,Tw.jsxs)("g",{transform:`translate(${l.left},${l.top})`,children:[y,p]}),g&&(0,Tw.jsx)("text",{x:e/2,y:Hh,textAnchor:"middle",fontSize:c.titleFontSize,fontWeight:c.titleFontWeight,fill:c.text,fontFamily:c.titleFontFamily,children:g})]}))}function Ih(t,e,o,i,n,r=0){const s=Qt(i),c=a({top:20,right:20,bottom:30,left:40,...n.margin},n.title),l="radial"===n.projection,u=l?c.left+(e-c.left-c.right)/2:c.left,d=l?c.top+(o-c.top-c.bottom)/2:c.top,h=Ph(n,i),f=_u({nodes:t,renderMode:n.renderMode,idPrefix:n.idPrefix}).map(t=>t.element),{titleText:p,descText:y,titleId:g,descId:m,labelledBy:x}=Sh(Mh(n,"ordinal-gif"),r,n.title,n.description);return Rw.renderToStaticMarkup((0,Tw.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:o,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,Tw.jsx)("title",{id:g,children:p}),y&&(0,Tw.jsx)("desc",{id:m,children:y}),h&&(0,Tw.jsx)("rect",{x:0,y:0,width:e,height:o,fill:h}),(0,Tw.jsx)("g",{transform:`translate(${u},${d})`,children:f}),p&&(0,Tw.jsx)("text",{x:e/2,y:Hh,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:p})]}))}async function Lh(t,e,o,i={}){const{fps:n=12,loop:r=!0,scale:s=1,background:a}=i,c=o.width||600,l=o.height||400,u=kh(t,e,a?{...o,background:a}:o,i);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Th(u,c,l,{fps:n,loop:r,scale:s})}async function Rh(t,e={}){const{fps:o=12,loop:i=!0,scale:n=1}=e,r=t.size??[t.width??600,t.height??400],s=$h(t,e);if(0===s.length)throw Error("No physics frames generated");return Th(s,r[0],r[1],{fps:o,loop:i,scale:n})}async function Th(t,e,o,i={}){const{fps:n=12,loop:r=!0,scale:s=1}=i,a=Math.round(e*s),c=Math.round(o*s);let l,u,d,h;try{const t="sharp",e=await(import(t));l=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await(import(t)),o=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!o)throw Error("gifenc did not expose its encoder functions");u=o.GIFEncoder,d=o.quantize,h=o.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 o=t[e],i=await l(Buffer.from(o),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),n=new Uint8Array(i),u=d(n,256),y=h(n,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}var Ch,Oh=Object.create,Fh=Object.defineProperty,Dh=Object.getOwnPropertyDescriptor,Nh=Object.getOwnPropertyNames,zh=Object.getPrototypeOf,Eh=Object.prototype.hasOwnProperty,Bh=(t,e,o,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of Nh(e))Eh.call(t,n)||n===o||Fh(t,n,{get:()=>e[n],enumerable:!(i=Dh(e,n))||i.enumerable});return t},Wh=(t,e,o)=>(o=null!=t?Oh(zh(t)):{},Bh(!e&&t&&t.__esModule?o:Fh(o,"default",{value:t,enumerable:!0}),t)),Yh={};((t,e)=>{for(var o in e)Fh(t,o,{get:e[o],enumerable:!0})})(Yh,{generateFrameSVGs:()=>kh,generateFrameSequence:()=>Ah,generatePhysicsFrameSVGs:()=>$h,renderChart:()=>mh,renderChartWithEvidence:()=>xh,renderDashboard:()=>wh,renderGeoToStaticSVG:()=>fh,renderNetworkToStaticSVG:()=>hh,renderOrdinalToStaticSVG:()=>dh,renderPhysicsToAnimatedGif:()=>Rh,renderToAnimatedGif:()=>Lh,renderToImage:()=>vh,renderToStaticSVG:()=>lh,renderXYToStaticSVG:()=>uh,resolveTheme:()=>Zt,serializeSvgPrecision:()=>yh,themeStyles:()=>Qt}),module.exports=(Ch=Yh,Bh(Fh({},"__esModule",{value:!0}),Ch));var qh,Xh=36,Gh=34,Vh=58,Hh=22,Uh=16,Kh=6,Zh=10,Qh=22,Jh=100,tf=10,ef=3,of=12,nf=18,rf=46,sf=26,af=22,cf=46,lf=64,uf=34,df=70,hf=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,ff=(t,e)=>(t>>>e|t<<32-e)>>>0,pf=t=>Math.floor(4294967296*(t-Math.floor(t)))>>>0,[yf,gf]=(()=>{const t=[],e=[];for(let o=2;64>e.length;o+=1){let i=!0;for(let t=2;o>=t*t;t+=1)if(o%t===0){i=!1;break}i&&(8>t.length&&t.push(pf(Math.sqrt(o))),e.push(pf(Math.cbrt(o))))}return[t,e]})(),mf="0.1",xf=at({"artifact.id":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.createdAt":{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"never"},"artifact.configFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.dataFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"purpose.intents":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.communicativeAct":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.stakes":{suppliedBy:["author","import"],derivable:!1,modelMayPropose:!0,humanReview:"required"},claims:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"claims.status":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},evidence:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.source":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.fingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},time:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"time.completeness":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},reception:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},form:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},contestability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"required"},accountability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"policy-dependent"},inheritance:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"}}),bf=["fresh","stale","unknown"],vf=["partial","provisional","settled","unknown"],wf=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],kf={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:bf},checkedAt:{},heartbeatAt:{},expiresAt:{},basis:{}},watermark:{value:{required:!0},policy:{},allowedLateness:{}},window:{start:{required:!0},end:{required:!0},status:{required:!0,values:["open","provisional","settled","reopened","corrected"]}},completeness:{status:{required:!0,values:vf},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},Af={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:bf},completeness:{values:vf}},Sf=["data","nodes","edges","points","areas","lines","flows"],Mf=44,_f={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Mf,snap:"nearestDatum",brushHandleSize:Mf,standardControls:!1},$f={..._f,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},Pf={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}}},jf={kind:"rank-competition"},If=Symbol.for("semiotic.semantic-viability"),Lf=globalThis,Rf=Lf[If]??(Lf[If]=new Map),Tf=Wh(require("react-dom/server")),Cf=Wh(require("react")),Of=Object.freeze([]),Ff=require("d3-scale"),Df=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Nf=wt(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),zf=wt(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Ef=wt(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Bf=wt(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),Wf=wt(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Yf=wt(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),qf=wt(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Xf=wt(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Gf=wt(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Vf=wt(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Hf=wt(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Uf=wt(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Kf={blues:Nf,reds:zf,greens:Ef,viridis:qf,oranges:Bf,purples:Wf,greys:Yf,plasma:Xf,inferno:Gf,magma:Vf,cividis:Hf,turbo:Uf},Zf=wt(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Qf=wt(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Jf=wt(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),tp=wt(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),ep=wt(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),op=wt(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),ip=wt(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),np={category10:Df,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Kf},rp=Df,sp="#007bff",ap=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],cp=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],lp=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"]),up={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},dp=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],hp={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}},fp={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}},pp={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:dp,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"},yp={light:hp,dark:fp,"high-contrast":pp,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"}},gp=2,mp="__forecastSegment",xp="__forecastOpacity",bp="__semiotic_resolvedX",vp="__semiotic_resolvedY",wp="__compoundGroup",kp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=ue({data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",forecast:n.forecast,anomaly:n.anomaly,annotations:i.annotations,themeCategorical:Zt(i.theme).colors.categorical}),s=Ut(r.annotations,n.regression);return{chartType:"scatter",data:r.data,xAccessor:r.xAccessor,yAccessor:r.yAccessor,colorAccessor:e,sizeAccessor:n.sizeBy,...n.symbolBy&&{symbolAccessor:n.symbolBy},...n.symbolMap&&{symbolMap:n.symbolMap},colorScheme:o,...i,...s&&s.length>0&&{annotations:s},...r.yExtent&&!i.yExtent&&{yExtent:r.yExtent},sizeRange:n.sizeRange||[3,15],pointStyle:i.pointStyle||de(t,e,o,i,n),showLegend:i.showLegend??!!e}}},Ap={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=Ut(i.annotations,n.regression);return{chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[5,40],colorScheme:o,...i,...r&&{annotations:r},pointStyle:i.pointStyle||he(t,e,o,i,n),showLegend:i.showLegend??!!e}}},Sp=(require("react"),"__semioticSelectionData"),Mp=Wh(require("react")),_p=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),$p=require("react/jsx-runtime"),Pp={frameType:"xy",layout:{margin:t=>({top:20,right:!1===t.showLabels?24:110,bottom:48,left:48})},buildProps:(t,e,o,i,n)=>{const r=function(t,e={}){const o=e.xAccessor??"x",i=e.yAccessor??"y",n=e.lineBy??"series",r=e.rankDirection??"descending",s=[],a=new Map,c=new Map,l=[],u=new Map;let d=1/0,h=-1/0;t.forEach((t,e)=>{const r=ve(o,t,e),f=ft(r);let p=a.get(f);null==p&&(p=s.length,a.set(f,p),s.push(r),c.set(p,[]));const y=ve(n,t,e)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(ve(i,t,e));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),c.get(p)?.push({datum:t,inputIndex:e,series:y,value:g}))});const f=[],p=new Map,y=new Map;for(let t=0;s.length>t;t++){const e=c.get(t)??[];e.sort((t,e)=>("descending"===r?e.value-t.value:t.value-e.value)||(u.get(t.series)??0)-(u.get(e.series)??0)),e.forEach((e,o)=>{const i=o+1;f.push({datum:e.datum,xIndex:t,xValue:s[t],series:e.series,value:e.value,rank:i}),p.set(e.series,(p.get(e.series)??0)+i),y.set(e.series,(y.get(e.series)??0)+1)})}const g=l.length+1,m=[...l].sort((t,e)=>{const o=y.get(t)??0,i=y.get(e)??0;return((p.get(t)??0)+(s.length-o)*g)/Math.max(1,s.length)-((p.get(e)??0)+(s.length-i)*g)/Math.max(1,s.length)||(u.get(t)??0)-(u.get(e)??0)}),x=new Set(m.slice(0,null==e.highlightTop?m.length:Math.max(0,Math.floor(e.highlightTop))));return{data:f.map(t=>{const e=x.has(t.series);return{...t.datum,x:t.xIndex,y:t.rank,__bumpRaw:t.datum,__bumpSeries:t.series,__bumpColorGroup:e?t.series:"Other",__bumpValue:t.value,__bumpRank:t.rank,__bumpXValue:t.xValue,__bumpHighlighted:e}}),xValues:s,seriesOrder:l,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}(Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],{xAccessor:n.xAccessor,yAccessor:n.yAccessor,lineBy:n.lineBy,rankDirection:n.rankDirection,highlightTop:"number"==typeof n.highlightTop?n.highlightTop:void 0}),s=Math.max(1,r.seriesOrder.length),a=Zt(i.theme),c=function(t){const{seriesOrder:e,overallOrder:o,highlightTop:i,color:n,colorScheme:r,neutralColor:s,themeCategorical:a,themeNeutral:c}=t;if(null==i&&null==n)return r;const l=new Set(o.slice(0,null==i?o.length:Math.max(0,Math.floor(i)))),u=new Map,d={};for(const t of e)Object.defineProperty(d,t,{configurable:!0,enumerable:!0,writable:!0,value:n??(l.has(t)?be(void 0,a,r,t,u):s??c??"#b8bec8")});return d}({seriesOrder:r.seriesOrder,overallOrder:r.overallOrder,highlightTop:"number"==typeof n.highlightTop?n.highlightTop:void 0,color:"string"==typeof n.color?n.color:void 0,colorScheme:o,neutralColor:"string"==typeof n.neutralColor?n.neutralColor:void 0,themeCategorical:a.colors.categorical,themeNeutral:a.colors.textSecondary}),l={ribbon:!0===n.ribbon,curve:"linear"===n.curve?"linear":"smooth",samplesPerSegment:"number"==typeof n.samplesPerSegment?n.samplesPerSegment:12,ribbonSizeRange:Array.isArray(n.ribbonSizeRange)?n.ribbonSizeRange:[4,28],valueExtent:r.valueExtent,seriesOrder:r.seriesOrder,lineWidth:"number"==typeof n.lineWidth?n.lineWidth:3,ribbonOpacity:"number"==typeof n.ribbonOpacity?n.ribbonOpacity:.82,lineOpacity:"number"==typeof n.lineOpacity?n.lineOpacity:.9,neutralColor:"string"==typeof n.neutralColor?n.neutralColor:void 0,color:"string"==typeof n.color?n.color:void 0,colorMap:c&&"object"==typeof c&&!Array.isArray(c)?c:void 0,stroke:"string"==typeof n.stroke?n.stroke:void 0,strokeWidth:"number"==typeof n.strokeWidth?n.strokeWidth:void 0,opacity:"number"==typeof n.opacity?n.opacity:void 0,styleRules:n.styleRules,areaStyle:i.areaStyle,pointStyle:i.pointStyle,labelStyle:n.labelStyle,showPoints:!0===n.showPoints,pointRadius:"number"==typeof n.pointRadius?n.pointRadius:3,showLabels:n.showLabels??!0,labelPriorityAccessor:n.labelPriorityAccessor,maxLabels:"number"==typeof n.maxLabels?n.maxLabels:void 0},u=i.xFormat,d=(t,e)=>{if(0===r.xValues.length)return"";const o=r.xValues[Math.max(0,Math.min(r.xValues.length-1,Math.round(Number(t))))];return u?u(o,e):(o instanceof Date?o.toLocaleDateString():o)+""},h=r.xValues.map((t,e)=>e),f=Array.from({length:s},(t,e)=>e+1),p=i.axes??[{orient:"left",tickValues:f,tickFormat:t=>t+"",label:i.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:i.xLabel,tickAnchor:"edges"}];return{...i,chartType:"custom",data:r.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,r.xValues.length-1)],yExtent:[s+.5,.5],customLayout:je,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:p,axisExtent:"exact",showAxes:i.showAxes??!0,showLegend:i.showLegend??!1,annotations:we(i.annotations,r.xValues)}}},jp="__ma_unitized",Ip="__ma_series",Lp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Array.isArray(n.series)?n.series:[],a=function(t,e,o){const i=At(e,o,rp),n=e&&"object"==typeof e&&!Array.isArray(e)?e:null;return t.map((t,e)=>{if("string"==typeof t.color&&t.color.length>0)return t.color;const o=t.label||"Series "+(e+1),r=n?.[o];return"string"==typeof r&&r.length>0?r:i[e%i.length]})}(s,o,Zt(i.theme).colors.categorical),c=2===s.length,l=s.map(t=>t.extent||function(t,e){const o="function"==typeof e?e:t=>Number(t[e||"y"]);let i=1/0,n=-1/0;for(const e of t){const t=o(e);"number"==typeof t&&Number.isFinite(t)&&(i>t&&(i=t),t>n&&(n=t))}if(!Number.isFinite(i)||!Number.isFinite(n))return[0,1];if(i===n){const t=0===i?1:.1*Math.abs(i);return[i-t,n+t]}return[i,n]}(r,t.yAccessor)),u=[];for(const t of r)s.forEach((e,o)=>{const i=("function"==typeof e.yAccessor?e.yAccessor:t=>t[e.yAccessor])(t);if(null==i||!Number.isFinite(Number(i)))return;const n=Number(i),r=l[o],s=r[1]-r[0]||1;u.push({...t,[jp]:c?(n-r[0])/s:n,[Ip]:e.label||"Series "+(o+1)})});const d=(t,e)=>o=>{const i=t[0]+o*(t[1]-t[0]);return"function"==typeof e?e(i):Number.isInteger(i)?i+"":i.toFixed(1)},h=c?[{orient:"left",label:s[0].label,tickFormat:d(l[0],s[0].format)},{orient:"right",label:s[1].label,tickFormat:d(l[1],s[1].format)},{orient:"bottom"}]:void 0,f=new Map;s.forEach((t,e)=>{f.set(t.label||"Series "+(e+1),a[e])});const p=jt(Nt({lineWidth:"number"==typeof n.lineWidth?n.lineWidth:2,resolveStroke:t=>f.get((t[Ip]??"")+"")||a[0],styleRules:n.styleRules,ruleContext:Ie(n.xAccessor,s)}),{stroke:"string"==typeof n.stroke?n.stroke:void 0,strokeWidth:"number"==typeof n.strokeWidth?n.strokeWidth:void 0,opacity:"number"==typeof n.opacity?n.opacity:void 0});return{chartType:"line",data:u,xAccessor:n.xAccessor||"x",yAccessor:jp,groupAccessor:Ip,colorAccessor:Ip,...h&&{axes:h},...c&&{yExtent:[0,1]},...i,curve:n.curve||i.curve||"monotoneX",showLegend:i.showLegend??!0,colorScheme:a,lineStyle:p}}},Rp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=n.xAccessor||"x",a="function"==typeof s?s:t=>t[s],c=r.some(t=>{const e=a(t);return!("number"==typeof e&&Number.isFinite(e)||e instanceof Date)}),l=c?r.map((t,e)=>({...t,__waterfallX:e,__waterfallTick:(a(t)??e)+""})):r,u=n.styleRules?Ft(void 0,n.styleRules,Lt(n.xAccessor,n.yAccessor)):void 0,d=u?t=>{const e=u(t),o="function"==typeof i.areaStyle?i.areaStyle(t):i.areaStyle;return o?{...e,...o}:e}:void 0;return{chartType:"waterfall",data:l,xAccessor:c?"__waterfallX":s,yAccessor:n.yAccessor||"y",waterfallStyle:{positiveColor:n.positiveColor,negativeColor:n.negativeColor,connectorStroke:n.connectorStroke,connectorWidth:n.connectorWidth,gap:n.gap,stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity},...i,...d&&{areaStyle:d},...c&&{axes:i.axes??[{orient:"bottom",tickValues:l.map((t,e)=>e)}],xFormat:t=>{const e=r[Number(t)]?a(r[Number(t)]):t,o=n.xFormat??i.xFormat;return"function"==typeof o?o(e):(e??t)+""}}}}},Tp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=e||n.lineBy,s=n.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",c=Zt(i.theme).colors.categorical,l=function(t,e,o,i,n){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Zt(i.theme).colors.categorical,a=o??i.colorScheme??s,c="string"==typeof e?e:"__ssrLineColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrLineColorBy:e(t)})):r,u=e?_t(l,c,a):void 0,d=Lt(n.xAccessor,n.yAccessor);return jt(Nt({lineWidth:"number"==typeof n.lineWidth?n.lineWidth:2,colorBy:e,colorScale:u,color:"string"==typeof n.color?n.color:void 0,fillArea:n.fillArea,areaOpacity:"number"==typeof n.areaOpacity?n.areaOpacity:.3,styleRules:n.styleRules,ruleContext:d}),{stroke:"string"==typeof n.stroke?n.stroke:void 0,strokeWidth:"number"==typeof n.strokeWidth?n.strokeWidth:void 0,opacity:"number"==typeof n.opacity?n.opacity:void 0})}(t,r,o,i,n),u=ue({data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",lineBy:n.lineBy,colorBy:r,colorScheme:o,color:"string"==typeof n.color?n.color:void 0,forecast:n.forecast,anomaly:n.anomaly,gapStrategy:n.gapStrategy,directLabel:n.directLabel,annotations:i.annotations,themeCategorical:c,baseLineStyle:l}),d=i.pointStyle||Re(u.data,u.colorAccessor,o,i,n);let h=i.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const f=(!n.directLabel||void 0!==i.showLegend)&&(i.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:o,lineStyle:u.lineStyle||l,...Array.isArray(s)&&{areaGroups:s},...s&&null!=n.areaOpacity&&{areaOpacity:n.areaOpacity},...null!=n.band&&{band:n.band},...i,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!i.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},Cp={frameType:"xy",layout:{margin:(t,e)=>function(t,e,o,i=!1){const n=y({axes:e,showAxes:o});return{...k(t,e,i),...!n.hasAxis&&{bottom:0},...!n.leftAxis?.hasAxis&&{left:0}}}(e.marginDefaults,Jt(t),e.showAxes,!!e.title)},buildProps:(t,e,o,i,n)=>{const r=Array.isArray(t)?xt(t):[],s=n.timeAccessor||"time",a=n.valueAccessor||"value",c=n.categoryAccessor,l=n.valueExtent||i.yExtent,u={...Ht(n),...void 0!==n.cursor&&{cursor:n.cursor}},d={...u,...void 0!==n.fill&&{fill:n.fill},...void 0!==n.gap&&{gap:n.gap}},h=Ft(void 0,n.styleRules,t=>{const e=t.categoryValue??t.total,o="number"==typeof e&&Number.isFinite(e)?e:void 0,i=Number(t.binStart),n=Number(t.binEnd);return{value:o,x:Number.isFinite(i)&&Number.isFinite(n)?(i+n)/2:void 0,y:o,category:null==t.category?void 0:t.category+""}});return{chartType:"bar",data:r,...i,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,r.length),arrowOfTime:n.arrowOfTime||"right",timeAccessor:t=>mt(t,s,"time")??NaN,valueAccessor:t=>mt(t,a,"value")??NaN,xExtent:n.timeExtent||i.xExtent,yExtent:l,invertY:"down"===n.direction,axes:Jt({...n,axes:i.axes??n.axes}),extentPadding:n.extentPadding??i.extentPadding,binSize:n.binSize,categoryAccessor:c,barColors:n.colors||i.barColors,colorScheme:n.colors||i.colorScheme,barStyle:i.barStyle||d,areaStyle:i.areaStyle||(t=>({...h(t),...!c&&void 0!==n.fill&&{fill:n.fill},...u})),showLegend:i.showLegend??!!c}}},Op={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=e||n.areaBy,s=ue({data:Array.isArray(t)?xt(t):[],xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",lineBy:n.areaBy,forecast:n.forecast,anomaly:n.anomaly,annotations:i.annotations,themeCategorical:Zt(i.theme).colors.categorical}),a=function({data:t,safeData:e,areaBy:o,lineDataAccessor:i}){if(null==t)return[];const n=void 0!==e[0]?.[i];if(!n&&!o)return e;let r;if(n)r=e;else{const t=e.reduce((t,e)=>{const n="function"==typeof o?o(e):e[o],r=n+"";if(!t[r]){const e={[i]:[]};"string"==typeof o&&(e[o]=n),t[r]=e}return t[r][i].push(e),t},{});r=Object.values(t)}return r.flatMap(t=>{const e=Array.isArray(t[i])?t[i]:[];return"string"==typeof o?e.map(e=>({...e,[o]:e[o]??t[o]})):e})}({data:t,safeData:s.data,areaBy:n.areaBy,lineDataAccessor:n.lineDataAccessor||"coordinates"}),c=function(t){if(t)return Array.isArray(t)?{stops:t.map(({at:t,color:e,opacity:o})=>({offset:t/100,color:e,...null!=o&&{opacity:o}}))}:Array.isArray(t.stops)?t:void 0}(n.semanticGradient),l=c?.stops.length?{stops:c.stops.map(t=>({...t,offset:1-t.offset})).sort((t,e)=>t.offset-e.offset)}:Yt(i.gradientFill),u=!1!==n.semanticLine?function(t){const e=t?.stops.filter(t=>"string"==typeof t.color&&Number.isFinite(t.offset)).map(({offset:t,color:e,opacity:o})=>({offset:Math.max(0,Math.min(1,t)),color:e,...Number.isFinite(o)&&{opacity:Math.max(0,Math.min(1,o))}})).sort((t,e)=>t.offset-e.offset);if(!e?.length)return;const o=e[0];return o.offset>0?[{...o,offset:0},...e]:e}(c):void 0,d=i.pointStyle||Re(a,r,o,i,n);return{chartType:"area",data:a,xAccessor:s.xAccessor,yAccessor:s.yAccessor,y0Accessor:n.y0Accessor,groupAccessor:n.areaBy||void 0,colorAccessor:r,colorScheme:o,...i,...s.annotations.length>0&&{annotations:s.annotations},...s.yExtent&&!i.yExtent&&{yExtent:s.yExtent},...void 0!==l&&{gradientFill:l},...u&&{semanticLineStops:u},lineStyle:i.lineStyle||Le(a,r,o,i,n),...d&&{pointStyle:d}}}},Fp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=n.xAccessor||"x",s=n.seriesAAccessor||"a",a=n.seriesBAccessor||"b",c=t=>Gt(Xt(r,"x",t)),l=t=>Gt(Xt(s,"a",t)),u=t=>Gt(Xt(a,"b",t)),d=n.seriesAColor||"var(--semiotic-danger, #dc2626)",h=n.seriesBColor||"var(--semiotic-info, #2563eb)",f=n.areaOpacity??.6,p=n.lineWidth??1.5,y=!1!==n.showLines,g=!1!==i.showLegend,m=n.seriesALabel||"A",x=n.seriesBLabel||"B",b=i.legendPosition||"right",v=function(t,e,o,i){if(!t.length)return[];const n=t.filter(t=>Number.isFinite(e(t))).sort((t,o)=>e(t)-e(o)),r=[];let s=0,a=null,c=null,l=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;n.length>t;t++){const r=n[t],p=e(r),y=o(r),g=i(r);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let t,e;if(l.length>0)t=l[0].x,e=l[0].y;else{const o=y-c.a-(g-c.b);if(0!==o){const i=Math.max(0,Math.min(1,(c.b-c.a)/o));t=c.x+i*(p-c.x),e=c.a+i*(y-c.a)}else t=c.x,e=c.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const t of l)f(t,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:r})}for(const t of l)f(t,a??"A");return r}(Array.isArray(t)?t:[],c,l,u),w=[];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),o=l(t),i=u(t);Number.isFinite(o)&&w.push({__x:e,__y:o,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:t}),Number.isFinite(i)&&w.push({__x:e,__y:i,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:t})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(t=>t.__diffSegment))),areaStyle:Bt({seriesAColor:d,seriesBColor:h,areaOpacity:f,styleRules:n.styleRules}),lineStyle:Wt({seriesAColor:d,seriesBColor:h,lineWidth:p,styleRules:n.styleRules}),curve:n.curve||"linear",...i,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},Dp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=e||n.areaBy,s="string"==typeof r&&Array.isArray(t)?_t(t,r,o):void 0,a="number"==typeof n.areaOpacity?n.areaOpacity:.7,c=i.lineStyle||(t=>{const e=null==r?void 0:St(t,r,s),o=n.showLine??!0,i={fill:n.color??e,stroke:o?n.stroke??e:"none",...o?{strokeWidth:n.strokeWidth??n.lineWidth??2}:{},fillOpacity:a,...null==n.opacity?{}:{opacity:n.opacity}},c=n.styleRules;if(c?.length){const e=It(n.yAccessor),o=r?"function"==typeof r?(r(t)??"")+"":(t[r]??"")+"":void 0;Object.assign(i,Ot(t,c,{value:e(t),category:o}))}return i}),l=n.normalize?"zero":n.baseline??"zero",u=i.pointStyle||Re(t,r,o,i,n);return{chartType:"stackedarea",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.areaBy,colorAccessor:r,colorScheme:o,normalize:n.normalize,baseline:l,stackOrder:n.stackOrder,lineStyle:c,...i,...u&&{pointStyle:u},curve:i.curve??n.curve??"monotoneX",showLegend:i.showLegend??!!r}}},Np={frameType:"xy",buildProps:(t,e,o,i,n)=>{const[r]=i.size??[600,400];return{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,...i,...!i.pointStyle&&Array.isArray(n.styleRules)&&n.styleRules.length>0&&{pointStyle:Ft(void 0,n.styleRules,Lt(n.xAccessor||"x",n.closeAccessor||n.highAccessor||"high"))},scalePadding:i.scalePadding??Math.max(2,Math.min(12,Math.round(r/40))),extentPadding:i.extentPadding??(r>200?.1:.02)}}},zp={frameType:"xy",buildProps:(t,e,o,i,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",h=c.strokeWidth??1,f=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=Cf.createElement,y=a?[(t,e,o)=>{if(!e?.x||!e?.y)return null;const i=o.width,n=o.height,c=null!=r?e.x(r):i/2,y=null!=s?e.y(s):n/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(i,c)),m=Math.max(0,Math.min(n,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:i-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:n-m},{c:a.bottomRight,x:g,y:m,w:i-g,h:n-m}],b=l?[p("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:i-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:n-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:i-8,y:n-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(Cf.Fragment,null,...x.map((t,e)=>t.w>0&&t.h>0?p("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),p("line",{key:"vc",x1:g,y1:0,x2:g,y2:n,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:i,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[3,15],colorScheme:o,pointStyle:i.pointStyle||n.pointStyle||de(t,e,o,i,n),...i,showLegend:i.showLegend??!!e,...y&&{svgPreRenderers:y}}}},Ep={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const o=e.xAccessor||"x",i=e.yAccessor||"y",n=e.orderAccessor?[...t].sort((t,o)=>null==t||"object"!=typeof t?1:null==o||"object"!=typeof o?-1:Gt(Xt(e.orderAccessor,"order",t))-Gt(Xt(e.orderAccessor,"order",o))):t,r=new WeakMap;let s=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=Gt(Xt(o,"x",t)),n=Gt(Xt(i,"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=Gt(Xt(o,"x",t)),n=Gt(Xt(i,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&r.set(t,{idx:a++,total:s})}return{data:n,orderMap:r}}(t,n),s=ue({data:r.data,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",forecast:n.forecast,anomaly:n.anomaly,annotations:i.annotations,themeCategorical:Zt(i.theme).colors.categorical}),a=Ut(s.annotations,n.regression),c=n.pointRadius??4,l=Lt(n.xAccessor,n.yAccessor),u=n.styleRules,d=[t=>{const e=t.filter(t=>"point"===t.type&&"number"==typeof t.x&&"number"==typeof t.y);if(2>e.length)return null;const o=[];for(let t=0;e.length-1>t;t++){const i=e[t],n=e[t+1],r=Vt(t,e.length);100>e.length&&o.push(Cf.createElement("line",{key:"halo-"+t,x1:i.x,y1:i.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:c+2,strokeLinecap:"round",opacity:.5})),o.push(Cf.createElement("line",{key:"segment-"+t,x1:i.x,y1:i.y,x2:n.x,y2:n.y,stroke:r,strokeWidth:c,strokeLinecap:"round"}))}return Cf.createElement(Cf.Fragment,null,...o)}];return{chartType:"scatter",data:s.data,xAccessor:s.xAccessor,yAccessor:s.yAccessor,colorAccessor:e,colorScheme:o,pointStyle:jt(t=>{const e=r.orderMap.get(t),o=e?.idx??0,i=e?.total??1,n={fill:i>0?Vt(o,i):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1};return u?.length&&Object.assign(n,Ot(t,u,l(t))),n},Ht(n)),...i,...a&&a.length>0&&{annotations:a},...s.yExtent&&!i.yExtent&&{yExtent:s.yExtent},svgPreRenderers:d}}},Bp={frameType:"xy",buildProps:(t,e,o,i,n)=>{const r=n.frameProps&&"object"==typeof n.frameProps?n.frameProps:void 0,s=Number.isFinite(n.cellBorderWidth)?Math.max(0,n.cellBorderWidth):1,a=Ft(()=>({stroke:n.cellBorderColor??"#fff",strokeWidth:s}),n.styleRules,function(t,e,o){const i=It(t),n=It(e),r=It(o);return t=>{const e="string"==typeof t.agg&&"number"==typeof t.count&&"number"==typeof t.xCenter&&"number"==typeof t.yCenter;return{value:e?Te(t.value):r(t),x:e?Te(t.xCenter):i(t),y:e?Te(t.yCenter):n(t)}}}(n.xAccessor,n.yAccessor,n.valueAccessor)),c=("string"==typeof r?.colorScheme?r.colorScheme:void 0)??o,l=null!=r&&Object.hasOwn(r,"heatmapColorScale"),u=r?.heatmapColorScale,d=l?"function"==typeof u?u:void 0:"custom"===c&&"function"==typeof n.customColorScale?n.customColorScale:void 0;return{chartType:"heatmap",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",valueAccessor:n.valueAccessor,showValues:n.showValues,heatmapValueFormat:n.valueFormat,...n.heatmapAggregation&&{heatmapAggregation:n.heatmapAggregation},...null!=n.heatmapXBins&&{heatmapXBins:n.heatmapXBins},...null!=n.heatmapYBins&&{heatmapYBins:n.heatmapYBins},areaStyle:a,...i,...void 0!==c&&{colorScheme:c},...d&&{heatmapColorScale:d}}}},Wp=(require("react"),{RdBu:Zf,PiYG:Qf,PRGn:Jf,BrBG:tp,RdYlBu:ep,RdYlGn:op,Spectral:ip}),Yp="__likert_neutral_neg",qp="__likert_neutral_pos",Xp={frameType:"ordinal",layout:{margin:(t,e)=>({...e.marginDefaults,left:"vertical"===t.orientation?e.marginDefaults.left:Math.max(100,e.marginDefaults.left)})},buildProps:(t,e,i,n,r)=>{const s=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],a="vertical"!==r.orientation;let c=function(t,e,o,i,n,r,s={}){const a=new Map,c=new Set(e);for(const s of t){const t=o(s);a.has(t)||a.set(t,new Map);const l=a.get(t);if(i){const t=i(s);if(null==t||!Number.isFinite(t))continue;if(!Number.isInteger(t)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",t);continue}const o=t-1;if(0>o||o>=e.length)continue;const n=e[o];l.set(n,(l.get(n)||0)+1)}else if(n&&r){const t=n(s),e=r(s);if(!c.has(t))continue;l.set(t,(l.get(t)||0)+(Number.isFinite(e)?e:0))}}const l=[];for(const[t,o]of a){let i=0;for(const t of e)i+=o.get(t)||0;if(0!==i)for(let n=0;e.length>n;n++){const r=e[n],a=o.get(r)||0,c={};s.category&&(c[s.category]=t),s.level&&(c[s.level]=r),s.count&&(c[s.count]=a),s.score&&(c[s.score]=n+1),l.push({...c,__likertCategory:t,__likertLevel:r,__likertLevelLabel:r,__likertCount:a,__likertPct:a/i*100,__likertLevelIndex:n})}}return l}(Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s,Ce(r.categoryAccessor,"question"),r.levelAccessor?null:Ce(r.valueAccessor,"score"),r.levelAccessor?Ce(r.levelAccessor,"level"):null,r.levelAccessor?Ce(r.countAccessor,"count"):null,{category:"string"==typeof r.categoryAccessor?r.categoryAccessor:void 0,level:"string"==typeof r.levelAccessor?r.levelAccessor:void 0,count:"string"==typeof r.countAccessor?r.countAccessor:void 0,score:r.levelAccessor||"string"!=typeof r.valueAccessor?void 0:r.valueAccessor});a&&(c=function(t,e){const o=e.length,i=o%2!=0,n=Math.floor(o/2),r=new Map;for(const e of t){const t=r.get(e.__likertCategory)||[];t.push(e),r.set(e.__likertCategory,t)}const s=[];for(const[,t]of r){const e=new Map;let r,a;for(const o of t)o.__likertLevel===Yp?r=o:o.__likertLevel===qp?a=o:e.set(o.__likertLevelIndex,o);i&&r&&s.push(r);for(let t=n-1;t>=0;t--){const o=e.get(t);o&&s.push(o)}i&&a&&s.push(a);for(let t=i?n+1:n;o>t;t++){const o=e.get(t);o&&s.push(o)}}return s}(function(t,e){const o=e.length,i=o%2!=0,n=Math.floor(o/2),r=[];for(const e of t){const t=e.__likertLevelIndex;if(i&&t===n){const t=e.__likertPct/2;r.push({...e,__likertLevel:Yp,__likertPct:-t}),r.push({...e,__likertLevel:qp,__likertPct:t})}else r.push(n>t?{...e,__likertPct:-e.__likertPct}:e)}return r}(c,s),s));const l=Zt(n.theme).colors.diverging,u=Array.isArray(i)&&i.length>=s.length?i:function(t,e){if(0>=t)return[];if(e&&Object.prototype.hasOwnProperty.call(Wp,e)){const o=Wp[e];if(1===t)return[o(.5)];const i=[];for(let e=0;t>e;e++)i.push(o(e/(t-1)));return i}const o=["#da1e28","#ff8389","#ffb3b8"],i=["#a6c8ff","#4589ff","#0043ce"],n="#a8a8a8";if(1===t)return[n];const r=t%2!=0,s=Math.floor(t/2),a=[];for(let t=0;s>t;t++)a.push(o[Math.min(Math.floor(t*o.length/s),o.length-1)]);r&&a.push(n);for(let t=0;s>t;t++)a.push(i[Math.min(Math.floor(t*i.length/s),i.length-1)]);return a}(s.length,l),d=new Map(s.map((t,e)=>[t,u[e]||"#888"])),h=s.length%2&&d.get(s[Math.floor(s.length/2)])||"#888",f="function"==typeof r.valueFormat?r.valueFormat:t=>Math.abs(Number(t)).toFixed(0)+"%",p=o(!1===n.showLegend?void 0:{legendGroups:[{label:"",items:s.map(t=>({label:t})),styleFn:t=>({fill:d.get(t.label)||"#888"})}]},n.legend),y=r.styleRules,g=n.pieceStyle;return{chartType:"bar",data:c,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:r.barPadding,showGrid:n.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(a?void 0:"Percentage"),rFormat:f,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...n,pieceStyle:jt((t,e)=>{const o=t.__likertLevel||t.data?.__likertLevel,i=t.__likertLevelLabel||t.data?.__likertLevelLabel,n=t.__likertPct??t.data?.__likertPct,r={fill:o===Yp||o===qp?h:d.get((i||o)+"")||"#888"};return y?.length&&Object.assign(r,Ot(t,y,{value:"number"==typeof n?n:void 0,category:e??(null==i?void 0:i+"")})),"function"==typeof g?Object.assign(r,g(t,e)||{}):g&&"object"==typeof g&&Object.assign(r,g),r},Ht(r)),showLegend:n.showLegend??!0,legendPosition:n.legendPosition||"right",...p&&{legend:p},__legendIncludesAutomatic:!0}}},Gp=require("react/jsx-runtime"),Vp=require("react/jsx-runtime"),Hp={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(t,{theme:e}){const o=t.__gauge;if(!o)return null;const i=(o.startAngleDeg+(o.gMax===o.gMin?0:(Math.max(o.gMin,Math.min(o.gMax,o.value??o.gMin))-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,n=o.needleColor||e.colors.text,r=o.showScaleLabels?(o.thresholds||[]).filter(t=>t.value>o.gMin&&o.gMax>t.value):[];return(0,Vp.jsxs)(Vp.Fragment,{children:[o.showNeedle&&(0,Vp.jsxs)(Vp.Fragment,{children:[(0,Vp.jsx)("line",{x1:o.centerX,y1:o.centerY,x2:o.centerX+o.needleLength*Math.cos(i),y2:o.centerY+o.needleLength*Math.sin(i),stroke:n,strokeWidth:2.5,strokeLinecap:"round"}),(0,Vp.jsx)("circle",{cx:o.centerX,cy:o.centerY,r:4,fill:n})]}),null!=o.contextValue&&(0,Vp.jsx)("text",{x:o.centerX,y:o.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:o.valueFontSize,fontWeight:700,fill:n,children:o.contextValue}),r.map((t,i)=>{const n=(o.startAngleDeg+(o.gMax===o.gMin?0:(t.value-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,r=o.innerRadius-1,s=o.radius+1,a=o.radius+10,c=((n+Math.PI/2)/(2*Math.PI)*12+12)%12,l=c>=11||1>c?"middle":5>c?"start":7>c?"middle":"end",u=c>=11||1>c?"auto":5>c?"middle":7>c?"hanging":"middle";return(0,Vp.jsxs)("g",{children:[(0,Vp.jsx)("line",{x1:o.centerX+Math.cos(n)*r,y1:o.centerY+Math.sin(n)*r,x2:o.centerX+Math.cos(n)*s,y2:o.centerY+Math.sin(n)*s,stroke:e.colors.border,strokeWidth:2,strokeLinecap:"round"}),(0,Vp.jsx)("text",{x:o.centerX+Math.cos(n)*a,y:o.centerY+Math.sin(n)*a,textAnchor:l,dominantBaseline:u,fill:e.colors.textSecondary,fontSize:10,children:t.label||t.value+""})]},"gauge-label-"+i)})]})},buildProps:(t,e,o,i,n)=>{const r=n.min??0,s=n.max??100,a=n.sweep??240,c=n.arcWidth??.3,l=!1!==n.showNeedle,u=!1!==n.fillZones,{startAngleDeg:d}=Ee(a),h=n.thresholds,f=qt(i.gradientFill),p=function(t){const{min:e,max:o,value:i,thresholds:n,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,d=o-e||1,h=(Math.max(e,Math.min(o,i))-e)/d;let f=n&&n.length>0?[...n].sort((t,e)=>t.value-e.value):[{value:o,color:r||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(o,t.value))})),o>f[f.length-1].value&&f.push({value:o,color:f[f.length-1].color});const p=!!l&&l.stops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?h:1,e=ze("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)),o=Math.max(1,Math.min(e,Math.round(t*e))),i=[];for(let e=0;o>e;e++)i.push(Ne(l.stops,t*(e+.5)/o,r||f[0]?.color||"#007bff"));const n=ze("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:i}}),g.set(n,{fill:i[0]||s})}}else{let t=e;for(let o=0;f.length>o;o++){const i=f[o],n=(i.value-t)/d,r=(t-e)/d,c=(i.value-e)/d,l=Math.max(0,(a?Math.min(h,c):c)-r),u=a?Math.max(0,n-l):0;if(l>0){const t=ze("fill",o);y.push({category:t,value:l,_zone:i.label||"Zone "+(o+1),_isFill:!0}),g.set(t,{fill:i.color})}if(u>0){const t=ze("bg",o);y.push({category:t,value:u,_zone:i.label||"Zone "+(o+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=i.value}}if(c&&n&&n.length>0)for(const t of n)t.value>e&&o>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:h,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==n.showScaleLabels,gradientFill:f}),y=n.styleRules,[g,m]=i.size||[300,250],x=function(t=240){const{sweepRad:e,offsetRad:o}=Ee(t),i=[[Math.cos(o),Math.sin(o)],[Math.cos(o+e),Math.sin(o+e)],[0,0]];for(let t=0;2*Math.PI>t;t+=Math.PI/2)((t-o)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>e+.001||i.push([Math.cos(t),Math.sin(t)]);const n=i.map(t=>t[0]),r=i.map(t=>t[1]),[s,a]=te(n),[c,l]=te(r);return{minX:s,maxX:a,minY:c,maxY:l,width:a-s,height:l-c,cx:(s+a)/2,cy:(c+l)/2}}(a),b=Math.min(10,Math.max(1,Math.min(g,m)/12)),v=Math.max(4,Math.min((g-2*b)/x.width,(m-2*b)/x.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-c))),k=g/2-x.cx*v,A=m/2-x.cy*v,S=2*(v+4),M=Math.max(r,Math.min(s,n.value??r)),_="function"==typeof n.valueFormat?n.valueFormat(M):Math.round(M)+"",$=n.centerContent??i.centerContent,P=null!=$?"function"==typeof $?$(M,r,s):$:"sparkline"===n.mode||"context"===n.mode?void 0:function({value:t,min:e,max:o,radius:i,showScaleLabels:n}){const r=Math.max(16,.3*i);return(0,Gp.jsxs)("g",{textAnchor:"middle",children:[(0,Gp.jsx)("text",{y:0,dominantBaseline:"central",fontSize:r,fontWeight:700,fill:"var(--semiotic-text, #333)",children:t}),n&&(0,Gp.jsxs)("text",{y:.7*r+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[e," – ",o]})]})}({value:_,min:r,max:s,radius:v,showScaleLabels:!1!==n.showScaleLabels});return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:jt((t,e)=>{const o={...p.pieceStyle(t,e)};return y?.length&&Object.assign(o,Ot(t,y,{value:"number"==typeof t.value?t.value:void 0,category:e??(null==t.category?void 0:t.category+"")})),o},Ht(n)),...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...i,size:[g,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:g-k-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==n.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:l,needleColor:n.needleColor,..."context"===n.mode&&null==$&&{contextValue:_,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},Up={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=Ut(i.annotations,n.regression);return{chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal"===n.orientation?"horizontal":"vertical",...n.valueExtent&&{rExtent:n.valueExtent},oSort:n.sort??!1,colorAccessor:e,colorScheme:o,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,...r&&{annotations:r},gradientFill:Be(i.gradientFill),pieceStyle:We(t,e,o,i,n)}}},Kp={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.stackBy;return{chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.stackBy,colorAccessor:r,colorScheme:o,projection:"horizontal"===n.orientation?"horizontal":"vertical",...n.valueExtent&&{rExtent:n.valueExtent},normalize:n.normalize,oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,gradientFill:Be(i.gradientFill),pieceStyle:We(t,r,o,i,n),showLegend:i.showLegend??!!r}}},Zp={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.groupBy;return{chartType:"clusterbar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",groupBy:n.groupBy,colorAccessor:r,colorScheme:o,projection:"horizontal"===n.orientation?"horizontal":"vertical",...n.valueExtent&&{rExtent:n.valueExtent},oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,gradientFill:Be(i.gradientFill),pieceStyle:We(t,r,o,i,n),showLegend:i.showLegend??!!r}}},Qp={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.categoryAccessor,s=It(n.valueAccessor??"value");return{chartType:"pie",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",colorAccessor:r,colorScheme:o,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...null!=n.startAngle&&{startAngle:n.startAngle},...i,pieceStyle:We(t,r,o,i,n,t=>{const e=s(t);return null==e?void 0:Math.abs(e)}),showLegend:i.showLegend??!!r}}},Jp={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(t,e,o,i,n)=>{const r=e||n.categoryAccessor,s=It(n.valueAccessor??"value");return{chartType:"donut",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",margin:i.margin??{top:50,right:40,bottom:60,left:70},innerRadius:n.innerRadius??60,colorAccessor:r,colorScheme:o,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...null!=n.startAngle&&{startAngle:n.startAngle},...i,pieceStyle:We(t,r,o,i,n,t=>{const e=s(t);return null==e?void 0:Math.abs(e)})}}},ty={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=n.valueAccessor||"value",a=r.map(t=>Number("function"==typeof s?s(t):t[s])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:t,oAccessor:n.categoryAccessor||(t=>null==t.category?"All":t.category+""),rAccessor:s,projection:"horizontal",bins:n.bins??25,normalize:n.relative??!1,colorAccessor:e,colorScheme:o,barPadding:n.categoryPadding??20,...n.valueExtent?{rExtent:n.valueExtent}:c?{rExtent:c}:{},...i,summaryStyle:Ye(t,e,o,i,n,"count")}}},ey={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"boxplot",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal"===n.orientation?"horizontal":"vertical",...n.valueExtent&&{rExtent:n.valueExtent},colorAccessor:e,colorScheme:o,...null!=n.showOutliers&&{showOutliers:n.showOutliers},...null!=n.outlierRadius&&{outlierRadius:n.outlierRadius},...i,summaryStyle:Ye(t,e,o,i,n)})},oy={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"violin",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,projection:"horizontal"===n.orientation?"horizontal":"vertical",bins:n.bins??25,showIQR:n.showIQR??!0,barPadding:n.categoryPadding??20,colorScheme:o,...i,summaryStyle:qe(t,e,o,i,n),showLegend:i.showLegend??!!e,...n.valueExtent&&{rExtent:n.valueExtent}})},iy={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"swarm",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal"===n.orientation?"horizontal":"vertical",...n.valueExtent&&{rExtent:n.valueExtent},barPadding:n.categoryPadding??20,colorAccessor:e,...n.symbolBy&&{symbolAccessor:n.symbolBy},...n.symbolMap&&{symbolMap:n.symbolMap},colorScheme:o,...i,sizeRange:n.sizeRange||[3,8],pieceStyle:Ge(t,e,o,i,n),showLegend:i.showLegend??!!e})},ny={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(t,e,o,i,n)=>{const r=Ut(i.annotations,n.regression);return{chartType:"point",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:o,projection:"vertical"===n.orientation?"vertical":"horizontal",...n.valueExtent&&{rExtent:n.valueExtent},oSort:n.sort??"auto",barPadding:n.categoryPadding??10,...i,...r&&{annotations:r},pieceStyle:Xe(t,e,o,i,n),showGrid:i.showGrid??!0,showLegend:i.showLegend??!!e}}},ry={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=n.seriesAccessor||e||"__radar",s=e||("__radar"===r?void 0:r),a=Xe(t,s,o,i,{...n,dotRadius:n.pointRadius??4});return{chartType:"point",projection:"radial",data:t,oAccessor:n.categoryAccessor||"attribute",rAccessor:n.valueAccessor||"value",colorAccessor:s,colorScheme:o,connectorAccessor:r,connectorStyle:t=>{const e=a(t),o="string"==typeof e.fill?e.fill:void 0;return{fill:o,fillOpacity:.15,stroke:o,strokeWidth:2,opacity:.7}},pieceStyle:a,rExtent:n.valueExtent||[0],oLabel:"",...i,...n.categoryFormat&&{oFormat:n.categoryFormat},showLegend:i.showLegend??!!s}}},sy={frameType:"ordinal",buildProps:(t,e,o,i,n)=>{const r=e||n.subcategoryAccessor;return{chartType:"swimlane",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.subcategoryAccessor,colorAccessor:r,categoryAccessor:n.categoryAccessor,subcategoryAccessor:n.subcategoryAccessor,colorScheme:o,projection:"vertical"===n.orientation?"vertical":"horizontal",...null!=n.trackFill&&{trackFill:n.trackFill},...n.valueExtent&&{rExtent:n.valueExtent},...null!=n.roundedTop&&{roundedTop:n.roundedTop},...i,gradientFill:Be(i.gradientFill),pieceStyle:We(t,r,o,i,n),showLegend:i.showLegend??!!r,barPadding:n.barPadding??40}}},ay={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"ridgeline",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:o,projection:"vertical"===n.orientation?"vertical":"horizontal",...n.valueExtent&&{rExtent:n.valueExtent},bins:n.bins??20,amplitude:n.amplitude??1.5,barPadding:n.categoryPadding??5,oSort:n.oSort??!1,...i,summaryStyle:Ye(t,e,o,i,n,"median",.5),showLegend:i.showLegend??!!e})},cy={frameType:"ordinal",layout:{margin:(t,e)=>"vertical"===t.orientation?{top:e.title?60:40,right:20,bottom:60,left:60}:{top:e.title?40:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r="vertical"===n.orientation,s=e||n.categoryAccessor;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:n.stepAccessor||"step",rAccessor:n.valueAccessor||"value",colorAccessor:s,categoryAccessor:n.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:n.connectorAccessor,connectorStyle:n.connectorStyle,...!r&&null!=n.connectorOpacity&&{connectorOpacity:n.connectorOpacity},barPadding:r?40:0,colorScheme:o,...i,showAxes:r&&!1!==i.showAxes,showGrid:r,pieceStyle:We(t,s,o,i,n),showLabels:n.showLabels??!0}}},ly=require("d3-scale"),uy={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},dy=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),hy=t=>{let e=1;for(let o=2;t>=o;o++)e*=o;return e},fy=828*hy(8),py=3e3,yy=new Map,gy=1e5,my=1e-9,xy=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,by=null,vy=new WeakMap,wy=require("react/jsx-runtime"),ky=new Map,Ay=require("react/jsx-runtime"),Sy="var(--semiotic-grid, #94a3b8)",My="var(--semiotic-text-secondary, #475569)",_y="var(--semiotic-text-secondary, #94a3b8)",$y=.22,Py=t=>{const{bands:e=[],ribbons:o=[],showLabels:i=!0,selectionDatum:n="raw"}=t.config,r=t.selection??null,s=[];for(const t of o){const e={__kind:"ribbon",data:t.rawDatum,id:t.id},o=!li(e,r,n);s.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:o?Math.min(t.opacity,$y):t.opacity,stroke:"none"},datum:e})}for(const t of e){if(!t.gradientStubs)continue;const e=!li({__kind:"band",data:t.rawDatum,id:t.id},r,n);for(let o=0;t.gradientStubs.length>o;o++){const i=t.gradientStubs[o];s.push({type:"bezier",pathD:i.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:e?$y:t.fillOpacity??.86,stroke:"none"},_gradient:{x0:i.x0,x1:i.x1,...null!=i.y0&&{y0:i.y0},...null!=i.y1&&{y1:i.y1},from:i.from,to:i.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${o}`}})}}for(const t of e){const e=!(!t.gradientStubs||0>=t.gradientStubs.length),o={__kind:"band",data:t.rawDatum,id:t.id},i=!li(o,r,n);s.push({type:"bezier",pathD:t.pathD,style:{...e?{fill:"none"}:{fill:t.hatchFill??t.fill,fillOpacity:i?$y:t.fillOpacity??.86},stroke:t.stroke??("string"==typeof t.fill?t.fill:"#666"),strokeWidth:t.strokeWidth??.5,...i&&e?{opacity:$y}:{}},datum:o})}const a=i?e.flatMap(t=>{const e=t.labelDeferred&&t.labelFullText?.trim(),o=t.labelText.trim().length>0,i=e&&r?.isActive&&li({__kind:"band",data:t.rawDatum,id:t.id},r,n),s=o?t.labelText:i?t.labelFullText:"";return s.trim()?[{x:t.labelX,y:t.labelY,text:s,anchor:t.labelAnchor??"end",baseline:t.labelBaseline??"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:s,labels:a}},jy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{if(!(e||Array.isArray(n.styleRules)&&n.styleRules.length>0||i.nodeStyle||n.nodeStyle||Pt(Ht(n))))return{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:o,...i,showLegend:(i.showLegend??!!e)&&!!e};const r=Array.isArray(n.edges)?n.edges:[],s=Array.isArray(n.nodes)&&n.nodes.length>0?n.nodes:di([],r,n.sourceAccessor||"source",n.targetAccessor||"target"),a=Zt(i.theme).colors.categorical,c=At(o,a),l="string"==typeof e?e:"__ssrChordColorBy",u="function"==typeof e?s.map(t=>({...t,__ssrChordColorBy:e(t)})):s,d=e?_t(u,l,o??i.colorScheme??a):void 0,h=new Map,f=n.nodeIdAccessor||n.nodeIDAccessor||"id",p=(t,o)=>{const i=t?.data||t;let r;if(e)r=St(i,e,d);else{const e=(t.id??i?.[f]??"")+"";h.has(e)||h.set(e,h.size);const n=t.index??o??h.get(e);r=c[n%c.length]}return{fill:r,stroke:n.stroke??"black",strokeWidth:n.strokeWidth??1,...void 0!==n.opacity&&{opacity:n.opacity}}},y=Dt(n.styleRules,e,n.valueAccessor);return{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:o,nodeStyle:jt(n.nodeStyle||(y?(t,e)=>({...p(t,e),...y(t,e)}):p),Ht(n)),...i,showLegend:(i.showLegend??!!e)&&!!e}}},Iy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=function(t){if(void 0!==t.edgeStyle)return t.edgeStyle;const{edgeWidth:e,edgeColor:o,edgeOpacity:i}=t,n=t.strokeWidth??1;return void 0!==e||void 0!==o||void 0!==i||void 0!==t.stroke||void 0!==t.strokeWidth||void 0!==t.opacity?r=>{const s=r?.data||r;let a=n;if("number"==typeof e)a=e;else if("function"==typeof e)a=e(s);else if("string"==typeof e){const t=s?.[e],o="number"==typeof t?t:Number(t);a=Number.isFinite(o)&&o>0?o:n}return{stroke:o??t.stroke??"#999",strokeWidth:a,opacity:i??t.opacity??.6}}:void 0}(n),s=Zt(i.theme).colors.categorical,a=new Map,c=n.nodeStyle??(t=>({fill:e?St(t?.data||t,e,void 0):be(void 0,s,o,void 0,a),..."number"==typeof n.nodeSize&&{r:n.nodeSize}})),l=Dt(n.styleRules,e,"number"==typeof n.nodeSize?void 0:n.nodeSize),u=jt(l?(t,e)=>({...c(t),...l(t,e)}):c,{stroke:n.nodeStroke??n.stroke,strokeWidth:n.nodeStrokeWidth??n.strokeWidth,opacity:n.opacity});return{chartType:"force",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,colorBy:e,colorScheme:o,iterations:n.iterations,forceStrength:n.forceStrength,showLabels:n.showLabels??!1,nodeLabel:n.nodeLabel,nodeSize:n.nodeSize??8,nodeSizeRange:n.nodeSizeRange,nodeStyle:u,edgeStyle:r,...i,showLegend:(i.showLegend??!!e)&&!!e}}},Ly={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=Zt(i.theme).colors.categorical,s=new Map,a=ui(t??null,n.childrenAccessor),c="function"==typeof e?e:null,l=c?a.map(t=>({__ssrCirclePackColorBy:c(t)})):a,u=c?"__ssrCirclePackColorBy":"string"==typeof e?e:void 0,d=e&&u?_t(l,u,o??i.colorScheme??r):void 0,h=n.showLabels??i.showLabels,f=i.nodeStyle||n.nodeStyle,p=Ft(t=>{const i=t?.data||t;return{fill:n.colorByDepth?cp[Number(t?.depth||0)%cp.length]:e?c?St({__ssrCirclePackColorBy:c(i)},"__ssrCirclePackColorBy",d??void 0):St(i,e,d??void 0):be(void 0,r,o,void 0,s),fillOpacity:n.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},n.styleRules,Rt(e,n.valueAccessor),t=>t?.data||t);return{chartType:"circlepack",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,nodeLabel:h?n.nodeLabel||n.nodeIdAccessor:void 0,...null!=n.padding&&{padding:n.padding},colorScheme:o,...i,showLegend:(i.showLegend??!(!e||n.colorByDepth))&&!(!e||n.colorByDepth),nodeStyle:hi(p,f,Ht(n))}}},Ry={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=t??n.data,s=n.childrenAccessor||"children",a=n.nodeIdAccessor||n.nodeIDAccessor||"name",c=Zt(i.theme).colors.categorical,l=o??i.colorScheme??c,u=At(l,c),d=ui(r,s),h="__ssrOrbitColorBy",f="function"==typeof e?e:null,p=e?_t(f?d.map(t=>({[h]:f(t)})):d,f?h:e,l):void 0,y=Ft(t=>{const o=t.data||t,i=Number(t.depth??0);return{fill:n.colorByDepth?0===i?u[0]:cp[i%cp.length]:e?f?St({[h]:f(o)},h,p):St(o,e,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===i?1:.85}},n.styleRules,Rt(e,"value"),t=>t?.data||t);return{chartType:"orbit",data:r,childrenAccessor:s,nodeIDAccessor:a,colorBy:e,colorScheme:l,colorByDepth:n.colorByDepth??!1,nodeSize:n.nodeRadius??6,nodeLabel:n.showLabels?a:void 0,showLabels:n.showLabels??!1,orbitMode:n.orbitMode??"flat",orbitSize:n.orbitSize??2.95,orbitSpeed:n.speed??.25,orbitRevolution:n.revolution,orbitRevolutionStyle:n.revolutionStyle,orbitEccentricity:n.eccentricity??1,orbitShowRings:n.showRings??!0,orbitAnimated:!1,nodeStyle:jt(y,Ht(n)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...i,showLegend:(i.showLegend??!(!e||n.colorByDepth))&&!(!e||n.colorByDepth)}}},Ty={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(t,e,i,n,r)=>{const s=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),a=r.sourceAccessor||"source",c=r.targetAccessor||"target",l=r.valueAccessor||"value",u=r.nodeIdAccessor||"id",d=r.startTimeAccessor||"startTime",h=r.endTimeAccessor||"endTime",f=r.systemInTimeAccessor,p=r.systemOutTimeAccessor,y=r.xExtentAccessor||"xExtent",g=r.groupBy,m=r.edgeIdAccessor||"id",x=(t,e)=>"function"==typeof t?t(e):e[t],b=Array.isArray(r.edges)?r.edges:[],v=Array.isArray(r.nodes)?r.nodes:[],w=v.length>0?v:di([],b,a,c),k=[s(r.domain?.[0]),s(r.domain?.[1])],A=w.map(t=>{const e=x(u,t)+"",o=x(y,t),i=r.nodeLabel?x(r.nodeLabel,t):e,n={id:e,label:null==i?e:i+"",__raw:t},a=g?x(g,t):null;if(null!=a&&a+""!=""&&(n.group=a+""),Array.isArray(o)&&2===o.length){const t=s(o[0]),e=s(o[1]);Number.isFinite(t)&&Number.isFinite(e)&&(n.xExtent=[t,e])}return n}),S=b.map((t,e)=>{const o=x(m,t),i={id:null!=o?o+"":`${x(a,t)}-${x(c,t)}-${e}`,source:x(a,t)+"",target:x(c,t)+"",value:Number(x(l,t)),startTime:s(x(d,t)),endTime:s(x(h,t)),__raw:t};if(f){const e=s(x(f,t));Number.isFinite(e)&&(i.systemInTime=e)}if(p){const e=s(x(p,t));Number.isFinite(e)&&(i.systemOutTime=e)}return i}),[M,_]=n.size??[600,400],$=n.margin,P="vertical"===r.orientation?"vertical":"horizontal",j=function(t,e,o,i="horizontal"){return"vertical"===i?{top:t?38:e?28:16,right:24,bottom:24,left:o?72:24}:{top:t?30:e?24:8,right:80,bottom:o?28:8,left:80}}(!!n.title,!!r.showQualityReadout,Array.isArray(r.axisTicks)&&r.axisTicks.length>0,P),I={...j,...$},L=(n.showLegend??!!e)&&!!e,R=n.legendPosition??"right";L&&("right"===R?I.right=Math.max(I.right,140):"left"===R?I.left=Math.max(I.left,140):"top"===R?I.top=Math.max(I.top,50):"bottom"===R&&(I.bottom=Math.max(I.bottom,80)));const T=I,C=M-T.left-T.right,O=_-T.top-T.bottom,F=At(i,Zt(n.theme).colors.categorical,Df),D="function"==typeof e?e:null,N=D?w.map(t=>({_cat:D(t)})):w,z=D?"_cat":"string"==typeof e?e:void 0,E=i??[...F],B=z?_t(N,z,E):null,W=new Map;for(const t of A)W.set(t.id,t.__raw);const Y=(t,o)=>{if(e&&W.has(t)){const o=W.get(t);return D?St({_cat:D(o)},"_cat",B??void 0):St(o,"string"==typeof e?e:"id",B??void 0)}return F[o%F.length]},q=o(L&&e?(()=>{const t=new Map;w.forEach((o,i)=>{const n=x(e,o),r=null==n?"":n+"";r&&!t.has(r)&&t.set(r,{label:r,color:Y(x(u,o)+"",i)})});const o=Array.from(t.values());return o.length>0?{legendGroups:[{type:"fill",label:"",items:o,styleFn:t=>{const e=t.color||"#333";return{fill:e,stroke:e}}}]}:void 0})():void 0,n.legend),X=!1!==r.showLabels&&("auto"!==r.showLabels||"auto"),{layout:G,layoutConfig:V,issues:H,xScale:U}=ci({nodes:A,edges:S,domain:k,plotW:C,plotH:O,orientation:P,ribbonLane:r.ribbonLane||"both",ribbonMinRun:"auto"===r.ribbonMinRun||"number"==typeof r.ribbonMinRun?r.ribbonMinRun:0,edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:Y,showLabels:X,styleRules:r.styleRules,colorBy:e,valueAccessor:l,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half",maxValueScale:"number"==typeof r.maxValueScale?r.maxValueScale:void 0,lanePlacement:r.lanePlacement||"stack",nodeSizing:r.nodeSizing||"temporal",groupPadding:"number"==typeof r.groupPadding?r.groupPadding:0}});if(H.length>0){const t=H.map(Ue).join("; ");throw Error("ProcessSankey: data invalid — "+t)}const K=G?function(t){const e=t.layout,o=t.nodes,i=t.orientation,n=t.plotW,r=t.plotH,s=t.timelineExtent,a=t.axisTicks,c=t.showQualityReadout??!1,l=t.showLaneRails??!1,u=(t.warnings??[]).slice(0,3),d=t.timeFormat,h=t.colorOf,f=t.toTime,p=t.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=e;let S=null,M=null;for(const t of o){const e=g[t.id];if(!e||null===e.start||null===e.end)continue;const o=p(e.start),i=p(e.end);(null===S||S>o)&&(S=o),(null===M||i>M)&&(M=i)}const _=t=>Math.max(0,Math.min(s,t)),$=_(S??0),P=Math.max($,_(M??s)),j=a.map((t,e)=>({tick:t,index:e,coordinate:p(f(t.date))})).filter(({coordinate:t})=>t>=$-.5&&P+.5>=t),I=null!==(w??null)&&null!=k&&null!=A,L=c&&(I||u.length>0)?(0,Ay.jsxs)("g",{fill:_y,fontSize:10,textAnchor:"end",children:[I&&(0,Ay.jsxs)(Ay.Fragment,{children:[(0,Ay.jsxs)("text",{x:n,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),(0,Ay.jsxs)("text",{x:n,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),u.map((t,e)=>(0,Ay.jsxs)("text",{x:n,y:I?10+11*e:11*e-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",t]},"warn-"+e))]}):null,R=b?(0,Ay.jsx)("text",{x:n,y:"vertical"===i?-3:2,fontSize:10,fill:_y,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,T=(t,e)=>h?h(t,e):Sy;return(0,Ay.jsxs)("g","vertical"===i?{children:[L,R,j.map(({index:t,coordinate:e})=>(0,Ay.jsx)("line",{x1:0,y1:e,x2:n,y2:e,stroke:Sy,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)),l&&o.map((t,e)=>{const o=g[t.id];if(!o||null===o.start)return null;const i=m[t.id],n=i?{topPeak:i.topPeak,botPeak:i.botPeak}:{topPeak:0,botPeak:0},r=y[t.id]+(n.botPeak-n.topPeak)*x/2,s=p(o.start),a=p(o.end),c=T(t.id,e);return(0,Ay.jsxs)("g",{children:[(0,Ay.jsx)("line",{x1:r,y1:s,x2:r,y2:a,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Ay.jsx)("line",{x1:r-4,y1:s,x2:r+4,y2:s,stroke:c,strokeOpacity:.5}),(0,Ay.jsx)("line",{x1:r-4,y1:a,x2:r+4,y2:a,stroke:c,strokeOpacity:.5})]},"lane-"+t.id)}),(0,Ay.jsx)("line",{x1:-4,y1:$,x2:-4,y2:P,stroke:Sy}),j.map(({tick:t,index:e,coordinate:o})=>{const i=f(t.date),n=null!=t.label?t.label:d?d(new Date(i)):"";return(0,Ay.jsxs)("g",{transform:`translate(-4,${o})`,children:[(0,Ay.jsx)("line",{x2:-6,stroke:Sy}),(0,Ay.jsx)("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:My,children:n})]},e)})]}:{children:[L,R,j.map(({index:t,coordinate:e})=>(0,Ay.jsx)("line",{x1:e,y1:0,x2:e,y2:r,stroke:Sy,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)),l&&o.map((t,e)=>{const o=g[t.id];if(!o||null===o.start)return null;const i=m[t.id],n=i?{topPeak:i.topPeak,botPeak:i.botPeak}:{topPeak:0,botPeak:0},r=y[t.id]+(n.botPeak-n.topPeak)*x/2,s=p(o.start),a=p(o.end),c=T(t.id,e);return(0,Ay.jsxs)("g",{children:[(0,Ay.jsx)("line",{x1:s,y1:r,x2:a,y2:r,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Ay.jsx)("line",{x1:s,y1:r-4,x2:s,y2:r+4,stroke:c,strokeOpacity:.5}),(0,Ay.jsx)("line",{x1:a,y1:r-4,x2:a,y2:r+4,stroke:c,strokeOpacity:.5})]},"lane-"+t.id)}),(0,Ay.jsx)("line",{x1:$,y1:r+4,x2:P,y2:r+4,stroke:Sy}),j.map(({tick:t,index:e,coordinate:o})=>{const i=f(t.date),n=null!=t.label?t.label:d?d(new Date(i)):"";return(0,Ay.jsxs)("g",{transform:`translate(${o},${r+4})`,children:[(0,Ay.jsx)("line",{y2:6,stroke:Sy}),(0,Ay.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:My,children:n})]},e)})]})}({layout:G,nodes:A,orientation:P,plotW:C,plotH:O,timelineExtent:"vertical"===P?O:C,axisTicks:Array.isArray(r.axisTicks)?r.axisTicks.map(t=>({date:t.date,label:t.label})):[],showQualityReadout:!!r.showQualityReadout,showLaneRails:!!r.showLaneRails,timeFormat:"function"==typeof r.timeFormat?t=>r.timeFormat(t):void 0,colorOf:Y,toTime:t=>s(t),xScale:t=>Number(U(t))}):void 0;return{chartType:"force",nodes:w,edges:b,customNetworkLayout:Py,layoutConfig:V,sourceAccessor:a,targetAccessor:c,valueAccessor:l,nodeIDAccessor:u,colorBy:e,colorScheme:i,...K&&{backgroundGraphics:K},...n,showLegend:L,...q&&{legend:q,legendPosition:R},__legendIncludesAutomatic:!0,margin:T}}},Cy={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(t,e,o,i,n)=>{const r=Array.isArray(n.nodes)?n.nodes:di([],Array.isArray(n.edges)?n.edges:[],n.sourceAccessor||"source",n.targetAccessor||"target"),s=Zt(i.theme).colors.categorical,a=new Map,c="string"==typeof e?e:"__ssrSankeyColorBy",l="function"==typeof e?r.map(t=>({...t,__ssrSankeyColorBy:e(t)})):r,u=e?_t(l,c,o??i.colorScheme??s):void 0,d=t=>({fill:e?St(t?.data||t,e,u):be(void 0,s,o,void 0,a),stroke:n.stroke??"black",strokeWidth:n.strokeWidth??1,...void 0!==n.opacity&&{opacity:n.opacity}}),h=Dt(n.styleRules,e,n.valueAccessor),f=h?(t,e)=>({...d(t),...h(t,e)}):d,p=function({edgeColorBy:t,colorBy:e,colorScale:o,nodeStyleFn:i,edgeOpacity:n,baseStyle:r={}}){return s=>{const a={fillOpacity:n,...r};if("function"==typeof t)a.fill=t(s);else if("source"===t){const t="object"==typeof s.source?s.source:null;e&&t?a.fill=St(t.data||t,e,o):t&&(a.fill=i(t,t.index).fill)}else if("target"===t){const t="object"==typeof s.target?s.target:null;e&&t?a.fill=St(t.data||t,e,o):t&&(a.fill=i(t,t.index).fill)}else"gradient"===t&&(a.fill="#999",a.fillOpacity=.7*n);return a}}({edgeColorBy:n.edgeColorBy??"source",colorBy:e,colorScale:u,nodeStyleFn:f,edgeOpacity:n.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{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:jt(n.nodeStyle||f,Ht(n)),edgeStyle:jt(n.edgeStyle||p,Ht(n)),colorScheme:o,...i,showLegend:(i.showLegend??!!e)&&!!e}}},Oy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=Zt(i.theme).colors.categorical,s=new Map,a=ui(t??null,n.childrenAccessor),c="function"==typeof e?e:null,l=c?a.map(t=>({__ssrTreeColorBy:c(t)})):a,u=c?"__ssrTreeColorBy":"string"==typeof e?e:void 0,d=e&&u?_t(l,u,o??i.colorScheme??r):void 0,h=!1!==n.showLabels,f=i.nodeStyle||n.nodeStyle,p=Ft(t=>{const i=t?.data||t;return{fill:n.colorByDepth?cp[Number(t?.depth||0)%cp.length]:e?c?St({__ssrTreeColorBy:c(i)},"__ssrTreeColorBy",d??void 0):St(i,e,d??void 0):be(void 0,r,o,void 0,s),stroke:n.stroke??"black",strokeWidth:n.strokeWidth??1,...void 0!==n.opacity&&{opacity:n.opacity}}},n.styleRules,Rt(e,n.valueAccessor),t=>t?.data||t);return{chartType:"cluster"===n.layout?"cluster":"tree",data:t,childrenAccessor:n.childrenAccessor,colorBy:e,colorByDepth:n.colorByDepth,orientation:n.orientation,showLabels:n.showLabels,nodeLabel:h?n.nodeLabel||n.nodeIdAccessor:void 0,colorScheme:o,...i,showLegend:(i.showLegend??!(!e||n.colorByDepth))&&!(!e||n.colorByDepth),nodeStyle:hi(p,f,Ht(n))}}},Fy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,o,i,n)=>{const r=Zt(i.theme).colors.categorical,s=new Map,a=ui(t??null,n.childrenAccessor),c="function"==typeof e?e:null,l=c?a.map(t=>({__ssrTreemapColorBy:c(t)})):a,u=c?"__ssrTreemapColorBy":"string"==typeof e?e:void 0,d=e&&u?_t(l,u,o??i.colorScheme??r):void 0,h=n.showLabels??i.showLabels,f=n.labelMode,p=void 0!==n.paddingTop?n.paddingTop:i.paddingTop,y=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,g=i.nodeStyle||n.nodeStyle,m=Ft(t=>{const i=t?.data||t;return{fill:n.colorByDepth?cp[Number(t?.depth||0)%cp.length]:e?c?St({__ssrTreemapColorBy:c(i)},"__ssrTreemapColorBy",d??void 0):St(i,e,d??void 0):be(void 0,r,o,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},n.styleRules,Rt(e,n.valueAccessor),t=>t?.data||t);return{chartType:"treemap",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,labelMode:f,nodeLabel:h?n.nodeLabel||n.nodeIdAccessor:void 0,...null!=n.padding&&{padding:n.padding},...null!=y&&{paddingTop:y},colorScheme:o,...i,showLegend:(i.showLegend??!(!e||n.colorByDepth))&&!(!e||n.colorByDepth),nodeStyle:hi(m,g,Ht(n))}}},Dy={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},Ny=require("d3-scale"),zy={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r="string"==typeof o?o:"blues",s=function(t,e,o){if(!Array.isArray(t))return;const i=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let n=1/0,r=-1/0;for(const e of t){const t=i(e);null!=t&&isFinite(t)&&(n>t&&(n=t),t>r&&(r=t))}const s=[Number.isFinite(n)?n:0,Number.isFinite(r)?r:1],a=(0,Ny.scaleSequential)(kt(o)).domain(s);return{domain:s,colorScale:t=>a(t),valueAccessor:i}}(n.areas,n.valueAccessor,r),a=n.areaStyle??function(t,e){if(t)return o=>{const i=t.valueAccessor(o);return{fill:null!=i&&isFinite(i)?t.colorScale(i):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:e}}}(s,n.areaOpacity??1),c=n.styleRules?Ft(a,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},gi):a,l=!1!==i.showLegend&&s?{gradient:{colorFn:s.colorScale,domain:s.domain,label:"string"==typeof n.valueAccessor?n.valueAccessor:"value"}}:void 0;return{areas:n.areas,projection:n.projection||"equalEarth",areaStyle:c,valueAccessor:n.valueAccessor,colorScheme:r,graticule:n.graticule,fitPadding:n.fitPadding,...i,...void 0===i.legend&&l?{legend:l}:{}}}},Ey={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r=t||n.points,s=n.pointStyle??yi(r,e,o,{sizeBy:n.sizeBy,sizeRange:n.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=n.styleRules?Ft(s,n.styleRules,Rt(e,n.sizeBy)):s;return{points:r,xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",areas:n.areas,areaStyle:n.areaStyle||Dy,pointStyle:a,sizeBy:n.sizeBy,colorBy:e,colorScheme:o,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,...i}}},By={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,n)=>{const r=t||n.points,s=n.pointStyle??yi(r,e,o,{pointRadius:"number"==typeof n.pointRadius?n.pointRadius:5,fillOpacity:.85,strokeWidth:1}),a=n.nodeIdAccessor||"id",c=n.cartogramLayout||("sparkline"===n.mode?"strip":"radial"),l="sparkline"===n.mode,u="strip"===c,d=n.styleRules?Ft(s,n.styleRules,Rt(e)):s;return{points:r,lines:n.lines,xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",pointStyle:t=>{const e="function"==typeof d?d(t):d,o="function"==typeof a?a(t):t[a],i=null!=o&&o+""==n.center+"",r="number"==typeof e.r?e.r:5;return{...e,fillOpacity:i?1:e.fillOpacity??.8,stroke:i?"var(--semiotic-text, #222)":e.stroke??"#fff",strokeWidth:i?1.25:e.strokeWidth??1,r:i?1.35*r:r}},colorBy:e,colorScheme:o,projection:n.projection||"mercator",graticule:n.graticule,fitPadding:n.fitPadding,projectionTransform:{center:n.center,centerAccessor:a,costAccessor:n.costAccessor,strength:n.strength??1,lineMode:n.lineMode||"straight",layout:c},...i,cartogramChrome:{showRings:n.showRings??!0,showNorth:n.showNorth??(!u&&!l),showRingLabels:n.showRingLabels??!u,costLabel:n.costLabel}}}},Wy={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,o,i,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],d="function"==typeof l?l:t=>t[l],h=(n.nodes||[]).map(t=>({...t,x:u(t),y:d(t)})),f=new Map;for(const t of h)f.set(t[s]+"",t);const p=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+""),o=f.get(t.target+"");return e&&o?{...t,coordinates:[{x:e.x,y:e.y},{x:o.x,y:o.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?_t(g.map(t=>({[m]:p(t)})),m,o||"category10"):_t(g,p,o||"category10"):null,b=g.map(t=>Number(t[a]??0)).filter(t=>Number.isFinite(t)),v=b.length>0?te(b):void 0,[w,k]=n.edgeWidthRange??[1,8];return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:n.lineType||"geo",flowStyle:n.flowStyle||"basic",areas:n.areas,areaStyle:n.areaStyle||Dy,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,colorScheme:o,lineStyle:pi({valueAccessor:a,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:t=>p&&x?St(t,p,x):"#007bff",edgeOpacity:n.edgeOpacity??.6,edgeLinecap:n.edgeLinecap??"round",styleRules:n.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}},Yy=require("d3-interpolate"),qy=864e5,Xy=t=>{const e=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const i=t=>{const o="function"==typeof e.dateAccessor?e.dateAccessor(t):t[e.dateAccessor];return o instanceof Date?o:new Date(o)},n=t=>{const o="function"==typeof e.valueAccessor?e.valueAccessor(t):t[e.valueAccessor];return Number(o)},r=new Map;let s=null;for(const e of t.data){const t=i(e);if(!isFinite(t.getTime()))continue;null==s&&(s=t.getUTCFullYear());const o=mi(t),a=n(e);r.set(o,(r.get(o)??0)+(Number.isFinite(a)?a:0))}const a=e.year??s??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const t of r.values())c>t&&(c=t),t>l&&(l=t);c===1/0&&(c=0,l=0);const[u,d]=e.colorRamp??[t.theme.semantic.surface??"#ebedf0",t.theme.semantic.primary??"#216e39"],h=t=>{if(l===c)return u;const e=(t-c)/(l-c);return(0,Yy.interpolateRgb)(u,d)(e)},f=e.gutter??2,p=e.labelInset??0,y=Math.min((o.width-p-53*f)/54,(o.height-6*f)/7);if(0>=y)return{nodes:[]};const g=new Date(Date.UTC(a,0,1)),m=g.getUTCDay(),x=new Date(g.getTime()-m*qy),b=[];for(let t=0;54>t;t++)for(let e=0;7>e;e++){const i=new Date(x.getTime()+(7*t+e)*qy);if(i.getUTCFullYear()!==a)continue;const n=mi(i),s=r.get(n),c=null==s?u:h(s);b.push({type:"rect",x:o.x+p+t*(y+f),y:o.y+e*(y+f),w:y,h:y,style:{fill:c,stroke:"none"},datum:{date:i,value:s??0}})}return{nodes:b}},Gy=Wh(require("react")),Vy=require("d3-scale"),Hy=(require("d3-interpolate"),require("react/jsx-runtime")),Uy=t=>{const e=t.config,{plot:o}=t.dimensions,i=e.fields??[];if(2>i.length||0>=o.width||0>=o.height)return{nodes:[]};if(0===t.data.length)return{nodes:[]};const n=Object.create(null);for(const o of i){const i=e.domains&&Object.prototype.hasOwnProperty.call(e.domains,o)?e.domains[o]:void 0;if(Array.isArray(i)&&i.length>=2&&"number"==typeof i[0]&&Number.isFinite(i[0])&&"number"==typeof i[1]&&Number.isFinite(i[1])){n[o]=[i[0],i[1]];continue}let r=1/0,s=-1/0;for(const e of t.data){const t=Number(e[o]);Number.isFinite(t)&&(r>t&&(r=t),t>s&&(s=t))}if(Number.isFinite(r)&&Number.isFinite(s))if(r===s){const t=Math.max(.01*Math.abs(r),.5);n[o]=[r-t,s+t]}else n[o]=[r,s];else n[o]=[0,1]}const r=!1!==e.showAxes,s=r?e.axisLabelPadding??24:8,a=r?18:8,c=i.map(t=>(0,Vy.scaleLinear)().domain(n[t]).range([o.y+o.height-a,o.y+s])),l=i.map((t,e)=>1===i.length?o.x+o.width/2:o.x+e/(i.length-1)*o.width),u=e.colorBy?"function"==typeof e.colorBy?e.colorBy:t=>(t[e.colorBy]??"")+"":null,d=e.opacity??.45,h=e.strokeWidth??1.25,f=t.theme.semantic.primary??"#3b6cb1",p=e.dimmedOpacity??.08,y=e.highlightFn,g=[],m=[];for(const o of t.data){const n=u?t.resolveColor(u(o)+""):f,r=!y||y(o),s=bi(o,{predicate:y,baseOpacity:d,dimOpacity:p,brighten:.4}),a=r?m:g;for(let t=0;i.length-1>t;t++){const e=Number(o[i[t]]),u=Number(o[i[t+1]]);if(!Number.isFinite(e)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[t],y1:c[t](e),x2:l[t+1],y2:c[t+1](u),style:{stroke:n,strokeWidth:y&&r?h+.75:h,opacity:s,fill:"none"},datum:o};a.push(d)}if(e.showPoints)for(let t=0;i.length>t;t++){const e=Number(o[i[t]]);if(!Number.isFinite(e))continue;const r={type:"point",x:l[t],y:c[t](e),r:2.5,style:{fill:n,stroke:"none",opacity:Math.min(1,s+.3)},datum:o};a.push(r)}}let x=null;if(r){const r=`var(--semiotic-border, ${t.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${t.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,h=o.y+s,f=o.y+o.height-a,p=[];for(let t=0;i.length>t;t++){const a=i[t],y=l[t],g=e.tickFormat&&Object.prototype.hasOwnProperty.call(e.tickFormat,a)?e.tickFormat[a]:void 0,m="function"==typeof g?g:t=>t.toLocaleString();p.push(Gy.createElement("line",{key:"pc-axis-line-"+t,x1:y,x2:y,y1:h,y2:f,stroke:r,strokeWidth:1})),p.push(vi({keyId:"pc-axis-label-"+t,text:a,x:y,y:o.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=n[a],v=5;for(let e=0;v>e;e++){const o=x+(b-x)*e/(v-1),i=c[t](o);p.push(Gy.createElement("line",{key:`pc-tick-${t}-${e}`,x1:y-3,x2:y+3,y1:i,y2:i,stroke:r,strokeWidth:1}),vi({keyId:`pc-ticktext-${t}-${e}`,text:m(o),x:y+6,y:i+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Gy.createElement(Gy.Fragment,null,...p)}return{nodes:g.concat(m),overlays:x}},Ky={frameType:"xy",buildProps:(t,e,o,i,n)=>({chartType:"custom",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:o,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...i,showAxes:n.frameProps?.showAxes??n.showAxes??!1,showLegend:i.showLegend??!!e})},Zy={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({chartType:"custom",data:t,oAccessor:n.categoryAccessor||n.oAccessor||"category",rAccessor:n.valueAccessor||n.rAccessor||"value",projection:n.projection||"vertical",colorAccessor:e,colorScheme:o,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...i,showAxes:n.frameProps?.showAxes??n.showAxes??!1})},Qy={frameType:"ordinal",buildProps:(t,e,o,i,n)=>({...Zy.buildProps(t,e,o,i,n),customLayout:Uy,showAxes:!1})},Jy={frameType:"xy",buildProps:(t,e,o,i,n)=>({...Ky.buildProps(t,e,o,i,n),customLayout:Xy,showAxes:!1})},tg=Wh(require("react")),eg=require("d3-scale"),og={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},ig=1e-9,ng=.005,rg=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={...og,...t},this.random=Ri(this.options.seed)}init(t={}){this.options={...og,...t},this.random=Ri(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(ig,t.mass??1),bodyCollisions:t.bodyCollisions??!0,...t.fixedPosition?{fixedPosition:Ci(t.fixedPosition)}:{},shape:Fi(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};Ti(e),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))Ji(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:Di(e.shape),bodyFilter:zi(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,o){const i=this.bodies.get(t);i&&(i.vx+=e/i.mass,i.vy+=o/i.mass,Ti(i),this.wake(i))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const o=this.sortedBodies();for(const t of o)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const i=this.options.maxVelocity;for(const t of o)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,Ti(t),i>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>i){const o=i/e;t.vx*=o,t.vy*=o}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(o),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(o,n,0===t),this.resolveColliders(o,r,0===t);this.updateSensors(o),this.updateSleeping(o,e)}settle(t=1200,e=this.options.fixedDt){let o=0;for(;t>o&&!this.allSleeping();)this.step(e),o+=1;return o}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,...e.fixedPosition?{fixedPosition:Ci(e.fixedPosition)}:{},shape:Fi(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Ji)}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(Ni),colliders:this.sortedColliders().map(Ei),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=Ri(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=Ni(e);Ti(t),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=Ei(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 o=this.bodies.get(e.bodyId);if(!o||o.sleeping)continue;const i="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!i)continue;const n=i.x-o.x,r=i.y-o.y,s=Math.sqrt(n*n+r*r);if(ig>=s)continue;const a=n/s,c=r/s,l=(s-e.restLength)*e.stiffness+((("vx"in i?i.vx:0)-o.vx)*a+(("vy"in i?i.vy:0)-o.vy)*c)*e.damping;o.vx+=l*a*t/o.mass,o.vy+=l*c*t/o.mass}}resolveBodyPairs(t,e,o){for(const i of e){const[e,n]=i.split(":").map(Number),r=t[e],s=t[n];if(!r||!s)continue;const a=Ki(r,s);a&&(this.resolveDynamicCollision(r,s,a),o&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),o=new Map;for(let i=0;t.length>i;i+=1){if(!1===t[i].bodyCollisions)continue;const n=Xi(t[i]),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=o.get(n);r?r.push(i):o.set(n,[i])}}const i=new Set;for(const e of Array.from(o.keys()).sort()){const n=o.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let o=e+1;n.length>o;o+=1){const r=n[e],s=n[o];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&Vi(Xi(t[r]),Xi(t[s]))&&i.add(`${r}:${s}`)}}return Array.from(i).sort((t,e)=>{const[o,i]=t.split(":").map(Number),[n,r]=e.split(":").map(Number);return o===n?i-r:o-n})}resolveDynamicCollision(t,e,o){(t.fixedPosition||e.fixedPosition)&&(!t.sleeping&&null==t.fixedPosition?.x||!e.sleeping&&null==e.fixedPosition?.x?!t.sleeping&&null==t.fixedPosition?.y||!e.sleeping&&null==e.fixedPosition?.y||(o=Oi(t,e,"y")):o=Oi(t,e,"x")),t.sleeping&&this.contactOpposesGravity(o.nx,o.ny)&&this.supportedThisStep.add(e.id),e.sleeping&&this.contactOpposesGravity(-o.nx,-o.ny)&&this.supportedThisStep.add(t.id);const i=t.sleeping?0:1/t.mass,n=e.sleeping?0:1/e.mass,r=null==t.fixedPosition?.x?i:0,s=null==t.fixedPosition?.y?i:0,a=null==e.fixedPosition?.x?n:0,c=null==e.fixedPosition?.y?n:0,l=t.fixedPosition||e.fixedPosition?o.nx**2*(r+a)+o.ny**2*(s+c):i+n;if(ig>=l)return;const u=Math.max(0,o.penetration-ng)/l;t.x-=o.nx*u*r,t.y-=o.ny*u*s,e.x+=o.nx*u*a,e.y+=o.ny*u*c;const d=(e.vx-t.vx)*o.nx+(e.vy-t.vy)*o.ny;if(d>0)return;const h=Math.abs(d),f=-(1+Wi(t.restitution,e.restitution,this.options.restitution))*d/l,p=f*o.nx,y=f*o.ny;t.vx-=p*r,t.vy-=y*s,e.vx+=p*a,e.vy+=y*c,this.applyFriction(t,e,o,f,i,n),h>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,o,i,n,r){const s=-o.ny,a=o.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=null==t.fixedPosition?.x?n:0,u=null==t.fixedPosition?.y?n:0,d=null==e.fixedPosition?.x?r:0,h=null==e.fixedPosition?.y?r:0,f=t.fixedPosition||e.fixedPosition?s**2*(l+d)+a**2*(u+h):n+r;if(ig>=Math.abs(c)||ig>=f)return;const p=Yi(t.friction,e.friction,this.options.friction),y=Bi(-c/f,-i*p,i*p),g=y*s,m=y*a;t.vx-=g*l,t.vy-=m*u,e.vx+=g*d,e.vy+=m*h}resolveColliders(t,e,o){for(const i of t)for(const t of e){if(!en(t,i))continue;if(!Vi(Xi(i),Gi(t)))continue;const e=Zi(i,t);e&&(this.resolveStaticCollision(i,t,e),this.contactOpposesGravity(e.nx,e.ny)&&this.supportedThisStep.add(i.id),o&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,o){t.x+=o.nx*Math.max(0,o.penetration-ng),t.y+=o.ny*Math.max(0,o.penetration-ng);const i=t.vx*o.nx+t.vy*o.ny;if(0>i){const n=Wi(t.restitution,e.restitution,this.options.restitution);t.vx-=(1+n)*i*o.nx,t.vy-=(1+n)*i*o.ny;const r=-o.ny,s=o.nx,a=t.vx*r+t.vy*s,c=Yi(t.friction,e.friction,this.options.friction);t.vx-=a*r*c,t.vy-=a*s*c}Ti(t)}updateSensors(t){const e=new Set,o=this.sortedColliders().filter(t=>t.sensor);for(const i of t){const t=Xi(i);for(const n of o){if(!en(n,i))continue;if(!Vi(t,Gi(n)))continue;if(!Zi(i,n))continue;const o=Qi(n.id,i.id);e.add(o),this.activeSensors.has(o)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:o,bodyId:i}=Ji(t);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:o})}this.activeSensors=e}updateSleeping(t,e){const o=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of t)Math.sqrt(i.vx*i.vx+i.vy*i.vy)>=this.options.sleepSpeed||Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY))>=this.options.sleepSpeed*e||o&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=e,i.sleeping||this.options.sleepAfter>i.sleepTime||(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}contactOpposesGravity(t,e){const{x:o,y:i}=this.options.gravity,n=Math.hypot(o,i);return 1e-9>=n||-.2>(t*o+e*i)/n}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},sg=class{constructor(t={}){this.id="builtin",this.capabilities={...(new rg).capabilities,engine:"builtin"},this.world=new rg(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,o){this.world.applyImpulse(t,e,o)}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()}},ag=["binId","targetBin","category","windowIndex","lane","group"],cg=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 o=ln(cn(this.config.binAccessor,t,e))??function(t){for(const e of ag){const o=ln(an(t,e));if(o)return o}return"sediment"}(t),i=ln(cn(this.config.labelAccessor,t,e))??o,n=function(t,e,o){if("number"==typeof t)return t;const i="function"==typeof t?t(e,o):"string"==typeof t?an(e,t):1,n="number"==typeof i?i:Number(i);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(o);return s||(s={id:o,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(o,s)),s.label=i,s.lastBodyId=t.id,s.lastDatum=t.datum,nn(s.x,t.x),nn(s.y,t.y),nn(s.value,n),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),un(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(un)}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:sn(e.x),y:sn(e.y),value:sn(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)}}},lg={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},ug={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},dg={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},hg=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=_n({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 o=_n(t,e,this.revisions);this.revisions=o.revisions,this.latest=o;for(const t of[...this.listeners])t();return o}},fg=require("d3-quadtree"),pg=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,o,i,n,r=0,s){const a=this.ensure(t,e);if(!a)return null;let c=null,l=1/0;const u=Math.max(0,s?.searchRadius??Math.max(0,r)+this.maxSearchRadius),d=i-u,h=i+u,f=n-u,p=n+u;return a.visit((t,e,a,u,y)=>{if(d>u||e>h||f>y||a>p)return!0;if(t.length)return!1;let g=t;for(;g;){const t=g.data;if(t&&(!s?.include||s.include(t))){const e=s?.distanceSquared?s.distanceSquared(t,i,n):wn(t,i,n,Math.max(0,r));null!=e&&(l>e||e===l&&o.indexOf(t.id)>o.indexOf(c?.id??""))&&(c=t,l=e)}g=g.next}return!1}),c}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const o=t.readState();return 0===o.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=o.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,fg.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o),this.revision=e,this.tree)}},yg=["data","scene-geometry","data-paint","accessibility","evidence"],gg=["scene-geometry","data-paint","accessibility","evidence"],mg=["overlay","accessibility","evidence"],xg=(t,e)=>({retainedData:t,invalidations:e}),bg=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],vg=["scene-geometry","data-paint","accessibility","evidence"],wg=[],kg={engine:xg("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:xg("preserve",vg),colliders:xg("preserve",vg),sediment:xg("preserve",vg),bodyBudget:xg("preserve",bg),bodyLimit:xg("preserve",bg),eviction:xg("preserve",bg),fixedDt:xg("preserve",wg),maxDeltaSeconds:xg("preserve",wg),maxSubsteps:xg("preserve",wg),settleStepLimit:xg("preserve",wg),timeScale:xg("preserve",wg),observation:xg("preserve",wg)},Ag=xg("preserve",bg),Sg=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],Mg=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(t){this.speed=function(t){const e=t?.sleepSpeed;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:8}(t)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(t,e,o){if(o>0)return void(this.seconds=0);const i=t.readState(this.scratch),n=this.speed*this.speed;let r=!0;for(const t of i)if(!t.sleeping&&t.vx*t.vx+t.vy*t.vy>=n){r=!1;break}this.seconds=r?this.seconds+Math.max(0,e):0}},_g=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new pg,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new hg,this.simulationState="settled",this.visible=!0,this.quiescence=new Mg;const{bodyBudget:e,colliders:o,engine:i,kernel:n,observation:r,sediment:s,...a}=t;this.config={...lg,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=i,this.observation=hn(r),this.sediment=new cg(s??!1),this.world=on(i,{fixedDt:this.config.fixedDt,...n}),this.quiescence.setKernelOptions(n),o&&this.world.setColliders(mn(o))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(o=>"kernel"===o?!Pn(t.kernel,e.kernel):t[o]!==e[o])}(t,this.configInput),{colliders:o,bodyBudget:i,engine:n,kernel:r,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=on(n,t.options),this.world.restore(t),this.revision+=1}if(r&&!Pn(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.quiescence.setKernelOptions(e),this.revision+=1}s&&(this.observation=hn(s,this.observation)),this.sediment.updateConfig(a),o&&(this.world.setColliders(mn(o)),this.revision+=1),this.configInput={...this.configInput,...t};const l=$n(e);this.updateResults.record({kind:"config",keys:e},l.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(mn(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},$n(["colliders"]).invalidations)}enqueue(t,e){const o=Array.isArray(t)?t:[t],i=e?function(t,e={}){const o=pn(e.startAt)??0,i=e.pacing??"immediate";if("arrival"===i){const i=t.map((t,o)=>function(t,e,o){return"function"==typeof o?pn(o(t,e)):"string"==typeof o?pn(yn(t,o)):pn(t.spawnAt)??pn(yn(t,"arrivalTime"))??pn(yn(t,"timestamp"))??pn(yn(t,"time"))??pn(yn(t,"eventTime"))}(t,o,e.timeAccessor)),n=i.filter(t=>null!=t),r=n.length>0?Math.min(...n):0,s=pn(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const n=i[e],s=null==n?0:Math.max(0,n-r);return{...fn(t),spawnAt:o+s/a}})}if("object"==typeof i){const e=pn(i.ratePerSec);if(e&&e>0)return t.map((t,i)=>({...fn(t),spawnAt:o+i/e}))}return t.map(t=>({...fn(t),spawnAt:o}))}(o,{...e,startAt:e.startAt??this.elapsedSeconds}):o;for(const t of i)this.queue.push({...fn(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(bn),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?yg:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(fn(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},yg)}materializeDueSpawns(){const t=this.revision,e=[],o=[];return this.spawnDue(e,o),0===e.length||(this.observeBodyBudget(o),this.evictOverflow(o),this.syncSimulationState(o),this.revision+=1,this.updateResults.record({kind:"enqueue",count:e.length},this.revision!==t?yg:[])),e}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.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},yg)}tick(t,e){const o=this.revision,i=[],n=[],r=[],s=[],a=[];if(this.paused||!this.visible){const t=this.result(0,i,n,r,s,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const c=Math.max(0,Math.min(Number.isFinite(t)?t:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(i,a);const l=this.observeBodyBudget(a),u=this.evictOverflow(a);n.push(...u.evicted),r.push(...u.sedimented),this.syncSimulationState(a),i.length>0&&this.quiescence.reset(),this.accumulator+=c;const d=this.stepObserver(e,{spawned:i,evicted:n,sedimented:r,events:s,observations:a}),h=c>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:f,budget:p}=In(this.settleHost(),Math.min(h,this.config.maxSubsteps),{spawned:i,evicted:n,sedimented:r,events:s,observations:a},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:d});this.accumulator=Math.max(0,this.accumulator-f*this.config.fixedDt),f===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(f>0||i.length>0||n.length>0||r.length>0||s.length>0)&&(this.revision+=1);const y=this.result(f,i,n,r,s,a,void 0,p??l);return this.updateResults.record({kind:"tick",count:f},this.revision!==o?i.length||n.length||r.length?yg:gg:[]),y}settle(t=this.config.settleStepLimit){return this.runSettle(t,!1).steps}settleWithObservations(t=this.config.settleStepLimit,e){return this.runSettle(t,!0,e)}stepObserver(t,e){return function(t,e){if(!t)return;const o=["spawned","evicted","sedimented","events","observations"],i={spawned:0,evicted:0,sedimented:0,events:0,observations:0},n=n=>{const r=e(n),s={...r,spawned:r.spawned.slice(i.spawned),evicted:r.evicted.slice(i.evicted),sedimented:r.sedimented.slice(i.sedimented),events:r.events.slice(i.events),observations:r.observations.slice(i.observations)};for(const t of o)i[t]=r[t].length;t.onStep(s)};return n(0),()=>n(1)}(t,t=>(t&&(this.revision+=1),this.result(t,e.spawned,e.evicted,e.sedimented,e.events,e.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:t=>{this.elapsedSeconds+=t},spawnDue:(t,e)=>this.spawnDue(t,e),observeBodyBudget:t=>this.observeBodyBudget(t),evictOverflow:t=>this.evictOverflow(t),step:t=>this.world.step(t),drainEvents:()=>this.world.events(),observeKernelEvents:(t,e)=>this.observeKernelEvents(t,e),observeSensorTransitions:t=>this.observeSensorTransitions(t),refreshQuiescence:(t,e)=>this.quiescence.refresh(this.world,t,e)}}runSettle(t,e,o){const i=this.revision,n=[],r=[],s=[],a=[],c=e?[]:void 0;if(e&&(this.paused||!this.visible)){const t=this.result(0,n,r,s,a,c??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(n,c);const l=this.observeBodyBudget(c),u=this.evictOverflow(c);r.push(...u.evicted),s.push(...u.sedimented),this.syncSimulationState(c),n.length>0&&this.quiescence.reset();const d=e?{spawned:n,evicted:r,sedimented:s,events:a,observations:c}:{spawned:n},h=this.stepObserver(o,{spawned:n,evicted:r,sedimented:s,events:a,observations:c??[]}),{steps:f,budget:p}=In(this.settleHost(),t,d,{afterStep:h,continueWhile:o?.continueWhile,shouldStop:e?()=>this.paused||!this.visible:void 0}),y=n.length+r.length+s.length>0;(f>0||y||a.length>0)&&(this.revision+=1);const g=this.result(f,n,r,s,a,c??[],void 0,p??l);return this.updateResults.record({kind:"settle",count:f},this.revision===i?[]:y?yg:gg),g}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:o=0,binWidth:i=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*(i+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:o-l,width:i,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,o=0,i){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,o,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:o,chartId:i,...n}=t,r={...n,timestamp:e??this.elapsedSeconds,chartType:o??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}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?mg:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?mg:[])}remove(t){const e=new Set(t),o=new Set(this.liveBodyOrder),i=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>o.has(t)||i.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?yg:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},gg),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},gg)}applyImpulse(t,e,o){this.world.applyImpulse(t,e,o),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},gg)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,o,i)=>t.applyImpulse(e,o,i),clear:()=>t.clear(),hitTest:(e,o,i)=>t.hitTest(e,o,i),pause:()=>t.setPaused(!0),push:(e,o)=>t.enqueue(e,o),pushMany:(e,o)=>t.enqueue(e,o),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:xn(this.bodyBudget),config:{...this.config,kernel:vn(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(gn),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){const e=this.simulationState;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:xn(t.bodyBudget??{}),kernel:vn(t.world.options)},this.bodyBudget=xn(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(t.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(gn).sort(bn),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??jn(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"},yg),this.simulationState!==e&&this.observation.onSimulationStateChange?.(this.simulationState,e)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds+1e-9*this.config.fixedDt>=this.queue[0].spawnAt;){const o=this.queue.shift();if(!o)return;this.spawnOne(o,e),t.push(o.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 o=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:o?.datum??t.datum,x:o?.x??t.x,y:o?.y??t.y},e)}result(t,e,o,i,n,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:o,events:n,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:c,sedimented:i,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,o){if(0===e.length)return;const i=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=i.get(t.bodyId);o.emit({type:"physics-settle",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.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,o){const i=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===i.size&&0===e.size)return i;const n=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:i,bodyId:r}=kn(e),s=o.observation.sensors[i],a=n.get(r);o.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:s?.binId??i})};for(const t of Array.from(i).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())i.has(t)||r("exit",t);return i}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const o of t)e.has(kn(o).bodyId)&&t.delete(o)}(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)),o=Math.max(0,Math.floor(t.queuedBodies??0)),i=e+o,n=dn(t.bodyLimit),r=dn(t.engineMaxBodiesHint),s=function(t,e,o){if(!1===o)return;const i=dn(o?.warnAt);return null!=i?i:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,r,t.options),a=null==n?0:Math.max(0,e-n),c=a>0?"overflow":null==s||s>i?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:i,queuedBodies:o,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 o=`${e.state}:${e.action}`;return o===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=o,function(t,e){e.emit({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:e.elapsedSeconds,chartType:e.observation.chartType,chartId:e.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,this.observationContext(t))),e}syncSimulationState(t){const e=jn(this.paused,this.visible,this.queue.length>0,this.atRest());if(e===this.simulationState)return;const o=this.simulationState;this.simulationState=e,function(t,e,o){o.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||o.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,simulationState:e,previousSimulationState:t})}(o,e,this.observationContext(t))}evictOverflow(t){const{evicted:e,sedimented:o,liveBodyOrder:i}=function(t,e,o,i,n,r){const s={evicted:[],sedimented:[],liveBodyOrder:n};if(!1===o)return s;const a=Math.max(0,Math.floor(i));if(!Number.isFinite(a))return s;const c=n.length-a;if(0>=c)return s;const l=function(t,e,o){if("sleeping-first"!==e)return o.slice();const i=new Map(t.readState().map(t=>[t.id,t.sleeping])),n=[],r=[];for(const t of o)i.get(t)?n.push(t):r.push(t);return[...n,...r]}(t,o,n),u=l.slice(0,c);if(0===u.length)return s;const d=function(t,e,o,i){const n=new Map(t.readState().map(t=>[t.id,t])),r=[];for(const t of o){const o=n.get(t);if(!o)continue;const s=e.add(o);s&&(r.push(t),i.emit({type:"physics-sediment",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t,datum:o.datum,x:o.x,y:o.y,binId:s.id,count:s.count,total:s.total}))}return r}(t,e,u,r);t.remove(u);const h=new Set(u);return{evicted:u,sedimented:d,liveBodyOrder:n.filter(t=>!h.has(t))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(t));return e.length>0&&(this.liveBodyOrder=i,this.removeActiveSensorPairsForBodies(new Set(e))),{evicted:e,sedimented:o}}},$g=require("d3-scale"),Pg=require("d3-scale"),jg=require("d3-scale"),Ig="gauntlet-negative",Lg={left:28,top:76,rightInset:30,thickness:8},Rg=1e-9,Tg=[900,520],Cg=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Og=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Fg=1e-9,Dg=Yr,Ng=Wh(require("react")),zg=require("d3-shape"),Eg=require("react/jsx-runtime"),Bg=require("react/jsx-runtime"),Wg="var(--semiotic-text, #26323a)",Yg="var(--semiotic-text-secondary, #6c7377)",qg="var(--semiotic-primary, #b8792d)",Xg="var(--semiotic-danger, #9f3d35)",Gg="var(--semiotic-success, #356b63)",Vg=require("react/jsx-runtime"),Hg=require("react/jsx-runtime"),Ug={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},Kg=require("react/jsx-runtime"),Zg=require("react/jsx-runtime"),Qg=require("react/jsx-runtime"),Jg={margin:(t,e)=>e.compactMode?"sparkline"===t.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}},tm=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],em={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,400],s=n.bins??21,a=n.seed??1,c=Math.max(1,Math.round(n.pegRows??s-1)),l="mechanical"===(n.simulationMode??n.mode),u=l?function(t){const e=Math.max(2,Math.round(t.bins)),o=Math.max(1,Math.round(t.pegRows??e-1)),i=Math.max(1,Math.round(t.count??Math.max(64,4*e))),n=$i(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=Ii(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:i},(t,e)=>{let i=0;for(let t=0;o>t;t+=1)r()<n&&(i+=1);const a=o/2;return{id:`${s}-${e}`,value:i,mechanical:!0,pegRows:o,branchProbability:n,pathRights:i,side:a>i?"left":i>a?"right":"center"}})}({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:a}):Array.isArray(t)?t:[],d=function(t){const{data:e,valueAccessor:o,bins:i,ballRadius:n,seed:r,size:s,valueExtent:a}=t,{rows:c}=Li(e,"galton"),l=wi(s),u=c.map((t,e)=>_i(Mi(t,e,o))).filter(t=>null!=t),d=function(t){if(!t)return;const e=_i(t[0]),o=_i(t[1]);return null!=e&&null!=o?e>o?[o,e]:[e,o]:void 0}(a),h=d?.[0]??(u.length?Math.min(...u):0),f=d?.[1]??(u.length?Math.max(...u):1),p=f===h?1:f-h,y=(0,eg.scaleLinear)().domain([0,i]).range([l.plot.x,l.plot.x+l.plot.width]),g=Array.from({length:i},()=>0),m=[];c.forEach((t,e)=>{const r=_i(Mi(t,e,o));if(null==r)return;const s=Math.max(0,Math.min(i-1,Math.floor((r-h)/p*i)));g[s]+=1,m.push({id:(t.id??"galton-"+e)+"",x:y(s+.5),y:l.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 x=l.plot.y+l.plot.height;return{config:Si(r,[...An({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Sn({idPrefix:"galton-bin",count:i,domainStart:0,domainStep:1,xScale:y,yTop:l.plot.y-400,yBottom:x,wallThickness:6})],"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:g.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:i,plot:l.plot,valueExtent:[h,f]}}}({data:u,valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??("sparkline"===n.mode?1.5:"context"===n.mode?4:6),seed:a,size:r,valueExtent:l?[0,c]:n.valueExtent});return{...i,config:d.config,initialSpawns:ws(d.initialSpawns),projectionRows:d.projectionRows,foregroundGraphics:ks(rs(d.projectionRows,s,As(i,n,"showProjection"),d.metadata,n.referenceLines),i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},om={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,400],s=function(t){const{data:e,timeAccessor:o,arrivalAccessor:i,windows:n,watermark:r,watermarkAtArrivalAccessor:s,ballRadius:a,seed:c,size:l,timeExtent:u,timeScale:d=1}=t,{events:h,watermarkValue:f}=function(t){const{windowSize:e,watermark:o,watermarkAtArrivalAccessor:i}=t;if(!Number.isFinite(e)||0>=e)throw new RangeError("EventDrop windows.size must be a finite positive number");const{rows:n}=Li(t.data,"event"),r=n.flatMap((e,o)=>{const i=_i(Mi(e,o,t.timeAccessor));return null==i?[]:[{datum:e,index:o,eventTime:i,arrivalTime:_i(Mi(e,o,t.arrivalAccessor))??i,watermarkAtArrival:0,late:!1}]}),s="function"==typeof o?null:_i(o?.value),a="function"==typeof o?e:_i(o?.delay)??e;let c=-1/0,l=-1/0;for(const t of r.slice().sort((t,e)=>t.arrivalTime-e.arrivalTime||t.index-e.index)){c=Math.max(c,t.eventTime);const n="function"==typeof o?_i(o(c)):c-a;l=s??Math.max(l,n??c-e);const r=i?_i(Mi(t.datum,t.index,i)):null;t.watermarkAtArrival=r??l,t.late=t.watermarkAtArrival>=(Math.floor(t.eventTime/e)+1)*e}return{events:r,watermarkValue:r.length?l:s??-a}}({data:e,timeAccessor:o,arrivalAccessor:i,watermark:r,watermarkAtArrivalAccessor:s,windowSize:n.size}),p=wi(l),y=h.map(t=>t.eventTime),g=h.length?Math.min(...h.map(t=>t.arrivalTime)):0,m=_i(u?.[0]),x=_i(u?.[1]),b=y.length?Math.min(...y):0,v=y.length?Math.max(...y):b+n.size,w=Math.min(m??b,b),k=Math.max(x??v,v),A=Math.floor(w/n.size)*n.size,S=Math.max(1,Math.ceil((k-A+n.size)/n.size)),M=Math.max(0,Math.min(S,Array.from({length:S},(t,e)=>e).reduce((t,e)=>A+(e+1)*n.size>f?t:t+1,0))),_=function(t,e){const o=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:o,height:t.plot.height},windowPlot:{x:t.plot.x+o,y:t.plot.y,width:Math.max(40,t.plot.width-o),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(p,a),$=A+S*n.size,P=(0,$g.scaleLinear)().domain([A,$]).range([_.windowPlot.x,_.windowPlot.x+_.windowPlot.width]),j=Array.from({length:S},()=>({value:0,secondary:0})),I=[];h.forEach(({datum:t,index:e,eventTime:o,arrivalTime:i,watermarkAtArrival:r,late:s})=>{const c=Math.max(0,Math.min(S-1,Math.floor((o-A)/n.size)));j[c].value+=s?0:1,j[c].secondary+=s?1:0,I.push({id:(t.id??"event-"+e)+"",x:Rn(o,c,s,{windowStart:A,windowSize:n.size,gutter:_.gutter,closedWindowCount:M,windowPlot:_.windowPlot,windowCount:S},a),y:p.plot.y+a+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:i,shape:{type:"circle",radius:a},datum:{...t,eventTime:o,arrivalTime:i,windowIndex:c,watermarkAtArrival:r,late:s}})});const L=p.plot.y+p.plot.height,R={closedWindowCount:M,gutter:_.gutter,plot:p.plot,windowCount:S,windowPlot:_.windowPlot,windowSize:n.size,windowStart:A},T=function(t,e){const o=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!o)return[];const i=t.windowStart,n=t.windowStart+t.windowCount*t.windowSize,r=(0,$g.scaleLinear)().domain([i,n]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+o*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;o>e;e+=1){const o=t.windowStart+e*t.windowSize,i=o+t.windowSize,n=r(o),s=r(i);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:n,y1:l(n),x2:s,y2:l(s)})}return u}(R,p.plot.y+.28*p.plot.height);for(const t of I){const e=t.datum;t.y=Ln({...R,lidSegments:T},e.windowIndex,e.late,a)}const C=function(t){const{count:e,idPrefix:o,wallThickness:i,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:`${o}-wall-${e}`,shape:{type:"aabb",x:n(e),y:c+l/2,width:i,height:l}}})}({idPrefix:"eventdrop-window",count:S,xScale:t=>P(A+t*n.size),yTop:_.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>M)return null;const e=0===t?T[0]?.y1:T[t-1]?.y2??T[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?_.wallTop:e+1.25*a},yBottom:L,wallThickness:6});return{config:Si(c,[...An({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...C,...T.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*a)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:I,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>{const e=t.datum,o=M>e.windowIndex;return o&&!e.late||!o&&e.late?g:e.arrivalTime},timeScale:d},projectionRows:j.map((t,e)=>({label:`${A+e*n.size}-${A+(e+1)*n.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:M,gutter:_.gutter,lidSegments:T,lateCount:j.reduce((t,e)=>t+e.secondary,0),plot:p.plot,windowPlot:_.windowPlot,windowWalls:C.map(({id:t,shape:e})=>({id:t,x:e.x-e.width/2,y:e.y-e.height/2,width:e.width,height:e.height})),watermarkValue:f,windowCount:S,windowSize:n.size,windowStart:A}}}({data:Array.isArray(t)?t:[],timeAccessor:n.timeAccessor||"time",arrivalAccessor:n.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:n.watermarkAtArrivalAccessor,windows:n.windows||{size:10},watermark:n.watermark,ballRadius:n.ballRadius??7,seed:n.seed??1,size:r,timeExtent:n.timeExtent,timeScale:n.timeScale??1});return{...i,config:s.config,initialSpawns:ws(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ks(ss(s.projectionRows,s.metadata,As(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||n.timeAccessor||"time"})}}},im={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,400],s="mechanical"===(n.simulationMode??n.mode),a=function(t){function e(t){let e=f.get(t);return null==e&&(e=h.length,h.push(t),f.set(t,e)),e}const{data:o,categoryAccessor:i,valueAccessor:n,unitValue:r,ballRadius:s,seed:a,size:c}=t,l=Pi(r,1),{rows:u}=Li(o,"pile"),d=wi(c),h=[],f=new Map,p=new Map,y=[];u.forEach((t,o)=>{e((Mi(t,o,i)??"unknown")+"")});const g=Math.max(1,h.length),m=Tn(d.plot,g,s),x=Math.max(0,m.tubeWidth/2-s-1),b=h.map(()=>[]);u.forEach((t,o)=>{const r=(Mi(t,o,i)??"unknown")+"",a=e(r),c=n?_i(Mi(t,o,n)):1,u=Math.max(0,c??0);p.set(r,(p.get(r)??0)+u);const h=function(t,e){const o=t/e,i=Math.round(o);return Math.ceil(i>0&&Number.EPSILON*o*4>=Math.abs(o-i)?i:o)}(u,l),f=m.centerX(a);for(let e=0;h>e;e+=1){const i=b[a].length,n=e===h-1?u-e*l:l,c=Math.min(1,n/l);b[a].push({id:`${(t.id??"pile-"+o)+""}-${e}`,x:f+(m.perRow>1?((m.perRow>1?i%m.perRow:0)/(m.perRow-1)*2-1)*x:0),y:d.plot.y+s+2,vx:(e%3-1)*s/2,vy:0,mass:1,shape:{type:"circle",radius:s*Math.sqrt(c)},datum:{...t,category:r,unitIndex:e,unitValue:l,representedValue:n,unitFraction:c}})}});const v=b.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;v>t;t+=1)for(const e of b)e.length>t&&y.push(e[t]);const w=d.plot.y+d.plot.height,k=[...An({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let t=0;g>t;t+=1){const e=m.centerX(t);for(const o of[-1,1])k.push({id:`pile-tube-${t}-${0>o?"l":"r"}`,shape:{type:"aabb",x:e+o*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:Si(a,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(t=>({label:t,value:p.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),o=e.length?e:["Intake"],i=Math.max(o.length,Math.round(t.count??Math.max(48,12*o.length))),n=Pi(t.unitValue,1),r=Ii(t.seed??1),s=t.idPrefix??"mechanical-pile",a=o.map(()=>.65+.9*r()),c=a.reduce((t,e)=>t+e,0)||1,l=i-o.length,u=a.map(t=>t/c*l),d=u.map(t=>1+Math.floor(t));let h=i-d.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;h>0;t=(t+1)%f.length)d[f[t].index]+=1,h-=1;return o.map((t,e)=>({id:`${s}-${e}`,category:t,value:d[e]*n,mechanical:!0,unitCount:d[e],unitValue:n,share:d[e]/i}))}({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??8,seed:n.seed??1,size:r});return{...i,config:a.config,initialSpawns:ws(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:ks(as(a.projectionRows,n.ballRadius??8,As(i,n,"showProjection"),Number.isFinite(n.unitValue)&&n.unitValue>0?n.unitValue:1),i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},nm={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[600,360],s=function(t){const{data:e,xAccessor:o,groupAccessor:i,radiusAccessor:n,pointRadius:r,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,{rows:d}=Li(e,"collision-swarm"),h=wi(a),f=Ii(s),p=[],y=[],g=new Map;d.forEach((t,e)=>{const s=_i(Mi(t,e,o));if(null==s)return;const a=i?(Mi(t,e,i)??"All")+"":"All",c=n?_i(Mi(t,e,n)):null,l=$i(null!=c&&c>0?c:r,2,18);!function(t){let e=g.get(t);null==e&&(e=y.length,y.push(t),g.set(t,e))}(a),p.push({datum:t,index:e,value:s,group:a,radius:l})});const m=p.map(t=>t.value),x=c?_i(c[0]):null,b=c?_i(c[1]):null,v=m.length?Math.min(...m):0,w=m.length?Math.max(...m):1;let k=x??v,A=b??w;if(k===A&&(k-=.5,A+=.5),k>A){const t=A;A=k,k=t}const S=Math.max(r,...p.map(t=>t.radius)),M=h.plot.x+S+8,_=h.plot.x+h.plot.width-S-8,$=(0,Pg.scaleLinear)().domain([k,A]).range([M,_]),P=h.plot.height/Math.max(1,y.length),j=Math.min(6,.05*P),I=t=>h.plot.y+((g.get(t)??0)+.5)*P,L=new Map,R=new Set,T=new Map;for(const t of y){const e=p.filter(e=>e.group===t),o=I(t),i=e.map(t=>({x:$(t.value),radius:t.radius})),n=Cn(i,o-P/2+j,o+P/2-j,f);L.set(t,e.length),n.overlapping&&R.add(t),e.forEach((t,e)=>T.set(t.index,{x:i[e].x,y:n.positions[e],entryOffset:n.entryOffset}))}const C=p.map((t,e)=>{const o=T.get(t.index),i=o.x,n=o.y,r=R.has(t.group);return{id:(t.datum.id??"collision-swarm-"+e)+"",x:i,y:n-(u?0:o.entryOffset),vx:0,vy:0,fixedPosition:{x:i},bodyCollisions:!r,mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:i,targetY:n,overlapping:r},springs:[{target:{type:"point",x:i,y:n},restLength:0,stiffness:34,damping:12}]}});return{config:Si(s,An({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:C,projectionRows:y.map(t=>({label:t,value:L.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[k,A],xRange:[M,_],groups:y.map(t=>({label:t,y:I(t),count:L.get(t)??0,overlapping:R.has(t)})),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{...i,config:s.config,initialSpawns:ws(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ks(ls(s.metadata,As(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy||n.groupAccessor,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.xAccessor||"x"})}}},rm={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[900,420],s=Array.isArray(n.stages)?n.stages:[],a=function(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const o=t.size,i=wi(o),n=$i(t.ballRadius??6,2,18),r=t.seed??1,s=Ii(r),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,d=t.workAccessor,h=t.radiusAccessor,f=t.groupCompletion??(l?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",o=Math.max(1,Math.round(t.width)),i=Math.max(1,Math.round(t.height)),n=t.padX??46,r=t.padY??72,s=n,a=o-n,c=r,l=i-Math.max(24,Math.round(.45*r)),u=(c+l)/2,d=Math.max(1,l-c),h=Bn(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Bn(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,A=t.stages;if(!A.length)throw Error("processStageLayout requires at least one stage");const S=Bn(t.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(A),_=a-s;let $=s;const P=A.map((t,e)=>{const o=$,i=e===A.length-1?a:$+(t.share??1)/M*_;return $=i,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:o,x1:i,x:(o+i)/2,width:i-o,y:u,height:d}}),j=P[S],I=j.x0,L=j.x1,R=(t,o)=>{if("lane"===e)return"top"===o?c:l;if("funnel"===e){const e=Bn((t-s)/Math.max(1,a-s),0,1);return"top"===o?c+(m-c)*e:l+(x-l)*e}if(I>=t){const e=Bn((t-s)/Math.max(1,I-s),0,1);return"top"===o?c+(m-c)*e:l+(x-l)*e}if(L>=t)return"top"===o?m:x;const i=Bn((t-L)/Math.max(1,a-L),0,1);return"top"===o?m+(c-m)*i:x+(l-x)*i},T=P.map(t=>{const e=Math.min(R(t.x0,"top"),R(t.x1,"top")),o=Math.max(R(t.x0,"bottom"),R(t.x1,"bottom"));return{...t,y:(e+o)/2,height:Math.max(1,o-e)}}),C={thickness:k,friction:v,restitution:w},O=[];"lane"===e?O.push(Wn(b+"-top",s,c,a,c,C),Wn(b+"-bottom",s,l,a,l,C),Wn(b+"-left",s,c,s,l,{...C,thickness:Math.max(6,k-2)}),Wn(b+"-right",a,c,a,l,{...C,thickness:Math.max(6,k)})):"funnel"===e?O.push(Wn(b+"-top",s,c,a,m,C),Wn(b+"-bottom",s,l,a,x,C),Wn(b+"-left",s,c,s,l,{...C,thickness:Math.max(6,k-2)}),Wn(b+"-right",a,m,a,x,{...C,thickness:Math.max(6,k)})):O.push(Wn(b+"-left-top",s,c,I,m,C),Wn(b+"-left-bottom",s,l,I,x,C),Wn(b+"-center-top",I,m,L,m,C),Wn(b+"-center-bottom",I,x,L,x,C),Wn(b+"-right-top",L,m,a,c,C),Wn(b+"-right-bottom",L,x,a,l,C),Wn(b+"-left",s,c,s,l,{...C,thickness:Math.max(6,k-2)}),Wn(b+"-right",a,c,a,l,{...C,thickness:Math.max(6,k)}));const F=t.membraneDampingScale??.5,D=s,N=Math.max(1,("bowtie"===e?I:a)-D),z=(t.membranes??[]).map(t=>{const e=D+Bn(t.offset,0,1)*N,o=t.width??18+18*t.cost,i=d-16,n=u+.25*(t.wobble??0);return{...t,x:e,y:n,width:o,height:i}}),E=!1===t.includeMembraneRegions?[]:z.map(t=>function(t){const e=t.dampingScale??.5,o=t.energyScale??1,i=Bn(t.cost,0,2);return{...Yn({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:i,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i*e,energyDelta:-i*o}}({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??F,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:o,height:i,padX:n,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:I,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:T,membranes:z,colliders:O,regionEffects:E,boundaryY:R}}({width:o[0],height:o[1],shape:"lane",padX:Math.max(28,i.plot.x),padY:Math.max(36,i.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],A=new Set(e.filter(t=>t.absorb).map(t=>t.id)),S=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const o={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{...Yn({...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"}}({...o,kind:t.kind??"sink",force:Xn(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...o.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return i={...o,kind:t.kind??"force-field",force:Xn(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...o.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Yn({...i,kind:i.kind??"force-field",attributes:{primitive:"portal",targetStage:i.targetStage,..."object"==typeof i.attributes&&i.attributes?i.attributes:{}}}),force:i.force,impulseOnEnter:i.impulseOnEnter,damping:i.damping??.08}}var i;if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Yn({...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}}({...o,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Xn(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...o.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,o=t.baseDamping??.08,i=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Yn({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o+e*i,energyDelta:n?-e*n:void 0,force:t.force}}({...o,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:Xn(t.force,8),attributes:{...o.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?qn({...o,kind:t.kind??"force-field",force:Xn(t.force,14),damping:t.damping??.02,attributes:{...o.attributes,primitive:"routeSurface"}}):function(t){return{...Yn({...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}}({...o,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...o.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});S.unshift(qn({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 o=(a?Mi(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",i=(Mi(t,e,c)??w)+"",r=b.has(i)?i:w;M.set(r,(M.get(r)??0)+1);const s=l?(Mi(t,e,l)??"")+"":void 0,f=s&&u?(Mi(t,e,u)??s)+"":s,p=d?_i(Mi(t,e,d))??1:1,y=h?_i(Mi(t,e,h)):null,g=$i(null!=y&&y>0?y:n,2,18);_.push({datum:t,id:o,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const $=new Map,P=new Map;for(const t of _){if(!t.groupId)continue;const e=$.get(t.groupId)??[];e.push(t.id),$.set(t.groupId,e),t.groupLabel&&P.set(t.groupId,t.groupLabel)}const j=$i(t.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*j,L=Array.from($.keys()),R=L.map((t,o)=>{const i=$.get(t)??[],n=L.length>1?x.topY+28+o/Math.max(1,L.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,o=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:o,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:o},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:P.get(t)??t,bodyIds:i,anchor:{x:I,y:n},x:I,y:n,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),T=function(t,e){const o=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],i=e.filter(t=>!o.has(t)),n=e.length-i.length,r=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s&&Object.prototype.hasOwnProperty.call(o=s,i=t)?o[i]:void 0;var o,i;return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:1},c=e.reduce((t,e)=>t+a(e),0),l=e.reduce((t,e)=>t+(o.has(e)?a(e):0),0),u=t.completion?.threshold,d="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:r,complete:e.length>0&&("anyAbsorbed"===r?n>0:"threshold"===r?l>=(d??c):0===i.length),absorbed:n,total:e.length,absorbedValue:l,totalValue:c,threshold:d,missing:i}})}(R,_.filter(t=>A.has(t.stageId)).map(t=>t.id)),C=new Map(R.map(t=>[t.id,t])),O=_.map((t,e)=>{const o=v.get(t.stageId)??k,i=o.x+(s()-.5)*Math.min(24,.2*o.width),n=x.boundaryY(i,"top")+t.radius+10,r=x.boundaryY(i,"bottom")-t.radius-10,a=r>n?n+s()*Math.max(1,r-n):x.midY,c=g?i:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:i,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=C.get(t.groupId);e?.anchor&&!A.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}}}),F={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},D=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),N=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:F,initialSpawns:O,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:D,metadata:{kind:"process-flow",plot:i.plot,volume:x,stages:N,groups:R,groupCompletion:T,regionEffects:S}}}({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{...i,config:a.config,initialSpawns:ws(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,backgroundGraphics:ks(ps(a.metadata,As(i,n,"showChrome"),{},n.chromeOptions),i.backgroundGraphics),foregroundGraphics:ks(ys(a.projectionRows,a.metadata,As(i,n,"showProjection")),i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy||n.groupBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.workAccessor||n.stageAccessor||"stage"})}}},sm={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[900,520],s=rr({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{...i,config:s.config,initialSpawns:ws(s.initialSpawns),projectionRows:[],backgroundGraphics:ks(As(i,n,"showChrome")?tg.createElement(bs,{layout:s.layout,states:s.states,compact:!0===i.__compactMode}):void 0,i.backgroundGraphics),foregroundGraphics:ks(As(i,n,"showProjection")?tg.createElement(vs,{layout:s.layout,states:s.states}):void 0,i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy)}}},am={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[900,520],s=Gr({data:Array.isArray(t)?t:[],phases:Array.isArray(n.phases)?n.phases:[],products:Array.isArray(n.products)?n.products:void 0,outlets:Array.isArray(n.outlets)?n.outlets:void 0,events:Array.isArray(n.events)?n.events:void 0,idAccessor:n.idAccessor,labelAccessor:n.labelAccessor,categoryAccessor:n.categoryAccessor,amountAccessor:n.amountAccessor,metricsAccessor:n.metricsAccessor,initialStateAccessor:n.initialStateAccessor,metrics:n.metrics,size:r,seed:n.seed,bodyRadius:"number"==typeof n.bodyRadius?n.bodyRadius:void 0,radiusRange:n.radiusRange}),a="snapshot"===n.playback?function(t,e){if(void 0===e)return t.duration;if("number"==typeof e)return Math.max(0,Math.min(t.duration,jr(e)??0));const o=t.phases.find(t=>t.id===e.phaseId);if(!o)return t.duration;const i=Math.max(0,Math.min(1,jr(e.progress??0)??0));return o.start+o.duration*i}(s,n.snapshotAt):s.duration,c=Xr(s,a).state,l=n.projection&&"object"==typeof n.projection?n.projection:{groupBy:"outlet",measure:"count"},u=function(t,e={}){const o=e.groupBy??"outlet",i=new Map,n=t=>{const e=function(t,e){return"product"===e?"product"===t.kind?t.id:"unassigned":"outlet"===e?t.outletId??"unassigned":"category"===e?t.category:t.status}({...t,status:t.status??"active"},o),n=i.get(e);if(n)return n.count+=1,n.amount+=t.amount,void yr(n.metrics,t.metrics);i.set(e,{key:e,label:"product"===o&&"product"===t.kind?t.label:e,count:1,amount:t.amount,metrics:cr(t.metrics),status:"status"===o?t.status:void 0,outletId:"outlet"===o?t.outletId:void 0,category:"category"===o?t.category:void 0,productId:"product"===o&&"product"===t.kind?t.id:void 0})};for(const e of Object.values(t.components))e.productIds.length||"consumed"===e.status||n({kind:"component",id:e.id,label:e.label,status:e.status,outletId:e.outletId,category:e.category,amount:e.amount,metrics:e.metrics});for(const e of Object.values(t.products))n({kind:"product",id:e.id,label:e.label,status:e.status,outletId:e.outletId,category:e.category,amount:e.amount,metrics:e.metrics});const r=new Map((e.order??[]).map((t,e)=>[t,e]));return[...i.values()].sort((t,e)=>(r.get(t.key)??Number.MAX_SAFE_INTEGER)-(r.get(e.key)??Number.MAX_SAFE_INTEGER)||dr(t.key,e.key))}(c,l),d=l.measure??"count",h=function(t,e={}){const o=e.bodies??[],i=Math.max(0,e.recentBodyLimit??6),n=new Map;for(const t of o){const o=e.getContainerId?.(t);if(!o)continue;const i=n.get(o);i?i.push(t):n.set(o,[t])}const r=t.map(t=>{const o=n.get(t.id)??[],r=Math.max(0,Math.floor(t.count??o.length)),s=o.slice(Math.max(0,o.length-i)).map(t=>({id:t.id,label:e.getBodyLabel?.(t)??ns(t),datum:t.datum}));return{id:t.id,label:t.label,count:r,share:0,secondary:t.secondary,secondaryLabel:t.secondaryLabel,observed:t.observed,bodyIds:o.map(t=>t.id),recentBodies:s,metadata:t.metadata}}),s=r.reduce((t,e)=>t+e.count,0);return r.map(t=>({...t,share:s>0?t.count/s:0}))}(u.map(t=>({id:t.key,label:t.label,count:t.count,secondary:"count"===d||"amount"===d?t.amount:Number(t.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?n.amountLabel??"amount":d,metadata:{amount:t.amount,metrics:t.metrics,status:t.status,outletId:t.outletId,category:t.category,productId:t.productId}}))),f={seed:n.seed,bodyRadius:"number"==typeof n.bodyRadius?n.bodyRadius:void 0,radiusRange:n.radiusRange},p=e??n.colorBy??"category",y=!1===n.showChrome?null:tg.createElement(os,{layout:s.layout,phases:s.phases,state:c,compact:520>r[0]||360>r[1]}),g=!1===n.showProjection?null:tg.createElement(is,{rows:u,layout:s.layout,projection:l,amountLabel:n.amountLabel});return{...i,config:s.config,initialSpawns:ws(Yr(c,s.layout,f)),projectionRows:h,bodyStyle:t=>function(t,e,o,i){const n=t.datum,r={stroke:i.stroke??("product"===n?.kind?"#fffaf0":"#26323a"),strokeWidth:i.strokeWidth??("product"===n?.kind?1.8:1.1),opacity:i.opacity??.96};if(!n?.__crucible)return{...r,fill:i.color??"#b8792d"};if("product"===n.kind){const t=e.products[n.semanticId];return{...r,fill:i.color??t?.color??Ss(t?.id??n.semanticId)}}const s=e.components[n.semanticId];if(!s)return{...r,fill:i.color??"#356b63"};let a;return a="status"===o?s.status:"outlet"===o?s.outletId??"in chamber":"product"===o?s.productIds[0]??"unalloyed":"category"===o||null==o?s.category:"function"==typeof o?(o(s.datum)??"unassigned")+"":(s.datum[o+""]??"unassigned")+"",{...r,fill:i.color??Ss(a)}}(t,c,p,n),getBodyLabel:t=>function(t,e){const o=t.datum;if(o?.__crucible)return"product"===o.kind?e.products[o.semanticId]?.label:e.components[o.semanticId]?.label}(t,c),renderBodySVG:ts,backgroundGraphics:ks(y,i.backgroundGraphics),foregroundGraphics:ks(g,i.foregroundGraphics)}}},cm={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[760,420],s=function(t){function e(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof s){const t=s(e,0);if(null!=t)return t+""}if("string"==typeof s&&null!=e[s])return e[s]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}const{coordinateMode:o,flowSpeed:i,links:n,maxParticles:r,nodeIdAccessor:s,nodeXAccessor:a,nodeYAccessor:c,nodes:l,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:f="path",reducedMotion:p,seed:y,size:g,sourceAccessor:m,targetAccessor:x,throughputAccessor:b}=t,v=wi(g),w=Ii(y),k=new Map,A=new Map,S=[];l.forEach((t,e)=>{const o=(Mi(t,e,s)??t.id??e)+"",i=_i(Mi(t,e,a)),n=_i(Mi(t,e,c));if(null!=i&&null!=n){const t={x:i,y:n};k.set(o,t),S.push(t)}A.set(o,(t.label??t.name??o)+"")});const M=[];n.forEach((t,o)=>{const i=e(Mi(t,o,m)),n=e(Mi(t,o,x)),r=Math.max(0,_i(Mi(t,o,b))??0),s=Fn(h?Mi(t,o,h):void 0),a=s.length?s:Fn(t.path??t.points??t.route);a.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${i}-${n}-${o}`)+"",link:t,index:o,source:i,target:n,throughput:r,rawPath:a})});const _=(P=S,"normalized"===($=o)||"pixels"===$?$:P.length>0&&P.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var $,P;const j=new Map;for(const[t,e]of k)j.set(t,Dn(e,v,_));const I=[];for(const t of M){let e=t.rawPath.map(t=>Dn(t,v,_));if(2>e.length){const o=j.get(t.source),i=j.get(t.target);o&&i&&(e=[o,i])}else j.has(t.source)||j.set(t.source,e[0]),j.has(t.target)||j.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(A.has(t.source)||A.set(t.source,t.source),A.has(t.target)||A.set(t.target,t.target),I.push({...t,path:e,packetCount:0}))}const L=Pi(d,.12),R=Math.max(1,Math.round(r)),T=I.map(t=>Math.max(1,Math.round(t.throughput*L))),C=T.reduce((t,e)=>t+e,0),O=C>R?R/C:1;I.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(T[e]*O))});let F=I.reduce((t,e)=>t+e.packetCount,0);for(;F>R;){const t=I.reduce((t,e,o)=>e.packetCount>1&&(-1===t||e.packetCount>I[t].packetCount)?o:t,-1);if(-1===t)break;I[t].packetCount-=1,F-=1}const D=new Map,N=new Map,z=[],E=Pi(i,90),B=Pi(u,4);I.forEach((t,e)=>{D.set(t.target,(D.get(t.target)??0)+t.throughput),N.set(t.source,(N.get(t.source)??0)+t.throughput);const o=Nn(t.path);for(let i=0;t.packetCount>i;i+=1){const n=(i+.5)/t.packetCount,r=p?n:$i(.12+.84*n+.04*(w()-.5),.04,.98),s=p?r:Math.max(0,r-(.18+.12*w())),a=zn(t.path,s),c=zn(t.path,r),l=En(t.path,s),u={x:-l.y,y:l.x},d=(w()-.5)*B*1.5;z.push({id:`${t.id}-packet-${i}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:p?0:l.x*E+10*(w()-.5),vy:p?0:l.y*E+10*(w()-.5),mass:.8,spawnAt:p?0:.04*e+i/32,shape:{type:"circle",radius:B},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:i,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:o,flowRouteId:t.id,flowSpeed:E,sourceLabel:A.get(t.source)??t.source,targetLabel:A.get(t.target)??t.target},springs:"none"!==f&&p?[{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(j,([t,e])=>({nodeId:t,label:A.get(t)??t,sensorId:"physical-flow-node-"+ji(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=Si(y,[...An({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PacketFlowChart",{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=R,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(j,([t,e])=>({id:t,label:A.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+ji(t),incoming:D.get(t)??0,outgoing:N.get(t)??0})),H=I.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:A.get(t.source)??t.source,targetLabel:A.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:G,initialSpawns:z,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:z.length,totalThroughput:I.reduce((t,e)=>t+e.throughput,0),plot:v.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{...i,config:s.config,initialSpawns:ws(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ks(ms(s.metadata,{showNodeLabels:!1!==n.showNodeLabels,showSensors:!1!==n.showSensors,showStaticFlow:!1!==n.showStaticFlow}),i.foregroundGraphics),bodyStyle:Ai(e||n.colorBy||"source")}}},lm={frameType:"physics",layout:Jg,buildProps:(t,e,o,i,n)=>{const r=i.size??[700,380],s=Zt(i.theme),a=function(t){const e=function(t,e,o){const i=t?.observation;return{...t,observation:{...i,chartId:e??i?.chartId??"physics-custom",chartType:i?.chartType??"PhysicsCustomChart",onObservation:o??i?.onObservation}}}(t.config,t.chartId,t.onObservation),o=Gn(t.colorScheme,t.themeCategorical,Df),i=wi(t.size),n={data:t.data,scales:{x:(0,jg.scaleLinear)().domain(t.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:(0,jg.scaleLinear)().domain(t.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:t.semantic,categorical:[...o]},resolveColor:Vn(o,t.colorScheme),config:t.layoutConfig??{},world:new _g(e)},r=t.skipLayout?{}:t.layout(n)??{},s=function(t,e){if(!e?.length)return t;const o=new Map;for(const t of e){const{bodyId:e,...i}=t,n=o.get(e)??[];n.push(i),o.set(e,n)}return t.map(t=>{const e=o.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Hn(e,r),context:n,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}({chartId:n.chartId,colorScheme:o,config:n.config,data:Array.isArray(t)?t:[],layout:n.layout,layoutConfig:n.layoutConfig,semantic:Kt(s)??{},size:r,themeCategorical:s.colors.categorical,xExtent:n.xExtent,yExtent:n.yExtent});return{...i,config:a.config,initialSpawns:ws(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??Ai(e||n.colorBy),backgroundGraphics:ks(i.backgroundGraphics,a.result.backgroundOverlays),foregroundGraphics:ks(i.foregroundGraphics,a.result.overlays)}}},um=Wh(require("react-dom/server")),dm=Wh(require("react")),hm=Wh(require("react-dom/server")),fm=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 o of t){const t=this.push(o);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 o=0;this._size>o;o++)t(this.buffer[(e+o)%this._capacity],o)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)t[o]=this.buffer[(e+o)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let o=0,i=[];e.length>t&&(o=e.length-t,i=e.slice(0,o)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=o;e.length>t;t++)this.push(e[t]);return i}update(t,e){const o=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++){const r=(i+n)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},o.push(t),this.buffer[r]=e(s)}}return o}remove(t){const e=[],o=[];if(this.forEach(i=>{t(i)?o.push(i):e.push(i)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return o}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}},pm=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 o of t){const t=e?e(o):o;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}},ym=/^\d{4}-\d{1,2}$/,gm=Object.create(null),mm="undefined"==typeof window||"undefined"==typeof document,xm=new Set,bm=require("d3-scale"),vm=new WeakMap,wm=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],km=["scene-style","data-paint","accessibility","evidence"],Am=(t,e)=>({retainedData:t,invalidations:e}),Sm=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mm=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],_m=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$m=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pm=["scene-geometry","data-paint","accessibility","evidence"],jm=["scene-style","data-paint","accessibility","evidence"],Im=[],Lm={chartType:Am("rebuild",Sm),runtimeMode:Am("rebuild",Sm),xAccessor:Am("rebuild",Sm),yAccessor:Am("rebuild",Sm),timeAccessor:Am("rebuild",Sm),valueAccessor:Am("rebuild",Sm),y0Accessor:Am("rebuild",Sm),boundsAccessor:Am("rebuild",Sm),band:Am("rebuild",Sm),openAccessor:Am("rebuild",Sm),highAccessor:Am("rebuild",Sm),lowAccessor:Am("rebuild",Sm),closeAccessor:Am("rebuild",Sm),candlestickRangeMode:Am("rebuild",Sm),accessorRevision:Am("rebuild",Sm),groupAccessor:Am("rebuild",Mm),categoryAccessor:Am("rebuild",Mm),lineDataAccessor:Am("rebuild",Mm),colorAccessor:Am("rebuild",jm),sizeAccessor:Am("rebuild",Pm),symbolAccessor:Am("rebuild",Pm),pointIdAccessor:Am("rebuild",Pm),xScaleType:Am("preserve",_m),yScaleType:Am("preserve",_m),xExtent:Am("preserve",_m),invertY:Am("preserve",_m),yExtent:Am("preserve",_m),extentPadding:Am("preserve",_m),scalePadding:Am("preserve",_m),axisExtent:Am("preserve",_m),yAxisExtent:Am("preserve",_m),binSize:Am("preserve",_m),normalize:Am("preserve",_m),heatmapAggregation:Am("preserve",_m),heatmapXBins:Am("preserve",_m),heatmapYBins:Am("preserve",_m),arrowOfTime:Am("preserve",$m),baseline:Am("preserve",$m),stackOrder:Am("preserve",$m),sizeRange:Am("preserve",$m),curve:Am("preserve",$m),areaGroups:Am("preserve",$m),customLayout:Am("preserve",$m),layoutConfig:Am("preserve",$m),layoutMargin:Am("preserve",$m),symbolMap:Am("preserve",Pm),showValues:Am("preserve",Pm),heatmapValueFormat:Am("preserve",Pm),trackHoverRows:Am("preserve",Pm),lineStyle:Am("preserve",jm),pointStyle:Am("preserve",jm),areaStyle:Am("preserve",jm),barStyle:Am("preserve",jm),swarmStyle:Am("preserve",jm),waterfallStyle:Am("preserve",jm),candlestickStyle:Am("preserve",jm),boundsStyle:Am("preserve",jm),gradientFill:Am("preserve",jm),lineGradient:Am("preserve",jm),semanticLineStops:Am("preserve",jm),colorScheme:Am("preserve",jm),themeCategorical:Am("preserve",jm),themeSemantic:Am("preserve",jm),themeSequential:Am("preserve",jm),themeDiverging:Am("preserve",jm),barColors:Am("preserve",jm),decay:Am("preserve",jm),pulse:Am("preserve",jm),staleness:Am("preserve",jm),layoutSelection:Am("preserve",jm),annotations:Am("preserve",["overlay","accessibility","evidence"]),windowSize:Am("preserve",Im),windowMode:Am("preserve",Im),maxCapacity:Am("preserve",Im),clock:Am("preserve",Im),transition:Am("preserve",Im),introAnimation:Am("preserve",Im),onLayoutError:Am("preserve",Im)},Rm=Am("preserve",$m),Tm=class{constructor(){this.tracker=new hg}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}},wm)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},km):this.recordNoop("restyle")}recordConfig(t,e=!1){const o=function(t){let e="preserve";const o=new Set;for(const i of t){const t=Lm[i]??Rm;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}(t);return this.tracker.record({kind:"config",keys:t},e?new Set([...o.invalidations,...Pm]):o.invalidations)}},Cm=require("d3-quadtree"),Om=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 o=0,i=0;for(const t of e)"point"===t.type&&!1!==t.interactive&&(o++,t.r>i&&(i=t.r));if(this.maxRadius=i,500>=o)return void(this.tree=null);const n=Array(o);let r=0;for(const t of e)"point"===t.type&&!1!==t.interactive&&(n[r++]=t);this.tree=(0,Cm.quadtree)().x(t=>t.x).y(t=>t.y).addAll(n)}},Fm=class t{constructor(t){if(this.xExtent=new pm,this.yExtent=new pm,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 Tm,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 Om,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,o)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,o,i,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;o.length>e;e++)t.set(o[e],e);return t})();for(const o of e){if("line"===o.type)continue;if("area"===o.type){const e=Array.isArray(o.datum)?o.datum:[o.datum];let n=0,a=!1;for(const o of e){const e=l.get(o);if(null==e)continue;a=!0;const s=i.get(e);if(null==s)continue;const c=Es(t,s,r);c>n&&(n=c)}a&&(c=Bs(o,n,s)||c);continue}const e=l.get(o.datum);if(null==e)continue;const n=i.get(e);c=Bs(o,null==n?0:Es(t,n,r),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),o),this.config=t,this.buffer=new fm(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=_s(t.timeAccessor||t.xAccessor,"time"),this.getY=_s(t.valueAccessor||t.yAccessor,"value")):(this.getX=_s(t.xAccessor,"x"),this.getY=_s(t.yAccessor,"y")),this.getGroup=Ps(t.groupAccessor),this.getCategory=Ps(t.categoryAccessor),this.getSize=t.sizeAccessor?_s(t.sizeAccessor,"size"):void 0,this.getColor=Ps(t.colorAccessor),this.getSymbol=Ps(t.symbolAccessor),this.getY0=t.y0Accessor?_s(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Zs(t),this.getPointId=Ps(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,o=null!=t.closeAccessor;this.getOpen=e?_s(t.openAccessor,"open"):void 0,this.getHigh=_s(t.highAccessor,"high"),this.getLow=_s(t.lowAccessor,"low"),this.getClose=o?_s(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!o}t.pulse&&(this.timestampBuffer=new fm(t.windowSize))}currentTime(){return this.config.clock?.()??Ds()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=da(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 o=e.getTop(t),i=e.getBottom(t);Number.isFinite(o)&&this.yExtent.push(o),Number.isFinite(i)&&this.yExtent.push(i)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const o=e.getTop(t),i=e.getBottom(t);Number.isFinite(o)&&this.yExtent.evict(o),Number.isFinite(i)&&this.yExtent.evict(i)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=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 o=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=o?_s(this.config.timeAccessor||this.config.xAccessor,"time"):_s(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],o=this.config.xAccessor,i="function"==typeof o?o(e):e[o||"x"],n=i instanceof Date,r="string"==typeof i&&Number.isFinite(Ls(i));if(this.xIsDate=n||r,r){const t="string"==typeof o?o:void 0;this.getX=t?e=>Rs(e[t]):t=>Rs(o(t))}}ua(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const o of t.inserts)ha(this.buffer,o,this.timestampBuffer,e),this.xExtent.push(this.getX(o)),this.pushDatumYExtent(o)}else for(const o 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=ha(this.buffer,o,this.timestampBuffer,e);this.xExtent.push(this.getX(o)),this.pushDatumYExtent(o),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:o}=this,i=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(o,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.xExtent.extent,a=this.yExtent.extent;let c="waterfall"===e.chartType&&o.size>0?function(t,e,o,i,n){const r=Array.from(new Set(t.map(e).filter(t=>Number.isFinite(t)))).sort((t,e)=>t-e);if(2>r.length)return aa(o,i);const s=r[0],a=r[1],c=r[r.length-1],l=r[r.length-2];return aa("log"===n&&s>0?[s/Math.sqrt(a/s),c*Math.sqrt(c/l)]:[s-(a-s)/2,c+(c-l)/2],i)}(r,this.getX,s,e.xExtent,e.xScaleType):aa(s,e.xExtent),l=aa(a,e.yExtent);const u=!(!(d=e.yExtent)||null==d[0]||null==d[1]);var d;const h="exact"===(e.yAxisExtent??e.axisExtent);if("stackedarea"===e.chartType&&!u&&o.size>0){const t=function(t){const{config:e,groups:o,getX:i,getY:n}=t,r="exact"===(e.yAxisExtent??e.axisExtent);if(e.normalize){const o=[0,r?1:1+e.extentPadding];return{yDomain:o,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:o}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,d=new Map;for(const t of o){const e=new Map;let o=0;for(const r of t.data){const t=i(r),s=n(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),o+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),d.set(t.key,o)}const h=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===h)p=o.map(t=>t.key);else if("insideOut"===h){const t=[...o].map(t=>t.key).sort((t,e)=>{const o=(d.get(e)??0)-(d.get(t)??0);return 0!==o?o:f(t,e)}),e=[],i=[];let n=0,r=0;for(const o of t)r>n?(e.push(o),n+=d.get(o)??0):(i.push(o),r+=d.get(o)??0);p=[...i.reverse(),...e]}else p="asc"===h?o.map(t=>t.key).sort((t,e)=>{const o=(d.get(t)??0)-(d.get(e)??0);return 0!==o?o:f(t,e)}):"desc"===h?o.map(t=>t.key).sort((t,e)=>{const o=(d.get(e)??0)-(d.get(t)??0);return 0!==o?o:f(t,e)}):o.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),o=oa(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let i=1/0,n=-1/0;for(const e of t){const t=o.get(e)??0,r=u.get(e)??0;i>t&&(i=t),t+r>n&&(n=t+r)}Number.isFinite(i)&&Number.isFinite(n)||(i=0,n=0);const s=n-i,l=r?0:s>0?s*e.extentPadding:1;y=[i-l,n+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[o,i]=function(t,e,o){let i=0,n=0;for(const r of t){let t=0,s=0;for(const i of e){const e=o(i,r)||0;0>e?s+=e:t+=e}i>s&&(i=s),t>n&&(n=t)}return[i,n]}(t,p,(t,e)=>a.get(t)?.get(e)||0),n=i-o,s=r?0:n>0?n*e.extentPadding:1;y=[o-s,i+s]}else y=[0,l+(r?0:l>0?l*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:o.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!u&&o.size>0?l=function(t,e,o,i,n,r,s){const[,a]=function(t,e,o,i,n){const r=Qs(t,e,o,i,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,o,i,n);return[0,s?a:a+a*r]}(o,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!u&&o.size>0?l=function(t,e,o,i){const[n,r]=function(t,e){let o=0,i=0,n=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(n+=t,o>n&&(o=n),n>i&&(i=n))}return[o,i]}(t,e),s=r-n,a=i?0:s>0?s*o:1;return[Math.min(0,n-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(o,this.getY,e.extentPadding,h):u||l[0]===1/0||(l=function(t,e,o){if(!o.length)return t;let[i,n]=t;for(const t of e)for(const e of o){const o=e.getTop(t),r=e.getBottom(t);Number.isFinite(o)&&(i>o&&(i=o),o>n&&(n=o)),Number.isFinite(r)&&(i>r&&(i=r),r>n&&(n=r))}return[i,n]}(l,r,this.resolvedRibbons),l=function(t,e){const o=t[1]-t[0],i=e.exactMode?0:o>0?o*e.extentPadding:1,n=[null!=e.userMin?t[0]:t[0]-i,null!=e.userMax?t[1]:t[1]+i];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}(l,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:a}));l=function(t,e,o){if(!e||o)return t;const i=e[0],n=e[1];return null==i&&null==n?t:[null!=i?i:t[0],null!=n?n:t[1]]}(l,e.yExtent,!!u),({xDomain:c,yDomain:l}=function(t,e,o){let i=t,n=e;if(i[0]===1/0||i[1]===-1/0)if("time"===o){const t=Date.now();i=[t-864e5,t]}else i=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:i,yDomain:n}}(c,l,e.xScaleType)),this.scales=function(t){const{config:e,layout:o,xDomain:i}=t,n=e.invertY?[t.yDomain[1],t.yDomain[0]]:t.yDomain,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(o.width,o.height)/2-1));if(r){const t="left"===e.arrowOfTime?[o.width-s,s]:[s,o.width-s];return{x:(0,bm.scaleLinear)().domain(i).range(t),y:ca(e.yScaleType,n,[o.height-s,s])}}return{x:ca(e.xScaleType,i,[s,o.width-s]),y:ca(e.yScaleType,n,[o.height-s,s])}}({config:e,layout:t,xDomain:c,yDomain:l}),this._customLayoutFailedThisBuild=!1;const f=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,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=f,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,o=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=o;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=o;for(const i of t.bottomPath)i[0]*=e,i[1]*=o;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*o,width:t.clipRect.width*e,height:t.clipRect.height*o}),t.strokeColorBands&&(t.strokeColorBands=t.strokeColorBands.map(t=>({...t,y:t.y*o,height:t.height*o})));break;case"point":case"glyph":t.x*=e,t.y*=o;break;case"rect":case"heatcell":t.x*=e,t.y*=o,t.w*=e,t.h*=o;break;case"candlestick":t.x*=e,t.openY*=o,t.closeY*=o,t.highY*=o,t.lowY*=o}const i=this.scales.x.domain(),n=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=ca,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,r[0]>r[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,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:o,scales:i}=this;if(!i)return[];if(o.customLayout){const n={data:e,scales:i,dimensions:{width:t.width,height:t.height,margin:o.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:o.themeCategorical??ap},resolveColor:(t,e)=>{const i=this.resolveGroupColor(t);if(i)return i;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:o.themeSemantic?.primary??"#4e79a7"},config:o.layoutConfig??{},selection:o.layoutSelection??null},r=Us({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:o.onLayoutError,run:()=>o.customLayout(n)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);const s=r.result;this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null;const a=s.nodes??[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of a)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(a,o.layoutSelection??null)}return Gs({label:"customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const n={scales:i,config:o,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},r=(s=o.chartType,gm[s]?.buildScene);var s;if(!r)return function(t){(function(t){return gm[t]})(t)||mm&&(xm.has(t)||(xm.add(t),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${t}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}(o.chartType),[];const a=(c=r(n,e,t),Array.isArray(c)?{nodes:c,binBoundaries:[]}:{nodes:c.nodes,binBoundaries:c.binBoundaries});var c;return"bar"===o.chartType&&(this._barCategoryCache=n.barCategoryCache??null,this._binBoundaries=a.binBoundaries),a.nodes}resolveBoundsStyle(t,e){return function(t,e,o,i){const n=t.boundsStyle;if("function"==typeof n)return n(o||{},e);if(n&&"object"==typeof n)return n;const r=i(e,o);return{fill:r.stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=r.opacity&&{opacity:r.opacity},stroke:"none",cursor:r.cursor}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const o=this.config.decay;return o&&e>1?Ns(o,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=zs(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,o,i=zs(o)){const n=o.length;if(n>1)for(const o of e){if("line"===o.type){const e=Array.isArray(o.datum)?o.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let o=0;e.length>o;o++){const a=i.get(e[o]);null!=a?(r[o]=Ns(t,a,n),1>r[o]&&(s=!0)):r[o]=1}s&&(o._decayOpacities=r);continue}if("area"===o.type){const e=Array.isArray(o.datum)?o.datum:[],r=o.topPath?o.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let o=0;e.length>o;o++){const r=i.get(e[o]);null!=r?(s[o]=Ns(t,r,n),1>s[o]&&(a=!0)):s[o]=1}a&&(o._decayOpacities=s)}else{let s=1;for(const o of e){const e=i.get(o);if(null!=e){const o=Ns(t,e,n);s>o&&(s=o)}}if(1>s){const t=Array(r);t.fill(s),o._decayOpacities=t}}continue}const e=i.get(o.datum);if(null==e)continue;const r=Ns(t,e,n);"candlestick"===o.type?o._decayOpacity=r:o.style={...o.style,opacity:(o.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&&Ws(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,o,i){o.clear(),i.clear();for(let n=0;e.length>n;n++){const r=e[n],s=Ys(t,r,n);s&&("point"===r.type?o.set(s,{x:r.x,y:r.y,r:r.r,opacity:qs(r.style)}):"glyph"===r.type?o.set(s,{x:r.x,y:r.y,r:r.size,opacity:qs(r.style),glyph:r.glyph}):"rect"===r.type||"heatcell"===r.type?o.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:qs(r.style)}):"candlestick"===r.type?o.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:qs(r.style)}):"line"===r.type?i.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&i.set(s,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const o=this.scene[e],i=Ys(this.transitionContext,o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:0,opacity:0}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:t,w:o.w,h:0,opacity:o.style.opacity??1}):"heatcell"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:0}):"line"===o.type?(o._introClipFraction=0,this.prevPathMap.set(i,{path:o.path.map(t=>[t[0],t[1]]),opacity:o.style.opacity})):"area"===o.type&&(o._introClipFraction=0,this.prevPathMap.set(i,{topPath:o.topPath.map(t=>[t[0],t[1]]),bottomPath:o.bottomPath.map(t=>[t[0],t[1]]),opacity:o.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,o,i,n,r=Ds()){if(0===i.size&&0===n.size)return o;const s=e.duration??300;if(o.exitNodes.length>0){const t=new Set(o.exitNodes);o.scene=o.scene.filter(e=>!t.has(e)),o.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let e=0;o.scene.length>e;e++){const r=o.scene[e],s=Ys(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=i.get(s);if("point"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=qs(r.style),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=qs(r.style),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=qs(r.style),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=qs(r.style),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=qs(r.style),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=qs(r.style),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=qs(r.style),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=qs(r.style),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=qs(r.style),(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=qs(r.style),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 i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};o.exitNodes.push(i),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};o.exitNodes.push(i),a=!0}for(const[t,e]of i)if(!c.has(t)){if(t.startsWith("p:"))o.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)o.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:"))o.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:"))o.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const i=e.openY??e.y;o.exitNodes.push({type:"candlestick",x:e.x,openY:i,closeY:e.closeY??i,highY:e.highY??i,lowY:e.lowY??i,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),a&&(o.activeTransition={startTime:r,duration:s}),o}(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},o=function(t,e,o,i){if(!o.activeTransition)return!1;const n=Os(t,o.activeTransition),r=Cs(n,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of o.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style.opacity=Fs(o?o.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=Fs(o.x,t._targetX,r),t.y=Fs(o.y,t._targetY,r),void 0!==t._targetR&&void 0!==o.r&&(t.r=Fs(o.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style.opacity=Fs(o?o.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=Fs(o.x,t._targetX,r),t.y=Fs(o.y,t._targetY,r),void 0!==t._targetR&&void 0!==o.r&&(t.size=Fs(o.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style.opacity=Fs(o?o.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=Fs(o.x,t._targetX,r),t.y=Fs(o.y,t._targetY,r),void 0!==o.w&&(t.w=Fs(o.w,t._targetW,r)),void 0!==o.h&&(t.h=Fs(o.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style={...t.style||{},opacity:Fs(o?o.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=Fs(o.x,t._targetX,r),t.y=Fs(o.y,t._targetY,r),void 0!==o.w&&(t.w=Fs(o.w,t._targetW,r)),void 0!==o.h&&(t.h=Fs(o.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const o=e?i.get(e):void 0;t.style={...t.style||{},opacity:Fs(o?o.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const o=i.get(e);if(!o)continue;t.x=Fs(o.x,t._targetX,r),void 0!==o.openY&&(t.openY=Fs(o.openY,t._targetOpenY,r)),void 0!==o.closeY&&(t.closeY=Fs(o.closeY,t._targetCloseY,r)),void 0!==o.highY&&(t.highY=Fs(o.highY,t._targetHighY,r)),void 0!==o.lowY&&(t.lowY=Fs(o.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Fs(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,o=t._targetPath;if(e&&o&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=Fs(e[i][0],o[i][0],r),t.path[i][1]=Fs(e[i][1],o[i][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Fs(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,o=t._prevBottomPath,i=t._targetTopPath,n=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let o=0;t.topPath.length>o;o++)t.topPath[o][0]=Fs(e[o][0],i[o][0],r),t.topPath[o][1]=Fs(e[o][1],i[o][1],r);if(o&&n&&o.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Fs(o[e][0],n[e][0],r),t.bottomPath[e][1]=Fs(o[e][1],n[e][1],r)}}if(n>=1){for(const t of o.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 o=0;t.path.length>o;o++)t.path[o]=e[o];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,o=t._targetBottomPath;if(e)for(let o=0;t.topPath.length>o;o++)t.topPath[o]=e[o];if(o)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=o[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(o.exitNodes.length>0){const t=new Set(o.exitNodes);o.scene=o.scene.filter(e=>!t.has(e)),o.exitNodes=[]}return o.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,o}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,function(t){for(const e of t){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type)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("glyph"===e.type)void 0!==e._targetX&&(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||"heatcell"===e.type)void 0!==e._targetX&&(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)void 0!==e._targetX&&(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||"area"===e.type){if(e._introClipFraction=void 0,"line"===e.type&&e._targetPath){for(let t=0;e.path.length>t;t++)e.path[t]=e._targetPath[t];e._prevPath=void 0,e._targetPath=void 0}if("area"===e.type){if(e._targetTopPath)for(let t=0;e.topPath.length>t;t++)e.topPath[t]=e._targetTopPath[t];if(e._targetBottomPath)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=e._targetBottomPath[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}}}(this.scene),this.exitNodes=[]}groupData(t){const{result:e,cache:o}=function(t,e,o,i){if(i&&i.version===o&&i.group===e&&i.data===t)return{result:i.result,cache:i};let n;if(e){const o=new Map;for(const i of t){const t=e(i);o.has(t)||o.set(t,[]),o.get(t).push(i)}n=Array.from(o.entries()).map(([t,e])=>({key:t,data:e}))}else n=[{key:"_default",data:t}];return{result:n,cache:{version:o,group:e,data:t,result:n}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=o,e}resolveColorMap(t){const{map:e,cache:o}=function(t,e,o,i,n){if(n&&n.version===i)return{map:n.map,cache:n};const r=new Set;if(e)for(const o of t){const t=e(o);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(n&&n.key===a){const t={...n,version:i};return{map:t.map,cache:t}}const c=At(o.colorScheme,o.themeCategorical,ap),l=new Map;for(let t=0;s.length>t;t++)l.set(s[t],la(o.colorScheme,s[t])??c[t%c.length]);return{map:l,cache:{key:a,map:l,version:i}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=o,e}resolveLineStyle(t,e){return function(t,e,o,i){const n=t.lineStyle;if("function"==typeof n){const t=n(o||{},e);if(t&&!t.stroke&&e){const o=i(e);if(o)return{...t,stroke:o}}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,cursor:n.cursor}:{stroke:i(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,o,i){if(t.areaStyle){const n=t.areaStyle(o||{});if(n&&!n.fill&&e){const t=i(e);if(t)return{...n,fill:t,stroke:n.stroke||t}}return n}const n=t.lineStyle;if("function"==typeof n){const t=n(o||{},e);if(t&&!t.fill&&e){const o=i(e);if(o)return{...t,fill:o,stroke:t.stroke||o}}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,cursor:n.cursor};const s=i(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:o,groupColorCounter:i}=function(t){const{group:e,colorMapCache:o,groupColorMap:i,groupColorMapCap:n,config:r}=t;let{groupColorCounter:s}=t;const a=la(r.colorScheme,e);if(a)return{color:a,groupColorCounter:s};if(o){const t=o.map.get(e);if(t)return{color:t,groupColorCounter:s}}const c=i.get(e);if(c)return{color:c,groupColorCounter:s};const l=At(r.colorScheme,r.themeCategorical,ap);if(0===l.length)return{color:null,groupColorCounter:s};const u=l[s%l.length];if(s++,i.set(e,u),i.size>n){const t=i.keys().next().value;void 0!==t&&i.delete(t)}return{color:u,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=i,o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Ts(t),o=this.getPointId,i=t=>e.has(o(t));fa(this.buffer,this.timestampBuffer,i);const n=this.buffer.remove(i);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 o=Ts(t),i=this.getPointId,n=new Set;this.buffer.forEach((t,e)=>{o.has(i(t))&&n.add(e)});const r=this.buffer.update(t=>o.has(i(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{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 o=this._customRestyle;if(o)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},n=o(i,e);i.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},o=Object.keys(t).filter(o=>t[o]!==e[o]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let i=!1,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,o=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=r||!Ms(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!Ms(o,s);(a||c)&&(t?(this.getX=_s(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=_s(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=_s(this.config.xAccessor,"x"),this.getY=_s(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Zs(this.config)),i=!0,n=!0)}if("groupAccessor"in t&&!Ms(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Ps(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in t&&!Ms(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Ps(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in t&&!Ms(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?_s(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in t&&!Ms(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Ps(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in t&&!Ms(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Ps(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in t&&!Ms(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?_s(this.config.y0Accessor,"y0"):void 0,i=!0,n=!0),("boundsAccessor"in t&&!Ms(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=Zs(this.config),i=!0,n=!0),"pointIdAccessor"in t&&!Ms(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Ps(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!Ms(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!Ms(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!Ms(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!Ms(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?_s(this.config.openAccessor,"open"):void 0,this.getHigh=_s(this.config.highAccessor,"high"),this.getLow=_s(this.config.lowAccessor,"low"),this.getClose=e?_s(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,i=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(i=!0,n=!0),!i){const o=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of o)if(t[n]!==e[n]){i=!0;break}}i&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(o,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&me(e.areaStyle)!==me(this.config.areaStyle))}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Fm.GROUP_COLOR_MAP_CAP=1e3;var Dm=Fm;va(Dm);var Nm=require("d3-shape"),zm=(t,e,o,i)=>{const n=e.filter(t=>"area"===t.type);for(const e of n){if(2>e.topPath.length)continue;let o=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),o=!0);const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,i.width*n,i.height),t.clip());const r=Ur(t,e.style.fill,"#4e79a7"),s=e._decayOpacities,a=!(!e.colorThresholds?.length||!e.rawValues||e.rawValues.length!==e.topPath.length),c=!!e.strokeColorBands?.length;if(s&&s.length===e.topPath.length&&!a&&!c){const o=e.style.fillOpacity??.7;t.fillStyle=r;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(s[i]+s[i+1])*o,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();const i=e.style.strokeWidth??2;if(e.style.stroke&&"none"!==e.style.stroke&&i>0){t.strokeStyle=ni(t,e.style.stroke)||e.style.stroke,t.lineWidth=i,t.setLineDash([]);for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(s[o]+s[o+1]),t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.stroke()}t.globalAlpha=1;continue}const l=e.style.opacity??1;if(Ta(t,e),e.fillGradient&&e.fillGradient.stops.length>=2&&e.fillGradient){let o=1/0;for(const t of e.topPath)o>t[1]&&(o=t[1]);let i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const n=Zr(t,e.fillGradient,"string"==typeof r?r:"#4e79a7",0,o,0,i);t.fillStyle=n||r,t.globalAlpha=l}else t.globalAlpha=(e.style.fillOpacity??.7)*l,t.fillStyle=r;t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Ta(t,e),Ia(t,e));const u=e.style.strokeWidth??2;if(e.style.stroke&&"none"!==e.style.stroke&&u>0){t.globalAlpha=l;const o=ni(t,e.style.stroke)||e.style.stroke,i=a||c||!e.strokeGradient||2>e.topPath.length?null:Zr(t,e.strokeGradient,o,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);if(t.lineWidth=u,t.setLineDash([]),c){let i=1/0,n=-1/0;for(const[t]of e.topPath)i=Math.min(i,t),n=Math.max(n,t);const r=t.lineWidth;for(const s of e.strokeColorBands){t.save(),t.beginPath(),t.rect(i-r,s.y,n-i+2*r,s.height),t.clip();const a=s.color??o;t.strokeStyle=ni(t,a)||a,t.globalAlpha=l*(s.opacity??1),Ca(t,e),t.stroke(),t.restore()}}else if(a){const i=Ra(e.topPath,e.rawValues,e.colorThresholds,o);for(const e of i){t.beginPath(),t.strokeStyle=ni(t,e.color)||e.color,t.moveTo(e.path[0][0],e.path[0][1]);for(let o=1;e.path.length>o;o++)t.lineTo(e.path[o][0],e.path[o][1]);t.stroke()}}else t.strokeStyle=i||o,Ca(t,e),t.stroke()}void 0!==n&&1>n&&t.restore(),o&&t.restore(),t.globalAlpha=1}},Em=require("d3-shape"),Bm=(t,e,o,i)=>{const n=e.filter(t=>"line"===t.type);for(const e of n){if(2>e.path.length)continue;const o=e._introClipFraction;void 0!==o&&1>o&&(t.save(),t.beginPath(),t.rect(0,0,i.width*o,i.height),t.clip());const n=e.style.stroke||"#007bff",r=ni(t,n)||n,s=e.style.strokeWidth??2,a=e.colorThresholds,c=e.rawValues;if(t.setLineDash(e.style.strokeDasharray?e.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),s>0&&(t.lineWidth=s),t.lineCap=e.style.strokeLinecap||"butt",e.style._edgeFade&&s>0){Oa(t,e.path,r,s,e.style.opacity??1,e.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const l=Hr(e.curve),u=a&&a.length>0&&c&&c.length===e.path.length,d=e._decayOpacities;if(s>0&&d&&d.length===e.path.length&&!u){t.strokeStyle=r;const o=e.style.opacity??1;for(let i=0;e.path.length-1>i;i++)t.globalAlpha=.5*(d[i]+d[i+1])*o,t.beginPath(),t.moveTo(e.path[i][0],e.path[i][1]),t.lineTo(e.path[i+1][0],e.path[i+1][1]),t.stroke()}else if(s>0&&!u){t.beginPath();const o=e.strokeGradient&&e.path.length>=2?Zr(t,e.strokeGradient,r,e.path[0][0],0,e.path[e.path.length-1][0],0):null;if(t.strokeStyle=o||r,l)(0,Em.line)().x(t=>t[0]).y(t=>t[1]).curve(l).context(t)(e.path);else{const[o,i]=e.path[0];t.moveTo(o,i);for(let o=1;e.path.length>o;o++)t.lineTo(e.path[o][0],e.path[o][1])}t.stroke()}else if(s>0){const o=Ra(e.path,c,a,r);for(const e of o){t.beginPath(),t.strokeStyle=ni(t,e.color)||e.color,t.moveTo(e.path[0][0],e.path[0][1]);for(let o=1;e.path.length>o;o++)t.lineTo(e.path[o][0],e.path[o][1]);t.stroke()}}if(e.style.fill&&e.style.fillOpacity&&e.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=e.style.fillOpacity,t.fillStyle=Ur(t,e.style.fill,e.style.fill),l&&!u)(0,Em.line)().x(t=>t[0]).y(t=>t[1]).curve(l).context(t)(e.path);else{const[o,i]=e.path[0];t.moveTo(o,i);for(let o=1;e.path.length>o;o++)t.lineTo(e.path[o][0],e.path[o][1])}const o=e.path[0][0];t.lineTo(e.path[e.path.length-1][0],i.height),t.lineTo(o,i.height),t.closePath(),t.fill()}void 0!==o&&1>o&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}},Wm=(t,e,o,i)=>{const n=e.filter(t=>"point"===t.type);if(0!==n.length){t.save();try{const e=t.globalAlpha;let o=[],i="";const r=o=>{t.beginPath(),t.arc(o.x,o.y,o.r,0,2*Math.PI),t.globalAlpha=e*(o.style.opacity??o.style.fillOpacity??1),t.fillStyle=Ur(t,o.style.fill,"#4e79a7"),t.fill();const i=o.style.strokeWidth??1;o.style.stroke&&"none"!==o.style.stroke&&i>0&&(t.strokeStyle=Ur(t,o.style.stroke,o.style.stroke),t.lineWidth=i,t.stroke()),function(t,e,o=.6){if(!Pa(e))return;const i=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,n=e.cx??e.x??0,r=e.cy??e.y??0;t.beginPath(),t.arc(n,r,i,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*o,t.stroke()}(t,o)},s=()=>{if(0===o.length)return;if(1===o.length)return r(o[0]),o=[],void(i="");const n=o[0];t.globalAlpha=e*(n.style.opacity??n.style.fillOpacity??1),t.beginPath();for(const e of o)t.moveTo(e.x+e.r,e.y),t.arc(e.x,e.y,e.r,0,2*Math.PI);t.fillStyle=Ur(t,n.style.fill,"#4e79a7"),t.fill();const s=n.style.strokeWidth??1;n.style.stroke&&"none"!==n.style.stroke&&s>0&&(t.strokeStyle=Ur(t,n.style.stroke,n.style.stroke),t.lineWidth=s,t.stroke()),o=[],i=""};for(const t of n){const e=t.style.opacity??t.style.fillOpacity??1,n=t.style.fill;if(Pa(t)||null!=n&&"string"!=typeof n||1>e){s(),r(t);continue}const a=t.style.strokeWidth??1,c=`${n??"#4e79a7"}\0${t.style.stroke&&"none"!==t.style.stroke&&a>0?t.style.stroke+"":""}\0${a}\0${t.r}\0${e}`;o.length>0&&c!==i&&s(),i=c,o.push(t),2048>o.length||s()}s()}finally{t.restore()}}},Ym={chartType:"line",buildScene:(t,e)=>function(t,e){const o=t.groupData(e),i=[],n=t.config.annotations?.filter($a).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Aa(t.ribbons);if(r.length>0&&i.push(...Sa(t,e,r)),n.length>0)for(const e of o)i.push(...Ma(t,e.data,e.key,n))}for(const e of o){const o=t.resolveLineStyle(e.key,ge(e.data)),r=ta(e.data,t.scales,t.getX,t.getY,o,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),i.push(r)}return _a(t,o,i),i}(t,e),canvasRenderers:[zm,Bm,Wm]},qm={chartType:"area",buildScene:(t,e)=>function(t,e){const o=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Aa(t.ribbons);if(r.length>0&&i.push(...Sa(t,e,r)),n.length>0)for(const e of o)i.push(...Ma(t,e.data,e.key,n))}const n=t.scales.y.domain(),r=n[0],s=t.config.semanticLineStops?.filter(t=>Number.isFinite(t.offset)).map(t=>({value:n[0]+Math.max(0,Math.min(1,t.offset))*(n[1]-n[0]),color:t.color,opacity:t.opacity,thresholdType:"greater"})).sort((t,e)=>t.value-e.value),a=s&&s.length>0?(()=>{const e=s.reduce((t,e)=>(t.at(-1)?.value===e.value?t[t.length-1]=e:t.push(e),t),[]),o=[{from:n[0],to:e[0].value,color:e[0].color,opacity:e[0].opacity}];for(let t=0;e.length>t;t++)o.push({from:e[t].value,to:e[t+1]?.value??n[1],color:e[t].color,opacity:e[t].opacity});return o.map(({from:e,to:o,color:i,opacity:n})=>{const r=t.scales.y(e),s=t.scales.y(o);return{y:Math.min(r,s),height:Math.abs(s-r),color:i,...null!=n&&{opacity:n}}}).filter(t=>t.height>0)})():void 0,c=t.getY0?e=>{const o=t.getY0(e);return null==o?r:o}:void 0;for(const e of o){const o=t.resolveAreaStyle(e.key,ge(e.data)),n=ea(e.data,t.scales,t.getX,t.getY,r,o,e.key,c),l=Fa(t.config.gradientFill);l&&(n.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),s&&s.length>0&&(n.colorThresholds=s,n.strokeColorBands=a),i.push(n)}return _a(t,o,i),i}(t,e),canvasRenderers:[zm,Wm]},Xm={chartType:"stackedarea",buildScene:(t,e)=>function(t,e){const o=t.groupData(e),i=t.config.stackOrder??"key",n=()=>o.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===i);else if("key"===i)n();else if("asc"===i||"desc"===i||"insideOut"===i){const e=new Map;for(const i of o){let o=0;for(const e of i.data){const i=t.getX(e),n=t.getY(e);Number.isFinite(i)&&Number.isFinite(n)&&(o+=n)}e.set(i.key,o)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===i)o.sort((t,o)=>{const i=(e.get(t.key)??0)-(e.get(o.key)??0);return 0!==i?i:n(t.key,o.key)});else if("desc"===i)o.sort((t,o)=>{const i=(e.get(o.key)??0)-(e.get(t.key)??0);return 0!==i?i:n(t.key,o.key)});else{const t=[...o].sort((t,o)=>{const i=(e.get(o.key)??0)-(e.get(t.key)??0);return 0!==i?i:n(t.key,o.key)}),i=[],r=[];let s=0,a=0;for(const o of t)a>s?(i.push(o),s+=e.get(o.key)??0):(r.push(o),a+=e.get(o.key)??0);o.length=0,o.push(...r.reverse(),...i)}}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,o,i,n,r,s,a="zero"){const c=new Set,l=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=o(n),r=i(n);if(!Number.isFinite(e))continue;if(c.add(e),!Number.isFinite(r))continue;const s=t.get(e);s?(s.value+=r,s.sources?s.sources.push(n):s.sources=[s.datum,n]):t.set(e,{value:r,datum:n})}l.set(e.key,t)}const u=Array.from(c).sort((t,e)=>t-e);let d;if(r){d=new Map;for(const e of u){let o=0;for(const i of t)o+=l.get(i.key)?.get(e)?.value||0;d.set(e,o||1)}}const h=oa(u,t.map(t=>t.key),(t,e)=>l.get(t)?.get(e)?.value||0,a),f="diverging"===a&&!r,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of u)g.set(t,h.get(t)??0),m.set(t,0),x.set(t,0);for(const o of t){const t=l.get(o.key),i=new Map;let a=[],c=[],h=[],b=[],v=[],w=!1;const k=()=>{if(0!==a.length){if(a.length>=2){const t=w?a.map((t,e)=>e).sort((t,e)=>a[t][0]-a[e][0]):void 0,e={type:"area",topPath:t?t.map(t=>a[t]):a,bottomPath:t?t.map(t=>c[t]):c,rawValues:t?t.map(t=>h[t]):h,style:n(o.key,ge(o.data)),datum:t?t.map(t=>b[t]):b,accessibleDatum:t?t.map(t=>v[t]):v,group:o.key};s&&(e.curve=s),p.push(e)}a=[],c=[],h=[],b=[],v=[],w=!1}};for(const n of u){const s=t.get(n),l=void 0!==s;let u,p,y=s?.value??0;if(r&&l&&(y/=d.get(n)),!l||!Number.isFinite(y)||0===y){k();continue}f?y>0?(u=m.get(n),p=u+y,m.set(n,p)):(u=x.get(n),p=u+y,x.set(n,p)):(u=g.get(n),p=u+y,g.set(n,p));const A=e.x(n),S=e.y(u),M=e.y(p);if(!Number.isFinite(A)||!Number.isFinite(S)||!Number.isFinite(M)){k();continue}const _=s.sources,$=s.value,P=_?{..._[0],__aggregateValue:$,__aggregateCount:_.length,__aggregateRows:_}:s.datum;a.length>0&&a[a.length-1][0]>A&&(w=!0),a.push([A,M]),c.push([A,S]),b.push(P),h.push($),v.push(_?{x:n,value:$,group:o.key,observations:_.length}:P),i.set(n,p)}k(),y.set(o.key,i)}return{nodes:p,stackedTops:y}}(o,t.scales,t.getX,t.getY,(e,o)=>t.resolveAreaStyle(e,o),t.config.normalize,r,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const i of o){const o=c.get(i.key);if(o)for(const n of i.data){const i=t.getX(n),r=t.getY(n);null==i||Number.isNaN(i)||null==r||Number.isNaN(r)||!o.has(i)||e.set(n,o.get(i))}}const i=o=>e.get(o)??t.getY(o);_a(t,o,l,i)}return l}(t,e),canvasRenderers:[zm,Wm]},Gm={chartType:"mixed",buildScene:(t,e)=>function(t,e){const o=t.groupData(e),i=[],n=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Aa(t.ribbons);if(r.length>0&&i.push(...Sa(t,e,r)),n.length>0)for(const e of o)i.push(...Ma(t,e.data,e.key,n))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const o=t.getY0(e);return null==o?r:o}:void 0;for(const e of o)if(n.has(e.key)){const o=t.resolveAreaStyle(e.key,ge(e.data)),n=ea(e.data,t.scales,t.getX,t.getY,r,o,e.key,s),a=Fa(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),i.push(n)}else{const o=t.resolveLineStyle(e.key,ge(e.data)),n=ta(e.data,t.scales,t.getX,t.getY,o,e.key);t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),i.push(n)}return _a(t,o,i),i}(t,e),canvasRenderers:[zm,Bm,Wm]},Vm=require("d3-shape"),Hm={circle:Vm.symbolCircle,square:Vm.symbolSquare,triangle:Vm.symbolTriangle,diamond:Vm.symbolDiamond,star:Vm.symbolStar,cross:Vm.symbolCross,wye:Vm.symbolWye},Um=new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),Km=["circle","triangle","diamond","star","square","chevron","cross","wye"],Zm=[40,40],Qm=[.5,.5],Jm=null,tx=new Map,ex=(t,e)=>{const o=t.globalAlpha;for(const i of e)"symbol"===i.type&&Va(t,i,i.x,i.y,o,"#4e79a7");t.globalAlpha=o},ox=[Wm,ex],ix={chartType:"scatter",buildScene:(t,e)=>Ea(t,e),canvasRenderers:ox},nx={chartType:"bubble",buildScene:(t,e)=>Ea(t,e),canvasRenderers:ox},rx=256,sx=new Map,ax=(t,e,o,i)=>{const n=e.filter(t=>"heatcell"===t.type);t.save();try{const e=ni(t,"var(--semiotic-font-family, sans-serif)")||"sans-serif";for(const o of n){const i=o.style;null!=i?.opacity&&(t.globalAlpha=i.opacity);const n=Kr(t,o.fill,"#4e79a7");t.fillStyle=n,t.fillRect(o.x,o.y,o.w,o.h);const r=Math.max(0,i?.strokeWidth??1);if(r>0&&(t.strokeStyle=ni(t,i?.stroke??"var(--semiotic-surface, #fff)"),t.lineWidth=r,t.strokeRect(o.x,o.y,o.w,o.h)),ja(t,o),t.globalAlpha=1,o.showValues&&null!=o.value){if(20>o.w||20>o.h)continue;const i=o.valueFormat?o.valueFormat(o.value):Ja(o.value),r=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h))),s=o.x+o.w/2,a=o.y+o.h/2;t.fillStyle=Qa(t,"string"==typeof n?n:"#4e79a7"),t.font=`${r}px ${e}`,t.textAlign="center",t.textBaseline="middle",t.fillText(i,s,a)}}}finally{t.restore()}},cx={chartType:"heatmap",buildScene:(t,e,o)=>function(t,e,o){if(t.config.heatmapAggregation)return Za(t,e,o);if(0===e.length)return[];const i=_s(t.config.valueAccessor,"value"),n=$s(t.config.xAccessor,"x"),r=$s(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 o=e[t],i=n(o),u=r(o);c[t]=i,l[t]=u,s.has(i)||s.set(i,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t)),g=4096;if(p&&y&&u*d>g&&e.length>g){const i=new Set;for(let n=0;e.length>n;n++){const r=s.get(c[n]),d=a.get(l[n]);if(void 0!==r&&void 0!==d&&(i.add(d*u+r),i.size>g))return Za({...t,config:{...t.config,heatmapAggregation:t.config.valueAccessor?"mean":"count"}},e,o)}}if(p){h.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;h.length>t;t++)s.set(h[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 m=new Float64Array(e.length),x=new Float64Array(e.length),b=Array(e.length),v=new Map;let w=0;for(let t=0;e.length>t;t++){const o=e[t],n=s.get(c[t]),r=a.get(l[t]);if(void 0===n||void 0===r)continue;const d=i(o),h=r*u+n,f=v.get(h);let p;void 0!==f?p=f:(p=w++,v.set(h,p)),m[p]=h,x[p]=d,b[p]=o}let k=1/0,A=-1/0;for(let t=0;w>t;t++){const e=x[t];isFinite(e)&&(k>e&&(k=e),e>A&&(A=e))}if(!isFinite(k)||!isFinite(A))return[];const S=t.config.heatmapColorScale,M=S?void 0:Ua("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=o.width/u,$=o.height/d,P=t.config.showValues,j=t.config.heatmapValueFormat,I=[];for(let e=0;w>e;e++){const o=x[e];if(!isFinite(o))continue;const i=m[e],n=i%u,r=(i-n)/u,s=Ha(o,k,A),a=S?S(o):M[s],c=b[e];I.push(Ka(sa(n*_,(d-1-r)*$,_,$,a,c,P?{value:o,showValues:!0,valueFormat:j}:{value:o}),c,t))}return I}(t,e,o),canvasRenderers:[ax]},lx=(t,e,o,i)=>{const n=e.filter(t=>"rect"===t.type);for(const e of n){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)rc(t,e);else if(e.cornerRadii&&tc(e.cornerRadii))t.fillStyle=ic(t,e),oc(t,e),t.fill(),nc(t,e)&&t.stroke();else if(e.roundedTop&&e.roundedTop>0){t.fillStyle=ic(t,e);const o=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:i,y:n,w:r,h:s}=e;switch(e.roundedEdge){case"right":t.moveTo(i,n),t.lineTo(i+r-o,n),t.arcTo(i+r,n,i+r,n+o,o),t.lineTo(i+r,n+s-o),t.arcTo(i+r,n+s,i+r-o,n+s,o),t.lineTo(i,n+s);break;case"left":t.moveTo(i+r,n),t.lineTo(i+o,n),t.arcTo(i,n,i,n+o,o),t.lineTo(i,n+s-o),t.arcTo(i,n+s,i+o,n+s,o),t.lineTo(i+r,n+s);break;case"bottom":t.moveTo(i,n),t.lineTo(i+r,n),t.lineTo(i+r,n+s-o),t.arcTo(i+r,n+s,i+r-o,n+s,o),t.lineTo(i+o,n+s),t.arcTo(i,n+s,i,n+s-o,o);break;default:t.moveTo(i,n+s),t.lineTo(i,n+o),t.arcTo(i,n,i+o,n,o),t.lineTo(i+r-o,n),t.arcTo(i+r,n,i+r,n+o,o),t.lineTo(i+r,n+s)}t.closePath(),t.fill(),nc(t,e)&&t.stroke()}else t.fillStyle=ic(t,e),t.fillRect(e.x,e.y,e.w,e.h),nc(t,e)&&t.strokeRect(e.x,e.y,e.w,e.h);ja(t,e),t.globalAlpha=1}},ux={chartType:"bar",buildScene:(t,e)=>function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=Qs(e,t.getX,t.getY,t.config.binSize,t.getCategory,!!t.config.trackHoverRows||me(t.config.areaStyle));if(0===o.size)return{nodes:[],binBoundaries:[]};let i=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const o of t.categories.keys())e.add(o);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?i=t.barCategoryCache.order:(i=[...a,...s],t.barCategoryCache={key:c,order:i})}const n=[],r=t.scales,[s,a]=r.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity),c?.cursor&&(h.cursor=c.cursor);for(const e of o.values()){const o=Math.max(e.start,s),u=Math.min(e.end,a);if(o>=u)continue;const f=r.x(o),p=r.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(i&&e.categories.size>0){let o=0;for(const s of i){const i=e.categories.get(s)||0;if(0===i)continue;const a=r.y(o),u=r.y(o+i),d=Math.min(a,u),f=Math.abs(a-u),p=(t.config.barColors?Mt(t.config.barColors,s):void 0)??c?.fill??l??"#4e79a7",y=fe({binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:i},e.categoryRows?.get(s)),g=t.config.areaStyle?.(y)??{};n.push(ra(m,d,x,f,{fill:p,...h,...g},y,s)),o+=i}}else{const o=r.y(0),i=r.y(e.total),s=Math.min(o,i),a=Math.abs(o-i),u=c?.fill||l||"#007bff",d=fe({binStart:e.start,binEnd:e.end,total:e.total},e.rows),f=t.config.areaStyle?.(d)??{};n.push(ra(m,s,x,a,{fill:u,...h,...f},d))}}const f=new Set;for(const t of o.values())f.add(t.start),f.add(t.end);return{nodes:n,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(t,e),canvasRenderers:[lx]},dx={chartType:"swarm",buildScene:(t,e)=>function(t,e){const o=[],i=t.config.swarmStyle||{},n=i.radius??3,r=i.fill??t.config.themeSemantic?.primary??"#007bff",s=i.opacity??.7,a=i.stroke,c=i.strokeWidth,l=i.cursor;for(const i of e){const e=t.getX(i),u=t.getY(i);if(null==u||Number.isNaN(u))continue;const d=t.scales.x(e),h=t.scales.y(u);let f=r;if(t.getCategory){const e=t.getCategory(i)+"";f=(t.config.barColors?Mt(t.config.barColors,e):void 0)??f}const{r:p,...y}=t.config.pointStyle?.(i)??{},g={type:"point",x:d,y:h,r:p??n,style:{fill:f,opacity:s,stroke:a,strokeWidth:c,cursor:l,...y},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),o.push(g)}return o}(t,e),canvasRenderers:[Wm]},hx=(t,e,o,i)=>{lx(t,e);const n=e.filter(t=>"rect"===t.type);if(2>n.length)return;const r=n[0].datum,s=r?._connectorStroke;if(s){t.save(),t.strokeStyle=ni(t,s)||s,t.lineWidth=r?._connectorWidth??1,t.setLineDash([]);for(let e=0;n.length-1>e;e++){const i=n[e],r=n[e+1],s=i.datum,a=r.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=o.y(s.cumEnd),l=i.x+i.w,u=r.x;t.beginPath(),t.moveTo(l,c),t.lineTo(u,c),t.stroke()}t.restore()}},fx={chartType:"waterfall",buildScene:(t,e,o)=>function(t,e,o){const i=[],n=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const o=t.getY(e),i=t.getX(e);return null!=o&&!Number.isNaN(o)&&null!=i&&isFinite(i)});if(0===s.length)return i;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,d=r?.strokeWidth,h=r?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g,x=n.x(y),b=e>0?n.x(t.getX(s[e-1])):void 0,v=s.length-1>e?n.x(t.getX(s[e+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-o.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+o.width/20,A=Math.min(w,k)+l/2,S=Math.max(w,k)-l/2-A;if(0>=S){f=m;continue}const M=n.y(f),_=n.y(m),$=Math.min(M,_),P=Math.abs(M-_),j=0>g?c:a,I={...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth},L={fill:j,stroke:u,strokeWidth:d,opacity:h,cursor:r?.cursor,...t.config.areaStyle?.(I)};i.push(ra(A,$,S,P,L,I)),f=m}return i}(t,e,o),canvasRenderers:[hx]},px=(t,e,o,i)=>{for(const o of e){if("candlestick"!==o.type)continue;const e=o;t.save();const n=(e._decayOpacity??1)*(e.style?.opacity??1);1!==n&&(t.globalAlpha=n);const r=ni(t,e.wickColor)||e.wickColor,s=60>i.height,a=s?Math.max(e.wickWidth,2):e.wickWidth,c=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=r,t.lineWidth=a,t.stroke()};if(s||c(),e.isRange){const o=e.dotRadius??Math.max(2,Math.min(e.bodyWidth/2,.12*i.height)),n=Kr(t,ri(e.style?.fill)?e.style.fill:e.wickColor,e.wickColor);t.fillStyle=n,t.beginPath(),t.arc(e.x,e.highY,o,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,o,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const o=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),n=e.isUp?e.upColor:e.downColor,r=Kr(t,ri(e.style?.fill)?e.style.fill:n,n),s="string"==typeof r?r:ni(t,e.wickColor)||e.wickColor;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.strokeStyle=s,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1))}s&&c(),t.restore()}},yx={chartType:"candlestick",buildScene:(t,e,o)=>function(t,e,o){if(!t.getHigh||!t.getLow||!t.scales)return[];const i=t.config.candlestickRangeMode??!1;if(!(i||t.getOpen&&t.getClose))return[];const n=[],r=t.config.candlestickStyle||{},s=r.rangeColor||"#6366f1",a=i?s:r.upColor||"#28a745",c=i?s:r.downColor||"#dc3545",l=i?s:r.wickColor||"#333",u=r.wickWidth||(i?2:1);let d=r.bodyWidth??0;if(null==r.bodyWidth){const o=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);if(o.length>1){let e=1/0,i=t.scales.x(o[0]);for(let n=1;o.length>n;n++){const r=t.scales.x(o[n]),s=Math.abs(r-i);s>0&&e>s&&(e=s),i=r}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else d=6}for(const s of e){const e=t.getX(s);if(null==e||Number.isNaN(e))continue;const h=t.getHigh(s),f=t.getLow(s);if(null==h||Number.isNaN(h)||null==f||Number.isNaN(f))continue;const p=i?h:t.getOpen(s),y=i?f:t.getClose(s);if(!i&&(null==p||Number.isNaN(p)||null==y||Number.isNaN(y)))continue;const g=y>=p,m=t.config.pointStyle?.(s)??{},x="string"==typeof m.fill?m.fill:void 0,b="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(p),closeY:t.scales.y(y),highY:t.scales.y(h),lowY:t.scales.y(f),bodyWidth:d,upColor:x&&g?x:a,downColor:x&&!g?x:c,wickColor:b??(i&&x?x:l),wickWidth:v??u,isUp:g,style:{cursor:r.cursor,...m,...void 0!==w&&{opacity:w}},datum:s};i&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*o.height))),n.push(k)}return n}(t,e,o),canvasRenderers:[px]},gx={chartType:"custom",buildScene:()=>[],canvasRenderers:[zm,lx,ax,Bm,Wm,ex,(t,e)=>{const o=t.globalAlpha;for(const i of e)"glyph"===i.type&&sc(t,i,i.x,i.y,o);t.globalAlpha=o},px,Wm,hx]},mx=Wh(require("react")),xx=require("d3-shape"),bx=Wh(require("react")),vx=require("react/jsx-runtime"),wx={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0},kx=(Wh(require("react")),require("react/jsx-runtime")),Ax=require("react/jsx-runtime"),Sx=new Set,Mx=require("d3-scale"),_x=require("react/jsx-runtime"),$x=Qh,Px=require("react/jsx-runtime"),jx="var(--semiotic-bg, #ffffff)",Ix=.85,Lx=require("react/jsx-runtime"),Rx=16,Tx=require("react/jsx-runtime"),Cx=require("react/jsx-runtime"),Ox=require("react/jsx-runtime"),Fx={secondary:0,primary:3},Dx=1,Nx=2,zx=.6,Ex="0.88em",Bx=.95,Wx=.72,Yx=.06,qx=".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}}",Xx=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}",Gx=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Vx=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),Hx=1,Ux=32,Kx=6,Zx=4,Qx=8,Jx=72,tb=30,eb=-30,ob=8,ib=480,nb=3,rb={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},sb=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]),ab=require("react/jsx-runtime"),cb={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"},lb=require("d3-hierarchy"),ub=require("d3-shape"),db=(Wh(require("react")),require("react/jsx-runtime")),hb={linear:ub.curveLinear,monotoneX:ub.curveMonotoneX,monotoneY:ub.curveMonotoneY,step:ub.curveStep,stepAfter:ub.curveStepAfter,stepBefore:ub.curveStepBefore,basis:ub.curveBasis,cardinal:ub.curveCardinal,catmullRom:ub.curveCatmullRom},fb=require("react/jsx-runtime"),pb=16,yb=require("react/jsx-runtime"),gb=Wh(require("react")),mb=require("react/jsx-runtime"),xb=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],bb=864e5,vb=3156e7,wb=require("react/jsx-runtime"),kb={right:110,left:110,top:50,bottom:80},Ab=require("react/jsx-runtime"),Sb={top:50,right:40,bottom:60,left:70},Mb={top:20,right:80,bottom:20,left:80},_b={top:40,right:40,bottom:40,left:40},$b=new Set(["chord","force","circlepack","orbit"]),Pb=require("react/jsx-runtime"),jb=require("react/jsx-runtime");ac();var Ib=Wh(require("react-dom/server")),Lb=require("react/jsx-runtime"),Rb=require("react/jsx-runtime"),Tb=require("react/jsx-runtime"),Cb={top:4,bottom:4,left:4,right:4},Ob={frameType:"xy",buildProps:su,renderStatic:function(t,e){const{data:o,colorBy:i,colorScheme:n,common:r,rest:s}=au(t),[a,c]=r.size??[600,400],l=s.minimap&&"object"==typeof s.minimap?s.minimap:{},u=cu(l.height,60),d=r.margin,h=l.margin&&"object"==typeof l.margin?l.margin:{},f={top:cu(h.top,0),right:cu(h.right,cu(d?.right,20)),bottom:cu(h.bottom,20),left:cu(h.left,cu(d?.left,40))},p=u+f.top+f.bottom,y=s.frameProps&&"object"==typeof s.frameProps?s.frameProps:{},g={...s,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y"},m={...r,size:[a,c],xExtent:y.xExtent??s.brushExtent??r.xExtent,yExtent:y.yExtent??s.yExtent??r.yExtent,_idPrefix:(r._idPrefix??"minimap")+"-detail"},x=Tp.buildProps(o,i,n,m,g);Object.assign(x,y);const b={...r,size:[a,p],margin:f,title:void 0,description:(r.description??r.title??"Chart")+" overview minimap",showAxes:l.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:l.background,xExtent:void 0,yExtent:s.yExtent??r.yExtent,_idPrefix:(r._idPrefix??"minimap")+"-overview"};delete b.lineStyle,delete b.pointStyle;const v={...g,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=Tp.buildProps(o,i,n,b,v);w.chartType=s.fillArea?"area":"line","function"==typeof l.lineStyle&&(w.lineStyle=l.lineStyle);const k={},A={},S=Hl(x,k),M=Hl(w,A),_=!0===s.renderBefore,$=_?0:c,P=""+uu(S,0,_?p:0,"detail")+uu(M,0,$,"overview"),j=c+p,I=Qt(Zt(r.theme)),L="string"==typeof r.title?r.title:void 0,R="string"==typeof r.description?r.description:L||"Chart with overview minimap",T=El(r),C=L?T+"-title":void 0,O=T+"-description",F="y"===l.brushDirection?"y":"x",D=Array.isArray(s.brushExtent)&&s.brushExtent.length>=2?[Number(s.brushExtent[0]),Number(s.brushExtent[1])]:null,N=A.evidence;let z=null;if(D&&D.every(Number.isFinite)&&N){const t="x"===F?N.xDomain:N.yDomain;if(t&&t[0]!==t[1]){const e=Math.max(0,a-f.left-f.right),o=u,i=e=>(e-t[0])/(t[1]-t[0]);if("x"===F){const t=i(Math.min(...D))*e,n=i(Math.max(...D))*e;z=(0,Tb.jsx)("rect",{className:"selection",x:f.left+t,y:$+f.top,width:n-t,height:o,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{const t=(1-i(Math.max(...D)))*o,n=(1-i(Math.min(...D)))*o;z=(0,Tb.jsx)("rect",{className:"selection",x:f.left,y:$+f.top+t,width:e,height:n-t,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}const E=um.renderToStaticMarkup((0,Tb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:a,height:j,role:"img","aria-labelledby":[C,O].filter(Boolean).join(" "),style:{fontFamily:I.fontFamily},children:[L&&(0,Tb.jsx)("title",{id:C,children:L}),(0,Tb.jsx)("desc",{id:O,children:R}),(0,Tb.jsx)("g",{dangerouslySetInnerHTML:{__html:P}}),z]}));if(e){const t=[k.evidence,A.evidence];e.evidence=cc({frameType:"xy",width:a,height:j,parts:t,title:L,description:R,xDomain:du(t,"xDomain"),yDomain:du(t,"yDomain")})}return E}},Fb={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(t,e,o,i,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,...i,showAxes:!1,margin:i.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:Pp,LineChart:Tp,AreaChart:Op,DifferenceChart:Fp,StackedAreaChart:Dp,Scatterplot:kp,CandlestickChart:Np,BubbleChart:Ap,ConnectedScatterplot:Ep,QuadrantChart:zp,Heatmap:Bp,WaterfallChart:Rp,MultiAxisLineChart:Lp,MinimapChart:Ob,ScatterplotMatrix:{frameType:"xy",buildProps:su,renderStatic:function(t,e){const{data:o,colorBy:i,colorScheme:n,common:r,rest:s}=au(t),a=Array.isArray(c=o)?c.filter(t=>null!=t&&"object"==typeof t&&!Array.isArray(t)):[];var c;const l=Array.isArray(s.fields)?s.fields.filter(t=>"string"==typeof t):[],u=s.fieldLabels&&"object"==typeof s.fieldLabels?s.fieldLabels:{},d=lu(s.cellSize,150),h=Math.max(0,cu(s.cellGap,4)),f=Math.max(0,cu(s.pointRadius,2)),p=Math.max(0,Math.min(1,cu(s.pointOpacity,.5))),y=lu(s.histogramBins,20),g="string"==typeof s.diagonal?s.diagonal:"histogram",m=40+l.length*d+l.length*h,x=l.length*d+40+l.length*h,b=Zt(r.theme),v=Qt(b),w=function(t,e,o,i){if(!e)return{categories:[],color:()=>sp};const n=Array.from(new Set(t.map(t=>hu(t,e)))),r="string"==typeof e?e:"__semioticSplomColor",s=_t("function"==typeof e?t.map(t=>({...t,[r]:hu(t,e)})):t,r,o??i.colors.categorical);return{categories:n,color:t=>St(t,e,s)}}(a,i,n,b),k="string"==typeof r.title?r.title:void 0,A="string"==typeof r.description?r.description:`Scatterplot matrix comparing ${l.length} fields`,S=k?28:0,M=s.showLegend??!!i?w.categories:[];let _=0,$=0;const P=M.map(t=>{const e=(t=>Math.max(72,30+7*t.length))(t);_>0&&_+e>m&&($+=1,_=0);const o={label:t,x:_,y:24*$};return _+=e,o}),j=S+(M.length?24*($+1)+4:0),I=j+x,L=[],R=[];let T=0;l.forEach((t,e)=>{l.forEach((o,n)=>{const c=40+h+n*(d+h),l=j+e*(d+h);if(e===n){const e=function(t){const{data:e,field:o,label:i,cellSize:n,bins:r,diagonal:s,colorBy:a,color:c,x:l,y:u}=t;if("label"===s)return{visibleBars:0,svg:um.renderToStaticMarkup((0,Tb.jsx)("svg",{x:l,y:u,width:n,height:n,"data-semiotic-composite-part":"diagonal-"+o,children:(0,Tb.jsx)("text",{x:n/2,y:n/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:i})}))};const d=e.map(t=>Number(t[o])).filter(Number.isFinite),h=d.length?Math.min(...d):0,f=((d.length?Math.max(...d):0)-h)/r||1,p=Array.from({length:r},()=>new Map);for(const t of e){const e=Number(t[o]);if(!Number.isFinite(e))continue;const i=Math.max(0,Math.min(r-1,Math.floor((e-h)/f))),n=a?hu(t,a):"__all",s=p[i];s.set(n,[...s.get(n)??[],t])}const y=p.map(t=>Array.from(t.values()).reduce((t,e)=>t+e.length,0)),g=Math.max(1,...y);let m=0;const x=p.flatMap((t,e)=>{let o=0;return Array.from(t.entries()).flatMap(([t,i])=>{if(0===i.length)return[];m+=1;const s=i.length/g*(n-24),l=o;return o+=s,(0,Tb.jsx)("rect",{x:e/r*n,y:n-l-s,width:Math.max(n/r-1,1),height:s,fill:a?c(i[0]):sp,opacity:.6},`${e}-${t}`)})});return{visibleBars:m,svg:um.renderToStaticMarkup((0,Tb.jsxs)("svg",{x:l,y:u,width:n,height:n,"data-semiotic-composite-part":"diagonal-"+o,children:[(0,Tb.jsx)("text",{x:n/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:i}),x]}))}}({data:a,field:t,label:Mt(u,t)??t,cellSize:d,bins:y,diagonal:g,colorBy:i,color:w.color,x:c,y:l});return T+=e.visibleBars,void R.push(e.svg)}const m={},x=Hl({chartType:"scatter",data:a,size:[d,d],xAccessor:o,yAccessor:t,pointStyle:Ft(t=>({r:f,opacity:p,fill:w.color(t)}),s.styleRules,Lt(o,t)),margin:Cb,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Mt(u,o)??o} versus ${Mt(u,t)??t} scatterplot`,theme:r.theme,_idPrefix:`${(r._idPrefix??"splom")+""}-${e}-${n}`},m);L.push(m.evidence),R.push(uu(x,c,l,`cell-${t}-${o}`))})});const C=El(r),O=k?C+"-title":void 0,F=C+"-description",D=um.renderToStaticMarkup((0,Tb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:m,height:I,role:"img","aria-labelledby":[O,F].filter(Boolean).join(" "),style:{fontFamily:v.fontFamily},children:[k&&(0,Tb.jsx)("title",{id:O,children:k}),(0,Tb.jsx)("desc",{id:F,children:A}),(0,Tb.jsx)("rect",{width:m,height:I,fill:v.background}),k&&(0,Tb.jsx)("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:v.text,children:k}),P.map(t=>{const e=a.find(e=>i&&hu(e,i)===t.label),o=e?w.color(e):sp;return(0,Tb.jsxs)("g",{transform:`translate(${t.x},${S+t.y})`,children:[(0,Tb.jsx)("circle",{cx:5,cy:8,r:5,fill:o}),(0,Tb.jsx)("text",{x:14,y:12,fontSize:11,fill:v.text,children:t.label})]},t.label)}),l.map((t,e)=>{const o=j+e*(d+h)+d/2;return(0,Tb.jsx)("text",{x:20,y:o,transform:`rotate(-90 20 ${o})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:Mt(u,t)??t},"row-"+t)}),l.map((t,e)=>(0,Tb.jsx)("text",{x:40+h+e*(d+h)+d/2,y:j+l.length*(d+h)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:Mt(u,t)??t},"column-"+t)),(0,Tb.jsx)("g",{dangerouslySetInnerHTML:{__html:R.join("")}})]}));return e&&(e.evidence=cc({frameType:"xy",width:m,height:I,parts:L,additionalMarkCountByType:T>0?{histogram:T}:void 0,title:k,description:A,categories:w.categories.length?w.categories:void 0,legendItems:M.length||void 0})),D}},TemporalHistogram:Cp,XYCustomChart:Ky,BarChart:Up,StackedBarChart:Kp,GroupedBarChart:Zp,PieChart:Qp,DonutChart:Jp,Histogram:ty,BoxPlot:ey,ViolinPlot:oy,SwarmPlot:iy,DotPlot:ny,SwimlaneChart:sy,RidgelinePlot:ay,LikertChart:Xp,FunnelChart:cy,RadarChart:ry,GaugeChart:Hp,OrdinalCustomChart:Zy,ParallelCoordinatesRecipe:Qy,CalendarHeatmapRecipe:Jy,ForceDirectedGraph:Iy,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(t,e,o,i,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:o,customNetworkLayout:n.layout||n.customNetworkLayout,layoutConfig:n.layoutConfig,...i})},SankeyDiagram:Cy,ProcessSankey:Ty,ChordDiagram:jy,TreeDiagram:Oy,Treemap:Fy,CirclePack:Ly,OrbitDiagram:Ry,ChoroplethMap:zy,ProportionalSymbolMap:Ey,FlowMap:Wy,DistanceCartogram:By,GeoCustomChart:{frameType:"geo",buildProps:(t,e,o,i,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:o,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...i})},GaltonBoardChart:em,EventDropChart:om,UnitPileChart:im,CollisionSwarmChart:nm,ProcessFlowChart:rm,GauntletChart:sm,CrucibleChart:am,PacketFlowChart:cm,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:su,renderStatic:function(t,e){const{data:o,common:i,rest:n}=function(t){return t.__composite}(t),r=Array.isArray(s=o)?s.filter(t=>null!=t&&"object"==typeof t&&!Array.isArray(t)):[];var s;const[a,c]=i.size??[920,620],l="string"==typeof i.title?i.title:"Dependency chain reaction",u=function(t){const e=[],o=new Map,i=[],n=new Set;t.data.forEach((r,s)=>{const a=(tu(r,s,t.taskIDAccessor)??"")+"";if(!a)return void e.push({code:"duplicate-task-id",message:`Task row ${s} has an empty id.`,taskIDs:[]});if(o.has(a))return void e.push({code:"duplicate-task-id",message:`Task id "${a}" occurs more than once.`,taskIDs:[a]});const c=(tu(r,s,t.laneAccessor)??"Unassigned")+"";n.has(c)||(n.add(c),i.push(c));const l=tu(r,s,t.dependencyAccessor)??[],u=Array.from(new Set(Array.from(l,t=>t+""))).sort(eu),d=tu(r,s,t.blockerAccessor),h=tu(r,s,t.statusAccessor)??(d?"blocked":"waiting");o.set(a,{id:a,label:(tu(r,s,t.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:s,datum:r,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:tu(r,s,t.startAccessor),end:tu(r,s,t.endAccessor),progress:nu(tu(r,s,t.progressAccessor)),status:h,completionTime:tu(r,s,t.completionTimeAccessor),blockerReason:d||void 0,milestone:!!tu(r,s,t.milestoneAccessor)})});const r=t.laneOrder?[...t.laneOrder,...i.filter(e=>!t.laneOrder?.includes(e))]:i,s=new Map(r.map((t,e)=>[t,e]));for(const t of o.values())t.laneIndex=s.get(t.lane)??0;const a=new Map,c=new Map;for(const t of o.keys())a.set(t,[]),c.set(t,[]);const l=[],u=[...o.values()].sort((t,e)=>t.index-e.index);for(const t of u)t.dependencyIDs.forEach((i,n)=>{const r=o.get(i);if(!r)return void e.push({code:"missing-dependency",message:`Task "${t.id}" depends on missing task "${i}".`,taskIDs:[t.id,i]});const s={id:ou(i,t.id),sourceID:i,targetID:t.id,sourceIndex:r.index,targetIndex:t.index,socketID:iu(t.id,n),socketIndex:n};l.push(s),a.get(t.id)?.push(s),c.get(i)?.push(s),t.incomingEdgeIDs.push(s.id),t.socketIDs.push(s.socketID),r.outgoingEdgeIDs.push(s.id)});for(const t of a.values())t.sort((t,e)=>eu(t.sourceID,e.sourceID)),t.forEach((t,e)=>{t.socketIndex=e,t.socketID=iu(t.targetID,e)});for(const t of c.values())t.sort((t,e)=>eu(t.targetID,e.targetID));for(const t of o.values()){const e=a.get(t.id)??[];t.incomingEdgeIDs=e.map(t=>t.id),t.socketIDs=e.map(t=>t.socketID),t.outgoingEdgeIDs=(c.get(t.id)??[]).map(t=>t.id)}const d=new Map,h=new Map;for(const t of o.keys())d.set(t,a.get(t)?.length??0),h.set(t,0);const f=[...o.keys()].filter(t=>0===d.get(t)).sort(eu);let p=0;for(;f.length;){const t=f.shift();p+=1;for(const e of c.get(t)??[]){const o=Math.max(h.get(e.targetID)??0,(h.get(t)??0)+1);h.set(e.targetID,o);const i=(d.get(e.targetID)??0)-1;if(d.set(e.targetID,i),0===i){const t=f.findIndex(t=>t>e.targetID);0>t?f.push(e.targetID):f.splice(t,0,e.targetID)}}}if(p!==o.size){const t=[...o.keys()].filter(t=>(d.get(t)??0)>0).sort(eu);e.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${t.join(", ")}.`,taskIDs:t})}let y=0;const g=[...o.values()].sort((t,e)=>t.index-e.index);for(const t of g)t.level=h.get(t.id)??0,y=Math.max(y,t.level);return{nodes:g,edges:l,byID:o,incoming:a,outgoing:c,lanes:r,maxLevel:y,diagnostics:e,valid:0===e.length}}({data:r,taskIDAccessor:n.taskIDAccessor,labelAccessor:n.labelAccessor,laneAccessor:n.laneAccessor,dependencyAccessor:n.dependencyAccessor,startAccessor:n.startAccessor,endAccessor:n.endAccessor,progressAccessor:n.progressAccessor,statusAccessor:n.statusAccessor,completionTimeAccessor:n.completionTimeAccessor,blockerAccessor:n.blockerAccessor,milestoneAccessor:n.milestoneAccessor}),d=Zt(i.theme),h=Qt(d),f=El(i),p=f+"-title",y=f+"-description";if(!u.valid){const t=u.diagnostics.map(t=>t.message).join(" "),o=Ib.renderToStaticMarkup((0,Rb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:c,role:"img","aria-labelledby":`${p} ${y}`,style:{fontFamily:h.fontFamily},children:[(0,Rb.jsx)("title",{id:p,children:l}),(0,Rb.jsx)("desc",{id:y,children:t}),(0,Rb.jsx)("rect",{width:a,height:c,fill:h.background}),(0,Rb.jsx)("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:h.text,children:l}),u.diagnostics.map((t,e)=>(0,Rb.jsx)("text",{x:24,y:72+22*e,fontSize:12,fill:d.colors.error,children:t.message},`${t.code}-${e}`))]}));return e&&(e.evidence=cc({frameType:"physics",width:a,height:c,parts:[],title:l,description:t,nodeCount:u.nodes.length,edgeCount:u.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),o}const g=function(t,e,o={}){const i=Math.max(240,e.width),n=Math.max(220,e.height),r=e.paddingX??48,s=e.paddingTop??48,a=e.paddingBottom??44,c=Math.max(70,(i-2*r)/Math.max(1,t.lanes.length)),l=Math.max(76,(n-s-a)/Math.max(1,t.maxLevel+1)),u=Math.min(o.taskWidth??112,Math.max(58,.78*c)),d=Math.min(o.taskHeight??58,.64*l),h=o.socketRadius??5,f=Math.max(1,Math.round(o.gutterCount??3)),p=new Map;for(const e of t.nodes){const t=`${e.laneIndex}:${e.level}`,o=p.get(t)??[];o.push(e),p.set(t,o)}for(const t of p.values())t.sort((t,e)=>eu(t.id,e.id));const y=.86*l,g=t.nodes.map(t=>{const e=p.get(`${t.laneIndex}:${t.level}`)??[t],o=Math.max(0,e.findIndex(e=>e.id===t.id))-(e.length-1)/2,i=(n=e.length)>1?Math.max(22,Math.min(d,(y-4*(n-1))/n)):d;var n;return{taskID:t.id,lane:t.lane,laneIndex:t.laneIndex,level:t.level,x:r+c*(t.laneIndex+.5),y:s+l*(t.level+.5)+o*(i+4),width:u,height:i}}),m=new Map(g.map(t=>[t.taskID,t])),x=[],b=[];t.edges.forEach((e,o)=>{const i=m.get(e.sourceID),n=m.get(e.targetID);if(!i||!n)return;const r=t.incoming.get(e.targetID)??[],s=Math.min(.72*n.width,14*Math.max(1,r.length-1)),a=r.length>1?n.x-s/2+s*e.socketIndex/(r.length-1):n.x,c=n.y-n.height/2-h-2;x.push({id:e.socketID,edgeID:e.id,taskID:n.taskID,index:e.socketIndex,x:a,y:c,radius:h});const l={x:i.x,y:i.y+i.height/2+3},u=Math.min(c-10,l.y+.48*Math.max(18,c-l.y)+7*(o%f-(f-1)/2));var d;b.push({edgeID:e.id,sourceID:e.sourceID,targetID:e.targetID,socketID:e.socketID,points:(d=[l,{x:l.x,y:u},{x:a,y:u},{x:a,y:c}],d.filter((t,e)=>{const o=d[e-1];return!o||o.x!==t.x||o.y!==t.y}))})});const v=new Map(x.map(t=>[t.id,t])),w=new Map(b.map(t=>[t.edgeID,t]));return{tasks:g,sockets:x,routes:b,taskByID:m,socketByID:v,routeByEdgeID:w}}(u,{width:a,height:c}),m=function(t,e,o){const i=t.nodes.map(Zl).filter(t=>null!=t),n=o,r=new Set,s=new Map;for(const e of t.nodes){const t=Zl(e);(null!=t&&n>=t||"done"===e.status&&!0)&&r.add(e.id),e.blockerReason&&!r.has(e.id)&&s.set(e.id,e.blockerReason)}const a=new Set;for(const e of t.edges)r.has(e.sourceID)&&a.add(e.id);return{currentTime:n,playing:!1,completed:r,delivered:a,inFlight:new Set,armed:Ql(t,a,s,r),blockers:s,previewTaskID:null}}(u,0,Kl(n.currentTime,1/0)),x=Array.isArray(n.selectedTaskIDs)?n.selectedTaskIDs.map(String):[],b=new Set(x),v=x[0]??null,w=v&&"none"!==n.insight?ru(u,v,{completedTaskIDs:m.completed}):null,k=new Set(w?.downstreamTaskIDs??[]),A=function(t){return"number"==typeof t&&Number.isFinite(t)?t:31}(n.seed),S=function(t,e,o){const i="string"==typeof o?o:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",n=[...e.blockers.keys()].map(o=>{const i=ru(t,o,{completedTaskIDs:e.completed});return`${t.byID.get(o)?.label??o} affects ${i.downstreamTaskCount} unfinished tasks across ${i.affectedLaneCount} lanes.`}).join(" ");return n?`${i} ${n}`:i+" No explicit blockers are active."}(u,m,i.description),M=Ib.renderToStaticMarkup((0,Rb.jsx)(Ul,{machine:u,layout:g,runtime:m,downstreamSet:k,selectedSet:b,width:a,height:c,seed:A,reduced:!0,onSelectTask:()=>{}})),_=void 0===i.theme?{}:xe(d),$=Ib.renderToStaticMarkup((0,Rb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:c,role:"img","aria-labelledby":`${p} ${y}`,style:{..._,fontFamily:h.fontFamily},children:[(0,Rb.jsx)("title",{id:p,children:l}),(0,Rb.jsx)("desc",{id:y,children:S}),(0,Rb.jsx)("rect",{width:a,height:c,fill:h.background}),(0,Rb.jsx)("text",{x:a/2,y:22,textAnchor:"middle",fontSize:h.titleFontSize,fontFamily:h.titleFontFamily,fontWeight:h.titleFontWeight,fill:h.text,children:l}),(0,Rb.jsx)("g",{dangerouslySetInnerHTML:{__html:M}})]}));return e&&(e.evidence=cc({frameType:"physics",width:a,height:c,parts:[],additionalMarkCountByType:{task:u.nodes.length,dependency:u.edges.length},title:l,description:S,categories:u.lanes,nodeCount:u.nodes.length,edgeCount:u.edges.length})),$}},PhysicsCustomChart:lm},Db=Wh(require("react")),Nb=require("react/jsx-runtime"),zb=new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]),Eb=Wh(require("react-dom/server")),Bb=require("d3-scale"),Wb=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,o){if(e&&"function"==typeof t.pieceStyle){const i=t.pieceStyle(e,o);return i&&!i.fill&&o?{...i,fill:this.getColorFromScheme(t,o)}:i}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&o?{fill:Mt(t.barColors,o)??"#007bff"}:{fill:o?this.getColorFromScheme(t,o):"#007bff"}}resolveSummaryStyle(t,e,o){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,o):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const o=this.colorSchemeMap.get(e);if(o)return o;const i=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||ap,n=i[this.colorSchemeIndex%i.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,n),n}},Yb=require("d3-array"),qb=require("d3-scale"),Xb={bar:function(t,e){const{scales:o,columns:i,config:n,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=o,u=[],d="vertical"===l,h="horizontal"===l,f=n.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(i))for(const o of e.pieceData){const e=s(o);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(i)){const e=new Map;for(const o of t.pieceData){const t=s?s(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t);i.total+=r(o),i.pieces.push(o)}let o=0;if(f)for(const t of e.values())o+=Math.abs(t.total);let i=0,n=0;for(const r of p){const l=e.get(r);if(!l)continue;let p=l.total;f&&o>0&&(p/=o);const y=a(l.pieces[0],s?r:t.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name};if(d){const e=c(0>p?n:i+p),o=0>p?c(n+p)-c(n):c(i)-c(i+p);u.push(ra(t.x,e,t.width,Math.abs(o),y,g,r)),0>p?n+=p:i+=p}else if(h){const e=c(0>p?n+p:i),o=0>p?c(n)-c(n+p):c(i+p)-c(i);u.push(ra(e,t.x,Math.abs(o),t.width,y,g,r)),0>p?n+=p:i+=p}}}const y="vertical"===l;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(void 0!==n.roundedTop){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const o=e.datum?.category||"";t.has(o)||t.set(o,[]),t.get(o).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),o=e.filter(t=>0>(t.datum?.__aggregateValue??0));if(t.length>0){const e=t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e),o=fu(n.roundedTop,e,y);o>0&&(e.roundedTop=o)}if(o.length>0){const t=o.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e),e=fu(n.roundedTop,t,y);e>0&&(t.roundedTop=e)}}}return u},clusterbar:function(t,e){const{scales:o,columns:i,config:n,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=o,u=[],d="vertical"===l,h=[],f=new Set;for(const t of Object.values(i))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const p=h.length||1;for(const t of Object.values(i)){const e=t.width/p,o=.2*e,i=e-o,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;h.length>s;s++){const l=n.get(h[s])||[];for(const n of l){const l=r(n),f=a(n,h[s]);if(d){const r=t.x+s*e+o/2,a=c(0),d=c(l);u.push(ra(r,Math.min(a,d),i,Math.abs(a-d),f,n,h[s]))}else{const r=t.x+s*e+o/2,a=c(0),d=c(l);u.push(ra(Math.min(a,d),r,Math.abs(d-a),i,f,n,h[s]))}}}}for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum),o=fu(n.roundedTop,t,d);o>0&&(t.roundedTop=o),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}return u},point:function(t,e){const{scales:o,columns:i,getR:n,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:c}=o,l=[],u="vertical"===c,d="radial"===c,h=r.length>0,f=pu(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(i))for(const e of t.pieceData){const o=e.__rIndex??0,i=e.__rValue??n(e),c=h&&r[o]||a,g=s(e,t.name),m=g.r||5;let x,b;if(d){const e=y+(t.pctStart+t.pct/2)*p,o=c(i);x=Math.cos(e)*o,b=Math.sin(e)*o}else u?(x=t.middle,b=c(i)):(x=c(i),b=t.middle);yu(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:o,columns:i,getR:n,resolvePieceStyle:r}=t,{r:s,projection:a}=o,c=[],l="vertical"===a,u=pu(t);for(const t of Object.values(i)){const e=t.width/2;for(let o=0;t.pieceData.length>o;o++){const i=t.pieceData[o],a=n(i),d=r(i,t.name),h=d.r||4,f=(7919*o%100/100-.5)*e*.8;yu(c,u,i,l?t.middle+f:s(a),l?s(a):t.middle+f,h,d)}}return c},pie:gu,donut:gu,boxplot:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=o,l=[],u="vertical"===c,d=!1!==n.showOutliers;for(const e of Object.values(i)){const o=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===o.length)continue;const i=xu(o),{min:n,max:c,q1:h,median:f,q3:p}=i,y=p-h,g=h-1.5*y,m=p+1.5*y,x=o.find(t=>t>=g)??n;let b=c;for(let t=o.length-1;t>=0;t--)if(m>=o[t]){b=o[t];break}i.min=x,i.max=b;const v=s(mu(e.pieceData,e.name,i),e.name),w=[];if(d)for(const t of e.pieceData){const o=r(t);if(g>o||o>m){const i=u?e.middle:a(o),n=u?a(o):e.middle;w.push({px:i,py:n,value:o,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(x),q1Pos:a(h),medianPos:a(f),q3Pos:a(p),maxPos:a(b),stats:i,style:v,datum:e.pieceData,category:e.name,outliers:w}),d)for(const e of w)l.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:v.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:e.datum})}return l},violin:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=o,l=[],u="vertical"===c,d=n.bins||20,h=!1!==n.showIQR;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],n=(i-o)/d||1,c=bu(e,o,i,n,d),f=ee(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(o)}`;for(let e=0;d>e;e++){const i=a(o+(e+.5)*n);y+=` L ${t.middle+c[e]/f*p} ${i}`}y+=` L ${t.middle} ${a(i)}`;for(let e=d-1;e>=0;e--){const i=a(o+(e+.5)*n);y+=` L ${t.middle-c[e]/f*p} ${i}`}y+=" Z"}else{y=`M ${a(o)} ${t.middle}`;for(let e=0;d>e;e++)y+=` L ${a(o+(e+.5)*n)} ${t.middle-c[e]/f*p}`;y+=` L ${a(i)} ${t.middle}`;for(let e=d-1;e>=0;e--)y+=` L ${a(o+(e+.5)*n)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=xu(e),m=s(mu(t.pieceData,t.name,g),t.name);let x;h&&e.length>=4&&(x={q1Pos:a(g.q1),medianPos:a(g.median),q3Pos:a(g.q3),centerPos:t.middle,isVertical:u});const b=u?{x:t.x,y:Math.min(a(i),a(o)),width:t.width,height:Math.abs(a(i)-a(o))}:{x:Math.min(a(o),a(i)),y:t.x,width:Math.abs(a(i)-a(o)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:b,iqrLine:x,stats:g,style:m,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a}=o,c=[],l=n.bins||25,u=n.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[o,i]=te(e),n=null!=h&&isFinite(h)?h:o,d=null!=f&&isFinite(f)?f:i,p=(d-n)/l||1,y=bu(e,n,d,p,l),g=e.length,m=ee(y,1);for(let e=0;l>e;e++){if(0===y[e])continue;const o=(u?y[e]/g:y[e]/m)*t.width*.9,i=a(n+e*p),r=a(n+(e+1)*p),l=Math.min(i,r),d=Math.abs(r-i),h=t.x+t.width-o,f={...t.pieceData[0],bin:e,count:y[e],range:[n+e*p,n+(e+1)*p],category:t.name,data:t.pieceData},x=s(f,t.name);c.push(ra(l,h,d,o,x,f,t.name))}}return c},ridgeline:function(t,e){const{scales:o,columns:i,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=o,l=[],u=n.bins||20,d="horizontal"===c,h=n.amplitude||1.5;for(const t of Object.values(i)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],n=(i-o)/u||1,c=bu(e,o,i,n,u),f=ee(c,1),p=xu(e),y=s(mu(t.pieceData,t.name,p),t.name),g=t.width*h;let m;if(d){const e=t.x+t.width;m=`M ${a(o)} ${e}`;for(let t=0;u>t;t++)m+=` L ${a(o+(t+.5)*n)} ${e-c[t]/f*g}`;m+=` L ${a(i)} ${e} Z`}else{const e=t.x;m=`M ${e} ${a(o)}`;for(let t=0;u>t;t++){const i=a(o+(t+.5)*n);m+=` L ${e+c[t]/f*g} ${i}`}m+=` L ${e} ${a(i)} Z`}const x=d?{x:Math.min(a(o),a(i)),y:t.x,width:Math.abs(a(i)-a(o)),height:t.width}:{x:t.x,y:Math.min(a(i),a(o)),width:t.width,height:Math.abs(a(i)-a(o))};l.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:p,style:{...y,fillOpacity:y.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:o,columns:i,getRawRange:n,resolvePieceStyle:r}=t,{r:s,projection:a}=o,c=[],l="horizontal"===a;for(const t of Object.values(i))for(const e of t.pieceData){const o=n(e);if(!o)continue;const[i,a]=o,u=r(e,t.name);if(l){const o=s(Math.min(i,a)),n=s(Math.max(i,a));c.push(ra(o,t.x,n-o,t.width,u,e,t.name))}else{const o=s(Math.max(i,a)),n=s(Math.min(i,a));c.push(ra(t.x,o,t.width,n-o,u,e,t.name))}}return c},funnel:function(t,e){const{columns:o,getR:i,getStack:n,resolvePieceStyle:r}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>o[t]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const t of l)for(const e of t.pieceData){const t=n?n(e):"_default";d.has(t)||(d.add(t),u.push(t))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let o=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=i(r);s.total+=a,s.pieces.push(r),o+=a}f.push({col:t,groups:e,stepTotal:o}),h||o>p&&(p=o)}if(h)for(const t of f){let e=0,o=0;for(let i=0;u.length>i;i++){const n=t.groups.get(u[i]);n&&(i%2==0?e+=n.total:o+=n.total)}const i=Math.max(e,o);i>p&&(p=i)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*e.width,x=(0,qb.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 o=f[e],i=o.col,n=0===e,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(h){let t=0;for(const e of u){const i=o.groups.get(e);i&&(t+=x(i.total))}let e=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=o.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?e:l-b;v?e+=b:l-=b;const k=r(g.pieces[0],f),A=y.get(f)??g.total,S={...g.pieces[0],__funnelValue:g.total,__funnelPercent:A>0?g.total/A*100:0,__funnelStep:i.name,__funnelIsFirstStep:n,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(S.__funnelStepLabel=i.name,S.__funnelStepLabelX=a,S.__funnelStepLabelY=p,S.__funnelRowWidth=t),S.__funnelValueLabelX=w+b/2,S.__funnelValueLabelY=p,S.__funnelBarW=b),s.push(ra(w,p,b,d,k,S,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const t=o.stepTotal,e=x(t),l=a-e/2,h=u[0],f="_default"!==h,y=o.groups.get(h)?.pieces[0]??i.pieceData[0],b=f?h:i.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:i.name,__funnelIsFirstStep:n,category:f?h:i.name};c&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(ra(l,p,e,d,v,k,b)),m.set(h,{x:l,y:p,w:e,h:d})}if(e>0&&v.size>0){const e=h?u:[u[0]];for(const n of e){const e=v.get(n),a=m.get(n);if(!e||!a)continue;const c=(()=>{const t=o.groups.get(n);return r(t?t.pieces[0]:i.pieceData[0],"_default"===n?i.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,cursor:c.cursor},datum:o.groups.get(n)?.pieces[0]??i.pieceData[0],category:"_default"===n?i.name:n};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:o,getR:i,getStack:n,resolvePieceStyle:r,scales:s}=t,a=[],c=s.o.domain().map(t=>o[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 d=l.length>1&&"_default"!==l[0],h=[];for(const t of c){const e=new Map;let o=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=i(r);s.total+=a,s.pieces.push(r),o+=a}h.push({col:t,groups:e,stepTotal:o})}const f=new Map;for(const t of l){const e=h[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let t=0;h.length>t;t++){const e=h[t],o=e.col,i=0===t,n=t>0?h[t-1]:null,s=o.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const h=l[t],y=e.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=n?.groups.get(h),v=i?0:Math.max(0,(b?.total??g)-g),w=o.x+t*s+c/2,k=p(g),A=p(0)-k,S=r(y.pieces[0],d?h:o.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:o.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(ra(w,k,u,A,S,M,d?h:o.name)),v>0){const t=p(g+v),e=k-t,i={...S},n={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:o.name};a.push(ra(w,t,u,e,i,n,d?h:o.name))}}}return a},swimlane:function(t,e){const{scales:o,columns:i,getR:n,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:c}=o,l=[],u="horizontal"===c,d=t.config.gradientFill,h=u?"left":"bottom",f=new Map,p=e=>{const o=f.get(e);if(void 0!==o)return o;const i="function"==typeof t.config.roundedTop?t.config.roundedTop(e.width):t.config.roundedTop,n="number"==typeof i&&Number.isFinite(i)?Math.max(0,i):0;return f.set(e,n),n},y=t.config.trackFill;if(y){const t="string"==typeof y?y:y.color,e="string"==typeof y?1:y.opacity??1,[o,n]=a.range(),r=Math.min(o,n),s=Math.abs(n-o);for(const o of Object.values(i)){const i={fill:t,opacity:e},n=u?ra(r,o.x,s,o.width,i,null,"__track__"):ra(o.x,r,o.width,s,i,null,"__track__"),a=p(o);a>0&&(n.cornerRadii={tl:a,tr:a,br:a,bl:a}),l.push(n)}}for(const t of Object.values(i)){let e=0;const o=l.length,i=p(t);for(const o of t.pieceData){const i=Math.abs(n(o));if(0===i)continue;const c=r?r(o):t.name,f=s(o,c);let p;if(u){const n=a(e),r=a(e+i);p=ra(n,t.x,r-n,t.width,f,o,c)}else{const n=a(e+i),r=a(e);p=ra(t.x,n,t.width,r-n,f,o,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),e+=i}if(i>0&&l.length>o){const t=l.slice(o),e=t[0],n=t[t.length-1];1===t.length?e.cornerRadii={tl:i,tr:i,br:i,bl:i}:u?(e.cornerRadii={tl:i,bl:i},n.cornerRadii={tr:i,br:i}):(e.cornerRadii={bl:i,br:i},n.cornerRadii={tl:i,tr:i})}}return l}},Gb=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vb=["scene-style","data-paint","accessibility","evidence"],Hb=(t,e)=>({retainedData:t,invalidations:e}),Ub=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Kb=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Zb=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qb=["scene-geometry","data-paint","accessibility","evidence"],Jb=["scene-style","data-paint","accessibility","evidence"],tv=[],ev={chartType:Hb("rebuild",Ub),runtimeMode:Hb("rebuild",Ub),categoryAccessor:Hb("rebuild",Ub),valueAccessor:Hb("rebuild",Ub),oAccessor:Hb("rebuild",Ub),rAccessor:Hb("rebuild",Ub),stackBy:Hb("rebuild",Ub),groupBy:Hb("rebuild",Ub),timeAccessor:Hb("rebuild",Ub),accessorRevision:Hb("rebuild",Ub),colorAccessor:Hb("rebuild",Jb),symbolAccessor:Hb("rebuild",Qb),connectorAccessor:Hb("rebuild",Qb),dataIdAccessor:Hb("rebuild",Qb),projection:Hb("preserve",Kb),extentPadding:Hb("preserve",Kb),axisExtent:Hb("preserve",Kb),rExtent:Hb("preserve",Kb),oExtent:Hb("preserve",Kb),multiAxis:Hb("preserve",Kb),normalize:Hb("preserve",Kb),bins:Hb("preserve",Kb),oSort:Hb("preserve",Zb),barPadding:Hb("preserve",Zb),roundedTop:Hb("preserve",Zb),baselinePadding:Hb("preserve",Zb),innerRadius:Hb("preserve",Zb),cornerRadius:Hb("preserve",Zb),startAngle:Hb("preserve",Zb),sweepAngle:Hb("preserve",Zb),trackFill:Hb("preserve",Zb),showOutliers:Hb("preserve",Zb),showIQR:Hb("preserve",Zb),amplitude:Hb("preserve",Zb),connectorOpacity:Hb("preserve",Zb),showLabels:Hb("preserve",Zb),dynamicColumnWidth:Hb("rebuild",Zb),customLayout:Hb("preserve",Zb),layoutConfig:Hb("preserve",Zb),layoutMargin:Hb("preserve",Zb),symbolMap:Hb("preserve",Qb),pieceStyle:Hb("preserve",Jb),summaryStyle:Hb("preserve",Jb),connectorStyle:Hb("preserve",Jb),gradientFill:Hb("preserve",Jb),colorScheme:Hb("preserve",Jb),themeCategorical:Hb("preserve",Jb),themeSemantic:Hb("preserve",Jb),themeSequential:Hb("preserve",Jb),themeDiverging:Hb("preserve",Jb),barColors:Hb("preserve",Jb),decay:Hb("preserve",Jb),pulse:Hb("preserve",Jb),staleness:Hb("preserve",Jb),layoutSelection:Hb("preserve",Jb),windowSize:Hb("preserve",tv),windowMode:Hb("preserve",tv),clock:Hb("preserve",tv),transition:Hb("preserve",tv),introAnimation:Hb("preserve",tv),onLayoutError:Hb("preserve",tv)},ov=Hb("preserve",Zb),iv=class{constructor(){this.tracker=new hg}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}},Gb)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Vb):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const o=new Set;for(const i of t){const t=ev[i]??ov;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},nv=require("d3-quadtree"),rv=class{constructor(t){this.rExtent=new pm,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new iv,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new Wb,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 fm(t.windowSize),this.getO=Ps(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>_s(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new pm)):(this.getR=_s(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Ps(t.stackBy),this.getGroup=Ps(t.groupBy),this.getColor=Ps(t.colorAccessor),this.getSymbol=Ps(t.symbolAccessor),this.getConnector=Ps(t.connectorAccessor),this.getDataId=Ps(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new fm(t.windowSize))}syncPulseTimestampBuffer(){var t,e,o,i;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,o=this.timestampBuffer,i=this.currentTime(),t?null!=o&&o.capacity===e.capacity&&o.size===e.size?o:da(e,i):null)}currentTime(){return this.config.clock?.()??Ds()}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(),ua(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const o of t.inserts)ha(this.buffer,o,this.timestampBuffer,e),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of t.inserts){const t=ha(this.buffer,o,this.timestampBuffer,e);this.categories.add(this.getO(o)),this.pushValueExtent(o),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 o="function"==typeof e?e(t):t[e];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(t){const{config:e,buffer:o}=this,i=this.scales,n=this.multiScales,r=this.columns;if(0===o.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(o,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(d){f=(0,Bb.scaleBand)().domain(c).range([0,1]).padding(0);const o=Math.min(t.width,t.height)/2,i=e.innerRadius||0;p=(0,Bb.scaleLinear)().domain(l).range([i,o])}else u?(f=(0,Bb.scaleBand)().domain(c).range([0,t.height]).padding(h),p=(0,Bb.scaleLinear)().domain(l).range([0,t.width])):(f=(0,Bb.scaleBand)().domain(c).range([0,t.width]).padding(h),p=(0,Bb.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((i,n)=>{const r=this.rExtents[n];r.dirty&&r.recalculate(o,i);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(e.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Bb.scaleLinear)().domain([s,a]).range([0,t.width]):(0,Bb.scaleLinear)().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,o)=>({...t,__rIndex:o,__rValue:e(t),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(y,c,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=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,o=Array.isArray(e)?e[t]:e;return"string"==typeof o?o:"value"+t}resolveCategories(t){const e=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===e?void 0:e;let n=null;if(o){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(o&&void 0===i){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===i)return r;if("function"==typeof i)return r.sort(i);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===i?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:o,projection:i,normalize:n,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=t,f=s;if("radial"===i&&("pie"===o||"donut"===o))return[0,1];let p=0,y=0;if("bar"===o&&d&&n)p=0,y=1;else if("bar"===o&&d){const t=new Map,o=new Map;for(const i of e){const e=l(i),n=u(i);0>n?o.set(e,(o.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 o.values())p>t&&(p=t)}else if("bar"===o){const t=new Map;for(const o of e){const e=l(o),i=u(o);t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===o){const t=new Map;for(const o of e){const e=l(o),i=Math.abs(u(o));t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===o||"bar-funnel"===o)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=h[0],e=h[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(y=r[1]));const g="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==o&&"exact"!==c){const t=y-p,e=t>0?t*f:1,i=g&&!a&&0===p,n=g&&!a&&0===y||"swimlane"===o;null!=r?.[0]||i||(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,o,i,n){return function(t){const{data:e,oExtent:o,oScale:i,projection:n,layout:r,dynamicColumnWidth:s,getO:a,getR:c}=t,l=Object.create(null),u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let d=0;if("radial"===n)for(const t of e)d+=Math.abs(c(t));let h=null;if(s&&"radial"!==n){h=new Map;let t=0;for(const e of o){const o=u.get(e)||[];let i;i="string"==typeof s?o.reduce((t,e)=>t+(Number(e[s])||0),0):s(o),h.set(e,i),t+=i}const e=("horizontal"===n?r.height:r.width)-i.padding()*i.step()*o.length;if(t>0)for(const[o,i]of h)h.set(o,i/t*e)}let f=0,p=0;for(const t of o){const e=u.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(c(e)),0),n=d>0?o/d:0;let r,s;h?(r=p,s=h.get(t)||i.bandwidth(),p+=s+i.padding()*i.step()):(r=i(t)??0,s=i.bandwidth()),l[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:i.padding()*i.step(),pieceData:e,pct:n,pctStart:f},f+=n}return l}({data:t,oExtent:e,oScale:o,projection:i,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 o=this.buildLayoutContext(t,e),i=Us({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(o)});if("failure"===i.kind)return this.lastCustomLayoutFailure=i.diagnostic,this._customLayoutFailedThisBuild=!0,i.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);const n=i.result;this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null;const r=n.nodes??[];if(this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of r)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return Gs({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 o=this.getSceneContext(),i=Xb[this.config.chartType];let n=i?i(o,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:o,config:i,getConnector:n,getO:r}=t;if(!n||!o)return[];const s=[],{projection:a}=o,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const o=n(e);if(!o)continue;let i,s;"point"===t.type?(i=t.x,s=t.y):(i=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:s,datum:e,category:r(e)})}const l=new Map(o.o.domain().map((t,e)=>[t,e])),u=i.connectorStyle,d={stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},h=(t,e,o)=>{var i;s.push({type:"connector",x1:t.x,y1:t.y,x2:e.x,y2:e.y,style:(i=t.datum,"function"==typeof u?u(i):u||d),datum:t.datum,group:o})};for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>(l.get(t.category)??-1)-(l.get(e.category)??-1));for(let o=0;e.length-1>o;o++)h(e[o],e[o+1],t);"radial"!==a||3>e.length||h(e[e.length-1],e[0],t)}return s}(o,n);n=[...t,...n]}return n}buildLayoutContext(t,e){const o=this.config,i=o.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Gn(o.colorScheme,o.themeCategorical,ap),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:i,plot:"radial"===r.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:o.themeSemantic??{},categorical:[...n]},resolveColor:Vn(n,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}computeDecayOpacity(t,e){const o=this.config.decay;return o&&e>1?Ns(o,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=zs(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 o="function"==typeof e,i=o?null:e||"category",n=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=o?e(s):s[i],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,o=0;for(const i of t)"point"===i.type&&!1!==i.interactive&&(e++,i.r>o&&(o=i.r));if(500>=e)return{quadtree:null,maxRadius:o};const i=Array(e);let n=0;for(const e of t)"point"===e.type&&!1!==e.interactive&&(i[n++]=e);return{maxRadius:o,quadtree:(0,nv.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const o=e.length;if(1>=o)return;const i=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=i.get(e.datum);if(null==t)continue;const n=this.computeDecayOpacity(t,o);e.style={...e.style,opacity:(e.style?.opacity??1)*n}}}applyPulse(t,e,o=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,o,i,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 i=0;for(const s of n(e)??[]){const e=o.get(s);null!=e&&(i=Math.max(i,Es(t,e,r)))}c=Bs(l,i,s)||c;continue}if(null==l.datum)continue;const e=i.get(l.datum);if(null==e)continue;const u=o.get(e);c=Bs(l,null==u?0:Es(t,u,r),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),o)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Ws(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,o="horizontal"!==this.scales?.projection;let i;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,o?{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}:{x:e,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===i&&(i=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:i,endAngle:i,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const o=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,i=e.get(o)||0;return e.set(o,i+1),`${o}:${i}`}if("rect"===t.type){const o=t.datum?null!=t.datum.category&&""!==t.datum.category?t.datum.category+"":(this.getO(t.datum)??"")+"":"",i=`r:${t.group||""}:${o}`,n=e.get(i)||0;return e.set(i,n+1),0===n?i:`${i}:${n}`}return"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 o=this.scene[e],i=this.getNodeKey(o,t);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity??o.style.fillOpacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity??o.style.fillOpacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.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 o=new Set,i=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=this.getNodeKey(n,i);if(!r)continue;n._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===n.type)s?(o.add(r),n._targetOpacity=n.style.opacity??n.style.fillOpacity??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??n.style.fillOpacity??1,n._targetR=n.r,n.r=0,n.style={...n.style,opacity:0},e=!0);else if("rect"===n.type)s?(o.add(r),n._targetOpacity=n.style.opacity??n.style.fillOpacity??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??n.style.fillOpacity??1,n.style={...n.style,opacity:0},e=!0);else if("wedge"===n.type)if(s)o.add(r),n._targetOpacity=n.style.opacity??n.style.fillOpacity??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??n.style.fillOpacity??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,i]of this.prevPositionMap)if(!o.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((i.startAngle??0)+(i.endAngle??0))/2,o={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}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=Os(t,this.activeTransition),o=Cs(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style.opacity=Fs(i?i.opacity??1:0,t._targetOpacity,o)}const i=this.prevPositionMap.get(e);void 0!==t._targetX&&i&&(t.x=Fs(i.x,t._targetX,o),t.y=Fs(i.y,t._targetY,o)),void 0!==t._targetR&&void 0!==i?.r&&(t.r=Fs(i.r,t._targetR,o))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style.opacity=Fs(i?i.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=Fs(i.x,t._targetX,o),t.y=Fs(i.y,t._targetY,o),void 0!==i.w&&(t.w=Fs(i.w,t._targetW,o),t.h=Fs(i.h,t._targetH,o))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e);t.style={...t.style,opacity:Fs(i?i.opacity??1:0,t._targetOpacity,o)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=Fs(i.startAngle,t._targetStartAngle,o),t.endAngle=Fs(i.endAngle,t._targetEndAngle,o))}}}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,function(t){for(const e of t){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}"point"===e.type?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):void 0!==e._targetR&&(e.r=e._targetR,e._targetR=void 0):"rect"===e.type?void 0!==e._targetX&&(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):"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0)}}(this.scene),this.exitNodes=[]}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=Ts(t),o=this.getDataId,i=t=>e.has(o(t));fa(this.buffer,this.timestampBuffer,i);const n=this.buffer.remove(i);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 o=Ts(t),i=this.getDataId,n=new Set;this.buffer.forEach((t,e)=>{o.has(i(t))&&n.add(e)});const r=this.buffer.update(t=>o.has(i(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),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 o=this._customRestyle;if(o)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},n=o(i,e);i.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),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},o=Object.keys(t).filter(o=>t[o]!==e[o]);"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&&!Ms(t.colorAccessor,e.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in t&&!Ms(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!Ms(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in t||"oAccessor"in t)&&(Ms(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=Ps(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let n=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,o=e.valueAccessor||e.rAccessor,i=Array.isArray(t)?t:[t],r=Array.isArray(o)?o:[o];if(n=i.length!==r.length||i.some((t,e)=>!Ms(t,r[e])),n){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>_s(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new pm)):(this.getR=_s(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!Ms(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?Ps(this.config.stackBy):void 0),"groupBy"in t&&!Ms(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?Ps(this.config.groupBy):void 0),"colorAccessor"in t&&!Ms(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Ps(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!Ms(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Ps(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!Ms(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Ps(this.config.connectorAccessor):void 0),(i||n||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};va(rv);var sv=Wh(require("react")),av=Wh(require("react")),cv=require("d3-shape"),lv=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)}),uv=require("react/jsx-runtime"),dv=require("react/jsx-runtime"),hv=require("react/jsx-runtime"),fv=require("react/jsx-runtime"),pv=Wh(require("react-dom/server")),yv=Object.create(null),gv=require("d3-array"),mv=require("d3-array"),xv=require("d3-interpolate"),bv=(require("d3-shape"),.5),vv=t=>{let e,o,i,n,r,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,o=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=(0,xv.interpolateNumber)(r,s),c=a(bv),l=a(.5),`M${e},${r}C${e},${c} ${o},${l} ${o},${s}L${i},${s}C${i},${l} ${n},${c} ${n},${r}Z`;const u=t.sankeyWidth/2,d=(0,xv.interpolateNumber)(t.source.x1,t.target.x0),{pathD:h}=Uo({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:d(bv),cp2X:d(.5)});return h},wv=new Set,kv=new WeakMap,Av={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(qu))-1:0},justify:Xu},Sv={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,o,i){if(0===t.length)return;const n="vertical"===o.orientation?"down":"right",r=o.nodeAlign||"justify",s=o.nodeWidth??15,a=o.nodePaddingRatio??.05,c=o.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:Is(t.source),target:Is(t.target),value:Math.sqrt(Math.max(1,t.value||1))}));let d;d="down"===n?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const h=fd().extent(d).links(u).nodes(l).nodeAlign(Av[r]||Xu).nodeId(t=>t.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let t=1/0,e=-1/0,o=1/0,n=-1/0;for(const i of l)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),o>i.y0&&(o=i.y0),i.y1>n&&(n=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(i._circularWidth??i.width??0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),o>r.verticalFullExtent-s&&(o=r.verticalFullExtent-s),r.verticalFullExtent+s>n&&(n=r.verticalFullExtent+s)}const r=e-t,s=n-o,a=i[0],c=i[1];if(r>0&&s>0&&(0>t||0>o||e>a||n>c)){const e=Math.min(a/r,c/s),i=-t*e+(a-r*e)/2,n=-o*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+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 o=t.circularPathData;o.sourceX=o.sourceX*e+i,o.targetX=o.targetX*e+i,o.sourceY=o.sourceY*e+n,o.targetY=o.targetY*e+n,o.rightFullExtent=o.rightFullExtent*e+i,o.leftFullExtent=o.leftFullExtent*e+i,o.verticalFullExtent=o.verticalFullExtent*e+n,o.rightInnerExtent=o.rightInnerExtent*e+i,o.leftInnerExtent=o.leftInnerExtent*e+i,o.verticalRightInnerExtent=o.verticalRightInnerExtent*e+n,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*e+n,o.rightSmallArcRadius*=e,o.rightLargeArcRadius*=e,o.leftSmallArcRadius*=e,o.leftLargeArcRadius*=e,o.sourceWidth*=e,o.rightNodeBuffer*=e,o.leftNodeBuffer*=e,o.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)if(t._edgeKey)p.set(t._edgeKey,t);else{const e=Is(t.source),o=Is(t.target);p.set(`${e}\0${o}`,t)}for(const t of u){const e=Is(t.source),o=Is(t.target),i=p.get(t._edgeKey?t._edgeKey:`${e}\0${o}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=t.width??0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=n;const r=f.get(e),s=f.get(o);r&&(i.source=r),s&&(i.target=s)}}},buildScene(t,e,o,i){const n="vertical"===o.orientation?"down":"right",r=o.nodeStyle,s=o.edgeStyle,a=o.edgeOpacity??.5,c=o.edgeColorBy||"source",l=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:Df,u=new Map;t.forEach((t,e)=>{u.set(t.id,l[e%l.length])});const d=[],h=[],f=[],p=new Map;for(const e of t){const t=e.x1-e.x0,o=e.y1-e.y0;if(0>=t||0>=o)continue;const i=r?r(yd(e,"nodeStyle")):{},s={fill:i.fill||u.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity,cursor:i.cursor};p.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),d.push("down"===n?{type:"rect",x:e.y0,y:e.x0,w:o,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:o,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n=o.themeSemantic?.border||o.themeSemantic?.secondary||"#999";n="function"==typeof c?c(t)||n:"target"===c?p.get(i.id)||u.get(i.id)||n:p.get(e.id)||u.get(e.id)||n;const r=s?s(yd(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,o=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=r.fill||n;h.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-o}L${e.sourceX+i},${e.sourceY-o}L${e.sourceX+i},${e.sourceY+o}L${e.sourceX},${e.sourceY+o}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),h.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-o}L${e.targetX-s},${e.targetY-o}L${e.targetX-s},${e.targetY+o}L${e.targetX},${e.targetY+o}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;(l=t.circular&&t.circularPathData?pd(t):vv(t),l)&&h.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,cursor:r.cursor},datum:t})}if(!1!==o.showLabels){const e=js(o.nodeLabel);for(const o of t){const t=o.x1-o.x0,r=o.y1-o.y0;if(0>=t||0>=r)continue;const s=e?e(o):o.id;if(!s)continue;let a,c,l;"down"===n?(a=o.y0+(o.y1-o.y0)/2,c=o.x1+14,l="start"):(i[0]/2>o.x0+t/2?(a=o.x0-6,l="end"):(a=o.x1+6,l="start"),c=o.y0+r/2),f.push({x:a,y:c,text:s+"",anchor:"down"===n?"middle":l,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}};Pu("sankey",Sv);var Mv=require("d3-force"),_v=require("d3-scale"),$v={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,o,i){if(0===t.length)return;const n=o.forceStrength??.1,r=i[0]/2,s=i[1]/2,a=Math.max(.1,Math.min(1,Math.min(i[0],i[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=o.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),o=l?.get(e.id);t?u++:o?(e.x=o.x,e.y=o.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const o=new Map;for(const e of t)o.set(e.id,e);for(const t of d){const i=md(t.id,e,o);if(i.length>0){let e=0,o=0;for(const t of i)e+=t.x,o+=t.y;const n=xd(t.id),r=n%360*(Math.PI/180),s=(10+n%20)*a;t.x=e/i.length+s*Math.cos(r),t.y=o/i.length+s*Math.sin(r)}else{const e=xd(t.id),o=e%360*(Math.PI/180),i=(15+e%30)*a;t.x=r+i*Math.cos(o),t.y=s+i*Math.sin(o)}}}else{const e=2.399963229728653;for(let o=0;t.length>o;o++){const i=t[o];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(o+.5)*a,n=o*e;i.x=r+t*Math.cos(n),i.y=s+t*Math.sin(n)}}}const f=o.__skipForceSimulation||0===o.iterations?0:h?40:o.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),p=gd(o.nodeSize,o.nodeSizeRange,t),y=t=>p(t);if(f>0){const l=new Map,u=new Map;for(const e of t)l.set(e.id,0),u.set(e.id,e);for(const t of e){const e=Is(t.source),o=Is(t.target);l.set(e,(l.get(e)??0)+1),l.set(o,(l.get(o)??0)+1)}const d=(0,Mv.forceLink)().strength(t=>{const e=t.weight,o=Is(t.source),i=Is(t.target),r=Math.max(1,Math.min(l.get(o)??1,l.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?u.get(t.source):t.source,o="string"==typeof t.target?u.get(t.target):t.target,i=(e?y(e):0)+(o?y(o):0)+Math.max(6,12*a);return Math.max(16,40*a,i)}).id(t=>t.id),p=(0,Mv.forceSimulation)();if(void 0===o.random&&void 0===o.seed||p.randomSource(o.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}}(o.seed)),p.force("charge",(0,Mv.forceManyBody)().strength(t=>{const e=l.get(t.id)??0;return-15*a*y(t)*Math.sqrt(e+1)})).force("collide",(0,Mv.forceCollide)(t=>y(t)+3*a).strength(.9).iterations(2)).force("center",(0,Mv.forceCenter)(r,s).strength(.8)).force("x",(0,Mv.forceX)(r).strength(c)).force("y",(0,Mv.forceY)(s).strength(c)).force("bounds",function(t,e,o=2,i=.6){let n=[];const r=r=>{const s=i*Math.max(r,.2);for(const i of n){const n=i.x??t[0]/2,r=i.y??t[1]/2,a=i.vx??0,c=i.vy??0,l=e(i)+o,u=Math.min(t[0]/2,l),d=Math.max(t[0]/2,t[0]-l),h=Math.min(t[1]/2,l),f=Math.max(t[1]/2,t[1]-l),p=n+a,y=r+c;u>p?i.vx=a+(u-p)*s:p>d&&(i.vx=a+(d-p)*s),h>y?i.vy=c+(h-y)*s:y>f&&(i.vy=c+(f-y)*s)}};return r.initialize=t=>{n=t},r}(i,y)),p.nodes(t),e.length>0){const t=e.map(t=>({...t,source:Is(t.source),target:Is(t.target)}));d.links(t),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let t=0;f>t;++t)p.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=y(e),o=f>0?2:0,n=Math.min(i[0]/2,t+o),r=Math.min(i[1]/2,t+o);e.x=Math.max(n,Math.min(i[0]-n,e.x)),e.y=Math.max(r,Math.min(i[1]-r,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,o,i){const n=o.nodeStyle,r=o.edgeStyle,s=gd(o.nodeSize,o.nodeSizeRange,t),a=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:Df,c=new Map;t.forEach((t,e)=>{c.set(t.id,a[e%a.length])});const l=[],u=[],d=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(yd(e,"nodeSize")),i=n?n(yd(e,"nodeStyle")):{},r={fill:i.fill||c.get(e.id)||o.themeSemantic?.primary||"#007bff",stroke:i.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity,cursor:i.cursor};l.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const h=new Map;for(const e of t)h.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:h.get(t.source),i="object"==typeof t.target?t.target:h.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const n=r?r(yd(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:n.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6,cursor:n.cursor},datum:t})}if(!1!==o.showLabels){const e=js(o.nodeLabel);for(const o of t){if(null==o.x||null==o.y)continue;const t=e?e(o):o.id;if(!t)continue;const i=s(yd(o,"nodeSize"));d.push({x:o.x,y:o.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:l,sceneEdges:u,labels:d}}};Pu("force",$v);var Pv=require("d3-chord"),jv=require("d3-shape"),Iv=Df,Lv={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,o,i){if(0===t.length)return;const{padAngle:n=.01,groupWidth:r=20,sortGroups:s}=o,a=Math.min(i[0],i[1])/2,c=a-r,l=i[0]/2,u=i[1]/2,d=(h=o.valueAccessor)?"function"==typeof h?h:t=>t[h]??1:t=>t.value??1;var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array(p).fill(0));for(const t of e){const e=Is(t.source),o=Is(t.target),i=f.get(e),n=f.get(o);if(void 0===i||void 0===n)continue;const r=d(t);y[i][n]=r}const g=(0,Pv.chord)().padAngle(n);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,jv.arc)().innerRadius(c).outerRadius(a);for(const e of x){const o=t[e.index],i=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});o.x=i[0]+l,o.y=i[1]+u,o.__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=Is(t.source),o=Is(t.target),i=v.get(e),n=v.get(o);i&&(t.source=i),n&&(t.target=n)}const w=new Map;for(const t of e){const e=Is(t.source),o=Is(t.target);w.set(`${e}\0${o}`,t)}for(const e of m){const o=t[e.source.index].id,i=t[e.target.index].id,n=w.get(`${o}\0${i}`)||w.get(`${i}\0${o}`);n&&(n.__chordData=e)}},buildScene(t,e,o,i){const{groupWidth:n=20,edgeOpacity:r=.5}=o,s=Math.min(i[0],i[1])/2,a=s-n,c=i[0]/2,l=i[1]/2,u=o.nodeStyle,d=o.edgeStyle,h=o.edgeColorBy||"source",f=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:Iv,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=(0,Pv.ribbon)().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const o=t[e],i=o.__arcData;if(!i)continue;const n=u?u(yd(o,"nodeStyle")):{},r=("string"==typeof n.fill?n.fill:void 0)||p.get(o.id)||f[e%f.length];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:n.stroke||"black",strokeWidth:n.strokeWidth??1,opacity:n.opacity,cursor:n.cursor},datum:o,id:o.id,label:o.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=y(e);if(!i)continue;const n=bd(i,c,l);let s=o.themeSemantic?.border||o.themeSemantic?.secondary||"#999";const a=d?d(yd(t,"edgeStyle")):{};if(d)s=("string"==typeof a.fill?a.fill:void 0)||s;else{const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;"target"===h&&o?s=p.get(o.id)||s:e&&(s=p.get(e.id)||s)}m.push({type:"ribbon",pathD:n,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity,cursor:a.cursor},datum:t})}if(!1!==o.showLabels){const e=js(o.nodeLabel),i=s+12;for(const o of t){const t=o.__arcData;if(!t)continue;const n=e?e(o):o.id;if(!n)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*i,y:l+Math.sin(s)*i,text:n+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:x}}};Pu("chord",Lv);var Rv=require("d3-hierarchy"),Tv=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],Cv={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,o,i){const n=o.__hierarchyRoot;if(!n)return;const r=o.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(o.childrenAccessor),a=o.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=(0,Rv.hierarchy)(n,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,d]=i;switch(r){case"tree":!function(t,e,o,i){const n=e.treeOrientation||"vertical",r=(0,Rv.tree)();r.size("horizontal"===n?[i,o]:"radial"===n?[2*Math.PI,Math.min(o,i)/2*.8]:[o,i]),r(t)}(l,o,u,d);break;case"cluster":!function(t,e,o,i){const n=e.treeOrientation||"vertical",r=(0,Rv.cluster)();r.size("horizontal"===n?[i,o]:"radial"===n?[2*Math.PI,Math.min(o,i)/2*.8]:[o,i]),r(t)}(l,o,u,d);break;case"treemap":!function(t,e,o,i){const n=e.padding??4,r=e.paddingTop??0,s=(0,Rv.treemap)().size([o,i]).tile(Rv.treemapBinary).padding(n);r>0&&s.paddingTop(r),s(t)}(l,o,u,d);break;case"circlepack":!function(t,e,o,i){const n=e.padding??4;(0,Rv.pack)().size([o,i]).padding(n)(t)}(l,o,u,d);break;case"partition":!function(t,e,o,i){(0,Rv.partition)().size([o,i]).padding(e.padding??1)(t)}(l,o,u,d)}const h=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;h.length>e;e++){const i=h[e],n={id:wd(i,o,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===r||"cluster"===r?_d(n,i,o):"treemap"===r||"partition"===r?$d(n,i):"circlepack"===r&&Pd(n,i),n.__hierarchyNode=i,t.push(n),f.set(i,n)}if("tree"===r||"cluster"===r)for(const t of h)if(t.parent){const o=f.get(t.parent),i=f.get(t);o&&i&&e.push({source:o,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,o,i){const n=o.nodeStyle||(()=>({})),r=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(t,e,o,i,n,r){const s=[],a=[],c=[],l=o.treeOrientation||"vertical",u="radial"===l,d=i[0]/2,h=i[1]/2,f="number"==typeof(p=o.nodeSize)?p:5;var p;for(const e of t){let t=e.x,i=e.y;u&&(t+=d,i+=h);const r=n(yd(e,"nodeStyle"));let a=r.fill||Sd(o);if(o.colorByDepth&&void 0!==e.depth){const t=Ad(o);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:i,r:f,style:{fill:a,stroke:r.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity,cursor:r.cursor},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=o.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n=e.x,s=e.y,c=i.x,f=i.y;u&&(n+=d,s+=h,c+=d,f+=h);const p=Md(n,s,c,f,l),g=r(yd(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y,cursor:g.cursor},datum:t})}if(!1!==o.showLabels){const e=kd(o.nodeLabel);for(const o of t){const t=e?e(o):o.id;if(!t)continue;let i,n,r,s=o.x,a=o.y;if(u&&(s+=d,a+=h),u){const t=s-d,e=a-h,o=Math.sqrt(t*t+e*e);o>0?(i=s+t/o*10,n=a+e/o*10,r=0>t?"end":"start"):(i=s,n=a-12,r="middle")}else"horizontal"===l?(o.data?.children&&0!==o.data.children.length?(i=s-f-6,r="end"):(i=s+f+6,r="start"),n=a):(i=s,n=a+f+14,r="middle");c.push({x:i,y:n,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,o,i,n,r);case"treemap":case"partition":return function(t,e,o,i){const n=[],r=[];for(const o of t){const t=o.x1-o.x0,r=o.y1-o.y0;if(0>=t||0>=r)continue;const s=i(yd(o,"nodeStyle"));let a=s.fill||Sd(e);if(e.colorByDepth&&void 0!==o.depth){const t=Ad(e);a=t[o.depth%t.length]}n.push({type:"rect",x:o.x0,y:o.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity,fillOpacity:s.fillOpacity,strokeOpacity:s.strokeOpacity,cursor:s.cursor},datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==e.showLabels){const o=kd(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=o?o(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let d=i(yd(a,"nodeStyle")).fill||Sd(e);if(e.colorByDepth&&void 0!==a.depth){const t=Ad(e);d=t[a.depth%t.length]}const h="string"==typeof d?vd(d):e.themeSemantic?.text??"#000";r.push(l?{x:a.x0+t/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,o,0,n);case"circlepack":return function(t,e,o,i){const n=[],r=[];for(const o of t){const t=o.__radius??5;if(0>=t)continue;const r=i(yd(o,"nodeStyle"));let s=r.fill||Sd(e);if(e.colorByDepth&&void 0!==o.depth){const t=Ad(e);s=t[o.depth%t.length]}n.push({type:"circle",cx:o.x,cy:o.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7,cursor:r.cursor},datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==e.showLabels){const o=kd(e.nodeLabel);for(const n of t){const t=n.__radius??5,s=o?o(n):n.id;if(!s)continue;if(15>t)continue;const a=!(n.data?.children&&n.data.children.length>0);let c=i(yd(n,"nodeStyle")).fill||Sd(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ad(e);c=t[n.depth%t.length]}if(a){const o="string"==typeof c?vd(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:o})}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,o,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};Pu("tree",Cv),Pu("cluster",Cv),Pu("treemap",Cv),Pu("circlepack",Cv),Pu("partition",Cv);var Ov=require("d3-shape"),Fv={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,o,i){const n=o.__hierarchyRoot;n&&function(t,e,o,i,n){function r(t){const e=p.get(t)??0;return p.set(t,e+1),0===e?t:`${t}__${e}`}const s=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(o.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(o.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),l=o.orbitSize??2.95,u=o.orbitEccentricity??1,d="number"==typeof l?()=>l:l,h="number"==typeof u?()=>u:u,f=jd(o);f.metaMap.clear(),i.length=0,n.length=0;const p=new Map,y=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=r(a(t));i.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),f.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,o,l,u,p,y,g){const m=s(e);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=c[Math.min(w,c.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=c[Math.min(x,c.length-1)],w=m.slice(k,k+v);if(!w.length)break;const A=(x+1)/b,S={id:o,depth:y,data:e,parentId:o},M=g?p/d(S)*A:p*A,_=(0,Ov.pie)().value(t=>{const e=s(t)?.length;return e?4:1}).sort(null)(w),$=h(S);for(let e=0;w.length>e;e++){const s=(_[e].startAngle+_[e].endAngle)/2,c=w[e],d=r(a(c)),h=l+M*Math.sin(s),p=u+M*Math.cos(s)*$;i.push({id:d,x:h,y:p,x0:h,x1:h,y0:p,y1:p,width:0,height:0,value:0,depth:y,data:c}),f.metaMap.set(d,{ring:M,angle:s,depth:y,parentId:o,eccentricity:$}),n.push({source:o,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:d}}),t(c,d,h,p,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(n,i,o,t,e)},buildScene(t,e,o,i){const n=o.nodeStyle,r=o.edgeStyle,s=o.nodeSize,a="number"==typeof s?()=>s:"function"==typeof s?s:()=>6,c=[],l=[],u=[];if(!1!==o.orbitShowRings){const e=jd(o),i=new Map;for(const e of t)i.set(e.id,e);const n=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const o=`${t.parentId}:${t.ring}`;n.has(o)||n.set(o,{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:o,ecc:i}]of n)for(let n=0;r>n;n++){const a=n/r*Math.PI*2,c=(n+1)/r*Math.PI*2;l.push({type:"line",x1:t+o*Math.sin(a),y1:e+o*Math.cos(a)*i,x2:t+o*Math.sin(c),y2:e+o*Math.cos(c)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=a(yd(e,"nodeSize")),i=n?n(yd(e,"nodeStyle")):{};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:i.fill||o.themeSemantic?.primary||"#6366f1",stroke:i.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??(0===(e.depth??0)?1:.85),cursor:i.cursor},datum:e,id:e.id,label:e.id,depth:e.depth})}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==o.x)continue;const i=r?r(yd(t,"edgeStyle")):{};l.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:i.stroke||"rgba(128,128,128,0.35)",strokeWidth:i.strokeWidth??.5,opacity:i.opacity??1,cursor:i.cursor},datum:t})}if(o.showLabels){const e=o.nodeLabel;for(const o of t){const t=a(yd(o,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(o):e?o.data?.[e]??o.id:o.id;u.push({x:o.x,y:o.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(t,e,o,i,n)=>!1!==o.orbitAnimated&&(function(t,e){const o=jd(e),i=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())-o.startTime)/1e3,s=i*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=a.get(t.parentId);if(!i)continue;const c=t.angle+r*s*n({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(c),e.y=i.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,o),!0)};Pu("orbit",Fv);var Dv=Wh(require("react")),Nv=require("d3-shape"),zv=require("react/jsx-runtime"),Ev=require("react/jsx-runtime");Pu("sankey",Sv),Pu("force",$v),Pu("chord",Lv),Pu("tree",Cv),Pu("cluster",Cv),Pu("treemap",Cv),Pu("circlepack",Cv),Pu("partition",Cv),Pu("orbit",Fv);var Bv=new Set(["tree","cluster","treemap","circlepack","partition","orbit"]),Wv=Wh(require("react-dom/server")),Yv=require("d3-geo"),qv=require("d3-quadtree"),Xv=require("d3-geo"),Gv={mercator:Xv.geoMercator,equalEarth:Xv.geoEqualEarth,albersUsa:Xv.geoAlbersUsa,orthographic:Xv.geoOrthographic,naturalEarth:Xv.geoNaturalEarth1,equirectangular:Xv.geoEquirectangular},Vv=require("d3-scale"),Hv=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Uv=["scene-style","data-paint","accessibility","evidence"],Kv=(t,e)=>({retainedData:t,invalidations:e}),Zv=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qv=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Jv=["scene-geometry","data-paint","accessibility","evidence"],tw=["scene-style","data-paint","accessibility","evidence"],ew=["overlay","accessibility","evidence"],ow=[],iw={xAccessor:Kv("rebuild",Zv),yAccessor:Kv("rebuild",Zv),lineDataAccessor:Kv("rebuild",Zv),pointIdAccessor:Kv("rebuild",Jv),lineIdAccessor:Kv("rebuild",Jv),windowSize:Kv("rebuild",Zv),projection:Kv("preserve",Qv),projectionExtent:Kv("preserve",Qv),fitPadding:Kv("preserve",Qv),lineType:Kv("preserve",Qv),flowStyle:Kv("preserve",Qv),graticule:Kv("preserve",Qv),projectionTransform:Kv("preserve",Qv),customLayout:Kv("preserve",Qv),layoutConfig:Kv("preserve",Qv),layoutMargin:Kv("preserve",Qv),areaStyle:Kv("preserve",tw),pointStyle:Kv("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Kv("preserve",tw),colorScheme:Kv("preserve",tw),themeCategorical:Kv("preserve",tw),themeDiverging:Kv("preserve",tw),themeSemantic:Kv("preserve",tw),themeSequential:Kv("preserve",tw),decay:Kv("preserve",tw),pulse:Kv("preserve",tw),layoutSelection:Kv("preserve",tw),annotations:Kv("preserve",ew),autoPlaceAnnotations:Kv("preserve",ew),clock:Kv("preserve",ow),transition:Kv("preserve",ow),introAnimation:Kv("preserve",ow),onLayoutError:Kv("preserve",ow)},nw=Kv("preserve",Qv),rw=class{constructor(){this.tracker=new hg}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}},Hv)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Uv):this.recordNoop("restyle")}recordConfig(t,e={}){const o=function(t){let e="preserve";const o=new Set;for(const i of t){const t=iw[i]??nw;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)o.add(e)}return{retainedData:e,invalidations:o}}(t),i=new Set(o.invalidations);return e.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:t},i)}},sw=require("d3-geo"),aw=class t{constructor(t){this.updateResults=new rw,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:Yd(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??Ds()}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(),o=this.timestampBuffer?.toArray()??[],i=e.slice(-t),n=o.slice(-i.length),r=this.currentTime();this.pointBuffer=new fm(t),this.timestampBuffer=new fm(t),i.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:Yd(t.fitPadding)}:t}(t),o=this.config,i=this.getConfiguredWindowSize(),n=Object.keys(e).filter(t=>e[t]!==o[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==i;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(),o=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],n=o.slice(-e),r=i.slice(-n.length),s=this.currentTime();this.pointBuffer=new fm(e),this.timestampBuffer=new fm(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();ha(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 o of t)ha(this.pointBuffer,o,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 o="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]),n=[];return this.lineData=this.lineData.filter(t=>!i.has(o(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 o="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(o(t)+"");fa(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=>!i.has(o(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 o of this.scene){const i=this._baseStyles.get(o)??o.style,n=e(o,t);o.style=n?{...i,...n}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,o=this.projection,i=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,Xv.geoEqualEarth)();if("string"==typeof t){const e=Gv[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),(0,Xv.geoEqualEarth)())}if("object"==typeof t&&"type"in t){const e=Gv[t.type],o=e?e():(0,Xv.geoEqualEarth)();return t.rotate&&"rotate"in o&&o.rotate(t.rotate),t.center&&"center"in o&&o.center(t.center),o}return t}(e.projection),this.geoPath=(0,Yv.geoPath)(this.projection),this.fitProjection(t),this.geoPath=(0,Yv.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=o,this.geoPath=i,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,o=t.height/2,i=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:o}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,o=this.config,i=[...this.areas],n=Fd(o.xAccessor,"lon"),r=Fd(o.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[n(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=Dd(o.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)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==i.length){if(o.projectionExtent){const[[i,n],[r,s]]=o.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,n],[i,s],[r,s],[r,n],[i,n]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const i=o.fitPadding??0,n=Math.min(t.width,t.height);e.scale(n/2-n*i),e.translate([t.width/2,t.height/2])}else{const n=o.fitPadding??0,r=t.width*n,s=t.height*n;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:i})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const o=this.projection;if(!o)return;const i=this.geoPath,n=this.scales,r=o.scale(),s=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*t.k),o.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=(0,Yv.geoPath)(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(t,e)=>o([t,e]),invertedPoint:(t,e)=>o.invert?o.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(s),this.currentZoom=a,this.geoPath=i,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 o=this.projection;if(!o)return;const i=this.geoPath,n=this.scales,r=o.scale(),s=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*t),o.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=(0,Yv.geoPath)(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(t,e)=>o([t,e]),invertedPoint:(t,e)=>o.invert?o.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(s),this.currentZoom=a,this.geoPath=i,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 o=this.projection;if(!o||!o.rotate)return;const i=this.geoPath,n=this.scales,r=[...o.rotate()];o.rotate(t),this.geoPath=(0,Yv.geoPath)(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(t,e)=>o([t,e]),invertedPoint:(t,e)=>o.invert?o.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(r),this.geoPath=i,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)}hasProjection(){return null!=this.projection}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,o=0;for(const t of this.scene)"point"===t.type&&!1!==t.interactive&&(o++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const i=Array(o);let n=0;for(const t of this.scene)"point"===t.type&&!1!==t.interactive&&(i[n++]=t);this._quadtree=(0,qv.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,o=this.projection,i=this.geoPath;if(e.customLayout&&this.scales){const o=e.layoutMargin??{top:0,right:0,bottom:0,left:0},i=Gn(e.colorScheme,e.themeCategorical,ap),n={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:o,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...i]},resolveColor:Vn(i,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null},r=Us({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:e.onLayoutError,run:()=>e.customLayout(n)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);const s=r.result,a=s.nodes??[];if(this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null,this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of a)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return Gs({label:"geo customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}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:o,areas:i,points:n,lines:r,layout:s}){const a=Fd(t.xAccessor,"lon"),c=Fd(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),d=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),h=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,i=(0,sw.geoGraticule)();e.step&&i.step(e.step);const n=o(i())||"";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 i){const i=o(e);if(!i)continue;const n=o.centroid(e),r=o.bounds(e),s=o.area(e);l.push({type:"geoarea",pathData:i,centroid:n,bounds:r,screenArea:s,style:Nd(t.areaStyle,e,u),datum:e,interactive:!0})}const f=Dd(t.lineDataAccessor);for(const o of r){const i=f(o);if(!i||2>i.length)continue;let n=[];if("geo"===t.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[a(i[e]),c(i[e])];for(let o=0;t.length-1>o;o++){const i=t[o],r=t[o+1],s=(0,sw.geoDistance)(i,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,sw.geoInterpolate)(i,r);for(let t=0;a>=t;t++){if(o>0&&0===t)continue;const i=e(c(t/a));null!=i&&n.push(i)}}}else for(let t=0;i.length>t;t++){const o=i[t],r=e([a(o),c(o)]);null!=r&&n.push(r)}if(2>n.length)continue;const r=Nd(t.lineStyle,o,d),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>n.length||"arc"!==t.flowStyle?2!==i.length||2>n.length||"offset"!==t.flowStyle||(n="geo"===t.lineType?Bd(n,u):Wd(n[0],n[n.length-1],0,0,u)):n=Ed(n[0],n[n.length-1]);const h=zd(n,s.width);if(h.length>1)for(const t of h)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:o});else l.push({type:"line",path:2>n.length&&h[0]||n,style:r,datum:o})}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 o of n){const i=a(o),n=c(o);if(null!=g&&(0,sw.geoDistance)([i,n],b)>g)continue;const r=e([i,n]);if(!r)continue;const s=t.pointStyle?t.pointStyle(o):{...h},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:o,pointId:p?p(o)+"":void 0};l.push(u)}return l}({config:e,projection:o,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const o=function(t,e,o,i){const n=t.filter(t=>"point"===t.type);if(2>n.length)return null;const r=e.strength??1,s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,a="strip"===e.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,l="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],u=n.find(t=>t.datum&&c(t.datum)+""==e.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const d=ee(n.map(t=>t.datum?Number(l(t.datum)):NaN).filter(t=>isFinite(t)&&t>=0),1);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const o=t[e];"geoarea"===o.type&&o.interactive&&t.splice(e,1)}const h="strip"===a?function(t,e,o,i,n){const r=Math.max(3,Math.min(8,.35*n.height)),s=Math.max(1,n.width-2*r),a=n.height/2,c=(0,Vv.scaleLinear)().domain([0,i]).range([0,s]);e.x=r,e.y=a;const l=[];for(const n of t){if(n===e)continue;if(!n.datum){n.x=r,n.y=a;continue}const t=Number(o(n.datum)),s=r+(isFinite(t)&&t>=0&&i>0?c(t):0);n.x=s,n.y=a,l.push({node:n,x:s})}l.sort((t,e)=>t.x-e.x);const u=Math.max(0,Math.min(n.height/2-1,6));let d=0;for(;l.length>d;){let t=d+1;for(;l.length>t&&3>Math.abs(l[t].x-l[d].x);)t++;const e=t-d;if(e>1&&u>0)for(let t=0;e>t;t++)l[d+t].node.y=a+(t-(e-1)/2)*Math.min(2.5,2*u/Math.max(1,e-1));d=t}return{cx:r,cy:a,maxCost:i,availableRadius:s,layout:"strip"}}(n,u,l,d,o):function(t,e,o,i,n,r){const s=e.x,a=e.y,c=r.width/2,l=r.height/2,u=Math.min(r.width,r.height)/2,d=(0,Vv.scaleLinear)().domain([0,i]).range([0,u]);for(const r of t){if(r===e)continue;if(!r.datum)continue;const t=r.x,u=r.y,h=Math.atan2(u-a,t-s),f=Math.hypot(t-s,u-a),p=Number(o(r.datum)),y=isFinite(p)&&p>=0?i>0?d(p):0:f,g=c+Math.cos(h)*y,m=l+Math.sin(h)*y;r.x=t+(g-t)*n,r.y=u+(m-u)*n}return e.x=s+(c-s)*n,e.y=a+(l-a)*n,{cx:e.x,cy:e.y,maxCost:i,availableRadius:u,layout:"radial"}}(n,u,l,d,s,o),f=t.filter(t=>"line"===t.type);if(f.length>0){const t=new Map;for(const e of n)null!=e.pointId&&t.set(e.pointId+"",[e.x,e.y]);for(const o of f){const i=o.datum?.source,n=o.datum?.target;if(null!=i&&null!=n){const r=t.get(i+""),s=t.get(n+"");if(r&&s)if("fractional"===e.lineMode&&o.path.length>2){const t=o.path[0],e=o.path[o.path.length-1],i=[r[0]-t[0],r[1]-t[1]],n=[s[0]-e[0],s[1]-e[1]],a=[0];for(let t=1;o.path.length>t;t++)a.push(a[t-1]+Math.hypot(o.path[t][0]-o.path[t-1][0],o.path[t][1]-o.path[t-1][1]));const c=a[a.length-1];o.path=o.path.map((t,e)=>{const r=c>0?a[e]/c:e/(o.path.length-1);return[t[0]+i[0]*(1-r)+n[0]*r,t[1]+i[1]*(1-r)+n[1]*r]})}else o.path=[r,s]}}}return h}(this.scene,t,e,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const o=this.scene.filter(t=>"point"===t.type);for(let i=0;o.length>i;i++){const n=Ns(t,i,e);o[i]._decayOpacity=n,o[i].style={...o[i].style,opacity:n}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const o=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray(),n=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let s=!1;for(let a=0;o.length>a&&i.length>a;a++){const c=Es(e,i[a],t);s=Bs(o[a],c,n,r)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&Ws(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 o=new Map;for(const e of t)"point"===e.type&&e.pointId&&o.set(e.pointId,[e.x,e.y]);const i=this.scene.filter(t=>"point"===t.type);let n=!1;for(const t of i)if(t.pointId){const e=o.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 i)t.pointId&&!o.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??t.style?.fillOpacity??1,t.style={...t.style,opacity:0},n=!0);n&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null;for(const t of this.scene)"point"===t.type&&(null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0),null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0))}advanceTransition(t){if(!this.activeTransition)return!1;const e=Os(t,this.activeTransition),o=Cs(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Fs(t.x,t._targetX,o),t.y=Fs(e,t._targetY,o)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*o})}if(e>=1){for(const t of i)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};aw.QUADTREE_THRESHOLD=500;var cw=aw;va(cw);var lw=Wh(require("react")),uw=require("react/jsx-runtime"),dw=require("react/jsx-runtime"),hw=require("react/jsx-runtime"),fw=Wh(require("react-dom/server")),pw={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85},yw=require("react/jsx-runtime"),gw={top:0,right:0,bottom:0,left:0},mw=require("react/jsx-runtime"),xw=require("d3-scale"),bw=require("react/jsx-runtime"),vw={top:0,right:0,bottom:0,left:0},ww=Wh(require("react-dom/server")),kw=require("react/jsx-runtime"),Aw={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},Sw={BigNumber:function(t,e){const o="presentation"===t.mode||"inline"===t.mode||"thumbnail"===t.mode?t.mode:"tile",i=Aw[o],n=ah(t.width,i.width),r=ah(t.height,i.height),s="number"==typeof t.padding&&Number.isFinite(t.padding)?Math.max(0,t.padding):i.padding,a="center"===t.align||"end"===t.align||"start"===t.align?t.align:i.align,c="center"===a?"middle":"end"===a?"end":"start",l="center"===a?n/2:"end"===a?n-s:s,u=Zt(t.theme),d="number"==typeof t.value&&Number.isFinite(t.value)?t.value:void 0,h=function(t,e={}){if("function"==typeof t)return t;const o=e.locale??"en-US";if("currency"===t){const t=e.precision??2,i=new Intl.NumberFormat(o,{style:"currency",currency:e.currency??"USD",maximumFractionDigits:t,minimumFractionDigits:t});return t=>i.format(t)}if("percent"===t){const t=new Intl.NumberFormat(o,{style:"percent",maximumFractionDigits:e.precision??1,minimumFractionDigits:0});return e=>t.format(e)}if("compact"===t){const t=new Intl.NumberFormat(o,{notation:"compact",maximumFractionDigits:e.precision??1,minimumFractionDigits:0});return e=>t.format(e)}if("duration"===t)return t=>function(t){if(!Number.isFinite(t))return t+"";const e=0>t?"-":"",o=Math.abs(t);if(1e3>o)return`${e}${Math.round(o)}ms`;const i=o/1e3;if(60>i)return`${e}${n=i,Math.round(100*n)/100+""}s`;var n;const r=i/60;if(60>r){const t=Math.floor(r),o=Math.round(i-60*t);return 0===o?`${e}${t}m`:`${e}${t}m ${o}s`}const s=r/60;if(24>s){const t=Math.floor(s),o=Math.round(r-60*t);return 0===o?`${e}${t}h`:`${e}${t}h ${o}m`}const a=Math.floor(s/24),c=Math.round(s-24*a);return 0===c?`${e}${a}d`:`${e}${a}d ${c}h`}(t);const i=new Intl.NumberFormat(o,{notation:e.notation??"standard",maximumFractionDigits:e.precision??0,minimumFractionDigits:0});return t=>i.format(t)}("string"==typeof t.format||"function"==typeof t.format?t.format:"number",{locale:"string"==typeof t.locale?t.locale:void 0,currency:"string"==typeof t.currency?t.currency:void 0,precision:"number"==typeof t.precision?t.precision:void 0}),f=void 0===d?"No value":(p=h(d),`${("string"==typeof t.prefix?t.prefix:void 0)??""}${p}${("string"==typeof t.suffix?t.suffix:void 0)??""}`);var p;const y=void 0===d?void 0:function(t,e){if(!e||0===e.length)return null;if(!Number.isFinite(t))return null;const o=e.filter(t=>Number.isFinite(t.at)||t.at===-1/0).slice().sort((t,e)=>t.at-e.at);let i=null;for(const e of o){if(e.at>t)break;i=e}return i}(d,t.thresholds),g="string"==typeof t.color?t.color:function(t,e,o){return e||("success"===t?o.colors.success??"#2ca02c":"warning"===t?o.colors.warning??"#b26a00":"danger"===t?o.colors.danger??"#d62728":"info"===t?o.colors.info??o.colors.primary:o.colors.text)}(y?.level??"neutral",y?.color,u),m="string"==typeof t.label?t.label:void 0,x="string"==typeof t.caption?t.caption:void 0,b="string"==typeof t.unit?t.unit:void 0,v=void 0===d?void 0:function(t,e,o){const i=t.comparison&&"object"==typeof t.comparison?t.comparison:void 0,n=i&&"number"==typeof i.value&&Number.isFinite(i.value)?i.value:void 0,r=("number"==typeof t.delta&&Number.isFinite(t.delta)?t.delta:void 0)??(void 0===n?void 0:e-n);if(void 0===r)return;const s=function(t,e){return Number.isFinite(t)?0===t?e(0):`${t>0?"+":"−"}${e(Math.abs(t))}`:""}(r,o);return`${s}${i&&"string"==typeof i.label?" "+i.label:""}`}(t,d,h),w=void 0===d?void 0:function(t,e,o){const i=t.target&&"object"==typeof t.target?t.target:void 0;if(!i||"number"!=typeof i.value||!Number.isFinite(i.value))return;const n="string"==typeof i.label?" "+i.label:"";return 0===i.value?`target ${o(i.value)}${n}`:`${new Intl.NumberFormat("string"==typeof t.locale?t.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(e/i.value)} of ${o(i.value)}${n}`}(t,d,h),k=[v,w,y?.label].filter(Boolean).join(" · "),A="string"==typeof t.description&&t.description||[m,f,b,k].filter(Boolean).join(", "),S="string"==typeof t.background?t.background:u.colors.surface??u.colors.background,M="string"==typeof t.borderColor?t.borderColor:u.colors.border,_=s+i.labelSize,$=_+i.captionSize+4,P="presentation"===o?r/2+.32*i.valueSize:"thumbnail"===o?r/2+.34*i.valueSize:Math.min(r-s-(k?26:4),(i.showHeader&&(m||x)?x?$+10:_+14:s)+i.valueSize),j=l+("start"===c?Math.max(i.valueSize,f.length*i.valueSize*.55):0),I=ww.renderToStaticMarkup((0,kw.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:r,viewBox:`0 0 ${n} ${r}`,role:"img","aria-label":A,"data-semiotic-component":"BigNumber",children:[(0,kw.jsx)("title",{children:m??f}),"string"==typeof t.description&&(0,kw.jsx)("desc",{children:t.description}),(0,kw.jsx)("rect",{x:i.border?.5:0,y:i.border?.5:0,width:i.border?n-1:n,height:i.border?r-1:r,rx:i.border?8:0,fill:S,stroke:i.border?M:"none"}),i.showHeader&&m&&(0,kw.jsx)("text",{x:l,y:_,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.labelSize,fontWeight:600,fill:u.colors.text,children:m}),i.showHeader&&x&&(0,kw.jsx)("text",{x:l,y:$,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.captionSize,fill:u.colors.textSecondary,children:x}),(0,kw.jsx)("text",{x:l,y:P,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:g,"data-mark-type":"value",children:f}),b&&void 0!==d&&"start"===c&&(0,kw.jsx)("text",{x:j+6,y:P,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*i.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:b}),i.showDetail&&k&&(0,kw.jsx)("text",{x:l,y:Math.min(r-s,P+i.detailSize+10),textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:i.detailSize,fill:u.colors.textSecondary,children:k})]}));return e&&(e.evidence=dc({frameType:"value",width:n,height:r,marks:void 0===d?[]:[{type:"value"}],title:m,description:A})),I}},Mw=Wh(require("react-dom/server")),_w=require("react/jsx-runtime"),$w=require("react/jsx-runtime"),Pw=new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),jw=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi,Iw=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],Lw=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"],Rw=Wh(require("react-dom/server")),Tw=require("react/jsx-runtime");ac();
|