semiotic 3.8.0 → 3.8.1
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 +12 -9
- package/README.md +39 -39
- package/ai/dist/mcp-server.js +98 -17
- package/ai/schema.json +1 -1
- package/ai/surface-manifest.json +3 -2
- package/ai/system-prompt.md +3 -2
- package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -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/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/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 +2 -2
- 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/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/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.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-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-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.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 +26 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as t from"react";import{useRef as e,useState as n,useEffect as r,useMemo as o,useCallback as i,useImperativeHandle as s,useId as a,forwardRef as l,memo as c}from"react";import{useRef as u,useEffect as h,useMemo as d}from"react";import{select as f}from"d3-selection";import{brush as y,brushX as p,brushY as g}from"d3-brush";import*as m from"react";import{jsx as x,jsxs as v}from"react/jsx-runtime";function b(t,e,n,r){const[o,i]=[Math.min(...e),Math.max(...e)],s=(i-o)/20;let[a,l]=t;if(r)0>n?a=Math.max(o,a-s):l=Math.min(i,l+s);else{const t=l-a;a=Math.max(o,Math.min(i-t,a+n*s)),l=a+t}return[a,l]}function k(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r+1>>1;e[o]>t?r=o-1:n=o}return e[n]}function w(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o]?n=o+1:r=o}return e[n]}function A({width:t,height:e,totalWidth:n,totalHeight:r,margin:o,dimension:i,scales:s,onBrush:a,binSize:l,snap:c,binBoundaries:A,snapDuring:S,streaming:_}){const M=u(null),P=u(null),C=u(a);C.current=a;const T=u(s);T.current=s;const L=d(()=>A?[...A].sort((t,e)=>t-e):void 0,[A]),N=u(L);N.current=L;const D=u(!1),E=u(null),R=function({label:t="Data range brush",description:e="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const r=m.useId().replace(/:/g,""),o=m.useRef(n);return o.current=n,{description:e,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":t,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:m.useCallback(t=>{const e=function(t){return"Escape"===t.key?{type:"clear"}:"ArrowLeft"===t.key?{type:"nudge",direction:"left",resize:t.shiftKey}:"ArrowRight"===t.key?{type:"nudge",direction:"right",resize:t.shiftKey}:"ArrowUp"===t.key?{type:"nudge",direction:"up",resize:t.shiftKey}:"ArrowDown"===t.key?{type:"nudge",direction:"down",resize:t.shiftKey}:null}(t);e&&(t.preventDefault(),o.current?.(e))},[])}}}({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:t=>{const e=T.current,n=P.current;if(!e||!n||!M.current)return;const r=f(M.current).select(".brush-g");if("clear"===t.type)return D.current=!0,r.call(n.move,null),D.current=!1,E.current=null,void C.current(null);const o=e.x.domain(),s=e.y.domain(),a=E.current;let l=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],c=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===t.direction||"right"===t.direction,h="left"===t.direction||"down"===t.direction?-1:1;if(u&&"y"!==i&&(l=b(l,o,h,t.resize)),u||"x"===i||(c=b(c,s,h,t.resize)),u&&"y"===i||!u&&"x"===i)return;const d={x:l,y:c};D.current=!0,r.call(n.move,"x"===i?[e.x(l[0]),e.x(l[1])]:"y"===i?[e.y(c[1]),e.y(c[0])]:[[e.x(l[0]),e.y(c[1])],[e.x(l[1]),e.y(c[0])]]),D.current=!1,E.current=d,C.current(d)}});return h(()=>{if(!M.current)return;const n=f(M.current).select(".brush-g"),r="x"===i?p():"y"===i?g():y();return r.extent([[0,0],[t,e]]),r.on("brush end",o=>{if(D.current)return;const s=T.current;if(!s)return;if(!o.selection)return E.current=null,void C.current(null);let a,u;if("x"===i){const[t,n]=o.selection;a=[s.x.invert(t),s.x.invert(n)],u=[s.y.invert(e),s.y.invert(0)]}else if("y"===i){const[e,n]=o.selection;a=[s.x.invert(0),s.x.invert(t)],u=[s.y.invert(n),s.y.invert(e)]}else{const[[t,e],[n,r]]=o.selection;a=[s.x.invert(t),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(e)]}if("bin"===c&&"y"!==i&&("end"===o.type||"brush"===o.type&&S)){const t=N.current;t&&t.length>0?a=function(t,e){return 0===e.length?t:[k(t[0],e),w(t[1],e)]}(a,t):l&&l>0&&(a=[Math.floor(a[0]/l)*l,Math.ceil(a[1]/l)*l]);const e=s.x(a[0]),c=s.x(a[1]);if(D.current=!0,"x"===i)n.call(r.move,[e,c]);else if("xy"===i){const t=o.selection;n.call(r.move,[[e,t[0][1]],[c,t[1][1]]])}D.current=!1}const h={x:a,y:u};E.current=h,C.current(h)}),n.call(r),P.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),P.current=null}},[t,e,i,c,l,S]),h(()=>{if(!(_&&s&&P.current&&E.current))return;if(!M.current)return;if("y"===i)return;const t=E.current,e=s.x.domain()[0],n=f(M.current).select(".brush-g");if(e>=t.x[1])return D.current=!0,n.call(P.current.move,null),D.current=!1,E.current=null,void C.current(null);let r=t.x[0],o=!1;if(e>t.x[0]){if(r=e,"bin"===c){const t=N.current;t&&t.length>0?r=w(e,t):l&&l>0&&(r=Math.ceil(e/l)*l)}if(r>=t.x[1])return D.current=!0,n.call(P.current.move,null),D.current=!1,E.current=null,void C.current(null);o=!0}const a=s.x(r),u=s.x(t.x[1]);if(D.current=!0,"x"===i)n.call(P.current.move,[a,u]);else{const e=s.y(t.y[1]),r=s.y(t.y[0]);n.call(P.current.move,[[a,e],[u,r]])}if(D.current=!1,o){const e={x:[r,t.x[1]],y:t.y};E.current=e,C.current(e)}},[s,_,i,c,l]),v("svg",{ref:M,width:n,height:r,...R.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[x("title",{children:R.svgProps["aria-label"]}),x("desc",{id:R.descriptionId,children:R.description}),x("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}var S=Object.freeze([]);function _(t){if(!t)return S;let e=!1;for(let n=0;t.length>n;n++){const r=t[n];if(null==r||"object"!=typeof r){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}var M=class{constructor(t,e){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=e?.chunkThreshold??5e3,this.chunkSize=e?.chunkSize??5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=_(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=_(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const r=t[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import{createContext as P,useCallback as C,useContext as T,useMemo as L,useRef as N,useSyncExternalStore as D}from"react";import{jsx as E}from"react/jsx-runtime";function R(t){let e=null;const n=()=>(e||(e=P(null)),e),r=I(t);return[function({children:e,initialState:r}){const o=N(r),i=L(()=>I(t,o.current),[]),s=n();return E(s.Provider,{value:i,children:e})},(t,e)=>{const o=n(),i=T(o)??r,s=N(t);s.current=t;const a=N({hasValue:!1,value:void 0}),l=C(()=>{const t=s.current(i.getState()),n=a.current;return n.hasValue&&e&&e(n.value,t)?n.value:(a.current={hasValue:!0,value:t},t)},[i,e]),c=C(()=>s.current(i.getState()),[i]);return D(i.subscribe,l,c)}]}function I(t,e){const n=new Set;let r={...t(function(t){const e=t(r);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){r={...r,...e};for(const t of n)t()}}),...e??{}};return{getState:()=>r,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function z(t){if(!t?.colors)return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function $(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:W}}),t.accessibility.highContrast){const t="dark"===e.mode;e={...e,colors:{...e.colors,text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"}}}return e}var W=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],F={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},O={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Y={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:W,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function B(t,e){if("light"===e)return F;if("dark"===e)return O;if("high-contrast"===e)return Y;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?O:F;return $({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return $({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[j,H]=R(t=>({theme:F,setTheme(e){t(t=>({theme:B(t.theme,e)}))}})),X=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let n=0,r=[];e.length>t&&(n=e.length-t,r=e.slice(0,n)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=n;e.length>t;t++)this.push(e[t]);return r}update(t,e){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,s=this.buffer[i];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(t),this.buffer[i]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(r=>{t(r)?n.push(r):e.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},G=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function V(t,e){return t===e}function q(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function U(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function K(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var Q=/^\d{4}-\d{1,2}$/;function Z(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=Q.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function J(t){return t instanceof Date?t.getTime():"string"==typeof t?Z(t):+t}function tt(t){return new Set(Array.isArray(t)?t:[t])}import{scaleOrdinal as et}from"d3-scale";function nt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function rt(t,e,n){const r=t=>t.toString(16).padStart(2,"0");return`#${r(t)}${r(e)}${r(n)}`}function ot(t){const e=t.map(nt),n=e.length-1;return t=>{if(0>=t){const[t,n,r]=e[0];return rt(t,n,r)}if(t>=1){const[t,r,o]=e[n];return rt(t,r,o)}const r=t*n,o=Math.floor(r),i=r-o,[s,a,l]=e[o],[c,u,h]=e[o+1];return rt(Math.round(s+(c-s)*i),Math.round(a+(u-a)*i),Math.round(l+(h-l)*i))}}var it=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],st=ot(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),at=ot(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),lt=ot(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ct=ot(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ut=ot(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ht=ot(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),dt=ot(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ft=ot(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),yt=ot(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),pt=ot(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),gt=ot(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),mt=ot(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),xt={blues:st,reds:at,greens:lt,viridis:dt,oranges:ct,purples:ut,greys:ht,plasma:ft,inferno:yt,magma:pt,cividis:gt,turbo:mt};ot(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),ot(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),ot(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),ot(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),ot(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),ot(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),ot(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var vt={category10:it,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...xt},bt=it,kt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function wt(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const n=t[e];return"string"==typeof n&&n.length>0?n:void 0}function At(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function St(t,e){return Math.min((t-e.startTime)/e.duration,1)}function _t(t,e,n){return t+(e-t)*n}function Mt(){return"undefined"!=typeof performance?performance.now():Date.now()}var Pt={fresh:1,aging:1.5,stale:3};function Ct(t,e,n={}){return Number.isFinite(e)&&e>0?Number.isNaN(t)?"fresh":t===1/0?"expired":0>t||e*(n.fresh??1)>t?"fresh":e*(n.aging??1.5)>t?"aging":e*(n.stale??3)>t?"stale":"expired":"fresh"}function Tt(t,e,n){if(null!=t)return"function"==typeof t?t(e,n):"object"==typeof t&&null!==t&&"constant"in t?t.constant:e[t]}function Lt(t){const{data:e,encoding:n}=t,r=[],o=new Map;return e.forEach((t,e)=>{const i=Tt(n.id,t,e);if(null==i||""===i)throw Error(`[semiotic] Motion encoding row ${e} resolved an empty id.`);const s=i+"";if(o.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=Tt(n.process?.group,t,e),l=Tt(n.process?.stage,t,e),c=Tt(n.accessible?.group,t,e)??(null!=a?a+"":null!=l?l+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=Tt(n.evidence?.[r],t,e);const h={id:s,datum:t,time:{arrival:Tt(n.time?.arrival,t,e),basis:n.time?.basis,unit:n.time?.unit},placement:{x:Tt(n.placement?.x,t,e),y:Tt(n.placement?.y,t,e),lane:Tt(n.placement?.lane,t,e),space:n.placement?.space},kinematics:{velocityX:Tt(n.kinematics?.velocityX,t,e),velocityY:Tt(n.kinematics?.velocityY,t,e),space:n.kinematics?.space},process:{group:a,stage:l,target:Tt(n.process?.target,t,e),work:Tt(n.process?.work,t,e)},evidence:u,accessible:{description:Tt(n.accessible?.description,t,e),group:c,label:Tt(n.accessible?.label,t,e)??s}};r.push(h),o.set(s,h)}),{rows:r,byId:o}}function Nt(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const n=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>n?1:e;if("exponential"===t.type){const r=t.halfLife??t.extent/2;return e+Math.pow(.5,n/(r>0?r:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-n/t.extent))*(1-e)}function Dt(t,e){const n=Number.isFinite(t)?t:0,r=Number.isFinite(e)?e:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function Et(t,e,n){return Number.isFinite(n)&&n>0?Dt((e.x-t.x)/n,(e.y-t.y)/n):Dt(0,0)}function Rt(t,e,n){if(1>=n)return 1;const r=n-1;return Nt({age:r-e,extent:r,type:t.type,halfLife:t.halfLife??n/2,threshold:t.stepThreshold??.5*n,minOpacity:t.minOpacity??.1})}function It(t){const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return e}function zt(t,e,n){const r=t.duration??500,o=n-e;return r>o?1-o/r:0}function $t(t,e,n,r){let o=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,o=!0),t._pulseColor!==n&&(t._pulseColor=n,o=!0),t._pulseGlowRadius!==r&&(t._pulseGlowRadius=r,o=!0),o):(0!==t._pulseIntensity&&(t._pulseIntensity=0,o=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,o=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,o=!0),o)}function Wt(t,e,n){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+n;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Ft(t,e,n,r,o,i){const s=[];for(const o of t){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&s.push({px:e.x(t),py:e.y(i),rawY:i,d:o})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:o,datum:c,group:i}}function Ot(t,e,n,r,o,i,s,a){const l=[];for(const i of t){const t=n(i),s=r(i);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(i):o;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:t,group:s}}function Yt(t,e,n,r){const o=new Map;if("silhouette"===r)for(const r of t){let t=0;for(const o of e)t+=n(o,r)||0;o.set(r,-t/2)}else if("wiggle"===r){t.length>0&&o.set(t[0],0);for(let r=1;t.length>r;r++){const i=t[r-1],s=t[r];let a=0,l=0,c=0;for(const t of e){const e=n(t,s)||0;a+=(2*c+e)*(e-(n(t,i)||0)),l+=e,c+=e}const u=o.get(i)??0;o.set(s,u-(l>0?a/(2*l):0))}if(t.length>0){let r=0;for(const i of t){let t=0;for(const r of e)t+=n(r,i)||0;r+=(o.get(i)??0)+t/2}const i=r/t.length;for(const e of t)o.set(e,(o.get(e)??0)-i)}}else for(const e of t)o.set(e,0);return o}function Bt(t,e,n,r,o,i,s){const a=n(t),l=r(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:o,style:i,datum:t};return void 0!==s&&(c.pointId=s),c}function jt(t,e,n,r,o,i,s,a){const l=n(t),c=r(t);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(l),y:e.y(c),size:o,symbolType:i,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function Ht(t,e,n,r,o,i,s){return{type:"rect",x:t,y:e,w:n,h:r,style:o,datum:i,group:s}}function Xt(t,e,n,r,o,i,s){const a={type:"heatcell",x:t,y:e,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Gt(t,e,n,r){return"function"==typeof e.style?e.style(r||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,r)}function Vt(t,e,n,r){if(!t.scales)return null;const o=[],i=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(o.push([l,c]),i.push([l,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:Gt(t,r,n,e[0]),datum:e,group:n,interactive:r.interactive}}function qt(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const r of t)r.perSeries?e.push(r):n.push(r);return{perSeries:e,aggregate:n}}function Ut(t,e,n){const r=[];for(const o of n){const n=Vt(t,e,"__ribbon_aggregate",o);n&&r.push(n)}return r}function Kt(t,e,n,r){const o=[];for(const i of r){const r=Vt(t,e,n,i);r&&o.push(r)}return o}function Qt(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const r of e){if("band"!==r.kind)continue;const e=r.getTop(t),o=r.getBottom(t);Number.isFinite(o)&&Number.isFinite(e)&&n.push({y0:o,y1:e})}return 0===n.length?t:{...t,band:n[0],bands:n}}function Zt(t,e,n,r){if(!t.config.pointStyle)return;const o=r??t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const i of r.data){let r=t.config.pointStyle(i);!r.fill&&e&&(r={...r,fill:e});const s=r.r??3,a=t.getPointId?t.getPointId(i)+"":void 0,l=Bt(i,t.scales,t.getX,o,s,r,a);l&&n.push(l)}}}var Jt={topOpacity:.8,bottomOpacity:.05};function te(t){if(t)return!0===t?Jt:"colorStops"in t?t:{topOpacity:t.topOpacity??Jt.topOpacity,bottomOpacity:t.bottomOpacity??Jt.bottomOpacity}}import{symbol as ee,symbolCircle as ne,symbolCross as re,symbolDiamond as oe,symbolSquare as ie,symbolStar as se,symbolTriangle as ae,symbolWye as le}from"d3-shape";var ce={circle:ne,square:ie,triangle:ae,diamond:oe,star:se,cross:re,wye:le},ue=["circle","triangle","diamond","star","square","chevron","cross","wye"];function he(t,e,n){if(n)return n;const r=t??"circle";return"chevron"===r?function(t){const e=1.5*de(t),n=.92*e;return`M0,${-e}L${n},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-n},${(.78*e).toFixed(3)}Z`}(e):ee(ce[r]??ne,Math.max(1,e))()??""}function de(t){return Math.sqrt(Math.max(1,t)/Math.PI)}var fe=new Map;function ye(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){const r=Math.max(1,Math.floor(t.config.heatmapXBins??20)),o=Math.max(1,Math.floor(t.config.heatmapYBins??20)),i=t.config.heatmapAggregation??"count",s=q(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,l]=t.scales.x.domain(),[c,u]=t.scales.y.domain(),h=(l-a||1)/r,d=(u-c||1)/o,f=r*o;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;e.length>n;n++){const i=e[n],l=t.getX(i),u=t.getY(i);if(!isFinite(l)||!isFinite(u))continue;const f=Math.min(Math.floor((l-a)/h),r-1),g=Math.min(Math.floor((u-c)/d),o-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const x=s(i);p[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===y[t])continue;let e;switch(i){case"sum":e=p[t];break;case"mean":e=p[t]/y[t];break;default:e=y[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,v=n.width/r,b=n.height/o,k=t.config.showValues,w=t.config.heatmapValueFormat,A=[];for(let t=0;o>t;t++){const e=t*r;for(let n=0;r>n;n++){const r=e+n;if(0===y[r])continue;let s;switch(i){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const l=(s-g)/x;A.push(Xt(n*v,(o-1-t)*b,v,b,`rgb(${220-(180*l+.5)|0},${220-(100*l+.5)|0},${255-(50*l+.5)|0})`,{xi:n,yi:t,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:c+(t+.5)*d,agg:i},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(t,e,n);if(0===e.length)return[];const r=q(t.config.valueAccessor,"value"),o=U(t.config.xAccessor,"x"),i=U(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],r=o(n),u=i(n);l[t]=r,c[t]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(t=>"number"==typeof t&&!isNaN(t)),p=f.every(t=>"number"==typeof t&&!isNaN(t));if(y){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(p){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),v=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(l[t]),i=a.get(c[t]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=v.get(d);let y;void 0!==f?y=f:(y=b++,v.set(d,y)),g[y]=d,m[y]=h,x[y]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in xt?t:"blues";let n=fe.get(e);if(n)return n;n=Array(256);const r=(o=e)&&xt[o]||st;var o;for(let t=0;256>t;t++)n[t]=r(t/255);return fe.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/h,P=t.config.showValues,C=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const n=g[t],r=n%u;T.push(Xt(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((e-k)*S+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return T}function pe(t,e,n,r,o){const i=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/r)*r;let c=i.get(l);if(c||(c={start:l,end:l+r,total:0,categories:new Map},i.set(l,c)),c.total+=a,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return i}function ge(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:r,warned:o}=t;me(r)&&0===n.length&&xe(o,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(t=>null==t.datum)&&xe(o,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function me(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(me))}function xe(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function ve(t,e,n,r){const o=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),i="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:i,message:`Semiotic ${t} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function be(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function ke(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,r=be(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=q(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=r(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e+o:e},getBottom:t=>{const e=r(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e-o:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:be(t.y1Accessor,"y1"),getBottom:be(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as we,scaleLog as Ae,scaleSymlog as Se,scaleTime as _e}from"d3-scale";function Me(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Pe(t,e,n){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return Ae().domain(t).range(n).clamp(!0)}return"symlog"===t?Se().domain(e).range(n):"time"===t?_e().domain([new Date(e[0]),new Date(e[1])]).range(n):we().domain(e).range(n)}function Ce(t,e,n,r){const o=t.push(e);return n&&n.push(r),o}var Te={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Le(t,e){const n={...t};for(const t of e)n[Te[t]]++;return n}function Ne(t,e,n){const r=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:r,revisions:Le(n,r)}}var De=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Ne({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(t,e){const n=Ne(t,e,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},Ee=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Re=["scene-style","data-paint","accessibility","evidence"],Ie=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),ze=class{constructor(){this.tracker=new De}get last(){return this.tracker.last}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Ee)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Re):this.recordNoop("restyle")}recordConfig(t,e,n){return this.tracker.record({kind:"config",keys:t},e?function(t,e){const n=new Set(["layout","scene-geometry","data-paint","overlay","accessibility","evidence"]);return e&&n.add("domain"),t.some(t=>Ie.has(t))&&n.add("scene-style"),n}(t,n):[])}};import{quadtree as $e}from"d3-quadtree";var We=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let n=0,r=0;for(const t of e)"point"===t.type&&(n++,t.r>r&&(r=t.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const t of e)"point"===t.type&&(o[i++]=t);this.tree=$e().x(t=>t.x).y(t=>t.y).addAll(o)}},Fe=class t{constructor(t){if(this.xExtent=new G,this.yExtent=new G,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new ze,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new We,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let l=!1;const c=o??(()=>{const t=new Map;for(let e=0;n.length>e;e++)t.set(n[e],e);return t})();for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0,a=!1;for(const n of e){const e=c.get(n);if(null==e)continue;a=!0;const s=r.get(e);if(null==s)continue;const l=zt(t,s,i);l>o&&(o=l)}a&&(l=$t(n,o,s)||l);continue}const e=c.get(n.datum);if(null==e)continue;const o=r.get(e);l=$t(n,null==o?0:zt(t,o,i),s,a)||l}return l}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),n),this._stylePaintPending=!1,this.config=t,this.buffer=new X(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=q(t.timeAccessor||t.xAccessor,"time"),this.getY=q(t.valueAccessor||t.yAccessor,"value")):(this.getX=q(t.xAccessor,"x"),this.getY=q(t.yAccessor,"y")),this.getGroup=K(t.groupAccessor),this.getCategory=K(t.categoryAccessor),this.getSize=t.sizeAccessor?q(t.sizeAccessor,"size"):void 0,this.getColor=K(t.colorAccessor),this.getSymbol=K(t.symbolAccessor),this.getY0=t.y0Accessor?q(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=ke(t),this.getPointId=K(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?q(t.openAccessor,"open"):void 0,this.getHigh=q(t.highAccessor,"high"),this.getLow=q(t.lowAccessor,"low"),this.getClose=n?q(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new X(t.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(t,e){const n=new X(t.capacity);return t.forEach(()=>n.push(e)),n}(this.buffer,Mt())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),r=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),r=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=Mt();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?q(this.config.timeAccessor||this.config.xAccessor,"time"):q(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(e):e[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(Z(r));if(this.xIsDate=o||i,i){const t="string"==typeof n?n:void 0;this.getX=t?e=>J(e[t]):t=>J(n(t))}}o=this.timestampBuffer,(r=t.totalSize||t.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),o&&r>o.capacity&&o.resize(r));for(const n of t.inserts)Ce(this.buffer,n,this.timestampBuffer,e),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=Ce(this.buffer,n,this.timestampBuffer,e);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}var n,r,o;return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:n}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=Me(this.xExtent.extent,e.xExtent),l=Me(s,e.yExtent);const c=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!c&&n.size>0){const t=function(t){const{config:e,groups:n,getX:r,getY:o}=t,i="exact"===e.axisExtent;if(e.normalize){const n=[0,i?1:1+e.extentPadding];return{yDomain:n,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:n}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,l=new Set;let c=0;const u=new Map,h=new Map;for(const t of n){const e=new Map;let n=0;for(const i of t.data){const t=r(i),s=o(i);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),l.add(t),n+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>c&&(c=a)}a.set(t.key,e),h.set(t.key,n)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let y,p;if("input"===d)y=n.map(t=>t.key);else if("insideOut"===d){const t=[...n].map(t=>t.key).sort((t,e)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(t,e)}),e=[],r=[];let o=0,i=0;for(const n of t)i>o?(e.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);y=[...r.reverse(),...e]}else y="asc"===d?n.map(t=>t.key).sort((t,e)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(t,e)}):"desc"===d?n.map(t=>t.key).sort((t,e)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(t,e)}):n.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),n=Yt(t,y,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let r=1/0,o=-1/0;for(const e of t){const t=n.get(e)??0,i=u.get(e)??0;r>t&&(r=t),t+i>o&&(o=t+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,c=i?0:s>0?s*e.extentPadding:1;p=[r-c,o+c]}else if("diverging"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),[n,r]=function(t,e,n){let r=0,o=0;for(const i of t){let t=0,s=0;for(const r of e){const e=n(r,i)||0;0>e?s+=e:t+=e}r>s&&(r=s),t>o&&(o=t)}return[r,o]}(t,y,(t,e)=>a.get(t)?.get(e)||0),o=r-n,s=i?0:o>0?o*e.extentPadding:1;p=[n-s,r+s]}else p=[0,c+(i?0:c>0?c*e.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:e,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!c&&n.size>0?l=function(t,e,n,r,o,i,s){const[,a]=function(t,e,n,r,o){const i=pe(t,e,n,r,o);if(0===i.size)return[0,0];let s=0;for(const t of i.values())t.total>s&&(s=t.total);return[0,s]}(t,e,n,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!c&&n.size>0?l=function(t,e,n,r){const[o,i]=function(t,e){let n=0,r=0,o=0;for(const i of t){const t=e(i);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(t,e),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,e.extentPadding,h):c||l[0]===1/0||(l=function(t,e,n){if(!n.length)return t;let[r,o]=t;for(const t of e)for(const e of n){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(l,i,this.resolvedRibbons),l=function(t,e){const n=t[1]-t[0],r=e.exactMode?0:n>0?n*e.extentPadding:1,o=[null!=e.userMin?t[0]:t[0]-r,null!=e.userMax?t[1]:t[1]+r];return"log"!==e.yScaleType||o[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(o[0]=e.dataYDomain[0]/(1+e.extentPadding)),o}(l,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));l=function(t,e,n){if(!e||n)return t;const r=e[0],o=e[1];return null==r&&null==o?t:[null!=r?r:t[0],null!=o?o:t[1]]}(l,e.yExtent,!!c),({xDomain:a,yDomain:l}=function(t,e,n){let r=t,o=e;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const t=Date.now();r=[t-864e5,t]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,l,e.xScaleType)),this.scales=function(t){const{config:e,layout:n,xDomain:r,yDomain:o}=t,i="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:we().domain(r).range(t),y:Pe(e.yScaleType,o,[n.height-s,s])}}const t="down"===e.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Pe(e.yScaleType,o,[s,n.width-s]),y:we().domain(r).range(t)}}var a;return{x:Pe(e.xScaleType,r,[s,n.width-s]),y:Pe(e.yScaleType,o,[n.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const r of t.path)r[0]*=e,r[1]*=n;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=n;for(const r of t.bottomPath)r[0]*=e,r[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":case"glyph":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Pe,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,o,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const o={data:e,scales:r,dimensions:{width:t.width,height:t.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??kt},resolveColor:(t,e)=>{const r=this.resolveGroupColor(t);if(r)return r;const o=this.resolveLineStyle(t,e);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,r=ve("xy",t,e,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{n.onLayoutError?.(r)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return ge({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const o={scales:r,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(t,e){const n=t.groupData(e),r=[],o=t.config.annotations?.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:i}=qt(t.ribbons);if(i.length>0&&r.push(...Ut(t,e,i)),o.length>0)for(const e of n)r.push(...Kt(t,e.data,e.key,o))}for(const e of n){const n=t.resolveLineStyle(e.key,e.data[0]),i=Ft(e.data,t.scales,t.getX,t.getY,n,e.key);o&&o.length>0&&(i.colorThresholds=o),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),r.push(i)}return Zt(t,n,r),r}(o,e);case"area":return function(t,e){const n=t.groupData(e),r=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:i}=qt(t.ribbons);if(i.length>0&&r.push(...Ut(t,e,i)),o.length>0)for(const e of n)r.push(...Kt(t,e.data,e.key,o))}const o=t.scales.y.domain()[0],i=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=Ot(e.data,t.scales,t.getX,t.getY,o,n,e.key,i),a=te(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),r.push(s)}return Zt(t,n,r),r}(o,e);case"mixed":return function(t,e){const n=t.groupData(e),r=[],o=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:i}=qt(t.ribbons);if(i.length>0&&r.push(...Ut(t,e,i)),o.length>0)for(const e of n)r.push(...Kt(t,e.data,e.key,o))}const i=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=Ot(e.data,t.scales,t.getX,t.getY,i,n,e.key,s),a=te(t.config.gradientFill);a&&(o.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Ft(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return Zt(t,n,r),r}(o,e);case"stackedarea":return function(t,e){const n=t.groupData(e),r=t.config.stackOrder??"key",o=()=>n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const e=new Map;for(const r of n){let n=0;for(const e of r.data){const r=t.getX(e),o=t.getY(e);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}e.set(r.key,n)}const o=(t,e)=>e>t?-1:t>e?1:0;if("asc"===r)n.sort((t,n)=>{const r=(e.get(t.key)??0)-(e.get(n.key)??0);return 0!==r?r:o(t.key,n.key)});else if("desc"===r)n.sort((t,n)=>{const r=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==r?r:o(t.key,n.key)});else{const t=[...n].sort((t,n)=>{const r=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==r?r:o(t.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of t)a>s?(r.push(n),s+=e.get(n.key)??0):(i.push(n),a+=e.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();const i=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:l}=function(t,e,n,r,o,i,s,a="zero"){const l=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&l.add(e)}const c=Array.from(l).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&t.set(e,(t.get(e)||0)+i)}u.set(e.key,t)}let h;if(i){h=new Map;for(const e of c){let n=0;for(const r of t)n+=u.get(r.key)?.get(e)||0;h.set(e,n||1)}}const d=Yt(c,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!i,y=[],p=new Map,g=new Map,m=new Map,x=new Map;for(const t of c)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const n of t){const t=u.get(n.key),r=new Map;let a=[],l=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(t.curve=s),y.push(t)}a=[],l=[]};for(const n of c){const o=t.has(n);let s,c,u=o?t.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),c=s+u,m.set(n,c)):(s=x.get(n),c=s+u,x.set(n,c)):(s=g.get(n),c=s+u,g.set(n,c));const y=e.x(n);l.push([y,e.y(s)]),a.push([y,e.y(c)]),r.set(n,c)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,i,s),c=a;if(t.config.pointStyle){const e=new WeakMap;for(const r of n){const n=l.get(r.key);if(n)for(const o of r.data){const r=t.getX(o),i=t.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||e.set(o,n.get(r))}}const r=n=>e.get(n)??t.getY(n);Zt(t,n,c,r)}return c}(o,e);case"scatter":case"bubble":return function(t,e){const n=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let i=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const r of n)t>r&&(t=r),r>e&&(e=r);i=n=>t===e?(o[0]+o[1])/2:o[0]+(n-t)/(e-t)*(o[1]-o[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",l=t.getSymbol,c=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=c?.[t];if(e)return e;let n=u.get(t);return n||(n=ue[h%ue.length],h++,u.set(t,n)),n};for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:a,opacity:.8},c=e.r||r;if(i&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(c=i(e))}if(s&&t.getColor&&!e.fill){const n=t.getColor(o);n&&s.has(n)&&(e={...e,fill:s.get(n)})}const u=t.getPointId?t.getPointId(o)+"":void 0;if(l){const r=d(l(o)+""),i=jt(o,t.scales,t.getX,t.getY,Math.PI*c*c,r,e,u);i&&n.push(i)}else{const r=Bt(o,t.scales,t.getX,t.getY,c,e,u);r&&n.push(r)}}return n}(o,e);case"heatmap":return ye(o,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const n=pe(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const o=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(o),s=Array.from(e).filter(t=>!i.has(t)).sort(),a=o.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:l,order:r})}const o=[],i=t.scales,[s,a]=i.x.domain(),l=t.config.barStyle,c=t.config.themeSemantic?.primary,u=l?.gap,h="number"!=typeof u||0>u?1:u,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.opacity);for(const e of n.values()){const n=Math.max(e.start,s),u=Math.min(e.end,a);if(n>=u)continue;const f=i.x(n),y=i.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,x=Math.max(p-g,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const s of r){const r=e.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(Ht(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||l?.fill||c||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:r},s)),n+=r}}else{const t=i.y(0),n=i.y(e.total);o.push(Ht(m,Math.min(t,n),x,Math.abs(t-n),{fill:l?.fill||c||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of n.values())f.add(t.start),f.add(t.end);return{nodes:o,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(o,e);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const n=[],r=t.config.swarmStyle||{},o=r.radius??3,i=r.fill??t.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,l=r.strokeWidth;for(const r of e){const e=t.getX(r),c=t.getY(r);if(null==c||Number.isNaN(c))continue;const u=t.scales.x(e),h=t.scales.y(c);let d=i;if(t.getCategory){const e=t.getCategory(r);d=t.config.barColors?.[e]||d}const{r:f,...y}=t.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:l,...y},datum:r};t.getPointId&&(p.pointId=t.getPointId(r)+""),n.push(p)}return n}(o,e);case"waterfall":return function(t,e,n){const r=[],o=t.scales,i=t.config.waterfallStyle,s=e.filter(e=>{const n=t.getY(e),r=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??t.config.themeSemantic?.success??"#28a745",l=i?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",c=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=i?.opacity;let f=0;for(let e=0;s.length>e;e++){const y=s[e],p=t.getX(y),g=t.getY(y),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-p:e>0?p-t.getX(s[e-1]):0;const v=o.x(p),b=0!==x?o.x(p+x):v+n.width/10,k=Math.min(v,b)+c/2,w=Math.max(v,b)-c/2-k;if(0>=w){f=m;continue}const A=o.y(f),S=o.y(m),_=Math.min(A,S),M=Math.abs(A-S),P={fill:0>g?l:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),r.push(Ht(k,_,w,M,P,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(o,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const n=t.config.candlestickRangeMode??!1;if(!(n||t.getOpen&&t.getClose))return[];const r=[],o=t.config.candlestickStyle||{},i=o.rangeColor||"#6366f1",s=n?i:o.upColor||"#28a745",a=n?i:o.downColor||"#dc3545",l=n?i:o.wickColor||"#333",c=o.wickWidth||(n?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let e=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(t.scales.x(u[n])-t.scales.x(u[n-1]));r>0&&e>r&&(e=r)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const o of e){const e=t.getX(o);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(o),u=t.getLow(o);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const d=n?i:t.getOpen(o),f=n?u:t.getClose(o);if(!n&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const y=f>=d,p={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(i),lowY:t.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:l,wickWidth:c,isUp:y,datum:o};n&&(p.isRange=!0),r.push(p)}return r}(o,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,n,r){const o=t.boundsStyle;return"function"==typeof o?o(n||{},e):o&&"object"==typeof o?o:{fill:r(e,n).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Rt(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=It(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,n,r=It(n)){const o=n.length;if(o>1)for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let s=!1;for(let n=0;e.length>n;n++){const a=r.get(e[n]);null!=a?(i[n]=Rt(t,a,o),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const s=Array(i);let a=!1;for(let n=0;e.length>n;n++){const i=r.get(e[n]);null!=i?(s[n]=Rt(t,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of e){const e=r.get(n);if(null!=e){const n=Rt(t,e,o);s>n&&(s=n)}}if(1>s){const t=Array(i);t.fill(s),n._decayOpacities=t}}continue}const e=r.get(n.datum);if(null==e)continue;const i=Rt(t,e,o);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&function(t,e,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const r=t.duration??500,o=e.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(Mt())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,r){n.clear(),r.clear();for(let o=0;e.length>o;o++){const i=e[o],s=Wt(t,i,o);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(s,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(s,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const n=this.scene[e],r=Wt(this.transitionContext,n,e);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:t,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(t=>[t[0],t[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{topPath:n.topPath.map(t=>[t[0],t[1]]),bottomPath:n.bottomPath.map(t=>[t[0],t[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,r,o){if(0===r.size&&0===o.size)return n;const i=e.duration??300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let s=!1;const a=new Set,l=new Set;for(let e=0;n.scene.length>e;e++){const i=n.scene[e],c=Wt(t,i,e);if(!c)continue;if(i._transitionKey=c,"line"===i.type||"area"===i.type){const t=o.get(c);if(t){if(l.add(c),"line"===i.type&&t.path&&t.path.length===i.path.length){i._targetPath=i.path.map(t=>[t[0],t[1]]),i._prevPath=t.path;for(let e=0;i.path.length>e;e++)i.path[e]=[t.path[e][0],t.path[e][1]];s=!0}else if("area"===i.type&&t.topPath&&t.bottomPath&&t.topPath.length===i.topPath.length&&t.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(t=>[t[0],t[1]]),i._targetBottomPath=i.bottomPath.map(t=>[t[0],t[1]]),i._prevTopPath=t.topPath,i._prevBottomPath=t.bottomPath;for(let e=0;i.topPath.length>e;e++)i.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;i.bottomPath.length>e;e++)i.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];s=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=t.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},s=!0;continue}const u=r.get(c);if("point"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("glyph"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("rect"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("heatcell"===i.type)if(u){a.add(c);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,s=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},s=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){a.add(c);const t={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(i._targetX=t.x,i._targetOpenY=t.openY,i._targetCloseY=t.closeY,i._targetHighY=t.highY,i._targetLowY=t.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,s=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},s=!0}for(const[t,e]of o)if(!l.has(t))if(t.startsWith("l:")&&e.path){const r={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),s=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),s=!0}for(const[t,e]of r)if(!a.has(t)){if(t.startsWith("p:"))n.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)n.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))n.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const r=e.openY??e.y;n.exitNodes.push({type:"candlestick",x:e.x,openY:r,closeY:e.closeY??r,highY:e.highY??r,lowY:e.lowY??r,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}s=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),s&&(n.activeTransition={startTime:Mt(),duration:i}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,r){if(!n.activeTransition)return!1;const o=St(t,n.activeTransition),i=At(o,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style.opacity=_t(n?n.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==t._targetR&&void 0!==n.r&&(t.r=_t(n.r,t._targetR,i))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style.opacity=_t(n?n.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==t._targetR&&void 0!==n.r&&(t.size=_t(n.r,t._targetR,i))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style.opacity=_t(n?n.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==n.w&&(t.w=_t(n.w,t._targetW,i)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,i))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style={...t.style||{},opacity:_t(n?n.opacity??1:0,t._targetOpacity,i)}}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),t.y=_t(n.y,t._targetY,i),void 0!==n.w&&(t.w=_t(n.w,t._targetW,i)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,i))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0;t.style={...t.style||{},opacity:_t(n?n.opacity??1:0,t._targetOpacity,i)}}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,i),void 0!==n.openY&&(t.openY=_t(n.openY,t._targetOpenY,i)),void 0!==n.closeY&&(t.closeY=_t(n.closeY,t._targetCloseY,i)),void 0!==n.highY&&(t.highY=_t(n.highY,t._targetHighY,i)),void 0!==n.lowY&&(t.lowY=_t(n.lowY,t._targetLowY,i))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:_t(t._startOpacity??0,t._targetOpacity,i)}),void 0!==t._introClipFraction&&(t._introClipFraction=i);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=_t(e[r][0],n[r][0],i),t.path[r][1]=_t(e[r][1],n[r][1],i)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:_t(t._startOpacity??0,t._targetOpacity,i)}),void 0!==t._introClipFraction&&(t._introClipFraction=i);const e=t._prevTopPath,n=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=_t(e[n][0],r[n][0],i),t.topPath[n][1]=_t(e[n][1],r[n][1],i);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=_t(n[e][0],o[e][0],i),t.bottomPath[e][1]=_t(n[e][1],o[e][1],i)}}if(o>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:n}=function(t,e,n,r){if(r&&r.version===n&&r.group===e&&r.data===t)return{result:r.result,cache:r};let o;if(e){const n=new Map;for(const r of t){const t=e(r);n.has(t)||n.set(t,[]),n.get(t).push(r)}o=Array.from(n.entries()).map(([t,e])=>({key:t,data:e}))}else o=[{key:"_default",data:t}];return{result:o,cache:{version:n,group:e,data:t,result:o}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,e}resolveColorMap(t){const{map:e,cache:n}=function(t,e,n,r,o){if(o&&o.version===r)return{map:o.map,cache:o};const i=new Set;if(e)for(const n of t){const t=e(n);t&&i.add(t)}const s=Array.from(i).sort(),a=s.join("\0");if(o&&o.key===a){const t={...o,version:r};return{map:t.map,cache:t}}const l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||kt,c=new Map;for(let t=0;s.length>t;t++)c.set(s[t],l[t%l.length]);return{map:c,cache:{key:a,map:c,version:r}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,e}resolveLineStyle(t,e){return function(t,e,n,r){const o=t.lineStyle;if("function"==typeof o){const t=o(n||{},e);if(t&&!t.stroke&&e){const n=r(e);if(n)return{...t,stroke:n}}return t}const i=t.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(e)||i||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,n,r){if(t.areaStyle){const o=t.areaStyle(n||{});if(o&&!o.fill&&e){const t=r(e);if(t)return{...o,fill:t,stroke:o.stroke||t}}return o}const o=t.lineStyle;if("function"==typeof o){const t=o(n||{},e);if(t&&!t.fill&&e){const n=r(e);if(n)return{...t,fill:n,stroke:t.stroke||n}}return t}const i=t.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(e)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:n,groupColorCounter:r}=function(t){const{group:e,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=t;let{groupColorCounter:s}=t;if(n){const t=n.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=r.get(e);if(a)return{color:a,groupColorCounter:s};const l=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||kt;if(0===l.length)return{color:null,groupColorCounter:s};const c=l[s%l.length];if(s++,r.set(e,c),r.size>o){const t=r.keys().next().value;void 0!==t&&r.delete(t)}return{color:c,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getLastUpdateResult(){return this.updateResults.last}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=tt(t),n=this.getPointId,r=t=>e.has(n(t));!function(t,e,n){if(!e||0===e.size)return;const r=new Set;if(t.forEach((t,e)=>{n(t)&&r.add(e)}),0===r.size)return;const o=e.toArray();e.clear();for(let t=0;o.length>t;t++)r.has(t)||e.push(o[t])}(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const t of o)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Mt(),this.updateResults.recordData("remove",o.length),o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=tt(t),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(r(t))&&o.add(e)});const i=this.buffer.update(t=>n.has(r(t)),e);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const t of i)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Mt(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){const n=this._customRestyle;if(n)for(const r of t){const t=this._baseStyles.get(r)??r.style??{},o=n(r,e);r.style=o?{...t,...o}:t}}consumeStylePaintPending(){const t=this._stylePaintPending;return this._stylePaintPending=!1,t}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this._stylePaintPending=!0,this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},n=Object.keys(t).filter(n=>t[n]!==e[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const i="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(i||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=i||!V(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),l=i||!V(n,s);(a||l)&&(t?(this.getX=q(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=q(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=q(this.config.xAccessor,"x"),this.getY=q(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=ke(this.config)),r=!0,o=!0)}if("groupAccessor"in t&&!V(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?K(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in t&&!V(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?K(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in t&&!V(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?q(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in t&&!V(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?K(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in t&&!V(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?K(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in t&&!V(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?q(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in t&&!V(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=ke(this.config),r=!0,o=!0),"pointIdAccessor"in t&&!V(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?K(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in t&&!V(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!V(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!V(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!V(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?q(this.config.openAccessor,"open"):void 0,this.getHigh=q(this.config.highAccessor,"high"),this.getLow=q(this.config.lowAccessor,"low"),this.getClose=e?q(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,r=!0,o=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const o of n)if(t[o]!==e[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,r,o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Fe.GROUP_COLOR_MAP_CAP=1e3;var Oe=Fe,Ye={sceneGeometry:0,layout:0,domain:0},Be="production"!==process.env.NODE_ENV,je={revisions:Ye,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},He=class{constructor(){this.lastConsumed=Ye,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(t,e){if(!Be)return je;const n=function(t){const{domain:e,layout:n,sceneGeometry:r}=t.revisions;return{domain:e,layout:n,sceneGeometry:r}}(t),r=function(t){return`${t.sceneGeometry}|${t.layout}|${t.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:t.changed.has("scene-geometry")||t.changed.has("layout")||t.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!e&&o&&this.lastUnconsumedWarning!==r}}afterCompute(t,e,n){if(Be){if(e&&t.wasUnconsumed&&(this.lastConsumed=t.revisions),t.warnUnconsumed&&!e)return console.warn(`[semiotic] StreamXYFrame observed scene-affecting revisions without a scene rebuild: ${t.signature}.`),void(this.lastUnconsumedWarning=t.signature);e&&t.sawSignals&&!t.wasUnconsumed&&!n&&this.lastDuplicateWarning!==t.signature?(console.warn(`[semiotic] StreamXYFrame performed scene rebuild with unchanged scene revisions: ${t.signature}.`),this.lastDuplicateWarning=t.signature):e&&!t.sawSignals&&(this.lastDuplicateWarning="")}}};import*as Xe from"react";function Ge(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:Xe.createElement(Xe.Fragment,null,...e)}import*as Ve from"react";import{jsx as qe}from"react/jsx-runtime";var Ue=Ve.createContext(null);function Ke({value:t,children:e}){return qe(Ue.Provider,{value:t,children:e})}function Qe(t,e){return null!=t?qe(Ke,{value:e,children:t}):t}import{useEffect as Ze,useRef as Je}from"react";function tn(t,e,n,r){Ze(()=>{t.current?.updateConfig(e),n.current=!0,r()},[e,r,t,n])}function en(t,e,n,r){const o=Je(null);Ze(()=>{const i=t.current;if(!i)return;const s=e??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[e,r,t,n])}function nn(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function rn(t,e=30){return Math.max((t??4)+5,12,e)}function on(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function sn(t,e){const n=on(t);if(!n)return!1;const r=on(e);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function an(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}var ln=[40,40],cn=[.5,.5];function un(t,e){const[n,r]=t.viewBox??ln,[o,i]=t.anchor??cn,s=r>0?r:1,a=Math.max(0,e)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-o*l,offsetY:-i*c}}function hn(t,e,n,r){if("none"!==t)return"color"===t||null==t?e??r:"accent"===t?n:t}var dn=null;function fn(t){if("undefined"==typeof Path2D)return null;dn||(dn=new Map);const e=dn.get(t);if(e)return e;const n=new Path2D(t);return dn.size>1024&&dn.clear(),dn.set(t,n),n}function yn(t,e,n=0,r="horizontal"){const[o,i]=t.viewBox??ln,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function pn(t,e){const n=un(t,e);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function gn(t,e,n,r,o,i=t=>t){for(const s of e.parts){const e=fn(s.d);if(!e)continue;const a=s.opacity??1,l=t.globalAlpha;1!==a&&(t.globalAlpha=l*a);const c=o?"none"===s.fill?void 0:o:hn(s.fill,n,r);c&&(t.fillStyle=i(c),t.fill(e));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:hn(s.stroke??"none",n,r);u&&(t.strokeStyle=i(u),t.lineWidth=s.strokeWidth??1,t.lineCap=s.strokeLinecap??"butt",t.lineJoin=s.strokeLinejoin??"miter",t.stroke(e)),1!==a&&(t.globalAlpha=l)}}function mn(t,e,n,r,o,i=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(r,o+5,12),c=e-l,u=e+l,h=n-l,d=n+l;let f=null,y=1/0;return t.visit((t,o,l,p,g)=>{if(o>u||c>p||l>d||h>g)return!0;if(!t.length){let o=t;do{const t=o.data,l=i(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);rn(a(t),r)>=u&&y>u&&(f=t,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}var xn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,vn=new WeakMap,bn=0,kn=!1,wn=null,An=null;function Sn(t,e){if(!e)return e;const n=xn.exec(e);if(!n)return e;const r=t.canvas;if(!r)return n[2]?.trim()||e;!function(){if(kn)return;if("undefined"==typeof window||"undefined"==typeof document)return;kn=!0;const t=()=>{bn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(t).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{wn=window.matchMedia("(prefers-color-scheme: dark)"),An=t,"function"==typeof wn.addEventListener?wn.addEventListener("change",An):"function"==typeof wn.addListener&&wn.addListener(An)}catch{}}();let o=vn.get(r);o&&o.version===bn||(o={version:bn,map:new Map},vn.set(r,o));const i=o.map.get(e);if(void 0!==i)return i;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||e;return o.map.set(e,s),s}import{curveMonotoneX as _n,curveMonotoneY as Mn,curveCardinal as Pn,curveCatmullRom as Cn,curveStep as Tn,curveStepBefore as Ln,curveStepAfter as Nn,curveBasis as Dn,curveNatural as En}from"d3-shape";function Rn(t){switch(t){case"monotoneX":return _n;case"monotoneY":return Mn;case"cardinal":return Pn;case"catmullRom":return Cn;case"step":return Tn;case"stepBefore":return Ln;case"stepAfter":return Nn;case"basis":return Dn;case"natural":return En;default:return null}}function In(t,e,n){return null==e?n:"string"!=typeof e?e:Sn(t,e)||n}function zn(t,e,n,r,o,i,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const a=t.createLinearGradient(r,o,i,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),h=t.createLinearGradient(r,o,i,s),[d,f,y]=function(t,e){const n=t.fillStyle,r="#010203";try{t.fillStyle=r,t.fillStyle=e}catch{return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&e.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(t,n);return h.addColorStop(0,`rgba(${d},${f},${y},${c})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function $n(t,e,n,r,o,i){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const a=t.createLinearGradient(n,r,o,i);for(const t of s)a.addColorStop(t.offset,t.color);return a}import{line as Wn}from"d3-shape";var Fn=new WeakMap;function On(t,e){const n=Rn(e);if(!n)return t;const r=Fn.get(t);if(r)return r;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const r=[];let o=null;const i={moveTo(t,e){o=[t,e],r.push([t,e])},lineTo(t,e){o=[t,e],r.push([t,e])},bezierCurveTo(t,e,i,s,a,l){if(!o)return o=[a,l],void r.push([a,l]);const[c,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*c+3*d*d*h*t+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*e+3*d*h*h*s+h*h*h*l])}o=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,i){o=[n,i],r.push([n,i])}};return Wn().x(t=>t[0]).y(t=>t[1]).curve(e).context(i)(t),r}(t,n);return Fn.set(t,o),o}function Yn(t,e,n,r=30,o,i=0){let s=null;if(o){const t=mn(o,e,n,r,i);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const i of t){let t=null;switch(i.type){case"point":if(o)break;t=jn(i,e,n,r);break;case"symbol":t=Hn(i,e,n,r);break;case"glyph":t=Xn(i,e,n,r);break;case"line":t=Gn(i,e,n,r);break;case"rect":if(null==i.datum)break;t=qn(i,e,n);break;case"heatcell":t=Un(i,e,n);break;case"area":if(!1===i.interactive)break;t=Qn(i,e,n);break;case"candlestick":t=Kn(i,e,n)}t&&r>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Bn(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const r=Zn(t,e);if(0>r)return null;if(Math.abs(t[r][0]-e)>n)return null;let o=r,i=r;r>0&&t[r][0]>=e?(o=r-1,i=r):t.length-1>r&&(o=r,i=r+1);const[s,a]=t[o],[l,c]=t[i];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function jn(t,e,n,r=30){const o=e-t.x,i=n-t.y,s=Math.sqrt(o*o+i*i);return s>rn(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Hn(t,e,n,r=30){const o=e-t.x,i=n-t.y,s=Math.sqrt(o*o+i*i);return s>rn(de(t.size),r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Xn(t,e,n,r=30){if(null==t.datum)return null;const o=pn(t.glyph,t.size),i=t.x+o.centerDx,s=t.y+o.centerDy,a=e-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>rn(o.radius,r)?null:{node:t,datum:t.datum,x:i,y:s,distance:c}}function Gn(t,e,n,r=30){if(0===t.path.length)return null;const o=Zn(t.path,e);if(0>o)return null;const[i,s]=t.path[o];let a;if(t.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(t.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=t.path[o],[a,l]=t.path[o+1],c=Vn(e,n,i,s,a,l);r>c&&(r=c)}a=r}else{const t=e-i,r=n-s;a=Math.sqrt(t*t+r*r)}const l=t.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,r)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:s,distance:a}}function Vn(t,e,n,r,o,i){const s=o-n,a=i-r,l=s*s+a*a;if(0===l)return Math.sqrt((t-n)**2+(e-r)**2);let c=((t-n)*s+(e-r)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((t-(n+c*s))**2+(e-(r+c*a))**2)}function qn(t,e,n){const r=nn(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Un(t,e,n){const r=nn(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Kn(t,e,n){const r=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,i=e-t.x,s=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function Qn(t,e,n){if(0===t.topPath.length)return null;const r=Zn(t.topPath,e);if(0>r)return null;const[o,i]=t.topPath[r],s=e-o,a=n-i,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:o,y:i,distance:l}}function Zn(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o][0]?n=o+1:r=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Jn(t){const e=new Map;for(const n of t){const t=n.group??"_default";let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}for(const t of e.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const n=Array.from(e.keys()).sort((t,n)=>{const r=e.get(t),o=e.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(e.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const o=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=r[t].datum?.id;null!=e&&o.set(e+"",t)}return{flat:r,groups:n,byGroup:e,idToIdx:o}}function tr(t,e){if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function er(t,e,n){const{group:r,indexInGroup:o}=e,i=n.byGroup.get(r);switch(t){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?nr(n,n.groups[t+1],i[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?nr(n,n.groups[t-1],i[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function nr(t,e,n){const r=t.byGroup.get(e);let o=0,i=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);i>e&&(i=e,o=t)}return r[o]._flatIndex}function rr(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function or(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}import{useEffect as ir,useRef as sr}from"react";var ar={fresh:1,aging:.7,stale:.45,expired:.25},lr={alpha:1,band:"fresh",isStale:!1};function cr(t,e){if(!t||0>=e)return lr;const n=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},o=Ct(e,n,t.thresholds);return{alpha:{...ar,...t.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return e>n?{alpha:t.dimOpacity??.5,band:"stale",isStale:!0}:lr}function ur(t,e,n,r,o,i){const s=sr("fresh");ir(()=>{if(!t)return;const a=setInterval(()=>{const a=e.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=cr(t,l-a.lastIngestTime);c.band===s.current&&c.isStale===o||(s.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[t,o,r])}import{jsx as hr}from"react/jsx-runtime";function dr({isStale:t,position:e}){return hr("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===e?{top:4,left:4}:"bottom-left"===e?{bottom:4,left:4}:"bottom-right"===e?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"},children:t?"STALE":"LIVE"})}import{useMemo as fr,useRef as yr,useEffect as pr}from"react";import*as gr from"react";import{jsx as mr,jsxs as xr}from"react/jsx-runtime";var vr={fill:(t,e)=>mr("rect",{style:t,width:e,height:e}),line:(t,e)=>mr("line",{style:t,x1:0,y1:0,x2:e,y2:e})};function br(t,e,n,r,o){let i;return i="function"==typeof n?n(t):(0,vr[n])(r(t,e),o),i}function kr({swatchSize:t}){return mr("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function wr(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}var Ar=(t,e,n,r,o,i,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:f}=t,y=[];let p=0;const g=!(!e&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:x,labelGap:v,rowHeight:b}=u;return f.forEach((t,c)=>{const u=br(t,c,h,d,x),k=wr(t,r,o),w=o&&o.size>0&&o.has(t.label);y.push(xr("g",{transform:`translate(0,${p})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&c===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:g?e=>{l(a,c),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&mr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+v+2+7*t.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&mr(kr,{swatchSize:x}),mr("text",{y:x/2,x:x+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+c)),p+=b}),y};function Sr({config:t,orientation:e="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=t,a=s||(t=>Math.round(100*t)/100+""),l="grad-legend-"+gr.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),s=Math.max(0,(n-e)/2),c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(mr("stop",{offset:100*e+"%",stopColor:r(o[0]+e*(o[1]-o[0]))},t))}return xr("g",{"aria-label":i||"Gradient legend",children:[mr("defs",{children:mr("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&mr("text",{x:s+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),mr("rect",{x:s,y:0,width:e,height:t,fill:`url(#${l})`,rx:2}),mr("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),mr("text",{x:s+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(mr("stop",{offset:100*e+"%",stopColor:r(o[1]-e*(o[1]-o[0]))},t))}return xr("g",{"aria-label":i||"Gradient legend",children:[i&&mr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),mr("defs",{children:mr("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),mr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),mr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),mr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function _r(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:h}=t,d=function(t){const e=Math.max(1,t?.swatchSize??16),n=Math.max(e,t?.rowHeight??22);return{swatchSize:e,labelGap:Math.max(0,t?.labelGap??6),itemGap:Math.max(0,t?.itemGap??10),rowHeight:n,align:"left"===t?.align?"start":"right"===t?.align?"end":t?.align??"start",maxWidth:t?.maxWidth}}(h),[f,y]=gr.useState(0),[p,g]=gr.useState(0),m=gr.useCallback((t,e)=>{y(t),g(e)},[]),x="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{let h=24;const d=[];return t.forEach((t,f)=>{h+=5,d.push(mr("line",{stroke:"gray",x1:0,y1:h,x2:e,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,t.label&&(h+=16,d.push(mr("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),h+=8),d.push(mr("g",{className:"legend-item",transform:`translate(0,${h})`,children:Ar(t,n,r,o,i,s,a,f,l,c,u)},"legend-group-"+f)),h+=t.items.length*u.rowHeight+8}),d})({legendGroups:e||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:t,height:e,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:h})=>{let d=0;const f=[];t.forEach((t,e)=>{let y=0;t.label&&(y+=16);const p=((t,e,n,r,o,i,s,a,l,c,u,h)=>{const{type:d="fill",styleFn:f,items:y}=t,p=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:v,align:b}=u,k=!(!e&&!n),w="isolate"===c||void 0===c&&null!=o,A=y.map(t=>g+m+7*t.label.length),S=[];let _=0,M=0;A.forEach((t,e)=>{const n=0===M?t:M+x+t;h&&h>0&&M>0&&n>h?(S.push({start:_,end:e,width:M}),_=e,M=t):M=n}),y.length>0&&S.push({start:_,end:y.length,width:M}),S.forEach((t,c)=>{let u="center"===b?Math.max(0,((h??t.width)-t.width)/2):"end"===b?Math.max(0,(h??t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=y[h],b=br(t,h,d,f,g),S=wr(t,r,o),_=o&&o.size>0&&o.has(t.label);p.push(xr("g",{transform:`translate(${u},${c*v})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?_||!1:void 0,"aria-current":k&&!w&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;l(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:k?e=>{l(a,h),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&mr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*t.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,_&&mr(kr,{swatchSize:g}),mr("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+h)),u+=A[h]+x}});const P=Math.max(0,...S.map(t=>t.width)),C=S.length;return{items:p,offset:P,totalRows:C,totalHeight:C*v}})(t,r,o,i,s,a,l,e,c,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:t.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const o=t[r];o.label&&(g.push(mr("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),p+=16),g.push(mr("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,t[r+1]&&g.push(mr("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||e)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),mr("g",{children:g})})({legendGroups:e||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),v=!(!n&&!r);return xr("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&mr("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function Mr(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}import{jsx as Pr}from"react/jsx-runtime";function Cr(t){const{legend:e,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=t;if(!e)return null;const f="top"===i||"bottom"===i,y=!!a,p=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,x;return"left"===i?(m=Math.max(4,o.left-g-10),x=o.top):"top"===i?(m=o.left,x=y?32:8):"bottom"===i?(m=o.left,x=r-o.bottom+38):(m=n-o.right+10,x=o.top),Pr("g",{transform:`translate(${m}, ${x})`,children:(v=e,"object"==typeof v&&null!==v&&"gradient"in v?Pr(Sr,{config:e.gradient,orientation:f?"horizontal":"vertical",width:g}):Mr(e)?Pr(_r,{legendGroups:e.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):e)});var v}import{useMemo as Tr}from"react";import{bin as Lr}from"d3-array";function Nr(t){let e=1/0,n=-1/0;for(const r of t)e>r&&(e=r),r>n&&(n=r);return[e,n]}import{jsx as Dr,jsxs as Er}from"react/jsx-runtime";function Rr(t){return"string"==typeof t?{type:t}:t}function Ir({orient:t,config:e,values:n,scale:r,size:o,length:i}){const s=function(t){return{type:t.type,bins:t.bins??20,fill:t.fill??"#4e79a7",fillOpacity:t.fillOpacity??.5,stroke:t.stroke??"none",strokeWidth:t.strokeWidth??1}}(e),a="top"===t||"bottom"===t,l=Tr(()=>{if(0===n.length)return null;const e=r.domain(),l=o-8;if("boxplot"===s.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const r=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],i=e[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(e[0],r-1.5*s),whiskerHigh:Math.min(e[n-1],i+1.5*s)}}(n);if(!e)return null;const{q1:o,median:i,q3:c,whiskerLow:u,whiskerHigh:h}=e,d=Math.min(.5*l,20),f=(l-d)/2+4;if(a){const e=r(o),n=r(c),a=r(i),l=r(u),y=r(h),p="top"===t?-1:1,g=0;return Er("g",{"data-testid":"marginal-boxplot-"+t,children:[Dr("line",{x1:l,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:l,y1:g+p*f,x2:l,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("rect",{x:Math.min(e,n),y:"top"===t?g-f-d:g+f,width:Math.abs(n-e),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Dr("line",{x1:a,y1:"top"===t?g-f-d:g+f,x2:a,y2:"top"===t?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const e=r(o),n=r(c),a=r(i),l=r(u),y=r(h),p="left"===t?-1:1,g=0;return Er("g",{"data-testid":"marginal-boxplot-"+t,children:[Dr("line",{x1:g+p*(f+d/2),y1:l,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:g+p*f,y1:l,x2:g+p*(f+d),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),Dr("rect",{x:"left"===t?g-f-d:g+f,y:Math.min(e,n),width:d,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Dr("line",{x1:"left"===t?g-f-d:g+f,y1:a,x2:"left"===t?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const c=Lr().domain(e).thresholds(s.bins)(n);if(0===c.length)return null;const u=function(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}(c.map(t=>t.length));if(0===u)return null;if("histogram"===s.type)return Dr("g",{"data-testid":"marginal-histogram-"+t,children:c.map((e,n)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/u*l;if(a){const i=r(e.x0),a=r(e.x1)-r(e.x0);return Dr("rect",{x:i,y:"top"===t?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(e.x0),a=r(e.x1)-r(e.x0);return Dr("rect",{x:"left"===t?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const e=l/2+4,n=[];for(const o of c){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(l/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===t?-(e-i):e-i}`:`${"left"===t?-(e-i):e-i},${s}`)}for(let o=c.length-1;o>=0;o--){const i=c[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(l/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${h}`)}return Dr("g",{"data-testid":"marginal-violin-"+t,children:Dr("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const e=[];if(a){const n=0,o=null!=c[0].x0?r(c[0].x0):0;e.push(`M${o},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);e.push(`L${i},${"top"===t?-o-4:o+4}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;e.push(`L${s},${n}`),e.push("Z")}else{const n=0,o=null!=c[0].x0?r(c[0].x0):0;e.push(`M${n},${o}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);e.push(`L${"left"===t?-o-4:o+4},${i}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;e.push(`L${n},${s}`),e.push("Z")}return Dr("g",{"data-testid":"marginal-ridgeline-"+t,children:Dr("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,o,i,t,a,4]);return l?Dr("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:l}):null}import*as zr from"react";import{jsx as $r,jsxs as Wr}from"react/jsx-runtime";function Fr(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let s="";for(const t of o)s&&s.length+1+t.length>r?(i.push(s),s=t):s=s?`${s} ${t}`:t;return s&&i.push(s),i}function Or(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Yr(t,e,n,r){if(!t)return $r("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=t;if(!o&&!i)return $r("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,y=i?c?[i]:Fr(i,l):[],p=o?c?[o]:Fr(o,l):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push($r("foreignObject",{className:"annotation-note-html",x:"end"===d?g-l:"middle"===d?g-l/2:g,y:-16,width:l,height:Math.max(f,(y.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:Wr("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&$r("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&$r("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(x.push($r("text",{className:"annotation-note-title",fill:v,textAnchor:d,fontWeight:"bold",children:y.map((t,e)=>$r("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=y.length*f),p.length>0&&x.push($r("text",{className:"annotation-note-label",fill:v,textAnchor:d,y:m,children:p.map((t,e)=>$r("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let b=null;if((i||o)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(l,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=$r("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=$r("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),Wr("g",{className:"annotation-note",transform:`translate(${e},${n})`,children:[$r("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:x}),b]})}function Br(t,e,n,r,o){const i=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&i.push($r("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,r=e?.height||0;(t>0||r>0)&&i.push($r("rect",{width:t,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&i.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,s=o||0;if(void 0!==e?.x){const r=(e.x||0)-t;i.push($r("line",{x1:r,y1:(e.y1||0)-s,x2:r,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const r=(e.y||0)-s;i.push($r("line",{x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?i.push($r("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||i.push($r("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",r=e?.width??e?.height;void 0!==r&&i.push($r("path",{d:Or(t,r,e?.depth||30,void 0===e?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return $r("g",{className:"annotation-subject",children:i})}function jr(t,e,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=t-o,c=e-i;if(0!==s||0!==c){const t=Math.abs(s),e=Math.abs(c),u=n/2,h=r/2,d=t*h>e*u?u/t:h/e;a=o+s*d,l=i+c*d}}}else if("bracket"===o&&i){const t=i.width,e=i.height,n=i.depth||30;void 0!==t?(a=t/2,l=n):void 0!==e&&(a=n,l=e/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((t-a)**2+(e-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(e-l,t-a);if(i){const r=(a+t)/2,i=(l+e)/2,h=-(e-l)/c,d=(t-a)/c,f=(n?.curve??.25)*c,y=r+h*f,p=i+d*f;s.push($r("path",{className:"connector-curve",d:`M${a},${l}Q${y},${p} ${t},${e}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-l,y-a)}else s.push($r("line",{x1:a,y1:l,x2:t,y2:e,stroke:o},"connector-line"));if("arrow"===n?.end){const t=10,e=16/180*Math.PI;s.push($r("path",{d:`M${a},${l}L${a+t*Math.cos(u+e)},${l+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${l+t*Math.sin(u-e)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return $r("g",{className:"annotation-connector",children:s})}function Hr(t){const{x:e=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,v=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-x),null!=s&&(w=s-v);const A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const t=c.depth||30;w=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;k=t+(0>t?-5:5),w=c.height/2}return Wr("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${v})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&jr(k,w,l,h,A,c),!b.has("subject")&&Br(A,c,h,x,v),!b.has("note")&&Yr(a,k,w,h)]})}function Xr(t){const{noteData:e}=t,{screenCoordinates:n}=e,r="string"==typeof e.type?e.type:"label",o=e.eventListeners||e.events||{};if(e.coordinates&&n){const t=e.nx||n[0][0]+(e.dx??0),o=e.ny||n[0][1]+(e.dy??0),i=n.map((n,i)=>{const s=Object.assign({},e,{note:0===i?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:o});return $r(Hr,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return $r("g",{children:i})}const i=e.note||{title:"none",label:e.label},s=`${i.label}-${i.title}-${e.i}`;return $r(Hr,{"data-testid":"semiotic-annotation",events:o,...e,type:r},s)}import{packEnclose as Gr}from"d3-hierarchy";import{area as Vr,curveLinear as qr,curveMonotoneX as Ur,curveMonotoneY as Kr,curveStep as Qr,curveStepAfter as Zr,curveStepBefore as Jr,curveBasis as to,curveCardinal as eo,curveCatmullRom as no}from"d3-shape";import ro from"regression";function oo(t,e){const n=e.scales?.x??e.scales?.time;return n?null!=t.x?n(t.x):e.xAccessor&&null!=t[e.xAccessor]?n(t[e.xAccessor]):null:null}function io(t,e){const n=e.scales?.y??e.scales?.value;return n?null!=t.y?n(t.y):e.yAccessor&&null!=t[e.yAccessor]?n(t[e.yAccessor]):null:null}function so(t){return null==t?null:t+""}function ao(t,e,n){return e.stickyPositionCache?.set(t,n),n}function lo(t,e,n){const r=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===t.pointId)return ao(e,n,{x:o.x,y:o.y})}const r=function(t){const e=t.data;if(!e||0===e.length)return null;const n=e[e.length-1],r=t.scales?.x??t.scales?.time,o=t.scales?.y??t.scales?.value;if(!r||!o)return null;const i=n[t.xAccessor||"x"],s=n[t.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?ao(e,n,r):null}if("semantic"===r){const r=function(t,e,n){const r=function(t){return so(t.provenance?.stableId??t.stableId)}(t);if(!r)return null;const o=n.pointNodes?.find(t=>so(t.pointId)===r);if(o)return ao(e,n,{x:o.x,y:o.y});const i=n.data?.find(t=>function(t){return so(t.stableId??t.id??t.provenance?.stableId)}(t)===r);if(!i)return null;const s=oo(i,n),a=io(i,n);return null==s||null==a?null:ao(e,n,{x:s,y:a})}(t,e,n);if(r)return r}let o=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(o=e.x,i=e.y)}if(null!=o&&null!=i||(o=oo(t,n),i=io(t,n)),null!=o&&null!=i)return ao(e,n,{x:o,y:i});if("sticky"===r){const t=n.stickyPositionCache?.get(e);if(t)return t}return null}function co(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}import{jsx as uo}from"react/jsx-runtime";var ho={secondary:0,primary:3},fo=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function yo(t){return!0===t?._annotationDeferred}function po(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function go(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function mo(t){return Math.max(.72,.95-.06*t)}import{jsx as xo,jsxs as vo}from"react/jsx-runtime";var bo={linear:qr,monotoneX:Ur,monotoneY:Kr,step:Qr,stepAfter:Zr,stepBefore:Jr,basis:to,cardinal:eo,catmullRom:no};function ko(t,e,n,r){const o=[];return t.forEach((t,i)=>{let s;if(n){const o=n(t,i,r);s=null!=o?o:e(t,i,r)}else s=e(t,i,r);s&&o.push({node:s,annotation:t})}),function(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:go(t.annotation),readingOrder:null,rank:1};var n}),n=e.some(t=>null!=t.emphasis||null!=t.confidence),r=t.some(t=>yo(t.annotation)),o=t.some(t=>null!=po(t.annotation)),i=t.some(t=>"layer"===po(t.annotation));if(!n&&!r&&!o)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=ho[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:n,emphasis:r,readingOrder:o}=t,i=yo(e.annotation);let s=e.node;if("primary"===r||"secondary"===r||null!=o){const t=null==r&&null!=o;s=uo("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:mo(o),"data-annotation-reading-order":o}:{},children:e.node},"annotation-emphasis-"+n)}const a=po(e.annotation);return a&&(s=uo("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=uo("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(uo("style",{children:fo},"annotation-disclosure-style")),i&&a.unshift(uo("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o)}function wo(t){return function(t,e,n){switch(t.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const r=lo(t,e,n);if(!r)return null;const{x:o,y:i}=r;if(!co(o,i,n))return null;const s="callout"===t.type?"callout-circle":t.type,a="callout-circle"===s?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===s?{width:t.width,height:t.height}:void 0;return xo(Xr,{noteData:{x:o,y:i,dx:t.dx??30,dy:t.dy??-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:s,...a?{subject:a}:{},connector:t.connector||{end:"arrow"},color:t.color,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-"+e)}case"x-threshold":{const r=oo(null!=t.value?{...t,x:t.value}:t,n);if(null==r)return null;const o=t.color||"#f97316",i=t.labelPosition||"top";let s;s="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12;const a=r>.6*(n.width||0),l=a?r-4:r+4,c=a?"end":"start";return vo("g",{opacity:t.opacity,children:[xo("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&xo("text",{x:l,y:s,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"y-threshold":{const r=io(null!=t.value?{...t,y:t.value}:t,n);if(null==r)return null;const o=t.color||"#f97316",i=t.labelPosition||"right";let s,a;return"left"===i?(s=4,a="start"):"center"===i?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),vo("g",{opacity:t.opacity,children:[xo("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:o,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&xo("text",{x:s,y:r-4,textAnchor:a,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"enclose":{const r=(t.coordinates||[]).map(t=>({x:oo({...t,type:"point"},n),y:io({...t,type:"point"},n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=Gr(r),i=t.padding||10;return vo("g",{children:[xo("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&xo("text",{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+e)}case"rect-enclose":{const r=(t.coordinates||[]).map(t=>({x:oo({...t,type:"point"},n),y:io({...t,type:"point"},n)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=t.padding||10,i=r.map(t=>t.x),s=r.map(t=>t.y),[a,l]=Nr(i),[c,u]=Nr(s),h=a-o,d=l+o,f=c-o;return vo("g",{children:[xo("rect",{x:h,y:f,width:d-h,height:u+o-f,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&xo("text",{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+e)}case"highlight":{const r=n.data||[],o="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],i={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return xo("g",{children:o.map((e,r)=>{const o=oo(e,n),s=io(e,n);if(null==o||null==s)return null;const a="function"==typeof t.r?t.r(e):t.r||6,l="function"==typeof t.style?t.style(e):t.style||i;return xo("circle",{cx:o,cy:s,r:a,...l},"hl-"+r)})},"ann-"+e)}case"bracket":{const r=oo(t,n),o=io(t,n);return xo(Xr,{noteData:{x:r??0,y:o??0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+e)}case"trend":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,l=s?o:null,c=s?i:null;let u;const h=[],d=new Map;if(s&&l&&c){for(const t of r){const e=t[l];if(null==e)continue;const n=e+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=r.map(t=>{const e=t[l],n=t[c];if(null==e||null==n)return null;const r=d.get(e+"");return null!=r?[r,+n]:null}).filter(t=>null!==t)}else u=r.map(t=>[t[o],t[i]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,y=n.scales?.y??n.scales?.value;if(!f||!y)return null;const p=t=>e=>{const n=Math.max(0,Math.floor(e)),r=Math.min(h.length-1,n+1),o=e-n,i=t(h[n]);return i+(t(h[r])-i)*o},g=f,m=y;let x;if(s)if(a){const t=p(m);x=(e,n)=>[g(n),t(e)]}else{const t=p(g);x=(e,n)=>[t(e),m(n)]}else x=(t,e)=>[g(t),m(e)];const v=t.method||"linear";let b;b="loess"===v?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),o=r.map(t=>t[0]),i=r.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],r=o.map(t=>Math.abs(t-e)),l=r.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:r[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*o[t],d+=e*i[t],f+=e*o[t]*o[t],y+=e*o[t]*i[t])}if(0===u){a.push([e,i[t]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([e,d/u]);else{const t=(u*y-h*d)/p;a.push([e,(d-t*h)/u+t*e])}}return a}(u,t.bandwidth??.3):("polynomial"===v?ro.polynomial(u,{order:t.order||2}):ro.linear(u)).points;const k=b.map(([t,e])=>{const[n,r]=x(t,e);return`${n},${r}`}).join(" "),w=t.color||"#6366f1",A=b[b.length-1],[S,_]=x(A[0],A[1]);return vo("g",{children:[xo("polyline",{points:k,fill:"none",stroke:w,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&xo("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:t.label})]},"ann-"+e)}case"band":{const r=n.scales?.y??n.scales?.value,o=r?.(t.y0)??0,i=r?.(t.y1)??(n.height||0);return vo("g",{opacity:t.opacity,children:[xo("rect",{x:0,y:Math.min(o,i),width:n.width||0,height:Math.abs(i-o),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&xo("text",{x:(n.width||0)-4,y:Math.max(Math.min(o,i),0)+13,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"x-band":{const r=n.scales?.x??n.scales?.time,o=null!=t.x0&&r?r(t.x0):null,i=null!=t.x1&&r?r(t.x1):null;return null==o||null==i?null:vo("g",{opacity:t.opacity,children:[xo("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:n.height||0,fill:t.fill||t.color||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity??.1}),t.label&&xo("text",{x:Math.min(o,i)+4,y:13,textAnchor:"start",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:t.label})]},"ann-"+e)}case"envelope":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!i||!s)return null;const a=t.upperAccessor||"upperBounds",l=t.lowerAccessor||"lowerBounds",c=t.filter,u=r.filter(t=>null!=t[a]&&null!=t[l]&&!(c&&!c(t))).sort((t,e)=>t[o]-e[o]);if(2>u.length)return null;const h=bo[n.curve||"linear"]||qr,d=Vr().x(t=>i(t[o])).y0(t=>s(t[l])).y1(t=>s(t[a])).curve(h)(u);if(!d)return null;const f=t.fill||"#6366f1";return vo("g",{children:[xo("path",{d:d,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&u.length>0&&xo("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+e)}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const o=n.yAccessor||"y",i=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!i||!s)return null;const a=r.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const l=a.reduce((t,e)=>t+e,0)/a.length,c=a.reduce((t,e)=>t+(e-l)**2,0)/a.length,u=Math.sqrt(c),h=t.threshold??2,d=l-h*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=t.fillOpacity??.1,g=t.anomalyColor||"#ef4444",m=t.anomalyRadius??6,x=s(l+h*u),v=s(d),b=r.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-l)>h*u});return vo("g",{children:[f&&xo("rect",{x:0,y:Math.min(x,v),width:n.width||0,height:Math.abs(v-x),fill:y,fillOpacity:p}),b.map((t,e)=>{const r=oo(t,n),o=io(t,n);return null==r||null==o?null:xo("circle",{cx:r,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+e)}),t.label&&xo("text",{x:(n.width||0)-4,y:Math.min(x,v)-4,textAnchor:"end",fill:y,fontSize:11,children:t.label})]},"ann-"+e)}case"forecast":{const r=n.data||[];if(3>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",s=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!s||!a)return null;const l=r.map(t=>[t[o],t[i]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>l.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=ro.polynomial(l,{order:t.order||2}).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}else{const t=l.length;let e=0,n=0,r=0,o=0;for(const[t,i]of l)e+=t,n+=i,r+=t*t,o+=t*i;const i=t*r-e*e;if(1e-12>Math.abs(i))return null;const s=(t*o-e*n)/i,a=(n-s*e)/t;c=t=>a+s*t}const u=l.length,h=l.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=l.reduce((t,e)=>t+e[0],0)/u,y=l.reduce((t,e)=>t+(e[0]-f)**2,0),p=t.confidence??.95,g=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=t.steps??5,x=l[u-1][0],v=(x-l[0][0])/Math.max(u-1,1),b=[];for(let t=1;m>=t;t++)b.push(x+t*v);const k=[];for(const t of b){const e=c(t),n=d*Math.sqrt(1+1/u+(y>0?(t-f)**2/y:0))*g;k.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const w=`M${k.map(t=>`${s(t.x)},${a(t.yUpper)}`).join(" L")} L${k.slice().reverse().map(t=>`${s(t.x)},${a(t.yLower)}`).join(" L")} Z`,A=k.map(t=>`${s(t.x)},${a(t.yCenter)}`).join(" "),S=`${s(x)},${a(c(x))}`,_=t.strokeColor||"#6366f1";return vo("g",{children:[xo("path",{d:w,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),xo("polyline",{points:`${S} ${A}`,fill:"none",stroke:_,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&k.length>0&&xo("text",{x:s(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:_,fontSize:11,children:t.label})]},"ann-"+e)}case"widget":{let r,o;if(null!=t.px&&null!=t.py)r=t.px,o=t.py;else{const i=lo(t,e,n);if(!i)return null;r=i.x,o=i.y}if(!co(r,o,n))return null;const i=t.width??32,s=t.height??32;return xo("foreignObject",{x:r+(t.dx??0)-i/2,y:o+(t.dy??0)-s/2,width:i,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:xo("div",{style:{width:i,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:t.content??xo("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"})})},"ann-"+e)}case"text":{const r=lo(t,e,n);if(!r)return null;const{x:o,y:i}=r,s=o+(t.dx||0),a=i+(t.dy||0),l=t.color||"var(--semiotic-text, #333)",c=xo("text",{x:s,y:a,fill:l,fontSize:t.fontSize||11,opacity:t.opacity,strokeDasharray:t.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label});return!0!==t._redundantConnector?zr.cloneElement(c,{key:"ann-text-"+e}):vo("g",{opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:[xo("line",{x1:o,y1:i,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),zr.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+e)}case"category-highlight":{const r=t.category;if(null==r)return null;const o=t=>"function"==typeof t&&"function"==typeof t.bandwidth,i=n.scales?.o,s=n.scales?.x,a=n.scales?.y,l=o(i)?i:o(s)?s:o(a)?a:null;if(!l)return null;const c=l(r+"");if(null==c)return null;const u=l.bandwidth(),h=t.color||"var(--semiotic-primary, #4589ff)",d=t.opacity??.15,f=t.label;return vo("g",(n.projection?"vertical"===n.projection:l===s)?{children:[xo("rect",{x:c,y:0,width:u,height:n.height||0,fill:h,fillOpacity:d}),f&&xo("text",{x:c+u/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]}:{children:[xo("rect",{x:0,y:c,width:n.width||0,height:u,fill:h,fillOpacity:d}),f&&xo("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+e)}default:return null}}}var Ao=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function So(t){return!!t&&"object"==typeof t&&Ao.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}function _o(t){return"primary"===t?.emphasis||!0===t?.defensive}function Mo(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Po(t){let e;const n=t?.emphasis;e="primary"===n?100:"secondary"===n?10:50;const r=t?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(e+=15*Math.max(0,Math.min(1,r))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}new Set(["label","callout","callout-circle","callout-rect"]);var Co=32,To=6,Lo=4,No=8,Do=72;var Eo={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Ro(t){if(!Io(t))return t;const e=("string"==typeof t.mobileText?t.mobileText:void 0)??("string"==typeof t.shortText?t.shortText:void 0);return!e||"string"!=typeof t.label&&null!=t.label?t:{...t,label:e}}function Io(t){return So(t)}function zo(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),r=t.split(/\s+/).filter(Boolean),o=[];let i="";for(const t of r)i&&i.length+t.length+1>n?(o.push(i),i=t):i=i?`${i} ${t}`:t;return i&&o.push(i),o}function $o(t,e,n,r,o){const i=t+n,s=e+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function Wo(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Fo(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function Oo(t,e,n,r,o,i,s,a){const l=Wo(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,r){const o=Math.max(0,r-t.x),i=Math.max(0,r-t.y);return(o+Math.max(0,t.x+t.width-(e-r)))*t.height+(i+Math.max(0,t.y+t.height-(n-r)))*t.width}(l,o,i,a);for(const t of n)c+=12*Fo(l,t);for(const t of r)c+=4*Fo(l,t);return c}function Yo(t){const{annotations:e,context:n,defaultOffset:r=Co,notePadding:o=To,markPadding:i=Lo,edgePadding:s=No,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:c=Do,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=t,m=n.width||0,x=n.height||0,v="object"==typeof y?y:{},b=v.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==v.preferShortText?e.map(Ro):e,A=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,S=h||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),_=k&&!f?v.responsive??{minWidth:b}:f,M=k&&!p?v.cohesion:p;if(0===w.length||0>=m||0>=x)return w.slice();const P=[],C=function(t,e){return(t.pointNodes||[]).map(t=>{const n=Math.max(1,t.r||1)+e;return{x:t.x-n,y:t.y-n,width:2*n,height:2*n}})}(n,i);let T=!1;const L=w.map((t,e)=>{if(!Io(t))return t;const i=function(t,e,n){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=t.pointId??t.nodeId;if(null!=r&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===r);if(t)return{x:t.x,y:t.y}}const o=t.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const t=o[0],e=o[1];if("number"==typeof t&&"number"==typeof e){const n=i([t,e]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof t.x||"number"!=typeof t.y?lo(t,e,n):{x:t.x,y:t.y}}(t,e,n);if(!i)return t;const u=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,n=[...zo("string"==typeof t.title?t.title:void 0,e),...zo("string"==typeof t.label?t.label:void 0,e)],r=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*r)+10),height:Math.max(18,16*n.length+6)}}(t);if(a&&("number"==typeof(h=t).dx||"number"==typeof h.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return P.push(Wo($o(i.x,i.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),o)),t}var h;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(r)){const e=Oo($o(i.x,i.y,t.dx,t.dy,u),t,P,C,m,x,o,s);f>e&&(d=t,f=e)}if(!d)return t;const y=Wo($o(i.x,i.y,d.dx,d.dy,u),o);P.push(y);const p=Math.hypot(d.dx,d.dy),g=l&&p>=c&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return T=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),N=T?L:w.slice();let D=N;if(d){let t=!1;const e=N.map(e=>{const n=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:{...t,_redundantConnector:!0}}(e);return n!==e&&(t=!0),n});D=t?e:N}{let t=!1;const e=D.map(e=>{if(!0!==e?.defensive)return e;const n=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const n="string"==typeof e.source?Eo[e.source]??e.source:null,r="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!n&&!r)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof t.label?t.label:"";return i.includes(`(${o})`)?t:{...t,label:i?`${i} (${o})`:`(${o})`}}(e);return n!==e&&(t=!0),n});D=t?e:D}const E=new Set;if(A){const t="object"==typeof A?A:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return 3;const n=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===n.length?3:n.reduce((t,e)=>t+e,0)/n.length}(t);return e>2?4>e?1:.6:1.5}(g),n=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??Mo(m,x,t))*e))},{deferred:r}=function(t){const{annotations:e,width:n,height:r}=t,o=Math.max(0,t.minVisible??1),i=Mo(n,r,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(n=t,So(n))};var n}),a=s.filter(t=>t.note);if(0===a.length||i>=a.length)return{visible:e.slice(),deferred:[],budget:i};const l=a.filter(t=>_o(t.annotation)),c=a.filter(t=>!_o(t.annotation)).sort((t,e)=>Po(e.annotation)-Po(t.annotation)||t.index-e.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),h=new Set([...l.map(t=>t.index),...c.slice(0,u).map(t=>t.index)]),d=[],f=[];for(const{annotation:t,index:e,note:n}of s)!n||h.has(e)?d.push(t):f.push(t);return{visible:d,deferred:f,budget:i}}({annotations:D,width:m,height:x,...n});for(const t of r)E.add(t)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const t of D)Io(t)&&"secondary"===t.emphasis&&E.add(t);if(E.size>0)for(const t of D)!0===t?.defensive&&E.delete(t);let R;return R=0===E.size?D:S?D.map(t=>E.has(t)?{...t,_annotationDeferred:!0}:t):D.filter(t=>!E.has(t)),M?function(t,e){let n=!1;const r=t.map(t=>Io(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,{...t,cohesion:e}):t);return n?r:t}(R,M):R}import{useSyncExternalStore as Bo}from"react";var jo={positions:new Map},Ho=new Set;function Xo(){for(const t of Ho)t()}function Go(t,e){const n=jo.positions.get(t);if(n?.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(jo.positions);r.delete(t),jo={positions:r},Xo()}function Vo(t,e){const n=jo.positions.get(t);if(!n?.locked)return;if(e&&n.sourceId!==e)return;const r=new Map(jo.positions);r.delete(t),jo={positions:r},Xo()}function qo(){return jo}function Uo(t){return Ho.add(t),()=>Ho.delete(t)}var Ko={positions:new Map};function Qo(){return()=>{}}function Zo(){return Ko}function Jo(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>e||s===a)return i?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=i?new Date(n):n}return c}(t,e):t.ticks(e)}import{Fragment as ti,jsx as ei,jsxs as ni}from"react/jsx-runtime";function ri(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function oi(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function ii(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const r of t)e>r.pixel&&(e=r.pixel),r.pixel>n&&(n=r.pixel);return{min:e,max:n}}function si(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function ai(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,o="left"===t?-1:1,i=Math.ceil(e/8);let s="M0,"+r;for(let t=0;i>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${r+4*o}`,s+=`L${Math.min(n,e)},${r}`}return s}{const r="bottom"===t?0:e,o="bottom"===t?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let t=0;i>t;t++){const e=8*(t+1);s+=`L${r+4*o},${Math.min(8*t+4,n)}`,s+=`L${r},${Math.min(e,n)}`}return s}}function li(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:h,axisExtent:d}=t,f=fr(()=>{if(!s)return[];const t=l?.find(t=>"bottom"===t.orient),n=t?.tickFormat||u||ci,r=Math.max(2,Math.floor(e/70)),o=t?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=t?.tickValues??Jo(s.x,i,d),c=a.map(t=>t.valueOf()),h=a.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,c)})),f=h.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return ui(h,Math.max(55,f+8))},[s,l,u,e,d]),y=fr(()=>{if(!s)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||h||ci,r=Math.max(2,Math.floor(n/30)),o=t?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return ui((t?.tickValues??Jo(s.y,i,d)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[s,l,h,n,d]),p=c&&s,g=a&&s;if(!p&&!g)return null;const m=l?.find(t=>"bottom"===t.orient),x=l?.find(t=>"left"===t.orient),v=g&&(!m||!1!==m.baseline),b=g&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,w=x?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return ei("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:ni("g",{transform:`translate(${i.left},${i.top})`,children:[p&&(()=>{const t=si(l?.find(t=>"bottom"===t.orient)?.gridStyle),r=si(l?.find(t=>"left"===t.orient)?.gridStyle);return ni("g",{className:"stream-grid",children:[f.map((e,r)=>ei("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+r)),y.map((t,n)=>ei("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),v&&!k&&ei("line",{x1:0,y1:n,x2:e,y2:n,stroke:A,strokeWidth:1}),k&&ei("path",{d:ai("bottom",e,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&ei("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&ei("path",{d:ai("left",e,n),fill:"none",stroke:A,strokeWidth:1})]})})}function ci(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function ui(t,e){if(2>=t.length)return t;const n=[t[0]];for(let r=1;t.length-1>r;r++)e>Math.abs(t[r].pixel-n[n.length-1].pixel)||n.push(t[r]);const r=t[t.length-1];return e>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function hi(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,xLabel:c,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:P,annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,xAccessor:N,yAccessor:D,annotationData:E,pointNodes:R,curve:I,underlayRendered:z,canvasObscuresUnderlay:$=!0,linkedCrosshairName:W,linkedCrosshairSourceId:F,children:O}=t,Y=fr(()=>{if(!a||!s)return[];const t=l?.find(t=>"bottom"===t.orient),n=t?.tickFormat||d||ci,r=Math.max(2,Math.floor(e/70)),o=t?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),c=t?.tickValues??Jo(s.x,i,y),u=c.map(t=>t.valueOf()),h=c.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,u)})),f=h.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),p=t?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=ui(h,p);if(g.length>1&&(g=g.filter((t,e)=>0===e||t.label+""!=g[e-1].label+"")),t?.includeMax&&g.length>0&&"exact"!==y&&!t?.tickValues){const t=s.x.domain()[1],e=s.x(t),r=g[g.length-1].pixel;if(Math.abs(e-r)>1){const o=n(t,g.length,u);p>e-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:t,pixel:e,label:o})}}return g},[a,s,l,d,e,y]),B=fr(()=>{if(!a||!s)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||f||ci,r=Math.max(2,Math.floor(n/30)),o=t?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let c=ui((t?.tickValues??Jo(s.y,i,y)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22);if(c.length>1&&(c=c.filter((t,e)=>0===e||t.label+""!=c[e-1].label+"")),t?.includeMax&&c.length>0&&"exact"!==y&&!t?.tickValues){const t=s.y.domain()[1],n=s.y(t),r=c[c.length-1].pixel;if(Math.abs(n-r)>1){const o=e(t);22>Math.abs(n-r)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:t,pixel:n,label:o})}}return c},[a,s,l,f,n,y]),j=fr(()=>{if(!a||!s)return[];const t=l?.find(t=>"right"===t.orient);if(!t)return[];const e=t.tickFormat||f||ci,r=Math.max(2,Math.floor(n/30)),o=t.ticks??5;return ui((t.tickValues??Jo(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[a,s,l,f,n,y]),H=yr(new Map),X=yr(C?.length??0),G=C?.length??0;X.current!==G&&(X.current=G,H.current=new Map);const V=fr(()=>{if(!C||0===C.length)return null;const t=wo(),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:N,yAccessor:D,width:e,height:n,data:E,frameType:"xy",pointNodes:R,curve:I,stickyPositionCache:H.current};return ko(T?Yo({annotations:C,context:r,..."object"==typeof T?T:{}}):C,t,L,r)},[C,T,L,e,n,N,D,E,s,R,I]),q=function(t){const e=Bo(t?Uo:Qo,t?qo:Zo,t?qo:Zo);return t?e.positions.get(t)??null:null}(W);return pr(()=>{if(!q?.locked||!W)return;const t=t=>{"Escape"===t.key&&Vo(W)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[q?.locked,W]),a||g||m||S||_||V&&V.length>0||p||O||q?ni("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[ei("title",{children:"string"==typeof g?g:"XY Chart"}),ei("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),ni("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&(!z||$)&&(()=>{const t=si(l?.find(t=>"bottom"===t.orient)?.gridStyle),r=si(l?.find(t=>"left"===t.orient)?.gridStyle);return ni("g",{className:"stream-grid",children:[Y.map((e,r)=>ei("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+r)),B.map((t,n)=>ei("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const t=l?.find(t=>"left"===t.orient),r=l?.find(t=>"bottom"===t.orient),o=!t||!1!==t.baseline,s=!r||!1!==r.baseline,a=t?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=t?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!r?.autoRotate&&Y.length>1&&(()=>{const t=e/Math.max(Y.length-1,1);return Y.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),v=x?12:18,b=n+(x?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=r?.tickAnchor,_=t?.tickAnchor,M=ii(Y),P=ii(B);return ni("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[ni("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!z||$)&&s&&!d&&ei("line",{x1:0,y1:n,x2:e,y2:n,stroke:p,strokeWidth:1}),(!z||$)&&d&&ei("path",{d:ai("bottom",e,n),fill:"none",stroke:p,strokeWidth:1}),Y.map((t,e)=>{const r=!!f&&("function"==typeof f?f(t.value,e):sn(t.value,e>0?Y[e-1].value:void 0));return ni("g",{transform:`translate(${t.pixel},${n})`,children:[ei("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ei("text",{y:v,textAnchor:x?"end":ri(S,t.pixel===M.min,t.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:x?"rotate(-45)":void 0,children:t.label}):ei("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:ei("div",{style:{textAlign:"center",userSelect:"none",...k},children:t.label})})]},"xtick-"+e)}),c&&ei("text",{x:e/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:c})]}),ni("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!z||$)&&o&&!a&&ei("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!z||$)&&a&&ei("path",{d:ai("left",e,n),fill:"none",stroke:p,strokeWidth:1}),B.map((t,e)=>{const n=!!y&&("function"==typeof y?y(t.value,e):sn(t.value,e>0?B[e-1].value:void 0));return ni("g",{transform:`translate(0,${t.pixel})`,children:[ei("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ei("text",{x:-8,textAnchor:"end",dominantBaseline:oi(_,t.pixel===P.min,t.pixel===P.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:t.label}):ei("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:ei("div",{style:{textAlign:"right",userSelect:"none",...k},children:t.label})})]},"ytick-"+e)}),(()=>{const e=t?.label||u;return e?ei("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:e}):null})()]}),(()=>{const t=l?.find(t=>"right"===t.orient);if(!t||0===j.length)return null;const r=!1!==t.baseline,o=t.landmarkTicks,s=t.label||h,a=t.tickAnchor,c=ii(j);return ni("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&ei("line",{x1:e,y1:0,x2:e,y2:n,stroke:p,strokeWidth:1}),j.map((t,n)=>{const r=!!o&&("function"==typeof o?o(t.value,n):sn(t.value,n>0?j[n-1].value:void 0));return ni("g",{transform:`translate(${e},${t.pixel})`,children:[ei("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ei("text",{x:8,textAnchor:"start",dominantBaseline:oi(a,t.pixel===c.min,t.pixel===c.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:t.label}):ei("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:ei("div",{style:{textAlign:"left",userSelect:"none",...k},children:t.label})})]},"ytick-r-"+n)}),s&&ei("text",{x:e+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${e+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),V,_&&s&&M&&P&&ni(ti,{children:[_.top&&ei("g",{transform:"translate(0, 0)",children:ei(Ir,{orient:"top",config:Rr(_.top),values:M,scale:s.x,size:i.top,length:e})}),_.bottom&&ei("g",{transform:`translate(0, ${n})`,children:ei(Ir,{orient:"bottom",config:Rr(_.bottom),values:M,scale:s.x,size:i.bottom,length:e})}),_.left&&ei("g",{transform:"translate(0, 0)",children:ei(Ir,{orient:"left",config:Rr(_.left),values:P,scale:s.y,size:i.left,length:n})}),_.right&&ei("g",{transform:`translate(${e}, 0)`,children:ei(Ir,{orient:"right",config:Rr(_.right),values:P,scale:s.y,size:i.right,length:n})})]}),S,q&&q.sourceId!==F&&s?.x&&(()=>{const t=s.x(q.xValue);if(null==t||0>t||t>e)return null;const r=q.locked;return ei("line",{x1:t,y1:0,x2:t,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),O]}),g&&ei("text",{x:r/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof g?g:null}),Cr({legend:m,totalWidth:r,totalHeight:o,margin:i,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}import*as di from"react";import{arc as fi}from"d3-shape";function yi(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}import{jsx as pi,jsxs as gi}from"react/jsx-runtime";var mi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function xi(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function vi(t,e,n,r){const o=t.glyph;if(!o?.parts?.length||0>=t.size)return null;const i=un(o,t.size);if(0>=i.scale)return null;const s=`translate(${e},${n})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),l=yn(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),c=l?function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(r+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>o.parts.map((n,r)=>{const o=e?"none"===n.fill?void 0:e:hn(n.fill,a,t.accent),i=e?n.stroke&&"none"!==n.stroke?e:void 0:hn(n.stroke??"none",a,t.accent);return o||i?pi("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return gi("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&pi("clipPath",{id:c,children:pi("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&t.ghostColor?pi("g",{children:h(t.ghostColor)}):null,l&&c?pi("g",{clipPath:`url(#${c})`,children:h()}):h()]},r)}var bi="undefined"==typeof window||"undefined"==typeof document;import{useEffect as ki,useLayoutEffect as wi,useRef as Ai,useState as Si,useSyncExternalStore as _i}from"react";var Mi="undefined"!=typeof window?wi:ki;function Pi(){const[t,e]=Si(!1);return Mi(()=>{e(!0)},[]),t}var Ci=()=>()=>{},Ti=()=>!1,Li=()=>!0;function Ni(){const t=_i(Ci,Ti,Li);return Ai(t).current}function Di(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=t;Mi(()=>{e&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),i.current()},[e,n]);const l=Ai(a);l.current=a,ki(()=>()=>l.current?.(),[])}import{useRef as Ei}from"react";function Ri(t){const e=Ei(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return zi(t,e);if(!$i(t)||!$i(e))return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(e,r))return!1;const n=t[r],o=e[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!zi(n,o))return!1}else{if(!$i(n)||!$i(o))return!1;if(!Ii(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}function Ii(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(e,r))return!1;if(!Object.is(t[r],e[r]))return!1}return!0}function zi(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function $i(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Wi(t,e){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:l}=e;if("transparent"===n)return!1;if(r)return!1;const c=n||(o&&"transparent"!==o?o:"")||null;if(!c)return!1;const u=Sn(t,c);return!!u&&(t.fillStyle=u,t.fillRect(i,s,a,l),!0)}var Fi={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function Oi(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],r=n[2],o=n[3];return`#${t}${t}${r}${r}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}import*as Yi from"react";import*as Bi from"react";import{jsx as ji}from"react/jsx-runtime";var Hi=Bi.createContext(null);function Xi(){return Bi.useContext(Hi)}function Gi(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,r]of Object.entries(t))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(e[n]=r):"string"==typeof r?e[n]=r:"boolean"==typeof r?e[n]=r+"":r instanceof Date&&(e[n]=r.toISOString().slice(0,10)));return e}function Vi(t){return t&&"object"==typeof t?t:{}}function qi(t){return Vi(t.accessibility).tableFields??t.accessibleDatum??t.datum}import{jsx as Ui,jsxs as Ki}from"react/jsx-runtime";var Qi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Zi(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===e?.datum)continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=i.indexOf(t),r=i.indexOf(e);return(-1===n?999:n)-(-1===r?999:r)});for(const t of s)r.push(`${n[t]} ${o[t]||t}`);return`${e}, ${r.join(", ")}`}function Ji(t,e,n){const r=[];return t>0&&r.push(t+" nodes"),e>0&&r.push(e+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var ts=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},es="semiotic-accessible-data-table",ns=es+" semiotic-accessible-data-table-hidden",rs=es+" semiotic-accessible-data-table-visible",os=rs+" semiotic-accessible-data-table-network",is={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},ss={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},as={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ls={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},cs={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},us={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},hs={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ds={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function fs({scene:t,chartType:e,tableId:n,chartTitle:r}){const[o,i]=Yi.useState(!1),[s,a]=Yi.useState(5),l=Xi(),c=l?.visible??!1,u=o||c,h=Yi.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${e} ${n}`:"Data summary for "+e;Yi.useEffect(()=>{u||a(5)},[u]);const f=Yi.useCallback(t=>{t.target===t.currentTarget&&(o||c||i(!0))},[o,c]),y=Yi.useCallback(t=>{c||h.current?.contains(t.relatedTarget)||i(!1)},[c]);if(!t||0===t.length)return n?Ui("span",{id:n,tabIndex:-1,style:Qi}):null;if(!u)return Ui("div",{id:n,className:ns,tabIndex:-1,onFocus:f,style:Qi,role:"region","aria-label":d,children:Ki("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",t.length," elements)"]})});const p=function(t){const e=[];if(!Array.isArray(t))return e;const n=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const r of t)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;e.push({label:"Point",values:Gi(qi(r))});break;case"line":case"area":{const t=qi(r),n=Array.isArray(t)?t:[],o="line"===r.type?"Line point":"Area point";for(const t of n)e.push({label:o,values:Gi(t)});break}case"rect":{const t=qi(r),n=null!=t&&"object"==typeof t?t:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Gi(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),e.push({label:"Bar",values:s});break}case"heatcell":{const t=Gi(qi(r));null==t.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(t.value=r.value),e.push({label:"Cell",values:t});break}case"wedge":{const t=qi(r),n=Gi(t);if(null==n.category){const e=Vi(t),r=e.category??e.label;null!=r&&(n.category=r+"")}e.push({label:"Wedge",values:n});break}case"circle":e.push({label:"Node",values:Gi(qi(r))});break;case"arc":e.push({label:"Arc",values:Gi(qi(r))});break;case"candlestick":e.push({label:"Candlestick",values:Gi(qi(r))});break;case"geoarea":{const t=Vi(qi(r)),n=Gi(t);if(null==n.name){const e=Vi(t.properties).name??t.name;null!=e&&(n.name=e+"")}e.push({label:"Region",values:n});break}}}catch{}return e}(t),g=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const r of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[r];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],i=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),i+=n;n.push({name:r,count:e.length,numeric:!0,min:t,max:o,mean:i/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:r,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(p),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${ts(t.min)} to ${ts(t.max)}, mean ${ts(t.mean)}.`);else{const e=t.uniqueValues,r=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${r}.`)}return n.join(" ")}(p.length,g),x=Math.min(s,p.length),v=p.slice(0,x),b=p.length-x,k=new Set;for(const t of v)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return Ki("div",{ref:h,id:n,className:rs,tabIndex:-1,onBlur:y,style:is,role:"region","aria-label":d,children:[Ui("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:as,children:"×"}),Ui("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ss,children:m}),Ki("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+e,style:ls,children:[Ui("caption",{className:"semiotic-accessible-data-table-caption",style:hs,children:b>0?`First ${x} of ${p.length} data points`:`All ${p.length} data points`}),Ui("thead",{children:Ki("tr",{children:[Ui("th",{style:cs,children:"type"}),w.map(t=>Ui("th",{style:cs,children:t},t))]})}),Ui("tbody",{children:v.map((t,e)=>Ki("tr",{children:[Ui("td",{style:us,children:t.label}),w.map(e=>{return Ui("td",{style:us,children:(n=t.values[e],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":ts(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},e);var n})]},e))})]}),b>0&&Ki("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(t=>t+25),style:ds,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function ys({nodes:t,edges:e,chartType:n,tableId:r,chartTitle:o}){const[i,s]=Yi.useState(!1),[a,l]=Yi.useState(5),c=Xi(),u=c?.visible??!1,h=i||u,d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Yi.useRef(null);Yi.useEffect(()=>{h||l(5)},[h]);const y=Yi.useCallback(t=>{t.target===t.currentTarget&&(i||u||s(!0))},[i,u]),p=Yi.useCallback(t=>{u||f.current?.contains(t.relatedTarget)||s(!1)},[u]);if(!t||0===t.length)return r?Ui("span",{id:r,tabIndex:-1,style:Qi}):null;if(!h)return Ui("div",{id:r,className:ns,tabIndex:-1,onFocus:y,style:Qi,role:"region","aria-label":d,children:Ki("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",t.length," nodes, ",e.length," edges)"]})});const g=Array.isArray(t)?t:[],m=Array.isArray(e)?e:[],x=new Map,v=new Map,b=new Map,k=new Map;for(const t of m){if(!t||"object"!=typeof t)continue;const e=t.datum??t,n="object"==typeof e.source?e.source?.id:e.source,r="object"==typeof e.target?e.target?.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";v.set(t,(v.get(t)??0)+1),k.set(t,(k.get(t)??0)+o)}if(null!=r&&""!==r){const t=r+"";x.set(t,(x.get(t)??0)+1),b.set(t,(b.get(t)??0)+o)}}const w=[];for(let t=0;g.length>t;t++){const e=g[t];if(!e||"object"!=typeof e)continue;const n=e.datum?.id??e.id,r=null!=n?n+"":"node-"+t,o=x.get(r)??0,i=v.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((t,e)=>e.degree-t.degree);let A=0,S=0;if(w.length>0){let t=0;for(const e of w)t+=e.degree,e.degree>S&&(S=e.degree);A=t/w.length}const _=m.some(t=>{const e=t?.datum??t;return"number"==typeof e?.value&&Number.isFinite(e.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${ts(A)}, max degree: ${S}.`);const P=Math.min(a,w.length),C=w.slice(0,P),T=w.length-P;return Ki("div",{ref:f,id:r,className:os,tabIndex:-1,onBlur:p,style:is,role:"region","aria-label":d,children:[Ui("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:as,children:"×"}),Ui("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ss,children:M.join(" ")}),Ki("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:ls,children:[Ui("caption",{className:"semiotic-accessible-data-table-caption",style:hs,children:T>0?`Top ${P} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),Ui("thead",{children:Ki("tr",{children:[Ui("th",{style:cs,children:"id"}),Ui("th",{style:cs,children:"degree"}),Ui("th",{style:cs,children:"in"}),Ui("th",{style:cs,children:"out"}),_&&Ui("th",{style:cs,children:"w. degree"}),_&&Ui("th",{style:cs,children:"w. in"}),_&&Ui("th",{style:cs,children:"w. out"})]})}),Ui("tbody",{children:C.map((t,e)=>Ki("tr",{children:[Ui("td",{style:us,children:t.id}),Ui("td",{style:us,children:t.degree}),Ui("td",{style:us,children:t.inDeg}),Ui("td",{style:us,children:t.outDeg}),_&&Ui("td",{style:us,children:ts(t.wDegree)}),_&&Ui("td",{style:us,children:ts(t.wInDeg)}),_&&Ui("td",{style:us,children:ts(t.wOutDeg)})]},e))})]}),T>0&&Ki("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(t=>t+25),style:ds,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function ps({summary:t}){return t?Ui("div",{role:"note",style:Qi,children:t}):null}function gs({tableId:t}){return Ui("a",{href:"#"+t,style:Qi,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Qi)},children:"Skip to data table"})}function ms({hoverPoint:t}){let e="";if(t){const n=t.data||t;e="object"==typeof n?"Data point: "+Object.entries(n).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Data point: "+n}return Ui("div",{"aria-live":"polite","aria-atomic":"true",style:Qi,children:e})}import{jsx as xs}from"react/jsx-runtime";var vs="var(--semiotic-focus, #005fcc)";function bs({active:t,hoverPoint:e,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!t||!e)return null;const l=e.x+n.left,c=e.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const t=Math.max(i,4),e=Math.max(s,4);u=xs("rect",{x:l-t/2-3,y:c-e/2-3,width:t+6,height:e+6,rx:3,fill:"none",stroke:vs,strokeWidth:2,strokeDasharray:"4,2"})}else u=xs("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:vs,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:vs,strokeWidth:2,strokeDasharray:"4,2"});else u=xs("g",{transform:`translate(${n.left},${n.top})`,children:xs("path",{d:a,fill:"none",stroke:vs,strokeWidth:2.5,strokeDasharray:"6,3"})});return xs("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as ks from"react";function ws(t,e){return"touch"===e?Math.max(t,24):t}function As(t){return Array.isArray(t)?t[0]:t}function Ss(t,e,n,r){return{data:As(t),x:e,y:n,__semioticHoverData:!0,...r}}var _s=["name","label","title"],Ms=["type","kind","category","group","class","status","role","shape"],Ps=["value","amount","total","count","weight","score"],Cs=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Ts(t,e){for(const n of e){const e=t.find(t=>t.lower===n);if(e)return e}}function Ls(t,e={}){if(!t||"object"!=typeof t)return{entries:[]};const n=e.maxEntries??6,r=!1!==e.skipPositional,o=[];for(const[e,n]of Object.entries(t)){if(e.startsWith("_"))continue;if("data"===e)continue;if(r&&Cs.has(e.toLowerCase()))continue;if(null==n)continue;const t=typeof n;("string"===t||"number"===t||"boolean"===t||n instanceof Date)&&o.push({key:e,lower:e.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(t=>_s.includes(t.lower));const s=i>=0;0>i&&(i=o.findIndex(t=>"id"===t.lower)),0>i&&(i=o.findIndex(t=>"string"==typeof t.value));const a=0>i?void 0:o[i];let l=o.filter((t,e)=>e!==i);s&&(l=l.filter(t=>"id"!==t.lower));const c=Ts(l,Ms),u=Ts(l,Ps),h=new Set(Ms),d=new Set(Ps),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const t of l){if(f.length>=n)break;t!==c&&t!==u&&(h.has(t.lower)||d.has(t.lower)||f.push({key:t.key,value:t.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}import{jsx as Ns,jsxs as Ds}from"react/jsx-runtime";var Es={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};import{jsx as Rs}from"react/jsx-runtime";function Is({x:t,y:e,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(t)&&Number.isFinite(e),c=ks.useRef(null),[u,h]=ks.useState(null);ks.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[i,s,n,r]);let d;d=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-e?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>e?"4px":"calc(-100% - 4px)"})`;const f=function(t){if(!ks.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),y=f?null:Es;return l?Rs("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:o.left+t,top:o.top+e,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}import*as zs from"react";import{useCallback as $s,useEffect as Ws,useLayoutEffect as Fs,useMemo as Os,useRef as Ys}from"react";import{useState as Bs,useEffect as js}from"react";import{useRef as Hs,useState as Xs,useEffect as Gs}from"react";var Vs="undefined"==typeof window?Ws:Fs,qs={requestAnimationFrame:t=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(t),cancelAnimationFrame:t=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(t)};function Us(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Ks(t){const e=function(){const[t,e]=Bs(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return js(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>e(t.matches))},[]),t}(),n=Ys(e);n.current=e;const[r,o]=function(t,e,n){const r=Hs(null),[o,i]=Xs(null);return Gs(()=>{if(!e&&!n)return;const t=r.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;i(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[r,[e&&o?o.w:t[0],n&&o?o.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),i=Os(()=>({...t.marginDefault,...t.userMargin}),[t.marginDefault,t.userMargin]),s=o[0]-i.left-i.right,a=o[1]-i.top-i.bottom,l=Us(t.foregroundGraphics,o,i),c=Us(t.backgroundGraphics,o,i),u=H(t=>t.theme),{transition:h,introEnabled:d}=function(t,e){if(!1===t)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:t?!0===t?{duration:300}:{duration:t.duration??300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(n||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),f="semiotic-table-"+zs.useId(),y=Ys(null),p=Ys(t.frameScheduler??qs);p.current=t.frameScheduler??qs;const g=Ys(null),m=Ys(!1),x=Ys(()=>{}),v=$s(()=>{if(null!==y.current||m.current)return;const t=p.current;let e=!1,n=!1;const r=t.requestAnimationFrame(()=>{e=!0;const t=!n;t&&(m.current=!0),y.current=null,g.current=null;try{x.current()}finally{t&&(m.current=!1)}});n=!0,e||(y.current=r,g.current=t)},[]),b=$s(()=>{null!==y.current&&((g.current??p.current).cancelAnimationFrame(y.current),y.current=null,g.current=null)},[]);Ws(()=>()=>{b()},[b]);const k=Ys(()=>{}),w=Ys(()=>{}),A=Ys(null),S=Ys(null),_=Ys(null),M=$s(()=>{const t=A.current;A.current=null,t&&k.current(t)},[]),P=$s(t=>{if(A.current={clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType},null===S.current){const t=p.current;let e=!1;const n=t.requestAnimationFrame(()=>{e=!0,S.current=null,_.current=null,M()});e||(S.current=n,_.current=t)}},[M]),C=$s(()=>{A.current=null,null!==S.current&&((_.current??p.current).cancelAnimationFrame(S.current),S.current=null,_.current=null),w.current()},[]);Ws(()=>()=>{A.current=null,null!==S.current&&((_.current??p.current).cancelAnimationFrame(S.current),S.current=null,_.current=null)},[]);const T=t.themeDirtyRef;return Vs(()=>{T&&(bn++,T.current=!0,v())},[u,v,T]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,resolvedForeground:l,resolvedBackground:c,currentTheme:u,transition:h,introEnabled:d,tableId:f,rafRef:y,renderFnRef:x,scheduleRender:v,cancelRender:b,hoverHandlerRef:k,hoverLeaveRef:w,onPointerMove:P,onPointerLeave:C}}function Qs(t,e,n,r){const o=t.getContext("2d");if(!o)return null;const i=Math.round(e[0]*r),s=Math.round(e[1]*r),a=i/e[0],l=s/e[1],c=e[0]+"px",u=e[1]+"px";return t.style.width!==c&&(t.style.width=c),t.style.height!==u&&(t.style.height=u),t.width===i&&t.height===s||(t.width=i,t.height=s),o.setTransform(a,0,0,l,0,0),o.translate(n.left,n.top),o}function Zs(){if("undefined"==typeof window)return 1;const t=window.devicePixelRatio||1,e=function(){if("undefined"==typeof window)return!1;const t="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,e=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return t||e}()?2:3;return Math.max(1,Math.min(t,e))}import{useCallback as Js}from"react";function ta(t,e,n,r){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:r,fn:e}:{key:void 0,fn:null}}var ea=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],na=3156e7;function ra(t){const e=t[1]-t[0];return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:na>e?t=>{const e=new Date(t);return`${ea[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*na>e?t=>{const e=new Date(t);return`${ea[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}function oa(t){if(!t)return;const e=[];for(const n of t)if("point"===n.type)e.push(n);else if("symbol"===n.type)e.push({pointId:n.pointId,x:n.x,y:n.y,r:de(n.size)});else if("glyph"===n.type){const t=pn(n.glyph,n.size);e.push({pointId:n.pointId,x:n.x+t.centerDx,y:n.y+t.centerDy,r:t.radius})}return e}import{line as ia}from"d3-shape";function sa(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}function aa(t,e,n,r,o,i){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],r=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=i;for(let n=0;e.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;l>r&&(i*=r/l),l>a-r&&(i*=(a-r)/l),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}var la=(t,e,n,r)=>{const o=e.filter(t=>"line"===t.type);for(const e of o){if(2>e.path.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,r.width*n,r.height),t.clip());const o=e.style.stroke||"#007bff",i=Sn(t,o)||o,s=e.style.strokeWidth||2,a=e.colorThresholds,l=e.rawValues;if(t.setLineDash(e.style.strokeDasharray?e.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),t.lineWidth=s,t.lineCap=e.style.strokeLinecap||"butt",e.style._edgeFade){aa(t,e.path,i,s,e.style.opacity??1,e.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const c=Rn(e.curve),u=a&&a.length>0&&l&&l.length===e.path.length,h=e._decayOpacities;if(h&&h.length===e.path.length&&!u){t.strokeStyle=i;const n=e.style.opacity??1;for(let r=0;e.path.length-1>r;r++)t.globalAlpha=.5*(h[r]+h[r+1])*n,t.beginPath(),t.moveTo(e.path[r][0],e.path[r][1]),t.lineTo(e.path[r+1][0],e.path[r+1][1]),t.stroke()}else if(u){let n=function(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),h=!0},r=function(){h&&(t.stroke(),h=!1)},o=null,s=null,c=null,u=null,h=!1;for(let h=0;e.path.length>h;h++){const[d,f]=e.path[h],y=l[h],p=sa(y,a,i);if(null!==o&&null!==u&&null!==c){if(p===u)t.lineTo(d,f);else{const e=[];for(const t of a){const n=t.value;(c>n||n>y)&&(n>c||y>n)||c===n||y===n||e.push({t:(n-c)/(y-c)})}e.sort((t,e)=>t.t-e.t);for(const l of e){const e=o+(d-o)*l.t,u=s+(f-s)*l.t,h=sa(c+(y-c)*Math.min(l.t+1e-4,1),a,i);t.lineTo(e,u),r(),n(h,e,u)}t.lineTo(d,f)}o=d,s=f,c=y,u=p}else n(p,d,f),o=d,s=f,c=y,u=p}r()}else{t.beginPath();const n=e.strokeGradient&&e.path.length>=2?$n(t,e.strokeGradient,e.path[0][0],0,e.path[e.path.length-1][0],0):null;if(t.strokeStyle=n||i,c)ia().x(t=>t[0]).y(t=>t[1]).curve(c).context(t)(e.path);else{const[n,r]=e.path[0];t.moveTo(n,r);for(let n=1;e.path.length>n;n++)t.lineTo(e.path[n][0],e.path[n][1])}t.stroke()}if(e.style.fill&&e.style.fillOpacity&&e.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=e.style.fillOpacity,t.fillStyle=In(t,e.style.fill,e.style.fill),c&&!u)ia().x(t=>t[0]).y(t=>t[1]).curve(c).context(t)(e.path);else{const[n,r]=e.path[0];t.moveTo(n,r);for(let n=1;e.path.length>n;n++)t.lineTo(e.path[n][0],e.path[n][1])}const n=e.path[0][0];t.lineTo(e.path[e.path.length-1][0],r.height),t.lineTo(n,r.height),t.closePath(),t.fill()}void 0!==n&&1>n&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ca(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ua(t,e,n=.3){ca(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function ha(t,e,n=.6){if(!ca(e))return;const r=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,o=e.cx??e.x??0,i=e.cy??e.y??0;t.beginPath(),t.arc(o,i,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function da(t,e,n,r=.35){ca(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",n?t.fill(n):t.fill())}import{area as fa,line as ya}from"d3-shape";function pa(t,e){const n=Rn(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const r=fa().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),r(e.topPath)}}var ga=(t,e,n,r)=>{const o=e.filter(t=>"area"===t.type);for(const e of o){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const o=e._introClipFraction;void 0!==o&&1>o&&(t.save(),t.beginPath(),t.rect(0,0,r.width*o,r.height),t.clip());const i=In(t,e.style.fill,"#4e79a7"),s=e._decayOpacities;if(s&&s.length===e.topPath.length){const n=e.style.fillOpacity??.7;t.fillStyle=i;for(let r=0;e.topPath.length-1>r;r++)t.globalAlpha=.5*(s[r]+s[r+1])*n,t.beginPath(),t.moveTo(e.topPath[r][0],e.topPath[r][1]),t.lineTo(e.topPath[r+1][0],e.topPath[r+1][1]),t.lineTo(e.bottomPath[r+1][0],e.bottomPath[r+1][1]),t.lineTo(e.bottomPath[r][0],e.bottomPath[r][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(s[n]+s[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const a=e.style.opacity??1;if(pa(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let r=-1/0;for(const t of e.bottomPath)t[1]>r&&(r=t[1]);const o=zn(t,e.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);t.fillStyle=o||i,t.globalAlpha=a}else t.globalAlpha=(e.style.fillOpacity??.7)*a,t.fillStyle=i;if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(pa(t,e),da(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a;const n=e.strokeGradient&&e.topPath.length>=2?$n(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const r=Rn(e.curve);if(t.beginPath(),r)ya().x(t=>t[0]).y(t=>t[1]).curve(r).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==o&&1>o&&t.restore(),n&&t.restore(),t.globalAlpha=1}},ma=(t,e,n,r)=>{const o=e.filter(t=>"point"===t.type);if(0!==o.length){t.save();try{const e=t.globalAlpha;for(const n of o)t.beginPath(),t.arc(n.x,n.y,n.r,0,2*Math.PI),t.globalAlpha=e*(n.style.opacity??n.style.fillOpacity??1),t.fillStyle=In(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=In(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),ha(t,n)}finally{t.restore()}}},xa=new Map;function va(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let n=xa.get(e);return n||(n=new Path2D(he(t.symbolType,t.size)),xa.size>256&&xa.clear(),xa.set(e,n)),n}catch{return null}}var ba=(t,e)=>{const n=t.globalAlpha;for(const r of e){if("symbol"!==r.type)continue;const e=r;if(0>=e.size)continue;const o=va(e);if(!o)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const i=(e.style.opacity??1)*(e._decayOpacity??1);e.style.fill&&(t.globalAlpha=n*i*(e.style.fillOpacity??1),t.fillStyle=In(t,e.style.fill,"#4e79a7"),t.fill(o)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*i,t.strokeStyle=In(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth??1,t.stroke(o)),t.restore()}t.globalAlpha=n};function ka(t,e,n,r,o){if(0>=e.size)return;const i=e.glyph;if(!i||!i.parts?.length)return;const s=un(i,e.size);if(0>=s.scale)return;const a=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=a)return;const l=e=>{const n=In(t,e,e);return"string"==typeof n?n:e},c=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(n,r),e.rotation&&t.rotate(e.rotation),t.translate(s.offsetX,s.offsetY),t.scale(s.scale,s.scale),t.globalAlpha=o*a*(e.style.fillOpacity??1);const u=yn(i,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");u&&e.ghostColor&&gn(t,i,c,e.accent,e.ghostColor,l),u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),gn(t,i,c,e.accent,void 0,l),t.restore()}function wa(t,e){const{x:n,y:r,w:o,h:i}=e,{tl:s,tr:a,br:l,bl:c}=function(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,r=t=>Math.max(0,Math.min(t??0,n));return{tl:r(e.tl),tr:r(e.tr),br:r(e.br),bl:r(e.bl)}}(e);t.beginPath(),t.moveTo(n+s,r),t.lineTo(n+o-a,r),a>0&&t.arcTo(n+o,r,n+o,r+a,a),t.lineTo(n+o,r+i-l),l>0&&t.arcTo(n+o,r+i,n+o-l,r+i,l),t.lineTo(n+c,r+i),c>0&&t.arcTo(n,r+i,n,r+i-c,c),t.lineTo(n,r+s),s>0&&t.arcTo(n,r,n+s,r,s),t.closePath()}function Aa(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}var Sa=(t,e,n,r)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)_a(t,e);else if(e.cornerRadii&&yi(e.cornerRadii)){const n=In(t,e.style.fill,Sn(t,"var(--semiotic-primary, #007bff)")),r=Aa(e),o=e.fillGradient&&"string"==typeof n?zn(t,e.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;t.fillStyle=o||n,wa(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=In(t,e.style.fill,Sn(t,"var(--semiotic-primary, #007bff)")),r=Aa(e),o=e.fillGradient&&"string"==typeof n?zn(t,e.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;t.fillStyle=o||n;const i=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-i,a),t.arcTo(s+l,a,s+l,a+i,i),t.lineTo(s+l,a+c-i),t.arcTo(s+l,a+c,s+l-i,a+c,i),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+i,a),t.arcTo(s,a,s,a+i,i),t.lineTo(s,a+c-i),t.arcTo(s,a+c,s+i,a+c,i),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-i),t.arcTo(s+l,a+c,s+l-i,a+c,i),t.lineTo(s+i,a+c),t.arcTo(s,a+c,s,a+c-i,i);break;default:t.moveTo(s,a+c),t.lineTo(s,a+i),t.arcTo(s,a,s+i,a,i),t.lineTo(s+l-i,a),t.arcTo(s+l,a,s+l,a+i,i),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=In(t,e.style.fill,Sn(t,"var(--semiotic-primary, #007bff)")),r=Aa(e),o=e.fillGradient&&"string"==typeof n?zn(t,e.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ua(t,e),t.globalAlpha=1}};function _a(t,e){const n=e.style.icon,r=e.style.iconPadding||2,o=Math.min(e.w,e.h)-r;if(0>=o)return;const i=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),i){const i=o+r,s=e.x+(e.w-o)/2;for(let r=e.y+e.h-o;r>=e.y-o;r-=i)t.drawImage(n,s,r,o,o)}else{const i=o+r,s=e.y+(e.h-o)/2;for(let r=e.x;e.x+e.w>r;r+=i)t.drawImage(n,r,s,o,o)}t.restore()}function Ma(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>128?"#000":"#fff"}function Pa(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var Ca=(t,e,n,r)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=n?.opacity&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Sn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ua(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):Pa(e.value),r=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,i=e.y+e.h/2;t.fillStyle=Ma(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,i)}}}finally{t.restore()}},Ta=(t,e,n,r)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const o=(e._decayOpacity??1)*(e.style?.opacity??1);1!==o&&(t.globalAlpha=o);const i=Sn(t,e.wickColor)||e.wickColor,s=60>r.height,a=s?Math.max(e.wickWidth,2):e.wickWidth,l=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=i,t.lineWidth=a,t.stroke()};if(s||l(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*r.height));t.fillStyle=i,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),r=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,i=Sn(t,o)||o;t.fillStyle=i,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1)),t.strokeStyle=i,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1))}s&&l(),t.restore()}},La={line:[ga,la,ma],area:[ga,ma],stackedarea:[ga,ma],scatter:[ma,ba],bubble:[ma,ba],heatmap:[Ca],bar:[Sa],swarm:[ma],waterfall:[(t,e,n,r)=>{Sa(t,e);const o=e.filter(t=>"rect"===t.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){t.save(),t.strokeStyle=Sn(t,s)||s,t.lineWidth=i?._connectorWidth??1,t.setLineDash([]);for(let e=0;o.length-1>e;e++){const r=o[e],i=o[e+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const l=n.y(s.cumEnd),c=r.x+r.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[Ta],mixed:[ga,la,ma],custom:[ga,Sa,Ca,la,ma,ba,(t,e)=>{const n=t.globalAlpha;for(const r of e)"glyph"===r.type&&ka(t,r,r.x,r.y,n);t.globalAlpha=n},Ta]};import{jsx as Na,jsxs as Da}from"react/jsx-runtime";import{jsx as Ea,jsxs as Ra}from"react/jsx-runtime";function Ia(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function za({hover:t}){const e=t.data??{},n=e.y??e.value,r=e.x??e.time;if(void 0===n&&void 0===r){const t=Ls(e);if(null!=t.title||t.entries.length>0)return Ra("div",{className:"semiotic-tooltip",style:Es,children:[null!=t.title&&Ea("div",{style:{fontWeight:600,marginBottom:t.entries.length?2:0},children:t.title+""}),t.entries.map(t=>Ra("div",{style:{opacity:.7,fontSize:11},children:[t.key,":"," ",Ea("span",{style:{fontWeight:600},children:Ia(t.value)})]},t.key))]})}return Ra("div",{className:"semiotic-tooltip",style:Es,children:[Ea("div",{style:{fontWeight:600,marginBottom:2},children:Ia(n)}),Ea("div",{style:{opacity:.7,fontSize:11},children:Ia(r)})]})}za.ownsChrome=!0;import{jsx as $a,jsxs as Wa}from"react/jsx-runtime";var Fa={top:20,right:20,bottom:30,left:40},Oa=Fi;function Ya(t){if(t)return"x"===t.dimension?"pan-y":"y"===t.dimension?"pan-x":"none"}var Ba=c(l(function(l,c){const{chartType:u,runtimeMode:h,data:d,chunkThreshold:f,chunkSize:y,xAccessor:p,yAccessor:g,accessorRevision:m,colorAccessor:x,sizeAccessor:v,symbolAccessor:b,symbolMap:k,groupAccessor:w,lineDataAccessor:S,curve:P,normalize:C,baseline:T,stackOrder:L,binSize:N,valueAccessor:D,arrowOfTime:E="right",windowMode:R="sliding",windowSize:I=200,timeAccessor:$,xExtent:W,yExtent:F,extentPadding:O=.1,scalePadding:Y,sizeRange:B,size:j=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,lineStyle:U,pointStyle:K,areaStyle:Q,barStyle:Z,waterfallStyle:J,swarmStyle:tt,barColors:et,colorScheme:nt,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,band:st,gradientFill:at,lineGradient:lt,areaGroups:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:ft,candlestickStyle:yt,showAxes:pt=!0,axes:gt,xLabel:mt,yLabel:xt,yLabelRight:vt,xFormat:bt,yFormat:kt,axisExtent:wt,tickFormatTime:At,tickFormatValue:St,hoverAnnotation:_t,tooltipContent:Mt,customHoverBehavior:Pt,customClickBehavior:Ct,enableHover:Tt,hoverRadius:Lt=30,tooltipMode:Nt,annotations:Dt,autoPlaceAnnotations:Et,svgAnnotationRules:Rt,showGrid:It,legend:zt,legendHoverBehavior:$t,legendClickBehavior:Wt,legendHighlightedCategory:Ft,legendIsolatedCategories:Ot,legendPosition:Yt,legendLayout:Bt,legendCategoryAccessor:jt,onCategoriesChange:Ht,backgroundGraphics:Xt,foregroundGraphics:Gt,canvasPreRenderers:Vt,svgPreRenderers:qt,title:Ut,categoryAccessor:Kt,brush:Zt,onBrush:Jt,decay:te,pulse:ee,transition:ne,animate:re,staleness:oe,heatmapAggregation:ie,heatmapXBins:se,heatmapYBins:ae,showValues:le,heatmapValueFormat:ce,marginalGraphics:ue,pointIdAccessor:de,xScaleType:fe,yScaleType:ye,accessibleTable:pe=!0,description:ge,summary:me,linkedCrosshairName:xe,linkedCrosshairSourceId:ve,customLayout:be,onLayoutError:ke,layoutConfig:we,layoutSelection:Ae}=l,Se=a().replace(/:/g,""),_e=e(!1),Me=e({w:-1,h:-1}),Pe=e(!1),Ce=Ks({sizeProp:j,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:Fa,animate:re,transitionProp:ne,themeDirtyRef:_e}),Te=Pi(),Le=Ni(),{reducedMotionRef:Ne,responsiveRef:De,size:Ee,currentTheme:Re,transition:Ie,introEnabled:ze,tableId:$e,rafRef:We,renderFnRef:Fe,scheduleRender:Ye,cancelRender:Be}=Ce;let je=Ce.margin;if(ue){const t=60,e={...Ce.margin};ue.top&&t>e.top&&(e.top=t),ue.bottom&&t>e.bottom&&(e.bottom=t),ue.left&&t>e.left&&(e.left=t),ue.right&&t>e.right&&(e.right=t),je=e}const Xe=Ee[0]-je.left-je.right,Ve=Ee[1]-je.top-je.bottom,qe=o(()=>_(d),[d]),Ue=_t??Tt,Ke=e(null),Ze=e(null),[Je,nn]=n(0),rn=e(0),[on,sn]=n(null),an=(t,e)=>"function"==typeof t?t({size:Ee,margin:je,scales:e}):t,ln=an(Gt,on),cn=an(Xt,on),un=e(null),hn=e(null),dn=e(void 0),[fn,yn]=n(null),gn=e(Oa.primary),mn=e(function(){let t=-1,e=Fi;return{resolve(n){if(!n)return Fi;const r=bn;return r===t||(e=function(t){if(!t)return Fi;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),i=e.getPropertyValue("--semiotic-primary").trim(),s=r||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:l||Fi.axisStroke,tickText:s||Fi.tickText,crosshair:s?Oi(s,"66"):Fi.crosshair,hoverFill:c?Oi(c,"4D"):Fi.hoverFill,hoverStroke:s?Oi(s,"99"):Fi.hoverStroke,pointRing:c||Fi.pointRing,primary:i||Fi.primary,background:c||Fi.background}:Fi}(n),t=r),e},invalidate(){t=-1}}}()),xn=e(!1),vn=e(new He),kn=e([]),wn=e(jt),An=e(Ht);wn.current=jt,An.current=Ht;const[Sn,_n]=n(!1),[Mn,Pn]=n([]),[Cn,Tn]=n([]),Ln="streaming"===h||["bar","swarm","waterfall"].includes(u),Nn=Ri(o(()=>({chartType:u,runtimeMode:Ln?"streaming":"bounded",windowSize:I,windowMode:R,arrowOfTime:Ln?E:"right",extentPadding:O,scalePadding:Y,axisExtent:wt,xAccessor:p,yAccessor:g,accessorRevision:m,timeAccessor:Ln?$:void 0,valueAccessor:D,colorAccessor:x,sizeAccessor:v,symbolAccessor:b,symbolMap:k,groupAccessor:w||(S?"_lineGroup":void 0),categoryAccessor:Kt,lineDataAccessor:S,xScaleType:fe,yScaleType:ye,xExtent:W,yExtent:F,sizeRange:B,binSize:N,normalize:C,baseline:T,stackOrder:L,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,band:st,gradientFill:!0===at?{topOpacity:.8,bottomOpacity:.05}:!1===at?void 0:at,areaGroups:ct?new Set(ct):void 0,lineGradient:lt,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:ft,candlestickStyle:yt,lineStyle:U,pointStyle:K,areaStyle:Q,swarmStyle:tt,waterfallStyle:J,colorScheme:nt,barColors:et,barStyle:Z,annotations:Dt,decay:te,pulse:ee,transition:Ie,introAnimation:ze,staleness:oe,heatmapAggregation:ie,heatmapXBins:se,heatmapYBins:ae,showValues:le,heatmapValueFormat:ce,pointIdAccessor:de,curve:P,themeCategorical:Re?.colors?.categorical,themeSemantic:z(Re),themeSequential:Re?.colors?.sequential,themeDiverging:Re?.colors?.diverging,customLayout:be,onLayoutError:ke,layoutConfig:we,layoutMargin:je}),[u,I,R,E,O,Y,wt,p,g,m,$,D,fe,ye,x,v,b,k,w,Kt,S,W,F,B,N,C,T,L,rt,ot,it,st,at,lt,ct,ut,ht,dt,ft,yt,U,K,Q,tt,J,Z,nt,et,Dt,te,ee,Ie?.duration,Ie?.easing,ze,oe,ie,se,ae,le,ce,Ln,de,P,Re,be,ke,we,je])),Dn=e(null);Dn.current||(Dn.current=new Oe(Nn));const En=function(t,e,n,r){return Js(()=>{const o=e.current,i=n.current;if(!i||!o)return;const s=function(t,e){if(!e)return[];const n=new Set,r=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const i=t+"";n.has(i)||(n.add(i),r.push(i))}return r}(t.current?.getData()??[],o);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(s,r.current)||(r.current=s,i(s))},[e,n,r,t])}(Dn,wn,An,kn);tn(Dn,Nn,_e,Ye),en(Dn,Ae,_e,Ye);const Rn=e(null);Rn.current||(Rn.current=new M(t=>{const e=Dn.current;e&&e.ingest(t)&&(_e.current=!0,Ye())},{chunkThreshold:f,chunkSize:y})),r(()=>{Rn.current?.updateChunkOptions({chunkThreshold:f,chunkSize:y})},[f,y]);const In=i(t=>{Rn.current?.push(t)},[]),zn=i(t=>{Rn.current?.pushMany(t)},[]),$n=i(()=>{Rn.current?.clear(),Dn.current?.clear(),_e.current=!0,Ye()},[Ye]);s(c,()=>({push:In,pushMany:zn,remove:t=>{Rn.current?.flush();const e=Dn.current?.remove(t)??[];return e.length>0&&(un.current&&e.some(t=>t===un.current?.data)&&(un.current=null,yn(null)),_e.current=!0,Ye()),e},update:(t,e)=>{Rn.current?.flush();const n=Dn.current?.update(t,e)??[];return n.length>0&&(_e.current=!0,Ye()),n},clear:$n,getData:()=>(Rn.current?.flush(),Dn.current?.getData()??[]),getScales:()=>Dn.current?.scales??null,getExtents:()=>Dn.current?.getExtents()??null,getCustomLayout:()=>Dn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Dn.current?.lastCustomLayoutFailure??null}),[In,zn,$n,Ye]),r(()=>{if(d){if(S&&qe.length>0&&"object"==typeof qe[0]&&null!==qe[0]){const t="string"==typeof S?S:"coordinates";if(Array.isArray(qe[0][t])){const e=[];for(const n of qe){const r=n[t];if(Array.isArray(r)){const t=n.label||n.id||n.key;if(null!=t)for(const n of r)e.push({...n,_lineGroup:t});else for(const t of r)e.push(t)}}return void Rn.current?.setBoundedData(e)}}Rn.current?.setBoundedData(qe)}},[d,qe,S]);const{hoverHandlerRef:Wn,hoverLeaveRef:Fn,onPointerMove:jn,onPointerLeave:Hn}=Ce;Wn.current=t=>{if(!Ue)return;const e=Ke.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-je.left,o=t.clientY-n.top-je.top;if(0>r||r>Xe||0>o||o>Ve)return void(un.current&&(un.current=null,hn.current=null,yn(null),Pt&&(Pt(null),_e.current=!0),Ye()));const i=Dn.current;if(!i||0===i.scene.length)return;const s=ws(Lt,t.pointerType),a=Yn(i.scene,r,o,s,i.quadtree,i.maxPointRadius),l="multi"===Nt,c=()=>{un.current&&(un.current=null,hn.current=null,yn(null),Pt&&Pt(null),Ye())};if(!a&&!l)return void c();const h=l||!a?r:a.x,d=l||!a?o:a.y,f=a?.datum?Qt(a.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=Ss(f,h,d,null!=g?{xValue:g,xPx:h}:void 0);if(l&&i.scene.length>0&&i.scales){const t=function(t,e,n=30){const r=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const i=Bn(On(t.path,t.curve),e,n);if(null===i)continue;const s=Zn(t.path,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:i,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const i=On(t.topPath,t.curve),s=On(t.bottomPath,t.curve),a=Bn(i,e,n);if(null===a)continue;const l=Bn(s,e,n),c=Zn(t.topPath,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:l??void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return r}(i.scene,h,Math.max(s,Xe));if(t.length>0){const e=i.scales.y.invert,n=gn.current,r=y?y(h):h;if(a)m.xValue=r,m.xPx=h;else{const t={xValue:r};"string"==typeof p&&(t[p]=r),m=Ss(t,h,d,{xValue:r,xPx:h})}m.allSeries=t.map(t=>{const r=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===u&&null!=o?r-o:r,valuePx:t.y,color:t.color||n,datum:Qt(t.datum,i.resolvedRibbons)}})}}a||m.allSeries?.length?(un.current=m,hn.current=a?.node??null,yn(m),Pt&&(Pt(m),_e.current=!0),Ye()):c()},Fn.current=()=>{un.current&&(un.current=null,hn.current=null,yn(null),Pt&&(Pt(null),_e.current=!0),Ye())};const Xn=e(()=>{});Xn.current=t=>{if(!Ct)return;const e=Ke.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-je.left,o=t.clientY-n.top-je.top;if(0>r||r>Xe||0>o||o>Ve)return void Ct(null);const i=Dn.current;if(!i||0===i.scene.length)return void Ct(null);const s=ws(Lt,dn.current),a=Yn(i.scene,r,o,s,i.quadtree,i.maxPointRadius);if(!a)return void Ct(null);const l=a.datum||{},c=i.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;Ct(Ss(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const Gn=i(t=>Xn.current(t),[]),Vn=e(-1),qn=e(null),Un=e(null),Kn=i(t=>{const e=Dn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(Un.current&&Un.current.version===n)r=Un.current.graph;else{const t=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const t=pn(n.glyph,n.size);e.push({x:n.x+t.centerDx,y:n.y+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:"_default"});break}case"line":{const t=n,r=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.path.length>n&&r.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const t=n,r=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.topPath.length>n&&r.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:r[n],shape:"circle",group:o});break}case"rect":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===t.length)return;r=Jn(t),Un.current={version:n,graph:r}}const o=Vn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Vn.current=0;const n=r.flat[0];qn.current={shape:n.shape,w:n.w,h:n.h};const o=or({...n,datum:Qt(n.datum,e.resolvedRibbons)});return un.current=o,yn(o),Pt&&Pt(o),void Ye()}const i=tr(r,o),s=er(t.key,i,r);if(null===s)return;if(t.preventDefault(),0>s)return Vn.current=-1,qn.current=null,un.current=null,hn.current=null,yn(null),Pt&&Pt(null),void Ye();Vn.current=s;const a=r.flat[s];qn.current={shape:a.shape,w:a.w,h:a.h};const l=or({...a,datum:Qt(a.datum,e.resolvedRibbons)});un.current=l,yn(l),Pt&&Pt(l),Ye()},[Pt,Ye]),Qn=i(t=>{dn.current=t.pointerType,Vn.current=-1,qn.current=null,jn(t)},[jn]),nr=i(t=>{dn.current="mouse",Vn.current=-1,qn.current=null,jn({clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"})},[jn]),rr=i(t=>{dn.current=t.pointerType},[]);Fe.current=()=>{We.current=null;const t=Ke.current,e=Ze.current;if(!t||!e)return;const n=Dn.current;if(!n)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=n.advanceTransition(Ne.current?r+1e6:r),i=!Ne.current&&o,s=Me.current.w!==Xe||Me.current.h!==Ve,a=_e.current||o||s,l=n.consumeStylePaintPending();let c=!1;const h=n.getLastUpdateResult(),d=vn.current.beforeCompute(h,i);!a||i&&!s||(n.computeScene({width:Xe,height:Ve}),Me.current={w:Xe,h:Ve},c=!0,En()),vn.current.afterCompute(d,c,s);const f=function(t,e,n,r){const o=r.current,i=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&t.hasActivePulsesAt(e),a=!(n||i||!s&&!o)&&t.refreshPulse(e);return r.current=s,{changed:a,pending:s}}(n,r,c,Pe),y=Zs(),m=mn.current.resolve(t);gn.current=m.primary;const x=cr(oe,n.lastIngestTime>0?r-n.lastIngestTime:0),v=oe&&x.isStale;if(a||l||f.changed){const e=Qs(t,Ee,je,y);if(e){if(e.clearRect(-je.left,-je.top,Ee[0],Ee[1]),oe&&1>x.alpha&&(e.globalAlpha=x.alpha),Wi(e,{background:q,hasBackgroundGraphics:!!Xt,themeBackground:m.background,x:-je.left,y:-je.top,width:Ee[0],height:Ee[1]}),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Xe,Ve),e.clip()),Vt&&n.scales)for(const t of Vt)e.save(),t(e,n.scene,n.scales,{width:Xe,height:Ve}),e.restore();const t=be?La.custom:La[u];if(t&&n.scales)for(const r of t)r(e,n.scene,n.scales,{width:Xe,height:Ve});e.restore(),oe&&1>x.alpha&&(e.globalAlpha=1)}}const b=!!(Ue&&un.current&&n.scales),k=!!(hn.current&&Array.isArray(_t)&&_t.some(t=>t&&"object"==typeof t&&"highlight"===t.type)),w=b||k;if(w||xn.current){const t=Qs(e,Ee,je,y);if(t&&(t.clearRect(-je.left,-je.top,Ee[0],Ee[1]),b&&un.current&&function(t,e,n,r,o,i,s){if(!1===o.crosshair)return;const a=e.allSeries,l=a&&a.length>0,c=e.xPx??e.x;t.save();const u="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=u.stroke||s.crosshair,t.lineWidth=u.strokeWidth||1,t.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(l?c:e.x,0),t.lineTo(l?c:e.x,r),t.stroke(),l||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),l){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(c,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(i)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,un.current,Xe,Ve,"object"==typeof Ue?Ue:{},hn.current,m),k&&hn.current&&Array.isArray(_t))){const e=_t.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,r,o){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of e){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=e.opacity??1,t.stroke(),t.restore()}}(t,n.scene,hn.current,e,m)}xn.current=w}a&&t&&t.setAttribute("aria-label",Zi(n.scene,u+" chart"));const A=_e.current;if(_e.current=A&&i&&!c,A&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!on||t(on.x.domain()[0])!==t(n.scales.x.domain()[0])||t(on.x.domain()[1])!==t(n.scales.x.domain()[1])||t(on.y.domain()[0])!==t(n.scales.y.domain()[0])||t(on.y.domain()[1])!==t(n.scales.y.domain()[1])||on.x.range()[0]!==n.scales.x.range()[0]||on.x.range()[1]!==n.scales.x.range()[1]||on.y.range()[0]!==n.scales.y.range()[0]||on.y.range()[1]!==n.scales.y.range()[1])&&sn(n.scales),ue){const t=n.getData(),e="function"==typeof p?p:t=>t[p||"x"],r="function"==typeof g?g:t=>t[g||"y"];Pn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Tn(t.map(t=>r(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Dt&&Dt.length>0||be)&&(c||i))||!c&&33>r-rn.current||(nn(t=>t+1),rn.current=r),oe?.showBadge&&_n(!!v),(i||null!=n.activeTransition||f.pending)&&Ye()},Di({hydrated:Te,wasHydratingFromSSR:Le,storeRef:Dn,dirtyRef:_e,renderFnRef:Fe,cancelRender:Be,cleanup:()=>Rn.current?.clear()}),r(()=>{_e.current=!0,Ye()},[u,Xe,Ve,pt,q,Xt,U,Vt,Ye]),ur(oe,Dn,_e,Ye,Sn,_n);const ir=o(()=>{if(bt||At)return;const t=Dn.current;return t?.xIsDate&&on?ra(on.x.domain()):void 0},[bt,At,on]),sr=bt||At||ir,ar=Ue&&fn?Mt?Mt(fn):$a(za,{hover:fn}):null,lr=ar?$a(Is,{x:fn.x,y:fn.y,containerWidth:Xe,containerHeight:Ve,margin:je,className:"stream-frame-tooltip",children:ar}):null,hr=qn.current,fr=$a(bs,{active:Vn.current>=0,hoverPoint:fn,margin:je,size:Ee,shape:hr?.shape,width:hr?.w,height:hr?.h}),yr=ta(p,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),pr=ta(g,D,"__semiotic_resolvedY","__semiotic_resolvedValue"),gr=yr.key,mr=pr.key,xr=function(t,e,n){return r=>{if(!r||!n||!t.fn&&!e.fn)return r;let o=!1;const i=r.map(n=>{const r=t.fn&&t.key&&!(t.key in n),i=e.fn&&e.key&&!(e.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[t.key]=t.fn(n)),i&&(s[e.key]=e.fn(n)),s});return o?i:r}}(yr,pr,Dt&&Dt.length>0||!1);if(bi||!Te&&Le){const e=Dn.current;e&&d&&(e.ingest({inserts:qe,bounded:!0}),e.computeScene({width:Xe,height:Ve}));const n=e?.scene??[],r=e?.scales??null,o=an(Gt,r),i=an(Xt,r),s=sr||(()=>{if(e?.xIsDate&&r)return ra(r.x.domain())})();return Wa("div",{ref:De,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":ge||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:H?"100%":Ee[0],height:X?"100%":Ee[1]},children:[$a(ps,{summary:me}),Wa("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[$a("g",{transform:`translate(${je.left},${je.top})`,children:i}),Wa("g",{transform:`translate(${je.left},${je.top})`,children:[q&&$a("rect",{x:0,y:0,width:Xe,height:Ve,fill:q}),qt&&r&&qt.map((e,o)=>$a(t.Fragment,{children:e(n,r,{width:Xe,height:Ve})},"svgpre-"+o)),n.map((t,e)=>function(t,e,n){switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const r="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return pi("path",{d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+e)}case"area":{const r=t;if(0===r.topPath.length)return null;const o=`M${r.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(r.clipRect){const t=`${n?n+"-":""}area-clip-${e}`;return gi("g",{children:[pi("defs",{children:pi("clipPath",{id:t,children:pi("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})}),pi("path",{d:o,fill:xi(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+e)}return pi("path",{d:o,fill:xi(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+e)}case"point":{const n=t;return pi("circle",{cx:n.x,cy:n.y,r:n.r,fill:xi(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+e)}case"symbol":return function(t,e){const n=he(t.symbolType,t.size,t.path);return pi("path",{d:n,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?xi(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},"symbol-"+e)}(t,e);case"glyph":return vi(t,t.x,t.y,`${n??""}glyph-${t.pointId??e}`);case"rect":{const n=t;return pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:xi(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+e)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(n.fill),s=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return gi("g",{children:[pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),pi("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+e)}case"candlestick":{const n=t,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return gi("g",{children:[pi("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),pi("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+e)}default:return null}}(t,e,Se)).filter(Boolean)]})]}),$a(hi,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,scales:r,showAxes:pt,axes:gt,xLabel:mt,yLabel:xt,yLabelRight:vt,xFormat:s,yFormat:kt||St,axisExtent:wt,showGrid:It,title:Ut,legend:zt,legendHoverBehavior:$t,legendClickBehavior:Wt,legendHighlightedCategory:Ft,legendIsolatedCategories:Ot,legendPosition:Yt,legendLayout:Bt,foregroundGraphics:Ge(o,Qe(Dn.current?.customLayoutOverlays,Ae??null)),marginalGraphics:ue,xValues:[],yValues:[],annotations:Dt,autoPlaceAnnotations:Et,svgAnnotationRules:Rt,annotationFrame:0,xAccessor:gr,yAccessor:mr,annotationData:xr(e?.getData()),pointNodes:oa(e?.scene),curve:"string"==typeof P?P:void 0,linkedCrosshairName:xe,linkedCrosshairSourceId:ve})]})}return Wa("div",{ref:De,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":ge||("string"==typeof Ut?Ut:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Ee[0],height:X?"100%":Ee[1],overflow:"visible",touchAction:Ya(Zt)},onKeyDown:Kn,children:[pe&&$a(gs,{tableId:$e}),pe&&$a(fs,{scene:Dn.current?.scene??[],chartType:u+" chart",tableId:$e,chartTitle:"string"==typeof Ut?Ut:void 0}),$a(ps,{summary:me}),$a(ms,{hoverPoint:fn}),Wa("div",{role:"img","aria-label":ge||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Ue?Qn:void 0,onMouseMove:Ue?nr:void 0,onPointerLeave:Ue?Hn:void 0,onMouseLeave:Ue?Hn:void 0,onPointerDown:Ue||Ct?rr:void 0,onClick:Ct?Gn:void 0,children:[cn&&$a("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:$a("g",{transform:`translate(${je.left},${je.top})`,children:cn})}),$a(li,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,scales:on,showAxes:pt,axes:gt,showGrid:It,xFormat:sr,yFormat:kt||St,axisExtent:wt}),$a("canvas",{ref:Ke,"aria-label":Zi(Dn.current?.scene??[],u+" chart"),style:{position:"absolute",left:0,top:0}}),$a("canvas",{ref:Ze,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),$a(hi,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,scales:on,showAxes:pt,axes:gt,xLabel:mt,yLabel:xt,yLabelRight:vt,xFormat:sr,yFormat:kt||St,axisExtent:wt,showGrid:It,title:Ut,legend:zt,legendHoverBehavior:$t,legendClickBehavior:Wt,legendHighlightedCategory:Ft,legendIsolatedCategories:Ot,legendPosition:Yt,legendLayout:Bt,foregroundGraphics:Ge(ln,Qe(Dn.current?.customLayoutOverlays,Ae??null)),marginalGraphics:ue,xValues:Mn,yValues:Cn,annotations:Dt,autoPlaceAnnotations:Et,svgAnnotationRules:Rt,annotationFrame:Je,xAccessor:gr,yAccessor:mr,annotationData:xr(Dn.current?.getData()),pointNodes:oa(Dn.current?.scene),curve:"string"==typeof P?P:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==q&&!Xt,linkedCrosshairName:xe,linkedCrosshairSourceId:ve}),(Zt||Jt)&&$a(A,{width:Xe,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:je,dimension:Zt?.dimension??"xy",scales:on,onBrush:Jt??(()=>{}),binSize:N,snap:Zt?.snap,binBoundaries:Zt?.binBoundaries??("bar"===u?Dn.current?.getBinBoundaries():void 0),snapDuring:Zt?.snapDuring,streaming:"streaming"===h}),oe?.showBadge&&$a(dr,{isStale:Sn,position:oe.badgePosition}),fr,lr]})]})}));Ba.displayName="StreamXYFrame";var ja=Ba;import{useRef as Ha,useState as Xa,useEffect as Ga,useMemo as Va,useCallback as qa,useImperativeHandle as Ua,forwardRef as Ka,memo as Qa}from"react";var Za={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ja={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},tl=class{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=t*e*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?el(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}};function el(t,e,n,r){if(t.circular&&t.segments)return void function(t,e,n,r,o){const i=t.length,s=e*i,a=Math.min(Math.floor(s),i-1),l=s-a,[c,u,h,d]=t[a];nl(c,u,h,d,l,o);const f=d.x-c.x,y=d.y-c.y,p=Math.sqrt(f*f+y*y);if(p>.001){const t=f/p;o.x+=-y/p*n*r*2,o.y+=t*n*r*2}}(t.segments,e,n,t.halfWidth,r);if(!t.points)return r.x=0,void(r.y=0);const[o,i,s,a]=t.points;nl(o,i,s,a,e,r);const l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const e=l/u;r.x+=-c/u*n*t.halfWidth*2,r.y+=e*n*t.halfWidth*2}}function nl(t,e,n,r,o,i){const s=1-o,a=s*s,l=a*s,c=o*o,u=c*o;i.x=l*t.x+3*a*o*e.x+3*s*c*n.x+u*r.x,i.y=l*t.y+3*a*o*e.y+3*s*c*n.y+u*r.y}function rl(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function ol(t,e){var n,r=[],o=[],i=[],s={},a=[];function l(t){i[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],i[e]&&l(e)})}function c(t){var e,r,h=!1;for(o.push(t),i[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,o),h=!0):i[r]||(h=c(r));if(h)l(t);else for(e=0;a[t].length>e;e++){var d=s[r=a[t][e]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(t,n){var o=[].concat(n).concat(t);e?e(o):r.push(o)}function h(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),o=Array(e),i=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,s[l]=-1,a[l]=[];var c,u=0,h=[],d=[];function f(e){var l=[e],c=[e];for(n[e]=r[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>i[e]){for(var y=i[e];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(r[e]=0|Math.min(r[e],r[p])),0>s[p]||a[e].push(s[p])}i[e]=y}else{if(r[e]===n[e]){var g=[],m=[],x=0;for(y=l.length-1;y>=0;--y){var v=l[y];if(o[v]=!1,g.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){l.length=y;break}}h.push(g);var b=Array(x);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--x]=m[y][k];d.push(b)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;d.length>l;l++){var y=d[l];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&c.push(y[p]);d[l]=c}}return{components:h,adjacencyList:d}}(t),o=r.components.filter(function(t){return t.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var l=o[n];return!!l&&{leastVertex:i,adjList:t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})})}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];i[+g]=!1,s[g]={}}c(n),n+=1}else n=d}return e?void 0:r}function il(t){return t.y0-t.y1>0?"up":"down"}function sl(t,e){return e(t.source)==e(t.target)}function al(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function ll(t){return t.target.x0-t.source.x1}function cl(t,e){var n=hl(t),r=ll(e)/Math.tan(n);return"up"==il(t)?t.y1-r:t.y1+r}function ul(t,e){var n=hl(t),r=ll(e)/Math.tan(n);return"up"==il(t)?t.y1+r:t.y1-r}function hl(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function dl(t,e){return e(t)}function fl(t){return pl(t.source)}function yl(t){return pl(t.target)}function pl(t){return(t.y0+t.y1)/2}function gl(t){return t.virtual?0:t.value}function ml(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!sl(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!sl(t,e)?r+1:r}),n+r}function xl(t){return t.target.depth}function vl(t,e){return t.sourceLinks.length?t.depth:e-1}function bl(t,e){return t.y0-e.y0}function kl(t,e){return e.y0-t.y0}function wl(t,e){return t.y1-e.y1}function Al(t,e){return e.y1-t.y1}function Sl(t,e){return Ml(t.source,e.source)||t.index-e.index}function _l(t,e){return Ml(t.target,e.target)||t.index-e.index}function Ml(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Pl(t,e){return Cl(t)==Cl(e)?"bottom"==t.circularLinkType?kl(t,e):bl(t,e):Cl(e)-Cl(t)}function Cl(t){return t.target.column-t.source.column}function Tl(t,e){return Ll(t)==Ll(e)}function Ll(t){return t.y0-t.y1>0?"up":"down"}import{min as Nl}from"d3-array";function Dl(t,e,n,r,o){let i=t;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=Nl(i.links,function(t){return t.source.y0});i.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=i.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),El(i.links.filter(function(t){return"top"==t.circularLinkType}),e,n),El(i.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),i.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,sl(t,e)&&al(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,l=t.circularLinkType,c=i.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?kl:bl);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=i.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Al:wl),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(i.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,r=t.target.x0,o=t.y1,i=(e+r)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(t)}),i}function El(t,e,n){t.sort(Pl);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var i=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(sl(t,e)&&al(t))t.circularPathData.verticalBuffer=i+t._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Rl(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=l>i?l:i}}t.circularPathData.verticalBuffer=i+t._circularWidth/2}}),t}function Rl(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as Il,max as zl,sum as $l,mean as Wl,group as Fl,groups as Ol}from"d3-array";function Yl(t){return function(){return t}}function Bl(t){return t.index}function jl(t){return t.nodes}function Hl(t){return t.links}function Xl(t,e,n){var r=Ol(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,i){var s=o.length;if(e)o.sort(e);else if(i>0){var a=new Map;o.forEach(function(t,e){var n,r,o,i=(r=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=pl(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=pl(t.target)*e,r+=e}}),r>0?o/r:NaN);a.set(t,{bc:i,idx:e})}),o.sort(function(t,e){var n=a.get(t),r=a.get(e),o=n.bc,i=r.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?ml(e,n)-ml(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==r.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==ml(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function Gl(t,e,n,r,o,i){var s=Ol(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,l=i;l>0;--l)c(a*=.99,n),u();function c(e,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&ml(o,n)>0){var l=Wl(o.sourceLinks,yl),c=Wl(o.targetLinks,fl),u=l&&c?(l+c)/2:l||c;if(u){var h=(u-pl(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==r-1&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=Wl(o.sourceLinks,yl),f=Wl(o.targetLinks,fl),y=((d&&f?(d+f)/2:d||f)-pl(o))*e;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var i,s,a,l=t.y0,c=n.length;for(n.sort(e||Ml),a=0;c>a;++a)(s=l-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),l=i.y1+r;if((s=l-r-t.y1)>0)for(l=i.y0-=s,i.y1-=s,a=c-2;a>=0;--a)(s=(i=n[a]).y1+o-l)>0&&(i.y0-=s,i.y1-=s),l=i.y0})}}function Vl(t){t.nodes.forEach(function(t){t.sourceLinks.sort(_l),t.targetLinks.sort(Sl)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function ql(){var t=0,e=0,n=1,r=1,o=24,i=8,s=null,a=Bl,l=vl,c=void 0,u=32,h=2,d=jl,f=Hl;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=n,d.y1=r,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return Fl(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=rl(n,r)),"object"!=typeof o&&(o=t.target=rl(n,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(d,a),function(t,e){var n=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var i=t.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var l=ol(r);l.sort(function(t,e){return t.length-e.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||c[r]&&c[r][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(d,c),function(t,e){var n=0,r=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,t.nodes.forEach(function(t){dl(t,e)!=dl(o.source,e)&&dl(t,e)!=dl(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),sl(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max($l(t.sourceLinks,gl),$l(t.targetLinks,gl)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,n){var r,o,i;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.depth=i,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.height=i,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,i):t.column})}(d,c,l);var f=i;if(null!==s){var y=Ol(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=zl(y,function(t){return t.length});p>1&&(f=Math.max(1,(r-e)*s/(p-1)))}(function(t,e,n){var r=Ol(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=Il(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/$l(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var i=zl(t.nodes,function(t){return t.column});t.nodes.forEach(i>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/i),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,o),Xl(d,c,a),Gl(d,c,a,f,f,u),Vl(d),Dl(d,a,h,10,8),Xl(d,c,a),Gl(d,c,a,f,f,u),Vl(d),Dl(d,a,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return dl(n.source,e)==dl(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Tl(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=cl(e,t);return t.y1-n}if(e.target.column>t.target.column)return cl(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y0=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return dl(n.target,e)==dl(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Tl(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=ul(e,t);return t.y0-n}if(e.source.column>t.source.column)return ul(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y1=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(e){return(e-i)/(s-i)*(t.y1-t.y0)+t.y0};var i=Il(e,function(t){return t.y0}),s=zl(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-i);1>a?(e.forEach(function(t){t.y0=r(t.y0),t.y1=r(t.y1)}),n.forEach(function(t){t.y0=r(t.y0),t.y1=r(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=r(t.y0)-t.y0;t.y0=r(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(d),Dl(d,a,h,10,8)}(y),y}return y.update=function(t){return Vl(t),Dl(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(i=+t,y):i},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:Yl(t),y):d},y.links=function(t){return arguments.length?(f="function"==typeof t?t:Yl(t),y):f},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Yl(t),y):a},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:Yl(t),y):l},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[t,e],[n,r]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],r=+o[1],y):[n-t,r-e]},y}import{interpolateNumber as Ul}from"d3-interpolate";import{line as Kl,curveLinearClosed as Ql}from"d3-shape";var Zl=t=>{let e,n,r,o,i,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,i=t.source.x1,s=t.target.x0,a=Ul(i,s),l=a(.5),c=a(.5),`M${e},${i}C${e},${l} ${n},${c} ${n},${s}L${r},${s}C${r},${c} ${o},${l} ${o},${i}Z`;const u=t.sankeyWidth/2,h=Ul(t.source.x1,t.target.x0),{pathD:d}=function(t){const{sx:e,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:l}=t,c=(n+r)/2,u=(i+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${i} ${o},${i}`,`L${o},${s}`,`C${l},${s} ${a},${r} ${e},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function Jl(t){const e=t.sankeyWidth/2,n=(t._circularWidth??t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-e}L${n+a},${o-e}L${n+a},${o+e}L${n},${o+e}ZM${i},${s-e}L${i-l},${s-e}L${i-l},${s+e}L${i},${s+e}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*e}L${l},${i-h*e}L${l+n},${i-h*e+h*d}L${l+n},${u+h*n-h*d}L${l+n-d},${u+h*n}L${c-n+d},${u+h*n}L${c-n},${u+h*n-h*d}L${c-n},${a-h*e+h*d}L${c-n+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${c+n},${a+h*e}L${c+n},${u-h*n}L${l-n},${u-h*n}L${l-n},${i+h*e}L${o},${i+h*e}Z`}var tc=new Set,ec=new WeakMap;function nc(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=ec.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,ec.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;tc.has(t)||(tc.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,r)}});return n.set(e,r),r}var rc={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(xl))-1:0},justify:vl};function oc(t){return"string"==typeof t?t:t.id}var ic={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=ql().extent(h).links(u).nodes(c).nodeAlign(rc[i]||vl).nodeId(t=>t.id).nodeWidth(s).iterations(l);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const r of c)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;t>i.leftFullExtent-s&&(t=i.leftFullExtent-s),i.rightFullExtent+s>e&&(e=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=e-t,s=o-n,a=r[0],l=r[1];if(i>0&&s>0&&(0>t||0>n||e>a||o>l)){const e=Math.min(a/i,l/s),r=-t*e+(a-i*e)/2,o=-n*e+(l-s*e)/2;for(const t of c)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of u)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of c){const e=f.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const y=new Map;for(const t of e)y.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=oc(t.source),n=oc(t.target),r=y.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(r){r.y0=t.y0,r.y1=t.y1,r.sankeyWidth=t.width??0,r.circular=!!t.circular,r.circularPathData=t.circularPathData,r._circularWidth=t._circularWidth,r._circularStub=t._circularStub,r.path=t.path,r.circularLinkType=t.circularLinkType,r.direction=o;const i=f.get(e),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(t,e,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:it,u=new Map;t.forEach((t,e)=>{u.set(t.id,c[e%c.length])});const h=[],d=[],f=[],y=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=i?i(nc(e,"nodeStyle")):{},s={fill:r.fill||u.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),h.push("down"===o?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:s,datum:e,id:e.id,label:e.id})}const p=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of p){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(t)||o:"target"===l?y.get(r.id)||u.get(r.id)||o:y.get(e.id)||u.get(e.id)||o;const i=s?s(nc(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=i.fill||o;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+r},${e.sourceY-n}L${e.sourceX+r},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+r}}),d.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let c;(c=t.circular&&t.circularPathData?Jl(t):Zl(t),c)&&d.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:t})}if(!1!==n.showLabels){const e=(g=n.nodeLabel)?"function"==typeof g?g:t=>t[g]||t.id:null;for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const s=e?e(n):n.id;if(!s)continue;let a,l,c;"down"===o?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+t/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:a,y:l,text:s+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}};import{forceSimulation as sc,forceCenter as ac,forceX as lc,forceY as cc,forceLink as uc,forceManyBody as hc,forceCollide as dc}from"d3-force";import{scaleLinear as fc}from"d3-scale";var yc={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=n.__previousPositions;let l=0;const c=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=a?.get(e.id);t?l++:n?(e.x=n.x,e.y=n.y,l++):c.push(e)}const u=l>0&&.3>=(t.length>0?c.length/t.length:1);if(u){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of c){const r=pc(t.id,e,n);if(r.length>0){let e=0,n=0;for(const t of r)e+=t.x,n+=t.y;const o=gc(t.id),i=o%360*(Math.PI/180),s=10+o%20;t.x=e/r.length+s*Math.cos(i),t.y=n/r.length+s*Math.sin(i)}else{const e=gc(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=i+r*Math.cos(n),t.y=s+r*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const r=t[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(n+.5),o=n*e;r.x=i+t*Math.cos(o),r.y=s+t*Math.sin(o)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),d=mc(n.nodeSize,n.nodeSizeRange,t),f=t=>d(t);if(h>0){const n=new Map,r=new Map;for(const e of t)n.set(e.id,0),r.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,r="string"==typeof t.target?t.target:t.target.id;n.set(e,(n.get(e)??0)+1),n.set(r,(n.get(r)??0)+1)}const a=uc().strength(t=>{const e=t.weight,r="string"==typeof t.target?t.target:t.target.id,i=Math.max(1,Math.min(n.get("string"==typeof t.source?t.source:t.source.id)??1,n.get(r)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*o/(.1*i))}).distance(t=>{const e="string"==typeof t.source?r.get(t.source):t.source,n="string"==typeof t.target?r.get(t.target):t.target,o=(e?f(e):0)+(n?f(n):0)+12;return Math.max(40,o)}).id(t=>t.id),l=sc().force("charge",hc().strength(t=>{const e=n.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",dc(t=>f(t)+3).strength(.9).iterations(2)).force("center",ac(i,s).strength(.8)).force("x",lc(i).strength(.06)).force("y",cc(s).strength(.06));if(l.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));a.links(t),l.force("link",a)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let t=0;h>t;++t)l.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=y.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=y.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=mc(n.nodeSize,n.nodeSizeRange,t),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:it,l=new Map;t.forEach((t,e)=>{l.set(t.id,a[e%a.length])});const c=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(nc(e,"nodeSize")),r=o?o(nc(e,"nodeStyle")):{},i={fill:r.fill||l.get(e.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:d.get(t.source),r="object"==typeof t.target?t.target:d.get(t.target);if(!e||!r)continue;if(null==e.x||null==e.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(nc(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:t})}if(!1!==n.showLabels){const e=(f=n.nodeLabel)?"function"==typeof f?f:t=>t[f]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const r=s(nc(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:h}}};function pc(t,e,n){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=i:i===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function gc(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function mc(t,e,n){if(n.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],o=[];for(const e of n){const n=e.data?.[t];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=Nr(o);if(i===s)return()=>(r[0]+r[1])/2;const a=fc().domain([i,s]).range(r).clamp(!0);return e=>{const n=e.data?.[t];return null==n||"number"!=typeof n?r[0]:a(n)}}import{chord as xc,ribbon as vc}from"d3-chord";import{arc as bc}from"d3-shape";var kc=it,wc={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,l=a-i,c=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),r=f.get(e);if(void 0===n||void 0===r)continue;const o=h(t);p[n][r]=o}const g=xc().padAngle(o);s&&g.sortGroups(s);const m=g(p),x=m.groups,v=bc().innerRadius(l).outerRadius(a);for(const e of x){const n=t[e.index],r=v.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);n&&(t.source=n),r&&(t.target=r)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,r=t[e.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:kc,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const p=vc().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.__arcData;if(!r)continue;let o;o=u?u(nc(n,"nodeStyle")).fill||y.get(n.id)||f[e%f.length]:y.get(n.id)||f[e%f.length];const i=u?u(nc(n,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const r=p(e);if(!r)continue;const o=Ac(r,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(nc(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===d&&n?s=y.get(n.id)||s:e&&(s=y.get(e.id)||s)}const a=h?h(nc(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==n.showLabels){const e=(v=n.nodeLabel)?"function"==typeof v?v:t=>t[v]||t.id:null,r=s+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const i=(t.startAngle+t.endAngle)/2,s=i-Math.PI/2;x.push({x:l+Math.cos(s)*r,y:c+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Ac(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let i=0;for(;r.length>i;){const t=r[i];if("M"===t||"L"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;3>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;2>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+e+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===t||"z"===t?(o.push(t),i++):(o.push(r[i]),i++)}return o.join(" ")}import{hierarchy as Sc,tree as _c,cluster as Mc,treemap as Pc,pack as Cc,partition as Tc,treemapBinary as Lc}from"d3-hierarchy";var Nc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Dc(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>150?"#222":"#fff"}function Ec(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Rc(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function Ic(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Nc}function zc(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function $c(t,e,n,r,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${n},${r}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${n},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${r}`}}var Wc={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,c=Sc(o,s);c.sum(l),c.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=r;switch(i){case"tree":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=_c();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,h);break;case"cluster":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=Mc();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,h);break;case"treemap":!function(t,e,n,r){const o=e.padding??4,i=e.paddingTop??0,s=Pc().size([n,r]).tile(Lc).padding(o);i>0&&s.paddingTop(i),s(t)}(c,n,u,h);break;case"circlepack":!function(t,e,n,r){const o=e.padding??4;Cc().size([n,r]).padding(o)(t)}(c,n,u,h);break;case"partition":!function(t,e,n,r){Tc().size([n,r]).padding(e.padding??1)(t)}(c,n,u,h)}const d=c.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const r=d[e],o={id:Ec(r,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Fc(o,r,n):"treemap"===i||"partition"===i?Oc(o,r):"circlepack"===i&&Yc(o,r),o.__hierarchyNode=r,t.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const t of d)if(t.parent){const n=f.get(t.parent),r=f.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,o,i){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const e of t){let t=e.x,r=e.y;u&&(t+=h,r+=d);const i=o(nc(e,"nodeStyle"));let a=i.fill||zc(n);if(n.colorByDepth&&void 0!==e.depth){const t=Ic(n);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const p=n.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let o=e.x,s=e.y,l=r.x,f=r.y;u&&(o+=h,s+=d,l+=h,f+=d);const y=$c(o,s,l,f,c),g=i(nc(t,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:t})}if(!1!==n.showLabels){const e=Rc(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,n=Math.sqrt(t*t+e*e);n>0?(r=s+t/n*10,o=a+e/n*10,i=0>t?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");l.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(t,e,n,r,o,i);case"treemap":case"partition":return function(t,e,n,r){const o=[],i=[];for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const s=r(nc(n,"nodeStyle"));let a=s.fill||zc(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ic(e);a=t[n.depth%t.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:t,h:i,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Rc(e.nodeLabel),o=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,l=a.y1-a.y0;if(0>=t||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>t||(c?16:14)>l)continue;let h=r(nc(a,"nodeStyle")).fill||zc(e);if(e.colorByDepth&&void 0!==a.depth){const t=Ic(e);h=t[a.depth%t.length]}const d="string"==typeof h?Dc(h):e.themeSemantic?.text??"#000";i.push(c?{x:a.x0+t/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(t,n,0,o);case"circlepack":return function(t,e,n,r){const o=[],i=[];for(const n of t){const t=n.__radius??5;if(0>=t)continue;const i=r(nc(n,"nodeStyle"));let s=i.fill||zc(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ic(e);s=t[n.depth%t.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:t,style:{fill:s,stroke:i.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Rc(e.nodeLabel);for(const o of t){const t=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>t)continue;const a=!(o.data?.children&&o.data.children.length>0);let l=r(nc(o,"nodeStyle")).fill||zc(e);if(e.colorByDepth&&void 0!==o.depth){const t=Ic(e);l=t[o.depth%t.length]}if(a){const n="string"==typeof l?Dc(l):e.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else i.push({x:o.x,y:o.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Fc(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Oc(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Yc(t,e){const n=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-n,t.x1=e.x+n,t.y0=e.y-n,t.y1=e.y+n,t.width=2*n,t.height=2*n,t.__radius=n}import{pie as Bc}from"d3-shape";function jc(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var Hc={sankey:ic,force:yc,chord:wc,tree:Wc,cluster:Wc,treemap:Wc,circlepack:Wc,partition:Wc,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;o&&function(t,e,n,r,o){const i=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(n.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,h="number"==typeof c?()=>c:c,d=jc(n);d.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function y(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const p=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=y(s(t));r.push({id:x,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,l,c,f,p,g){const m=i(e);if(!m?.length)return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=a[Math.min(k,a.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=a[Math.min(x,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,S={id:n,depth:p,data:e,parentId:n},_=g?f/u(S)*A:f*A,M=Bc().value(t=>{const e=i(t)?.length;return e?4:1}).sort(null)(k),P=h(S);for(let e=0;k.length>e;e++){const i=(M[e].startAngle+M[e].endAngle)/2,a=k[e],u=y(s(a)),h=l+_*Math.sin(i),f=c+_*Math.cos(i)*P;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:_,angle:i,depth:p,parentId:n,eccentricity:P}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(a,u,h,f,_,p+1,!0)}w+=b}}(t,x,p,g,m,1,!1)}(o,r,n,t,e)},buildScene(t,e,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const e=jc(n),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*r,x2:t+n*Math.sin(c),y2:e+n*Math.cos(c)*r,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(nc(e,"nodeSize")),r=o?o(nc(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const u=new Map;for(const e of t)u.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:u.get(t.source),n="object"==typeof t.target?t.target:u.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&l.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=s(nc(n,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(n):e?n.data?.[e]??n.id:n.id;c.push({x:n.x,y:n.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){const n=jc(e),r=e.orbitSpeed??.25,o=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=n.metaMap.get(e.id);if(!t||!t.parentId)continue;const r=a.get(t.parentId);if(!r)continue;const l=t.angle+i*s*o({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=r.x+t.ring*Math.sin(l),e.y=r.y+t.ring*Math.cos(l)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)}};function Xc(t){return Hc[t]}function Gc(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&wt(n,t)||"#4e79a7":e=>{if(n){const t=wt(n,e);if(t)return t}let r=0;for(let t=0;e.length>t;t++)r=31*r+e.charCodeAt(t)|0;return t[Math.abs(r)%t.length]??"#4e79a7"}}import{quadtree as Vc}from"d3-quadtree";function qc(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Uc(t){if(!t||"object"!=typeof t)return!1;const e=t;if("boolean"!=typeof e.circular)return!1;if("number"!=typeof e.halfWidth||!Number.isFinite(e.halfWidth))return!1;if(e.circular){if(!Array.isArray(e.segments)||0===e.segments.length)return!1;for(const t of e.segments)if(!Kc(t))return!1;return!0}return Kc(e.points)}function Kc(t){if(!Array.isArray(t)||4!==t.length)return!1;for(const e of t){if(!e||"object"!=typeof e)return!1;const t=e;if("number"!=typeof t.x||!Number.isFinite(t.x))return!1;if("number"!=typeof t.y||!Number.isFinite(t.y))return!1}return!0}import{interpolateNumber as Qc}from"d3-interpolate";var Zc="rgba(34, 197, 94, 0.7)",Jc=2e3,tu=class t{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this._stylePaintPending=!1,this.config=t,this.tensionConfig={...Za,...t.tensionConfig},t.showParticles&&("sankey"===t.chartType||t.customNetworkLayout)&&(this.particlePool=new tl(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),void 0===t.layoutSelection&&null!=e.layoutSelection&&(t.layoutSelection=e.layoutSelection),this.config=t,this.tensionConfig={...Za,...t.tensionConfig},!t.showParticles||"sankey"!==t.chartType&&!t.customNetworkLayout||this.particlePool||(this.particlePool=new tl(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,l="function"==typeof o?o:t=>t[o],c="function"==typeof i?i:t=>t[i],u="function"==typeof s?s:t=>t[s],h="function"==typeof a?a:t=>t[a]??1;this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,{...qc(t),data:e})}for(let t=0;e.length>t;t++){const n=e[t],r=c(n)+"",o=u(n)+"",i=h(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...qc(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...qc(o),data:n});const l=`${r}\0${o}\0${t}`,d={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&Uc(n.bezier)&&(d.bezier=n.bezier),this.edges.set(l,d)}r?.deferLayout||this.runLayout(n)}applyForceLayoutPositions(t,e){for(const[e,n]of Object.entries(t)){const t=this.nodes.get(e);t&&(t.x=n.x,t.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(e)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,o=0===this.nodes.size;let i=!1;const s=Mt();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(e)||(this.nodes.set(e,qc(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,qc(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(e,n),l=this.edges.get(a);let c=!1;return l?(l.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(t){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const e=Xc(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!e.hierarchical)return;if(this.prepareForRelayout(),e.supportsStreaming&&!e.hierarchical){const t=new Map;for(const e of n)void 0!==e._prevX0?t.set(e.id,{x:(e._prevX0??0)+((e._prevX1??0)-(e._prevX0??0))/2,y:(e._prevY0??0)+((e._prevY1??0)-(e._prevY0??0))/2}):0===e.x&&0===e.y||t.set(e.id,{x:e.x,y:e.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(e.computeLayout(n,r,this.config,t),this.config.__previousPositions=void 0,e.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of n)this.nodes.set(t.id,t);for(let t=0;r.length>t;t++){const e=r[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||o.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:Mt(),duration:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:Mt(),duration:s});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const t=new Set(this.nodes.keys()),e=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of t)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)t.has(e)||this.removedNodes.add(e);for(const t of e)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)e.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=Mt()),this.previousNodeIds=t,this.previousEdgeKeys=e}setLayoutSelection(t){this.config.layoutSelection=t}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const t of this.sceneNodes)this._baseStyles.set(t,t.style);for(const t of this.sceneEdges)this._baseStyles.set(t,t.style)}consumeStylePaintPending(){const t=this._stylePaintPending;return this._stylePaintPending=!1,t}restyleScene(t){if(this._customRestyle){const e=this._customRestyle;for(const n of this.sceneNodes){const r=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...r,...o}:r}}if(this._customRestyleEdge){const e=this._customRestyleEdge;for(const n of this.sceneEdges){const r=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...r,...o}:r}}this._stylePaintPending=!0}buildScene(t){if(this.config.customNetworkLayout){const e=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),r=function(t,e,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=vt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}(this.config.colorScheme,this.config.themeCategorical,it),o={nodes:e,edges:n,dimensions:{width:t[0],height:t[1],plot:{x:0,y:0,width:t[0],height:t[1]}},theme:{semantic:this.config.themeSemantic??{},categorical:[...r]},resolveColor:Gc(r,this.config.colorScheme),config:this.config.layoutConfig??{},selection:this.config.layoutSelection??null};let i;try{i=this.config.customNetworkLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,n=ve("network",t,e,this.layoutVersion);this.lastCustomLayoutFailure=n,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{this.config.onLayoutError?.(n)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return void(e||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++))}return this.sceneNodes=i.sceneNodes??[],this.sceneEdges=i.sceneEdges??[],this.labels=i.labels??[],this.customLayoutOverlays=i.overlays??null,this.customLayoutHtmlMarks=i.htmlMarks??[],this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=i.restyle,this._customRestyleEdge=i.restyleEdge,this.hasCustomRestyle=!(!i.restyle&&!i.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(this.config.layoutSelection??null)),void ge({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const e=Xc(this.config.chartType);if(!e)return void this._sceneNodesRevision++;const n=e.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=e.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=e.buildScene(n,r,this.config,t);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,this._sceneNodesRevision++}rebuildNodeQuadtree(){let e=0,n=0;for(const t of this.sceneNodes)"circle"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxNodeRadius=n,t.QUADTREE_THRESHOLD>=e)return void(this._nodeQuadtree=null);const r=Array(e);let o=0;for(const t of this.sceneNodes)"circle"===t.type&&(r[o++]=t);this._nodeQuadtree=Vc().x(t=>t.cx).y(t=>t.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const t=Xc(this.config.chartType);return!!t?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Xc(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,t,e)}cancelIntroAnimation(){this.transition=null;for(const t of this.nodes.values())t._prevX0=void 0,t._prevX1=void 0,t._prevY0=void 0,t._prevY1=void 0;for(const t of this.edges.values())t._prevY0=void 0,t._prevY1=void 0,t._prevSankeyWidth=void 0,t._introFromZero=!1}advanceTransition(t){if(!this.transition)return!1;const e=St(t,this.transition),n=At(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=_t(t._prevX0,t._targetX0,n),t.x1=_t(t._prevX1,t._targetX1,n),t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n),t.sankeyWidth=_t(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=t?.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){!function(t,e,n=.5){const r="string"==typeof t.source?e.get(t.source):t.source,o="string"==typeof t.target?e.get(t.target):t.target;!r||!o||(t.bezier=t.circular&&t.circularPathData?function(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let r;r="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],i=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+i/3,y:e.y+s/3},{x:e.x+2*i/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}(t):function(t,e,n,r=.5){const o=(t.sankeyWidth||1)/2;if("down"===t.direction){const i=e.x1,s=n.x0,a=Qc(i,s);return{circular:!1,points:[{x:t.y0,y:i},{x:t.y0,y:a(r)},{x:t.y1,y:a(1-r)},{x:t.y1,y:s}],halfWidth:o}}const i=e.x1,s=n.x0,a=Qc(i,s);return{circular:!1,points:[{x:i,y:t.y0},{x:a(r),y:t.y0},{x:a(1-r),y:t.y1},{x:s,y:t.y1}],halfWidth:o}}(t,r,o,n))}(t,this.nodes,.5)}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){!function(t){const e=t.pulse;if(!e)return;const n=e.duration??500,r=e.color??"rgba(255,255,255,0.6)",o=e.glowRadius??4,{now:i}=t;for(const e of t.sceneNodes){const s=e.id;if(!s)continue;const a=t.nodeTimestamps.get(s);if(!a)continue;const l=i-a;n>l&&(e._pulseIntensity=1-l/n,e._pulseColor=r,e._pulseGlowRadius=o)}for(const e of t.sceneEdges){const o=e.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const l=t.edgeTimestamps.get(`${s}\0${a}`);if(!l)continue;const c=i-l;n>c&&(e._pulseIntensity=1-c/n,e._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:t})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(t){const e=t.decay;if(!e)return;const n=t.nodeTimestamps.size;if(1>=n)return;if(!t.cache.sortedNodes){t.cache.sortedNodes=Array.from(t.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]);const e=new Map;for(let n=0;t.cache.sortedNodes.length>n;n++)e.set(t.cache.sortedNodes[n][0],n);t.cache.ageMap=e}const r=t.cache.ageMap;for(const o of t.sceneNodes){const t=o.id;if(!t)continue;const i=r.get(t);if(void 0===i)continue;const s=Rt(e,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(t){!function(t){for(const e of t.sceneNodes)e._pulseColor===Zc&&(e._pulseIntensity=0,e._pulseColor=void 0,e._pulseGlowRadius=void 0);if(0===t.addedNodes.size)return;const e=t.now-t.lastTopologyChangeTime;if(e>=Jc)return;const n=1-e/Jc;for(const e of t.sceneNodes){const r=e.id;r&&t.addedNodes.has(r)&&(e._pulseIntensity=Math.max(e._pulseIntensity??0,n),e._pulseColor=Zc,e._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:t})}get hasActiveTopologyDiff(){return function(t,e,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==t.size&&Jc>n-e}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(t){!function(t){const e=t.thresholds;if(!e)return;const n=e.warningColor??"#f59e0b",r=e.criticalColor??"#ef4444",o=!1!==e.pulse;for(const i of t.sceneNodes){const s=i.id;if(!s)continue;const a=t.nodes.get(s);if(!a)continue;const l=e.metric(a);let c=null;void 0===e.critical||e.critical>l?void 0===e.warning||e.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(t.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:t})}get hasActiveThresholds(){return function(t,e){if(!e)return!1;for(const n of t){const t=e.metric(n);if(void 0!==e.warning&&t>=e.warning||void 0!==e.critical&&t>=e.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(t){const e=t.pulse;if(!e||0===t.lastIngestTime)return!1;const n=t.now??("undefined"!=typeof performance?performance.now():Date.now());return(e.duration??500)>n-t.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){const n=this.nodes.get(t);if(!n)return null;const r=n.data?{...n.data}:{};return n.data=e(n.data??{}),this.layoutVersion++,this.lastIngestTime=Mt(),r}updateEdge(t,e,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?t=>t[r]:t=>t.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===t&&("string"==typeof r.target?r.target:r.target.id)===e){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const t=o(r.data);null!=t&&(r.value=Number(t))}return i.length>0&&(this.layoutVersion++,this.lastIngestTime=Mt()),i}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,this.lastIngestTime=Mt(),!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof e?e:t=>t?.[e];for(const[e,o]of this.edges)o.data&&r(o.data)===t&&n.push(e)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(r);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&(this.layoutVersion++,this.lastIngestTime=Mt()),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear()}};tu.QUADTREE_THRESHOLD=500;var eu=tu;import*as nu from"react";import{Fragment as ru,jsx as ou,jsxs as iu}from"react/jsx-runtime";function su(t){const{width:e,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,autoPlaceAnnotations:x,svgAnnotationRules:v}=t,b=nu.useMemo(()=>{const t=(g||[]).flatMap(t=>{const e=function(t){if("glyph"===t.type&&t.glyph&&"number"==typeof t.size){const e=t.cx??t.x,n=t.cy??t.y;if("number"!=typeof e||"number"!=typeof n)return null;const r=pn(t.glyph,t.size);return{x:e+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const e=t.cx??(null!=t.x&&null!=t.w?t.x+t.w/2:t.x),n=t.cy??(null!=t.y&&null!=t.h?t.y+t.h/2:t.y);return"number"!=typeof e||"number"!=typeof n?null:{x:e,y:n,r:"number"==typeof t.r?Math.max(1,t.r):"number"==typeof t.outerR?Math.max(1,t.outerR):"number"==typeof t.size?Math.max(1,de(t.size)):Math.max(1,t.w??0,t.h??0)/2}}(t),n=function(t){const e=t.id??t.datum?.id??t.datum?.data?.id??t.datum?.data?.name;return null==e?void 0:e+""}(t);return e?[{pointId:n,...e}]:[]});return{scales:null,width:e,height:n,frameType:"network",pointNodes:t,sceneNodes:g}},[n,g,e]),k=nu.useMemo(()=>m&&x?Yo({annotations:m,context:b,..."object"==typeof x?x:{}}):m,[m,x,b]),w=nu.useMemo(()=>wo(),[]),A=k?ko(k.filter(t=>"widget"!==t.type),w,v,b):null,S=!0===k?.some(t=>"widget"===t.type&&!0===t._annotationDeferred);return iu(ru,{children:[S&&ou("style",{children:fo},"annotation-widget-disclosure-style"),iu("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[ou("title",{children:"string"==typeof a?a:"Network Chart"}),ou("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),iu("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((t,e)=>ou("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+e)),A,p]}),a&&"string"==typeof a?ou("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?ou("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,Cr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),k?.filter(t=>"widget"===t.type&&t.nodeId&&g).map((t,e)=>{const n=!0===t._annotationDeferred,r=g.find(e=>e.id===t.nodeId||e.datum?.id===t.nodeId||e.datum?.data?.id===t.nodeId||e.datum?.data?.name===t.nodeId);if(!r)return null;const o=t.width??32,s=t.height??32;return ou("div",{className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0))+(t.dx??0)-o/2,top:i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0))+(t.dy??-16)-s/2,width:o,height:s,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:t.content??ou("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"})},"widget-"+e)})]})}su.displayName="NetworkSVGOverlay";import*as au from"react";import{jsx as lu}from"react/jsx-runtime";var cu={position:"absolute",top:0,left:0,pointerEvents:"none"};function uu({marks:t,margin:e,selection:n=null,overscan:r=400}){const o=au.useRef(null),i=function(t,e,n){const[r,o]=au.useState(null);return au.useLayoutEffect(()=>{const t=e.current,n=function(t){let e=t?.parentElement??null;for(;e;){const{overflow:t,overflowX:n,overflowY:r}=window.getComputedStyle(e);if(/(auto|scroll|overlay)/.test(`${t} ${r} ${n}`))return e;e=e.parentElement}return null}(t);if(!t||!n)return void o(null);let r=0;const i=()=>{r=0;const e=n.getBoundingClientRect(),i=t.getBoundingClientRect();o(0!==e.width&&0!==e.height?{scroll:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[e,t,n]),au.useMemo(()=>{if(!t||!r)return t;const{scroll:e,originX:o,originY:i}=r,s=e.left-n,a=e.right+n,l=e.top-n,c=e.bottom+n;return t.filter(t=>{const e=o+t.x,n=i+t.y;return!(s>e+t.width||e>a||l>n+t.height||n>c)})},[t,r,n])}(t,o,r);if(!t||0===t.length)return null;const s=lu("div",{className:"semiotic-network-html-marks",ref:o,style:{...cu,transform:`translate(${e.left}px, ${e.top}px)`},children:(i??t).map(t=>lu("div",{className:"semiotic-network-html-mark","data-mark-id":t.id,style:{position:"absolute",transform:`translate(${t.x}px, ${t.y}px)`,width:t.width,height:t.height,pointerEvents:"none"},children:t.content},t.id))});return null!=n?lu(Ke,{value:n,children:s}):s}import{jsx as hu}from"react/jsx-runtime";"undefined"!=typeof process&&process;var du={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},fu={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function yu(t,e,n,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?hu("div",{style:{...du,width:e,height:n},children:r||"No data available"}):null}function pu(t,e,n,r){if(!t)return null;if(!1===r)return null;if(null!=r)return hu("div",{style:{width:e,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return hu("div",{style:{width:e,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(t,n)=>hu("div",{className:"semiotic-loading-bar",style:{...fu,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function gu(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function mu(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const t=Error("Force layout aborted");return t.name="AbortError",t}var xu=class{constructor(t=function(){const t="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):function(t){if("undefined"!=typeof __filename){const e=__filename.replace(/\\/g,"/"),n=e.startsWith("/")?e:"/"+e;return new URL("./"+t,"file:"+n)}throw Error("Cannot resolve module worker asset: "+t)}("forceLayoutWorker.js");return new Worker(t,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=t,this.worker.onmessage=t=>{const e=t.data,n=e.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),e.error){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),void r.reject(t)}r.resolve({positions:e.positions??{}})}},this.worker.onerror=t=>{this.rejectAll(Error(t.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(t,e){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(e?.aborted)return Promise.reject(mu());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:t};return new Promise((t,o)=>{const i=()=>{this.pending.delete(n),e?.removeEventListener("abort",i),o(mu())},s=()=>e?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:t}),e?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(t){this.pending.delete(n),s(),o(t instanceof Error?t:Error(t+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(t){for(const e of this.pending.values())e.cleanup(),e.reject(t);this.pending.clear()}},vu=null;import{jsx as bu,jsxs as ku}from"react/jsx-runtime";var wu=/^(value|amount|total|count|weight|score)$/i;function Au({data:t}){if("edge"===t.nodeOrEdge){const e=t.data;return e?ku("div",{className:"semiotic-tooltip",style:Es,children:[ku("div",{style:{fontWeight:600},children:["object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target]}),null!=e.value&&ku("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]})]}):null}const e=t.data;if(!e)return null;const n=e.__hierarchyNode;if(n){const t=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??e.id;null!=n&&t.unshift(n+""),r=r.parent}t.length>1&&t.shift();const o=t.length-1;return ku("div",{className:"semiotic-tooltip",style:Es,children:[bu("div",{children:t.map((t,e)=>ku("span",{children:[e>0&&bu("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),e===o?bu("strong",{children:t}):bu("span",{style:{opacity:.7},children:t})]},e))}),null!=e.value&&e.value>0&&bu("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof e.value?e.value.toLocaleString():e.value+""})]})}const r=(e.sourceLinks?.length||0)+(e.targetLinks?.length||0),o=(e.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(e.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0),i=Ls(e.data??e),s=null!=i.title?i.title+"":e.id,a=i.entries.some(t=>wu.test(t.key));return ku("div",{className:"semiotic-tooltip",style:Es,children:[bu("div",{style:{fontWeight:600},children:s}),i.entries.map(t=>{return ku("div",{style:{marginTop:4,opacity:.8},children:[t.key,": ",(e=t.value,null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+"")]},t.key);var e}),!a&&null!=e.value&&e.value>0&&ku("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]}),r>0&&ku("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Su(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function _u(t,e){if(!e.pathD)return;t.save();const n=Su(e);if(e.style.fill&&"none"!==e.style.fill){const r=e._gradient;if(r){const n=t.createLinearGradient(r.x0,0,r.x1,0),o=e.style.fillOpacity??e.style.opacity??.5,i="string"==typeof e.style.fill?e.style.fill:"#999",s=Sn(t,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),t.fillStyle=n,t.globalAlpha=o}else t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.globalAlpha=e.style.fillOpacity??e.style.opacity??.5;t.fill(n)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??.5,t.globalAlpha=.5*(e.style.opacity??1),t.stroke(n)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(n)),t.restore()}function Mu(t,e){t.save();const n=e.style.stroke||"#999";t.strokeStyle=Sn(t,n)||n,t.lineWidth=e.style.strokeWidth??1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(e.style.strokeWidth??1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Pu(t,e){if(!e.pathD)return;t.save();const n=Su(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.globalAlpha=e.style.fillOpacity??e.style.opacity??.5,t.fill(n)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??.5,t.globalAlpha=.3*(e.style.opacity??1),t.stroke(n)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(n)),t.restore()}function Cu(t,e){if(!e.pathD)return;t.save();const n=Su(e),r=e.style.stroke||"#999";t.strokeStyle=Sn(t,r)||r,t.lineWidth=e.style.strokeWidth??1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(n),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.globalAlpha=e.style.fillOpacity??.1,t.fill(n)),t.restore()}Au.ownsChrome=!0;var Tu=new Map;function Lu(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let n=Tu.get(e);return n||(n=new Path2D(he(t.symbolType,t.size)),Tu.size>256&&Tu.clear(),Tu.set(e,n)),n}catch{return null}}function Nu(t){const{sceneNodes:e,nodes:n,nodeColorMap:r,colorScheme:o}=t;for(const t of e)t.id&&"string"==typeof t.style?.fill&&r.set(t.id,t.style.fill);const i=Array.isArray(o)?o:bt,s=Array.from(n);for(let t=0;s.length>t;t++){const e=s[t];r.has(e.id)||r.set(e.id,i[t%i.length])}return s.length}function Du(t,e,n,r=30){switch(t.type){case"circle":return function(t,e,n,r=30){const o=e-t.cx,i=n-t.cy,s=Math.sqrt(o*o+i*i);return s>rn(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,r);case"rect":return function(t,e,n){const r=nn(e,n,t);return r.hit?{type:"node",datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);if(t.innerR-2>i||i>t.outerR+2)return null;const s=an(Math.atan2(o,r)),a=an(t.startAngle),l=an(t.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);case"symbol":return function(t,e,n,r=30){const o=e-t.cx,i=n-t.cy,s=Math.sqrt(o*o+i*i);return s>rn(de(t.size),r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,r);case"glyph":return function(t,e,n,r=30){if(null==t.datum)return null;const o=pn(t.glyph,t.size),i=t.cx+o.centerDx,s=t.cy+o.centerDy,a=e-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>rn(o.radius,r)?null:{type:"node",datum:t.datum,x:i,y:s,distance:c}}(t,e,n,r);default:return null}}var Eu=null,Ru=null;function Iu(){return Ru||((Eu=document.createElement("canvas")).width=1,Eu.height=1,Ru=Eu.getContext("2d")),Ru}function zu(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch{return null}}function $u(t,e,n){switch(t.type){case"bezier":return function(t,e,n){if(!t.pathD)return null;const r=zu(t),o=Iu();if(!r||!o)return null;try{if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,e,n);if(o.lineWidth=i,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch{}return null}(t,e,n);case"line":return function(t,e,n){const r=t.x2-t.x1,o=t.y2-t.y1,i=r*r+o*o;if(0===i)return null;let s=((e-t.x1)*r+(n-t.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=t.x1+s*r,l=t.y1+s*o,c=Math.sqrt((e-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:t.datum,x:a,y:l,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const r=zu(t),o=Iu();if(!r||!o)return null;try{if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,e,n);if(o.lineWidth=i,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch{}return null}(t,e,n);default:return null}}function Wu(t){const{clientX:e,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:h=30}=t,d=e-r.left-o.left,f=n-r.top-o.top;if(0>d||d>i||0>f||f>s)return{kind:"miss-outside"};const y=function(t,e,n,r,o=30,i,s=0){let a=null,l=o,c=1/0;if(i){const t=mn(i,n,r,o,s,t=>t.cx,t=>t.cy,t=>t.r);t&&(a={type:"node",datum:t.node.datum,x:t.node.cx,y:t.node.cy,distance:t.distance},l=t.distance)}for(const e of t){if(i&&"circle"===e.type)continue;const t=Du(e,n,r,o);if(t)if("rect"===e.type){const n=e.w*e.h;c>n&&(a=t,c=n)}else l>t.distance&&(a=t,l=t.distance)}if(a)return a;for(const t of e){if(!1===t.interactive)continue;const e=$u(t,n,r);e&&l>e.distance&&(a=e,l=e.distance)}return a}(a,l,d,f,h,c,u);return y?{kind:"hit",hover:Ss(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}import{jsx as Fu,jsxs as Ou}from"react/jsx-runtime";var Yu={top:20,right:80,bottom:20,left:80},Bu={top:40,right:40,bottom:40,left:40},ju=new Set(["chord","force","circlepack","orbit"]),Hu=[800,600],Xu=Qa(Ka(function(t,e){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:x=300,forceStrength:v=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:w,padAngle:A=.01,groupWidth:S=20,sortGroups:M,edgeSort:P,treeOrientation:C="vertical",edgeType:T="curve",padding:L,paddingTop:N,tensionConfig:D,showParticles:E=!1,particleStyle:R,nodeStyle:I,edgeStyle:$,colorBy:W,colorScheme:F="category10",edgeColorBy:O="source",edgeOpacity:Y=.5,colorByDepth:B=!1,nodeSize:j=8,nodeSizeRange:H=[5,20],nodeLabel:X,showLabels:G=!0,labelMode:V,size:q=Hu,responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,enableHover:tt=!0,tooltipContent:et,customHoverBehavior:nt,customClickBehavior:rt,onObservation:ot,chartId:it,onTopologyChange:st,annotations:at,autoPlaceAnnotations:lt,svgAnnotationRules:ct,legend:ut,legendPosition:ht,legendLayout:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:pt,legendIsolatedCategories:gt,title:mt,foregroundGraphics:xt,backgroundGraphics:vt,decay:kt,pulse:wt,transition:At,animate:St,staleness:_t,thresholds:Mt,accessibleTable:Pt=!0,description:Ct,summary:Tt,orbitMode:Lt,orbitSize:Nt,orbitSpeed:Dt,orbitRevolution:Et,orbitRevolutionStyle:Rt,orbitEccentricity:It,orbitShowRings:zt,orbitAnimated:$t,customNetworkLayout:Wt,onLayoutError:Ft,layoutConfig:Ot,layoutSelection:Yt}=t,Bt=ju.has(n)?Bu:Yu,jt=Ha(!0),Ht=Ks({sizeProp:q,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:Bt,foregroundGraphics:xt,backgroundGraphics:vt,animate:St,transitionProp:At,themeDirtyRef:jt}),{reducedMotionRef:Xt,responsiveRef:Gt,size:Vt,margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,resolvedForeground:Qt,resolvedBackground:Zt,transition:Jt,introEnabled:te,tableId:ee,rafRef:ne,renderFnRef:re,scheduleRender:oe,cancelRender:ie,currentTheme:se}=Ht,ae=Pi(),le=Ni(),ce=Va(()=>_(r),[r]),ue=Va(()=>Array.isArray(o)?_(o):o,[o]),de=Va(()=>({...Za,...D}),[D]),fe=Va(()=>({...Ja,...R}),[R]),ye=Va(()=>{return{chartType:(t={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:P,treeOrientation:C,edgeType:T,padding:L,paddingTop:N,tensionConfig:de,showParticles:E,particleStyle:fe,nodeStyle:I,edgeStyle:$,nodeLabel:X,showLabels:G,labelMode:V,colorBy:W,colorScheme:F,edgeColorBy:O,edgeOpacity:Y,colorByDepth:B,nodeSize:j,nodeSizeRange:H,decay:kt,pulse:wt,transition:Jt,introAnimation:te,staleness:_t,thresholds:Mt,orbitMode:Lt,orbitSize:Nt,orbitSpeed:Dt,orbitRevolution:Et,orbitRevolutionStyle:Rt,orbitEccentricity:It,orbitShowRings:zt,orbitAnimated:$t,customNetworkLayout:Wt,onLayoutError:Ft,layoutConfig:Ot,currentTheme:se}).chartType,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,edgeIdAccessor:t.edgeIdAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,tensionConfig:t.tensionConfig,showParticles:t.showParticles,particleStyle:t.particleStyle,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,labelMode:t.labelMode,colorBy:t.colorBy,colorScheme:t.colorScheme,themeCategorical:t.currentTheme?.colors?.categorical,themeSemantic:z(t.currentTheme),edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,decay:t.decay,pulse:t.pulse,transition:t.transition,introAnimation:t.introAnimation,staleness:t.staleness,thresholds:t.thresholds,orbitMode:t.orbitMode,orbitSize:t.orbitSize,orbitSpeed:t.orbitSpeed,orbitRevolution:t.orbitRevolution,orbitRevolutionStyle:t.orbitRevolutionStyle,orbitEccentricity:t.orbitEccentricity,orbitShowRings:t.orbitShowRings,orbitAnimated:t.orbitAnimated,customNetworkLayout:t.customNetworkLayout,onLayoutError:t.onLayoutError,layoutConfig:t.layoutConfig};var t},[n,a,l,c,u,d,f,y,p,g,m,x,v,A,S,M,P,C,T,L,N,de,E,fe,I,$,X,G,V,W,F,O,Y,B,j,H,kt,wt,Jt?.duration,Jt?.easing,te,_t,Mt,Lt,Nt,Dt,Et,Rt,It,zt,$t,se,Wt,Ft,Ot]),pe=Ri(ye),ge=Ri({chartType:(me={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:P,treeOrientation:C,edgeType:T,padding:L,paddingTop:N,tensionConfig:de,customNetworkLayout:Wt,orbitMode:Lt,orbitSize:Nt,orbitEccentricity:It}).chartType,nodeIDAccessor:me.nodeIDAccessor,sourceAccessor:me.sourceAccessor,targetAccessor:me.targetAccessor,valueAccessor:me.valueAccessor,edgeIdAccessor:me.edgeIdAccessor,childrenAccessor:me.childrenAccessor,hierarchySum:me.hierarchySum,orientation:me.orientation,nodeAlign:me.nodeAlign,nodePaddingRatio:me.nodePaddingRatio,nodeWidth:me.nodeWidth,iterations:me.iterations,forceStrength:me.forceStrength,padAngle:me.padAngle,groupWidth:me.groupWidth,sortGroups:me.sortGroups,edgeSort:me.edgeSort,treeOrientation:me.treeOrientation,edgeType:me.edgeType,padding:me.padding,paddingTop:me.paddingTop,tensionConfig:me.tensionConfig,customNetworkLayout:me.customNetworkLayout,orbitMode:me.orbitMode,orbitSize:me.orbitSize,orbitEccentricity:me.orbitEccentricity});var me;const xe=Ha(null),ve=Ha(0),be=Ha(0),ke=Ha(!1),we=Ha(null);we.current||(we.current=new eu(pe));const[Ae,Se]=Xa(null),[_e,Me]=Xa(0),[Pe,Ce]=Xa(0),[Te,Le]=Xa(!1),[Ne,De]=Xa(!1),Ee=Ha(0),Re=Ha(null),Ie=Ha(!1),ze=Ha(w);ze.current=w;const $e=Ha(pe);$e.current=pe;const We=Ha(null),Fe=Ha(new Map),Oe=Ha(0),Ye=qa(t=>function(t){const{node:e,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=t;if("function"==typeof n)return n(e)+"";if("string"==typeof n&&e.data){const t=e.data[n];if(void 0!==t){if(!o.has(t+"")){const e=Array.isArray(r)?r:bt;o.set(t+"",e[i.current++%e.length])}return o.get(t+"")}}if(o.has(e.id))return o.get(e.id);const s=Array.isArray(r)?r:bt,a=n?s[i.current++%s.length]:s[0];return o.set(e.id,a),a}({node:t,colorBy:W,colorScheme:F,nodeColorMap:Fe.current,colorIndexRef:Oe}),[W,F]),Be=(je=se,je?.colors?.border||je?.colors?.secondary||je?.colors?.primary||"#999");var je;const He=qa(t=>function(t,e){return t?"object"==typeof t?t:e?.get(t)??null:null}(t,we.current?.nodes),[]),Xe=qa(t=>function(t){const{edge:e,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=t;if("function"==typeof n)return n(e);const s=o(e.source),a=o(e.target);return"target"===n&&a?r(a):s?r(s):i}({edge:t,edgeColorBy:O,getNodeColor:Ye,resolveEndpoint:He,fallback:Be}),[O,Ye,Be,He]),Ve=qa(t=>function(t){const{edge:e,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:l}=t;if("function"==typeof n){const t=a(e.source);return t?n(e,t):l}if(!o)return i(e);const c=r,u=a(e.source),h=a(e.target);return"target"===c&&h?s(h):u?s(u):l}({edge:t,particleStyleColor:fe.color,particleColorBy:fe.colorBy,hasExplicitParticleColorBy:!!R?.colorBy,getEdgeColor:Xe,getNodeColor:Ye,resolveEndpoint:He,fallback:Be}),[R?.colorBy,fe.color,fe.colorBy,Ye,Xe,Be,He]),qe=("sankey"===n||!!Wt)&&E||!!wt||(we.current?.isAnimating??!1);tn(we,pe,jt,oe),en(we,Yt,jt,oe),Ga(()=>{const t=we.current;t&&(t.buildScene([Ut,Kt]),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),jt.current=!0,oe())},[se,Ut,Kt,oe]);const Ue=qa(()=>{const t=we.current;if(t&&(t.runLayout([Ut,Kt]),t.buildScene([Ut,Kt]),jt.current=!0,Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),Me(t.layoutVersion),st)){const{nodes:e,edges:n}=t.getLayoutData();st(e,n)}},[Ut,Kt,st,F]),Ke=qa(t=>{if(null==t||"object"!=typeof t)return;const e=we.current;e&&(e.ingestEdge(t)&&Ue(),oe())},[Ue,oe]),Ze=qa(t=>{const e=we.current;if(!e)return;let n=!1;for(const r of t)null!=r&&"object"==typeof r&&e.ingestEdge(r)&&(n=!0);n&&Ue(),oe()},[Ue,oe]),Je=qa(()=>{we.current?.clear(),Fe.current.clear(),Oe.current=0,Me(we.current?.layoutVersion??0),Se(null),We.current=null,jt.current=!0,oe()},[oe]),nn=qa(()=>{const t=we.current;t&&(t.tension+=999,Ue(),oe())},[Ue,oe]);Ua(e,()=>({push:Ke,pushMany:Ze,removeNode:t=>{const e=we.current?.removeNode(t)??!1;if(e){const e=We.current?.data?"function"==typeof a?a(We.current.data):We.current.data[a]:void 0;We.current&&"node"===We.current.nodeOrEdge&&e===t&&(We.current=null,Se(null)),Fe.current.delete(t),Ue(),jt.current=!0,oe()}return e},removeEdge:(t,e)=>{const n=we.current?.removeEdge(t,e)??!1;if(n){if(We.current&&"edge"===We.current.nodeOrEdge){const n=We.current.data;let r;r=void 0!==e?("object"==typeof n?.source?n.source.id:n?.source)===t&&("object"==typeof n?.target?n.target.id:n?.target)===e:!h||!n||("function"==typeof h?h:t=>t?.[h])(n)===t,r&&(We.current=null,Se(null))}Ue(),jt.current=!0,oe()}return n},updateNode:(t,e)=>{const n=we.current?.updateNode(t,e)??null;return n&&(jt.current=!0,oe()),n},updateEdge:(t,e,n)=>{const r=we.current?.updateEdge(t,e,n)??[];return r.length>0&&(Ue(),jt.current=!0,oe()),r},clear:Je,getTopology:()=>we.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>we.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>we.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const t=we.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:nn,getTension:()=>we.current?.tension??0}),[Ke,Ze,Je,nn,Ue,oe]);const rn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),on=rn?i||(Array.isArray(o)?void 0:o):void 0;Ga(()=>{const t=we.current;if(!t)return;const e=++Ee.current;if(Re.current?.abort(),Re.current=null,rn&&on)t.ingestHierarchy(on,[Ut,Kt]),t.buildScene([Ut,Kt]),De(!1),ze.current?.("ready"),jt.current=!0,oe();else{const i=ce,s=Array.isArray(ue)?ue:[];if(0===i.length&&0===s.length)return null==r&&null==o||0>=t.nodes.size&&0>=t.edges.size||Je(),De(!1),void ze.current?.("ready");const a=[Ut,Kt],l="force"===n&&!Wt&&gu()&&function(t,e,n,r,o=4e4){return"sync"!==t&&("worker"===t||r*(e+n)>=o)}(b,i.length,s.length,x);if(l&&le&&!Ie.current&&t.sceneNodes.length>0)return Ie.current=!0,De(!1),ze.current?.("ready"),jt.current=!0,void oe();if(l){const n=new AbortController;Re.current=n;const r=t._lastPositionSnapshot;t.ingestBounded(i,s,a,{deferLayout:!0});const o=t.getLayoutData(),l=function(t,e,n,r,o){const i=mc(n.nodeSize,n.nodeSizeRange,t);return{kind:"frame",nodes:t.map(t=>{const e=o?.get(t.id);return{id:t.id,x:0!==t.x||0!==t.y?t.x:e?.x??0,y:0!==t.x||0!==t.y?t.y:e?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:t.value,__forceRadius:i(t)}}),edges:e.map(t=>{const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,r=t.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:t.value;return{source:e,target:n,value:t.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength},size:r}}(o.nodes,o.edges,$e.current,a,r);return De(!0),ze.current?.("pending"),function(t,e){return gu()?e?.aborted?Promise.reject(mu()):(vu&&!vu.isDead||(vu=new xu),vu).request(t,e):Promise.reject(Error("Web Workers are unavailable"))}(l,n.signal).then(({positions:n})=>{e===Ee.current&&(t.applyForceLayoutPositions(n,a),t.buildScene(a),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),De(!1),ze.current?.("ready"),Me(t.layoutVersion),jt.current=!0,oe())}).catch(n=>{"AbortError"!==n.name&&e===Ee.current&&(t.runLayout(a),t.buildScene(a),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),De(!1),ze.current?.("error"),Me(t.layoutVersion),jt.current=!0,oe())}),()=>n.abort()}t.ingestBounded(i,s,a),t.buildScene(a),De(!1),ze.current?.("ready"),Oe.current=Nu({sceneNodes:t.sceneNodes,nodes:t.nodes.values(),nodeColorMap:Fe.current,colorScheme:F}),jt.current=!0,oe()}},[ce,ue,r,o,i,on,rn,Ut,Kt,ge,b,x,le,n,Wt,oe,Je,F]),Ga(()=>{s&&s.length>0&&Ze(s)},[]);const sn=qa(t=>{if(nt&&nt(t),ot){const e=Date.now();ot(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:it}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:it})}},[nt,ot,it]),an=qa(t=>{if(rt&&rt(t),ot){const e=Date.now();ot(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:it}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:it})}},[rt,ot,it]),{hoverHandlerRef:ln,hoverLeaveRef:cn,onPointerMove:un,onPointerLeave:hn}=Ht,dn=()=>!Wt||(we.current?.hasCustomRestyle??!1);ln.current=t=>{if(!tt)return;const e=dn(),n=xe.current;if(!n)return;const r=we.current;if(!r)return;const o=Wu({clientX:t.clientX,clientY:t.clientY,canvasRect:n.getBoundingClientRect(),margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(We.current=o.hover,Se(o.hover),sn&&(sn(o.hover),e&&(jt.current=!0)),e&&oe()):We.current&&(We.current=null,Se(null),sn&&(sn(null),e&&(jt.current=!0)),e&&oe())},cn.current=()=>{if(We.current){const t=dn();We.current=null,Se(null),sn&&(sn(null),t&&(jt.current=!0)),t&&oe()}};const fn=Ha(()=>{});fn.current=t=>{if(!rt&&!ot)return;const e=xe.current;if(!e)return;const n=we.current;if(!n)return;const r=Wu({clientX:t.clientX,clientY:t.clientY,canvasRect:e.getBoundingClientRect(),margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?an(r.hover):"miss"===r.kind&&an(null)};const yn=qa(t=>fn.current(t),[]),gn=Ha(-1),mn=Ha(null),xn=Ha(-1),vn=qa(t=>{const e=we.current;if(!e)return;const n=function(t){const e=[];for(const n of t)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const t=pn(n.glyph,n.size);e.push({x:n.cx+t.centerDx,y:n.cy+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:n.datum?.id??"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const r=Jn(n),o=gn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),gn.current=0,xn.current=-1;const e=r.flat[0];mn.current={shape:e.shape,w:e.w,h:e.h};const n=Ss(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return We.current=n,Se(n),sn&&(sn(n),jt.current=!0),void oe()}const i=tr(r,o),s=function(t,e,n,r,o){const i=n.flat[e.flatIndex];if(!i)return er(t,e,n);const s=i.datum?.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(t,e,n){let r=null,o=1/0;for(let i=0;t.flat.length>i;i++){const s=t.flat[i];if(s===e)continue;const a=s.x-e.x,l=s.y-e.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up")??e.flatIndex;return r!==e.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return e.flatIndex;const t=function(t,e){const n=t+"",r=[];for(const t of e){const e=t.datum??t,o=rr(e.source),i=rr(e.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===t.length)return e.flatIndex;const i=n.idToIdx.get(t[(o.current+1)%t.length])??-1;return 0>i?e.flatIndex:(o.current=-1,i)}default:{const r=er(t,e,n);return null!==r&&r!==e.flatIndex&&(o.current=-1),r}}}(t.key,i,r,e.sceneEdges??[],xn);if(null===s)return;if(t.preventDefault(),0>s)return gn.current=-1,mn.current=null,xn.current=-1,We.current=null,Se(null),sn&&(sn(null),jt.current=!0),void oe();gn.current=s;const a=r.flat[s];mn.current={shape:a.shape,w:a.w,h:a.h};const l={data:a.datum||{},x:a.x,y:a.y,__semioticHoverData:!0,nodeOrEdge:"node"};We.current=l,Se(l),sn&&(sn(l),jt.current=!0),oe()},[sn,oe]),bn=qa(t=>{gn.current=-1,mn.current=null,un(t)},[un]);re.current=()=>{ne.current=null;const t=xe.current;if(!t)return;const e=we.current;e&&function(t){const{canvas:e,store:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,background:a,dirtyRef:l,lastFrameTimeRef:c,reducedMotion:u,showParticles:h,isContinuous:d,animate:f,decay:y,pulse:p,thresholds:g,staleness:m,particleStyle:x,getParticleColor:v,pendingAnnotationFrameRef:b,lastAnnotationFrameTimeRef:k,setAnnotationFrame:w,scheduleNextFrame:A}=t,S=e.getContext("2d");if(!S)return;const _=performance.now(),M=c.current?Math.min((_-c.current)/1e3,.1):.016;c.current=_;const P=n.advanceTransition(u?_+1e6:_),C=!u&&P,T=!u&&n.tickAnimation([i,s],M),L=l.current;(P||L||T)&&n.buildScene([i,s]);const N=h&&!u&&!!n.particlePool,D=!!((E={dirtyOrRebuilt:L,transitioning:C,animationTicked:T,continuous:N||d,liveEncoding:!!y||!!p||!!g||!1!==f&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||E.transitioning||E.animationTicked||E.continuous||E.liveEncoding||E.forced);var E;const R=!!m&&n.lastIngestTime>0&&_-n.lastIngestTime>(m?.threshold??5e3);if(D){if(!Qs(e,r,o,Zs()))return;if(S.clearRect(-o.left,-o.top,r[0],r[1]),Wi(S,{background:a,width:i,height:s}),y&&n.applyDecay(),p&&n.applyPulse(_),g&&n.applyThresholds(_),!1!==f&&n.applyTopologyDiff(_),R&&(S.globalAlpha=m?.dimOpacity??.5),function(t,e){for(const n of e)switch(n.type){case"bezier":_u(t,n);break;case"line":Mu(t,n);break;case"ribbon":Pu(t,n);break;case"curved":Cu(t,n)}}(S,n.sceneEdges),function(t,e){for(const n of e){if("rect"!==n.type)continue;const e=n;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(e.style.opacity??1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.globalAlpha=e.style.opacity??1,t.strokeRect(e.x,e.y,e.w,e.h)),ua(t,e),t.restore())}}(S,n.sceneNodes),function(t,e){for(const n of e){if("circle"!==n.type)continue;const e=n;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(e.style.opacity??1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.globalAlpha=e.style.opacity??1,t.stroke()),ha(t,e),t.restore())}}(S,n.sceneNodes),function(t,e){for(const n of e){if("arc"!==n.type)continue;const e=n;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(e.style.opacity??1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.globalAlpha=e.style.opacity??1,t.stroke()),t.restore()}}(S,n.sceneNodes),function(t,e){const n=t.globalAlpha;for(const r of e){if("symbol"!==r.type)continue;const e=r;if(0>=e.size)continue;const o=Lu(e);if(!o)continue;t.save(),t.translate(e.cx,e.cy),e.rotation&&t.rotate(e.rotation);const i=e.style.opacity??1;e.style.fill&&(t.globalAlpha=n*i*(e.style.fillOpacity??1),t.fillStyle="string"==typeof e.style.fill&&Sn(t,e.style.fill)||e.style.fill,t.fill(o)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*i,t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth??1,t.stroke(o)),t.restore()}}(S,n.sceneNodes),function(t,e){const n=t.globalAlpha;for(const r of e)"glyph"===r.type&&ka(t,r,r.cx,r.cy,n);t.globalAlpha=n}(S,n.sceneNodes),N&&!R){const t=n.edgesArray;if(t.length>0){!function(t,e,n,r){const o=r.spawnRate??.1,i=r.maxPerEdge??50;for(let r=0;e.length>r;r++){const s=e[r];if(!s.bezier)continue;if(t.countForEdge(r)>=i)continue;const a=s.value*o*n*(s.bezier.circular?.3:1),l=Math.floor(a),c=a-l;let u=l;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(r)<i;e++)t.spawn(r)}}(n.particlePool,t,M,x);const e=.5*(x.speedMultiplier??1);let r;if(x.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}n.particlePool.step(M,e,t,r),function(t,e,n,r,o){const i=r.radius??3;t.globalAlpha=r.opacity??.7;for(let s=0;e.particles.length>s;s++){const a=e.particles[s];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),t.fillStyle=Sn(t,c)||c,t.beginPath(),t.arc(a.x,a.y,i,0,2*Math.PI),t.fill()}t.globalAlpha=1}(S,n.particlePool,t,x,v)}}R&&(S.globalAlpha=1)}l.current=!1,(L||C||T)&&e.setAttribute("aria-label",Ji(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const I=L||C||T||b.current;I&&_-k.current>=33?(w(t=>t+1),k.current=_,b.current=!1):b.current=!!I,(d||C||null!=n.transition||T||n.hasActivePulses||n.hasActiveThresholds||!1!==f&&n.hasActiveTopologyDiff||b.current)&&A()}({canvas:t,store:e,size:Vt,margin:qt,adjustedWidth:Ut,adjustedHeight:Kt,background:J,dirtyRef:jt,lastFrameTimeRef:ve,reducedMotion:!!Xt.current,showParticles:E,isContinuous:qe,animate:St,decay:kt,pulse:wt,thresholds:Mt,staleness:_t,particleStyle:fe,getParticleColor:Ve,pendingAnnotationFrameRef:ke,lastAnnotationFrameTimeRef:be,setAnnotationFrame:Ce,scheduleNextFrame:()=>{oe()}})},Di({hydrated:ae,wasHydratingFromSSR:le,storeRef:we,dirtyRef:jt,renderFnRef:re,cancelRender:ie}),Ga(()=>{jt.current=!0,oe()},[n,Ut,Kt,J,oe]),ur(_t,we,jt,oe,Te,Le);const kn=tt&&Ae?Fu(Is,{x:Ae.x,y:Ae.y,containerWidth:Ut,containerHeight:Kt,margin:qt,className:"stream-network-tooltip",zIndex:2,children:et?et(Ae):Fu(Au,{data:Ae})}):null;if(bi||!ae&&le){const t=we.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),r=e?i||(Array.isArray(o)?void 0:o):void 0;if(e&&r)t.ingestHierarchy(r,[Ut,Kt]),t.buildScene([Ut,Kt]);else{const e=ce,n=Array.isArray(ue)?ue:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[Ut,Kt]),t.buildScene([Ut,Kt]))}}const e=t?.sceneNodes??[],r=t?.sceneEdges??[],s=t?.labels??[];return Ou("div",{ref:Gt,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":Ct||("string"==typeof mt?mt:"Network chart"),style:{position:"relative",width:U?"100%":Vt[0],height:K?"100%":Vt[1]},children:[Fu(ps,{summary:Tt}),Ou("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vt[0],height:Vt[1],style:{position:"absolute",left:0,top:0},children:[Zt&&Fu("g",{transform:`translate(${qt.left},${qt.top})`,children:Zt}),Ou("g",{transform:`translate(${qt.left},${qt.top})`,children:[J&&Fu("rect",{x:0,y:0,width:Ut,height:Kt,fill:J}),r.map((t,e)=>function(t,e){switch(t.type){case"line":return pi("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const n=t;return pi("path",{d:n.pathD,fill:xi(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"ribbon":{const n=t;return pi("path",{d:n.pathD,fill:xi(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"curved":{const n=t;return pi("path",{d:n.pathD,fill:xi(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+e)}default:return null}}(t,e)).filter(Boolean),e.map((t,e)=>function(t,e){switch(t.type){case"circle":{const n=t;return pi("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+e)}case"rect":{const n=t;return pi("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+e)}case"arc":{const n=t,r=fi().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(mi)||"";return pi("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+e)}case"symbol":{const n=t,r=he(n.symbolType,n.size,n.path);return pi("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?xi(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+e)}case"glyph":return vi(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e)).filter(Boolean),s.map((t,e)=>function(t,e){return pi("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}(t,e)).filter(Boolean)]})]}),Fu(su,{width:Ut,height:Kt,totalWidth:Vt[0],totalHeight:Vt[1],margin:qt,labels:s,sceneNodes:e,title:mt,legend:ut,legendPosition:ht,legendLayout:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:pt,legendIsolatedCategories:gt,foregroundGraphics:Ge(Qt,Qe(we.current?.customLayoutOverlays,Yt??null)),annotations:at,autoPlaceAnnotations:lt,svgAnnotationRules:ct,annotationFrame:0}),Fu(uu,{marks:t?.customLayoutHtmlMarks,margin:qt,selection:Yt??null})]})}const wn=we.current;return Ou("div",{ref:Gt,className:"stream-network-frame"+(Z?" "+Z:""),role:"group","aria-label":Ct||("string"==typeof mt?mt:"Network chart"),tabIndex:0,"aria-busy":Ne||void 0,style:{position:"relative",width:U?"100%":Vt[0],height:K?"100%":Vt[1],overflow:"visible"},onKeyDown:vn,children:[Pt&&Fu(gs,{tableId:ee}),Pt&&Fu(ys,{nodes:wn?.sceneNodes??[],edges:wn?.sceneEdges??[],chartType:"Network chart",tableId:ee,chartTitle:"string"==typeof mt?mt:void 0}),Fu(ps,{summary:Tt}),Fu(ms,{hoverPoint:Ae}),Ou("div",{role:"img","aria-label":Ct||("string"==typeof mt?mt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:tt?bn:void 0,onMouseLeave:tt?hn:void 0,onClick:rt||ot?yn:void 0,children:[Ne&&!1!==k&&Fu("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:pu(!0,Vt[0],Vt[1],k)}),Zt&&Fu("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:Vt[0],height:Vt[1],pointerEvents:"none",overflow:"visible"},children:Fu("g",{transform:`translate(${qt.left},${qt.top})`,children:Zt})}),Fu("canvas",{ref:xe,"aria-label":Ji(wn?.sceneNodes?.length??0,wn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Fu(su,{width:Ut,height:Kt,totalWidth:Vt[0],totalHeight:Vt[1],margin:qt,labels:wn?.labels||[],sceneNodes:wn?.sceneNodes,title:mt,legend:ut,legendPosition:ht,legendLayout:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:pt,legendIsolatedCategories:gt,foregroundGraphics:Ge(Qt,Qe(we.current?.customLayoutOverlays,Yt??null)),annotations:at,autoPlaceAnnotations:lt,svgAnnotationRules:ct,annotationFrame:Pe}),Fu(uu,{marks:wn?.customLayoutHtmlMarks,margin:qt,selection:Yt??null}),Fu(bs,{active:gn.current>=0,hoverPoint:Ae,margin:qt,size:Vt,shape:mn.current?.shape,width:mn.current?.w,height:mn.current?.h}),kn,_t?.showBadge&&Fu(dr,{isStale:Te,position:_t.badgePosition})]})]})}));Xu.displayName="StreamNetworkFrame";var Gu=Xu,Vu=class t{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(t){if(!Number.isFinite(t))return;this._count+=1;const e=t-this._mean;this._mean+=e/this._count,this._m2+=e*(t-this._mean),this._min>t&&(this._min=t),t>this._max&&(this._max=t)}merge(t){if(0===t._count)return;if(0===this._count)return this._count=t._count,this._mean=t._mean,this._m2=t._m2,this._min=t._min,void(this._max=t._max);const e=this._count+t._count,n=t._mean-this._mean;this._mean+=n*t._count/e,this._m2+=t._m2+n*n*this._count*t._count/e,this._count=e,this._min>t._min&&(this._min=t._min),t._max>this._max&&(this._max=t._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const e=new t;return e._count=this._count,e._mean=this._mean,e._m2=this._m2,e._min=this._min,e._max=this._max,e}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},qu=class{constructor(t){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=t.window??"tumbling",this.size=t.size;const e=t.hop??t.size;this.hop=e>0&&t.size>=e?e:t.size,this.gap=t.gap??t.size,this.retain=null!=t.retain&&t.retain>0?t.retain:1/0}push(t,e){Number.isFinite(t)&&Number.isFinite(e)&&(t>this.latest&&(this.latest=t),"session"===this.type?this.pushSession(t,e):this.pushFixed(t,e),this.prune())}pushFixed(t,e){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(t/this.size)*this.size,e);const n=this.hop,r=Math.floor(t/n);for(let o=Math.floor((t-this.size)/n)+1;r>=o;o++)this.bump(o*n,e)}bump(t,e){let n=this.windows.get(t);n||(n=new Vu,this.windows.set(t,n)),n.push(e)}pushSession(t,e){const n=this.gap,r=new Vu;r.push(e);let o=t,i=t;const s=[],a={start:o,end:i,stats:r};for(const e of this.sessions)t-n>e.end||e.start>t+n?s.push(e):(a.stats.merge(e.stats),o>e.start&&(o=e.start),e.end>i&&(i=e.end));a.start=o,a.end=i,s.push(a),s.sort((t,e)=>t.start-e.start),this.sessions=s}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const t=[...this.windows.keys()].sort((t,e)=>t-e),e=t.length-this.retain;for(let n=0;e>n;n++)this.windows.delete(t[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const t=[];for(const[e,n]of this.windows){const r=e+this.size;t.push(this.row(e,r,n,r>this.latest))}return t.sort((t,e)=>t.start-e.start),t}emitSessions(){return this.sessions.map(t=>this.row(t.start,t.end,t.stats,this.gap>this.latest-t.end))}row(t,e,n,r){return{start:t,end:e,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Uu(t,e){switch(e){case"sum":return t.sum;case"min":return t.min;case"max":return t.max;case"count":return t.count;default:return t.mean}}function Ku(t,e,n,r=1){if("none"===e)return null;if("minmax"===e)return[t.min,t.max];const o=Uu(t,n),i=t.stddev*r;return[o-i,o+i]}var Qu={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Zu=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Ju(t){if("number"==typeof t)return Number.isFinite(t)&&t>0?t:null;if("string"!=typeof t)return null;const e=t.trim();if(""===e)return null;Zu.lastIndex=0;let n,r=0,o=0;for(;null!==(n=Zu.exec(e));){const t=parseFloat(n[1]),e=Qu[n[2]];if(null==e||!Number.isFinite(t))return null;r+=t*e,o+=n[0].length}return o!==e.length?null:r>0?r:null}var th=class{constructor(t){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=t.lateness>0?t.lateness:0,this.getTime=t.getTime,this.latePolicy=t.latePolicy??"drop"}push(t){const e=this.getTime(t);if(!Number.isFinite(e))return{released:[t],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>e?(this._lateCount+=1,n.push(t),"drop"===this.latePolicy?{released:[],late:n}:{released:[t],late:n}):(e>this._watermark&&(this._watermark=e),this.held.push(t),{released:this.drain(),late:n})}drain(){const t=this._watermark-this.lateness;if(0===this.held.length)return[];const e=[],n=[];for(const r of this.held)this.getTime(r)>t?n.push(r):e.push(r);return this.held=n,e.sort((t,e)=>this.getTime(t)-this.getTime(e)),e}flush(){const t=this.held;return this.held=[],t.sort((t,e)=>this.getTime(t)-this.getTime(e)),t}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as eh,useImperativeHandle as nh,forwardRef as rh,useCallback as oh,useState as ih,useEffect as sh}from"react";import{useMemo as ah,useCallback as lh,useState as ch,useId as uh,useEffect as hh,useRef as dh}from"react";function fh(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function yh(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function ph(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}var[gh,mh]=R(t=>({selections:new Map,setClause(e,n){t(t=>{const r=t.selections.get(e),o=r?.clauses.get(n.clientId);if(o&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,r]of n){const n=e.fields[t];if(!n||!ph(r,n))return!1}return!0}(o,n))return{};const i=new Map(t.selections),s=yh(i,e),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(e,{...s,clauses:a}),{selections:i}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r||!r.clauses.has(n))return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,{...r,clauses:i}),{selections:o}})},setResolution(e,n){t(t=>{const r=t.selections.get(e);if(r?.resolution===n)return{};const o=new Map(t.selections),i=yh(o,e);return o.set(e,{...i,resolution:n}),{selections:o}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const r=new Map(t.selections);return r.set(e,{...n,clauses:new Map}),{selections:r}})}})),[xh,vh]=R(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));import{useId as bh,useMemo as kh,useCallback as wh}from"react";function Ah(t){const e=bh(),n=t.clientId||e,{name:r}=t,o=mh(t=>t.selections.get(r)),i=mh(t=>t.setClause),s=mh(t=>t.clearClause),a=kh(()=>!!o&&o.clauses.size>0,[o]);return{predicate:kh(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(fh(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:wh(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:e})},[n,r,i]),selectInterval:wh(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:e})},[n,r,i]),clear:wh(()=>{s(r,n)},[s,r,n]),clientId:n}}function Sh(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function _h(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function Mh(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function Ph(t,e,n){const r=t.xValue??e?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function Ch(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?{...e,xValue:t.xValue}:e||{}}var Th={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Lh(t,e={}){const n=e.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,o="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,i=!!n||void 0!==r,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!o&&!i)return Th;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Nh({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const h=uh(),d=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(e,n),f="series"===d?.mode?[d.seriesField||c||n[0]].filter(t=>!!t):d?.fields||n||[],y=Ah({name:t?.name||"__unused__",fields:f}),p=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:o,selectPoints:i,clear:s}=Ah({name:e,fields:n});return{onHover:wh(t=>{if(!t)return void s();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}_h(e)&&i(e)},[n,i,s,e]),predicate:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=vh(t=>t.pushObservation),m=t?{isActive:y.isActive,predicate:y.predicate}:null,[x,v]=ch(null),b=dh(!1),k=c||n[0],w=ah(()=>{if(!l||null==x||!k)return null;const t=x,e=k;return{isActive:!0,predicate:n=>("string"==typeof n[e]?n[e]:(n[e]??"")+"")===t}},[l,x,k]),A=lh(t=>{const n=!t&&b.current&&!!u?.enabled&&u.tapToLockTooltip;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===d?.mode&&d.xField){const n=Ph(t,e,d.xField);null!=n&&function(t,e,n){const r=jo.positions.get(t);r?.locked||r&&r.xValue===e&&r.sourceId===n||(jo={positions:new Map(jo.positions).set(t,{xValue:e,sourceId:n})},Xo())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(e)}else"x-position"!==d?.mode||n||Go(d.name||"hover",h),"x-position"===d?.mode||n||p.onHover(null);if(l&&k)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=e?.[k];v(null!=n?n+"":null)}else n||v(null);if(o||g){const e={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(t){const n=Ch(t),r={...e,type:"hover",datum:n||{},x:t.x??0,y:t.y??0};o&&o(r),g&&g(r)}else{const t={...e,type:"hover-end"};o&&o(t),g&&g(t)}}},[e,p,d,h,o,i,s,g,l,k,u]),S=lh((n=!0)=>{b.current=!1,e&&"x-position"!==d?.mode&&p.onHover(null),t&&u?.tapToSelect&&y.clear(),n&&l&&v(null),"x-position"===d?.mode&&(Vo(d.name||"hover",h),Go(d.name||"hover",h))},[e,d,p,t,u,y,l,h]),_=lh(n=>{const r=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),c=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]);const e=Ph(n,t,d.xField);null!=e&&function(t,e,n){const r=jo.positions.get(t);if(r?.locked){const e=new Map(jo.positions);return e.delete(t),jo={positions:e},Xo(),!1}jo={positions:new Map(jo.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Xo()}(d.name||"hover",e,h)}if(r)if(n){b.current=!0;const r=Ch(n);if(e&&"x-position"!==d?.mode&&p.onHover(r),t&&u?.tapToSelect&&f.length>0){const t={};for(const e of f){const n=r[e];void 0!==n&&(t[e]=[n])}(function(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(t)&&y.selectPoints(t)}if(l&&k){const t=r?.[k];v(null!=t?t+"":null)}}else c&&S();if(n||c){if(n&&a){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]),a(t,{x:n.x??0,y:n.y??0})}if(o||g){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(n){const e=Ch(n),r={...t,type:"click",datum:e||{},x:n.x??0,y:n.y??0};o&&o(r),g&&g(r)}else{const e={...t,type:"click-end"};o&&o(e),g&&g(e)}}}},[a,o,g,i,s,d,h,u,e,p,t,y,f,l,k,S]);return hh(()=>{if(!u?.enabled||"undefined"==typeof document)return;const t=t=>{"Escape"===t.key&&b.current&&S()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u?.enabled,S]),hh(()=>()=>{b.current&&S(!1)},[S]),hh(()=>{if("x-position"!==d?.mode)return;const t=d.name||"hover";return()=>{Vo(t,h),Go(t,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:m,hoverSelectionHook:w,customHoverBehavior:A,customClickBehavior:_,crosshairSourceId:h}}var Dh={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Eh(t,e,n){const r=Dh[t||"primary"],o=t&&"primary"!==t||!n?.width?r.width:n.width,i=t&&"primary"!==t||!n?.height?r.height:n.height,s=function(t,e,n=t.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:t,matches:[]};const r=n.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:n}=t,r=e.width,o=e.height,i=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),s=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(t.rule,e)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:r.reduce((t,e)=>function(t,e){const n={...t,...e};for(const r of["margin","frameProps","mobileSemantics","style"])Mh(t[r])&&Mh(e[r])&&(n[r]={...t[r],...e[r]});return"string"==typeof t.className&&"string"==typeof e.className&&(n.className=`${t.className} ${e.className}`),n}(t,e.rule.transform),t),matches:r}}({...e,mode:t},{width:e.width??o,height:e.height??i}).props,a=s.mode||t,l=Dh[a||"primary"],c="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?l.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?l.height:n.height),showAxes:s.showAxes??l.showAxes,showGrid:s.showGrid??l.showGrid,enableHover:s.enableHover??(!!s.linkedHover||l.enableHover),showLegend:s.showLegend??l.showLegend,showLabels:s.showLabels??l.showLabels,title:c?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:c?void 0:s.xLabel,yLabel:c?void 0:s.yLabel,categoryLabel:c?void 0:s.categoryLabel,valueLabel:c?void 0:s.valueLabel,marginDefaults:Rh(l.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:c,mobileInteraction:Lh(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function Rh(t,e,n){if(!1!==e)return t;const r={...t};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{jsx as Ih,jsxs as zh}from"react/jsx-runtime";var $h={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},Wh={opacity:.7,marginRight:4};function Fh(t,e,n){if(null!=t)return"function"==typeof e?e(t):t["string"==typeof e?e:n]}function Oh(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function Yh(t={}){const{timeAccessor:e,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=t;return t=>{const i=t?.data??null,s=Fh(i,e,"time"),a=Fh(i,n,"value");return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[zh("span",{style:Wh,children:[r,":"]}),Oh(s)]}),zh("div",{children:[zh("span",{style:Wh,children:[o,":"]}),Oh(a)]})]})}}function Bh(t,e){return null!=t?t:Math.max(e?.length??0,200)}var jh="time",Hh="value",Xh="__aggLower",Gh="__aggUpper",Vh="__aggPartial",qh="count",Uh="__aggStart",Kh="__aggEnd";function Qh(t,e){const n=e.stat??"mean",r=e.band??"none",o=e.sigma??1;return t.emit().map(t=>{const e={[jh]:(t.start+t.end)/2,[Hh]:Uu(t,n),[qh]:t.count,[Vh]:t.partial,[Uh]:t.start,[Kh]:t.end},i=Ku(t,r,n,o);return i&&(e[Xh]=i[0],e[Gh]=i[1]),e})}function Zh(t){const{linkedHover:e,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=t,f={},y=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(a||e||r||o||s)&&(f.customHoverBehavior=u),h&&(l||(d?r||o||e:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(e||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}import{jsx as Jh}from"react/jsx-runtime";function td(t,e,n){const r="function"==typeof e?e(t):t[e??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isFinite(o)?o:null}var ed=rh(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:x,background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,transition:N,linkedHover:D,selection:E,onObservation:R,chartId:I,loading:z,loadingContent:$,emptyContent:W,emphasis:F,legendPosition:O,aggregate:Y,eventTime:B}=t,j=n.showAxes,H=n.enableHover,X=o??n.marginDefaults,G=r??[n.width,n.height],V=b??k??Yh({timeAccessor:u,valueAccessor:h}),q=eh(null),{customHoverBehavior:U}=Nh({selection:E,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:I}),K=oh(t=>{w&&w(t),U(t)},[w,U]),Q=null!=Y,[Z,J]=ih([]),tt=eh(null),et=eh(Y);et.current=Y;const nt=eh(Q);nt.current=Q;const rt=eh(Z);rt.current=Z;const ot=eh({timeAccessor:u,valueAccessor:h});ot.current={timeAccessor:u,valueAccessor:h},sh(()=>{if(!Q)return void(tt.current=null);const t=et.current,e=function(t){const e=t.window??"tumbling",n=Ju("session"===e?t.gap??t.size:t.size);if(null==n)return null;const r=null!=t.hop?Ju(t.hop):void 0,o=null!=t.gap?Ju(t.gap):void 0;return new qu({window:e,size:n,hop:r??void 0,gap:o??void 0,retain:t.retain})}(t);if(tt.current=e,e&&c){const{timeAccessor:t,valueAccessor:n}=ot.current;for(const r of c){const o=td(r,t,"time"),i=td(r,n,"value");null!=o&&null!=i&&e.push(o,i)}}J(e?Qh(e,t):[])},[Q?[Y.window??"tumbling",Y.size,Y.hop??"",Y.gap??"",Y.retain??""].join("|"):"",Q,c]),sh(()=>{Q&&tt.current&&J(Qh(tt.current,et.current))},[Y?.stat,Y?.band,Y?.sigma]);const it=oh(t=>{const e=tt.current,n=et.current;if(!e||!n)return;const{timeAccessor:r,valueAccessor:o}=ot.current;for(const n of t){const t=td(n,r,"time"),i=td(n,o,"value");null!=t&&null!=i&&e.push(t,i)}J(Qh(e,n))},[]),st=null!=B,at=eh(null),lt=eh(B);lt.current=B;const ct=eh(st);ct.current=st;const ut=eh(R);ut.current=R;const ht=eh(I);ht.current=I,sh(()=>{at.current=st?function(t){const e=Ju(t.lateness);return null==e?null:new th({lateness:e,getTime:t=>td(t,ot.current.timeAccessor,"time")??NaN,latePolicy:t.latePolicy??"drop"})}(lt.current):null},[st?`${B.lateness}|${B.latePolicy??"drop"}`:"",st]);const dt=oh(t=>{0!==t.length&&(nt.current?it(t):q.current?.pushMany(t))},[it]),ft=oh(t=>{const e=at.current;if(!ct.current||!e)return void dt(t);const n=[];for(const r of t){const t=e.push(r);if(t.released.length&&n.push(...t.released),t.late.length){const n=ut.current;if(n){const{timeAccessor:r}=ot.current,o=lt.current?.latePolicy??"drop";for(const i of t.late)n({type:"late-data",datum:i,eventTime:td(i,r,"time")??NaN,watermark:e.watermark,policy:o,lateCount:e.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:ht.current})}}}dt(n)},[dt]);nh(e,()=>({push:t=>ft([t]),pushMany:t=>ft(t),remove:t=>nt.current?[]:q.current?.remove(t)??[],update:(t,e)=>nt.current?[]:q.current?.update(t,e)??[],clear:()=>{at.current?.clear(),nt.current?(tt.current?.clear(),J([])):q.current?.clear()},getData:()=>nt.current?rt.current:q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[ft]);const yt=pu(z,G[0],G[1],$),pt=yt?null:yu(Q?void 0:c,G[0],G[1],W),gt={stroke:p,strokeWidth:g,strokeDasharray:m};null!=x&&(gt.opacity=x);const mt=Bh(l,c),xt=Q?Z:c,vt=Q?jh:u,bt=Q?Hh:h,kt=Q&&Y&&"none"!==(Y.band??"none")?{y0Accessor:Xh,y1Accessor:Gh,perSeries:!1}:void 0;return yt||pt||Jh(ja,{ref:q,chartType:"line",runtimeMode:"streaming",size:G,margin:X,className:F?`${i||""} semiotic-emphasis-${F}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,Y?.retain??Math.max(Z.length,600)):mt,data:xt,timeAccessor:vt,valueAccessor:bt,xExtent:d,yExtent:f,extentPadding:y,band:kt,lineStyle:gt,showAxes:j,background:v,hoverAnnotation:H,tooltipContent:V,...Zh({linkedHover:D,selection:E,onObservation:R,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,transition:N,pointIdAccessor:t.pointIdAccessor,legendPosition:O})});ed.displayName="RealtimeLineChart";import{useRef as nd,useImperativeHandle as rd,forwardRef as od,useCallback as id,useMemo as sd}from"react";import{jsx as ad}from"react/jsx-runtime";function ld(t,e,n){const r="function"==typeof e?e(t):t[e??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}var cd=od(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,showAxes:t.showAxes,enableHover:null!=t.enableHover?!!t.enableHover:void 0,linkedHover:t.linkedHover,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{binSize:r,size:o,margin:i,className:s,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:x,fill:v,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:P,annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,linkedHover:E,selection:R,decay:I,pulse:z,staleness:$,transition:W,onObservation:F,chartId:O,loading:Y,loadingContent:B,emptyContent:j,emphasis:H,legendPosition:X,brush:G,onBrush:V,linkedBrush:q}=t,U=n.showAxes,K=n.enableHover,Q=i??n.marginDefaults,Z=o??[n.width,n.height],J=_??M??function(t={}){const{timeAccessor:e,valueAccessor:n}=t;return t=>{const r=t?.data??null;if(null==r?.binStart||null==r?.binEnd){const t=Fh(r,e,"time"),o=Fh(r,n,"value");return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[Ih("span",{style:Wh,children:"x:"}),Oh(t)]}),zh("div",{children:[Ih("span",{style:Wh,children:"y:"}),Oh(o)]})]})}return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[Ih("span",{style:Wh,children:"range:"}),Oh(r.binStart),"–",Oh(r.binEnd)]}),null!=r.total&&zh("div",{children:[Ih("span",{style:Wh,children:"count:"}),Oh(r.total)]}),null!=r.category&&zh("div",{children:[Ih("span",{style:Wh,children:"category:"}),Oh(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),tt=nd(null),{customHoverBehavior:et}=Nh({selection:R,linkedHover:E,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:O}),nt=id(t=>{P&&P(t),et(t)},[P,et]),rt=!0===G?{dimension:"x",snap:"bin"}:"x"===G?{dimension:"x"}:"object"==typeof G?G:void 0,ot=(it=q)?"string"==typeof it?{name:it}:it:null;var it;const st="string"==typeof h?h:"time",at=function(t){const{name:e,xField:n,yField:r}=t,{predicate:o,isActive:i,selectInterval:s,clear:a}=Ah({name:e,fields:[n,r].filter(Boolean)}),l=n&&r?"xyBrush":n?"xBrush":"yBrush",c=wh(t=>{if(!t)return void a();const e={};"xyBrush"===l&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),r&&(e[r]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===l&&Sh(t)?n&&(e[n]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]):"yBrush"===l&&Sh(t)&&r&&(e[r]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]),_h(e)&&s(e)},[l,n,r,s,a]);return{brushInteraction:kh(()=>({brush:l,during:c,end:c}),[l,c]),predicate:o,isActive:i,clear:a}}({name:ot?.name||"__unused_hist_brush__",xField:ot?.xField||st,...ot?.yField?{yField:ot.yField}:{}}),lt=nd(at.brushInteraction);lt.current=at.brushInteraction;const ct=id(t=>{if(V&&V(t),F&&F(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}),ot){const e=lt.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[V,F,O,ot]);rd(e,()=>({push:t=>tt.current?.push(t),pushMany:t=>tt.current?.pushMany(t),remove:t=>tt.current?.remove(t)??[],update:(t,e)=>tt.current?.update(t,e)??[],clear:()=>tt.current?.clear(),getData:()=>tt.current?.getData()??[],getScales:()=>tt.current?.getScales()??null}),[]);const ut=pu(Y,Z[0],Z[1],B),ht=ut?null:yu(u,Z[0],Z[1],j),dt={};null!=v&&(dt.fill=v),null!=b&&(dt.stroke=b),null!=k&&(dt.strokeWidth=k),null!=w&&(dt.opacity=w),null!=A&&(dt.gap=A);const ft=H?`${s||""} semiotic-emphasis-${H}`.trim():s,yt=Bh(c,u),pt=sd(()=>"down"!==f?p:function({data:t,valueAccessor:e,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!t||0===t.length)return;const s=new Map;for(const o of t){const t=ld(o,n,"time"),i=ld(o,e,"value");if(null==t||null==i)continue;const a=Math.floor(t/r)*r;s.set(a,(s.get(a)??0)+i)}let a=0;for(const t of s.values())t>a&&(a=t);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ut||ht||ad(ja,{ref:tt,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:ft,arrowOfTime:a,windowMode:l,windowSize:yt,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pt,extentPadding:g,binSize:r,categoryAccessor:m,barColors:x,barStyle:dt,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...Zh({linkedHover:E,selection:R,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:nt}),annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,decay:I,pulse:z,staleness:$,transition:W,pointIdAccessor:t.pointIdAccessor,legendPosition:X,brush:rt||(q?{dimension:"x"}:void 0),onBrush:rt||q?ct:void 0})});function ud(t){return ad(cd,{...t,windowMode:"growing"})}cd.displayName="RealtimeHistogram",ud.displayName="TemporalHistogram";import{useRef as hd,useImperativeHandle as dd,forwardRef as fd,useCallback as yd}from"react";import{jsx as pd}from"react/jsx-runtime";var gd=fd(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:x,fill:v,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:P,annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,linkedHover:E,selection:R,onObservation:I,chartId:z,loading:$,loadingContent:W,emptyContent:F,emphasis:O,legendPosition:Y}=t,B=n.showAxes,j=n.enableHover,H=o??n.marginDefaults,X=r??[n.width,n.height],G=_??M??Yh({timeAccessor:u,valueAccessor:h}),V=hd(null),{customHoverBehavior:q}=Nh({selection:R,linkedHover:E,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:z}),U=yd(t=>{P&&P(t),q(t)},[P,q]);dd(e,()=>({push:t=>V.current?.push(t),pushMany:t=>V.current?.pushMany(t),remove:t=>V.current?.remove(t)??[],update:(t,e)=>V.current?.update(t,e)??[],clear:()=>V.current?.clear(),getData:()=>V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[]);const K=pu($,X[0],X[1],W),Q=K?null:yu(c,X[0],X[1],F),Z={};null!=x&&(Z.radius=x),null!=v&&(Z.fill=v),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,tt=O?`${i||""} semiotic-emphasis-${O}`.trim():i,et=Bh(l,c);return K||Q||pd(ja,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:tt,arrowOfTime:s,windowMode:a,windowSize:et,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:B,background:S,hoverAnnotation:j,tooltipContent:G,...Zh({linkedHover:E,selection:R,onObservation:I,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:C,autoPlaceAnnotations:T,svgAnnotationRules:L,tickFormatTime:N,tickFormatValue:D,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});gd.displayName="RealtimeSwarmChart";import{useRef as md,useImperativeHandle as xd,forwardRef as vd,useCallback as bd}from"react";import{jsx as kd}from"react/jsx-runtime";var wd=vd(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:x,gap:v,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:P,autoPlaceAnnotations:C,svgAnnotationRules:T,tickFormatTime:L,tickFormatValue:N,linkedHover:D,selection:E,onObservation:R,chartId:I,loading:z,loadingContent:$,emptyContent:W,emphasis:F,legendPosition:O}=t,Y=n.showAxes,B=n.enableHover,j=o??n.marginDefaults,H=r??[n.width,n.height],X=S??_??function(t={}){const{timeAccessor:e,valueAccessor:n}=t;return t=>{const r=t?.data??null,o=Fh(r,e,"time"),i=r?.delta??Fh(r,n,"value"),s=r?.cumEnd,a="number"==typeof i?0>i?Oh(i):"+"+Oh(i):Oh(i);return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[Ih("span",{style:Wh,children:"x:"}),Oh(o)]}),zh("div",{children:[Ih("span",{style:Wh,children:"Δ:"}),a]}),null!=s&&zh("div",{children:[Ih("span",{style:Wh,children:"total:"}),Oh(s)]})]})}}({timeAccessor:u,valueAccessor:h}),G=md(null),{customHoverBehavior:V}=Nh({selection:E,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:I}),q=bd(t=>{M&&M(t),V(t)},[M,V]);xd(e,()=>({push:t=>G.current?.push(t),pushMany:t=>G.current?.pushMany(t),remove:t=>G.current?.remove(t)??[],update:(t,e)=>G.current?.update(t,e)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const U=pu(z,H[0],H[1],$),K=U?null:yu(c,H[0],H[1],W),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=x&&(Q.connectorWidth=x),null!=v&&(Q.gap=v),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=F?`${i||""} semiotic-emphasis-${F}`.trim():i,J=Bh(l,c);return U||K||kd(ja,{ref:G,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:j,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:Y,background:A,hoverAnnotation:B,tooltipContent:X,...Zh({linkedHover:D,selection:E,onObservation:R,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:q}),annotations:P,autoPlaceAnnotations:C,svgAnnotationRules:T,tickFormatTime:L,tickFormatValue:N,legendPosition:O,pointIdAccessor:t.pointIdAccessor})});wd.displayName="RealtimeWaterfallChart";import{useRef as Ad,useImperativeHandle as Sd,forwardRef as _d,useCallback as Md}from"react";import{jsx as Pd}from"react/jsx-runtime";var Cd=_d(function(t,e){const n=Eh(t.mode,{width:t.size?.[0]??t.width,height:t.size?.[1]??t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:x="count",background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,linkedHover:N,selection:D,onObservation:E,chartId:R,loading:I,loadingContent:z,emptyContent:$,emphasis:W,legendPosition:F}=t,O=n.showAxes,Y=n.enableHover,B=o??n.marginDefaults,j=r??[n.width,n.height],H=b??k??function(t={}){const{timeAccessor:e,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=t;return t=>{const i=t?.data??null,s=i?.xCenter??Fh(i,e,"time"),a=i?.yCenter??Fh(i,n,"value"),l=i?.count,c=i?.sum,u=i?.value,h=i?.agg??"count";return zh("div",{className:"semiotic-tooltip",style:$h,children:[zh("div",{children:[zh("span",{style:Wh,children:[r,":"]}),Oh(s)]}),zh("div",{children:[zh("span",{style:Wh,children:[o,":"]}),Oh(a)]}),null!=l&&zh("div",{children:[Ih("span",{style:Wh,children:"count:"}),Oh(l)]}),"sum"===h&&null!=c&&zh("div",{children:[Ih("span",{style:Wh,children:"sum:"}),Oh(c)]}),"mean"===h&&null!=u&&zh("div",{children:[Ih("span",{style:Wh,children:"mean:"}),Oh(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=Ad(null),{customHoverBehavior:G}=Nh({selection:D,linkedHover:N,unwrapData:!0,onObservation:E,chartType:"RealtimeHeatmap",chartId:R}),V=Md(t=>{w&&w(t),G(t)},[w,G]);Sd(e,()=>({push:t=>X.current?.push(t),pushMany:t=>X.current?.pushMany(t),remove:t=>X.current?.remove(t)??[],update:(t,e)=>X.current?.update(t,e)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const q=pu(I,j[0],j[1],z),U=q?null:yu(c,j[0],j[1],$),K=W?`${i||""} semiotic-emphasis-${W}`.trim():i,Q=Bh(l,c);return q||U||Pd(ja,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:j,margin:B,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:x,showAxes:O,background:v,hoverAnnotation:Y,tooltipContent:H,...Zh({linkedHover:N,selection:D,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:P,decay:C,pulse:T,staleness:L,legendPosition:F,pointIdAccessor:t.pointIdAccessor})});Cd.displayName="RealtimeHeatmap";import{useCallback as Td,useEffect as Ld,useMemo as Nd,useRef as Dd,useState as Ed}from"react";var Rd=Symbol("semiotic.useStreamStatus.wrapped");function Id(t={}){const{staleThresholdMs:e=5e3,pollIntervalMs:n=1e3}=t,r=Dd(null),[o,i]=Ed("idle"),[s,a]=Ed(null),l=Nd(()=>{const t={_frame:null,_origPush:null,_origPushMany:null};return{get current(){return t._frame},set current(e){const n=t._frame;if(n&&n!==e&&t._origPush&&t._origPushMany&&(n.push=t._origPush,n.pushMany=t._origPushMany,delete n[Rd]),t._frame=e,!e)return t._origPush=null,void(t._origPushMany=null);if(e[Rd])return;e[Rd]=!0;const r=e.push,o=e.pushMany,i=r.bind(e),s=o.bind(e);t._origPush=r,t._origPushMany=o,e.push=t=>(c(),i(t)),e.pushMany=t=>(t&&t.length>0&&c(),s(t))}}},[]),c=Td(()=>{const t="undefined"!=typeof performance?performance.now():Date.now();r.current=t,a(t),i(t=>"active"===t?t:"active")},[]);return Ld(()=>{const t=setInterval(()=>{const t=r.current;if(null==t)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-t>e;i(t=>{const e=n?"stale":"active";return t===e?t:e})},n);return()=>clearInterval(t)},[e,n]),{ref:l,status:o,lastPushTime:s}}import{useEffect as zd,useMemo as $d,useRef as Wd}from"react";function Fd(t,e,n,r){const o=new Map;n.forEach((t,e)=>{o.set(r?r(t,e):e+"",t)});const i=[];e.forEach((t,e)=>{o.has(e)||i.push(e)}),i.length>0&&t.remove?.(i);const s=[];if(o.forEach((n,r)=>{const o=e.get(r);void 0===o?s.push(n):o!==n&&(t.update?t.update(r,()=>n):(t.remove?.(r),s.push(n)))}),s.length>0)if(t.pushMany)t.pushMany(s);else if(t.push)for(const e of s)t.push(e);return o}function Od(t,e,n={}){const{id:r,resetKey:o}=n,i=$d(()=>function(t){return null==t?null:"function"==typeof t?(e,n)=>{const r=t(e,n);return null==r?n+"":r+""}:(e,n)=>{const r=e[t];return null==r?n+"":r+""}}(r),[r]),s=Wd({map:new Map,handle:null,resetKey:void 0});zd(()=>{const n=t.current;if(!n)return;const r=s.current;r.handle===n&&r.resetKey===o||(n.clear?.(),r.map=new Map,r.handle=n,r.resetKey=o),r.map=Fd(n,r.map,e,i)},[t,e,i,o])}export{Pt as DEFAULT_LIFECYCLE_THRESHOLDS,G as IncrementalExtent,Cd as RealtimeHeatmap,cd as RealtimeHistogram,ed as RealtimeLineChart,gd as RealtimeSwarmChart,wd as RealtimeWaterfallChart,th as ReorderBuffer,X as RingBuffer,Vu as RunningStats,Gu as StreamNetworkFrame,ja as StreamXYFrame,ud as TemporalHistogram,qu as WindowAccumulator,Ku as bandBounds,Ct as bandFromAge,Lt as compileMotionEncoding,Et as deriveMotionVector,Nt as opacityFromAge,Ju as parseWindowDuration,Tt as resolveMotionAccessor,Dt as resolveMotionVector,Uu as statValue,Fd as syncPushBuffer,Id as useStreamStatus,Od as useSyncedPushData};
|
|
2
|
+
import*as e from"react";import{useRef as t,useState as n,useEffect as r,useMemo as o,useCallback as i,useImperativeHandle as s,useId as a,forwardRef as c,memo as l}from"react";import{useRef as u,useEffect as h,useMemo as d}from"react";import{select as f}from"d3-selection";import{brush as y,brushX as p,brushY as g}from"d3-brush";import*as m from"react";import{jsx as v,jsxs as x}from"react/jsx-runtime";function b(e,t,n,r){const[o,i]=[Math.min(...t),Math.max(...t)],s=(i-o)/20;let[a,c]=e;if(r)0>n?a=Math.max(o,a-s):c=Math.min(i,c+s);else{const e=c-a;a=Math.max(o,Math.min(i-e,a+n*s)),c=a+e}return[a,c]}function k(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function w(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function A({width:e,height:t,totalWidth:n,totalHeight:r,margin:o,dimension:i,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:A,snapDuring:S,streaming:_}){const M=u(null),C=u(null),P=u(a);P.current=a;const T=u(s);T.current=s;const R=d(()=>A?[...A].sort((e,t)=>e-t):void 0,[A]),D=u(R);D.current=R;const N=u(!1),L=u(null),E=function({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const r=m.useId().replace(/:/g,""),o=m.useRef(n);return o.current=n,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:m.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),o.current?.(t))},[])}}}({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=T.current,n=C.current;if(!t||!n||!M.current)return;const r=f(M.current).select(".brush-g");if("clear"===e.type)return N.current=!0,r.call(n.move,null),N.current=!1,L.current=null,void P.current(null);const o=t.x.domain(),s=t.y.domain(),a=L.current;let c=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,h="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==i&&(c=b(c,o,h,e.resize)),u||"x"===i||(l=b(l,s,h,e.resize)),u&&"y"===i||!u&&"x"===i)return;const d={x:c,y:l};N.current=!0,r.call(n.move,"x"===i?[t.x(c[0]),t.x(c[1])]:"y"===i?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),N.current=!1,L.current=d,P.current(d)}});return h(()=>{if(!M.current)return;const n=f(M.current).select(".brush-g"),r="x"===i?p():"y"===i?g():y();return r.extent([[0,0],[e,t]]),r.on("brush end",o=>{if(N.current)return;const s=T.current;if(!s)return;if(!o.selection)return L.current=null,void P.current(null);let a,u;if("x"===i){const[e,n]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===i){const[t,n]=o.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,r]]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(t)]}if("bin"===l&&"y"!==i&&("end"===o.type||"brush"===o.type&&S)){const e=D.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[k(e[0],t),w(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(N.current=!0,"x"===i)n.call(r.move,[t,l]);else if("xy"===i){const e=o.selection;n.call(r.move,[[t,e[0][1]],[l,e[1][1]]])}N.current=!1}const h={x:a,y:u};L.current=h,P.current(h)}),n.call(r),C.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),C.current=null}},[e,t,i,l,c,S]),h(()=>{if(!(_&&s&&C.current&&L.current))return;if(!M.current)return;if("y"===i)return;const e=L.current,t=s.x.domain()[0],n=f(M.current).select(".brush-g");if(t>=e.x[1])return N.current=!0,n.call(C.current.move,null),N.current=!1,L.current=null,void P.current(null);let r=e.x[0],o=!1;if(t>e.x[0]){if(r=t,"bin"===l){const e=D.current;e&&e.length>0?r=w(t,e):c&&c>0&&(r=Math.ceil(t/c)*c)}if(r>=e.x[1])return N.current=!0,n.call(C.current.move,null),N.current=!1,L.current=null,void P.current(null);o=!0}const a=s.x(r),u=s.x(e.x[1]);if(N.current=!0,"x"===i)n.call(C.current.move,[a,u]);else{const t=s.y(e.y[1]),r=s.y(e.y[0]);n.call(C.current.move,[[a,t],[u,r]])}if(N.current=!1,o){const t={x:[r,e.x[1]],y:e.y};L.current=t,P.current(t)}},[s,_,i,l,c]),x("svg",{ref:M,width:n,height:r,...E.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[v("title",{children:E.svgProps["aria-label"]}),v("desc",{id:E.descriptionId,children:E.description}),v("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}var S=Object.freeze([]);function _(e){if(!e)return S;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var M=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=_(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=_(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const r=e[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import{createContext as C,useCallback as P,useContext as T,useMemo as R,useRef as D,useSyncExternalStore as N}from"react";import{jsx as L}from"react/jsx-runtime";function E(e){let t=null;const n=()=>(t||(t=C(null)),t),r=I(e);return[function({children:t,initialState:r}){const o=D(r),i=R(()=>I(e,o.current),[]),s=n();return L(s.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=T(o)??r,s=D(e);s.current=e;const a=D({hasValue:!1,value:void 0}),c=P(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),l=P(()=>s.current(i.getState()),[i]);return N(i.subscribe,c,l)}]}function I(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function W(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function $(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:z}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var z=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],O={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}},F={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}},B={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:z,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 Y(e,t){if("light"===t)return O;if("dark"===t)return F;if("high-contrast"===t)return B;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?F:O;return $({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return $({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[j,H]=E(e=>({theme:O,setTheme(t){e(e=>({theme:Y(e.theme,t)}))}})),X=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,r=[];t.length>e&&(n=t.length-e,r=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return r}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},G=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function V(e,t){return e===t}function q(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function U(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function K(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Q=/^\d{4}-\d{1,2}$/;function Z(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Q.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function J(e){return e instanceof Date?e.getTime():"string"==typeof e?Z(e):+e}function ee(e){return new Set(Array.isArray(e)?e:[e])}import{scaleOrdinal as te}from"d3-scale";function ne(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function re(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function oe(e){const t=e.map(ne),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return re(e,n,r)}if(e>=1){const[e,r,o]=t[n];return re(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[s,a,c]=t[o],[l,u,h]=t[o+1];return re(Math.round(s+(l-s)*i),Math.round(a+(u-a)*i),Math.round(c+(h-c)*i))}}var ie=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],se=oe(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ae=oe(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ce=oe(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),le=oe(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ue=oe(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),he=oe(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),de=oe(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),fe=oe(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),ye=oe(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),pe=oe(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ge=oe(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),me=oe(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ve={blues:se,reds:ae,greens:ce,viridis:de,oranges:le,purples:ue,greys:he,plasma:fe,inferno:ye,magma:pe,cividis:ge,turbo:me};oe(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),oe(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),oe(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),oe(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),oe(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),oe(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),oe(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var xe={category10:ie,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ve},be=ie,ke=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function we(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ae(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Se(e,t){return Math.min((e-t.startTime)/t.duration,1)}function _e(e,t,n){return e+(t-e)*n}function Me(){return"undefined"!=typeof performance?performance.now():Date.now()}var Ce={fresh:1,aging:1.5,stale:3};function Pe(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}function Te(e,t,n){if(null!=e)return"function"==typeof e?e(t,n):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function Re(e){const{data:t,encoding:n}=e,r=[],o=new Map;return t.forEach((e,t)=>{const i=Te(n.id,e,t);if(null==i||""===i)throw Error(`[semiotic] Motion encoding row ${t} resolved an empty id.`);const s=i+"";if(o.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=Te(n.process?.group,e,t),c=Te(n.process?.stage,e,t),l=Te(n.accessible?.group,e,t)??(null!=a?a+"":null!=c?c+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=Te(n.evidence?.[r],e,t);const h={id:s,datum:e,time:{arrival:Te(n.time?.arrival,e,t),basis:n.time?.basis,unit:n.time?.unit},placement:{x:Te(n.placement?.x,e,t),y:Te(n.placement?.y,e,t),lane:Te(n.placement?.lane,e,t),space:n.placement?.space},kinematics:{velocityX:Te(n.kinematics?.velocityX,e,t),velocityY:Te(n.kinematics?.velocityY,e,t),space:n.kinematics?.space},process:{group:a,stage:c,target:Te(n.process?.target,e,t),work:Te(n.process?.work,e,t)},evidence:u,accessible:{description:Te(n.accessible?.description,e,t),group:l,label:Te(n.accessible?.label,e,t)??s}};r.push(h),o.set(s,h)}),{rows:r,byId:o}}function De(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}function Ne(e,t){const n=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function Le(e,t,n){return Number.isFinite(n)&&n>0?Ne((t.x-e.x)/n,(t.y-e.y)/n):Ne(0,0)}function Ee(e,t,n){if(1>=n)return 1;const r=n-1;return De({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Ie(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function We(e,t,n){const r=e.duration??500,o=n-t;return r>o?1-o/r:0}function $e(e,t,n,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==n&&(e._pulseColor=n,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function ze(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Oe(e,t,n,r,o,i){const s=[];for(const o of e){const e=n(o),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:o,datum:l,group:i}}function Fe(e,t,n,r,o,i,s,a){const c=[];for(const i of e){const e=n(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(i):o;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:i,datum:e,group:s}}function Be(e,t,n,r){const o=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const o of t)e+=n(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){const i=e[r-1],s=e[r];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=o.get(i)??0;o.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let r=0;for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r+=(o.get(i)??0)+e/2}const i=r/e.length;for(const t of e)o.set(t,(o.get(t)??0)-i)}}else for(const t of e)o.set(t,0);return o}function Ye(e,t,n,r,o,i,s){const a=n(e),c=r(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:o,style:i,datum:e};return void 0!==s&&(l.pointId=s),l}function je(e,t,n,r,o,i,s,a){const c=n(e),l=r(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:o,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function He(e,t,n,r,o,i,s){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:s}}function Xe(e,t,n,r,o,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Ge(e,t,n,r){return"function"==typeof t.style?t.style(r||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,r)}function Ve(e,t,n,r){if(!e.scales)return null;const o=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(o.push([c,l]),i.push([c,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:Ge(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function qe(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const r of e)r.perSeries?t.push(r):n.push(r);return{perSeries:t,aggregate:n}}function Ue(e,t,n){const r=[];for(const o of n){const n=Ve(e,t,"__ribbon_aggregate",o);n&&r.push(n)}return r}function Ke(e,t,n,r){const o=[];for(const i of r){const r=Ve(e,t,n,i);r&&o.push(r)}return o}function Qe(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),o=r.getBottom(e);Number.isFinite(o)&&Number.isFinite(t)&&n.push({y0:o,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function Ze(e,t,n,r){if(!e.config.pointStyle)return;const o=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const i of r.data){let r=e.config.pointStyle(i);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,c=Ye(i,e.scales,e.getX,o,s,r,a);c&&n.push(c)}}}function Je(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var et={topOpacity:.8,bottomOpacity:.05};function tt(e){if(e)return!0===e?et:"colorStops"in e?e:{topOpacity:e.topOpacity??et.topOpacity,bottomOpacity:e.bottomOpacity??et.bottomOpacity}}import{symbol as nt,symbolCircle as rt,symbolCross as ot,symbolDiamond as it,symbolSquare as st,symbolStar as at,symbolTriangle as ct,symbolWye as lt}from"d3-shape";var ut={circle:rt,square:st,triangle:ct,diamond:it,star:at,cross:ot,wye:lt},ht=["circle","triangle","diamond","star","square","chevron","cross","wye"];function dt(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*ft(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):nt(ut[r]??rt,Math.max(1,t))()??""}function ft(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var yt=new Map;function pt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=q(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),h=(c-a||1)/r,d=(u-l||1)/o,f=r*o;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;t.length>n;n++){const i=t[n],c=e.getX(i),u=e.getY(i);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),r-1),g=Math.min(Math.floor((u-l)/d),o-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const v=s(i);p[m]+=isFinite(v)?v:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===y[e])continue;let t;switch(i){case"sum":t=p[e];break;case"mean":t=p[e]/y[e];break;default:t=y[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const v=m-g||1,x=n.width/r,b=n.height/o,k=e.config.showValues,w=e.config.heatmapValueFormat,A=[];for(let e=0;o>e;e++){const t=e*r;for(let n=0;r>n;n++){const r=t+n;if(0===y[r])continue;let s;switch(i){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const c=(s-g)/v;A.push(Xe(n*x,(o-1-e)*b,x,b,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:l+(e+.5)*d,agg:i},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(e,t,n);if(0===t.length)return[];const r=q(e.config.valueAccessor,"value"),o=U(e.config.xAccessor,"x"),i=U(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),u=i(n);c[e]=r,l[e]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(e=>"number"==typeof e&&!isNaN(e)),p=f.every(e=>"number"==typeof e&&!isNaN(e));if(y){d.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;d.length>e;e++)s.set(d[e],e)}if(p){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),v=Array(t.length),x=new Map;let b=0;for(let e=0;t.length>e;e++){const n=t[e],o=s.get(c[e]),i=a.get(l[e]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=x.get(d);let y;void 0!==f?y=f:(y=b++,x.set(d,y)),g[y]=d,m[y]=h,v[y]=n}let k=1/0,w=-1/0;for(let e=0;b>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in ve?e:"blues";let n=yt.get(t);if(n)return n;n=Array(256);const r=(o=t)&&ve[o]||se;var o;for(let e=0;256>e;e++)n[e]=r(e/255);return yt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/h,C=e.config.showValues,P=e.config.heatmapValueFormat,T=[];for(let e=0;b>e;e++){const t=m[e];if(!isFinite(t))continue;const n=g[e],r=n%u;T.push(Xe(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((t-k)*S+.5|0,255)],v[e],C?{value:t,showValues:!0,valueFormat:P}:void 0))}return T}function gt(e,t,n,r,o){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/r)*r;let l=i.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},i.set(c,l)),l.total+=a,o){const e=o(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return i}function mt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;vt(r)&&0===n.length&&xt(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&xt(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function vt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(vt))}function xt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function bt(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function kt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function wt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=kt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=q(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:kt(e.y1Accessor,"y1"),getBottom:kt(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as At,scaleLog as St,scaleSymlog as _t,scaleTime as Mt}from"d3-scale";function Ct(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Pt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return St().domain(e).range(n).clamp(!0)}return"symlog"===e?_t().domain(t).range(n):"time"===e?Mt().domain([new Date(t[0]),new Date(t[1])]).range(n):At().domain(t).range(n)}function Tt(e,t,n,r){const o=e.push(t);return n&&n.push(r),o}var Rt=new WeakMap;function Dt(){return this.updateResults.last}function Nt(){return this.updateResults.last}function Lt(e){return this.updateResults.subscribe(e)}function Et(e){this.config.layoutSelection=e}function It(){Rt.set(this,!0)}function Wt(){const e=!0===Rt.get(this);return Rt.delete(this),e}function $t(e){Object.assign(e.prototype,{getLastUpdateResult:Dt,getUpdateSnapshot:Nt,subscribeUpdateResult:Lt,setLayoutSelection:Et,markStylePaintPending:It,consumeStylePaintPending:Wt})}var zt={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 Ot(e,t){const n={...e};for(const e of t)n[zt[e]]++;return n}function Ft(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:Ot(n,r)}}var Bt=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=Ft({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=Ft(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},Yt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jt=["scene-style","data-paint","accessibility","evidence"],Ht=(e,t)=>({retainedData:e,invalidations:t}),Xt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Gt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ut=["scene-geometry","data-paint","accessibility","evidence"],Kt=["scene-style","data-paint","accessibility","evidence"],Qt=[],Zt={chartType:Ht("rebuild",Xt),runtimeMode:Ht("rebuild",Xt),xAccessor:Ht("rebuild",Xt),yAccessor:Ht("rebuild",Xt),timeAccessor:Ht("rebuild",Xt),valueAccessor:Ht("rebuild",Xt),y0Accessor:Ht("rebuild",Xt),boundsAccessor:Ht("rebuild",Xt),band:Ht("rebuild",Xt),openAccessor:Ht("rebuild",Xt),highAccessor:Ht("rebuild",Xt),lowAccessor:Ht("rebuild",Xt),closeAccessor:Ht("rebuild",Xt),candlestickRangeMode:Ht("rebuild",Xt),accessorRevision:Ht("rebuild",Xt),groupAccessor:Ht("rebuild",Gt),categoryAccessor:Ht("rebuild",Gt),lineDataAccessor:Ht("rebuild",Gt),colorAccessor:Ht("rebuild",Kt),sizeAccessor:Ht("rebuild",Ut),symbolAccessor:Ht("rebuild",Ut),pointIdAccessor:Ht("rebuild",Ut),xScaleType:Ht("preserve",Vt),yScaleType:Ht("preserve",Vt),xExtent:Ht("preserve",Vt),yExtent:Ht("preserve",Vt),extentPadding:Ht("preserve",Vt),scalePadding:Ht("preserve",Vt),axisExtent:Ht("preserve",Vt),binSize:Ht("preserve",Vt),normalize:Ht("preserve",Vt),heatmapAggregation:Ht("preserve",Vt),heatmapXBins:Ht("preserve",Vt),heatmapYBins:Ht("preserve",Vt),arrowOfTime:Ht("preserve",qt),baseline:Ht("preserve",qt),stackOrder:Ht("preserve",qt),sizeRange:Ht("preserve",qt),curve:Ht("preserve",qt),areaGroups:Ht("preserve",qt),customLayout:Ht("preserve",qt),layoutConfig:Ht("preserve",qt),layoutMargin:Ht("preserve",qt),symbolMap:Ht("preserve",Ut),showValues:Ht("preserve",Ut),heatmapValueFormat:Ht("preserve",Ut),lineStyle:Ht("preserve",Kt),pointStyle:Ht("preserve",Kt),areaStyle:Ht("preserve",Kt),barStyle:Ht("preserve",Kt),swarmStyle:Ht("preserve",Kt),waterfallStyle:Ht("preserve",Kt),candlestickStyle:Ht("preserve",Kt),boundsStyle:Ht("preserve",Kt),gradientFill:Ht("preserve",Kt),lineGradient:Ht("preserve",Kt),colorScheme:Ht("preserve",Kt),themeCategorical:Ht("preserve",Kt),themeSemantic:Ht("preserve",Kt),themeSequential:Ht("preserve",Kt),themeDiverging:Ht("preserve",Kt),barColors:Ht("preserve",Kt),decay:Ht("preserve",Kt),pulse:Ht("preserve",Kt),staleness:Ht("preserve",Kt),layoutSelection:Ht("preserve",Kt),annotations:Ht("preserve",["overlay","accessibility","evidence"]),windowSize:Ht("preserve",Qt),windowMode:Ht("preserve",Qt),maxCapacity:Ht("preserve",Qt),clock:Ht("preserve",Qt),transition:Ht("preserve",Qt),introAnimation:Ht("preserve",Qt),onLayoutError:Ht("preserve",Qt)},Jt=Ht("preserve",qt),en=class{constructor(){this.tracker=new Bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Yt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},jt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Zt[r]??Jt;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as tn}from"d3-quadtree";var nn=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,r=0;for(const e of t)"point"===e.type&&(n++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const e of t)"point"===e.type&&(o[i++]=e);this.tree=tn().x(e=>e.x).y(e=>e.y).addAll(o)}},rn=class e{constructor(e){if(this.xExtent=new G,this.yExtent=new G,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new en,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 nn,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=o??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let o=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const c=We(e,s,i);c>o&&(o=c)}a&&(c=$e(n,o,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const o=r.get(t);c=$e(n,null==o?0:We(e,o,i),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new X(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=q(e.timeAccessor||e.xAccessor,"time"),this.getY=q(e.valueAccessor||e.yAccessor,"value")):(this.getX=q(e.xAccessor,"x"),this.getY=q(e.yAccessor,"y")),this.getGroup=K(e.groupAccessor),this.getCategory=K(e.categoryAccessor),this.getSize=e.sizeAccessor?q(e.sizeAccessor,"size"):void 0,this.getColor=K(e.colorAccessor),this.getSymbol=K(e.symbolAccessor),this.getY0=e.y0Accessor?q(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=wt(e),this.getPointId=K(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?q(e.openAccessor,"open"):void 0,this.getHigh=q(e.highAccessor,"high"),this.getLow=q(e.lowAccessor,"low"),this.getClose=n?q(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new X(e.windowSize))}currentTime(){return this.config.clock?.()??Me()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(e,t){const n=new X(e.capacity);return e.forEach(()=>n.push(t)),n}(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?q(this.config.timeAccessor||this.config.xAccessor,"time"):q(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(Z(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>J(t[e]):e=>J(n(e))}}o=this.timestampBuffer,(r=e.totalSize||e.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),o&&r>o.capacity&&o.resize(r));for(const n of e.inserts)Tt(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Tt(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}var n,r,o;return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=Ct(this.xExtent.extent,t.xExtent),c=Ct(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:o}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=r(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),h.set(e.key,n)}const d=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let y,p;if("input"===d)y=n.map(e=>e.key);else if("insideOut"===d){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}),t=[],r=[];let o=0,i=0;for(const n of e)i>o?(t.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);y=[...r.reverse(),...t]}else y="asc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Be(e,y,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,o=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;r>e&&(r=e),e+i>o&&(o=e+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,l=i?0:s>0?s*t.extentPadding:1;p=[r-l,o+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,o=0;for(const i of e){let e=0,s=0;for(const r of t){const t=n(r,i)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>o&&(o=e)}return[r,o]}(e,y,(e,t)=>a.get(e)?.get(t)||0),o=r-n,s=i?0:o>0?o*t.extentPadding:1;p=[n-s,r+s]}else p=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,r,o,i,s){const[,a]=function(e,t,n,r,o){const i=gt(e,t,n,r,o);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,r){const[o,i]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(e,t),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,h):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[r,o]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(c,i,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}(c,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const r=t[0],o=t[1];return null==r&&null==o?e:[null!=r?r:e[0],null!=o?o:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:o}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:At().domain(r).range(e),y:Pt(t.yScaleType,o,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Pt(t.yScaleType,o,[s,n.width-s]),y:At().domain(r).range(e)}}var a;return{x:Pt(t.xScaleType,r,[s,n.width-s]),y:Pt(t.yScaleType,o,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i,this.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:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Pt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,o,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??ke},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,r=bt("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return mt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const o={scales:r,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),r=[],o=e.config.annotations?.filter(Je).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Oe(t.data,e.scales,e.getX,e.getY,n,t.key);o&&o.length>0&&(i.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return Ze(e,n,r),r}(o,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}const o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Fe(t.data,e.scales,e.getX,e.getY,o,n,t.key,i),a=tt(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),r.push(s)}return Ze(e,n,r),r}(o,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}const i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=Fe(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=tt(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=Oe(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return Ze(e,n,r),r}(o,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",o=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of n){let n=0;for(const t of r.data){const r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}t.set(r.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)n.sort((e,n)=>{const r=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==r?r:o(e.key,n.key)});else if("desc"===r)n.sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,r,o,i,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of l){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Be(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!i,y=[],p=new Map,g=new Map,m=new Map,v=new Map;for(const e of l)g.set(e,d.get(e)??0),m.set(e,0),v.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),y.push(e)}a=[],c=[]};for(const n of l){const o=e.has(n);let s,l,u=o?e.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=v.get(n),l=s+u,v.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const y=t.x(n);c.push([y,t.y(s)]),a.push([y,t.y(l)]),r.set(n,l)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=c.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>t.get(n)??e.getY(n);Ze(e,n,l,r)}return l}(o,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=ht[h%ht.length],h++,u.set(e,n)),n};for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},l=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(l=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(o);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(c){const r=d(c(o)+""),i=je(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);i&&n.push(i)}else{const r=Ye(o,e.scales,e.getX,e.getY,l,t,u);r&&n.push(r)}}return n}(o,t);case"heatmap":return pt(o,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=gt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const o=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(o),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=o.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:c,order:r})}const o=[],i=e.scales,[s,a]=i.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=i.x(n),y=i.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,v=Math.max(p-g,1);if(v>0)if(r&&t.categories.size>0){let n=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(He(m,Math.min(a,u),v,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=i.y(0),n=i.y(t.total);o.push(He(m,Math.min(e,n),v,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...d},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(o,t);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},o=r.radius??3,i=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,c=r.strokeWidth;for(const r of t){const t=e.getX(r),l=e.getY(r);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),h=e.scales.y(l);let d=i;if(e.getCategory){const t=e.getCategory(r);d=e.config.barColors?.[t]||d}const{r:f,...y}=e.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...y},datum:r};e.getPointId&&(p.pointId=e.getPointId(r)+""),n.push(p)}return n}(o,t);case"waterfall":return function(e,t,n){const r=[],o=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=i?.opacity;let f=0;for(let t=0;s.length>t;t++){const y=s[t],p=e.getX(y),g=e.getY(y),m=f+g;let v;v=s.length-1>t?e.getX(s[t+1])-p:t>0?p-e.getX(s[t-1]):0;const x=o.x(p),b=0!==v?o.x(p+v):x+n.width/10,k=Math.min(x,b)+l/2,w=Math.max(x,b)-l/2-k;if(0>=w){f=m;continue}const A=o.y(f),S=o.y(m),_=Math.min(A,S),M=Math.abs(A-S),C={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(C.opacity=d),r.push(He(k,_,w,M,C,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(o,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const r=[],o=e.config.candlestickStyle||{},i=o.rangeColor||"#6366f1",s=n?i:o.upColor||"#28a745",a=n?i:o.downColor||"#dc3545",c=n?i:o.wickColor||"#333",l=o.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));r>0&&t>r&&(t=r)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const i=e.getHigh(o),u=e.getLow(o);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const d=n?i:e.getOpen(o),f=n?u:e.getClose(o);if(!n&&[d,f].some(e=>null==e||Number.isNaN(e)))continue;const y=f>=d,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(d),closeY:e.scales.y(f),highY:e.scales.y(i),lowY:e.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:y,datum:o};n&&(p.isRange=!0),r.push(p)}return r}(o,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const o=e.boundsStyle;return"function"==typeof o?o(n||{},t):o&&"object"==typeof o?o:{fill:r(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Ee(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Ie(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=Ie(n)){const o=n.length;if(o>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=r.get(t[n]);null!=a?(i[n]=Ee(e,a,o),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=r.get(t[n]);null!=i?(s[n]=Ee(e,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=r.get(n);if(null!=t){const n=Ee(e,t,o);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const i=Ee(e,t,o);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,o=t.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer,e)}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(e,t,n,r){n.clear(),r.clear();for(let o=0;t.length>o;o++){const i=t[o],s=ze(e,i,o);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(s,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=ze(this.transitionContext,n,t);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,o,i=Me()){if(0===r.size&&0===o.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=ze(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=o.get(s);if(e){if(l.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=r.get(s);if("point"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of o)if(!l.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}for(const[e,t]of r)if(!c.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const r=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){if(!n.activeTransition)return!1;const o=Se(e,n.activeTransition),i=Ae(o,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=_e(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=_e(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==n.w&&(e.w=_e(n.w,e._targetW,i)),void 0!==n.h&&(e.h=_e(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:_e(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==n.w&&(e.w=_e(n.w,e._targetW,i)),void 0!==n.h&&(e.h=_e(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:_e(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=_e(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=_e(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=_e(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=_e(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_e(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=_e(t[r][0],n[r][0],i),e.path[r][1]=_e(t[r][1],n[r][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_e(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=_e(t[n][0],r[n][0],i),e.topPath[n][1]=_e(t[n][1],r[n][1],i);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=_e(n[t][0],o[t][0],i),e.bottomPath[t][1]=_e(n[t][1],o[t][1],i)}}if(o>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,r){if(r&&r.version===n&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}o=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:n,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,o){if(o&&o.version===r)return{map:o.map,cache:o};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const s=Array.from(i).sort(),a=s.join("\0");if(o&&o.key===a){const e={...o,version:r};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||ke,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,r){const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const o=e.areaStyle(n||{});if(o&&!o.fill&&t){const e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:r}=function(e){const{group:t,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=r.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||ke;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,r.set(t,l),r.size>o){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ee(e),n=this.getPointId,r=e=>t.has(n(e));!function(e,t,n){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{n(e)&&r.add(t)}),0===r.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=ee(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},o=n(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=i||!V(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!V(n,s);(a||c)&&(e?(this.getX=q(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=q(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=q(this.config.xAccessor,"x"),this.getY=q(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=wt(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!V(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?K(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!V(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?K(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!V(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?q(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!V(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?K(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!V(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?K(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!V(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?q(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!V(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=wt(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!V(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?K(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!V(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!V(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!V(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!V(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?q(this.config.openAccessor,"open"):void 0,this.getHigh=q(this.config.highAccessor,"high"),this.getLow=q(this.config.lowAccessor,"low"),this.getClose=t?q(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of n)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};rn.GROUP_COLOR_MAP_CAP=1e3;var on=rn;$t(on);import{memo as sn,useEffect as an,useRef as cn}from"react";var ln={sceneGeometry:0,layout:0,domain:0};function un(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function hn(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var dn="production"!==process.env.NODE_ENV,fn={revisions:ln,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},yn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=ln,this.lastObserved=ln,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){dn&&(this.lastObserved=hn(this.lastObserved,un(e)))}beforeCompute(e,t){if(!dn)return fn;const n=hn(un(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(dn){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};function pn(e){return cn(new yn(e))}var gn=sn(function({store:e,diagnostics:t}){return an(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null});import*as mn from"react";function vn(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:mn.createElement(mn.Fragment,null,...t)}import*as xn from"react";import{jsx as bn}from"react/jsx-runtime";var kn=xn.createContext(null);function wn({value:e,children:t}){return bn(kn.Provider,{value:e,children:t})}function An(e,t){return null!=e?bn(wn,{value:t,children:e}):e}import{useEffect as Sn,useRef as _n}from"react";function Mn(e,t,n,r){Sn(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}function Cn(e,t,n,r){const o=_n(null);Sn(()=>{const i=e.current;if(!i)return;const s=t??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[t,r,e,n])}function Pn(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function Tn(e,t=30){return Math.max((e??4)+5,12,t)}function Rn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Dn(e,t){const n=Rn(e);if(!n)return!1;const r=Rn(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function Nn(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var Ln=[40,40],En=[.5,.5];function In(e,t){const[n,r]=e.viewBox??Ln,[o,i]=e.anchor??En,s=r>0?r:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-o*c,offsetY:-i*l}}function Wn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var $n=null;function zn(e){if("undefined"==typeof Path2D)return null;$n||($n=new Map);const t=$n.get(e);if(t)return t;const n=new Path2D(e);return $n.size>1024&&$n.clear(),$n.set(e,n),n}function On(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??Ln,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Fn(e,t){const n=In(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Bn(e,t,n,r,o,i=e=>e){for(const s of t.parts){const t=zn(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=o?"none"===s.fill?void 0:o:Wn(s.fill,n,r);l&&(e.fillStyle=i(l),e.fill(t));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:Wn(s.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}function Yn(e,t,n,r,o,i=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(r,o+5,12),l=t-c,u=t+c,h=n-c,d=n+c;let f=null,y=1/0;return e.visit((e,o,c,p,g)=>{if(o>u||l>p||c>d||h>g)return!0;if(!e.length){let o=e;do{const e=o.data,c=i(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);Tn(a(e),r)>=u&&y>u&&(f=e,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}var jn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Hn=new WeakMap,Xn=0,Gn=!1,Vn=null,qn=null;function Un(e,t){if(!t)return t;const n=jn.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if(Gn)return;if("undefined"==typeof window||"undefined"==typeof document)return;Gn=!0;const e=()=>{Xn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Vn=window.matchMedia("(prefers-color-scheme: dark)"),qn=e,"function"==typeof Vn.addEventListener?Vn.addEventListener("change",qn):"function"==typeof Vn.addListener&&Vn.addListener(qn)}catch{}}();let o=Hn.get(r);o&&o.version===Xn||(o={version:Xn,map:new Map},Hn.set(r,o));const i=o.map.get(t);if(void 0!==i)return i;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return o.map.set(t,s),s}var Kn=null;import{jsx as Qn,jsxs as Zn}from"react/jsx-runtime";function Jn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function er(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var tr=new Map;function nr(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*i));return Zn("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&Qn("rect",{width:c,height:c,fill:n}),Qn("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:o,strokeOpacity:a}),Qn("line",{x1:i,y1:0,x2:i,y2:c,stroke:r,strokeWidth:o,strokeOpacity:a})]},t)}function rr(e,t,n="#4e79a7"){if(Jn(e)){const n=function(e,t){let n=2166136261;const r=er(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:nr(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}import{curveMonotoneX as or,curveMonotoneY as ir,curveCardinal as sr,curveCatmullRom as ar,curveStep as cr,curveStepBefore as lr,curveStepAfter as ur,curveBasis as hr,curveNatural as dr}from"d3-shape";function fr(e){switch(e){case"monotoneX":return or;case"monotoneY":return ir;case"cardinal":return sr;case"catmullRom":return ar;case"step":return cr;case"stepBefore":return lr;case"stepAfter":return ur;case"basis":return hr;case"natural":return dr;default:return null}}function yr(e,t,n){if(null==t)return n;if(Jn(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${er(e)}@${n}`,o=tr.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Kn||(Kn=document.createElement("canvas")),Kn.width=e,Kn.height=e,Kn)}(a)}catch{return null}const l=c.getContext("2d");if(!l)return null;n&&"transparent"!==n?(l.fillStyle=n,l.fillRect(0,0,a,a)):l.clearRect(0,0,a,a),l.strokeStyle=r,l.lineWidth=o,l.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=i)l.beginPath(),l.moveTo(t,0),l.lineTo(t+e*a,a),l.stroke()}else{l.save(),l.translate(a/2,a/2),l.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=i)l.beginPath(),l.moveTo(-e,t),l.lineTo(e,t),l.stroke();l.restore()}return(t||l).createPattern(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return tr.set(r,i),i}(t,e);return r||t.background&&Un(e,t.background)||n}return"string"!=typeof t?t:Un(e,t)||n}function pr(e,t,n,r,o,i,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(r,o,i,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),h=e.createLinearGradient(r,o,i,s),[d,f,y]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const o=e.fillStyle;if(e.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${y},${l})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function gr(e,t,n,r,o,i){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,r,o,i);for(const e of s)a.addColorStop(e.offset,e.color);return a}import{line as mr}from"d3-shape";var vr=new WeakMap;function xr(e,t){const n=fr(t);if(!n)return e;const r=vr.get(e);if(r)return r;const o=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let o=null;const i={moveTo(e,t){o=[e,t],r.push([e,t])},lineTo(e,t){o=[e,t],r.push([e,t])},bezierCurveTo(e,t,i,s,a,c){if(!o)return o=[a,c],void r.push([a,c]);const[l,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*l+3*d*d*h*e+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*c])}o=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){o=[n,i],r.push([n,i])}};return mr().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),r}(e,n);return vr.set(e,o),o}function br(e,t,n,r=30,o,i=0){let s=null;if(o){const e=Yn(o,t,n,r,i);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(o)break;e=wr(i,t,n,r);break;case"symbol":e=Ar(i,t,n,r);break;case"glyph":e=Sr(i,t,n,r);break;case"line":e=_r(i,t,n,r);break;case"rect":if(null==i.datum)break;e=Cr(i,t,n);break;case"heatcell":e=Pr(i,t,n);break;case"area":if(!1===i.interactive)break;e=Rr(i,t,n);break;case"candlestick":e=Tr(i,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function kr(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=Dr(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[s,a]=e[o],[c,l]=e[i];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function wr(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Tn(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Ar(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Tn(ft(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Sr(e,t,n,r=30){if(null==e.datum)return null;const o=Fn(e.glyph,e.size),i=e.x+o.centerDx,s=e.y+o.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Tn(o.radius,r)?null:{node:e,datum:e.datum,x:i,y:s,distance:l}}function _r(e,t,n,r=30){if(0===e.path.length)return null;const o=Dr(e.path,t);if(0>o)return null;const[i,s]=e.path[o];let a;if(e.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(e.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=e.path[o],[a,c]=e.path[o+1],l=Mr(t,n,i,s,a,c);r>l&&(r=l)}a=r}else{const e=t-i,r=n-s;a=Math.sqrt(e*e+r*r)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function Mr(e,t,n,r,o,i){const s=o-n,a=i-r,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-r)**2);let l=((e-n)*s+(t-r)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(r+l*a))**2)}function Cr(e,t,n){const r=Pn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Pr(e,t,n){const r=Pn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Tr(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function Rr(e,t,n){if(0===e.topPath.length)return null;const r=Dr(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],s=t-o,a=n-i,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:c}}function Dr(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as Nr,useRef as Lr}from"react";var Er={fresh:1,aging:.7,stale:.45,expired:.25},Ir={alpha:1,band:"fresh",isStale:!1};function Wr(e,t){if(!e||0>=t)return Ir;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=Pe(t,n,e.thresholds);return{alpha:{...Er,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Ir}function $r(e,t,n,r,o,i){const s=Lr("fresh");Nr(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Wr(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===o||(s.current=l.band,l.isStale!==o&&i(l.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r,t,i,n])}import{jsx as zr}from"react/jsx-runtime";function Or({isStale:e,position:t}){return zr("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as Fr,useRef as Br,useEffect as Yr}from"react";import*as jr from"react";import{jsx as Hr,jsxs as Xr}from"react/jsx-runtime";var Gr={fill:(e,t)=>Hr("rect",{style:e,width:t,height:t}),line:(e,t)=>Hr("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Vr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Gr[n])(r(e,t),o),i}function qr({swatchSize:e}){return Hr("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ur(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Kr=(e,t,n,r,o,i,s,a,c,l,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let p=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=o,{swatchSize:v,labelGap:x,rowHeight:b}=u;return f.forEach((e,l)=>{const u=Vr(e,l,h,d,v),k=Ur(e,r,o),w=o&&o.size>0&&o.has(e.label);y.push(Xr("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&Hr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+x+2+7*e.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&Hr(qr,{swatchSize:v}),Hr("text",{y:v/2,x:v+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),p+=b}),y};function Qr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+jr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(Hr("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return Xr("g",{"aria-label":i||"Gradient legend",children:[Hr("defs",{children:Hr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&Hr("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Hr("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),Hr("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),Hr("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(Hr("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return Xr("g",{"aria-label":i||"Gradient legend",children:[i&&Hr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Hr("defs",{children:Hr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),Hr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),Hr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),Hr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function Zr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:h}=e,d=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(h),[f,y]=jr.useState(0),[p,g]=jr.useState(0),m=jr.useCallback((e,t)=>{y(e),g(t)},[]),v="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let h=24;const d=[];return e.forEach((e,f)=>{h+=5,d.push(Hr("line",{stroke:"gray",x1:0,y1:h,x2:t,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,e.label&&(h+=16,d.push(Hr("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),h+=8),d.push(Hr("g",{className:"legend-item",transform:`translate(0,${h})`,children:Kr(e,n,r,o,i,s,a,f,c,l,u)},"legend-group-"+f)),h+=e.items.length*u.rowHeight+8}),d})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:h})=>{let d=0;const f=[];e.forEach((e,t)=>{let y=0;e.label&&(y+=16);const p=((e,t,n,r,o,i,s,a,c,l,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,p=[],{swatchSize:g,labelGap:m,itemGap:v,rowHeight:x,align:b}=u,k=!(!t&&!n),w="isolate"===l||void 0===l&&null!=o,A=y.map(e=>g+m+7*e.label.length),S=[];let _=0,M=0;A.forEach((e,t)=>{const n=0===M?e:M+v+e;h&&h>0&&M>0&&n>h?(S.push({start:_,end:t,width:M}),_=t,M=e):M=n}),y.length>0&&S.push({start:_,end:y.length,width:M}),S.forEach((e,l)=>{let u="center"===b?Math.max(0,((h??e.width)-e.width)/2):"end"===b?Math.max(0,(h??e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=y[h],b=Vr(e,h,d,f,g),S=Ur(e,r,o),_=o&&o.size>0&&o.has(e.label);p.push(Xr("g",{transform:`translate(${u},${l*x})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?_||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{c(a,h),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&Hr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,_&&Hr(qr,{swatchSize:g}),Hr("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),u+=A[h]+v}});const C=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:p,offset:C,totalRows:P,totalHeight:P*x}})(e,r,o,i,s,a,c,t,l,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:e.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(g.push(Hr("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),p+=16),g.push(Hr("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push(Hr("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),Hr("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),x=!(!n&&!r);return Xr("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&Hr("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),v]})}function Jr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as eo}from"react/jsx-runtime";function to(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===i||"bottom"===i,y=!!a,p=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,v;return"left"===i?(m=Math.max(4,o.left-g-10),v=o.top):"top"===i?(m=o.left,v=y?32:8):"bottom"===i?(m=o.left,v=r-o.bottom+38):(m=n-o.right+10,v=o.top),eo("g",{transform:`translate(${m}, ${v})`,children:(x=t,"object"==typeof x&&null!==x&&"gradient"in x?eo(Qr,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):Jr(t)?eo(Zr,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t)});var x}import{useMemo as no}from"react";import{bin as ro}from"d3-array";function oo(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}import{jsx as io,jsxs as so}from"react/jsx-runtime";function ao(e){return"string"==typeof e?{type:e}:e}function co({orient:e,config:t,values:n,scale:r,size:o,length:i}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,c=no(()=>{if(0===n.length)return null;const t=r.domain(),c=o-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:o,median:i,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*c,20),f=(c-d)/2+4;if(a){const t=r(o),n=r(l),a=r(i),c=r(u),y=r(h),p="top"===e?-1:1,g=0;return so("g",{"data-testid":"marginal-boxplot-"+e,children:[io("line",{x1:c,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:c,y1:g+p*f,x2:c,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),io("rect",{x:Math.min(t,n),y:"top"===e?g-f-d:g+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),io("line",{x1:a,y1:"top"===e?g-f-d:g+f,x2:a,y2:"top"===e?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const t=r(o),n=r(l),a=r(i),c=r(u),y=r(h),p="left"===e?-1:1,g=0;return so("g",{"data-testid":"marginal-boxplot-"+e,children:[io("line",{x1:g+p*(f+d/2),y1:c,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:g+p*f,y1:c,x2:g+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),io("rect",{x:"left"===e?g-f-d:g+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),io("line",{x1:"left"===e?g-f-d:g+f,y1:a,x2:"left"===e?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=ro().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return io("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/u*c;if(a){const i=r(t.x0),a=r(t.x1)-r(t.x0);return io("rect",{x:i,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(t.x0),a=r(t.x1)-r(t.x0);return io("rect",{x:"left"===e?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const o of l){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(c/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let o=l.length-1;o>=0;o--){const i=l[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(c/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return io("g",{"data-testid":"marginal-violin-"+e,children:io("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,o=null!=l[0].x0?r(l[0].x0):0;t.push(`M${o},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,i=r((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-o-4:o+4}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,o=null!=l[0].x0?r(l[0].x0):0;t.push(`M${n},${o}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,i=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${i}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return io("g",{"data-testid":"marginal-ridgeline-"+e,children:io("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,o,i,e,a,4]);return c?io("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}import*as lo from"react";import{jsx as uo,jsxs as ho}from"react/jsx-runtime";function fo(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let s="";for(const e of o)s&&s.length+1+e.length>r?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function yo(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function po(e,t,n,r){if(!e)return uo("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!o&&!i)return uo("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>t?"end":"start";const f=16,y=i?l?[i]:fo(i,c):[],p=o?l?[o]:fo(o,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const v=[],x=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?v.push(uo("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(y.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:ho("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:x,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[i&&uo("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&uo("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(v.push(uo("text",{className:"annotation-note-title",fill:x,textAnchor:d,fontWeight:"bold",children:y.map((e,t)=>uo("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=y.length*f),p.length>0&&v.push(uo("text",{className:"annotation-note-label",fill:x,textAnchor:d,y:m,children:p.map((e,t)=>uo("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let b=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),b=uo("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),b=uo("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),ho("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[uo("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:v}),b]})}function go(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(uo("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push(uo("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push(uo("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;i.push(uo("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(uo("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push(uo("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push(uo("path",{d:yo(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return uo("g",{className:"annotation-subject",children:i})}function mo(e,t,n,r,o,i){const s=[];let a=0,c=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=e-o,l=t-i;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=o+s*d,c=i+l*d}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,c=Math.sin(r)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(i){const r=(a+e)/2,i=(c+t)/2,h=-(t-c)/l,d=(e-a)/l,f=(n?.curve??.25)*l,y=r+h*f,p=i+d*f;s.push(uo("path",{className:"connector-curve",d:`M${a},${c}Q${y},${p} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-c,y-a)}else s.push(uo("line",{x1:a,y1:c,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push(uo("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return uo("g",{className:"annotation-connector",children:s})}function vo(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=e,v=Array.isArray(t)?t[0]??0:t,x=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-v),null!=s&&(w=s-x);const A="string"==typeof u?u:"label";if("bracket"===A&&l&&0===k&&0===w)if(void 0!==l.width){k=l.width/2;const e=l.depth||30;w=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;k=e+(0>e?-5:5),w=l.height/2}return ho("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${v},${x})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&mo(k,w,c,h,A,l),!b.has("subject")&&go(A,l,h,v,x),!b.has("note")&&po(a,k,w,h)]})}function xo(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return uo(vo,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return uo("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return uo(vo,{"data-testid":"semiotic-annotation",events:o,...t,type:r},s)}import{packEnclose as bo}from"d3-hierarchy";import{area as ko,curveLinear as wo,curveMonotoneX as Ao,curveMonotoneY as So,curveStep as _o,curveStepAfter as Mo,curveStepBefore as Co,curveBasis as Po,curveCardinal as To,curveCatmullRom as Ro}from"d3-shape";function Do(e){return Math.round(100*e)/100}function No(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const s=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));s.push(r)}r.push(s)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(Do);return{points:e.map(([e])=>[Do(e),Do(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function Lo(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Eo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Io(e){return null==e?null:e+""}function Wo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function $o(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return Wo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?Wo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return Io(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>Io(e.pointId)===r);if(o)return Wo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return Io(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const s=Lo(i,n),a=Eo(i,n);return null==s||null==a?null:Wo(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=Lo(e,n),i=Eo(e,n)),null!=o&&null!=i)return Wo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function zo(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}import{jsx as Oo}from"react/jsx-runtime";var Fo={secondary:0,primary:3},Bo=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function Yo(e){return!0===e?._annotationDeferred}function jo(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Ho(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Xo(e){return Math.max(.72,.95-.06*e)}import*as Go from"react";var[Vo,qo]=E(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Uo(e){const t=qo(e=>e.pushObservation),n=Go.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Go.useMemo(()=>({...e,onObservation:n}),[n,e])}function Ko(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function Qo(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}import{jsx as Zo,jsxs as Jo}from"react/jsx-runtime";var ei="var(--semiotic-bg, #ffffff)";function ti(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=e,d=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>Zo("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:h,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??ei,strokeWidth:d.haloWidth??3});const y=d.padding??{x:6,y:3},p="number"==typeof y?y:y.x,g="number"==typeof y?y:y.y,m=function(e,t){return(e+"").length*t*.6}(r,i),v=i+2*g;let x,b;return x="middle"===c?t-m/2-p:"end"===c?t-m-p:t-p,b="middle"===l||"central"===l?n-v/2:"hanging"===l||"text-before-edge"===l?n-g:n-.8*i-g,Jo("g",{className:h,children:[Zo("rect",{x:x,y:b,width:m+2*p,height:v,rx:d.radius??3,ry:d.radius??3,fill:d.fill??ei,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}import{jsx as ni,jsxs as ri}from"react/jsx-runtime";var oi={linear:wo,monotoneX:Ao,monotoneY:So,step:_o,stepAfter:Mo,stepBefore:Co,basis:Po,cardinal:To,catmullRom:Ro};function ii(e,t,n,r){const o=[];return e.forEach((e,i)=>{let s;if(n){const o=n(e,i,r);s=null!=o?o:t(e,i,r)}else s=t(e,i,r);s&&o.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Ho(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Yo(e.annotation)),o=e.some(e=>null!=jo(e.annotation)),i=e.some(e=>"layer"===jo(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Fo[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=Yo(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;s=Oo("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Xo(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const a=jo(t.annotation);return a&&(s=Oo("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=Oo("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(Oo("style",{children:Bo},"annotation-disclosure-style")),i&&a.unshift(Oo("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o)}function si(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=$o(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!zo(o,i,r))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return ni(xo,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=Lo(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const a=t>.6*(r.width||0),c=a?t-4:t+4,l=a?"end":"start";return ri("g",{opacity:e.opacity,children:[ni("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni(ti,{x:c,y:s,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=Eo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(r.width||0)/2,c="middle"):(a=(r.width||0)-4,c="end");const l=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return ri("g",{opacity:e.opacity,children:[ni("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni(ti,{x:a,y:l,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:Lo({...e,type:"point"},r),y:Eo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=bo(t),i=e.padding||10;return ri("g",{children:[ni("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&ni(ti,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:Lo({...e,type:"point"},r),y:Eo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=oo(i),[l,u]=oo(s),h=a-o,d=c+o,f=l-o;return ri("g",{children:[ni("rect",{x:h,y:f,width:d-h,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&ni(ti,{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return ni("g",{children:o.map((t,n)=>{const o=Lo(t,r),s=Eo(t,r);if(null==o||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return ni("circle",{cx:o,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=Lo(e,r),o=Eo(e,r);return ni(xo,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,c=s?o:null,l=s?i:null;let u;const h=[],d=new Map;if(s&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,y=r.scales?.y??r.scales?.value;if(!f||!y)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(h.length-1,n+1),o=t-n,i=e(h[n]);return i+(e(h[r])-i)*o},g=f,m=y;let v;if(s)if(a){const e=p(m);v=(t,n)=>[g(n),e(t)]}else{const e=p(g);v=(t,n)=>[e(t),m(n)]}else v=(e,t)=>[g(e),m(t)];const x=e.method||"linear";let b;if("loess"===x)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),c=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:r[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,h+=t*o[e],d+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([t,d/u]);else{const e=(u*y-h*d)/p;a.push([t,(d-e*h)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===x?No(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:Do((n*t[3]-t[0]*t[1])/r),i=Do(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[Do(e),Do(o*e+i)]),equation:[o,i]}}(u);b=t.points}const k=b.map(([e,t])=>{const[n,r]=v(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",A=b[b.length-1],[S,_]=v(A[0],A[1]);return ri("g",{children:[ni("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.(e.y0)??0,a=t?.(e.y1)??(r.height||0),c=rr(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return ri("g",{opacity:e.opacity,children:[c.def&&ni("defs",{children:c.def}),ni("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:c.fill,fillOpacity:e.fillOpacity||.1}),e.label&&ni(ti,{x:(r.width||0)-4,y:(o=s,i=a,Math.max(Math.min(o,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=null!=e.x0&&t?t(e.x0):null,i=null!=e.x1&&t?t(e.x1):null;if(null==o||null==i)return null;const s=rr(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return ri("g",{opacity:e.opacity,children:[s.def&&ni("defs",{children:s.def}),ni("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:r.height||0,fill:s.fill,fillOpacity:e.fillOpacity??.1}),e.label&&ni(ti,{x:Math.min(o,i)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const h=oi[r.curve||"linear"]||wo,d=ko().x(e=>i(e[o])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return ri("g",{children:[ni("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&ni("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),h=e.threshold??2,d=c-h*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,v=s(c+h*u),x=s(d),b=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-c)>h*u});return ri("g",{children:[f&&ni("rect",{x:0,y:Math.min(v,x),width:r.width||0,height:Math.abs(x-v),fill:y,fillOpacity:p}),b.map((e,t)=>{const n=Lo(e,r),o=Eo(e,r);return null==n||null==o?null:ni("circle",{cx:n,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&ni("text",{x:(r.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=No(c,e.order||2).equation;l=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=c.length;let t=0,n=0,r=0,o=0;for(const[e,i]of c)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const s=(e*o-t*n)/i,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,h=c.map(([e,t])=>t-l(e)),d=h.reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),y=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-y)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,v=e.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),k=[];for(let e=1;v>=e;e++)k.push(x+e*b);const w=[];for(const e of k){const t=l(e),n=f*Math.sqrt(1+1/u+(p>0?(e-y)**2/p:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),_=`${s(x)},${a(l(x))}`,M=e.strokeColor||"#6366f1";return ri("g",{children:[ni("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),ni("polyline",{points:`${_} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&ni("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=$o(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!zo(o,i,r))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??ni("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return ni("foreignObject",{x:o+s-c/2,y:i+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:ni("div",{...Ko(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=$o(e,n,r);if(!t)return null;const{x:o,y:i}=t,s=o+(e.dx||0),a=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=ni("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?lo.cloneElement(l,{key:"ann-text-"+n}):ri("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[ni("line",{x1:o,y1:i,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),lo.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,s=r.scales?.x,a=r.scales?.y,c=o(i)?i:o(s)?s:o(a)?a:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return ri("g",(r.projection?"vertical"===r.projection:c===s)?{children:[ni("rect",{x:l,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&ni(ti,{x:l+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[ni("rect",{x:0,y:l,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&ni(ti,{x:12,y:l+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,s}}var ai=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function ci(e){return!!e&&"object"==typeof e&&ai.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function li(e){return"primary"===e?.emphasis||!0===e?.defensive}function ui(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function hi(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var di=32,fi=6,yi=4,pi=8,gi=72;var mi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function vi(e){if(!xi(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function xi(e){return ci(e)}function bi(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function ki(e,t,n,r,o){const i=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function wi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ai(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Si(e,t,n,r,o,i,s,a){const c=wi(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(c,o,i,a);for(const e of n)l+=12*Ai(c,e);for(const e of r)l+=4*Ai(c,e);return l}function _i(e){const{annotations:t,context:n,defaultOffset:r=di,notePadding:o=fi,markPadding:i=yi,edgePadding:s=pi,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=gi,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=e,m=n.width||0,v=n.height||0,x="object"==typeof y?y:{},b=x.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==x.preferShortText?t.map(vi):t,A=k&&!u?{maxAnnotations:x.maxAnnotations??("callout-list"===x.strategy?1:2),minVisible:x.minVisible??1}:u,S=h||k&&(!1!==x.progressiveDisclosure||"callout-list"===x.strategy),_=k&&!f?x.responsive??{minWidth:b}:f,M=k&&!p?x.cohesion:p;if(0===w.length||0>=m||0>=v)return w.slice();const C=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let T=!1;const R=w.map((e,t)=>{if(!xi(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?$o(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...bi("string"==typeof e.title?e.title:void 0,t),...bi("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(h=e).dx||"number"==typeof h.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return C.push(wi(ki(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var h;let d=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Si(ki(i.x,i.y,e.dx,e.dy,u),e,C,P,m,v,o,s);f>t&&(d=e,f=t)}if(!d)return e;const y=wi(ki(i.x,i.y,d.dx,d.dy,u),o);C.push(y);const p=Math.hypot(d.dx,d.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return T=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),D=T?R:w.slice();let N=D;if(d){let e=!1;const t=D.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});N=e?t:D}{let e=!1;const t=N.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?mi[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});N=e?t:N}const L=new Set;if(A){const e="object"==typeof A?A:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ui(m,v,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=ui(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,ci(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>li(e.annotation)),l=a.filter(e=>!li(e.annotation)).sort((e,t)=>hi(t.annotation)-hi(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,o-c.length))),h=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),d=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?d.push(e):f.push(e);return{visible:d,deferred:f,budget:i}}({annotations:N,width:m,height:v,...n});for(const e of r)L.add(e)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const e of N)xi(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of N)!0===e?.defensive&&L.delete(e);let E;return E=0===L.size?N:S?N.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):N.filter(e=>!L.has(e)),M?function(e,t){let n=!1;const r=e.map(e=>xi(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(E,M):E}import{useSyncExternalStore as Mi}from"react";var Ci={positions:new Map},Pi=new Set;function Ti(){for(const e of Pi)e()}function Ri(e,t){const n=Ci.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Ci.positions);r.delete(e),Ci={positions:r},Ti()}function Di(e,t){const n=Ci.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Ci.positions);r.delete(e),Ci={positions:r},Ti()}function Ni(){return Ci}function Li(e){return Pi.add(e),()=>Pi.delete(e)}var Ei={positions:new Map};function Ii(){return()=>{}}function Wi(){return Ei}function $i(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function zi(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Oi(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Fi(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>n&&(n=r.pixel);return{min:t,max:n}}function Bi(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Yi(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*o}`,s+=`L${Math.min(n,t)},${r}`}return s}const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${r+4*o},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}import{Fragment as ji,jsx as Hi,jsxs as Xi}from"react/jsx-runtime";function Gi(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:h,axisExtent:d}=e,f=Fr(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Vi,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=e?.tickValues??$i(s.x,i,d),l=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=h.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return qi(h,Math.max(55,f+8))},[s,c,u,t,d]),y=Fr(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||h||Vi,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return qi((e?.tickValues??$i(s.y,i,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,h,n,d]),p=l&&s,g=a&&s;if(!p&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),v=c?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return Hi("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:Xi("g",{transform:`translate(${i.left},${i.top})`,children:[p&&(()=>{const e=Bi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=Bi(c?.find(e=>"left"===e.orient)?.gridStyle);return Xi("g",{className:"stream-grid",children:[f.map((t,r)=>Hi("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),y.map((e,n)=>Hi("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),x&&!k&&Hi("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&Hi("path",{d:Yi("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&Hi("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&Hi("path",{d:Yi("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function Vi(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function qi(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ui(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:v,legendClickBehavior:x,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:C,annotations:P,onAnnotationActivate:T,onObservation:R,chartId:D,chartType:N,autoPlaceAnnotations:L,svgAnnotationRules:E,xAccessor:I,yAccessor:W,annotationData:$,pointNodes:z,curve:O,underlayRendered:F,canvasObscuresUnderlay:B=!0,linkedCrosshairName:Y,linkedCrosshairSourceId:j,children:H}=e,X=Uo({onAnnotationActivate:T,onObservation:R,chartId:D,chartType:N}),G=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||d||Vi,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),l=e?.tickValues??$i(s.x,i,y),u=l.map(e=>e.valueOf()),h=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=h.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),p=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=qi(h,p);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:o})}}return g},[a,s,c,d,t,y]),V=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Vi,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let l=qi((e?.tickValues??$i(s.y,i,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=l[l.length-1].pixel;if(Math.abs(n-r)>1){const o=t(e);22>Math.abs(n-r)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:o})}}return l},[a,s,c,f,n,y]),q=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Vi,r=Math.max(2,Math.floor(n/30)),o=e.ticks??5;return qi((e.tickValues??$i(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,y]),U=Br(new Map),K=Br(P?.length??0),Q=P?.length??0;K.current!==Q&&(K.current=Q,U.current=new Map);const Z=Fr(()=>{if(!P||0===P.length)return null;const e=si(0,X),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:I,yAccessor:W,width:t,height:n,data:$,frameType:"xy",pointNodes:z,curve:O,stickyPositionCache:U.current};return ii(L?_i({annotations:P,context:r,..."object"==typeof L?L:{}}):P,e,E,r)},[P,L,E,t,n,I,W,$,s,z,O,X]),J=function(e){const t=Mi(e?Li:Ii,e?Ni:Wi,e?Ni:Wi);return e?t.positions.get(e)??null:null}(Y);return Yr(()=>{if(!J?.locked||!Y)return;const e=e=>{"Escape"===e.key&&Di(Y)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J?.locked,Y]),a||g||m||S||_||Z&&Z.length>0||p||H||J?Xi("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Hi("title",{children:"string"==typeof g?g:"XY Chart"}),Hi("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),Xi("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&(!F||B)&&(()=>{const e=Bi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=Bi(c?.find(e=>"left"===e.orient)?.gridStyle);return Xi("g",{className:"stream-grid",children:[G.map((t,r)=>Hi("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),V.map((e,n)=>Hi("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),o=!e||!1!==e.baseline,s=!r||!1!==r.baseline,a=e?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",v=!!r?.autoRotate&&G.length>1&&(()=>{const e=t/Math.max(G.length-1,1);return G.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),x=v?12:18,b=n+(v?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=r?.tickAnchor,_=e?.tickAnchor,M=Fi(G),C=Fi(V);return Xi("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[Xi("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!F||B)&&s&&!d&&Hi("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!F||B)&&d&&Hi("path",{d:Yi("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),G.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):Dn(e.value,t>0?G[t-1].value:void 0));return Xi("g",{transform:`translate(${e.pixel},${n})`,children:[Hi("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{y:x,textAnchor:v?"end":zi(S,e.pixel===M.min,e.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:v?"rotate(-45)":void 0,children:e.label}):Hi("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"center",userSelect:"none",...k},children:e.label})})]},"xtick-"+t)}),l&&Hi("text",{x:t/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:l})]}),Xi("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!F||B)&&o&&!a&&Hi("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!F||B)&&a&&Hi("path",{d:Yi("left",t,n),fill:"none",stroke:p,strokeWidth:1}),V.map((e,t)=>{const n=!!y&&("function"==typeof y?y(e.value,t):Dn(e.value,t>0?V[t-1].value:void 0));return Xi("g",{transform:`translate(0,${e.pixel})`,children:[Hi("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{x:-8,textAnchor:"end",dominantBaseline:Oi(_,e.pixel===C.min,e.pixel===C.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:e.label}):Hi("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"right",userSelect:"none",...k},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?Hi("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const r=!1!==e.baseline,o=e.landmarkTicks,s=e.label||h,a=e.tickAnchor,l=Fi(q);return Xi("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&Hi("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),q.map((e,n)=>{const r=!!o&&("function"==typeof o?o(e.value,n):Dn(e.value,n>0?q[n-1].value:void 0));return Xi("g",{transform:`translate(${t},${e.pixel})`,children:[Hi("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{x:8,textAnchor:"start",dominantBaseline:Oi(a,e.pixel===l.min,e.pixel===l.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:e.label}):Hi("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"left",userSelect:"none",...k},children:e.label})})]},"ytick-r-"+n)}),s&&Hi("text",{x:t+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),Z,_&&s&&M&&C&&Xi(ji,{children:[_.top&&Hi("g",{transform:"translate(0, 0)",children:Hi(co,{orient:"top",config:ao(_.top),values:M,scale:s.x,size:i.top,length:t})}),_.bottom&&Hi("g",{transform:`translate(0, ${n})`,children:Hi(co,{orient:"bottom",config:ao(_.bottom),values:M,scale:s.x,size:i.bottom,length:t})}),_.left&&Hi("g",{transform:"translate(0, 0)",children:Hi(co,{orient:"left",config:ao(_.left),values:C,scale:s.y,size:i.left,length:n})}),_.right&&Hi("g",{transform:`translate(${t}, 0)`,children:Hi(co,{orient:"right",config:ao(_.right),values:C,scale:s.y,size:i.right,length:n})})]}),S,J&&J.sourceId!==j&&s?.x&&(()=>{const e=s.x(J.xValue);if(null==e||0>e||e>t)return null;const r=J.locked;return Hi("line",{x1:e,y1:0,x2:e,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),H]}),g&&"string"==typeof g?Hi("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?Hi("foreignObject",{x:0,y:0,width:r,height:i.top,children:g}):null,to({legend:m,totalWidth:r,totalHeight:o,margin:i,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:v,legendClickBehavior:x,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}import*as Ki from"react";import{arc as Qi}from"d3-shape";function Zi(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}import{jsx as Ji,jsxs as es}from"react/jsx-runtime";var ts={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ns(e,t="#4e79a7"){return Jn(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function rs(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=In(o,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=On(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),h=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:Wn(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Wn(n.stroke??"none",a,e.accent);return o||i?Ji("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return es("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&Ji("clipPath",{id:l,children:Ji("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?Ji("g",{children:h(e.ghostColor)}):null,c&&l?Ji("g",{clipPath:`url(#${l})`,children:h()}):h()]},r)}var os="undefined"==typeof window||"undefined"==typeof document;import{useEffect as is,useLayoutEffect as ss,useRef as as,useState as cs,useSyncExternalStore as ls}from"react";var us="undefined"!=typeof window?ss:is;function hs(){const[e,t]=cs(!1);return us(()=>{t(!0)},[]),e}var ds=()=>()=>{},fs=()=>!1,ys=()=>!0;function ps(){const e=ls(ds,fs,ys);return as(e).current}import{useRef as gs}from"react";function ms(e){const t=gs(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return xs(e,t);if(!bs(e)||!bs(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!xs(n,o))return!1}else{if(!bs(n)||!bs(o))return!1;if(!vs(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function vs(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function xs(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function bs(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ks(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(r)return!1;const l=n||(o&&"transparent"!==o?o:"")||null;if(!l)return!1;const u=Un(e,l);return!!u&&(e.fillStyle=u,e.fillRect(i,s,a,c),!0)}var ws={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function As(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],o=n[3];return`#${e}${e}${r}${r}${o}${o}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}import*as Ss from"react";import*as _s from"react";import{jsx as Ms}from"react/jsx-runtime";var Cs=_s.createContext(null);function Ps(){return _s.useContext(Cs)}import{jsx as Ts}from"react/jsx-runtime";var Rs={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ds({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return Ts("div",{"aria-live":"polite","aria-atomic":"true",style:Rs,children:t})}function Ns(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function Ls(e){return e&&"object"==typeof e?e:{}}function Es(e){return Ls(e.accessibility).tableFields??e.accessibleDatum??e.datum}import{jsx as Is,jsxs as Ws}from"react/jsx-runtime";function $s(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function zs(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var Os=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Fs="semiotic-accessible-data-table",Bs=Fs+" semiotic-accessible-data-table-hidden",Ys=Fs+" semiotic-accessible-data-table-visible",js=Ys+" semiotic-accessible-data-table-network",Hs={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Xs={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Gs={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Vs={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},qs={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Us={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Ks={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Qs={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Zs({scene:e,chartType:t,tableId:n,chartTitle:r}){const[o,i]=Ss.useState(!1),[s,a]=Ss.useState(5),c=Ps(),l=c?.visible??!1,u=o||l,h=Ss.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ss.useEffect(()=>{u||a(5)},[u]);const f=Ss.useCallback(e=>{e.target===e.currentTarget&&(o||l||i(!0))},[o,l]),y=Ss.useCallback(e=>{l||h.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?Is("span",{id:n,tabIndex:-1,style:Rs}):null;if(!u)return Is("div",{id:n,className:Bs,tabIndex:-1,onFocus:f,style:Rs,role:"region","aria-label":d,children:Ws("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const p=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:Ns(Es(r))});break;case"line":case"area":{const e=Es(r),n=Array.isArray(e)?e:[],o="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:o,values:Ns(e)});break}case"rect":{const e=Es(r),n=null!=e&&"object"==typeof e?e:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Ns(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=Ns(Es(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Es(r),n=Ns(e);if(null==n.category){const t=Ls(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Ns(Es(r))});break;case"arc":t.push({label:"Arc",values:Ns(Es(r))});break;case"candlestick":t.push({label:"Candlestick",values:Ns(Es(r))});break;case"geoarea":{const e=Ls(Es(r)),n=Ns(e);if(null==n.name){const t=Ls(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Os(e.min)} to ${Os(e.max)}, mean ${Os(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(p.length,g),v=Math.min(s,p.length),x=p.slice(0,v),b=p.length-v,k=new Set;for(const e of x)for(const t of Object.keys(e.values))k.add(t);const w=Array.from(k);return Ws("div",{ref:h,id:n,className:Ys,tabIndex:-1,onBlur:y,style:Hs,role:"region","aria-label":d,children:[Is("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Gs,children:"×"}),Is("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Xs,children:m}),Ws("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Vs,children:[Is("caption",{className:"semiotic-accessible-data-table-caption",style:Ks,children:b>0?`First ${v} of ${p.length} data points`:`All ${p.length} data points`}),Is("thead",{children:Ws("tr",{children:[Is("th",{style:qs,children:"type"}),w.map(e=>Is("th",{style:qs,children:e},e))]})}),Is("tbody",{children:x.map((e,t)=>Ws("tr",{children:[Is("td",{style:Us,children:e.label}),w.map(t=>{return Is("td",{style:Us,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Os(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),b>0&&Ws("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Qs,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function Js({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,s]=Ss.useState(!1),[a,c]=Ss.useState(5),l=Ps(),u=l?.visible??!1,h=i||u,d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ss.useRef(null);Ss.useEffect(()=>{h||c(5)},[h]);const y=Ss.useCallback(e=>{e.target===e.currentTarget&&(i||u||s(!0))},[i,u]),p=Ss.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?Is("span",{id:r,tabIndex:-1,style:Rs}):null;if(!h)return Is("div",{id:r,className:Bs,tabIndex:-1,onFocus:y,style:Rs,role:"region","aria-label":d,children:Ws("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],v=new Map,x=new Map,b=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";x.set(e,(x.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";v.set(e,(v.get(e)??0)+1),b.set(e,(b.get(e)??0)+o)}}const w=[];for(let e=0;g.length>e;e++){const t=g[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=v.get(r)??0,i=x.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((e,t)=>t.degree-e.degree);let A=0,S=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>S&&(S=t.degree);A=e/w.length}const _=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${Os(A)}, max degree: ${S}.`);const C=Math.min(a,w.length),P=w.slice(0,C),T=w.length-C;return Ws("div",{ref:f,id:r,className:js,tabIndex:-1,onBlur:p,style:Hs,role:"region","aria-label":d,children:[Is("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Gs,children:"×"}),Is("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Xs,children:M.join(" ")}),Ws("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Vs,children:[Is("caption",{className:"semiotic-accessible-data-table-caption",style:Ks,children:T>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),Is("thead",{children:Ws("tr",{children:[Is("th",{style:qs,children:"id"}),Is("th",{style:qs,children:"degree"}),Is("th",{style:qs,children:"in"}),Is("th",{style:qs,children:"out"}),_&&Is("th",{style:qs,children:"w. degree"}),_&&Is("th",{style:qs,children:"w. in"}),_&&Is("th",{style:qs,children:"w. out"})]})}),Is("tbody",{children:P.map((e,t)=>Ws("tr",{children:[Is("td",{style:Us,children:e.id}),Is("td",{style:Us,children:e.degree}),Is("td",{style:Us,children:e.inDeg}),Is("td",{style:Us,children:e.outDeg}),_&&Is("td",{style:Us,children:Os(e.wDegree)}),_&&Is("td",{style:Us,children:Os(e.wInDeg)}),_&&Is("td",{style:Us,children:Os(e.wOutDeg)})]},t))})]}),T>0&&Ws("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Qs,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function ea({summary:e}){return e?Is("div",{role:"note",style:Rs,children:e}):null}function ta({tableId:e}){return Is("a",{href:"#"+e,style:Rs,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Rs)},children:"Skip to data table"})}import{jsx as na}from"react/jsx-runtime";var ra="var(--semiotic-focus, #005fcc)";function oa({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=na("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ra,strokeWidth:2,strokeDasharray:"4,2"})}else u=na("circle","wedge"===o?{cx:c,cy:l,r:12,fill:"none",stroke:ra,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:ra,strokeWidth:2,strokeDasharray:"4,2"});else u=na("g",{transform:`translate(${n.left},${n.top})`,children:na("path",{d:a,fill:"none",stroke:ra,strokeWidth:2.5,strokeDasharray:"6,3"})});return na("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as ia from"react";function sa(e,t){return"touch"===t?Math.max(e,24):e}function aa(e){return Array.isArray(e)?e[0]:e}function ca(e,t,n,r){return{data:aa(e),x:t,y:n,__semioticHoverData:!0,...r}}var la=["name","label","title"],ua=["type","kind","category","group","class","status","role","shape"],ha=["value","amount","total","count","weight","score"],da=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function fa(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function ya(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&da.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>la.includes(e.lower));const s=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:o[i];let c=o.filter((e,t)=>t!==i);s&&(c=c.filter(e=>"id"!==e.lower));const l=fa(c,ua),u=fa(c,ha),h=new Set(ua),d=new Set(ha),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(h.has(e.lower)||d.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}import{jsx as pa,jsxs as ga}from"react/jsx-runtime";var ma={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};import{jsx as va}from"react/jsx-runtime";function xa({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=ia.useRef(null),[u,h]=ia.useState(null);ia.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&h(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,r,c]);let d;d=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!ia.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),y=f?null:ma;return c?va("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}import*as ba from"react";import{useCallback as ka,useEffect as wa,useLayoutEffect as Aa,useMemo as Sa,useRef as _a}from"react";import{useState as Ma,useEffect as Ca}from"react";import{useRef as Pa,useState as Ta,useEffect as Ra}from"react";var Da=()=>"undefined"!=typeof performance?performance.now():Date.now();function Na(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}}function La(e,t){const n=e();return Number.isFinite(n)?n:t}var Ea=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Da,this.lastWallTime=La(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=La(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Da;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=La(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Na(n)))}},Ia="undefined"==typeof window?wa:Aa,Wa={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function $a(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function za(e){const t=function(){const[e,t]=Ma(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return Ca(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=_a(t);n.current=t;const[r,o]=function(e,t,n){const r=Pa(null),[o,i]=Ta(null);return Ra(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=Sa(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),c=o[0]-a.left-a.right,l=o[1]-a.top-a.bottom,u=$a(e.foregroundGraphics,o,a),h=$a(e.backgroundGraphics,o,a),d=H(e=>e.theme),{transition:f,introEnabled:y}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+ba.useId(),g=_a(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Ea({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const v=_a(null),x=_a(e.frameScheduler??Wa);x.current=e.frameScheduler??Wa;const b=_a(null),k=_a(!1),w=_a(()=>{}),A=ka(()=>{if(null!==v.current||k.current)return;const e=x.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),v.current=null,b.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(v.current=r,b.current=e)},[]),S=ka(()=>{null!==v.current&&((b.current??x.current).cancelAnimationFrame(v.current),v.current=null,b.current=null)},[]);Ia(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),wa(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),wa(()=>()=>{S()},[S]);const _=_a(()=>{}),M=_a(()=>{}),C=_a(null),P=_a(null),T=_a(null),R=ka(()=>{const e=C.current;C.current=null,e&&_.current(e)},[]),D=ka(e=>{if(C.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===P.current){const e=x.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,P.current=null,T.current=null,R()});t||(P.current=n,T.current=e)}},[R]),N=ka(()=>{C.current=null,null!==P.current&&((T.current??x.current).cancelAnimationFrame(P.current),P.current=null,T.current=null),M.current()},[]);wa(()=>()=>{C.current=null,null!==P.current&&((T.current??x.current).cancelAnimationFrame(P.current),P.current=null,T.current=null)},[]);const L=e.themeDirtyRef;return Ia(()=>{L&&(Xn++,L.current=!0,A())},[d,A,L]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:y,tableId:p,frameRuntime:m,rafRef:v,renderFnRef:w,scheduleRender:A,cancelRender:S,hoverHandlerRef:_,hoverLeaveRef:M,onPointerMove:D,onPointerLeave:N}}import{useEffect as Oa,useRef as Fa}from"react";import{jsx as Ba}from"react/jsx-runtime";function Ya(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,s=Fa(null),a=Fa(null),c=Fa(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=e;us(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),i.current()},[t,n]);const c=as(a);c.current=a,is(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),Oa(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),Oa(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function ja({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?Ba("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:Ba("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Ha(e,t,n,r){return"function"==typeof e?e({size:t,margin:n,scales:r}):e}function Xa(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),s=Math.round(t[1]*r),a=i/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),o.setTransform(a,0,0,c,0,0),o.translate(n.left,n.top),o}function Ga(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}import{useCallback as Va,useRef as qa}from"react";function Ua(e,t,n,r){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null}}var Ka=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qa=3156e7;function Za(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Qa>t?e=>{const t=new Date(e);return`${Ka[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Qa>t?e=>{const t=new Date(e);return`${Ka[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Ja(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:ft(n.size)});else if("glyph"===n.type){const e=Fn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as ec}from"d3-shape";function tc(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function nc(e,t,n,r,o,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;c>r&&(i*=r/c),c>a-r&&(i*=(a-r)/c),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var rc=(e,t,n,r)=>{const o=t.filter(e=>"line"===e.type);for(const t of o){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const o=t.style.stroke||"#007bff",i=Un(e,o)||o,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){nc(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=fr(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(h[r]+h[r+1])*n,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let n=function(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),h=!0},r=function(){h&&(e.stroke(),h=!1)},o=null,s=null,l=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],y=c[h],p=tc(y,a,i);if(null!==o&&null!==u&&null!==l){if(p===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>y)&&(n>l||y>n)||l===n||y===n||t.push({t:(n-l)/(y-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=o+(d-o)*c.t,u=s+(f-s)*c.t,h=tc(l+(y-l)*Math.min(c.t+1e-4,1),a,i);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}o=d,s=f,l=y,u=p}else n(p,d,f),o=d,s=f,l=y,u=p}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?gr(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)ec().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=yr(e,t.style.fill,t.style.fill),l&&!u)ec().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(n,r.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function oc(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ic(e,t,n=.3){oc(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function sc(e,t,n=.6){if(!oc(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function ac(e,t,n,r=.35){oc(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as cc,line as lc}from"d3-shape";function uc(e,t){const n=fr(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const r=cc().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}var hc=(e,t,n,r)=>{const o=t.filter(e=>"area"===e.type);for(const t of o){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());const i=yr(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(s[r]+s[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(s[n]+s[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(uc(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const o=pr(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);e.fillStyle=o||i,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(uc(e,t),ac(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?gr(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=fr(t.curve);if(e.beginPath(),r)lc().x(e=>e[0]).y(e=>e[1]).curve(r).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==o&&1>o&&e.restore(),n&&e.restore(),e.globalAlpha=1}},dc=(e,t,n,r)=>{const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{const t=e.globalAlpha;for(const n of o)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=yr(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=yr(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),sc(e,n)}finally{e.restore()}}},fc=new Map;function yc(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=fc.get(t);return n||(n=new Path2D(dt(e.symbolType,e.size)),fc.size>256&&fc.clear(),fc.set(t,n)),n}catch{return null}}var pc=(e,t)=>{const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=yc(t);if(!o)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=yr(e,t.style.fill,"#4e79a7"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=yr(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}e.globalAlpha=n};function gc(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=In(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=yr(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=o*a*(t.style.fillOpacity??1);const u=On(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Bn(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Bn(e,i,l,t.accent,void 0,c),e.restore()}function mc(e,t){const{x:n,y:r,w:o,h:i}=t,{tl:s,tr:a,br:c,bl:l}=function(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}(t);e.beginPath(),e.moveTo(n+s,r),e.lineTo(n+o-a,r),a>0&&e.arcTo(n+o,r,n+o,r+a,a),e.lineTo(n+o,r+i-c),c>0&&e.arcTo(n+o,r+i,n+o-c,r+i,c),e.lineTo(n+l,r+i),l>0&&e.arcTo(n,r+i,n,r+i-l,l),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function vc(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var xc=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)bc(e,t);else if(t.cornerRadii&&Zi(t.cornerRadii)){const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,mc(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+l-i),e.arcTo(s,a+l,s+i,a+l,i),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s+i,a+l),e.arcTo(s,a+l,s,a+l-i,i);break;default:e.moveTo(s,a+l),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}ic(e,t),e.globalAlpha=1}};function bc(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=o+r,s=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,s,r,o,o)}else{const i=o+r,s=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,s,o,o)}e.restore()}function kc(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>128?"#000":"#fff"}function wc(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ac=(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Un(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),ic(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):wc(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=kc(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}},Sc=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);const i=Un(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,i=Un(e,o)||o;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&c(),e.restore()}},_c={line:[hc,rc,dc],area:[hc,dc],stackedarea:[hc,dc],scatter:[dc,pc],bubble:[dc,pc],heatmap:[Ac],bar:[xc],swarm:[dc],waterfall:[(e,t,n,r)=>{xc(e,t);const o=t.filter(e=>"rect"===e.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=Un(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){const r=o[t],i=o[t+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[Sc],mixed:[hc,rc,dc],custom:[hc,xc,Ac,rc,dc,pc,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&gc(e,r,r.x,r.y,n);e.globalAlpha=n},Sc]},Mc=new Set;function Cc(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function Pc(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Mc.has(n)||(Mc.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Tc(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=Cc(r,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}c||(Pc(n.id,e.type??"unknown"),i([e]))}a()}function Rc(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=Cc(r,t);if(!i)return o();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(Pc(i.id,t.type??"unknown"),o())}import{jsx as Dc,jsxs as Nc}from"react/jsx-runtime";import{jsx as Lc,jsxs as Ec}from"react/jsx-runtime";function Ic(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Wc({hover:e}){const t=e.data??{},n=t.y??t.value,r=t.x??t.time;if(void 0===n&&void 0===r){const e=ya(t);if(null!=e.title||e.entries.length>0)return Ec("div",{className:"semiotic-tooltip",style:ma,children:[null!=e.title&&Lc("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>Ec("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",Lc("span",{style:{fontWeight:600},children:Ic(e.value)})]},e.key))]})}return Ec("div",{className:"semiotic-tooltip",style:ma,children:[Lc("div",{style:{fontWeight:600,marginBottom:2},children:Ic(n)}),Lc("div",{style:{opacity:.7,fontSize:11},children:Ic(r)})]})}function $c(e){return"touch"===e?"touch":"pointer"}function zc(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function Oc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:c,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"hover-end",timestamp:c,chartType:i,chartId:s}))}function Fc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:c,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"click-end",timestamp:c,chartType:i,chartId:s}))}Wc.ownsChrome=!0;import{useCallback as Bc}from"react";import{useCallback as Yc,useRef as jc}from"react";function Hc(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}function Xc(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Gc(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Vc(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Vc(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Vc(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function qc(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=Fn(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.path.length>n&&r.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.topPath.length>n&&r.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:r[n],shape:"circle",group:o});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function Uc(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as Kc,jsxs as Qc}from"react/jsx-runtime";var Zc={top:20,right:20,bottom:30,left:40},Jc=ws;function el(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var tl=l(c(function(c,l){const{chartType:u,runtimeMode:h,data:d,chunkThreshold:f,chunkSize:y,xAccessor:p,yAccessor:g,accessorRevision:m,colorAccessor:v,sizeAccessor:x,symbolAccessor:b,symbolMap:k,groupAccessor:w,lineDataAccessor:S,curve:C,normalize:P,baseline:T,stackOrder:R,binSize:D,valueAccessor:N,arrowOfTime:L="right",windowMode:E="sliding",windowSize:I=200,timeAccessor:$,xExtent:z,yExtent:O,extentPadding:F=.1,scalePadding:B,sizeRange:Y,size:j=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,renderMode:U,lineStyle:K,pointStyle:Q,areaStyle:Z,barStyle:J,waterfallStyle:ee,swarmStyle:te,barColors:ne,colorScheme:re,boundsAccessor:oe,boundsStyle:ie,y0Accessor:se,band:ae,gradientFill:ce,lineGradient:le,areaGroups:ue,openAccessor:he,highAccessor:de,lowAccessor:fe,closeAccessor:ye,candlestickStyle:pe,showAxes:ge=!0,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:ke,yFormat:we,axisExtent:Ae,tickFormatTime:Se,tickFormatValue:_e,hoverAnnotation:Me,tooltipContent:Ce,customHoverBehavior:Pe,customClickBehavior:Te,onObservation:Re,annotationObservationCallback:De,chartId:Ne,enableHover:Le,hoverRadius:Ee=30,tooltipMode:Ie,annotations:We,onAnnotationActivate:$e,autoPlaceAnnotations:ze,svgAnnotationRules:Oe,showGrid:Fe,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,legendCategoryAccessor:qe,onCategoriesChange:Ue,backgroundGraphics:Ke,foregroundGraphics:Ze,canvasPreRenderers:Je,svgPreRenderers:et,title:tt,categoryAccessor:nt,brush:rt,onBrush:ot,decay:it,pulse:st,transition:at,animate:ct,staleness:lt,frameScheduler:ut,clock:ht,random:ft,seed:yt,paused:pt=!1,suspendWhenHidden:gt=!0,heatmapAggregation:mt,heatmapXBins:vt,heatmapYBins:xt,showValues:bt,heatmapValueFormat:kt,marginalGraphics:wt,pointIdAccessor:At,xScaleType:St,yScaleType:_t,accessibleTable:Mt=!0,description:Ct,summary:Pt,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt,customLayout:Dt,onLayoutError:Nt,layoutConfig:Lt,layoutSelection:Et}=c,{customHoverBehavior:It,customClickBehavior:Wt,hasClickBehavior:$t}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r,chartType:o}){return{customHoverBehavior:Bc((t,i)=>{e?.(t,i),Oc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:o,chartId:r,context:i})},[r,o,e,n]),customClickBehavior:Bc((e,i)=>{t?.(e,i),Fc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:o,chartId:r,context:i})},[r,o,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:Pe,customClickBehavior:Te,onObservation:Re,chartId:Ne,chartType:"StreamXYFrame"}),zt=a().replace(/:/g,""),Ot=t(!1),Ft=t({w:-1,h:-1}),Bt=t(!1),Yt=za({sizeProp:j,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:Zc,title:tt,legend:Be,legendPosition:Ge,animate:ct,transitionProp:at,frameScheduler:ut,clock:ht,random:ft,seed:yt,paused:pt,suspendWhenHidden:gt,themeDirtyRef:Ot}),jt=hs(),Ht=ps(),{reducedMotionRef:Xt,responsiveRef:Gt,size:Vt,currentTheme:qt,transition:Ut,introEnabled:Kt,tableId:Qt,rafRef:Zt,renderFnRef:Jt,scheduleRender:en,frameRuntime:tn}=Yt;let nn=Yt.margin;if(wt){const e=60,t={...Yt.margin};wt.top&&e>t.top&&(t.top=e),wt.bottom&&e>t.bottom&&(t.bottom=e),wt.left&&e>t.left&&(t.left=e),wt.right&&e>t.right&&(t.right=e),nn=t}const rn=Vt[0]-nn.left-nn.right,sn=Vt[1]-nn.top-nn.bottom,an=o(()=>_(d),[d]),cn=Me??Le,[ln,un]=n(0),hn=t(0),[dn,fn]=n(null),yn=Ha(Ze,Vt,nn,dn),mn=Ha(Ke,Vt,nn,dn),xn=t(null),bn=t(null),kn=t(void 0),[wn,Sn]=n(null),_n=t(Jc.primary),Pn=t(function(){let e=-1,t=ws;return{resolve(n){if(!n)return ws;const r=Xn;return r===e||(t=function(e){if(!e)return ws;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=o||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:c||ws.axisStroke,tickText:s||ws.tickText,crosshair:s?As(s,"66"):ws.crosshair,hoverFill:l?As(l,"4D"):ws.hoverFill,hoverStroke:s?As(s,"99"):ws.hoverStroke,pointRing:l||ws.pointRing,primary:i||ws.primary,background:l||ws.background}:ws}(n),e=r),t},invalidate(){e=-1}}}()),Tn=t(!1),Rn=pn("StreamXYFrame"),[Dn,Nn]=n(!1),[Ln,En]=n([]),[In,Wn]=n([]),$n="streaming"===h||["bar","swarm","waterfall"].includes(u),zn=ms(o(()=>({chartType:u,runtimeMode:$n?"streaming":"bounded",windowSize:I,windowMode:E,arrowOfTime:$n?L:"right",extentPadding:F,scalePadding:B,axisExtent:Ae,xAccessor:p,yAccessor:g,accessorRevision:m,timeAccessor:$n?$:void 0,valueAccessor:N,colorAccessor:v,sizeAccessor:x,symbolAccessor:b,symbolMap:k,groupAccessor:w||(S?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:S,xScaleType:St,yScaleType:_t,xExtent:z,yExtent:O,sizeRange:Y,binSize:D,normalize:P,baseline:T,stackOrder:R,boundsAccessor:oe,boundsStyle:ie,y0Accessor:se,band:ae,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:ue?new Set(ue):void 0,lineGradient:le,openAccessor:he,highAccessor:de,lowAccessor:fe,closeAccessor:ye,candlestickStyle:pe,lineStyle:K,pointStyle:Q,areaStyle:Z,swarmStyle:te,waterfallStyle:ee,colorScheme:re,barColors:ne,barStyle:J,annotations:We,decay:it,pulse:st,transition:Ut,introAnimation:Kt,staleness:lt,clock:tn.now,heatmapAggregation:mt,heatmapXBins:vt,heatmapYBins:xt,showValues:bt,heatmapValueFormat:kt,pointIdAccessor:At,curve:C,themeCategorical:qt?.colors?.categorical,themeSemantic:W(qt),themeSequential:qt?.colors?.sequential,themeDiverging:qt?.colors?.diverging,customLayout:Dt,onLayoutError:Nt,layoutConfig:Lt,layoutMargin:nn}),[u,$n,I,E,L,F,B,Ae,p,g,m,$,N,v,x,b,k,w,S,nt,St,_t,z,O,Y,D,P,T,R,oe,ie,se,ae,ce,ue,le,he,de,fe,ye,pe,K,Q,Z,te,ee,re,ne,J,We,it,st,Ut,Kt,lt,tn.now,mt,vt,xt,bt,kt,At,C,qt,Dt,Nt,Lt,nn])),On=t(null);On.current||(On.current=new on(zn));const Fn=function(e,t,n,r){const o=qa({accessor:t,onChange:n,readData:r}),i=qa([]);return o.current={accessor:t,onChange:n,readData:r},Va(()=>{const{accessor:t,onChange:n,readData:r}=o.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e="function"==typeof t?t(o):o[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),r.push(i))}return r}(e.current?r(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,n(s))},[e])}(On,qe,Ue,e=>e.getData());Mn(On,zn,Ot,en),Cn(On,Et,Ot,en);const Bn=t(null);Bn.current||(Bn.current=new M(e=>{const t=On.current;t&&t.ingest(e)&&(Ot.current=!0,en())},{chunkThreshold:f,chunkSize:y})),r(()=>{Bn.current?.updateChunkOptions({chunkThreshold:f,chunkSize:y})},[f,y]);const Yn=i(e=>{Bn.current?.push(e)},[]),jn=i(e=>{Bn.current?.pushMany(e)},[]),Hn=i(()=>{Bn.current?.clear(),On.current?.clear(),Ot.current=!0,en()},[en]);s(l,()=>({push:Yn,pushMany:jn,remove:e=>{Bn.current?.flush();const t=On.current?.remove(e)??[];return t.length>0&&(xn.current&&t.some(e=>e===xn.current?.data)&&(xn.current=null,Sn(null)),Ot.current=!0,en()),t},update:(e,t)=>{Bn.current?.flush();const n=On.current?.update(e,t)??[];return n.length>0&&(Ot.current=!0,en()),n},clear:Hn,getData:()=>(Bn.current?.flush(),On.current?.getData()??[]),getScales:()=>On.current?.scales??null,getExtents:()=>On.current?.getExtents()??null,getCustomLayout:()=>On.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>On.current?.lastCustomLayoutFailure??null}),[Yn,jn,Hn,en]),r(()=>{if(d){if(S&&an.length>0&&"object"==typeof an[0]&&null!==an[0]){const e="string"==typeof S?S:"coordinates";if(Array.isArray(an[0][e])){const t=[];for(const n of an){const r=n[e];if(Array.isArray(r)){const e=n.label||n.id||n.key;if(null!=e)for(const n of r)t.push({...n,_lineGroup:e});else for(const e of r)t.push(e)}}return void Bn.current?.setBoundedData(t)}}Bn.current?.setBoundedData(an)}},[d,an,S]);const{canvasRef:Gn,interactionCanvasRef:Vn}=Ya(Yt,{storeRef:On,dirtyRef:Ot,hydrated:jt,wasHydratingFromSSR:Ht,cleanup:()=>Bn.current?.clear(),canvasPaintDependencies:[u,rn,sn,ge,q,Ke,K,U,Je,en]}),{hoverHandlerRef:qn,hoverLeaveRef:Un,onPointerMove:Kn,onPointerLeave:Qn}=Yt;qn.current=e=>{if(!cn)return;const t=Gn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-nn.left,o=e.clientY-n.top-nn.top;if(0>r||r>rn||0>o||o>sn)return void(xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&(It(null),Ot.current=!0),en()));const i=On.current;if(!i||0===i.scene.length)return;const s=sa(Ee,e.pointerType),a=br(i.scene,r,o,s,i.quadtree,i.maxPointRadius),c="multi"===Ie,l=()=>{xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&It(null),en())};if(!a&&!c)return void l();const h=c||!a?r:a.x,d=c||!a?o:a.y,f=a?.datum?Qe(a.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=ca(f,h,d,null!=g?{xValue:g,xPx:h}:void 0);if(c&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=kr(xr(e.path,e.curve),t,n);if(null===i)continue;const s=Dr(e.path,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=xr(e.topPath,e.curve),s=xr(e.bottomPath,e.curve),a=kr(i,t,n);if(null===a)continue;const c=kr(s,t,n),l=Dr(e.topPath,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(i.scene,h,Math.max(s,rn));if(e.length>0){const t=i.scales.y.invert,n=_n.current,r=y?y(h):h;if(a)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof p&&(e[p]=r),m=ca(e,h,d,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===u&&null!=o?r-o:r,valuePx:e.y,color:e.color||n,datum:Qe(e.datum,i.resolvedRibbons)}})}}a||m.allSeries?.length?(xn.current=m,bn.current=a?.node??null,Sn(m),It&&(It(m),Ot.current=!0),en()):l()},Un.current=()=>{xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&(It(null),Ot.current=!0),en())};const Zn=t(()=>{});Zn.current=e=>{if(Qo(e.target))return;if(!Wt)return;const t=Gn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-nn.left,o=e.clientY-n.top-nn.top;if(0>r||r>rn||0>o||o>sn)return void Wt(null);const i=On.current;if(!i||0===i.scene.length)return void Wt(null);const s=sa(Ee,kn.current),a=br(i.scene,r,o,s,i.quadtree,i.maxPointRadius);if(!a)return void Wt(null);const c=a.datum||{},l=i.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Wt(ca(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:$c(kn.current)})};const er=i(e=>Zn.current(e),[]),{kbFocusIndexRef:tr,focusedNavPointRef:rr,onKeyDown:or}=(cr={storeRef:On,hoverRef:xn,hoveredNodeRef:bn,setHoverPoint:Sn,customHoverBehavior:It,customClickBehavior:Wt,scheduleRender:en},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:r,customHoverBehavior:o,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=jc(-1),u=jc(null),h=jc(null),d=Yc(d=>{if(zc(d))return;const f=e.current;if(!f)return;const y=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),r(null),o(null),s()};if(0===f.scene.length)return void(0>l.current||y());let p;if(h.current?.version===f.version)p=h.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>l.current||y());p=Hc(e),h.current={version:f.version,graph:p}}let g=l.current;if(p.flat.length>g||(y(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void i(c(p.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),l.current=0;const e=p.flat[0];u.current=e;const n=c(e,f);return t.current=n,r(n),o(n,{type:"focus",inputType:"keyboard"}),void s()}const m=Gc(d.key,Xc(p,g),p);if(null===m)return;if(d.preventDefault(),0>m)return void y();l.current=m;const v=p.flat[m];u.current=v;const x=c(v,f);t.current=x,r(x),o(x,{type:"focus",inputType:"keyboard"}),s()},[i,o,a,t,n,s,r,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:d}}({...cr,extractPoints:qc,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:Qe(e.datum,t.resolvedRibbons)})})),ir=i(e=>{kn.current=e.pointerType,tr.current=-1,rr.current=null,Kn(e)},[rr,tr,Kn]),sr=i(e=>{kn.current="mouse",tr.current=-1,rr.current=null,Kn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[rr,tr,Kn]),ar=i(e=>{kn.current=e.pointerType},[]);var cr;Jt.current=()=>{if(Zt.current=null,!tn.isActive)return;const e=Gn.current,t=Vn.current;if(!e||!t)return;const n=On.current;if(!n)return;const r=tn.now(),o=n.advanceTransition(Xt.current?r+1e6:r),i=!Xt.current&&o,s=Ft.current.w!==rn||Ft.current.h!==sn,a=Ot.current||o||s,c=n.consumeStylePaintPending();let l=!1;const h=n.getLastUpdateResult(),d=Rn.current.beforeCompute(h,i);!a||i&&!s||(n.computeScene({width:rn,height:sn}),Ft.current={w:rn,h:sn},l=!0,Fn()),Rn.current.afterCompute(d,l,s);const f=function(e,t,n,r){const o=r.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!o)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(n,r,l,Bt),y=Ga(),m=Pn.current.resolve(e);_n.current=m.primary;const v=Wr(lt,n.lastIngestTime>0?r-n.lastIngestTime:0),x=lt&&v.isStale;if(a||c||f.changed){const t=Xa(e,Vt,nn,y);if(t){if(t.clearRect(-nn.left,-nn.top,Vt[0],Vt[1]),lt&&1>v.alpha&&(t.globalAlpha=v.alpha),ks(t,{background:q,hasBackgroundGraphics:!!Ke,themeBackground:m.background,x:-nn.left,y:-nn.top,width:Vt[0],height:Vt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,rn,sn),t.clip()),Je&&n.scales)for(const e of Je)t.save(),e(t,n.scene,n.scales,{width:rn,height:sn}),t.restore();const e=Dt?_c.custom:_c[u];Tc({context:t,nodes:n.scene,renderMode:U,pixelRatio:y,paintBuiltIn:r=>{if(e&&n.scales)for(const o of e)o(t,r,n.scales,{width:rn,height:sn})}}),t.restore(),lt&&1>v.alpha&&(t.globalAlpha=1)}}const b=!!(cn&&xn.current&&n.scales),k=!!(bn.current&&Array.isArray(Me)&&Me.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),w=b||k;if(w||Tn.current){const e=Xa(t,Vt,nn,y);if(e&&(e.clearRect(-nn.left,-nn.top,Vt[0],Vt[1]),b&&xn.current&&function(e,t,n,r,o,i,s){if(!1===o.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof o.crosshair?o.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,r),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=o.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,xn.current,rn,sn,"object"==typeof cn?cn:{},bn.current,m),k&&bn.current&&Array.isArray(Me))){const t=Me.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,o){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||o.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,n.scene,bn.current,t,m)}Tn.current=w}a&&e&&e.setAttribute("aria-label",$s(n.scene,u+" chart"));const A=Ot.current;if(Ot.current=A&&i&&!l,A&&n.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!dn||e(dn.x.domain()[0])!==e(n.scales.x.domain()[0])||e(dn.x.domain()[1])!==e(n.scales.x.domain()[1])||e(dn.y.domain()[0])!==e(n.scales.y.domain()[0])||e(dn.y.domain()[1])!==e(n.scales.y.domain()[1])||dn.x.range()[0]!==n.scales.x.range()[0]||dn.x.range()[1]!==n.scales.x.range()[1]||dn.y.range()[0]!==n.scales.y.range()[0]||dn.y.range()[1]!==n.scales.y.range()[1])&&fn(n.scales),wt){const e=n.getData(),t="function"==typeof p?p:e=>e[p||"x"],r="function"==typeof g?g:e=>e[g||"y"];En(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Wn(e.map(e=>r(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((We&&We.length>0||Dt)&&(l||i))||!l&&33>r-hn.current||(un(e=>e+1),hn.current=r),lt?.showBadge&&Nn(!!x),(i||null!=n.activeTransition||f.pending)&&en()},$r(lt,On,Ot,en,Dn,Nn);const lr=o(()=>{if(ke||Se)return;const e=On.current;return e?.xIsDate&&dn?Za(dn.x.domain()):void 0},[ke,Se,dn]),ur=ke||Se||lr,hr=cn&&wn?Ce?Ce(wn):Kc(Wc,{hover:wn}):null,dr=hr?Kc(xa,{x:wn.x,y:wn.y,containerWidth:rn,containerHeight:sn,margin:nn,className:"stream-frame-tooltip",children:hr}):null,fr=rr.current,yr=Kc(oa,{active:tr.current>=0,hoverPoint:wn,margin:nn,size:Vt,shape:fr?.shape,width:fr?.w,height:fr?.h}),pr=Ua(p,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),gr=Ua(g,N,"__semiotic_resolvedY","__semiotic_resolvedValue"),mr=pr.key,vr=gr.key,wr=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let o=!1;const i=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return o?i:r}}(pr,gr,We&&We.length>0||!1);if(os||!jt&&Ht){const t=On.current;t&&d&&(t.ingest({inserts:an,bounded:!0}),t.computeScene({width:rn,height:sn}));const n=t?.scene??[],r=t?.scales??null,o=Ha(Ze,Vt,nn,r),i=Ha(Ke,Vt,nn,r),s=ur||(()=>{if(t?.xIsDate&&r)return Za(r.x.domain())})();return Qc("div",{ref:Gt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:H?"100%":Vt[0],height:X?"100%":Vt[1]},children:[Kc(ea,{summary:Pt}),Qc("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vt[0],height:Vt[1],style:{position:"absolute",left:0,top:0},children:[Kc("g",{transform:`translate(${nn.left},${nn.top})`,children:i}),Qc("g",{transform:`translate(${nn.left},${nn.top})`,children:[q&&Kc("rect",{x:0,y:0,width:rn,height:sn,fill:q}),et&&r&&et.map((t,o)=>Kc(e.Fragment,{children:t(n,r,{width:rn,height:sn})},"svgpre-"+o)),n.map((e,t)=>Rc({node:e,index:t,renderMode:U,fallback:()=>function(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return Ji("path",{d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const o=`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,i=`${n?n+"-":""}area-${t}-hatch`,s=Jn(r.style.fill)?nr(r.style.fill,i):void 0,a=s?`url(#${i})`:ns(r.style.fill);if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return es("g",{children:[es("defs",{children:[s,Ji("clipPath",{id:e,children:Ji("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),Ji("path",{d:o,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return es(Ki.Fragment,{children:[s&&Ji("defs",{children:s}),Ji("path",{d:o,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"area-"+t)}case"point":{const r=e,o=`${n?n+"-":""}point-${t}-hatch`,i=Jn(r.style.fill)?nr(r.style.fill,o):void 0;return es(Ki.Fragment,{children:[i&&Ji("defs",{children:i}),Ji("circle",{cx:r.x,cy:r.y,r:r.r,fill:i?`url(#${o})`:ns(r.style.fill),opacity:r.style.opacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return function(e,t){const n=dt(e.symbolType,e.size,e.path);return Ji("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?ns(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+t)}(e,t);case"glyph":return rs(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,o=`${n?n+"-":""}xyrect-${t}-hatch`,i=Jn(r.style.fill)?nr(r.style.fill,o):void 0;return es(Ki.Fragment,{children:[i&&Ji("defs",{children:i}),Ji("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i?`url(#${o})`:ns(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return es("g",{children:[Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),Ji("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return es("g",{children:[Ji("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),Ji("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}(e,t,zt)})).filter(Boolean)]})]}),Kc(Ui,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:r,showAxes:ge,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:s,yFormat:we||_e,axisExtent:Ae,showGrid:Fe,title:tt,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,foregroundGraphics:vn(o,An(On.current?.customLayoutOverlays,Et??null)),marginalGraphics:wt,xValues:[],yValues:[],annotations:We,onAnnotationActivate:$e,onObservation:De??Re,chartId:Ne,chartType:"StreamXYFrame",autoPlaceAnnotations:ze,svgAnnotationRules:Oe,annotationFrame:0,xAccessor:mr,yAccessor:vr,annotationData:wr(On.current?.getData()),pointNodes:Ja(On.current?.scene),curve:"string"==typeof C?C:void 0,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt})]})}return Qc("div",{ref:Gt,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Vt[0],height:X?"100%":Vt[1],overflow:"visible",touchAction:el(rt)},onKeyDown:or,children:["production"!==process.env.NODE_ENV&&On.current&&Kc(gn,{store:On.current,diagnostics:Rn.current}),Mt&&Kc(ta,{tableId:Qt}),Mt&&Kc(Zs,{scene:On.current?.scene??[],chartType:u+" chart",tableId:Qt,chartTitle:"string"==typeof tt?tt:void 0}),Kc(ea,{summary:Pt}),Kc(Ds,{hoverPoint:wn}),Qc("div",{role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:cn?ir:void 0,onMouseMove:cn?sr:void 0,onPointerLeave:cn?Qn:void 0,onMouseLeave:cn?Qn:void 0,onPointerDown:cn||$t?ar:void 0,onClick:$t?er:void 0,children:[Kc(ja,{size:Vt,margin:nn,children:mn}),Kc(Gi,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:dn,showAxes:ge,axes:me,showGrid:Fe,xFormat:ur,yFormat:we||_e,axisExtent:Ae}),Kc("canvas",{ref:Gn,"aria-label":$s(On.current?.scene??[],u+" chart"),style:{position:"absolute",left:0,top:0}}),Kc("canvas",{ref:Vn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Kc(Ui,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:dn,showAxes:ge,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:ur,yFormat:we||_e,axisExtent:Ae,showGrid:Fe,title:tt,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,foregroundGraphics:vn(yn,An(On.current?.customLayoutOverlays,Et??null)),marginalGraphics:wt,xValues:Ln,yValues:In,annotations:We,onAnnotationActivate:$e,onObservation:De??Re,chartId:Ne,chartType:"StreamXYFrame",autoPlaceAnnotations:ze,svgAnnotationRules:Oe,annotationFrame:ln,xAccessor:mr,yAccessor:vr,annotationData:wr(On.current?.getData()),pointNodes:Ja(On.current?.scene),curve:"string"==typeof C?C:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==q&&!Ke,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt}),(rt||ot)&&Kc(A,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,dimension:rt?.dimension??"xy",scales:dn,onBrush:ot??(()=>{}),binSize:D,snap:rt?.snap,binBoundaries:rt?.binBoundaries??("bar"===u?On.current?.getBinBoundaries():void 0),snapDuring:rt?.snapDuring,streaming:"streaming"===h}),lt?.showBadge&&Kc(Or,{isStale:Dn,position:lt.badgePosition}),yr,dr]})]})}));tl.displayName="StreamXYFrame";var nl=tl;import{useRef as rl,useState as ol,useEffect as il,useMemo as sl,useCallback as al,useImperativeHandle as cl,forwardRef as ll,memo as ul}from"react";var hl={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},dl={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},fl=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?yl(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function yl(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),c=s-a,[l,u,h,d]=e[a];pl(l,u,h,d,c,o);const f=d.x-l.x,y=d.y-l.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;o.x+=-y/p*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,s,a]=e.points;pl(o,i,s,a,t,r);const c=a.x-o.x,l=a.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;r.x+=-l/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function pl(e,t,n,r,o,i){const s=1-o,a=s*s,c=a*s,l=o*o,u=l*o;i.x=c*e.x+3*a*o*t.x+3*s*l*n.x+u*r.x,i.y=c*e.y+3*a*o*t.y+3*s*l*n.y+u*r.y}function gl(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function ml(e,t){var n,r=[],o=[],i=[],s={},a=[];function c(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&c(t)})}function l(e){var t,r,h=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),h=!0):i[r]||(h=l(r));if(h)c(e);else for(t=0;a[e].length>t;t++){var d=s[r=a[e][t]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function h(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,r[c]=0,o[c]=!1,i[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(t){var c=[t],l=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,c.push(p),l.push(p);break}o[p]&&(r[t]=0|Math.min(r[t],r[p])),0>s[p]||a[t].push(s[p])}i[t]=y}else{if(r[t]===n[t]){var g=[],m=[],v=0;for(y=c.length-1;y>=0;--y){var x=c[y];if(o[x]=!1,g.push(x),m.push(a[x]),v+=a[x].length,s[x]=h.length,x===t){c.length=y;break}}h.push(g);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;d.length>c;c++){var y=d[c];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&l.push(y[p]);d[c]=l}}return{components:h,adjacencyList:d}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var c=o[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var d=e.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];i[+g]=!1,s[g]={}}l(n),n+=1}else n=d}return t?void 0:r}function vl(e){return e.y0-e.y1>0?"up":"down"}function xl(e,t){return t(e.source)==t(e.target)}function bl(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function kl(e){return e.target.x0-e.source.x1}function wl(e,t){var n=Sl(e),r=kl(t)/Math.tan(n);return"up"==vl(e)?e.y1-r:e.y1+r}function Al(e,t){var n=Sl(e),r=kl(t)/Math.tan(n);return"up"==vl(e)?e.y1+r:e.y1-r}function Sl(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function _l(e,t){return t(e)}function Ml(e){return Pl(e.source)}function Cl(e){return Pl(e.target)}function Pl(e){return(e.y0+e.y1)/2}function Tl(e){return e.virtual?0:e.value}function Rl(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!xl(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!xl(e,t)?r+1:r}),n+r}function Dl(e){return e.target.depth}function Nl(e,t){return e.sourceLinks.length?e.depth:t-1}function Ll(e,t){return e.y0-t.y0}function El(e,t){return t.y0-e.y0}function Il(e,t){return e.y1-t.y1}function Wl(e,t){return t.y1-e.y1}function $l(e,t){return Ol(e.source,t.source)||e.index-t.index}function zl(e,t){return Ol(e.target,t.target)||e.index-t.index}function Ol(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Fl(e,t){return Bl(e)==Bl(t)?"bottom"==e.circularLinkType?El(e,t):Ll(e,t):Bl(t)-Bl(e)}function Bl(e){return e.target.column-e.source.column}function Yl(e,t){return jl(e)==jl(t)}function jl(e){return e.y0-e.y1>0?"up":"down"}import{min as Hl}from"d3-array";function Xl(e,t,n,r,o){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=Hl(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Gl(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Gl(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,xl(e,t)&&bl(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?El:Ll);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Wl:Il),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Gl(e,t,n){e.sort(Fl);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xl(e,t)&&bl(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Vl(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Vl(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as ql,max as Ul,sum as Kl,mean as Ql,group as Zl,groups as Jl}from"d3-array";function eu(e){return function(){return e}}function tu(e){return e.index}function nu(e){return e.nodes}function ru(e){return e.links}function ou(e,t,n){var r=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Pl(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Pl(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Rl(t,n)-Rl(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Rl(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function iu(e,t,n,r,o,i){var s=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=i;c>0;--c)l(a*=.99,n),u();function l(t,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Rl(o,n)>0){var c=Ql(o.sourceLinks,Cl),l=Ql(o.targetLinks,Ml),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Pl(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==r-1&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=Ql(o.sourceLinks,Cl),f=Ql(o.targetLinks,Ml),y=((d&&f?(d+f)/2:d||f)-Pl(o))*t;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var i,s,a,c=e.y0,l=n.length;for(n.sort(t||Ol),a=0;l>a;++a)(s=c-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),c=i.y1+r;if((s=c-r-e.y1)>0)for(c=i.y0-=s,i.y1-=s,a=l-2;a>=0;--a)(s=(i=n[a]).y1+o-c)>0&&(i.y0-=s,i.y1-=s),c=i.y0})}}function su(e){e.nodes.forEach(function(e){e.sourceLinks.sort(zl),e.targetLinks.sort($l)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function au(){var e=0,t=0,n=1,r=1,o=24,i=8,s=null,a=tu,c=Nl,l=void 0,u=32,h=2,d=nu,f=ru;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=e,d.y0=t,d.x1=n,d.y1=r,d.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return Zl(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=gl(n,r)),"object"!=typeof o&&(o=e.target=gl(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var c=ml(r);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||l[r]&&l[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(d,l),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){_l(e,t)!=_l(o.source,t)&&_l(e,t)!=_l(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xl(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Kl(e.sourceLinks,Tl),Kl(e.targetLinks,Tl)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(d),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(d,l,c);var f=i;if(null!==s){var y=Jl(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=Ul(y,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=ql(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Kl(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=Ul(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(d,f,o),ou(d,l,a),iu(d,l,a,f,f,u),su(d),Xl(d,a,h,10,8),ou(d,l,a),iu(d,l,a,f,f,u),su(d),Xl(d,a,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return _l(n.source,t)==_l(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Yl(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=wl(t,e);return e.y1-n}if(t.target.column>e.target.column)return wl(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y0=e.y1-s-t.width/2}})})}(d,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return _l(n.target,t)==_l(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Yl(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Al(t,e);return e.y0-n}if(t.source.column>e.source.column)return Al(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=ql(t,function(e){return e.y0}),s=Ul(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(d),Xl(d,a,h,10,8)}(y),y}return y.update=function(e){return su(e),Xl(e,a,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(o=+e,y):o},y.nodePadding=function(e){return arguments.length?(i=+e,y):i},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(d="function"==typeof e?e:eu(e),y):d},y.links=function(e){return arguments.length?(f="function"==typeof e?e:eu(e),y):f},y.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:eu(e),y):a},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:eu(e),y):c},y.nodeSort=function(e){return arguments.length?(l=e,y):l},y.iterations=function(e){return arguments.length?(u=+e,y):u},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[e,t],[n,r]]},y.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],y):[n-e,r-t]},y}import{interpolateNumber as cu}from"d3-interpolate";import{line as lu,curveLinearClosed as uu}from"d3-shape";var hu=e=>{let t,n,r,o,i,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=cu(i,s),c=a(.5),l=a(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${s}L${r},${s}C${r},${l} ${o},${c} ${o},${i}Z`;const u=e.sankeyWidth/2,h=cu(e.source.x1,e.target.x0),{pathD:d}=function(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:c}=e,l=(n+r)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${i} ${o},${i}`,`L${o},${s}`,`C${c},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function du(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+a},${o-t}L${n+a},${o+t}L${n},${o+t}ZM${i},${s-t}L${i-c},${s-t}L${i-c},${s+t}L${i},${s+t}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,c=r.rightFullExtent,l=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*t}L${c},${i-h*t}L${c+n},${i-h*t+h*d}L${c+n},${u+h*n-h*d}L${c+n-d},${u+h*n}L${l-n+d},${u+h*n}L${l-n},${u+h*n-h*d}L${l-n},${a-h*t+h*d}L${l-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${l+n},${a+h*t}L${l+n},${u-h*n}L${c-n},${u-h*n}L${c-n},${i+h*t}L${o},${i+h*t}Z`}var fu=new Set,yu=new WeakMap;function pu(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=yu.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,yu.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;fu.has(e)||(fu.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var gu={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Dl))-1:0},justify:Nl};function mu(e){return"string"==typeof e?e:e.id}var vu={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=au().extent(h).links(u).nodes(l).nodeAlign(gu[i]||Nl).nodeId(e=>e.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of l)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=t-e,s=o-n,a=r[0],c=r[1];if(i>0&&s>0&&(0>e||0>n||t>a||o>c)){const t=Math.min(a/i,c/s),r=-e*t+(a-i*t)/2,o=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const y=new Map;for(const e of t)y.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=mu(e.source),n=mu(e.target),r=y.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ie,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const h=[],d=[],f=[],y=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(pu(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),h.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?y.get(r.id)||u.get(r.id)||o:y.get(t.id)||u.get(t.id)||o;const i=s?s(pu(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||o;d.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),d.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?du(e):hu(e),l)&&d.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===o?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+i/2),f.push({x:a,y:c,text:s+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}};import{forceSimulation as xu,forceCenter as bu,forceX as ku,forceY as wu,forceLink as Au,forceManyBody as Su,forceCollide as _u}from"d3-force";import{scaleLinear as Mu}from"d3-scale";var Cu={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const r=Pu(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Tu(e.id),i=o%360*(Math.PI/180),s=10+o%20;e.x=t/r.length+s*Math.cos(i),e.y=n/r.length+s*Math.sin(i)}else{const t=Tu(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=i+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=i+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),d=Ru(n.nodeSize,n.nodeSizeRange,e),f=e=>d(e);if(h>0){const r=new Map,a=new Map;for(const t of e)r.set(t.id,0),a.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;r.set(t,(r.get(t)??0)+1),r.set(n,(r.get(n)??0)+1)}const c=Au().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(r.get("string"==typeof e.source?e.source:e.source.id)??1,r.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?a.get(e.source):e.source,n="string"==typeof e.target?a.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),l=xu();if(void 0===n.random&&void 0===n.seed||l.randomSource(n.random??Na(n.seed)),l.force("charge",Su().strength(e=>{const t=r.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",_u(e=>f(e)+3).strength(.9).iterations(2)).force("center",bu(i,s).strength(.8)).force("x",ku(i).strength(.06)).force("y",wu(s).strength(.06)),l.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),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;h>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=Ru(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ie,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(pu(t,"nodeSize")),r=o?o(pu(t,"nodeStyle")):{},i={fill:r.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),r="object"==typeof e.target?e.target:d.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(pu(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=s(pu(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Pu(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Tu(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Ru(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=oo(o);if(i===s)return()=>(r[0]+r[1])/2;const a=Mu().domain([i,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}import{chord as Du,ribbon as Nu}from"d3-chord";import{arc as Lu}from"d3-shape";var Eu=ie,Iu={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,c=a-i,l=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:e=>e[d]??1:e=>e.value??1;var d;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=h(e);p[n][r]=o}const g=Du().padAngle(o);s&&g.sortGroups(s);const m=g(p),v=m.groups,x=Lu().innerRadius(c).outerRadius(a);for(const t of v){const n=e[t.index],r=x.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+l,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=b.get("string"==typeof e.source?e.source:e.source.id),r=b.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,c=r[0]/2,l=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Eu,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=Nu().radius(a),g=[],m=[],v=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(pu(n,"nodeStyle")).fill||y.get(n.id)||f[t%f.length]:y.get(n.id)||f[t%f.length];const i=u?u(pu(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const o=Wu(r,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(pu(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===d&&n?s=y.get(n.id)||s:t&&(s=y.get(t.id)||s)}const a=h?h(pu(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;v.push({x:c+Math.cos(s)*r,y:l+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var x;return{sceneNodes:g,sceneEdges:m,labels:v}}};function Wu(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}import{hierarchy as $u,tree as zu,cluster as Ou,treemap as Fu,pack as Bu,partition as Yu,treemapBinary as ju}from"d3-hierarchy";var Hu=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xu(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Gu(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Vu(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function qu(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Hu}function Uu(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ku(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Qu={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=$u(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=zu();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(l,n,u,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=Ou();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(l,n,u,h);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,s=Fu().size([n,r]).tile(ju).padding(o);i>0&&s.paddingTop(i),s(e)}(l,n,u,h);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;Bu().size([n,r]).padding(o)(e)}(l,n,u,h);break;case"partition":!function(e,t,n,r){Yu().size([n,r]).padding(t.padding??1)(e)}(l,n,u,h)}const d=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],o={id:Gu(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Zu(o,r,n):"treemap"===i||"partition"===i?Ju(o,r):"circlepack"===i&&eh(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of d)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const t of e){let e=t.x,r=t.y;u&&(e+=h,r+=d);const i=o(pu(t,"nodeStyle"));let a=i.fill||Uu(n);if(n.colorByDepth&&void 0!==t.depth){const e=qu(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,s=t.y,c=r.x,f=r.y;u&&(o+=h,s+=d,c+=h,f+=d);const y=Ku(o,s,c,f,l),g=i(pu(e,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:e})}if(!1!==n.showLabels){const t=Vu(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const e=s-h,t=a-d,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");c.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=r(pu(n,"nodeStyle"));let a=s.fill||Uu(t);if(t.colorByDepth&&void 0!==n.depth){const e=qu(t);a=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vu(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let h=r(pu(a,"nodeStyle")).fill||Uu(t);if(t.colorByDepth&&void 0!==a.depth){const e=qu(t);h=e[a.depth%e.length]}const d="string"==typeof h?Xu(h):t.themeSemantic?.text??"#000";i.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(pu(n,"nodeStyle"));let s=i.fill||Uu(t);if(t.colorByDepth&&void 0!==n.depth){const e=qu(t);s=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vu(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let c=r(pu(o,"nodeStyle")).fill||Uu(t);if(t.colorByDepth&&void 0!==o.depth){const e=qu(t);c=e[o.depth%e.length]}if(a){const n="string"==typeof c?Xu(c):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Zu(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ju(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function eh(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}import{pie as th}from"d3-shape";function nh(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var rh={sankey:vu,force:Cu,chord:Iu,tree:Qu,cluster:Qu,treemap:Qu,circlepack:Qu,partition:Qu,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=nh(n);d.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function y(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=y(s(e));r.push({id:v,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),d.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,p,g){const m=i(t);if(!m?.length)return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=a[Math.min(k,a.length-1)],k++,x++;let w=0;for(let v=0;x>v;v++){const b=a[Math.min(v,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(v+1)/x,S={id:n,depth:p,data:t,parentId:n},_=g?f/u(S)*A:f*A,M=th().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),C=h(S);for(let t=0;k.length>t;t++){const i=(M[t].startAngle+M[t].endAngle)/2,a=k[t],u=y(s(a)),h=c+_*Math.sin(i),f=l+_*Math.cos(i)*C;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:_,angle:i,depth:p,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,h,f,_,p+1,!0)}w+=b}}(e,v,p,g,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=nh(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(pu(t,"nodeSize")),r=o?o(pu(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(pu(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=nh(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=a.get(e.parentId);if(!r)continue;const c=e.angle+i*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(c),t.y=r.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function oh(e){return rh[e]}import{quadtree as ih}from"d3-quadtree";function sh(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ah(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!ch(e))return!1;return!0}return ch(t.points)}function ch(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as lh}from"d3-interpolate";var uh="rgba(34, 197, 94, 0.7)",hh=2e3,dh=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fh=["scene-style","data-paint","accessibility","evidence"],yh=(e,t)=>({retainedData:e,invalidations:t}),ph=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gh=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mh=["scene-geometry","data-paint","overlay","accessibility","evidence"],vh=["scene-style","data-paint","accessibility","evidence"],xh=["scene-geometry","data-paint","overlay","accessibility","evidence"],bh=[],kh={chartType:yh("rebuild",ph),nodeIDAccessor:yh("rebuild",ph),sourceAccessor:yh("rebuild",ph),targetAccessor:yh("rebuild",ph),valueAccessor:yh("rebuild",ph),edgeIdAccessor:yh("rebuild",ph),childrenAccessor:yh("rebuild",ph),hierarchySum:yh("rebuild",ph),orientation:yh("preserve",gh),nodeAlign:yh("preserve",gh),nodePaddingRatio:yh("preserve",gh),nodeWidth:yh("preserve",gh),edgeSort:yh("preserve",gh),iterations:yh("preserve",gh),forceStrength:yh("preserve",gh),padAngle:yh("preserve",gh),groupWidth:yh("preserve",gh),sortGroups:yh("preserve",gh),treeOrientation:yh("preserve",gh),edgeType:yh("preserve",gh),padding:yh("preserve",gh),paddingTop:yh("preserve",gh),orbitMode:yh("preserve",gh),orbitSize:yh("preserve",gh),orbitSpeed:yh("preserve",gh),orbitRevolution:yh("preserve",gh),orbitRevolutionStyle:yh("preserve",gh),orbitEccentricity:yh("preserve",gh),orbitShowRings:yh("preserve",gh),orbitAnimated:yh("preserve",gh),customNetworkLayout:yh("preserve",gh),layoutConfig:yh("preserve",gh),nodeSize:yh("preserve",mh),nodeSizeRange:yh("preserve",mh),colorByDepth:yh("preserve",mh),nodeLabel:yh("preserve",xh),showLabels:yh("preserve",xh),labelMode:yh("preserve",xh),nodeStyle:yh("preserve",vh),edgeStyle:yh("preserve",vh),colorBy:yh("preserve",vh),colorScheme:yh("preserve",vh),themeCategorical:yh("preserve",vh),themeSemantic:yh("preserve",vh),edgeColorBy:yh("preserve",vh),edgeOpacity:yh("preserve",vh),showParticles:yh("preserve",vh),particleStyle:yh("preserve",vh),decay:yh("preserve",vh),pulse:yh("preserve",vh),thresholds:yh("preserve",vh),staleness:yh("preserve",vh),layoutSelection:yh("preserve",vh),clock:yh("preserve",bh),random:yh("preserve",bh),seed:yh("preserve",bh),tensionConfig:yh("preserve",bh),transition:yh("preserve",bh),introAnimation:yh("preserve",bh),onLayoutError:yh("preserve",bh),__skipForceSimulation:yh("preserve",bh),__hierarchyRoot:yh("preserve",bh),__orbitState:yh("preserve",bh),__previousPositions:yh("preserve",bh)},wh=yh("preserve",gh),Ah=class{constructor(){this.tracker=new Bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},dh)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},fh):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=kh[r]??wh;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};function Sh(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&we(n,e)||"#4e79a7":t=>{if(n){const e=we(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}var _h=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Ah,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...hl,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new fl(2e3))}currentTime(){return this.config.clock?.()??Me()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...hl,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new fl(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>e[s],h="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=c(t)+"";this.nodes.set(e,{...sh(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=l(n)+"",o=u(n)+"",i=h(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...sh(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...sh(o),data:n});const c=`${r}\0${o}\0${e}`,d={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:c};n&&"object"==typeof n&&ah(n.bezier)&&(d.bezier=n.bezier),this.edges.set(c,d)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,sh(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,sh(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),c=this.edges.get(a);let l=!1;c?(c.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||l||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=oh(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const s=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return s}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:s}){const a=function(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=xe[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(e.colorScheme,e.themeCategorical,ie),c={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:Sh(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(c)}}catch(t){const n=null!==i,r=bt("network",t,n,s);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void mt({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=oh(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=ih().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=oh(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=oh(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Se(e,this.transition),n=Ae(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=_e(e._prevX0,e._targetX0,n),e.x1=_e(e._prevX1,e._targetX1,n),e.y0=_e(e._prevY0,e._targetY0,n),e.y1=_e(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=_e(e._prevY0,e._targetY0,n),e.y1=_e(e._prevY1,e._targetY1,n),e.sankeyWidth=_e(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,s=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,s=n.x0,a=lh(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:o}}const i=t.x1,s=n.x0,a=lh(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const c=i-a;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const c=e.edgeTimestamps.get(`${s}\0${a}`);if(!c)continue;const l=i-c;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const s=Ee(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===uh&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=hh)return;const n=1-t/hh;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=uh,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&hh>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const s=i.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const c=t.metric(a);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=n):l=r,l&&(i.style={...i.style,fill:l},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=l,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};_h.QUADTREE_THRESHOLD=500;var Mh=_h;$t(Mh);import*as Ch from"react";import{Fragment as Ph,jsx as Th,jsxs as Rh}from"react/jsx-runtime";function Dh(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:A}=e,S=Uo({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k}),_=Ch.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=Fn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,ft(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),M=Ch.useMemo(()=>m&&w?_i({annotations:m,context:_,..."object"==typeof w?w:{}}):m,[m,w,_]),C=Ch.useMemo(()=>si(),[]),P=M?ii(M.filter(e=>"widget"!==e.type),C,A,_):null,T=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Rh(Ph,{children:[T&&Th("style",{children:Bo},"annotation-widget-disclosure-style"),Rh("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Th("title",{children:"string"==typeof a?a:"Network Chart"}),Th("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),Rh("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>Th("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),P,p]}),a&&"string"==typeof a?Th("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?Th("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,to({legend:c,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),M?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,r=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),s=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),a=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,h=e.content??Th("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return Th("div",{...Ko(e,S),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+a-l/2,top:s+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:h},"widget-"+t)})]})}Dh.displayName="NetworkSVGOverlay";import*as Nh from"react";import{jsx as Lh}from"react/jsx-runtime";var Eh={position:"absolute",top:0,left:0,pointerEvents:"none"};function Ih({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=Nh.useRef(null),i=function(e,t,n){const[r,o]=Nh.useState(null);return Nh.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),Nh.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,s=t.left-n,a=t.right+n,c=t.top-n,l=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(s>t+e.width||t>a||c>n+e.height||n>l)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const s=Lh("div",{className:"semiotic-network-html-marks",ref:o,style:{...Eh,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>Lh("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?Lh(wn,{value:n,children:s}):s}import{jsx as Wh,jsxs as $h}from"react/jsx-runtime";function zh({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,resolvedBackground:a,resolvedForeground:c}){const{chartType:l,nodes:u,edges:h,data:d,className:f,description:y,title:p,responsiveWidth:g,responsiveHeight:m,summary:v,background:x,renderMode:b,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,layoutSelection:T,annotations:R,onAnnotationActivate:D,annotationObservationCallback:N,onObservation:L,chartId:E,autoPlaceAnnotations:I,svgAnnotationRules:W}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=e?d||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[i,s]),t.buildScene([i,s]);else{const e=_(u),n=Array.isArray(h)?_(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,s]),t.buildScene([i,s]))}}const $=t?.sceneNodes??[],z=t?.sceneEdges??[],O=t?.labels??[];return $h("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:g?"100%":r[0],height:m?"100%":r[1]},children:[Wh(ea,{summary:v}),$h("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[a&&Wh("g",{transform:`translate(${o.left},${o.top})`,children:a}),$h("g",{transform:`translate(${o.left},${o.top})`,children:[x&&Wh("rect",{x:0,y:0,width:i,height:s,fill:x}),z.map((e,t)=>Rc({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"line":return Ji("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>Rc({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Jn(n.style.fill)?nr(n.style.fill,`net-circle-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[r&&Ji("defs",{children:r}),Ji("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Jn(n.style.fill)?nr(n.style.fill,`net-rect-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[r&&Ji("defs",{children:r}),Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=Qi().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(ts)||"",o=Jn(n.style.fill)?nr(n.style.fill,`net-arc-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[o&&Ji("defs",{children:o}),Ji("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=dt(n.symbolType,n.size,n.path);return Ji("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?ns(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return rs(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),O.map((e,t)=>function(e,t){return Ji("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),Wh(Dh,{width:i,height:s,totalWidth:r[0],totalHeight:r[1],margin:o,labels:O,sceneNodes:$,title:p,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,foregroundGraphics:vn(c,An(t?.customLayoutOverlays,T??null)),annotations:R,onAnnotationActivate:D,onObservation:N??L,chartId:E,chartType:"StreamNetworkFrame",autoPlaceAnnotations:I,svgAnnotationRules:W,annotationFrame:0}),Wh(Ih,{marks:t?.customLayoutHtmlMarks,margin:o,selection:T??null})]})}import{jsx as Oh}from"react/jsx-runtime";"undefined"!=typeof process&&process;var Fh={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Bh={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Yh(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?Oh("div",{style:{...Fh,width:t,height:n},children:r||"No data available"}):null}function jh(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return Oh("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return Oh("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>Oh("div",{className:"semiotic-loading-bar",style:{...Bh,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Hh(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Xh(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Gh=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(Xh());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(Xh())},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Vh=null;import{jsx as qh,jsxs as Uh}from"react/jsx-runtime";var Kh=/^(value|amount|total|count|weight|score)$/i;function Qh({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?Uh("div",{className:"semiotic-tooltip",style:ma,children:[Uh("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return Uh("div",{className:"semiotic-tooltip",style:ma,children:[qh("div",{children:e.map((e,t)=>Uh("span",{children:[t>0&&qh("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?qh("strong",{children:e}):qh("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&qh("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=ya(t.data??t),s=null!=i.title?i.title+"":t.id,a=i.entries.some(e=>Kh.test(e.key));return Uh("div",{className:"semiotic-tooltip",style:ma,children:[qh("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>{return Uh("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Zh(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Jh(e,t){if(!t.pathD)return;e.save();const n=Zh(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",s=Un(e,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function ed(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Un(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function td(e,t){if(!t.pathD)return;e.save();const n=Zh(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function nd(e,t){if(!t.pathD)return;e.save();const n=Zh(t),r=t.style.stroke||"#999";e.strokeStyle=Un(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}Qh.ownsChrome=!0;var rd=new Map;function od(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=rd.get(t);return n||(n=new Path2D(dt(e.symbolType,e.size)),rd.size>256&&rd.clear(),rd.set(t,n)),n}catch{return null}}function id(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:be,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return s.length}function sd(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Tn(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"rect":return function(e,t,n){const r=Pn(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const s=Nn(Math.atan2(o,r)),a=Nn(e.startAngle),c=Nn(e.endAngle);if(a>c?s>=a||c>=s:s>=a&&c>=s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Tn(ft(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=Fn(e.glyph,e.size),i=e.cx+o.centerDx,s=e.cy+o.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Tn(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:s,distance:l}}(e,t,n,r);default:return null}}var ad=null,cd=null;function ld(){return cd||((ad=document.createElement("canvas")).width=1,ad.height=1,cd=ad.getContext("2d")),cd}function ud(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function hd(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=ud(e),o=ld();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let s=((t-e.x1)*r+(n-e.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,c=e.y1+s*o,l=Math.sqrt((t-a)**2+(n-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:a,y:c,distance:l}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=ud(e),o=ld();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function dd(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:c,nodeQuadtree:l,maxNodeRadius:u,hitRadius:h=30}=e,d=t-r.left-o.left,f=n-r.top-o.top;if(0>d||d>i||0>f||f>s)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,s=0){let a=null,c=o,l=1/0;if(i){const e=Yn(i,n,r,o,s,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=sd(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(a=e,l=n)}else c>e.distance&&(a=e,c=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=hd(e,n,r);t&&c>t.distance&&(a=t,c=t.distance)}return a}(a,c,d,f,h,l,u);return y?{kind:"hit",hover:ca(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}import{useCallback as fd}from"react";var yd="StreamNetworkFrame";import{jsx as pd,jsxs as gd}from"react/jsx-runtime";var md={top:20,right:80,bottom:20,left:80},vd={top:40,right:40,bottom:40,left:40},xd=new Set(["chord","force","circlepack","orbit"]),bd=[800,600],kd=ul(ll(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:v=300,forceStrength:x=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:w,padAngle:A=.01,groupWidth:S=20,sortGroups:M,edgeSort:C,treeOrientation:P="vertical",edgeType:T="curve",padding:R,paddingTop:D,tensionConfig:N,showParticles:L=!1,particleStyle:E,renderMode:I,nodeStyle:$,edgeStyle:z,colorBy:O,colorScheme:F="category10",edgeColorBy:B="source",edgeOpacity:Y=.5,colorByDepth:j=!1,nodeSize:H=8,nodeSizeRange:X=[5,20],nodeLabel:G,showLabels:V=!0,labelMode:q,size:U=bd,responsiveWidth:K,responsiveHeight:Q,margin:Z,className:J,background:ee,enableHover:te=!0,tooltipContent:ne,customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,annotationObservationCallback:se,chartId:ae,onTopologyChange:ce,annotations:le,onAnnotationActivate:ue,autoPlaceAnnotations:he,svgAnnotationRules:de,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:ve,legendIsolatedCategories:xe,title:ke,foregroundGraphics:we,backgroundGraphics:Ae,decay:Se,pulse:_e,transition:Me,animate:Ce,staleness:Pe,frameScheduler:Te,clock:Re,random:De,seed:Ne,paused:Le=!1,suspendWhenHidden:Ee=!0,thresholds:Ie,accessibleTable:We=!0,description:$e,summary:ze,orbitMode:Oe,orbitSize:Fe,orbitSpeed:Be,orbitRevolution:Ye,orbitRevolutionStyle:je,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Ge,customNetworkLayout:Ve,onLayoutError:qe,layoutConfig:Ue,layoutSelection:Ke}=e,Qe=xd.has(n)?vd:md,Ze=rl(!0),Je=za({sizeProp:U,responsiveWidth:K,responsiveHeight:Q,userMargin:Z,marginDefault:Qe,title:ke,legend:fe,legendPosition:ye,foregroundGraphics:we,backgroundGraphics:Ae,animate:Ce,transitionProp:Me,frameScheduler:Te,clock:Re,random:De,seed:Ne,paused:Le,suspendWhenHidden:Ee,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedForeground:st,resolvedBackground:at,transition:ct,introEnabled:lt,tableId:ut,rafRef:ht,renderFnRef:dt,scheduleRender:ft,frameRuntime:yt,currentTheme:pt}=Je,gt=hs(),mt=ps(),vt=sl(()=>_(r),[r]),xt=sl(()=>Array.isArray(o)?_(o):o,[o]),bt=sl(()=>({...hl,...N}),[N]),kt=sl(()=>({...dl,...E}),[E]),wt=sl(()=>{return{chartType:(e={chartType:n,clock:yt.now,random:De,seed:Ne,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:v,forceStrength:x,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:C,treeOrientation:P,edgeType:T,padding:R,paddingTop:D,tensionConfig:bt,showParticles:L,particleStyle:kt,nodeStyle:$,edgeStyle:z,nodeLabel:G,showLabels:V,labelMode:q,colorBy:O,colorScheme:F,edgeColorBy:B,edgeOpacity:Y,colorByDepth:j,nodeSize:H,nodeSizeRange:X,decay:Se,pulse:_e,transition:ct,introAnimation:lt,staleness:Pe,thresholds:Ie,orbitMode:Oe,orbitSize:Fe,orbitSpeed:Be,orbitRevolution:Ye,orbitRevolutionStyle:je,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Ge,customNetworkLayout:Ve,onLayoutError:qe,layoutConfig:Ue,currentTheme:pt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:W(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,yt.now,De,Ne,a,c,l,u,h,d,f,y,p,g,m,v,x,A,S,M,C,P,T,R,D,bt,L,kt,$,z,G,V,q,O,F,B,Y,j,H,X,Se,_e,ct,lt,Pe,Ie,Oe,Fe,Be,Ye,je,He,Xe,Ge,Ve,qe,Ue,pt]),At=ms(wt),St=ms({chartType:(_t={chartType:n,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:v,forceStrength:x,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:C,treeOrientation:P,edgeType:T,padding:R,paddingTop:D,random:De,seed:Ne,tensionConfig:bt,customNetworkLayout:Ve,orbitMode:Oe,orbitSize:Fe,orbitEccentricity:He}).chartType,nodeIDAccessor:_t.nodeIDAccessor,sourceAccessor:_t.sourceAccessor,targetAccessor:_t.targetAccessor,valueAccessor:_t.valueAccessor,edgeIdAccessor:_t.edgeIdAccessor,childrenAccessor:_t.childrenAccessor,hierarchySum:_t.hierarchySum,orientation:_t.orientation,nodeAlign:_t.nodeAlign,nodePaddingRatio:_t.nodePaddingRatio,nodeWidth:_t.nodeWidth,iterations:_t.iterations,forceStrength:_t.forceStrength,padAngle:_t.padAngle,groupWidth:_t.groupWidth,sortGroups:_t.sortGroups,edgeSort:_t.edgeSort,treeOrientation:_t.treeOrientation,edgeType:_t.edgeType,padding:_t.padding,paddingTop:_t.paddingTop,random:_t.random,seed:_t.seed,tensionConfig:_t.tensionConfig,customNetworkLayout:_t.customNetworkLayout,orbitMode:_t.orbitMode,orbitSize:_t.orbitSize,orbitEccentricity:_t.orbitEccentricity});var _t;const Mt=rl(0),Ct=rl(0),Pt=rl(!1),Tt=rl(null);Tt.current||(Tt.current=new Mh(At));const Rt=pn("StreamNetworkFrame"),Dt=al((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(Rt.current,e,()=>e.buildScene(t),n),[Rt]),[Nt,Lt]=ol(null),[Et,It]=ol(0),[Wt,$t]=ol(0),[zt,Ot]=ol(!1),[Ft,Bt]=ol(!1),Yt=rl(0),jt=rl(null),Ht=rl(!1),Xt=rl(w);Xt.current=w;const Gt=rl(At);Gt.current=At;const Vt=rl(null),qt=rl(new Map),Ut=rl(0),Kt=al(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:be;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const s=Array.isArray(r)?r:be,a=n?s[i.current++%s.length]:s[0];return o.set(t.id,a),a}({node:e,colorBy:O,colorScheme:F,nodeColorMap:qt.current,colorIndexRef:Ut}),[O,F]),Qt=(Zt=pt,Zt?.colors?.border||Zt?.colors?.secondary||Zt?.colors?.primary||"#999");var Zt;const Jt=al(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Tt.current?.nodes),[]),en=al(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const s=o(t.source),a=o(t.target);return"target"===n&&a?r(a):s?r(s):i}({edge:e,edgeColorBy:B,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[B,Kt,Qt,Jt]),tn=al(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:c}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):c}if(!o)return i(t);const l=r,u=a(t.source),h=a(t.target);return"target"===l&&h?s(h):u?s(u):c}({edge:e,particleStyleColor:kt.color,particleColorBy:kt.colorBy,hasExplicitParticleColorBy:!!E?.colorBy,getEdgeColor:en,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[E?.colorBy,kt.color,kt.colorBy,Kt,en,Qt,Jt]),nn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ve,L,!!_e,Tt.current?.isAnimating??!1);Mn(Tt,At,Ze,ft),Cn(Tt,Ke,Ze,ft),il(()=>{const e=Tt.current;e&&(Dt(e,[ot,it]),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Ze.current=!0,ft())},[pt,ot,it,Dt,ft,F]);const rn=al(()=>{const e=Tt.current;if(e&&(e.runLayout([ot,it]),Dt(e,[ot,it]),Ze.current=!0,Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),It(e.layoutVersion),ce)){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[ot,it,Dt,ce,F]),on=al(e=>{if(null==e||"object"!=typeof e)return;const t=Tt.current;t&&(t.ingestEdge(e)&&rn(),ft())},[rn,ft]),sn=al(e=>{const t=Tt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&rn(),ft()},[rn,ft]),an=al(()=>{Tt.current?.clear(),qt.current.clear(),Ut.current=0,It(Tt.current?.layoutVersion??0),Lt(null),Vt.current=null,Ze.current=!0,ft()},[ft]),cn=al(()=>{const e=Tt.current;e&&(e.tension+=999,rn(),ft())},[rn,ft]);cl(t,()=>({push:on,pushMany:sn,removeNode:e=>{const t=Tt.current?.removeNode(e)??!1;if(t){const t=Vt.current?.data?"function"==typeof a?a(Vt.current.data):Vt.current.data[a]:void 0;Vt.current&&"node"===Vt.current.nodeOrEdge&&t===e&&(Vt.current=null,Lt(null)),qt.current.delete(e),rn(),Ze.current=!0,ft()}return t},removeEdge:(e,t)=>{const n=Tt.current?.removeEdge(e,t)??!1;if(n){if(Vt.current&&"edge"===Vt.current.nodeOrEdge){const n=Vt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!h||!n||("function"==typeof h?h:e=>e?.[h])(n)===e,r&&(Vt.current=null,Lt(null))}rn(),Ze.current=!0,ft()}return n},updateNode:(e,t)=>{const n=Tt.current?.updateNode(e,t)??null;return n&&(Ze.current=!0,ft()),n},updateEdge:(e,t,n)=>{const r=Tt.current?.updateEdge(e,t,n)??[];return r.length>0&&(rn(),Ze.current=!0,ft()),r},clear:an,getTopology:()=>Tt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Tt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Tt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Tt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:cn,getTension:()=>Tt.current?.tension??0}),[on,sn,an,cn,a,rn,ft,h]);const ln=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),un=ln?i||(Array.isArray(o)?void 0:o):void 0;il(()=>{const e=Tt.current;if(!e)return;const t=++Yt.current;if(jt.current?.abort(),jt.current=null,ln&&un)e.ingestHierarchy(un,[ot,it]),Dt(e,[ot,it]),Bt(!1),Xt.current?.("ready"),Ze.current=!0,ft();else{const i=vt,s=Array.isArray(xt)?xt:[];if(0===i.length&&0===s.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||an(),Bt(!1),void Xt.current?.("ready");const a=[ot,it],c="force"===n&&!Ve&&Hh()&&!De&&function(e,t,n,r,o=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}(b,i.length,s.length,v);if(c&&mt&&!Ht.current&&e.sceneNodes.length>0)return Ht.current=!0,Bt(!1),Xt.current?.("ready"),Ze.current=!0,void ft();if(c){const n=new AbortController;jt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,s,a,{deferLayout:!0});const o=e.getLayoutData(),c=function(e,t,n,r,o){const i=Ru(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Gt.current,a,r);return Bt(!0),Xt.current?.("pending"),function(e,t){return Hh()?t?.aborted?Promise.reject(Xh()):(Vh&&!Vh.isDead||(Vh=new Gh),Vh).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===Yt.current&&(e.applyForceLayoutPositions(n,a),Dt(e,a),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Bt(!1),Xt.current?.("ready"),It(e.layoutVersion),Ze.current=!0,ft())}).catch(n=>{"AbortError"!==n.name&&t===Yt.current&&(e.runLayout(a),Dt(e,a),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Bt(!1),Xt.current?.("error"),It(e.layoutVersion),Ze.current=!0,ft())}),()=>n.abort()}e.ingestBounded(i,s,a),Dt(e,a),Bt(!1),Xt.current?.("ready"),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Ze.current=!0,ft()}},[vt,xt,r,o,i,un,ln,ot,it,St,b,v,mt,n,Ve,De,ft,an,F,Dt]),il(()=>{s&&s.length>0&&sn(s)},[s,sn]);const{customHoverBehavior:hn,customClickBehavior:dn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:fd((t,o)=>{e?.(t,o),Oc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:yd,chartId:r,context:o})},[e,n,r]),customClickBehavior:fd((e,o)=>{t?.(e,o),Fc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:yd,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,chartId:ae}),{hoverHandlerRef:fn,hoverLeaveRef:yn,onPointerMove:mn,onPointerLeave:xn}=Je,bn=()=>!Ve||(Tt.current?.hasCustomRestyle??!1);fn.current=e=>{if(!te)return;const t=bn(),n=Dn.current;if(!n)return;const r=Tt.current;if(!r)return;const o=dd({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Vt.current=o.hover,Lt(o.hover),hn&&(hn(o.hover),t&&(Ze.current=!0)),t&&ft()):Vt.current&&(Vt.current=null,Lt(null),hn&&(hn(null),t&&(Ze.current=!0)),t&&ft())},yn.current=()=>{if(Vt.current){const e=bn();Vt.current=null,Lt(null),hn&&(hn(null),e&&(Ze.current=!0)),e&&ft()}};const kn=rl(()=>{});kn.current=e=>{if(Qo(e.target))return;if(!oe&&!ie)return;const t=Dn.current;if(!t)return;const n=Tt.current;if(!n)return;const r=dd({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?dn(r.hover,{type:"activate",inputType:$c(e.nativeEvent.pointerType)}):"miss"===r.kind&&dn(null)};const wn=al(e=>kn.current(e),[]),Sn=rl(-1),_n=rl(null),Pn=rl(-1),Tn=al(e=>{if(zc(e))return;const t=Tt.current;if(!t)return;const n=()=>{Sn.current=-1,_n.current=null,Pn.current=-1,Vt.current=null,Lt(null),hn&&(hn(null),Ze.current=!0),ft()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=Fn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Sn.current||n());const o=Hc(r);let i=Sn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void dn(ca(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Sn.current=0,Pn.current=-1;const t=o.flat[0];_n.current={shape:t.shape,w:t.w,h:t.h};const n=ca(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vt.current=n,Lt(n),hn&&(hn(n,{type:"focus",inputType:"keyboard"}),Ze.current=!0),void ft()}const s=Xc(o,i),a=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Gc(e,t,n);const s=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const s=e.flat[i];if(s===t)continue;const a=s.x-t.x,c=s.y-t.y;let l=!1;switch(n){case"right":l=a>0&&Math.abs(a)>=Math.abs(c);break;case"left":l=0>a&&Math.abs(a)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(a);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(a)}if(!l)continue;const u=a*a+c*c;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=Uc(t.source),i=Uc(t.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Gc(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,s,o,t.sceneEdges??[],Pn);if(null===a)return;if(e.preventDefault(),0>a)return void n();Sn.current=a;const c=o.flat[a];_n.current={shape:c.shape,w:c.w,h:c.h};const l={data:c.datum||{},x:c.x,y:c.y,__semioticHoverData:!0,nodeOrEdge:"node"};Vt.current=l,Lt(l),hn&&(hn(l,{type:"focus",inputType:"keyboard"}),Ze.current=!0),ft()},[dn,hn,ft]),Rn=al(e=>{Sn.current=-1,_n.current=null,mn(e)},[mn]);dt.current=()=>{if(ht.current=null,!yt.isActive)return;const e=Dn.current;if(!e)return;const t=Tt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,background:c,renderMode:l,hasBackgroundGraphics:u=!1,dirtyRef:h,lastFrameTimeRef:d,now:f,random:y,reducedMotion:p,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:b,thresholds:k,staleness:w,particleStyle:A,getParticleColor:S,pendingAnnotationFrameRef:_,lastAnnotationFrameTimeRef:M,setAnnotationFrame:C,scheduleNextFrame:P}=e,T=t.getContext("2d");if(!T)return;const R=d.current?Math.min((f-d.current)/1e3,.1):.016;d.current=f;const D=n.advanceTransition(p?f+1e6:f),N=!p&&D,L=!p&&n.tickAnimation([s,a],R),E=h.current,I=r?.beforeCompute(n.getLastUpdateResult(),N),W=D||E||L;W&&n.buildScene([s,a]),I&&r?.afterCompute(I,W,!1);const $=g&&!p&&!!n.particlePool,z=!!((O={dirtyOrRebuilt:E,transitioning:N,animationTicked:L,continuous:$||m,liveEncoding:!!x||!!b||!!k||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||O.transitioning||O.animationTicked||O.continuous||O.liveEncoding||O.forced);var O;const F=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(z){const e=Ga();if(!Xa(t,o,i,e))return;if(T.clearRect(-i.left,-i.top,o[0],o[1]),ks(T,{background:c,hasBackgroundGraphics:u,width:s,height:a}),x&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==v&&n.applyTopologyDiff(f),F&&(T.globalAlpha=w?.dimOpacity??.5),Tc({context:T,nodes:n.sceneEdges,renderMode:l,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Jh(e,n);break;case"line":ed(e,n);break;case"ribbon":td(e,n);break;case"curved":nd(e,n)}}(T,e)}),Tc({context:T,nodes:n.sceneNodes,renderMode:l,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),ic(e,t),e.restore())}}(T,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),sc(e,t),e.restore())}}(T,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(T,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=od(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=yr(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(T,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&gc(e,r,r.cx,r.cy,n);e.globalAlpha=n}(T,t)}}),$&&!F){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,s=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=s)continue;const c=a.value*i*n*(a.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let h=l;o()<u&&h++;for(let t=0;h>t&&e.countForEdge(r)<s;t++)e.spawn(r,o)}}(n.particlePool,e,R,A,y);const t=.5*(A.speedMultiplier??1);let r;if(A.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(R,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const c=n[a.edgeIndex];if(!c)continue;let l;l="string"==typeof r.color&&"inherit"!==r.color?r.color:o(c),e.fillStyle=Un(e,l)||l,e.beginPath(),e.arc(a.x,a.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(T,n.particlePool,e,A,S)}}F&&(T.globalAlpha=1)}h.current=!1,(E||N||L)&&t.setAttribute("aria-label",zs(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const B=E||N||L||_.current;B&&f-M.current>=33?(C(e=>e+1),M.current=f,_.current=!1):_.current=!!B,(m||N||null!=n.transition||L||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||_.current)&&P()}({canvas:e,store:t,sceneRevisionDiagnostics:Rt.current,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,background:ee,renderMode:I,hasBackgroundGraphics:!!Ae,dirtyRef:Ze,lastFrameTimeRef:Mt,now:yt.now(),random:yt.random,reducedMotion:!!et.current,showParticles:L,isContinuous:nn,animate:Ce,decay:Se,pulse:_e,thresholds:Ie,staleness:Pe,particleStyle:kt,getParticleColor:tn,pendingAnnotationFrameRef:Pt,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:$t,scheduleNextFrame:()=>{ft()}})};const{canvasRef:Dn}=Ya(Je,{hydrated:gt,wasHydratingFromSSR:mt,storeRef:Tt,dirtyRef:Ze,canvasPaintDependencies:[n,ot,it,ee,Ae,I,ft]});$r(Pe,Tt,Ze,ft,zt,Ot);const Nn=te&&Nt?pd(xa,{x:Nt.x,y:Nt.y,containerWidth:ot,containerHeight:it,margin:rt,className:"stream-network-tooltip",zIndex:2,children:ne?ne(Nt):pd(Qh,{data:Nt})}):null;if(os||!gt&&mt)return pd(zh,{props:e,store:Tt.current,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedBackground:at,resolvedForeground:st});const Ln=Tt.current;return gd("div",{ref:tt,className:"stream-network-frame"+(J?" "+J:""),role:"group","aria-label":$e||("string"==typeof ke?ke:"Network chart"),tabIndex:0,"aria-busy":Ft||void 0,style:{position:"relative",width:K?"100%":nt[0],height:Q?"100%":nt[1],overflow:"visible"},onKeyDown:Tn,children:["production"!==process.env.NODE_ENV&&Tt.current&&pd(gn,{store:Tt.current,diagnostics:Rt.current}),We&&pd(ta,{tableId:ut}),We&&pd(Js,{nodes:Ln?.sceneNodes??[],edges:Ln?.sceneEdges??[],chartType:"Network chart",tableId:ut,chartTitle:"string"==typeof ke?ke:void 0}),pd(ea,{summary:ze}),pd(Ds,{hoverPoint:Nt}),gd("div",{role:"img","aria-label":$e||("string"==typeof ke?ke:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:te?Rn:void 0,onMouseLeave:te?xn:void 0,onClick:oe||ie?wn:void 0,children:[Ft&&!1!==k&&pd("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:jh(!0,nt[0],nt[1],k)}),pd(ja,{size:nt,margin:rt,overflowVisible:!0,children:at}),pd("canvas",{ref:Dn,"aria-label":zs(Ln?.sceneNodes?.length??0,Ln?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),pd(Dh,{width:ot,height:it,totalWidth:nt[0],totalHeight:nt[1],margin:rt,labels:Ln?.labels||[],sceneNodes:Ln?.sceneNodes,title:ke,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:ve,legendIsolatedCategories:xe,foregroundGraphics:vn(st,An(Tt.current?.customLayoutOverlays,Ke??null)),annotations:le,onAnnotationActivate:ue,onObservation:se??ie,chartId:ae,chartType:"StreamNetworkFrame",autoPlaceAnnotations:he,svgAnnotationRules:de,annotationFrame:Wt}),pd(Ih,{marks:Ln?.customLayoutHtmlMarks,margin:rt,selection:Ke??null}),pd(oa,{active:Sn.current>=0,hoverPoint:Nt,margin:rt,size:nt,shape:_n.current?.shape,width:_n.current?.w,height:_n.current?.h}),Nn,Pe?.showBadge&&pd(Or,{isStale:zt,position:Pe.badgePosition})]})]})}));kd.displayName="StreamNetworkFrame";var wd=kd,Ad=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Sd=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,r=Math.floor(e/n);for(let o=Math.floor((e-this.size)/n)+1;r>=o;o++)this.bump(o*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Ad,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,r=new Ad;r.push(t);let o=e,i=e;const s=[],a={start:o,end:i,stats:r};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),o>t.start&&(o=t.start),t.end>i&&(i=t.end));a.start=o,a.end=i,s.push(a),s.sort((e,t)=>e.start-t.start),this.sessions=s}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const r=t+this.size;e.push(this.row(t,r,n,r>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,r){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function _d(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function Md(e,t,n,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=_d(e,n),i=e.stddev*r;return[o-i,o+i]}var Cd={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Pd=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Td(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Pd.lastIndex=0;let n,r=0,o=0;for(;null!==(n=Pd.exec(t));){const e=parseFloat(n[1]),t=Cd[n[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=n[0].length}return o!==t.length?null:r>0?r:null}var Rd=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const r of this.held)this.getTime(r)>e?n.push(r):t.push(r);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Dd,useImperativeHandle as Nd,forwardRef as Ld,useCallback as Ed,useState as Id,useEffect as Wd}from"react";import{useMemo as $d,useCallback as zd,useState as Od,useId as Fd,useEffect as Bd,useRef as Yd}from"react";function jd(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Hd(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Xd(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Gd,Vd]=E(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!Xd(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),s=Hd(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Hd(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}}));import{useId as qd,useMemo as Ud,useCallback as Kd}from"react";function Qd(e){const t=qd(),n=e.clientId||t,{name:r}=e,o=Vd(e=>e.selections.get(r)),i=Vd(e=>e.setClause),s=Vd(e=>e.clearClause),a=Ud(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Ud(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(jd(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:Kd(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:Kd(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:Kd(()=>{s(r,n)},[s,r,n]),clientId:n}}function Zd(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Jd(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function ef(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function tf(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function nf(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}var rf=[],of={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function sf(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!i)return of;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function af({selection:e,linkedHover:t,fallbackFields:n=rf,unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const h=Fd(),d=$d(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=$d(()=>"series"===d?.mode?[d.seriesField||l||n[0]].filter(e=>!!e):d?.fields||n,[d,l,n]),y=Qd({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:s}=Qd({name:t,fields:n});return{onHover:Kd(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Jd(t)&&i(t)},[n,i,s]),predicate:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=qo(e=>e.pushObservation),m=zd(e=>{o?.(e),g?.(e)},[o,g]),v=e?{isActive:y.isActive,predicate:y.predicate}:null,[x,b]=Od(null),k=Yd(!1),w=l||n[0],A=$d(()=>{if(!c||null==x||!w)return null;const e=x,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,x,w]),S=zd((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===d?.mode&&d.xField){const n=tf(e,t,d.xField);null!=n&&function(e,t,n){const r=Ci.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Ci={positions:new Map(Ci.positions).set(e,{xValue:t,sourceId:n})},Ti())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(t)}else"x-position"!==d?.mode||r||Ri(d.name||"hover",h),"x-position"===d?.mode||r||p.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else r||b(null);(o||g)&&Oc({onObservation:m,datum:e?nf(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,p,d,h,o,i,s,g,m,c,w,u]),_=zd((n=!0)=>{k.current=!1,t&&"x-position"!==d?.mode&&p.onHover(null),e&&u?.tapToSelect&&y.clear(),n&&c&&b(null),"x-position"===d?.mode&&(Di(d.name||"hover",h),Ri(d.name||"hover",h))},[t,d,p,e,u,y,c,h]),M=zd((n,r)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),v=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=tf(n,e,d.xField);null!=t&&function(e,t,n){const r=Ci.positions.get(e);if(r?.locked){const t=new Map(Ci.positions);return t.delete(e),Ci={positions:t},Ti(),!1}Ci={positions:new Map(Ci.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ti()}(d.name||"hover",t,h)}if(l)if(n){k.current=!0;const r=nf(n);if(t&&"x-position"!==d?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}(function(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(e)&&y.selectPoints(e)}if(c&&w){const e=r?.[w];b(null!=e?e+"":null)}}else v&&_();if(n||v){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(o||g)&&Fc({onObservation:m,datum:n?nf(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:r})}},[a,o,g,m,i,s,d,h,u,t,p,e,y,f,c,w,_]);return Bd(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&_()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,_]),Bd(()=>()=>{k.current&&_(!1)},[_]),Bd(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{Di(e,h),Ri(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:v,hoverSelectionHook:A,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:h}}var cf={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 lf(e,t,n){const r=cf[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])ef(e[r])&&ef(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??i}).props,a=s.mode||e,c=cf[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:uf(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:sf(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function uf(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{jsx as hf,jsxs as df}from"react/jsx-runtime";var ff={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},yf={opacity:.7,marginRight:4};function pf(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function gf(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function mf(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=pf(i,t,"time"),a=pf(i,n,"value");return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[df("span",{style:yf,children:[r,":"]}),gf(s)]}),df("div",{children:[df("span",{style:yf,children:[o,":"]}),gf(a)]})]})}}function vf(e,t){return null!=e?e:Math.max(t?.length??0,200)}var xf="time",bf="value",kf="__aggLower",wf="__aggUpper",Af="__aggPartial",Sf="count",_f="__aggStart",Mf="__aggEnd";function Cf(e,t){const n=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[xf]:(e.start+e.end)/2,[bf]:_d(e,n),[Sf]:e.count,[Af]:e.partial,[_f]:e.start,[Mf]:e.end},i=Md(e,r,n,o);return i&&(t[kf]=i[0],t[wf]=i[1]),t})}function Pf(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={};r&&(f.annotationObservationCallback=r);const y=l?.enabled?Math.max(i??30,Math.ceil((l.targetSize||44)/2),24):i;return(a||t||r||o||s)&&(f.customHoverBehavior=u),h&&(c||(d?r||o||t:r||o)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}import{jsx as Tf}from"react/jsx-runtime";function Rf(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isFinite(o)?o:null}var Df=Ld(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,transition:D,linkedHover:N,selection:L,onObservation:E,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F,aggregate:B,eventTime:Y}=e,j=n.showAxes,H=n.enableHover,X=o??n.marginDefaults,G=r??[n.width,n.height],V=b??k??mf({timeAccessor:u,valueAccessor:h}),q=Dd(null),{customHoverBehavior:U}=af({selection:L,linkedHover:N,unwrapData:!0,onObservation:E,chartType:"RealtimeLineChart",chartId:I}),K=Ed(e=>{w&&w(e),U(e)},[w,U]),Q=null!=B,[Z,J]=Id([]),ee=Dd(null),te=Dd(B);te.current=B;const ne=Dd(Q);ne.current=Q;const re=Dd(Z);re.current=Z;const oe=Dd({timeAccessor:u,valueAccessor:h});oe.current={timeAccessor:u,valueAccessor:h},Wd(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=Td("session"===t?e.gap??e.size:e.size);if(null==n)return null;const r=null!=e.hop?Td(e.hop):void 0,o=null!=e.gap?Td(e.gap):void 0;return new Sd({window:t,size:n,hop:r??void 0,gap:o??void 0,retain:e.retain})}(e);if(ee.current=t,t&&l){const{timeAccessor:e,valueAccessor:n}=oe.current;for(const r of l){const o=Rf(r,e,"time"),i=Rf(r,n,"value");null!=o&&null!=i&&t.push(o,i)}}J(t?Cf(t,e):[])},[Q?[B.window??"tumbling",B.size,B.hop??"",B.gap??"",B.retain??""].join("|"):"",Q,l]),Wd(()=>{Q&&ee.current&&J(Cf(ee.current,te.current))},[B?.stat,B?.band,B?.sigma]);const ie=Ed(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:r,valueAccessor:o}=oe.current;for(const n of e){const e=Rf(n,r,"time"),i=Rf(n,o,"value");null!=e&&null!=i&&t.push(e,i)}J(Cf(t,n))},[]),se=null!=Y,ae=Dd(null),ce=Dd(Y);ce.current=Y;const le=Dd(se);le.current=se;const ue=Dd(E);ue.current=E;const he=Dd(I);he.current=I,Wd(()=>{ae.current=se?function(e){const t=Td(e.lateness);return null==t?null:new Rd({lateness:t,getTime:e=>Rf(e,oe.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[se?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",se]);const de=Ed(e=>{0!==e.length&&(ne.current?ie(e):q.current?.pushMany(e))},[ie]),fe=Ed(e=>{const t=ae.current;if(!le.current||!t)return void de(e);const n=[];for(const r of e){const e=t.push(r);if(e.released.length&&n.push(...e.released),e.late.length){const n=ue.current;if(n){const{timeAccessor:r}=oe.current,o=ce.current?.latePolicy??"drop";for(const i of e.late)n({type:"late-data",datum:i,eventTime:Rf(i,r,"time")??NaN,watermark:t.watermark,policy:o,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:he.current})}}}de(n)},[de]);Nd(t,()=>({push:e=>fe([e]),pushMany:e=>fe(e),remove:e=>ne.current?[]:q.current?.remove(e)??[],update:(e,t)=>ne.current?[]:q.current?.update(e,t)??[],clear:()=>{ae.current?.clear(),ne.current?(ee.current?.clear(),J([])):q.current?.clear()},getData:()=>ne.current?re.current:q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[fe]);const ye=jh(W,G[0],G[1],$),pe=ye?null:Yh(Q?void 0:l,G[0],G[1],z),ge={stroke:p,strokeWidth:g,strokeDasharray:m};null!=v&&(ge.opacity=v);const me=vf(c,l),ve=Q?Z:l,xe=Q?xf:u,be=Q?bf:h,ke=Q&&B&&"none"!==(B.band??"none")?{y0Accessor:kf,y1Accessor:wf,perSeries:!1}:void 0;return ye||pe||Tf(nl,{ref:q,chartType:"line",runtimeMode:"streaming",size:G,margin:X,className:O?`${i||""} semiotic-emphasis-${O}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,B?.retain??Math.max(Z.length,600)):me,data:ve,timeAccessor:xe,valueAccessor:be,xExtent:d,yExtent:f,extentPadding:y,band:ke,lineStyle:ge,showAxes:j,background:x,hoverAnnotation:H,tooltipContent:V,...Pf({linkedHover:N,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,transition:D,pointIdAccessor:e.pointIdAccessor,legendPosition:F})});Df.displayName="RealtimeLineChart";import{useRef as Nf,useImperativeHandle as Lf,forwardRef as Ef,useCallback as If,useMemo as Wf}from"react";import{jsx as $f}from"react/jsx-runtime";function zf(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}var Of=Ef(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:r,size:o,margin:i,className:s,arrowOfTime:a="right",windowMode:c="sliding",windowSize:l,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,linkedHover:L,selection:E,decay:I,pulse:W,staleness:$,transition:z,onObservation:O,chartId:F,loading:B,loadingContent:Y,emptyContent:j,emphasis:H,legendPosition:X,brush:G,onBrush:V,linkedBrush:q}=e,U=n.showAxes,K=n.enableHover,Q=i??n.marginDefaults,Z=o??[n.width,n.height],J=_??M??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null;if(null==r?.binStart||null==r?.binEnd){const e=pf(r,t,"time"),o=pf(r,n,"value");return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"x:"}),gf(e)]}),df("div",{children:[hf("span",{style:yf,children:"y:"}),gf(o)]})]})}return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"range:"}),gf(r.binStart),"–",gf(r.binEnd)]}),null!=r.total&&df("div",{children:[hf("span",{style:yf,children:"count:"}),gf(r.total)]}),null!=r.category&&df("div",{children:[hf("span",{style:yf,children:"category:"}),gf(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),ee=Nf(null),{customHoverBehavior:te}=af({selection:E,linkedHover:L,unwrapData:!0,onObservation:O,chartType:"RealtimeHistogram",chartId:F}),ne=If(e=>{C&&C(e),te(e)},[C,te]),re=!0===G?{dimension:"x",snap:"bin"}:"x"===G?{dimension:"x"}:"object"==typeof G?G:void 0,oe=(ie=q)?"string"==typeof ie?{name:ie}:ie:null;var ie;const se="string"==typeof h?h:"time",ae=function(e){const{name:t,xField:n,yField:r}=e,{predicate:o,isActive:i,selectInterval:s,clear:a}=Qd({name:t,fields:[n,r].filter(Boolean)}),c=n&&r?"xyBrush":n?"xBrush":"yBrush",l=Kd(e=>{if(!e)return void a();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Zd(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&Zd(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Jd(t)&&s(t)},[c,n,r,s,a]);return{brushInteraction:Ud(()=>({brush:c,during:l,end:l}),[c,l]),predicate:o,isActive:i,clear:a}}({name:oe?.name||"__unused_hist_brush__",xField:oe?.xField||se,...oe?.yField?{yField:oe.yField}:{}}),ce=Nf(ae.brushInteraction);ce.current=ae.brushInteraction;const le=If(e=>{if(V&&V(e),O&&O(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}),oe){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[V,O,F,oe]);Lf(t,()=>({push:e=>ee.current?.push(e),pushMany:e=>ee.current?.pushMany(e),remove:e=>ee.current?.remove(e)??[],update:(e,t)=>ee.current?.update(e,t)??[],clear:()=>ee.current?.clear(),getData:()=>ee.current?.getData()??[],getScales:()=>ee.current?.getScales()??null}),[]);const ue=jh(B,Z[0],Z[1],Y),he=ue?null:Yh(u,Z[0],Z[1],j),de={};null!=x&&(de.fill=x),null!=b&&(de.stroke=b),null!=k&&(de.strokeWidth=k),null!=w&&(de.opacity=w),null!=A&&(de.gap=A);const fe=H?`${s||""} semiotic-emphasis-${H}`.trim():s,ye=vf(l,u),pe=Wf(()=>"down"!==f?p:function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!e||0===e.length)return;const s=new Map;for(const o of e){const e=zf(o,n,"time"),i=zf(o,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/r)*r;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())e>a&&(a=e);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ue||he||$f(nl,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:fe,arrowOfTime:a,windowMode:c,windowSize:ye,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pe,extentPadding:g,binSize:r,categoryAccessor:m,barColors:v,barStyle:de,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...Pf({linkedHover:L,selection:E,onObservation:O,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ne}),annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,decay:I,pulse:W,staleness:$,transition:z,pointIdAccessor:e.pointIdAccessor,legendPosition:X,brush:re||(q?{dimension:"x"}:void 0),onBrush:re||q?le:void 0})});function Ff(e){return $f(Of,{...e,windowMode:"growing"})}Of.displayName="RealtimeHistogram",Ff.displayName="TemporalHistogram";import{useRef as Bf,useImperativeHandle as Yf,forwardRef as jf,useCallback as Hf}from"react";import{jsx as Xf}from"react/jsx-runtime";var Gf=jf(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,linkedHover:L,selection:E,onObservation:I,chartId:W,loading:$,loadingContent:z,emptyContent:O,emphasis:F,legendPosition:B}=e,Y=n.showAxes,j=n.enableHover,H=o??n.marginDefaults,X=r??[n.width,n.height],G=_??M??mf({timeAccessor:u,valueAccessor:h}),V=Bf(null),{customHoverBehavior:q}=af({selection:E,linkedHover:L,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:W}),U=Hf(e=>{C&&C(e),q(e)},[C,q]);Yf(t,()=>({push:e=>V.current?.push(e),pushMany:e=>V.current?.pushMany(e),remove:e=>V.current?.remove(e)??[],update:(e,t)=>V.current?.update(e,t)??[],clear:()=>V.current?.clear(),getData:()=>V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[]);const K=jh($,X[0],X[1],z),Q=K?null:Yh(l,X[0],X[1],O),Z={};null!=v&&(Z.radius=v),null!=x&&(Z.fill=x),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,ee=F?`${i||""} semiotic-emphasis-${F}`.trim():i,te=vf(c,l);return K||Q||Xf(nl,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:Y,background:S,hoverAnnotation:j,tooltipContent:G,...Pf({linkedHover:L,selection:E,onObservation:I,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:D,tickFormatValue:N,legendPosition:B,pointIdAccessor:e.pointIdAccessor})});Gf.displayName="RealtimeSwarmChart";import{useRef as Vf,useImperativeHandle as qf,forwardRef as Uf,useCallback as Kf}from"react";import{jsx as Qf}from"react/jsx-runtime";var Zf=Uf(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:T,tickFormatTime:R,tickFormatValue:D,linkedHover:N,selection:L,onObservation:E,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F}=e,B=n.showAxes,Y=n.enableHover,j=o??n.marginDefaults,H=r??[n.width,n.height],X=S??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null,o=pf(r,t,"time"),i=r?.delta??pf(r,n,"value"),s=r?.cumEnd,a="number"==typeof i?0>i?gf(i):"+"+gf(i):gf(i);return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"x:"}),gf(o)]}),df("div",{children:[hf("span",{style:yf,children:"Δ:"}),a]}),null!=s&&df("div",{children:[hf("span",{style:yf,children:"total:"}),gf(s)]})]})}}({timeAccessor:u,valueAccessor:h}),G=Vf(null),{customHoverBehavior:V}=af({selection:L,linkedHover:N,unwrapData:!0,onObservation:E,chartType:"RealtimeWaterfallChart",chartId:I}),q=Kf(e=>{M&&M(e),V(e)},[M,V]);qf(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const U=jh(W,H[0],H[1],$),K=U?null:Yh(l,H[0],H[1],z),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=v&&(Q.connectorWidth=v),null!=x&&(Q.gap=x),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=O?`${i||""} semiotic-emphasis-${O}`.trim():i,J=vf(c,l);return U||K||Qf(nl,{ref:G,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:j,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:B,background:A,hoverAnnotation:Y,tooltipContent:X,...Pf({linkedHover:N,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:q}),annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:T,tickFormatTime:R,tickFormatValue:D,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Zf.displayName="RealtimeWaterfallChart";import{useRef as Jf,useImperativeHandle as ey,forwardRef as ty,useCallback as ny}from"react";import{jsx as ry}from"react/jsx-runtime";var oy=ty(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,linkedHover:D,selection:N,onObservation:L,chartId:E,loading:I,loadingContent:W,emptyContent:$,emphasis:z,legendPosition:O}=e,F=n.showAxes,B=n.enableHover,Y=o??n.marginDefaults,j=r??[n.width,n.height],H=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=i?.xCenter??pf(i,t,"time"),a=i?.yCenter??pf(i,n,"value"),c=i?.count,l=i?.sum,u=i?.value,h=i?.agg??"count";return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[df("span",{style:yf,children:[r,":"]}),gf(s)]}),df("div",{children:[df("span",{style:yf,children:[o,":"]}),gf(a)]}),null!=c&&df("div",{children:[hf("span",{style:yf,children:"count:"}),gf(c)]}),"sum"===h&&null!=l&&df("div",{children:[hf("span",{style:yf,children:"sum:"}),gf(l)]}),"mean"===h&&null!=u&&df("div",{children:[hf("span",{style:yf,children:"mean:"}),gf(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=Jf(null),{customHoverBehavior:G}=af({selection:N,linkedHover:D,unwrapData:!0,onObservation:L,chartType:"RealtimeHeatmap",chartId:E}),V=ny(e=>{w&&w(e),G(e)},[w,G]);ey(t,()=>({push:e=>X.current?.push(e),pushMany:e=>X.current?.pushMany(e),remove:e=>X.current?.remove(e)??[],update:(e,t)=>X.current?.update(e,t)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const q=jh(I,j[0],j[1],W),U=q?null:Yh(l,j[0],j[1],$),K=z?`${i||""} semiotic-emphasis-${z}`.trim():i,Q=vf(c,l);return q||U||ry(nl,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:j,margin:Y,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:F,background:x,hoverAnnotation:B,tooltipContent:H,...Pf({linkedHover:D,selection:N,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});oy.displayName="RealtimeHeatmap";import{useCallback as iy,useEffect as sy,useMemo as ay,useRef as cy,useState as ly}from"react";var uy=Symbol("semiotic.useStreamStatus.wrapped");function hy(e={}){const{staleThresholdMs:t=5e3,pollIntervalMs:n=1e3}=e,r=cy(null),[o,i]=ly("idle"),[s,a]=ly(null),c=iy(()=>{const e="undefined"!=typeof performance?performance.now():Date.now();r.current=e,a(e),i(e=>"active"===e?e:"active")},[]),l=ay(()=>{const e={_frame:null,_origPush:null,_origPushMany:null};return{get current(){return e._frame},set current(t){const n=e._frame;if(n&&n!==t&&e._origPush&&e._origPushMany&&(n.push=e._origPush,n.pushMany=e._origPushMany,delete n[uy]),e._frame=t,!t)return e._origPush=null,void(e._origPushMany=null);if(t[uy])return;t[uy]=!0;const r=t.push,o=t.pushMany,i=r.bind(t),s=o.bind(t);e._origPush=r,e._origPushMany=o,t.push=e=>(c(),i(e)),t.pushMany=e=>(e&&e.length>0&&c(),s(e))}}},[c]);return sy(()=>{const e=setInterval(()=>{const e=r.current;if(null==e)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-e>t;i(e=>{const t=n?"stale":"active";return e===t?e:t})},n);return()=>clearInterval(e)},[t,n]),{ref:l,status:o,lastPushTime:s}}import{useEffect as dy,useMemo as fy,useRef as yy}from"react";function py(e,t,n,r){const o=new Map;n.forEach((e,t)=>{o.set(r?r(e,t):t+"",e)});const i=[];t.forEach((e,t)=>{o.has(t)||i.push(t)}),i.length>0&&e.remove?.(i);const s=[];if(o.forEach((n,r)=>{const o=t.get(r);void 0===o?s.push(n):o!==n&&(e.update?e.update(r,()=>n):(e.remove?.(r),s.push(n)))}),s.length>0)if(e.pushMany)e.pushMany(s);else if(e.push)for(const t of s)e.push(t);return o}function gy(e,t,n={}){const{id:r,resetKey:o}=n,i=fy(()=>function(e){return null==e?null:"function"==typeof e?(t,n)=>{const r=e(t,n);return null==r?n+"":r+""}:(t,n)=>{const r=t[e];return null==r?n+"":r+""}}(r),[r]),s=yy({map:new Map,handle:null,resetKey:void 0});dy(()=>{const n=e.current;if(!n)return;const r=s.current;r.handle===n&&r.resetKey===o||(n.clear?.(),r.map=new Map,r.handle=n,r.resetKey=o),r.map=py(n,r.map,t,i)},[e,t,i,o])}export{Ce as DEFAULT_LIFECYCLE_THRESHOLDS,G as IncrementalExtent,oy as RealtimeHeatmap,Of as RealtimeHistogram,Df as RealtimeLineChart,Gf as RealtimeSwarmChart,Zf as RealtimeWaterfallChart,Rd as ReorderBuffer,X as RingBuffer,Ad as RunningStats,wd as StreamNetworkFrame,nl as StreamXYFrame,Ff as TemporalHistogram,Sd as WindowAccumulator,Md as bandBounds,Pe as bandFromAge,Re as compileMotionEncoding,Le as deriveMotionVector,De as opacityFromAge,Td as parseWindowDuration,Te as resolveMotionAccessor,Ne as resolveMotionVector,_d as statValue,py as syncPushBuffer,hy as useStreamStatus,gy as useSyncedPushData};
|