semiotic 3.8.0 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +14 -9
- package/README.md +56 -55
- package/ai/behaviorContracts.cjs +9 -0
- package/ai/dist/mcp-server.js +240 -30
- package/ai/schema.json +616 -42
- package/ai/surface-manifest.json +3 -2
- package/ai/system-prompt.md +7 -3
- package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
- package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
- package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
- package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
- package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
- package/dist/chunk-chunk-27HVVXS6.module.min.js +1 -0
- package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
- package/dist/chunk-chunk-2UN3ANRN.module.min.js +2 -0
- package/dist/chunk-chunk-2VUEY5TH.module.min.js +1 -0
- package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
- package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
- package/dist/chunk-chunk-5WEFWNUW.module.min.js +2 -0
- package/dist/chunk-chunk-6F6GEAQU.module.min.js +1 -0
- package/dist/chunk-chunk-7LHMKRKE.module.min.js +2 -0
- package/dist/chunk-chunk-BHYTYMY2.module.min.js +2 -0
- package/dist/chunk-chunk-C6EJ4IOD.module.min.js +2 -0
- package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
- package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
- package/dist/chunk-chunk-CYIML3AV.module.min.js +2 -0
- package/dist/chunk-chunk-DNY43POY.module.min.js +1 -0
- package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
- package/dist/chunk-chunk-E7MIQX7D.module.min.js +2 -0
- package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
- package/dist/chunk-chunk-ES4DCG3L.module.min.js +1 -0
- package/dist/chunk-chunk-FAKO3RGQ.module.min.js +2 -0
- package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
- package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
- package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
- package/dist/chunk-chunk-H4PPRW6N.module.min.js +1 -0
- package/dist/chunk-chunk-IFYPMWKY.module.min.js +1 -0
- package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
- package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
- package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
- package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
- package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
- package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
- package/dist/chunk-chunk-L6D3I3V7.module.min.js +2 -0
- package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
- package/dist/chunk-chunk-NO4MCQVD.module.min.js +1 -0
- package/dist/chunk-chunk-ODUZEEBH.module.min.js +2 -0
- package/dist/chunk-chunk-P6UBCMSQ.module.min.js +2 -0
- package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
- package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
- package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
- package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
- package/dist/chunk-chunk-RH5TSQPH.module.min.js +1 -0
- package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
- package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
- package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
- package/dist/chunk-chunk-STZFFTAN.module.min.js +2 -0
- package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
- package/dist/chunk-chunk-T27ZEV6A.module.min.js +1 -0
- package/dist/chunk-chunk-U3AGQ5EF.module.min.js +2 -0
- package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
- package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
- package/dist/chunk-chunk-W3DB2MN4.module.min.js +2 -0
- package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
- package/dist/chunk-chunk-WDIN4LRC.module.min.js +1 -0
- package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
- package/dist/chunk-chunk-XOYX77KF.module.min.js +2 -0
- package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
- package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
- package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
- package/dist/chunk-chunk-Z5KXAVQD.module.min.js +2 -0
- package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
- package/dist/chunk-chunk-ZLKRTF5N.module.min.js +2 -0
- package/dist/chunk-chunk-ZTNVDWAK.module.min.js +2 -0
- package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
- package/dist/components/AccessibleNavTree.d.ts +7 -1
- package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
- package/dist/components/ai/useNavigationSync.d.ts +17 -2
- package/dist/components/chartContainerMobile.d.ts +9 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
- package/dist/components/charts/geo/DistanceCartogram.d.ts +14 -2
- package/dist/components/charts/geo/FlowMap.d.ts +10 -6
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +14 -2
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +9 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +11 -0
- package/dist/components/charts/network/SankeyDiagram.d.ts +9 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +21 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +11 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +11 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +7 -0
- package/dist/components/charts/physics/EventDropChart.d.ts +7 -0
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +8 -0
- package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +4 -25
- package/dist/components/charts/physics/PhysicsPileChart.d.ts +7 -0
- package/dist/components/charts/physics/physicsChartShared.d.ts +17 -1
- package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
- package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
- package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
- package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
- package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +3 -3
- package/dist/components/charts/shared/datumTypes.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +2 -0
- package/dist/components/charts/shared/formatUtils.d.ts +3 -3
- package/dist/components/charts/shared/hatchFill.d.ts +87 -0
- package/dist/components/charts/shared/hooks.d.ts +7 -6
- package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
- package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
- package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
- package/dist/components/charts/shared/sparseArray.d.ts +1 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +6 -4
- package/dist/components/charts/shared/styleRules.d.ts +205 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
- package/dist/components/charts/shared/types.d.ts +9 -6
- package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
- package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
- package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +24 -1
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
- package/dist/components/charts/shared/validateChartData.d.ts +7 -5
- package/dist/components/charts/shared/validationMap.d.ts +11 -2
- package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
- package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
- package/dist/components/charts/value/targetPresentation.d.ts +22 -0
- package/dist/components/charts/value/types.d.ts +5 -6
- package/dist/components/charts/xy/AreaChart.d.ts +8 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
- package/dist/components/charts/xy/Heatmap.d.ts +2 -2
- package/dist/components/charts/xy/LineChart.d.ts +11 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +7 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +10 -0
- package/dist/components/charts/xy/StackedAreaChart.d.ts +7 -0
- package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
- package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
- package/dist/components/controls/SentenceFilter.d.ts +97 -0
- package/dist/components/data/fromVegaLite.d.ts +19 -9
- package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
- package/dist/components/semiotic-ai.d.ts +3 -1
- package/dist/components/semiotic-controls.d.ts +2 -0
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +4 -0
- package/dist/components/semiotic-ordinal.d.ts +6 -0
- package/dist/components/semiotic-physics.d.ts +4 -0
- package/dist/components/semiotic-rough.d.ts +4 -0
- package/dist/components/semiotic-utils-core.d.ts +4 -0
- package/dist/components/semiotic-xy.d.ts +4 -0
- package/dist/components/semiotic.d.ts +9 -1
- package/dist/components/server/optionalImageTypes.d.ts +37 -0
- package/dist/components/server/serverChartConfigShared.d.ts +9 -5
- package/dist/components/server/serverChartConfigs.d.ts +4 -4
- package/dist/components/server/staticAnnotations.d.ts +6 -3
- package/dist/components/server/staticLegend.d.ts +1 -1
- package/dist/components/server/staticNetwork.d.ts +4 -4
- package/dist/components/server/staticSVGChrome.d.ts +5 -4
- package/dist/components/store/ObservationStore.d.ts +21 -1
- package/dist/components/stream/AccessibleDataTable.d.ts +4 -10
- package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
- package/dist/components/stream/CanvasHitTester.d.ts +4 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
- package/dist/components/stream/FrameRuntime.d.ts +57 -0
- package/dist/components/stream/GeoParticlePool.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +43 -12
- package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
- package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
- package/dist/components/stream/NetworkPipelineStore.d.ts +24 -21
- package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +6 -0
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
- package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
- package/dist/components/stream/OrdinalPipelineStore.d.ts +13 -13
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
- package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
- package/dist/components/stream/ParticlePool.d.ts +1 -1
- package/dist/components/stream/PipelineStore.d.ts +12 -16
- package/dist/components/stream/SVGOverlay.d.ts +6 -0
- package/dist/components/stream/SceneGraph.d.ts +3 -3
- package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
- package/dist/components/stream/accessorUtils.d.ts +2 -2
- package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
- package/dist/components/stream/frameGraphics.d.ts +4 -0
- package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
- package/dist/components/stream/geoPipelineHelpers.d.ts +3 -3
- package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
- package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
- package/dist/components/stream/geoTypes.d.ts +48 -15
- package/dist/components/stream/hitTestUtils.d.ts +2 -2
- package/dist/components/stream/hoverUtils.d.ts +4 -2
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +1 -0
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
- package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
- package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
- package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
- package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
- package/dist/components/stream/networkFrameObservations.d.ts +15 -0
- package/dist/components/stream/networkFramePaint.d.ts +11 -2
- package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +2 -2
- package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
- package/dist/components/stream/networkTypes.d.ts +37 -56
- package/dist/components/stream/ordinalCanvasRenderers.d.ts +2 -2
- package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +20 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
- package/dist/components/stream/ordinalTypes.d.ts +30 -3
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +2 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +6 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +21 -6
- package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
- package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
- package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +19 -1
- package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +3 -1
- package/dist/components/stream/pipelineConfig.d.ts +4 -2
- package/dist/components/stream/pipelineDecay.d.ts +2 -2
- package/dist/components/stream/pipelinePulse.d.ts +2 -2
- package/dist/components/stream/pipelineStoreUpdateResults.d.ts +23 -2
- package/dist/components/stream/pipelineTransitions.d.ts +1 -1
- package/dist/components/stream/pipelineUpdateContract.d.ts +7 -0
- package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
- package/dist/components/stream/renderBackend.d.ts +27 -0
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
- package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
- package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
- package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
- package/dist/components/stream/sceneRevisionDiagnostics.d.ts +31 -4
- package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
- package/dist/components/stream/streamThemeTypes.d.ts +14 -0
- package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
- package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
- package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
- package/dist/components/stream/titleLayout.d.ts +31 -0
- package/dist/components/stream/types.d.ts +30 -65
- package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
- package/dist/components/stream/useFrame.d.ts +23 -0
- package/dist/components/stream/useLegendCategoryEmission.d.ts +3 -3
- package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
- package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
- package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +6 -5
- package/dist/controls.min.js +1 -1
- package/dist/controls.module.min.js +1 -1
- package/dist/forceLayoutWorker.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics-matter.min.js +1 -1
- package/dist/physics-matter.module.min.js +1 -1
- package/dist/physics-rapier.min.js +1 -1
- package/dist/physics-rapier.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -0
- package/dist/rough.module.min.js +1 -0
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +3 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-controls.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +4 -0
- package/dist/semiotic-ordinal.d.ts +6 -0
- package/dist/semiotic-physics.d.ts +4 -0
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-realtime-react.min.js +1 -1
- package/dist/semiotic-realtime-react.module.min.js +1 -1
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes-react.min.js +1 -1
- package/dist/semiotic-recipes-react.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-rough.d.ts +4 -0
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-themes-core.min.js +1 -1
- package/dist/semiotic-themes-core.module.min.js +1 -1
- package/dist/semiotic-themes-react.min.js +1 -1
- package/dist/semiotic-themes-react.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils-core.d.ts +4 -0
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils-react.min.js +1 -1
- package/dist/semiotic-utils-react.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +4 -0
- package/dist/semiotic.d.ts +9 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/capturedFrameProps.d.ts +67 -0
- package/dist/test-utils/frameMock.d.ts +12 -9
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +29 -10
- package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
- package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
- package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
- package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
- package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{useRef as t}from"react";var r=["value","threshold","partition-boundary","time-window","range-boundary"];function n({controlType:e,controlId:t,chartId:r,chartType:n="VisualizationControl",onObservation:a}){return(o,i,l)=>{a?.({type:o,controlType:e,value:i,chartType:n,timestamp:Date.now(),...t?{controlId:t}:{},...r?{chartId:r}:{},...l?{source:l}:{}})}}import{jsx as a,jsxs as o}from"react/jsx-runtime";function i(e,t,r,n){return Math.min(r,Math.max(t,Number((t+Math.round((Math.min(r,Math.max(t,e))-t)/n)*n).toFixed(12))))}function l({value:r,onChange:l,pointerToValue:s,min:c,max:u,step:d=1,largeStep:p=5*d,x:m,y:h,controlType:g="value",controlId:b,label:f,valueText:y,radius:v=12,fill:x="var(--semiotic-bg, #ffffff)",stroke:$="var(--semiotic-primary, #4e79a7)",strokeWidth:C=4,labelText:k,labelDx:w=16,labelDy:M=-16,labelClassName:T,className:z,disabled:S=!1,onChangeStart:I,onChangeEnd:A,onObservation:P,chartId:D,chartType:N}){const R=t(null),V=t(r);V.current=r;const Z=e.useMemo(()=>n({controlType:g,controlId:b,chartId:D,chartType:N,onObservation:P}),[D,N,b,g,P]),W=e=>{if(S)return;const t=s(e);if(null==t||!Number.isFinite(t))return;const r=i(t,c,u,d);V.current=r,l(r),Z("control-change",r,"pointer")},L=e=>{e.stopPropagation(),R.current===e.pointerId&&(e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture?.(e.pointerId),R.current=null,A?.(V.current),Z("control-end",V.current,"pointer"))},O=["semiotic-direct-manipulation-control",z].filter(Boolean).join(" ");return o("g",{className:O,role:"slider",tabIndex:S?-1:0,"aria-disabled":S||void 0,"aria-label":f,"aria-valuemin":c,"aria-valuemax":u,"aria-valuenow":r,"aria-valuetext":y??`${f}: ${r}`,"aria-roledescription":"visualization control","data-viz-control":g,"data-viz-control-id":b,"data-viz-control-state":"controlled",pointerEvents:"all",onPointerDown:e=>{S||(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture?.(e.pointerId),R.current=e.pointerId,I?.(V.current),Z("control-start",V.current,"pointer"),W(e))},onPointerMove:e=>{e.stopPropagation(),R.current===e.pointerId&&W(e)},onPointerUp:L,onPointerCancel:L,onLostPointerCapture:L,onKeyDown:e=>{if(S)return;const t=e.shiftKey?p:d,r=V.current;let n=null;if("ArrowLeft"!==e.key&&"ArrowDown"!==e.key||(n=r-t),"ArrowRight"!==e.key&&"ArrowUp"!==e.key||(n=r+t),"Home"===e.key&&(n=c),"End"===e.key&&(n=u),null===n)return;e.preventDefault();const a=i(n,c,u,d);V.current=a,l(a),Z("control-change",a,"keyboard")},style:{cursor:S?"default":"grab",touchAction:"none"},children:[a("circle",{className:"semiotic-direct-manipulation-control__hit",cx:m,cy:h,r:v+10,fill:"transparent"}),a("circle",{className:"semiotic-direct-manipulation-control__handle",cx:m,cy:h,r:v,fill:x,stroke:$,strokeWidth:C}),k?a("text",{className:T,x:m+w,y:h+M,fill:$,children:k}):null]})}function s(e,t,r,n,a){return{id:e,...t?{controlId:t}:{},status:r,message:n,...a?{remediation:a}:{}}}function c({controls:e=[],minimumTargetSize:t=24}){const n=[],a=new Set;for(const o of e){const e=o?.id,i="controls."+(e||"unknown"),l=o?.domain,c=Array.isArray(l)&&2===l.length&&Number.isFinite(l[0])&&Number.isFinite(l[1])&&l[1]>l[0],u=r.includes(o?.type),d="string"==typeof o?.target&&o.target.trim().length>0,p=["slider","buttons","native-range"].includes(o?.keyboard??""),m=o?.minimumTargetSize;n.push(s(i+".semantic-type",e,u?"pass":"fail",u?`Control uses the semantic type "${o.type}".`:"Control has no recognized semantic type.","Use one of VISUALIZATION_CONTROL_TYPES.")),n.push(s(i+".state-binding",e,d?"pass":"fail",d?`Control is bound to "${o.target}".`:"Control has no declarative state binding.","Declare the controlled state key with target.")),n.push(s(i+".domain",e,c?"pass":"fail",c?"Control has a finite ordered value domain.":"Control has no finite ordered value domain.","Declare domain as [minimum, maximum].")),n.push(s(i+".keyboard",e,p?"pass":"fail",p?`Control declares a ${o.keyboard} keyboard path.`:"Control does not declare a keyboard path.","Declare slider, buttons, or native-range keyboard interaction.")),n.push(s(i+".value-text",e,"string"==typeof o?.valueText&&o.valueText.trim().length>0?"pass":"fail","string"==typeof o?.valueText&&o.valueText.trim().length>0?"Control declares human-readable value text.":"Control does not declare human-readable value text.","Provide valueText, typically with a {value} placeholder.")),n.push(s(i+".target-size",e,"number"!=typeof m||t>m?"fail":"pass","number"!=typeof m||t>m?`Control target is below the ${t}px minimum or undeclared.`:`Control declares a ${m}px target.`,`Declare minimumTargetSize of at least ${t}.`)),null!=o?.step&&n.push(s(i+".step",e,Number.isFinite(o.step)&&o.step>0?"pass":"fail",Number.isFinite(o.step)&&o.step>0?"Control has a positive quantization step.":"Control step must be a positive finite number.","Use a positive finite step.")),o?.observations?.length&&n.push(s(i+".observations",e,o.observations.includes("control-change")?"pass":"warn",o.observations.includes("control-change")?"Control declares control-change observation coverage.":"Control declares observations but omits control-change.","Include control-change so observable state changes are represented.")),e&&!a.has(e)||n.push(s(i+".identity",e,"fail",e?"Control id is duplicated.":"Control id is missing.","Use a unique stable control id.")),e&&a.add(e)}return{ok:n.every(e=>"fail"!==e.status),findings:n}}import{useRef as u}from"react";var d=2*Math.PI;function p(e,t,r){const n=r?.center?.x??0,a=r?.center?.y??0;return{x:n+Math.sin(e)*t,y:a-Math.cos(e)*t}}function m(e,t,r,n,a){const o=a?.center,i=(e,t)=>{const{x:r,y:n}=p(e,t,{center:o});return`${h(r)},${h(n)}`},l=Math.max(0,r),s=Math.max(l,n),c=Math.abs(t-e),u=e>t?0:1;if(c>=d-1e-6){const e=o?.x??0,t=o?.y??0,r=`${h(e)},${h(t-s)}`,n=`${h(e)},${h(t+s)}`;let a=`M${r} A${h(s)},${h(s)} 0 1 1 ${n} A${h(s)},${h(s)} 0 1 1 ${r} Z`;if(l>0){const r=`${h(e)},${h(t-l)}`,n=`${h(e)},${h(t+l)}`;a+=` M${r} A${h(l)},${h(l)} 0 1 0 ${n} A${h(l)},${h(l)} 0 1 0 ${r} Z`}return a}const m=c>Math.PI?1:0,g=i(e,s),b=i(t,s);if(0>=l){const e=o?.x??0,t=o?.y??0;return`M${h(e)},${h(t)} L${g} A${h(s)},${h(s)} 0 ${m} ${u} ${b} Z`}const f=i(t,l),y=i(e,l);return`M${g} A${h(s)},${h(s)} 0 ${m} ${u} ${b} L${f} A${h(l)},${h(l)} 0 ${m} ${1===u?0:1} ${y} Z`}function h(e){return Math.round(1e3*e)/1e3}function g(e,t,r=0){return t>0?((e-r)%t+t)%t+r:e}import{jsx as b,jsxs as f}from"react/jsx-runtime";function y({value:e,onChange:t,period:r=365,radius:n=180,innerRadius:a=14,width:o,height:i,step:l=1,largeStep:s=7,label:c="Range",formatValue:h,arcFill:y="var(--semiotic-primary, #4e79a7)",stroke:v="var(--semiotic-bg, #ffffff)",className:x,style:$}){const C=o??2*n+40,k=i??2*n+40,w=C/2,M=k/2,T=function(e){const[t,r]=e,n=r-t||1,a=d;return e=>0+(e-t)/n*(a-0)}([0,r]),z=u(null),S=e=>{const t=e.currentTarget.ownerSVGElement??e.currentTarget,n=t.getBoundingClientRect(),a=t.viewBox?.baseVal;return Math.round((Math.atan2((a?.width||C)/(n.width||1)*(e.clientX-n.left)-w-0,-((a?.height||k)/(n.height||1)*(e.clientY-n.top)-M-0))+d)%d/d*r)%r},I=(e,t)=>{e.preventDefault(),e.stopPropagation();const r=e.currentTarget.ownerSVGElement;r?.setPointerCapture?.(e.pointerId),z.current={mode:t,lastValue:S(e)}},A=e=>{const t=e.currentTarget.ownerSVGElement??e.currentTarget;t?.hasPointerCapture?.(e.pointerId)&&t.releasePointerCapture(e.pointerId),z.current=null},P=(e,n)=>{t("range"===e?e=>({start:g(e.start+n,r),end:g(e.end+n,r)}):t=>({...t,[e]:g(t[e]+n,r)}))},D=e=>t=>{const r=t.shiftKey?s:l;"ArrowRight"===t.key||"ArrowUp"===t.key?(t.preventDefault(),P(e,r)):"ArrowLeft"!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),P(e,-r))},N=e.start>e.end?[[e.start,r],[0,e.end]]:[[e.start,e.end]],R=e=>h?h(e):e+"";return b("svg",{viewBox:`0 0 ${C} ${k}`,width:C,height:k,className:x,onPointerMove:e=>{const n=z.current;if(!n)return;const a=S(e);if("range"===n.mode){const e=function(e,t,r){if(0>=r)return t-e;let n=(t-e)%r;return n>r/2?n-=r:-r/2>n&&(n+=r),n}(n.lastValue,a,r);if(0===e)return;return n.lastValue=a,void t(t=>({start:g(t.start+e,r),end:g(t.end+e,r)}))}t(e=>({...e,[n.mode]:a}))},onPointerUp:A,onPointerCancel:A,onLostPointerCapture:A,style:{touchAction:"none",...$},"aria-label":c+" brush",children:f("g",{transform:`translate(${w},${M})`,children:[b("g",{role:"slider",tabIndex:0,"aria-label":c+" (move both ends)","aria-valuemin":0,"aria-valuemax":r-1,"aria-valuenow":e.start,"aria-valuetext":`${R(e.start)} to ${R(e.end)}`,onPointerDown:e=>I(e,"range"),onKeyDown:D("range"),style:{cursor:"grab"},children:N.map(([e,t],r)=>b("path",{d:m(T(e),T(t),a,n),fill:y,fillOpacity:.35,stroke:v,strokeWidth:1},r))}),["start","end"].map(t=>{const o=e[t],i=(e=>p(T(e),a))(o),l=(e=>p(T(e),n+8))(o);return f("g",{role:"slider",tabIndex:0,"aria-label":`${c} ${t}`,"aria-valuemin":0,"aria-valuemax":r-1,"aria-valuenow":o,"aria-valuetext":R(o),onPointerDown:e=>I(e,t),onKeyDown:D(t),style:{cursor:"grab"},children:[b("line",{x1:i.x,y1:i.y,x2:l.x,y2:l.y,stroke:"transparent",strokeWidth:20}),b("line",{x1:i.x,y1:i.y,x2:l.x,y2:l.y,stroke:v,strokeWidth:1.5}),b("circle",{cx:l.x,cy:l.y,r:4.5,fill:v,stroke:y,strokeWidth:1})]},t)})]})})}import*as v from"react";import{jsx as x,jsxs as $}from"react/jsx-runtime";function C(e,t,r=0){const n=Math.min(t[0],t[1]),a=Math.max(t[0],t[1]),o=Math.max(n,Math.min(a,e[0])),i=Math.max(n,Math.min(a,e[1])),l=o>i?[i,o]:[o,i];if(l[1]-l[0]>=r)return l;const s=(l[0]+l[1])/2,c=r/2;return[Math.max(n,Math.min(a-r,s-c)),Math.min(a,Math.max(n+r,s+c))]}function k(e,t,r,n=1,a=n){const o="in"===r?n:-n;return C([e[0]+o,e[1]-o],t,a)}function w(e){const{domain:t,initialValue:r=t,step:n=1,minSpan:a=n,label:o,formatValue:i,onChange:l}=e,[s,c]=v.useState(()=>C(r,t,a)),u=C(s,t,a),d=v.useCallback(e=>{const r=C(e,t,a);c(r),l?.(r)},[t,a,l]),p=v.useMemo(()=>({label:o,domain:t,value:u,step:n,formatValue:i,onChange:d,onClear:()=>d(t)}),[t,i,o,d,n,u]),m=v.useMemo(()=>({onZoomIn:()=>d(k(u,t,"in",n,a)),onZoomOut:()=>d(k(u,t,"out",n,a)),onReset:()=>d(t)}),[t,a,d,n,u]);return{value:u,setValue:d,xExtent:u,brush:p,zoom:m}}var M={display:"grid",gap:8,padding:"10px 12px",border:"1px solid var(--semiotic-border, #d8dee4)",borderRadius:12,background:"var(--semiotic-surface, var(--semiotic-bg, rgba(255,255,255,0.92)))"},T={fontSize:11,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #57606a)"};function z(e,t){return{minWidth:e,minHeight:e,padding:"0 12px",borderRadius:999,border:"1px solid var(--semiotic-border, #d8dee4)",background:t?"var(--semiotic-primary, #0969da)":"var(--semiotic-bg, #fff)",color:t?"var(--semiotic-on-primary, #fff)":"var(--semiotic-text, #24292f)",fontSize:13,fontWeight:650,touchAction:"manipulation"}}function S(e){return"function"==typeof e}function I({brush:e,targetSize:t}){const r=e?.value,n=e?.domain,a=!!r&&!!n,o=!0===e?.disabled,i=e?.formatValue??(e=>e),l=!!e?.onChange&&a&&!o,s=n?.[0]??0,c=n?.[1]??1,u=r?.[0]??s,d=r?.[1]??c,p=e?.step??((c-s)/100||1);return $("section",{style:M,"aria-label":"Brush controls",children:[x("div",{style:T,children:e?.label??"Filter range"}),a?$("div",{style:{display:"grid",gap:8},children:[$("label",{style:{display:"grid",gap:4,fontSize:12},children:[$("span",{children:["Start: ",i(u)]}),x("input",{type:"range",min:s,max:c,step:p,value:u,disabled:!l,style:{minHeight:t},onChange:t=>{const r=Number(t.currentTarget.value);e?.onChange?.([Math.min(r,d),d])}})]}),$("label",{style:{display:"grid",gap:4,fontSize:12},children:[$("span",{children:["End: ",i(d)]}),x("input",{type:"range",min:s,max:c,step:p,value:d,disabled:!l,style:{minHeight:t},onChange:t=>{const r=Number(t.currentTarget.value);e?.onChange?.([u,Math.max(r,u)])}})]})]}):x("div",{style:{fontSize:12,color:"var(--semiotic-text-secondary, #57606a)"},children:"Provide a brush domain and value to expose range inputs beside the drag gesture."}),x("button",{type:"button",disabled:o||!S(e?.onClear),onClick:e?.onClear,style:z(t),children:"Clear range"})]})}function A({zoom:e,targetSize:t}){const r=!0===e?.disabled;return $("section",{style:M,"aria-label":"Zoom controls",children:[x("div",{style:T,children:e?.label??"Zoom"}),$("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[x("button",{type:"button","aria-label":"Zoom out",disabled:r||!S(e?.onZoomOut),onClick:e?.onZoomOut,style:z(t),children:"-"}),x("button",{type:"button","aria-label":"Reset zoom",disabled:r||!S(e?.onReset),onClick:e?.onReset,style:z(t),children:"Reset"}),x("button",{type:"button","aria-label":"Zoom in",disabled:r||!S(e?.onZoomIn),onClick:e?.onZoomIn,style:z(t),children:"+"})]})]})}function P({legend:e,targetSize:t}){const r=!0===e?.disabled,n=e?.items??[];return $("section",{style:M,"aria-label":"Legend controls",children:[x("div",{style:T,children:e?.label??"Series"}),n.length>0&&x("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:n.map(n=>{const a=!1!==n.active;return $("button",{type:"button",disabled:r||n.disabled||!e?.onToggle,onClick:()=>e?.onToggle?.(n.id,!a),style:z(t,a),"aria-pressed":a,children:[n.color&&x("span",{"aria-hidden":"true",style:{display:"inline-block",width:9,height:9,marginRight:6,borderRadius:999,background:n.color}}),n.label??n.id]},n.id)})}),$("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[x("button",{type:"button",disabled:r||!S(e?.onShowAll),onClick:e?.onShowAll,style:z(t),children:"Show all"}),x("button",{type:"button",disabled:r||!S(e?.onHideAll),onClick:e?.onHideAll,style:z(t),children:"Hide all"})]})]})}function D({controls:e,targetSize:t=44,compact:r=!1,className:n,style:a,ariaLabel:o="Mobile chart controls",brush:i,zoom:l,legend:s}){const c=function(e,t){if(!1===e)return[];if(!0===e||"all"===e)return["brush","zoom","legend"];if(Array.isArray(e))return e;if(e)return[e];const r=[];return t.brush&&r.push("brush"),t.zoom&&r.push("zoom"),t.legend&&r.push("legend"),r}(e,{brush:i,zoom:l,legend:s});return 0===c.length?null:$("div",{className:n,role:"group","aria-label":o,style:{display:"grid",gridTemplateColumns:r?"1fr":"repeat(auto-fit, minmax(180px, 1fr))",gap:10,...a},children:[c.includes("brush")&&x(I,{brush:i,targetSize:t}),c.includes("zoom")&&x(A,{zoom:l,targetSize:t}),c.includes("legend")&&x(P,{legend:s,targetSize:t})]})}export{y as CircularBrush,l as DirectManipulationControl,D as MobileStandardControls,r as VISUALIZATION_CONTROL_TYPES,c as auditVisualizationControls,C as clampMobileRange,n as createControlObservationAdapter,w as useMobileRangeControls,k as zoomMobileRange};
|
|
2
|
+
import{CircularBrush as e,DirectManipulationControl as t}from"./chunk-chunk-G7WFWHAD.module.min.js";import{MobileStandardControls as n,VISUALIZATION_CONTROL_TYPES as r,auditVisualizationControls as i,clampMobileRange as a,createControlObservationAdapter as l,useMobileRangeControls as o,zoomMobileRange as s}from"./chunk-chunk-RCF52Z42.module.min.js";import*as c from"react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";var p="undefined"==typeof window?c.useEffect:c.useLayoutEffect,m={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},h={position:"absolute",zIndex:30,top:"calc(100% + 0.5rem)",left:0,boxSizing:"border-box",display:"flex",flexDirection:"column",gap:8,width:"var(--sentence-filter-popover-width, 18rem)",maxWidth:"min(22rem, calc(100vw - 2rem))",maxHeight:"min(24rem, calc(100vh - 2rem))",overflow:"auto",padding:12,color:"var(--sentence-filter-text-color, var(--semiotic-fg, #1f2933))",backgroundColor:"var(--semiotic-bg, #fff)",border:"1px solid var(--semiotic-border, #cbd5e1)",borderRadius:6,boxShadow:"0 10px 28px rgba(15, 23, 42, 0.18)",fontFamily:"inherit",fontSize:"1rem",fontWeight:400,lineHeight:1.4,textAlign:"left",whiteSpace:"normal"},b={offsetX:0,placement:"below",maxHeight:null,maxWidth:null},y={boxSizing:"border-box",width:"100%",minHeight:38,padding:"6px 8px",color:"inherit",backgroundColor:"var(--semiotic-bg, #fff)",border:"1px solid var(--semiotic-border, #94a3b8)",borderRadius:4,font:"inherit"},v={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%",minHeight:38,padding:"7px 8px",color:"inherit",backgroundColor:"transparent",border:0,borderRadius:4,font:"inherit",textAlign:"left",cursor:"pointer"};function g(e){return null==e||"boolean"==typeof e?"":"string"==typeof e||"number"==typeof e?e+"":Array.isArray(e)?e.map(g).join(""):c.isValidElement(e)?g(e.props.children):""}function x(e,t){return Object.is(e,t)}function w(e,t){return e.find(e=>x(e.value,t))}function k(e){return null==e||""===e||Array.isArray(e)&&0===e.length}function C(e,t){if(k(t))return e.emptyLabel??"Any";if("select"===e.type)return w(e.options,t)?.label??t+"";if("multiselect"===e.type){const n=t.map(t=>w(e.options,t)?.label??t+""),r="or"===e.conjunction?" or ":" and ";return n.map((e,t)=>f(c.Fragment,{children:[t>0?r:null,e]},t))}return"toggle"===e.type?t?e.trueLabel??"on":e.falseLabel??"off":"range"===e.type?`${t[0]} to ${t[1]}`:t+""}function L(e,t,n){return k(t)?g(e.emptyLabel??"Any"):e.getAccessibleValue?e.getAccessibleValue(t,n):g(C(e,t))||t+""}function E(e){return 0===e.detail?"keyboard":"pointer"}function M(e,t){const n=t.trim().toLocaleLowerCase();return n?e.filter(e=>[g(e.label),...e.keywords??[]].some(e=>e.toLocaleLowerCase().includes(n))):e}function S(e,t,n){if(0===e.length)return-1;for(let r=1;e.length>=r;r+=1){const i=(t+n*r+e.length)%e.length;if(!e[i].disabled)return i}return-1}function A(e,t=0){const[n,r]=c.useState(()=>e[t]&&!e[t].disabled?t:S(e,-1,1)),i=c.useRef(null),a=c.useRef({value:"",at:0});c.useEffect(()=>{(0>n||!e[n]||e[n].disabled)&&r(S(e,-1,1))},[n,e]);const l=c.useCallback(e=>{0>e||(r(e),i.current?.querySelector(`[data-sentence-filter-option-index="${e}"]`)?.focus())},[]),o=c.useCallback(t=>{let r=-1;if("ArrowDown"===t.key)r=S(e,n,1);else if("ArrowUp"===t.key)r=S(e,n,-1);else if("Home"===t.key)r=S(e,-1,1);else if("End"===t.key)r=S(e,0,-1);else if(1===t.key.length&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const i=Date.now(),l=a.current,o=`${i-l.at>600?"":l.value}${t.key}`.toLocaleLowerCase();a.current={value:o,at:i};for(let t=1;e.length>=t;t+=1){const i=(Math.max(n,-1)+t)%e.length,a=e[i],l=[g(a.label),...a.keywords??[]];if(!a.disabled&&l.some(e=>e.toLocaleLowerCase().startsWith(o))){r=i;break}}}0>r||(t.preventDefault(),l(r))},[n,l,e]);return{activeIndex:n,focusIndex:l,listRef:i,onKeyDown:o}}function D({option:e}){return f(u,{children:[d("span",{children:e.label}),null!=e.count?d("span",{"aria-label":e.count+" results",children:e.count}):null,e.description?d("span",{style:{display:"block",fontSize:"0.82em",opacity:.78},children:e.description}):null]})}function $({value:e,definition:t,setValue:n,close:r}){const i=t,[a,l]=c.useState(""),o=c.useMemo(()=>M(i.options,a),[a,i.options]),s=Math.max(0,o.findIndex(t=>x(t.value,e))),p=A(o,s);return f(u,{children:[i.searchable?d("input",{"data-sentence-filter-autofocus":!0,type:"search","aria-label":"Search "+i.label,value:a,onChange:e=>l(e.currentTarget.value),onKeyDown:e=>{"ArrowDown"===e.key&&(e.preventDefault(),p.focusIndex(S(o,-1,1)))},style:y}):null,f("span",{ref:p.listRef,role:"listbox","aria-label":i.label,style:{display:"flex",flexDirection:"column",gap:2},children:[o.map((t,a)=>d("button",{"data-sentence-filter-option-index":a,"data-sentence-filter-autofocus":i.searchable||a!==p.activeIndex?void 0:"",type:"button",role:"option","aria-selected":x(t.value,e),tabIndex:a===p.activeIndex?0:-1,disabled:t.disabled,onKeyDown:p.onKeyDown,onClick:e=>{n(t.value,E(e)),r()},style:{...v,backgroundColor:x(t.value,e)?"var(--sentence-filter-hover-background, rgba(78, 121, 167, 0.12))":"transparent",opacity:t.disabled?.5:1},children:d(D,{option:t})},`${t.value+""}-${a}`)),0===o.length?d("span",{role:"status",children:"No options found."}):null]})]})}function N({value:e,definition:t,setValue:n}){const r=t,[i,a]=c.useState(""),l=c.useMemo(()=>M(r.options,i),[r.options,i]),o=Array.isArray(e)?e:[],s=A(l);return f(u,{children:[r.searchable?d("input",{"data-sentence-filter-autofocus":!0,type:"search","aria-label":"Search "+r.label,value:i,onChange:e=>a(e.currentTarget.value),onKeyDown:e=>{"ArrowDown"===e.key&&(e.preventDefault(),s.focusIndex(S(l,-1,1)))},style:y}):null,f("span",{ref:s.listRef,role:"group","aria-label":r.label,style:{display:"flex",flexDirection:"column",gap:2},children:[l.map((e,t)=>{const i=o.some(t=>x(t,e.value));return f("label",{style:{...v,justifyContent:"flex-start",opacity:e.disabled?.5:1},children:[d("input",{"data-sentence-filter-option-index":t,"data-sentence-filter-autofocus":r.searchable||t!==s.activeIndex?void 0:"",type:"checkbox",checked:i,disabled:e.disabled,tabIndex:t===s.activeIndex?0:-1,onKeyDown:s.onKeyDown,onChange:t=>{const r=t.currentTarget.checked?[...o,e.value]:o.filter(t=>!x(t,e.value));n(r,"input")}}),d("span",{style:{flex:1},children:d(D,{option:e})})]},`${e.value+""}-${t}`)}),0===l.length?d("span",{role:"status",children:"No options found."}):null]})]})}function V({value:e,definition:t,setValue:n}){const r=t,i=r.inputMode??"input",a={min:r.min,max:r.max,step:r.step??1,value:"number"==typeof e?e:r.min??0,onChange:e=>{const t=e.currentTarget.valueAsNumber;Number.isFinite(t)&&n(t,"input")}};return f(u,{children:["slider"!==i?d("input",{...a,"data-sentence-filter-autofocus":!0,type:"number","aria-label":r.label,style:y}):null,"input"!==i?d("input",{...a,"data-sentence-filter-autofocus":"slider"===i?"":void 0,type:"range","aria-label":r.label,style:{width:"100%"}}):null]})}function I({value:e,definition:t,setValue:n}){const r=t,i=Array.isArray(e)&&e.length>=2?[Number(e[0]),Number(e[1])]:[r.min,r.max],a=(e,t)=>{if(!Number.isFinite(t))return;const a=Math.min(r.max,Math.max(r.min,t));n(0===e?[Math.min(a,i[1]),i[1]]:[i[0],Math.max(a,i[0])],"input")},l={min:r.min,max:r.max,step:r.step??1};return f(u,{children:[f("span",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[f("label",{children:[d("span",{children:"Minimum"}),d("input",{...l,"data-sentence-filter-autofocus":!0,type:"number",value:i[0],onChange:e=>a(0,e.currentTarget.valueAsNumber),style:y})]}),f("label",{children:[d("span",{children:"Maximum"}),d("input",{...l,type:"number",value:i[1],onChange:e=>a(1,e.currentTarget.valueAsNumber),style:y})]})]}),f("label",{children:[f("span",{style:m,children:["Minimum ",r.label]}),d("input",{...l,type:"range",value:i[0],onChange:e=>a(0,e.currentTarget.valueAsNumber),style:{width:"100%"}})]}),f("label",{children:[f("span",{style:m,children:["Maximum ",r.label]}),d("input",{...l,type:"range",value:i[1],onChange:e=>a(1,e.currentTarget.valueAsNumber),style:{width:"100%"}})]})]})}function F({value:e,definition:t,setValue:n,close:r}){const i=t,a=[{value:!0,label:i.trueLabel??"On"},{value:!1,label:i.falseLabel??"Off"}],l=A(a.map(e=>({...e})),!1===e?1:0);return d("span",{ref:l.listRef,role:"listbox","aria-label":i.label,style:{display:"flex",gap:4},children:a.map((t,i)=>d("button",{"data-sentence-filter-option-index":i,"data-sentence-filter-autofocus":i===l.activeIndex?"":void 0,type:"button",role:"option","aria-selected":e===t.value,tabIndex:i===l.activeIndex?0:-1,onKeyDown:l.onKeyDown,onClick:e=>{n(t.value,E(e)),r()},style:{...v,justifyContent:"center",backgroundColor:e===t.value?"var(--sentence-filter-hover-background, rgba(78, 121, 167, 0.12))":"transparent"},children:t.label},t.value+""))})}function R({value:e,definition:t,setValue:n,close:r}){const i=t,a="string"==typeof e?e:"",[l,o]=c.useState(""),s=c.useMemo(()=>M(i.suggestions??[],l),[l,i.suggestions]),p=A(s);return f(u,{children:[d("input",{"data-sentence-filter-autofocus":!0,type:"text","aria-label":i.label,placeholder:i.placeholder,value:a,onChange:e=>{o(e.currentTarget.value),n(e.currentTarget.value,"input")},onKeyDown:e=>{"ArrowDown"===e.key&&s.length>0&&(e.preventDefault(),p.focusIndex(S(s,-1,1)))},style:y}),s.length>0?d("span",{ref:p.listRef,role:"listbox","aria-label":i.label+" suggestions",style:{display:"flex",flexDirection:"column",gap:2},children:s.map((e,t)=>d("button",{"data-sentence-filter-option-index":t,type:"button",role:"option","aria-selected":e.value===a,disabled:e.disabled,tabIndex:t===p.activeIndex?0:-1,onKeyDown:p.onKeyDown,onClick:t=>{n(e.value,E(t)),r()},style:{...v,opacity:e.disabled?.5:1},children:d(D,{option:e})},`${e.value}-${t}`))}):null]})}function W(e){switch(e.definition.type){case"select":return d($,{...e});case"multiselect":return d(N,{...e});case"number":return d(V,{...e});case"range":return d(I,{...e});case"toggle":return d(F,{...e});case"text":return d(R,{...e})}}function H({sentence:e,filters:t,defaultFilters:n,definitions:r,onChange:i,as:a="div",className:l,style:o,size:s="inherit",align:u="start",wrap:y=!0,disabled:g=!1,readOnly:x=!1,ariaLabel:w,id:E,renderControl:M,onOpenChange:S}){const[A,D]=c.useState(()=>({...n??{}})),$=t??A,N=c.useRef($);N.current=$;const V=void 0!==t,I=c.useMemo(()=>function(e){const t=[];let n="";const r=()=>{if(!n)return;const e=t[t.length-1];"text"===e?.type?e.value+=n:t.push({type:"text",value:n}),n=""};for(let i=0;e.length>i;)if(e.startsWith("{{",i))n+="{",i+=2;else if(e.startsWith("}}",i))n+="}",i+=2;else{if("{"===e[i]){const n=e.indexOf("}",i+1);if(-1!==n){const a=e.slice(i+1,n);if(a.length>0&&!a.includes("{")){r(),t.push({type:"filter",key:a}),i=n+1;continue}}}n+=e[i],i+=1}return r(),t}(e),[e]),[F,R]=c.useState(null),[H,K]=c.useState(b),z=c.useRef(F);z.current=F;const T=c.useRef(null),j=c.useRef(null),O=c.useRef(new Set),[B,X]=c.useState(""),[q,_]=c.useState(null),[P,Z]=c.useState(null),G=c.useId().replace(/:/g,""),U=E??"sentence-filter-"+G;c.useEffect(()=>{if("undefined"==typeof process||"production"!==process.env?.NODE_ENV)for(const e of I){if("filter"!==e.type)continue;let t=null;r[e.key]?e.key in $||(t=`SentenceFilter: placeholder "{${e.key}}" has no matching filter value.`):t=`SentenceFilter: placeholder "{${e.key}}" has no matching definition.`,t&&!O.current.has(t)&&(O.current.add(t),console.warn(t))}},[r,$,I]);const J=c.useCallback(()=>{z.current&&(z.current=null,R(null),K(b),S?.(null),j.current?.focus())},[S]);c.useEffect(()=>{if(!F)return;const e=e=>{T.current?.contains(e.target)||J()},t=e=>{"Escape"===e.key&&(e.preventDefault(),J())};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("click",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("click",e),document.removeEventListener("keydown",t)}},[J,F]),p(()=>{if(!F||"undefined"==typeof window)return;const e=T.current?.querySelector(`[data-sentence-filter-popover="${F.occurrence}"]`);if(!e)return;const t=()=>{const t=16,n=e.getBoundingClientRect();if(0>=n.width)return;const r=j.current?.getBoundingClientRect(),i=window.visualViewport,a=i?.offsetLeft??0,l=i?.offsetTop??0,o=i?.width??window.innerWidth,s=a+o,c=l+(i?.height??window.innerHeight),u=window.getComputedStyle(e),d=Number.parseFloat(u.getPropertyValue("--sentence-filter-popover-viewport-inset-top")),f=Number.parseFloat(u.getPropertyValue("--sentence-filter-popover-viewport-inset-bottom"));let p=l+(Number.isFinite(d)?Math.max(0,d):0),m=c-(Number.isFinite(f)?Math.max(0,f):0),h=j.current?.parentElement??null;for(;h;){const e=window.getComputedStyle(h);if("sticky"===e.position){const t=h.getBoundingClientRect(),n=Number.parseFloat(e.top),r=Number.parseFloat(e.bottom);Number.isFinite(n)&&1>=Math.abs(t.top-(l+n))&&(p=Math.max(p,t.bottom)),Number.isFinite(r)&&1>=Math.abs(t.bottom-(c-r))&&(m=Math.min(m,t.top))}h=h.parentElement}const b=n.left-H.offsetX,y=n.right-H.offsetX;let v=0;y>s-t&&(v-=y-(s-t)),a+t>b+v&&(v+=a+t-(b+v));const g=r?m-r.bottom-8-t:m-p-32,x=r?r.top-p-8-t:0,w=Math.min(Math.max(n.height,e.scrollHeight),160)>g&&x>g?"above":"below",k=Math.max(0,Math.min(384,Math.floor("above"===w?x:g))),C=Math.max(0,Math.floor(o-32));K(e=>e.offsetX===v&&e.placement===w&&e.maxHeight===k&&e.maxWidth===C?e:{offsetX:v,placement:w,maxHeight:k,maxWidth:C})};return t(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),window.visualViewport?.addEventListener("resize",t),window.visualViewport?.addEventListener("scroll",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0),window.visualViewport?.removeEventListener("resize",t),window.visualViewport?.removeEventListener("scroll",t)}},[F,H]),c.useEffect(()=>{if(!F)return;const e=T.current?.querySelector(`[data-sentence-filter-popover="${F.occurrence}"]`),t=e?.querySelector("[data-sentence-filter-autofocus]")??e;t?.focus()},[F]),c.useEffect(()=>{F&&(g||x||r[F.key]?.disabled)&&J()},[J,r,g,F,x]);const Q=c.useCallback((e,t,n)=>{const a=N.current,l=a[e]??null,o={...a,[e]:t};V||(N.current=o,D(o));const s={key:e,previousValue:l,value:t,source:n};i?.(o,s);const c=r[e];if(c){const e=L(c,l,a),n=L(c,t,o);X(`${c.label} changed from ${e} to ${n}.`)}},[V,r,i]),Y=c.useMemo(()=>I.map(e=>{if("text"===e.type)return e.value;const t=r[e.key];return t?L(t,$[e.key],$):`{${e.key}}`}).join(""),[r,$,I]),ee={position:"relative",margin:0,color:"var(--sentence-filter-text-color, inherit)",fontFamily:"inherit",fontSize:"small"===s?"0.875rem":"medium"===s?"1rem":"large"===s?"1.5rem":"inherit",lineHeight:"inherit",textAlign:"start"===u?"start":"end"===u?"end":"center",whiteSpace:y?"normal":"nowrap",...o},te=["semiotic-sentence-filter",l].filter(Boolean).join(" ");let ne=0;return f(a,{ref:e=>{T.current=e},id:U,className:te,style:ee,role:"div"===a||"span"===a?"group":void 0,"aria-label":w??Y,"data-semiotic-control":"sentence-filter","data-sentence-filter-state":V?"controlled":"uncontrolled",children:[I.map((e,t)=>{if("text"===e.type)return d("span",{"aria-hidden":"true",children:e.value},t);const n=r[e.key];if(!n)return d("span",{"aria-hidden":"true",children:`{${e.key}}`},t);const i=ne;ne+=1;const a=$[e.key]??null,l=function(e,t,n){return k(t)?e.emptyLabel??"Any":e.formatValue?e.formatValue(t,n):C(e,t)}(n,a,$),o=L(n,a,$),s=F?.key===e.key&&F.occurrence===i,c=g||x||!!n.disabled,u=e.key.replace(/[^a-zA-Z0-9_-]/g,"-"),p=`${U}-${u}-${i}-popover`;return f("span",{className:"semiotic-sentence-filter__value",style:{position:"relative",display:"inline"},children:[d("button",{type:"button","aria-haspopup":"dialog","aria-expanded":s,"aria-controls":p,"aria-label":`${n.label}: ${o}. Activate to change.`,disabled:c,"data-sentence-filter-key":e.key,"data-sentence-filter-type":n.type,"data-sentence-filter-open":s||void 0,onMouseEnter:()=>_(i),onMouseLeave:()=>_(e=>e===i?null:e),onFocus:()=>Z(i),onBlur:()=>Z(e=>e===i?null:e),onClick:t=>{if(c)return;if(s)return void J();j.current=t.currentTarget;const r={key:e.key,occurrence:i};z.current=r,K(b),R(r),X(n.label+" control opened."),S?.(e.key)},style:{appearance:"none",display:"inline",minWidth:24,padding:"0.35em 0.12em",margin:"-0.35em 0",color:n.accent??"var(--sentence-filter-accent, var(--semiotic-primary, #4e79a7))",backgroundColor:q===i||s?"var(--sentence-filter-hover-background, rgba(78, 121, 167, 0.12))":"transparent",border:0,borderBottom:"var(--sentence-filter-underline-thickness, 0.09em) solid currentColor",borderRadius:2,outline:P===i?"2px solid var(--sentence-filter-focus-color, currentColor)":"2px solid transparent",outlineOffset:2,font:"inherit",fontWeight:600,lineHeight:"inherit",textAlign:"inherit",cursor:c?"default":"pointer",opacity:c?.6:1},children:l}),s?f("span",{id:p,role:"dialog","aria-label":n.label,"aria-describedby":n.description?p+"-description":void 0,tabIndex:-1,"data-sentence-filter-popover":i,"data-sentence-filter-key":e.key,style:{...h,top:"below"===H.placement?"calc(100% + 0.5rem)":"auto",bottom:"above"===H.placement?"calc(100% + 0.5rem)":"auto",left:H.offsetX,maxHeight:H.maxHeight??h.maxHeight,maxWidth:H.maxWidth??h.maxWidth},children:[d("span",{style:{fontWeight:650},children:n.label}),n.description?d("span",{id:p+"-description",style:{fontSize:"0.88em",opacity:.78},children:n.description}):null,M?M({key:e.key,value:a,filters:$,definition:n,setValue:(t,n="programmatic")=>Q(e.key,t,n),close:J}):d(W,{value:a,definition:n,setValue:(t,n)=>Q(e.key,t,n),close:J}),n.allowClear&&!k(a)?f("button",{type:"button",onClick:()=>{Q(e.key,"multiselect"===n.type?[]:null,"clear"),J()},style:{...v,justifyContent:"center",border:"1px solid var(--semiotic-border, #cbd5e1)"},children:["Clear ",n.label]}):null]}):null]},`${e.key}-${i}`)}),d("span",{role:"status","aria-live":"polite","aria-atomic":"true","data-sentence-filter-live-region":!0,style:m,children:B})]})}export{e as CircularBrush,t as DirectManipulationControl,n as MobileStandardControls,H as SentenceFilter,r as VISUALIZATION_CONTROL_TYPES,i as auditVisualizationControls,a as clampMobileRange,l as createControlObservationAdapter,o as useMobileRangeControls,s as zoomMobileRange};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{forceCenter as e,forceCollide as t,forceLink as o,forceManyBody as n,forceSimulation as r,forceX as f,forceY as a}from"d3-force";function c(c,s,i={}){const d=i.seed??1,u=i.iterations??260,l=i.repulsion??5200,g=i.linkDistance??165,h=i.linkStrength??.045,b=i.centerStrength??.018,y=i.damping??.84,p=i.nodeRadius??12,m=i.nodePadding??3,M=i.inset??.06,x=function(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(d),S=new Map;for(const e of c)S.set(e.id,0);for(const e of s)S.set(e.source,(S.get(e.source)??0)+1),S.set(e.target,(S.get(e.target)??0)+1);const k=500,w=c.map(e=>({id:e.id,data:e,x:200+600*x(),y:200+600*x()})),q=new Set(c.map(e=>e.id)),I=s.filter(e=>q.has(e.source)&&q.has(e.target)).map(e=>({source:e.source,target:e.target}));if(u>0){const c=r(w).randomSource(x).alphaDecay(1-Math.pow(.001,1/u)).velocityDecay(Math.max(0,Math.min(1,1-y))).force("charge",n().strength(e=>{const t=S.get(e.id)??0;return 2.5*-Math.sqrt(l)*Math.sqrt(t+1)})).force("collide",t(e=>(e=>"function"==typeof p?p(e.data):p)(e)+m).strength(.9).iterations(2)).force("center",e(k,k).strength(.8)).force("x",f(k).strength(b)).force("y",a(k).strength(b));I.length>0&&c.force("link",o(I).id(e=>e.id).distance(g).strength(e=>{const t="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(S.get(t)??1,S.get(o)??1));return h/.045/n})),c.stop();for(let e=0;e<u;e+=1)c.tick()}let R=1/0,v=1/0,z=-1/0,$=-1/0;for(const e of w){const t=e.x??k,o=e.y??k;t<R&&(R=t),o<v&&(v=o),t>z&&(z=t),o>$&&($=o)}const E=z-R,_=$-v,C={};for(const e of w)C[e.id]={x:0===E?.5:M+((e.x??k)-R)/E*(1-2*M),y:0===_?.5:M+((e.y??k)-v)/_*(1-2*M)};return C}import{forceSimulation as s,forceCenter as i,forceX as d,forceY as u,forceLink as l,forceManyBody as g,forceCollide as h}from"d3-force";import{scaleLinear as b}from"d3-scale";function y(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function p(e,t,o){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(o)}`}function m(e){const t=e.map(y),o=t.length-1;return e=>{if(e<=0){const[e,o,n]=t[0];return p(e,o,n)}if(e>=1){const[e,n,r]=t[o];return p(e,n,r)}const n=e*o,r=Math.floor(n),f=n-r,[a,c,s]=t[r],[i,d,u]=t[r+1];return p(Math.round(a+(i-a)*f),Math.round(c+(d-c)*f),Math.round(s+(u-s)*f))}}var M=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"];m(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),m(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),m(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),m(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),m(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),m(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),m(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),m(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),m(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),m(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),m(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),m(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),m(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),m(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),m(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),m(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),m(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),m(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),m(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var x=new Set,S=new WeakMap;function k(e,t){if(!e||!e.data||"object"!=typeof e.data)return e;let o=S.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,S.set(e,o);const n=new Proxy(e,{get(e,o,n){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;x.has(e)||(x.add(e),console.warn(`[Semiotic] "${t}" 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(e,o,n)}});return o.set(t,n),n}var w={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const r=o.forceStrength??.1,f=n[0]/2,a=n[1]/2,c=o.__previousPositions;let b=0;const y=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=c?.get(t.id);e?b++:o?(t.x=o.x,t.y=o.y,b++):y.push(t)}const p=e.length>0?y.length/e.length:1,m=b>0&&p<=.3;if(m){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of y){const n=q(e.id,t,o);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const r=I(e.id),f=r%360*(Math.PI/180),a=10+r%20;e.x=t/n.length+a*Math.cos(f),e.y=o/n.length+a*Math.sin(f)}else{const t=I(e.id),o=t%360*(Math.PI/180),n=15+t%30;e.x=f+n*Math.cos(o),e.y=a+n*Math.sin(o)}}}else{const t=Math.PI*(3-Math.sqrt(5));for(let o=0;o<e.length;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5),r=o*t;n.x=f+e*Math.cos(r),n.y=a+e*Math.sin(r)}}}const M=e.length,x=o.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(M-30)))),S=o.__skipForceSimulation||0===o.iterations?0:m?40:x,k=R(o.nodeSize,o.nodeSizeRange,e),w=e=>k(e);if(S>0){const o=new Map,n=new Map;for(const t of e)o.set(t.id,0),n.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;o.set(t,(o.get(t)??0)+1),o.set(n,(o.get(n)??0)+1)}const c=l().strength(e=>{const t=e.weight,n="string"==typeof e.source?e.source:e.source.id,f="string"==typeof e.target?e.target:e.target.id,a=Math.max(1,Math.min(o.get(n)??1,o.get(f)??1)),c=t&&t>0?Math.sqrt(t):1;return Math.min(2.5,c*r/(.1*a))}).distance(e=>{const t="string"==typeof e.source?n.get(e.source):e.source,o="string"==typeof e.target?n.get(e.target):e.target,r=(t?w(t):0)+(o?w(o):0)+12;return Math.max(40,r)}).id(e=>e.id),b=s().force("charge",g().strength(e=>{const t=o.get(e.id)??0;return-15*w(e)*Math.sqrt(t+1)})).force("collide",h(e=>w(e)+3).strength(.9).iterations(2)).force("center",i(f,a).strength(.8)).force("x",d(f).strength(.06)).force("y",u(a).strength(.06));if(b.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));c.links(e),b.force("link",c)}m?b.alpha(.3):b.alpha()<.1&&b.alpha(1),b.stop();for(let e=0;e<S;++e)b.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=w(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,n){const r=o.nodeStyle,f=o.edgeStyle,a=R(o.nodeSize,o.nodeSizeRange,e),c=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:M,s=new Map;e.forEach((e,t)=>{s.set(e.id,c[t%c.length])});const i=[],d=[],u=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(k(t,"nodeSize")),n=r?r(k(t,"nodeStyle")):{},f={fill:n.fill||s.get(t.id)||o.themeSemantic?.primary||"#007bff",stroke:n.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity};i.push({type:"circle",cx:t.x,cy:t.y,r:e,style:f,datum:t,id:t.id,label:t.id})}const l=new Map;for(const t of e)l.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:l.get(e.source),n="object"==typeof e.target?e.target:l.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const r=f?f(k(e,"edgeStyle")):{},a={stroke:r.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6};d.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:a,datum:e})}if(!1!==o.showLabels){const t=(g=o.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=a(k(o,"nodeSize"));u.push({x:o.x,y:o.y-n-4,text:String(e),anchor:"middle",baseline:"auto",fontSize:11})}}var g;return{sceneNodes:i,sceneEdges:d,labels:u}}};function q(e,t,o){const n=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,f="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=f:f===e&&(a=t),a){const e=o.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function I(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function R(e,t,o){if(o.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],r=[];for(const t of o){const o=t.data?.[e];"number"==typeof o&&r.push(o)}if(0===r.length)return()=>n[0];const[f,a]=function(e){let t=1/0,o=-1/0;for(const n of e)n<t&&(t=n),n>o&&(o=n);return[t,o]}(r);if(f===a)return()=>(n[0]+n[1])/2;const c=b().domain([f,a]).range(n).clamp(!0);return t=>{const o=t.data?.[e];return null==o||"number"!=typeof o?n[0]:c(o)}}self.onmessage=e=>{const t=e.data,o=t?.requestId,n=t?.request??t;try{if("normalized"===n.kind){const e=n.nodeRadii,t=e?{...n.options,nodeRadius:t=>e[t.id]??12}:n.options;return void self.postMessage({requestId:o,positions:c(n.nodes,n.edges,t)})}const e=n.nodes,t=n.edges;w.computeLayout(e,t,n.config,n.size),self.postMessage({requestId:o,positions:Object.fromEntries(e.map(e=>[e.id,{x:e.x,y:e.y}]))})}catch(e){self.postMessage({requestId:o,error:{message:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:"Error",stack:e instanceof Error?e.stack:void 0}})}};
|
|
1
|
+
import{forceCenter as e,forceCollide as t,forceLink as o,forceManyBody as n,forceSimulation as r,forceX as a,forceY as f}from"d3-force";function c(c,s,i={}){const d=i.seed??1,u=i.iterations??260,l=i.repulsion??5200,g=i.linkDistance??165,h=i.linkStrength??.045,b=i.centerStrength??.018,y=i.damping??.84,p=i.nodeRadius??12,m=i.nodePadding??3,M=i.inset??.06,x=function(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(d),S=new Map;for(const e of c)S.set(e.id,0);for(const e of s)S.set(e.source,(S.get(e.source)??0)+1),S.set(e.target,(S.get(e.target)??0)+1);const k=500,w=c.map(e=>({id:e.id,data:e,x:200+600*x(),y:200+600*x()})),q=new Set(c.map(e=>e.id)),v=s.filter(e=>q.has(e.source)&&q.has(e.target)).map(e=>({source:e.source,target:e.target}));if(u>0){const c=r(w).randomSource(x).alphaDecay(1-Math.pow(.001,1/u)).velocityDecay(Math.max(0,Math.min(1,1-y))).force("charge",n().strength(e=>{const t=S.get(e.id)??0;return 2.5*-Math.sqrt(l)*Math.sqrt(t+1)})).force("collide",t(e=>(e=>"function"==typeof p?p(e.data):p)(e)+m).strength(.9).iterations(2)).force("center",e(k,k).strength(.8)).force("x",a(k).strength(b)).force("y",f(k).strength(b));v.length>0&&c.force("link",o(v).id(e=>e.id).distance(g).strength(e=>{const t="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(S.get(t)??1,S.get(o)??1));return h/.045/n})),c.stop();for(let e=0;e<u;e+=1)c.tick()}let I=1/0,R=1/0,z=-1/0,$=-1/0;for(const e of w){const t=e.x??k,o=e.y??k;t<I&&(I=t),o<R&&(R=o),t>z&&(z=t),o>$&&($=o)}const E=z-I,_=$-R,C={};for(const e of w)C[e.id]={x:0===E?.5:M+((e.x??k)-I)/E*(1-2*M),y:0===_?.5:M+((e.y??k)-R)/_*(1-2*M)};return C}import{forceSimulation as s,forceCenter as i,forceX as d,forceY as u,forceLink as l,forceManyBody as g,forceCollide as h}from"d3-force";import{scaleLinear as b}from"d3-scale";function y(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function p(e,t,o){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(o)}`}function m(e){const t=e.map(y),o=t.length-1;return e=>{if(e<=0){const[e,o,n]=t[0];return p(e,o,n)}if(e>=1){const[e,n,r]=t[o];return p(e,n,r)}const n=e*o,r=Math.floor(n),a=n-r,[f,c,s]=t[r],[i,d,u]=t[r+1];return p(Math.round(f+(i-f)*a),Math.round(c+(d-c)*a),Math.round(s+(u-s)*a))}}var M=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"];m(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),m(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),m(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),m(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),m(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),m(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),m(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),m(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),m(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),m(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),m(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),m(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),m(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),m(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),m(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),m(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),m(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),m(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),m(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var x=new Set,S=new WeakMap;function k(e,t){if(!e||!e.data||"object"!=typeof e.data)return e;let o=S.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,S.set(e,o);const n=new Proxy(e,{get(e,o,n){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;x.has(e)||(x.add(e),console.warn(`[Semiotic] "${t}" 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(e,o,n)}});return o.set(t,n),n}var w={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const r=o.forceStrength??.1,a=n[0]/2,f=n[1]/2,c=o.__previousPositions;let b=0;const y=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=c?.get(t.id);e?b++:o?(t.x=o.x,t.y=o.y,b++):y.push(t)}const p=e.length>0?y.length/e.length:1,m=b>0&&p<=.3;if(m){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of y){const n=q(e.id,t,o);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const r=v(e.id),a=r%360*(Math.PI/180),f=10+r%20;e.x=t/n.length+f*Math.cos(a),e.y=o/n.length+f*Math.sin(a)}else{const t=v(e.id),o=t%360*(Math.PI/180),n=15+t%30;e.x=a+n*Math.cos(o),e.y=f+n*Math.sin(o)}}}else{const t=Math.PI*(3-Math.sqrt(5));for(let o=0;o<e.length;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5),r=o*t;n.x=a+e*Math.cos(r),n.y=f+e*Math.sin(r)}}}const M=e.length,x=o.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(M-30)))),S=o.__skipForceSimulation||0===o.iterations?0:m?40:x,k=I(o.nodeSize,o.nodeSizeRange,e),w=e=>k(e);if(S>0){const n=new Map,c=new Map;for(const t of e)n.set(t.id,0),c.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(o,(n.get(o)??0)+1)}const b=l().strength(e=>{const t=e.weight,o="string"==typeof e.source?e.source:e.source.id,a="string"==typeof e.target?e.target:e.target.id,f=Math.max(1,Math.min(n.get(o)??1,n.get(a)??1)),c=t&&t>0?Math.sqrt(t):1;return Math.min(2.5,c*r/(.1*f))}).distance(e=>{const t="string"==typeof e.source?c.get(e.source):e.source,o="string"==typeof e.target?c.get(e.target):e.target,n=(t?w(t):0)+(o?w(o):0)+12;return Math.max(40,n)}).id(e=>e.id),y=s();if(void 0===o.random&&void 0===o.seed||y.randomSource(o.random??function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(o.seed)),y.force("charge",g().strength(e=>{const t=n.get(e.id)??0;return-15*w(e)*Math.sqrt(t+1)})).force("collide",h(e=>w(e)+3).strength(.9).iterations(2)).force("center",i(a,f).strength(.8)).force("x",d(a).strength(.06)).force("y",u(f).strength(.06)),y.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));b.links(e),y.force("link",b)}m?y.alpha(.3):y.alpha()<.1&&y.alpha(1),y.stop();for(let e=0;e<S;++e)y.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=w(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const R=new Map;for(const t of e)R.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=R.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=R.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,n){const r=o.nodeStyle,a=o.edgeStyle,f=I(o.nodeSize,o.nodeSizeRange,e),c=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:M,s=new Map;e.forEach((e,t)=>{s.set(e.id,c[t%c.length])});const i=[],d=[],u=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(k(t,"nodeSize")),n=r?r(k(t,"nodeStyle")):{},a={fill:n.fill||s.get(t.id)||o.themeSemantic?.primary||"#007bff",stroke:n.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity};i.push({type:"circle",cx:t.x,cy:t.y,r:e,style:a,datum:t,id:t.id,label:t.id})}const l=new Map;for(const t of e)l.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:l.get(e.source),n="object"==typeof e.target?e.target:l.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const r=a?a(k(e,"edgeStyle")):{},f={stroke:r.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6};d.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:f,datum:e})}if(!1!==o.showLabels){const t=(g=o.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=f(k(o,"nodeSize"));u.push({x:o.x,y:o.y-n-4,text:String(e),anchor:"middle",baseline:"auto",fontSize:11})}}var g;return{sceneNodes:i,sceneEdges:d,labels:u}}};function q(e,t,o){const n=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,a="string"==typeof r.target?r.target:r.target.id;let f=null;if(t===e?f=a:a===e&&(f=t),f){const e=o.get(f);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function v(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function I(e,t,o){if(o.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],r=[];for(const t of o){const o=t.data?.[e];"number"==typeof o&&r.push(o)}if(0===r.length)return()=>n[0];const[a,f]=function(e){let t=1/0,o=-1/0;for(const n of e)n<t&&(t=n),n>o&&(o=n);return[t,o]}(r);if(a===f)return()=>(n[0]+n[1])/2;const c=b().domain([a,f]).range(n).clamp(!0);return t=>{const o=t.data?.[e];return null==o||"number"!=typeof o?n[0]:c(o)}}self.onmessage=e=>{const t=e.data,o=t?.requestId,n=t?.request??t;try{if("normalized"===n.kind){const e=n.nodeRadii,t=e?{...n.options,nodeRadius:t=>e[t.id]??12}:n.options;return void self.postMessage({requestId:o,positions:c(n.nodes,n.edges,t)})}const e=n.nodes,t=n.edges;w.computeLayout(e,t,n.config,n.size),self.postMessage({requestId:o,positions:Object.fromEntries(e.map(e=>[e.id,{x:e.x,y:e.y}]))})}catch(e){self.postMessage({requestId:o,error:{message:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:"Error",stack:e instanceof Error?e.stack:void 0}})}};
|