semiotic 3.3.1 → 3.4.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 +25 -6
- package/README.md +1 -1
- package/ai/dist/mcp-server.js +104 -9
- package/ai/schema.json +42 -1
- package/ai/system-prompt.md +4 -0
- package/dist/components/Annotation.d.ts +42 -2
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartGrid.d.ts +1 -1
- package/dist/components/ContextLayout.d.ts +1 -1
- package/dist/components/DataSummaryContext.d.ts +1 -1
- package/dist/components/DetailsPanel.d.ts +3 -2
- package/dist/components/Legend.d.ts +2 -3
- package/dist/components/LinkedCharts.d.ts +9 -1
- package/dist/components/ThemeProvider.d.ts +1 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +4 -4
- package/dist/components/charts/geo/DistanceCartogram.d.ts +5 -4
- package/dist/components/charts/geo/FlowMap.d.ts +4 -4
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +4 -3
- package/dist/components/charts/index.d.ts +3 -1
- package/dist/components/charts/network/ChordDiagram.d.ts +4 -3
- package/dist/components/charts/network/CirclePack.d.ts +3 -3
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +3 -2
- package/dist/components/charts/network/OrbitDiagram.d.ts +6 -5
- package/dist/components/charts/network/SankeyDiagram.d.ts +4 -3
- package/dist/components/charts/network/TreeDiagram.d.ts +3 -3
- package/dist/components/charts/network/Treemap.d.ts +3 -3
- package/dist/components/charts/ordinal/BarChart.d.ts +30 -4
- package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/DonutChart.d.ts +4 -3
- package/dist/components/charts/ordinal/DotPlot.d.ts +13 -4
- package/dist/components/charts/ordinal/FunnelChart.d.ts +4 -3
- package/dist/components/charts/ordinal/GaugeChart.d.ts +2 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +6 -5
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -3
- package/dist/components/charts/ordinal/LikertChart.d.ts +8 -4
- package/dist/components/charts/ordinal/PieChart.d.ts +4 -3
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +4 -3
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +6 -5
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -3
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +4 -3
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -6
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -6
- package/dist/components/charts/shared/ChartError.d.ts +1 -2
- package/dist/components/charts/shared/annotationResolvers.d.ts +4 -3
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/colorUtils.d.ts +4 -3
- package/dist/components/charts/shared/datumTypes.d.ts +20 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +2 -7
- package/dist/components/charts/shared/formatUtils.d.ts +4 -2
- package/dist/components/charts/shared/hooks.d.ts +41 -24
- package/dist/components/charts/shared/legendUtils.d.ts +3 -2
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +43 -0
- package/dist/components/charts/shared/networkUtils.d.ts +7 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +14 -11
- package/dist/components/charts/shared/statisticalOverlays.d.ts +14 -26
- package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +2 -2
- package/dist/components/charts/shared/statsTooltip.d.ts +3 -2
- package/dist/components/charts/shared/tooltipUtils.d.ts +20 -7
- package/dist/components/charts/shared/types.d.ts +27 -19
- package/dist/components/charts/shared/useChartSetup.d.ts +15 -6
- package/dist/components/charts/shared/useLikertAggregation.d.ts +18 -7
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +3 -2
- package/dist/components/charts/shared/useResolvedSelection.d.ts +2 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -1
- package/dist/components/charts/shared/validateChartData.d.ts +2 -1
- package/dist/components/charts/shared/validateProps.d.ts +2 -8
- package/dist/components/charts/shared/withChartWrapper.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +4 -3
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -3
- package/dist/components/charts/xy/CandlestickChart.d.ts +47 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -3
- package/dist/components/charts/xy/Heatmap.d.ts +12 -7
- package/dist/components/charts/xy/LineChart.d.ts +4 -3
- package/dist/components/charts/xy/MinimapChart.d.ts +4 -4
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +5 -4
- package/dist/components/charts/xy/QuadrantChart.d.ts +4 -3
- package/dist/components/charts/xy/Scatterplot.d.ts +4 -3
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +3 -3
- package/dist/components/charts/xy/StackedAreaChart.d.ts +4 -3
- package/dist/components/data/transforms.d.ts +8 -7
- package/dist/components/export/chartConfig.d.ts +4 -3
- package/dist/components/geo/mergeData.d.ts +2 -1
- package/dist/components/realtime/BinAccumulator.d.ts +3 -2
- package/dist/components/realtime/renderers/types.d.ts +2 -1
- package/dist/components/realtime/renderers/waterfallRenderer.d.ts +2 -1
- package/dist/components/realtime/types.d.ts +32 -16
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +7 -0
- package/dist/components/semiotic-ordinal.d.ts +8 -0
- package/dist/components/semiotic-themes.d.ts +2 -1
- package/dist/components/semiotic-xy.d.ts +11 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/animatedGif.d.ts +4 -18
- package/dist/components/server/renderToStaticSVG.d.ts +6 -5
- package/dist/components/server/serverChartConfigs.d.ts +2 -10
- package/dist/components/server/staticAnnotations.d.ts +2 -1
- package/dist/components/server/staticLegend.d.ts +2 -1
- package/dist/components/store/ObservationStore.d.ts +4 -3
- package/dist/components/store/SelectionStore.d.ts +3 -8
- package/dist/components/store/ThemeStore.d.ts +34 -4
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/useSelection.d.ts +6 -5
- package/dist/components/stream/AccessibleDataTable.d.ts +5 -5
- package/dist/components/stream/CanvasHitTester.d.ts +10 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +19 -1
- package/dist/components/stream/FocusRing.d.ts +1 -2
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoParticlePool.d.ts +2 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +26 -7
- package/dist/components/stream/MarginalGraphics.d.ts +1 -2
- package/dist/components/stream/NetworkPipelineStore.d.ts +8 -2
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -4
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -19
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +3 -1
- package/dist/components/stream/OrdinalPipelineStore.d.ts +44 -6
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -5
- package/dist/components/stream/ParticlePool.d.ts +4 -0
- package/dist/components/stream/PipelineStore.d.ts +80 -30
- package/dist/components/stream/SVGOverlay.d.ts +10 -10
- package/dist/components/stream/SceneGraph.d.ts +6 -5
- package/dist/components/stream/StreamGeoFrame.d.ts +2 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +2 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +2 -1
- package/dist/components/stream/StreamXYFrame.d.ts +19 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +1 -21
- package/dist/components/stream/devDataAccessWarning.d.ts +2 -11
- package/dist/components/stream/geoTypes.d.ts +32 -18
- package/dist/components/stream/hoverUtils.d.ts +14 -1
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +4 -3
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +4 -3
- package/dist/components/stream/networkTypes.d.ts +51 -28
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/barScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/connectorScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/statisticalScene.d.ts +4 -4
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/timelineScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +9 -8
- package/dist/components/stream/ordinalTypes.d.ts +102 -29
- package/dist/components/stream/pipelineDecay.d.ts +2 -1
- package/dist/components/stream/pipelinePulse.d.ts +2 -1
- package/dist/components/stream/pipelineTransitionUtils.d.ts +21 -0
- package/dist/components/stream/pipelineTransitions.d.ts +16 -4
- package/dist/components/stream/quadtreeHitTest.d.ts +22 -0
- package/dist/components/stream/renderers/colorUtils.d.ts +20 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +23 -6
- package/dist/components/stream/types.d.ts +63 -8
- package/dist/components/stream/useFrame.d.ts +122 -0
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/types.d.ts +35 -26
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -1
- package/dist/components/types/marginType.d.ts +15 -0
- 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/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +7 -0
- package/dist/semiotic-ordinal.d.ts +8 -0
- package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.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-xy.d.ts +11 -0
- package/dist/semiotic.d.ts +3 -3
- 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/canvasMock.d.ts +35 -1
- package/dist/test-utils/ordinalFixtures.d.ts +48 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +50 -42
- package/dist/components/types/annotationTypes.d.ts +0 -145
- package/dist/components/types/generalTypes.d.ts +0 -241
- package/dist/components/types/interactionTypes.d.ts +0 -72
- package/dist/components/types/networkTypes.d.ts +0 -174
- package/dist/components/types/ordinalTypes.d.ts +0 -112
- package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +0 -1
package/dist/xy.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-scale-chromatic"),s=require("d3-array"),a=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression");function u(e){return e&&e.__esModule?e:{default:e}}function d(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const h=d(e),g=u(c);function f(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function p(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function y({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u,binSize:d,snap:g,binBoundaries:y,snapDuring:m,streaming:v}){const b=e.useRef(null),x=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const A=e.useMemo(()=>y?[...y].sort((e,t)=>e-t):void 0,[y]),O=e.useRef(A);O.current=A;const S=e.useRef(!1),j=e.useRef(null);return e.useEffect(()=>{if(!b.current)return;const e=t.select(b.current).select(".brush-g"),i="x"===l?n.brushX():"y"===l?n.brushY():n.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",t=>{if(S.current)return;const n=w.current;if(!n)return;if(!t.selection)return j.current=null,void k.current(null);let s,a;if("x"===l){const[e,o]=t.selection;s=[n.x.invert(e),n.x.invert(o)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===l){const[e,r]=t.selection;s=[n.x.invert(0),n.x.invert(o)],a=[n.y.invert(r),n.y.invert(e)]}else{const[[e,o],[r,i]]=t.selection;s=[n.x.invert(e),n.x.invert(r)],a=[n.y.invert(i),n.y.invert(o)]}if("bin"===g&&"y"!==l&&("end"===t.type||"brush"===t.type&&m)){const o=O.current;o&&o.length>0?s=function(e,t){return 0===t.length?e:[f(e[0],t),p(e[1],t)]}(s,o):d&&d>0&&(s=[Math.floor(s[0]/d)*d,Math.ceil(s[1]/d)*d]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===l)e.call(i.move,[r,a]);else if("xy"===l){const n=t.selection;e.call(i.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const c={x:s,y:a};j.current=c,k.current(c)}),e.call(i),x.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),x.current=null}},[o,r,l,g,d,m]),e.useEffect(()=>{if(!(v&&c&&x.current&&j.current))return;if(!b.current)return;if("y"===l)return;const e=j.current,n=c.x.domain()[0],o=t.select(b.current).select(".brush-g");if(n>=e.x[1])return S.current=!0,o.call(x.current.move,null),S.current=!1,j.current=null,void k.current(null);let r=e.x[0],i=!1;if(n>e.x[0]){if(r=n,"bin"===g){const e=O.current;e&&e.length>0?r=p(n,e):d&&d>0&&(r=Math.ceil(n/d)*d)}if(r>=e.x[1])return S.current=!0,o.call(x.current.move,null),S.current=!1,j.current=null,void k.current(null);i=!0}const s=c.x(r),a=c.x(e.x[1]);if(S.current=!0,"x"===l)o.call(x.current.move,[s,a]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);o.call(x.current.move,[[s,t],[a,n]])}if(S.current=!1,i){const t={x:[r,e.x[1]],y:e.y};j.current=t,k.current(t)}},[c,v,l,g,d]),h.createElement("svg",{ref:b,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class m{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o: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(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;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class v{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;const t=this;return{next:()=>t._size>e?{done:!1,value:t.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(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),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}}class b{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(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.isNaN(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 x(e,t,n,o,r){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 l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=a,r){const e=r(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function k(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function w(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function A(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function O(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const S={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},j=i.schemeCategory10,M=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],C=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function E(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||C.has(t)}(o)?n(o):o}const o=null==e?void 0:e[t];return n?n(o):j[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%j.length]}function _(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const s=S[n]||S.category10;if(i&&"function"==typeof s){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:j;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function P(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):null==e?void 0:e[t],!o)return r;const[i,s]=o,[a,l]=n;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}function B(e,t,n){var o,r,i;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:s;default:return 1}}function L(e,t,n){var o;const r=null!==(o=e.duration)&&void 0!==o?o:500,i=n-t;return r>i?1-i/r:0}function N(e,t,n){return e+(t-e)*n}function I(e,t,n){var o,r,i,s;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(s=null!==(r=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==s?s: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 T(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:r,datum:c,group:i}}function H(e,t,n,o,r,i,s,a){const l=[];for(const i of e){const e=n(i),s=o(i);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(i):r;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:s}}function F(e,t,n,o,r,i,s){const a=n(e),l=o(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:r,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function z(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function R(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function $(e,t,n){if(!e.getBounds||!e.scales)return null;const o=[],r=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const s=e.getBounds(n),a=e.scales.x(t);if(s&&0!==s)o.push([a,e.scales.y(i+s)]),r.push([a,e.scales.y(i-s)]);else{const t=e.scales.y(i);o.push([a,t]),r.push([a,t])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function D(e,t,n,o){var r;if(!e.config.pointStyle)return;const i=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const s of o.data){let o=e.config.pointStyle(s);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const a=null!==(r=o.r)&&void 0!==r?r:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=F(s,e.scales,e.getX,i,a,o,l);c&&n.push(c)}}}const W={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},G=new Map;class Y{constructor(e){if(this.xExtent=new b,this.yExtent=new b,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=e,this.buffer=new v(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=w(e.timeAccessor||e.xAccessor,"time"),this.getY=w(e.valueAccessor||e.yAccessor,"value")):(this.getX=w(e.xAccessor,"x"),this.getY=w(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?w(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?w(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?w(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?w(e.openAccessor,"open"):void 0,this.getHigh=w(e.highAccessor,"high"),this.getLow=w(e.lowAccessor,"low"),this.getClose=n?w(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new v(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?w(this.config.timeAccessor||this.config.xAccessor,"time"):w(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,s,a,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(r=c.xExtent[1])&&void 0!==r?r:h[1]]:h,p=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:g[0],null!==(s=c.yExtent[1])&&void 0!==s?s:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);p=[0,o+(o>0?o*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,n,o,r){const i=x(e,t,n,o,r);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]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(u,this.getY),n=t-e,o=n>0?n*c.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],o=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=n?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(p).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:o.scaleLinear().domain(p).range([v,e.width-v]),y:o.scaleLinear().domain(f).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,f,[v,e.width-v]),y:t(c.yScaleType,p,[e.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>Y.QUADTREE_THRESHOLD?r.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}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 o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":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(),i=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,r,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:o,scales:r}=this;if(!r||0===t.length)return[];const s={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,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(o.chartType){case"line":return function(e,t){var n;const o=e.groupData(t),r=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of o){const n=$(e,t.data,t.key);n&&r.push(n)}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=T(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return D(e,o,r),r}(s,t);case"area":return function(e,t){const n=e.groupData(t),o=[],r=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=H(t.data,e.scales,e.getX,e.getY,r,n,t.key,i);e.config.gradientFill&&(s.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),o.push(s)}return D(e,n,o),o}(s,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set,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(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=H(t.data,e.scales,e.getX,e.getY,i,n,t.key,s);e.config.gradientFill&&(r.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=T(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return D(e,n,o),o}(s,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:r,stackedTops:i}=function(e,t,n,o,r,i,s){var a;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(t))||0;d.set(t,n||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[],l=new Map;for(const n of c){let r=e.get(n)||0;const s=f.get(n);i&&(r/=d.get(n));const c=s+r,u=t.x(n);a.push([u,t.y(s)]),o.push([u,t.y(c)]),f.set(n,c),l.set(n,c)}g.set(n.key,l);const p={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(p.curve=s),h.push(p)}return{nodes:h,stackedTops:g}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o),s=r;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=i.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};D(e,n,s,o)}return s}(s,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=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 o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null;for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(a=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t=Object.assign(Object.assign({},t),{fill:s.get(n)}))}const l=e.getPointId?e.getPointId(r)+"":void 0,c=F(r,e.scales,e.getX,e.getY,a,t,l);c&&n.push(c)}return n}(s,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,r,i;const s=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=e.config.heatmapYBins)&&void 0!==r?r:20)),l=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=w(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/s,p=(g-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],r=e.getX(o),i=e.getY(o);if(!isFinite(r)||!isFinite(i))continue;const l=Math.min(Math.floor((r-u)/f),s-1),d=Math.min(Math.floor((i-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;m[g]++;const y=c(o);v[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===m[e])continue;let t;switch(l){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,A=n.width/s,O=n.height/a,S=e.config.showValues,j=e.config.heatmapValueFormat,M=[];for(let e=0;a>e;e++){const t=e*s;for(let n=0;s>n;n++){const o=t+n;if(0===m[o])continue;let r;switch(l){case"sum":r=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const i=(r-b)/k;M.push(R(n*A,(a-1-e)*O,A,O,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:r,count:m[o],sum:v[o]},S?{value:r,showValues:!0,valueFormat:j}:void 0))}}return M}(e,t,n);if(0===t.length)return[];const o=w(e.config.valueAccessor,"value"),r=A(e.config.xAccessor,"x"),s=A(e.config.yAccessor,"y"),a=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),i=s(n);c[e]=o,u[e]=i,a.has(o)||a.set(o,a.size),l.has(i)||l.set(i,l.size)}const d=a.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(a.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],r=a.get(c[e]),i=l.get(u[e]);if(void 0===r||void 0===i)continue;const s=o(n),h=i*d+r,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),m[f]=h,v[f]=s,b[f]=n}let O=1/0,S=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(O>t&&(O=t),t>S&&(S=t))}if(!isFinite(O)||!isFinite(S))return[];const j=function(e){const t=e in W?e:"blues";let n=G.get(t);if(n)return n;n=Array(256);const o=W[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=o(e/255);return G.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),M=255/(S-O||1),C=n.width/d,E=n.height/h,_=e.config.showValues,P=e.config.heatmapValueFormat,B=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],o=n%d;B.push(R(o*C,(h-1-(n-o)/d)*E,C,E,j[Math.min((t-O)*M+.5|0,255)],b[e],_?{value:t,showValues:!0,valueFormat:P}:void 0))}return B}(s,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const o=x(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of o.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=n.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const i=[],s=e.scales,[a,l]=s.x.domain();for(const t of o.values()){const o=Math.max(t.start,a),c=Math.min(t.end,l);if(o>=c)continue;const u=s.x(o),d=s.x(c),h=Math.abs(d-u),g=h>2?1:0,f=Math.min(u,d)+g/2,p=Math.max(h-g,1);if(p>0)if(r&&t.categories.size>0){let o=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const l=s.y(o),c=s.y(o+r);i.push(z(f,Math.min(l,c),p,Math.abs(l-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),o+=r}}else{const e=s.y(0),n=s.y(t.total);i.push(z(f,Math.min(e,n),p,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of o.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(s,t);return this._barCategoryCache=null!==(n=s.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,o,r,i;const s=[],a=e.config.swarmStyle||{},l=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(o=a.fill)&&void 0!==o?o:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,d=a.stroke,h=a.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const r=e.scales.x(t),a=e.scales.y(o);let g=c;if(e.getCategory){const t=e.getCategory(n);g=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||g}const f={type:"point",x:r,y:a,r:l,style:{fill:g,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(f.pointId=e.getPointId(n)+""),s.push(f)}return s}(s,t);case"waterfall":return function(e,t,n){var o,r,i;const s=[],a=e.scales,l=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===c.length)return s;const u=null!==(o=null==l?void 0:l.positiveColor)&&void 0!==o?o:"#28a745",d=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,g=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let t=0;c.length>t;t++){const o=c[t],r=e.getX(o),i=e.getY(o),y=p+i;let m;m=c.length-1>t?e.getX(c[t+1])-r:t>0?r-e.getX(c[t-1]):0;const v=a.x(r),b=0!==m?a.x(r+m):v+n.width/10,x=Math.min(v,b)+h/2,k=Math.max(v,b)-h/2-x;if(0>=k){p=y;continue}const w=a.y(p),A=a.y(y);s.push(z(x,Math.min(w,A),k,Math.abs(w-A),{fill:0>i?d:u,stroke:g,strokeWidth:f},Object.assign(Object.assign({},o),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return s}(s,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const r=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(r||e.getOpen&&e.getClose))return[];const i=[],s=e.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=r?a:s.upColor||"#28a745",c=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",d=s.wickWidth||(r?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=r?0:null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(!r&&null==s.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else r||null!=s.bodyWidth||(g=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),s=e.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:e.getOpen(n),h=r?s:e.getClose(n);if(!r&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=a,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:n};r&&(p.isRange=!0),i.push(p)}return i}(s,t);default:return[]}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?B(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,r;const i=n.length;if(1>=i)return;const s=new Map;for(let e=0;n.length>e;e++)s.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let r=!1;for(let n=0;t.length>n;n++){const a=s.get(t[n]);null!=a?(o[n]=B(e,a,i),1>o[n]&&(r=!0)):o[n]=1}r&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const r=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=s.get(t[n]);null!=o?(r[n]=B(e,o,i),1>r[n]&&(a=!0)):r[n]=1}a&&(n._decayOpacities=r)}else{let r=1;for(const n of t){const t=s.get(n);if(null!=t){const n=B(e,t,i);r>n&&(r=n)}}if(1>r){const e=Array(o);e.fill(r),n._decayOpacities=e}}continue}const t=s.get(n.datum);if(null==t)continue;const a=B(e,t,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(r=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var r,i;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=e.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=o.get(t);if(null==i)continue;const a=L(e,i,s);a>r&&(r=a)}r>0&&(n._pulseIntensity=r,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const r=o.get(t);if(null==r)continue;const i=L(e,r,s);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&r>o-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var r,i,s;n.clear(),o.clear();for(let a=0;t.length>a;a++){const l=t[a],c=I(e,l,a);c&&("point"===l.type?n.set(c,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?n.set(c,{x:l.x,y:l.openY}):"line"===l.type?o.set(c,{path:l.path.map(e=>[e[0],e[1]]),opacity:null===(i=l.style)||void 0===i?void 0:i.opacity}):"area"===l.type&&o.set(c,{topPath:l.topPath.map(e=>[e[0],e[1]]),bottomPath:l.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r){var i,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,O,S,j,M,C,E,_,P,B;if(0===o.size&&0===r.size)return n;const L=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let N=!1;const T=new Set,H=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],A=I(e,i,t);if(!A)continue;if(i._transitionKey=A,"line"===i.type||"area"===i.type){const e=r.get(A);if(e){if(H.add(A),"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]];N=!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]];N=!0}i._targetOpacity=null!==(s=i.style.opacity)&&void 0!==s?s:1,i._startOpacity=null!==(l=null!==(a=e.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==l?l:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;continue}const O=o.get(A);if("point"===i.type)if(O){T.add(A);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,O.x===e.x&&O.y===e.y&&O.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=O.x,i.y=O.y,i.r=null!==(d=O.r)&&void 0!==d?d:i.r,N=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("rect"===i.type)if(O){T.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(g=i.style.opacity)&&void 0!==g?g:1,O.x===e.x&&O.y===e.y&&O.w===e.w&&O.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=O.x,i.y=O.y,i.w=null!==(f=O.w)&&void 0!==f?f:i.w,i.h=null!==(p=O.h)&&void 0!==p?p:i.h,N=!0)}else i._targetOpacity=null!==(y=i.style.opacity)&&void 0!==y?y:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("heatcell"===i.type)if(O){T.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,O.x===e.x&&O.y===e.y&&O.w===e.w&&O.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=O.x,i.y=O.y,i.w=null!==(b=O.w)&&void 0!==b?b:i.w,i.h=null!==(x=O.h)&&void 0!==x?x:i.h,N=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),N=!0}for(const[e,t]of r)if(!H.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),N=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={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:null!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),N=!0}for(const[e,t]of o)if(!T.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(S=t.r)&&void 0!==S?S:3,style:{opacity:null!==(j=t.opacity)&&void 0!==j?j:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(M=t.w)&&void 0!==M?M:0,h:null!==(C=t.h)&&void 0!==C?C:0,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(_=t.w)&&void 0!==_?_:0,h:null!==(P=t.h)&&void 0!==P?P:0,fill:"#999",datum:null,style:{opacity:null!==(B=t.opacity)&&void 0!==B?B:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}N=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),N&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:L}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var r,i,s,a,l;if(!n.activeTransition)return!1;const c=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,n.activeTransition),u=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(c,"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?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=N(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=N(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=N(r,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:N(r,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(a=e._startOpacity)&&void 0!==a?a:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=N(t[o][0],n[o][0],u),e.path[o][1]=N(t[o][1],n[o][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=N(t[n][0],o[n][0],u),e.topPath[n][1]=N(t[n][1],o[n][1],u);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=N(n[t][0],r[t][0],u),e.bottomPath[t][1]=N(n[t][1],r[t][1],u)}}if(c>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style: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("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("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}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}}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}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:M,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(e)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:M,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}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=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,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.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,o,r;const i=Object.assign({},this.config);void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null);let s=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==i.chartType||"runtimeMode"in e&&e.runtimeMode!==i.runtimeMode;if(a||void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor){const l=a||!k(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!k(null!==(o=e.yAccessor)&&void 0!==o?o:e.valueAccessor,null!==(r=i.yAccessor)&&void 0!==r?r:i.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=w(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=w(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=w(this.config.xAccessor,"x"),this.getY=w(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!k(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?O(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!k(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?O(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!k(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?w(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!k(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?O(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!k(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?w(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!k(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?O(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!k(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!k(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!k(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!k(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?w(this.config.openAccessor,"open"):void 0,this.getHigh=w(this.config.highAccessor,"high"),this.getLow=w(this.config.lowAccessor,"low"),this.getClose=t?w(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0}if(!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==i[n]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function q(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 X(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function V(e,t){const n=X(e);if(!n)return!1;const o=X(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function U(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=K(e,t,n,o);r&&o>r.distance&&(i=r,s=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(r&&s)break;e=K(a,t,n,o);break;case"line":e=J(a,t,n,o);break;case"rect":e=ee(a,t,n);break;case"heatcell":e=te(a,t,n);break;case"area":if(!1===a.interactive)break;e=oe(a,t,n);break;case"candlestick":e=ne(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function Q(e,t,n){if(0===e.length)return null;const o=re(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[s,a]=e[r],[l,c]=e[i];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function K(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i),a=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,o);return s>a?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function J(e,t,n,o=30){var r,i,s,a;if(0===e.path.length)return null;const l=re(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let o=1/0;const r=Math.max(0,l-1),i=Math.min(e.path.length-2,l);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=Z(t,n,r,i,a,l);o>c&&(o=c)}d=o}else{const e=t-c,o=n-u;d=Math.sqrt(e*e+o*o)}const h=null!==(a=null!==(i=null===(r=e.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==i?i:null===(s=e.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function Z(e,t,n,o,r,i){const s=r-n,a=i-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function ee(e,t,n){const o=q(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function te(e,t,n){const o=q(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ne(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function oe(e,t,n){if(0===e.topPath.length)return null;const o=re(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function re(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function ie(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function se(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}Y.QUADTREE_THRESHOLD=500;const ae={fill:e=>h.createElement("rect",{style:e,width:16,height:16}),line:e=>h.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function le(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ae[n])(o(e,t)),r}function ce(){return h.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ue(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function de({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+h.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(h.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return h.createElement("g",{"aria-label":i||"Gradient legend"},h.createElement("defs",null,h.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&h.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),h.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),h.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),h.createElement("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(h.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return h.createElement("g",{"aria-label":i||"Gradient legend"},i&&h.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),h.createElement("defs",null,h.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),h.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),h.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),h.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function he(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[d,g]=h.useState(0),[f,p]=h.useState(0),y=h.useCallback((e,t)=>{g(e),p(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,g)=>{u+=5,d.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(h.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(h.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:d,items:g}=e,f=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=le(e,c,u,d),b=ue(e,o,r),x=r&&r.size>0&&r.has(e.label);f.push(h.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?a===i&&c===s?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&h.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&h.createElement(ce,null),h.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),p+=22}),f})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:y,legendInteraction:s}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const g=[];e.forEach((e,t)=>{let f=0;e.label&&(f+=16);const p=((e,t,n,o,r,i,s,a,l,c,u)=>{const{type:d="fill",styleFn:g,items:f}=e,p=[];let y=0,m=0;const v=!(!t&&!n),b="isolate"===c||void 0===c&&null!=r;f.forEach((e,c)=>{const x=le(e,c,d,g),k=ue(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;u&&u>0&&y>0&&y+A>u&&(m++,y=0),p.push(h.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?a===i&&c===s?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?w||!1:void 0,"aria-current":v&&!b&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:v?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&h.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&h.createElement(ce,null),h.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),y+=A});let x=0,k=0;for(const e of f){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:p,offset:x,totalRows:w,totalHeight:22*w}})(e,o,r,i,s,a,l,t,c,u,n);f+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:f,totalRows:p.totalRows,totalHeight:p.totalHeight})),d+=f+12});let f=d>n?0:Math.max(0,(n-d)/2);const p=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(p.push(h.createElement("text",{key:"legend-text-"+o,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),p.push(h.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,e[o+1]&&p.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8})),f+=12}),h.createElement("g",null,p)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:y,legendInteraction:s}),v=!(!n&&!o);return h.createElement("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)"}},void 0!==a&&""!==a&&"vertical"===u&&h.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function ge(e){return"string"==typeof e?{type:e}:e}function fe({orient:t,config:n,values:o,scale:r,size:i,length:a}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),n=i-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(o);if(!e)return null;const{q1:i,median:s,q3:a,whiskerLow:u,whiskerHigh:d}=e,g=Math.min(.5*n,20),f=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),p=r(d),y="top"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:c,y1:m+y*(f+g/2),x2:p,y2:m+y*(f+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:c,y1:m+y*f,x2:c,y2:m+y*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:p,y1:m+y*f,x2:p,y2:m+y*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-f-g:m+f,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:o,y1:"top"===t?m-f-g:m+f,x2:o,y2:"top"===t?m-f:m+f+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),p=r(d),y="left"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:m+y*(f+g/2),y1:c,x2:m+y*(f+g/2),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*f,y1:c,x2:m+y*(f+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+y*f,y1:p,x2:m+y*(f+g),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:"left"===t?m-f-g:m+f,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:"left"===t?m-f-g:m+f,y1:o,x2:"left"===t?m-f:m+f+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=s.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return h.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return h.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(s,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),s=r(e.x1)-r(e.x0);return h.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+s),width:i,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const s=i.length/d*(n/2),a=r((i.x0+i.x1)/2);o.push(c?`${a},${"top"===t?-(e-s):e-s}`:`${"left"===t?-(e-s):e-s},${a}`)}for(let i=u.length-1;i>=0;i--){const s=u[i];if(null==s.x0||null==s.x1)continue;const a=s.length/d*(n/2),l=r((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${l}`)}return h.createElement("g",{"data-testid":"marginal-violin-"+t},h.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,s=r((o.x0+o.x1)/2);e.push(`L${s},${"top"===t?-i-4:i+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${s},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,s=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${o},${s}`),e.push("Z")}return h.createElement("g",{"data-testid":"marginal-ridgeline-"+t},h.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,a,t,c,4]);return u?h.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function ye(e,t,n,o){return"curly"===e?o?`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`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function me(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:d,className:g,disable:f,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(f)?f:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=s&&(b=s-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return h.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!m.has("connector")&&function(e,t,n,o,r,i){const s=[];let a=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,s=e-r,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;a=r+s*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);a=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-l,2))>.5&&(s.push(h.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:o||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-a);s.push(h.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${a+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return h.createElement("g",{className:"annotation-connector"},s)}(v,b,l,d,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const s=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&s.push(h.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&s.push(h.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==t?void 0:t.custom)&&s.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;s.push(h.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;s.push(h.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(h.createElement("line",{key:"threshold-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"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(h.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&s.push(h.createElement("path",{key:"bracket-path",d:ye((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}}return h.createElement("g",{className:"annotation-subject"},s)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return h.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return h.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>t?"end":"start";const f=16,p=i?c?[i]:pe(i,l):[],y=r?c?[r]:pe(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[],x=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(h.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold"},p.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e)))),v=p.length*f),y.length>0&&b.push(h.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:g,y:v},y.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e))));let k=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),k=h.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=h.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let A=0;return"topBottom"===u?A=0>n?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),h.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},h.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),k)}(a,v,b,d))}function ve(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),s=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),a=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:s});return h.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return h.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return h.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}function be(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function xe(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function ke(e,t,n){var o,r,i,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=be(e,n),c=xe(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function we(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const Ae={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};let Oe={positions:new Map};const Se=new Set;function je(){for(const e of Se)e()}function Me(e,t){const n=Oe.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Oe.positions);o.delete(e),Oe={positions:o},je()}function Ce(e,t){const n=Oe.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Oe.positions);o.delete(e),Oe={positions:o},je()}function Ee(){return Oe}function _e(e){return Se.add(e),()=>Se.delete(e)}const Pe={positions:new Map};function Be(){return()=>{}}function Le(){return Pe}function Ne(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ie(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function Te(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:d,yFormat:g}=t,f=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||d||He,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=a.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))),s=i.map(e=>e.valueOf()),l=i.map((e,t)=>({value:e,pixel:a.x(e),label:o(e,t,s)})),u=l.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 Fe(l,Math.max(55,u+8))},[a,c,d,n]),p=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||He,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return Fe(a.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)})),22)},[a,c,g,o]),y=u&&a,m=l&&a;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,O="var(--semiotic-border, #ccc)";return h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${s.left},${s.top})`},y&&(()=>{var e,t;const r=Ne(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Ne(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return h.createElement("g",{className:"stream-grid"},f.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),p.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),x&&!w&&h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:O,strokeWidth:1}),w&&h.createElement("path",{d:Ie("bottom",n,o),fill:"none",stroke:O,strokeWidth:1}),k&&!A&&h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:O,strokeWidth:1}),A&&h.createElement("path",{d:Ie("left",n,o),fill:"none",stroke:O,strokeWidth:1})))}function He(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Fe(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function ze(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:d,showAxes:f,axes:p,xLabel:y,yLabel:m,yLabelRight:v,xFormat:b,yFormat:x,showGrid:k,title:w,legend:A,legendHoverBehavior:O,legendClickBehavior:S,legendHighlightedCategory:j,legendIsolatedCategories:M,legendPosition:C="right",foregroundGraphics:E,marginalGraphics:_,xValues:P,yValues:B,annotations:L,svgAnnotationRules:N,xAccessor:I,yAccessor:T,annotationData:H,pointNodes:F,curve:z,underlayRendered:R,linkedCrosshairName:$,linkedCrosshairSourceId:D,children:W}=t,G=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||b||He,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=d.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),s=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:d.x(e),label:n(e,t,s)})),l=a.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),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let u=Fe(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=d.x.domain()[1],t=d.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,u.length,s);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[f,d,p,b,r]),Y=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||He,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=Fe(d.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=d.y.domain()[1],t=d.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[f,d,p,x,i]),q=e.useMemo(()=>{var e;if(!f||!d)return[];const t=null==p?void 0:p.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||He,o=null!==(e=t.ticks)&&void 0!==e?e:5;return Fe(d.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22)},[f,d,p,x,i]),X=e.useRef(new Map),U=e.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),Q=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;U.current!==Q&&(U.current=Q,X.current=new Map);const K=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,d,f,p,y,m,v,b,x,k,w,A,O,S,j,M,C,E,_,P,B,L,N,I,T,H,F,z,R,$,D,W,G,Y,q,X,V,U,Q,K,J,Z,ee;switch(e.type){case"label":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return we(r,i,n)?h.createElement(ve,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return we(r,i,n)?h.createElement(ve,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=be(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let s;return s="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:o+4,y:s,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=xe(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.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"),h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:s,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:be(Object.assign(Object.assign({},e),{type:"point"}),n),y:xe(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=a.packEnclose(o),i=e.padding||10;return h.createElement("g",{key:"ann-"+t},h.createElement("circle",{cx:r.x,cy:r.y,r:r.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&&h.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:be(Object.assign(Object.assign({},e),{type:"point"}),n),y:xe(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),s=o.map(e=>e.y),a=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...s)-r,u=Math.max(...s)+r;return h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:a,y:c,width:l-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&h.createElement("text",{x:(a+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return h.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=be(t,n),s=xe(t,n);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return h.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:a},l))}))}case"bracket":{const o=be(e,n),r=xe(e,n);return h.createElement(ve,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const l=n.xAccessor||"x",f=n.yAccessor||"y",p=a.map(e=>[e[l],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))a.push([t,h/u]);else{const e=(u*f-d*h)/p;a.push([t,(h-e*d)/u+e*t])}}return a}(p,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?g.default.polynomial(p,{order:e.order||2}):g.default.linear(p)).points;const x=b.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:y(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(p=null===(f=n.scales)||void 0===f?void 0:f.y)&&void 0!==p?p:null===(y=n.scales)||void 0===y?void 0:y.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,s=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(O=n.scales)||void 0===O?void 0:O.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const g=Ae[n.curve||"linear"]||l.curveLinear,f=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(d);if(!f)return null;const p=e.fill||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:f,fill:p,fillOpacity:null!==(S=e.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),e.label&&d.length>0&&h.createElement("text",{x:i(d[d.length-1][r])+4,y:s(d[d.length-1][a])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(M=null===(j=n.scales)||void 0===j?void 0:j.x)&&void 0!==M?M:null===(C=n.scales)||void 0===C?void 0:C.time,s=null!==(_=null===(E=n.scales)||void 0===E?void 0:E.y)&&void 0!==_?_:null===(P=n.scales)||void 0===P?void 0:P.value;if(!i||!s)return null;const a=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-l,2),0)/a.length,u=Math.sqrt(c),d=null!==(B=e.threshold)&&void 0!==B?B:2,g=l-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(L=e.fillOpacity)&&void 0!==L?L:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=s(l+d*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return h.createElement("g",{key:"ann-"+t},f&&h.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=be(e,n),r=xe(e,n);return null==o||null==r?null:h.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",s=null!==(T=null===(I=n.scales)||void 0===I?void 0:I.x)&&void 0!==T?T:null===(H=n.scales)||void 0===H?void 0:H.time,a=null!==(z=null===(F=n.scales)||void 0===F?void 0:F.y)&&void 0!==z?z:null===(R=n.scales)||void 0===R?void 0:R.value;if(!s||!a)return null;const l=o.map(e=>[e[r],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>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=g.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==($=e.confidence)&&void 0!==$?$:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D:5,x=l[u-1][0],k=(x-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=f*Math.sqrt(1+1/u+(y>0?Math.pow(e-p,2)/y:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const O=`M${A.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),j=`${s(x)},${a(c(x))}`,M=e.strokeColor||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:O,fill:e.fill||"#6366f1",fillOpacity:null!==(W=e.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),h.createElement("polyline",{points:`${j} ${S}`,fill:"none",stroke:M,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&h.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:M,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=ke(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!we(o,r,n))return null;const i=null!==(q=e.dx)&&void 0!==q?q:0,s=null!==(X=e.dy)&&void 0!==X?X:0,a=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(Q=e.content)&&void 0!==Q?Q:h.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return h.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},h.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ke(e,t,n);if(!o)return null;const{x:r,y:i}=o;return h.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(K=n.scales)||void 0===K?void 0:K.o,i=null===(J=n.scales)||void 0===J?void 0:J.x,s=null===(Z=n.scales)||void 0===Z?void 0:Z.y,a=(null==r?void 0:r.bandwidth)?r:(null==i?void 0:i.bandwidth)?i:(null==s?void 0:s.bandwidth)?s:null;if(!a)return null;const l=a(o);if(null==l)return null;const c=a.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,g=e.label;return(n.projection?"vertical"===n.projection:a===i)?h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:l,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),g&&h.createElement("text",{x:l+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},g)):h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:l,width:n.width||0,height:c,fill:u,fillOpacity:d}),g&&h.createElement("text",{x:12,y:l+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},g))}default:return null}},t={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:I,yAccessor:T,width:r,height:i,data:H,frameType:"xy",pointNodes:F,curve:z,stickyPositionCache:X.current};return L.map((n,o)=>{if(N){const r=N(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,N,r,i,I,T,H,d,F,z]),J=function(t){var n;const o=e.useSyncExternalStore(t?_e:Be,t?Ee:Le,t?Ee:Le);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}($);return e.useEffect(()=>{if(!(null==J?void 0:J.locked)||!$)return;const e=e=>{"Escape"===e.key&&Ce($)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==J?void 0:J.locked,$]),f||w||A||E||_||K&&K.length>0||k||W||J?h.createElement("svg",{role:"img",width:s,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},h.createElement("title",null,"string"==typeof w?w:"XY Chart"),h.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),h.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&d&&!R&&(()=>{var e,t;const n=Ne(null===(e=null==p?void 0:p.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),o=Ne(null===(t=null==p?void 0:p.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return h.createElement("g",{className:"stream-grid"},G.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),Y.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),f&&d&&(()=>{const e=null==p?void 0:p.find(e=>"left"===e.orient),t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=!t||!1!==t.baseline,s=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,l=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",f="var(--semiotic-text, #333)",b=!!(null==t?void 0:t.autoRotate)&&G.length>1&&(()=>{const e=r/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})();return h.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!R&&o&&!a&&h.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:d,strokeWidth:1}),!R&&a&&h.createElement("path",{d:Ie("bottom",r,i),fill:"none",stroke:d,strokeWidth:1}),G.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):V(e.value,t>0?G[t-1].value:void 0));return h.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},h.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0},e.label):h.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),y&&h.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},y),!R&&n&&!s&&h.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:d,strokeWidth:1}),!R&&s&&h.createElement("path",{d:Ie("left",r,i),fill:"none",stroke:d,strokeWidth:1}),Y.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):V(e.value,t>0?Y[t-1].value:void 0));return h.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"}},e.label):h.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||m;return t?h.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==p?void 0:p.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const t=e.landmarkTicks,n=e.label||v;return h.createElement(h.Fragment,null,!1!==e.baseline&&h.createElement("line",{x1:r,y1:0,x2:r,y2:i,stroke:d,strokeWidth:1}),q.map((e,n)=>{const o=!!t&&("function"==typeof t?t(e.value,n):V(e.value,n>0?q[n-1].value:void 0));return h.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${e.pixel})`},h.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?h.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:g,style:{userSelect:"none"}},e.label):h.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},h.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&h.createElement("text",{x:r+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(90, ${r+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),K,_&&d&&P&&B&&h.createElement(h.Fragment,null,_.top&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(fe,{orient:"top",config:ge(_.top),values:P,scale:d.x,size:u.top,length:r})),_.bottom&&h.createElement("g",{transform:`translate(0, ${i})`},h.createElement(fe,{orient:"bottom",config:ge(_.bottom),values:P,scale:d.x,size:u.bottom,length:r})),_.left&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(fe,{orient:"left",config:ge(_.left),values:B,scale:d.y,size:u.left,length:i})),_.right&&h.createElement("g",{transform:`translate(${r}, 0)`},h.createElement(fe,{orient:"right",config:ge(_.right),values:B,scale:d.y,size:u.right,length:i}))),E,J&&J.sourceId!==D&&(null==d?void 0:d.x)&&(()=>{const e=d.x(J.xValue);if(null==e||0>e||e>r)return null;const t=J.locked;return h.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),W),w&&h.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),function(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:s,legendHoverBehavior:a,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const g="top"===i||"bottom"===i;let f,p;return"left"===i?(f=4,p=r.top):"top"===i?(f=0,p=s?32:8):"bottom"===i?(f=0,p=o-r.bottom+50):(f=n-r.right+10,p=r.top),h.createElement("g",{transform:`translate(${f}, ${p})`},"object"==typeof(y=t)&&null!==y&&"gradient"in y?h.createElement(de,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?h.createElement(he,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t);var y}({legend:A,totalWidth:s,totalHeight:c,margin:u,legendPosition:C,title:w,legendHoverBehavior:O,legendClickBehavior:S,legendHighlightedCategory:j,legendIsolatedCategories:M})):null}function Re(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const $e="undefined"==typeof window||"undefined"==typeof document,De=h.createContext(null),We={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ge(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={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),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}const Ye=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},qe={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid 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-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Xe={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Ve={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Ue={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Qe={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Ke={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Je={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Ze({scene:e,chartType:t,tableId:n,chartTitle:o}){var r;const[i,s]=h.useState(!1),a=h.useContext(De),l=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,c=i||l,u=h.useRef(null),d=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t,g=h.useCallback(()=>{i||l||s(!0)},[i,l]),f=h.useCallback(e=>{var t;l||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||s(!1)},[l]);if(!e||0===e.length)return n?h.createElement("span",{id:n,tabIndex:-1,style:We}):null;if(!c)return h.createElement("div",{id:n,tabIndex:-1,onFocus:g,style:We,role:"region","aria-label":d},h.createElement("button",{type:"button",onClick:()=>s(!0)},"View data summary (",e.length," elements)"));const p=function(e){var t,n,o,r,i,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,O,S;const j=[];if(!Array.isArray(e))return j;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":j.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&j.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&j.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==n?n:"",s=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;j.push({label:"Bar",values:{category:i,value:null!=s?s:""}});break}case"heatcell":j.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":j.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(i=M.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:null===(a=M.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":j.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":j.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=M.cx)&&void 0!==m?m:M.x,y:null!==(v=M.cy)&&void 0!==v?v:M.y}});break;case"candlestick":j.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":j.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(S=null===(O=M.datum)||void 0===O?void 0:O.value)&&void 0!==S?S:""}})}}catch(e){}return j}(e),y=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 o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,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}: ${Ye(e.min)} to ${Ye(e.max)}, mean ${Ye(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(p.length,y),v=p.slice(0,5),b=new Set;for(const e of v)for(const t of Object.keys(e.values))b.add(t);const x=Array.from(b);return h.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:qe,role:"region","aria-label":d},h.createElement("button",{type:"button",onClick:()=>{l&&a&&a.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Ve},"×"),h.createElement("div",{role:"note",style:Xe},m),h.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:Ue},h.createElement("caption",{style:Je},"First ",v.length," of ",p.length," data points"),h.createElement("thead",null,h.createElement("tr",null,h.createElement("th",{style:Qe},"type"),x.map(e=>h.createElement("th",{key:e,style:Qe},e)))),h.createElement("tbody",null,v.map((e,t)=>h.createElement("tr",{key:t},h.createElement("td",{style:Ke},e.label),x.map(t=>{return h.createElement("td",{key:t,style:Ke},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ye(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function et({summary:e}){return e?h.createElement("div",{role:"note",style:We},e):null}function tt({tableId:e}){return h.createElement("a",{href:"#"+e,style:We,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,We)}},"Skip to data table")}function nt({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return h.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:We},t)}const ot="var(--semiotic-focus, #005fcc)";function rt({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:s}){if(!e||!t)return null;const a=t.x+n.left,l=t.y+n.top;let c;if("rect"===r&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);c=h.createElement("rect",{x:a-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ot,strokeWidth:2,strokeDasharray:"4,2"})}else c=h.createElement("circle","wedge"===r?{cx:a,cy:l,r:12,fill:"none",stroke:ot,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:l,r:8,fill:"none",stroke:ot,strokeWidth:2,strokeDasharray:"4,2"});return h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function it({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=h.useRef(null),[c,u]=h.useState(null);h.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,s,n,o]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`,h.createElement("div",{ref:l,className:s,style:{position:"absolute",left:r.left+e,top:r.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function st(t){const n=e.createContext(null),o=at(t);return[function({children:o}){const r=e.useMemo(()=>at(t),[]);return h.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,s=e.useRef(t);s.current=t;const a=e.useCallback(()=>s.current(i.getState()),[i]),l=e.useCallback(()=>s.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,l)}]}function at(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const lt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ct={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ut={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},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"},[dt,ht]=st(e=>({theme:lt,setTheme(t){e(e=>{if("light"===t)return{theme:lt};if("dark"===t)return{theme:ct};if("high-contrast"===t)return{theme:ut};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?ct:lt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}}));function gt(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}const ft=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,pt=new WeakMap;function yt(e,t){var n,o;if(!t)return t;const r=ft.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;let s=pt.get(i);if(s||(s=new Map,pt.set(i,s)),s.has(t))return s.get(t);const a=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return s.set(t,a),a}function mt(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function vt(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function bt(e,t,n,o,r,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],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;l>o&&(i*=o/l),l>a-o&&(i*=(a-o)/l),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()}}const xt=(e,t,n,o)=>{var r,i;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,d=a.colorThresholds,h=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const y=null!==(r=a.style.opacity)&&void 0!==r?r:1;bt(e,a.path,c,u,y,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=mt(a.curve),f=d&&d.length>0&&h&&h.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!f){e.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)e.globalAlpha=.5*(p[v]+p[v+1])*m,e.beginPath(),e.moveTo(a.path[v][0],a.path[v][1]),e.lineTo(a.path[v+1][0],a.path[v+1][1]),e.stroke()}else if(f){let b=null,x=null,k=null,w=null,A=!1;function O(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function S(){A&&(e.stroke(),A=!1)}for(let j=0;a.path.length>j;j++){const[M,C]=a.path[j],E=h[j],_=vt(E,d,c);if(null!==b&&null!==w&&null!==k){if(_===w)e.lineTo(M,C);else{const P=[];for(const B of d){const L=B.value;(k>L||L>E)&&(L>k||E>L)||k===L||E===L||P.push({t:(L-k)/(E-k)})}P.sort((e,t)=>e.t-t.t);for(const N of P){const I=b+(M-b)*N.t,T=x+(C-x)*N.t,H=vt(k+(E-k)*Math.min(N.t+1e-4,1),d,c);e.lineTo(I,T),S(),O(H,I,T)}e.lineTo(M,C)}b=M,x=C,k=E,w=_}else O(_,M,C),b=M,x=C,k=E,w=_}S()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=c;else{const F=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const z of a.strokeGradient.colorStops)F.addColorStop(Math.max(0,Math.min(1,z.offset)),z.color);e.strokeStyle=F}if(g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[R,$]=a.path[0];e.moveTo(R,$);for(let D=1;a.path.length>D;D++)e.lineTo(a.path[D][0],a.path[D][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?yt(e,a.style.fill):a.style.fill)||a.style.fill,g&&!f)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[G,Y]=a.path[0];e.moveTo(G,Y);for(let q=1;a.path.length>q;q++)e.lineTo(a.path[q][0],a.path[q][1])}const W=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(W,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function kt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function wt(e,t,n=.3){kt(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 At(e,t,n=.6){var o,r,i,s,a;if(!kt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,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 Ot(e,t,n,o=.35){kt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function St(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function jt(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function Mt(e,t){const n=St(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=l.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Ct=(e,t,n,o)=>{var r,i,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,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.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=yt(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*(o[n]+o[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=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Mt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=e.createLinearGradient(0,o,0,r);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=jt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=a}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Mt(e,t),Ot(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=a,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=St(t.curve);if(e.beginPath(),n)l.line().x(e=>e[0]).y(e=>e[1]).curve(n).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()}e.globalAlpha=1}},Et=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?yt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),At(e,t),e.globalAlpha=1}}finally{e.restore()}}},_t=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Pt(e,t);else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#007bff";const n=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:o,y:r,w:i,h:s}=t;switch(t.roundedEdge){case"right":e.moveTo(o,r),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+s-n),e.arcTo(o+i,r+s,o+i-n,r+s,n),e.lineTo(o,r+s);break;case"left":e.moveTo(o+i,r),e.lineTo(o+n,r),e.arcTo(o,r,o,r+n,n),e.lineTo(o,r+s-n),e.arcTo(o,r+s,o+n,r+s,n),e.lineTo(o+i,r+s);break;case"bottom":e.moveTo(o,r),e.lineTo(o+i,r),e.lineTo(o+i,r+s-n),e.arcTo(o+i,r+s,o+i-n,r+s,n),e.lineTo(o+n,r+s),e.arcTo(o,r+s,o,r+s-n,n);break;default:e.moveTo(o,r+s),e.lineTo(o,r+n),e.arcTo(o,r,o+n,r,n),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+s)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else e.fillStyle=("string"==typeof t.style.fill?yt(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=yt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h));wt(e,t),e.globalAlpha=1}};function Pt(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const 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=r+o,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function Bt(e,t,n,o){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:n,time:t,value:n}),o)}function Lt(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function Nt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const It=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Tt(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${It[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${It[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Ht={line:[Ct,xt,Et],area:[Ct,Et],stackedarea:[Ct,Et],scatter:[Et],bubble:[Et],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),wt(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):Nt(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Lt(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[_t],swarm:[Et],waterfall:[(e,t,n,o)=>{var r,i,s;_t(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const o=a[t],r=a[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(s=r.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=t._decayOpacity;if(null!=o&&1!==o&&(e.globalAlpha=o),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}e.restore()}}],mixed:[Ct,xt,Et]},Ft={top:20,right:20,bottom:30,left:40},zt={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"},Rt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function $t({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return h.createElement("div",{className:"semiotic-tooltip",style:Rt},h.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),h.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const Dt=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,d,g,f;const{chartType:p,runtimeMode:v,data:b,chunkThreshold:x,chunkSize:k,xAccessor:w,yAccessor:A,colorAccessor:O,sizeAccessor:S,groupAccessor:j,lineDataAccessor:M,curve:C,normalize:E,binSize:_,valueAccessor:P,arrowOfTime:B="right",windowMode:L="sliding",windowSize:N=200,timeAccessor:I,xExtent:T,yExtent:H,extentPadding:F=.1,scalePadding:z,sizeRange:R,size:$=[500,300],responsiveWidth:D,responsiveHeight:W,margin:G,className:q,background:X,lineStyle:V,pointStyle:K,areaStyle:J,waterfallStyle:Z,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:ae,y0Accessor:le,gradientFill:ce,lineGradient:ue,areaGroups:de,openAccessor:he,highAccessor:ge,lowAccessor:fe,closeAccessor:pe,candlestickStyle:ye,showAxes:me=!0,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:we,yFormat:Ae,tickFormatTime:Oe,tickFormatValue:Se,hoverAnnotation:je,tooltipContent:Me,customHoverBehavior:Ce,customClickBehavior:Ee,enableHover:_e,hoverRadius:Pe=30,tooltipMode:Be,annotations:Le,svgAnnotationRules:Ne,showGrid:Ie,legend:He,legendHoverBehavior:Fe,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,backgroundGraphics:Xe,foregroundGraphics:Ve,canvasPreRenderers:Ue,svgPreRenderers:Qe,title:Ke,categoryAccessor:Je,brush:ot,onBrush:st,decay:at,pulse:lt,transition:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:ft,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,marginalGraphics:bt,pointIdAccessor:xt,xScaleType:kt,yScaleType:wt,accessibleTable:At=!0,description:Ot,summary:St,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}=t,Ct=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),t}(),Et=e.useRef(Ct);Et.current=Ct;const[_t,Pt]=function(t,n,o){const r=e.useRef(null),[i,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}($,D,W),Lt=Object.assign(Object.assign({},Ft),G);if(bt){const e=60;bt.top&&e>Lt.top&&(Lt.top=e),bt.bottom&&e>Lt.bottom&&(Lt.bottom=e),bt.left&&e>Lt.left&&(Lt.left=e),bt.right&&e>Lt.right&&(Lt.right=e)}const Nt=Pt[0]-Lt.left-Lt.right,It=Pt[1]-Lt.top-Lt.bottom,Rt="function"==typeof Ve?Ve({size:Pt,margin:Lt}):Ve,Dt="function"==typeof Xe?Xe({size:Pt,margin:Lt}):Xe,Wt=null!=je?je:_e,Gt=e.useRef(null),Yt=e.useRef(null),qt=e.useRef(0),Xt=e.useRef(!1),Vt=ht(e=>e.theme),[Ut,Qt]=e.useState(0),[Kt,Jt]=e.useState(null),Zt=e.useRef(null),en=e.useRef(null),[tn,nn]=e.useState(null),[on,rn]=e.useState(!1),[sn,an]=e.useState([]),[ln,cn]=e.useState([]),un=e.useRef(()=>{}),dn="streaming"===v||["bar","swarm","waterfall"].includes(p),hn=e.useMemo(()=>({chartType:p,runtimeMode:dn?"streaming":"bounded",windowSize:N,windowMode:L,arrowOfTime:dn?B:"right",extentPadding:F,scalePadding:z,xAccessor:dn?void 0:w,yAccessor:dn?void 0:A,timeAccessor:dn?I:void 0,valueAccessor:P,colorAccessor:O,sizeAccessor:S,groupAccessor:j||(M?"_lineGroup":void 0),categoryAccessor:Je,lineDataAccessor:M,xScaleType:kt,yScaleType:wt,xExtent:T,yExtent:H,sizeRange:R,binSize:_,normalize:E,boundsAccessor:oe,boundsStyle:ae,y0Accessor:le,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:de?new Set(de):void 0,lineGradient:ue,openAccessor:he,highAccessor:ge,lowAccessor:fe,closeAccessor:pe,candlestickStyle:ye,lineStyle:V,pointStyle:K,areaStyle:J,swarmStyle:ee,waterfallStyle:Z,colorScheme:ne,barColors:te,annotations:Le,decay:at,pulse:lt,transition:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:ft,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,pointIdAccessor:xt,curve:C}),[p,N,L,B,F,z,w,A,I,P,kt,wt,O,S,j,Je,M,T,H,R,_,E,oe,ae,le,ce,ue,de,he,ge,fe,pe,ye,V,K,J,ee,Z,ne,te,Le,at,lt,ct,ut,dt,ft,yt,mt,vt,dn,xt,C]),gn=e.useRef(null);gn.current||(gn.current=new Y(hn));const fn=e.useCallback(()=>{qt.current||(qt.current=requestAnimationFrame(()=>un.current()))},[]);e.useEffect(()=>{var e;null===(e=gn.current)||void 0===e||e.updateConfig(hn),Xt.current=!0,fn()},[hn,fn]),e.useEffect(()=>{Gt.current&&pt.delete(Gt.current),Xt.current=!0,fn()},[Vt,fn]);const pn=e.useRef(null);pn.current||(pn.current=new m(e=>{const t=gn.current;t&&t.ingest(e)&&(Xt.current=!0,fn())},{chunkThreshold:x,chunkSize:k})),e.useEffect(()=>{var e;null===(e=pn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:x,chunkSize:k})},[x,k]);const yn=e.useCallback(e=>{var t;null===(t=pn.current)||void 0===t||t.push(e)},[]),mn=e.useCallback(e=>{var t;null===(t=pn.current)||void 0===t||t.pushMany(e)},[]),vn=e.useCallback(()=>{var e,t;null===(e=pn.current)||void 0===e||e.clear(),null===(t=gn.current)||void 0===t||t.clear(),Xt.current=!0,fn()},[fn]);e.useImperativeHandle(n,()=>({push:yn,pushMany:mn,remove:e=>{var t,n,o;null===(t=pn.current)||void 0===t||t.flush();const r=null!==(o=null===(n=gn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return r.length>0&&(Zt.current&&r.some(e=>{var t;return e===(null===(t=Zt.current)||void 0===t?void 0:t.data)})&&(Zt.current=null,nn(null)),Xt.current=!0,fn()),r},update:(e,t)=>{var n,o,r;null===(n=pn.current)||void 0===n||n.flush();const i=null!==(r=null===(o=gn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(Xt.current=!0,fn()),i},clear:vn,getData:()=>{var e,t,n;return null===(e=pn.current)||void 0===e||e.flush(),null!==(n=null===(t=gn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=gn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=gn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[yn,mn,vn,fn]),e.useEffect(()=>{var e,t;if(b){if(M&&b.length>0&&"object"==typeof b[0]&&null!==b[0]){const t="string"==typeof M?M:"coordinates";if(Array.isArray(b[0][t])){const n=[];for(const e of b){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=pn.current)||void 0===e||e.setBoundedData(n))}}null===(t=pn.current)||void 0===t||t.setBoundedData(b)}},[b,M]);const bn=e.useRef(()=>{}),xn=e.useRef(()=>{});bn.current=e=>{if(!Wt)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Lt.left,r=e.clientY-n.top-Lt.top;if(0>o||o>Nt||0>r||r>It)return void(Zt.current&&(Zt.current=null,en.current=null,nn(null),Ce&&(Ce(null),Xt.current=!0),fn()));const i=gn.current;if(!i||0===i.scene.length)return;const s=U(i.scene,o,r,Pe,i.quadtree);if(!s)return void(Zt.current&&(Zt.current=null,en.current=null,nn(null),Ce&&Ce(null),fn()));const a=Bt(s.datum||{},s.x,s.y);if("multi"===Be&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=Q(e.path,t,n);if(null===i)continue;const s=re(e.path,t);o.push({node:r,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"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Q(e.topPath,t,n);if(null===i)continue;const s=re(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.topPath[s][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,s.x,Pe),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const o=n?n(s.x):s.x;a.xValue=o,a.xPx=s.x,a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}Zt.current=a,en.current=s.node,nn(a),Ce&&(Ce(a),Xt.current=!0),fn()},xn.current=()=>{Zt.current&&(Zt.current=null,en.current=null,nn(null),Ce&&(Ce(null),Xt.current=!0),fn())},e.useCallback(e=>bn.current(e),[]);const kn=e.useCallback(()=>xn.current(),[]),wn=e.useRef(()=>{});wn.current=e=>{if(!Ee)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Lt.left,r=e.clientY-n.top-Lt.top;if(0>o||o>Nt||0>r||r>It)return void Ee(null);const i=gn.current;if(!i||0===i.scene.length)return void Ee(null);const s=U(i.scene,o,r,Pe,i.quadtree);Ee(s?Bt(s.datum||{},s.x,s.y):null)};const An=e.useCallback(e=>wn.current(e),[]),On=e.useRef(-1),Sn=e.useRef(null),jn=e.useRef(null),Mn=e.useCallback(e=>{const t=gn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(jn.current&&jn.current.version===n)o=jn.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const s of e)switch(s.type){case"point":i.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(t=s.group)&&void 0!==t?t:"_default"});break;case"line":{const e=s,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:o});break}case"area":{const e=s,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)i.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});break}case"rect":i.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(r=s.group)&&void 0!==r?r:"_default"});break;case"heatcell":i.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.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 r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&s.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:s}}(e),jn.current={version:n,graph:o}}const r=On.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),On.current=0;const t=o.flat[0];Sn.current={shape:t.shape,w:t.w,h:t.h};const n=se(t);return Zt.current=n,nn(n),Ce&&Ce(n),void fn()}const i=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}(o,r),s=function(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?ie(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?ie(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(e.key,i,o);if(null===s)return;if(e.preventDefault(),0>s)return On.current=-1,Sn.current=null,Zt.current=null,en.current=null,nn(null),Ce&&Ce(null),void fn();On.current=s;const a=o.flat[s];Sn.current={shape:a.shape,w:a.w,h:a.h};const l=se(a);Zt.current=l,nn(l),Ce&&Ce(l),fn()},[Ce,fn]),Cn=e.useCallback(e=>{On.current=-1,Sn.current=null,bn.current(e)},[]);un.current=()=>{var e,t;qt.current=0;const n=Gt.current,o=Yt.current;if(!n||!o)return;const r=gn.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(Et.current?i+1e6:i),a=!Et.current&&s,l=Xt.current||s;l&&!a&&r.computeScene({width:Nt,height:It});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return zt;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),s=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||s||n?{axisStroke:a||zt.axisStroke,tickText:i||zt.tickText,crosshair:i?i+"66":zt.crosshair,hoverFill:l?l+"4D":zt.hoverFill,hoverStroke:i?i+"99":zt.hoverStroke,pointRing:l||zt.pointRing}:zt}(n),d=null!==(e=null==ut?void 0:ut.threshold)&&void 0!==e?e:5e3,h=ut&&r.lastIngestTime>0&&i-r.lastIngestTime>d;if(l){const e=gt(n,Pt,Lt,c);if(e){e.clearRect(-Lt.left,-Lt.top,Pt[0],Pt[1]),h&&(e.globalAlpha=null!==(t=null==ut?void 0:ut.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=X||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-Lt.left,-Lt.top,Pt[0],Pt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Nt,It),e.clip()),Ue&&r.scales)for(const t of Ue)e.save(),t(e,r.scene,r.scales,{width:Nt,height:It}),e.restore();const s=Ht[p];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:Nt,height:It});e.restore(),h&&(e.globalAlpha=1)}}{const e=gt(o,Pt,Lt,c);if(e&&(e.clearRect(-Lt.left,-Lt.top,Pt[0],Pt[1]),Wt&&Zt.current&&r.scales&&function(e,t,n,o,r,i,s){var a,l;if(!1===r.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const h="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=h.stroke||s.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,o),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(l=e.canvas)||void 0===l?void 0:l.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const o=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,Zt.current,Nt,It,"object"==typeof Wt?Wt:{},en.current,u),en.current&&Array.isArray(je))){const t=je.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;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 o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,en.current,t)}}l&&n&&n.setAttribute("aria-label",Ge(r.scene,p+" chart"));const g=Xt.current;if(Xt.current=!1,g&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Kt||e(Kt.x.domain()[0])!==e(r.scales.x.domain()[0])||e(Kt.x.domain()[1])!==e(r.scales.x.domain()[1])||e(Kt.y.domain()[0])!==e(r.scales.y.domain()[0])||e(Kt.y.domain()[1])!==e(r.scales.y.domain()[1])||Kt.x.range()[0]!==r.scales.x.range()[0]||Kt.x.range()[1]!==r.scales.x.range()[1]||Kt.y.range()[0]!==r.scales.y.range()[0]||Kt.y.range()[1]!==r.scales.y.range()[1])&&Jt(r.scales),bt){const e=r.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof A?A:e=>e[A||"y"];an(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),cn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Le&&Le.length>0&&Qt(e=>e+1),(null==ut?void 0:ut.showBadge)&&rn(!!h),(a||r.hasActivePulses)&&(qt.current=requestAnimationFrame(()=>un.current()))},e.useEffect(()=>(fn(),()=>{qt.current&&(cancelAnimationFrame(qt.current),qt.current=0)}),[fn]),e.useEffect(()=>{Xt.current=!0,fn()},[p,Nt,It,me,X,V,Ue,fn]),function(t,n,o,r,i,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}(ut,gn,Xt,fn,on,rn);const En=e.useMemo(()=>{if(we||Oe)return;const e=gn.current;return(null==e?void 0:e.xIsDate)&&Kt?Tt(Kt.x.domain()):void 0},[we,Oe,Kt]),_n=we||Oe||En,Pn=Wt&&tn?Me?Me(tn):h.createElement($t,{hover:tn}):null,Bn=Pn?h.createElement(it,{x:tn.x,y:tn.y,containerWidth:Nt,containerHeight:It,margin:Lt,className:"stream-frame-tooltip"},Pn):null,Ln=Sn.current,Nn=h.createElement(rt,{active:On.current>=0,hoverPoint:tn,margin:Lt,size:Pt,shape:null==Ln?void 0:Ln.shape,width:null==Ln?void 0:Ln.w,height:null==Ln?void 0:Ln.h}),In=(e,t,n,o)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null},Tn=In(w,I,"__semiotic_resolvedX","__semiotic_resolvedTime"),Hn=In(A,P,"__semiotic_resolvedY","__semiotic_resolvedValue"),Fn=Tn.key,zn=Hn.key,Rn=Le&&Le.length>0,$n=e=>{if(!e||!Rn||!Tn.fn&&!Hn.fn)return e;let t=!1;const n=e.map(e=>{const n=Tn.fn&&Tn.key&&!(Tn.key in e),o=Hn.fn&&Hn.key&&!(Hn.key in e);if(!n&&!o)return e;t=!0;const r=Object.assign({},e);return n&&(r[Tn.key]=Tn.fn(e)),o&&(r[Hn.key]=Hn.fn(e)),r});return t?n:e};if($e){const e=gn.current;e&&b&&(e.ingest({inserts:b,bounded:!0}),e.computeScene({width:Nt,height:It}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i=_n||(()=>{if((null==e?void 0:e.xIsDate)&&n)return Tt(n.x.domain())})();return h.createElement("div",{className:"stream-xy-frame"+(q?" "+q:""),role:"img","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:Pt[0],height:Pt[1]}},h.createElement(et,{summary:St}),h.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Pt[0],height:Pt[1],style:{position:"absolute",left:0,top:0}},h.createElement("g",{transform:`translate(${Lt.left},${Lt.top})`},Dt),h.createElement("g",{transform:`translate(${Lt.left},${Lt.top})`},X&&h.createElement("rect",{x:0,y:0,width:Nt,height:It,fill:X}),Qe&&n&&Qe.map((e,o)=>h.createElement(h.Fragment,{key:"svgpre-"+o},e(t,n,{width:Nt,height:It}))),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return h.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),s=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return h.createElement("path",{key:"area-"+t,d:`M${i}L${s}Z`,fill:Re(r.style.fill),fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const n=e;return h.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:Re(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return h.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:Re(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}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),[o,r,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*o+.587*r+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return h.createElement("g",{key:"heatcell-"+t},h.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),h.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},e))}return h.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return h.createElement("g",{key:"candle-"+t},h.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),h.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),h.createElement(ze,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,scales:n,showAxes:me,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:i,yFormat:Ae||Se,showGrid:Ie,title:Ke,legend:He,legendHoverBehavior:Fe,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,foregroundGraphics:Rt,marginalGraphics:bt,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Ne,annotationFrame:0,xAccessor:Fn,yAccessor:zn,annotationData:$n(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof C?C:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}))}const Dn="semiotic-table-"+h.useId();return h.createElement("div",{ref:_t,className:"stream-xy-frame"+(q?" "+q:""),role:"group","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),tabIndex:0,style:{position:"relative",width:D?"100%":Pt[0],height:W?"100%":Pt[1],overflow:"visible"},onKeyDown:Mn},At&&h.createElement(tt,{tableId:Dn}),At&&h.createElement(Ze,{scene:null!==(s=null===(i=gn.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],chartType:p+" chart",tableId:Dn,chartTitle:"string"==typeof Ke?Ke:void 0}),h.createElement(et,{summary:St}),h.createElement("div",{role:"img","aria-label":Ot||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Wt?Cn:void 0,onMouseLeave:Wt?kn:void 0,onClick:Ee?An:void 0},Dt&&h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Pt[0],height:Pt[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${Lt.left},${Lt.top})`},Dt)),h.createElement(Te,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,scales:Kt,showAxes:me,axes:ve,showGrid:Ie,xFormat:_n,yFormat:Ae||Se}),h.createElement("canvas",{ref:Gt,"aria-label":Ge(null!==(l=null===(a=gn.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],p+" chart"),style:{position:"absolute",left:0,top:0}}),h.createElement("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),h.createElement(nt,{hoverPoint:tn}),h.createElement(ze,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,scales:Kt,showAxes:me,axes:ve,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:_n,yFormat:Ae||Se,showGrid:Ie,title:Ke,legend:He,legendHoverBehavior:Fe,legendClickBehavior:De,legendHighlightedCategory:We,legendIsolatedCategories:Ye,legendPosition:qe,foregroundGraphics:Rt,marginalGraphics:bt,xValues:sn,yValues:ln,annotations:Le,svgAnnotationRules:Ne,annotationFrame:Ut,xAccessor:Fn,yAccessor:zn,annotationData:$n(null===(c=gn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=gn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof C?C:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:Mt}),(ot||st)&&h.createElement(y,{width:Nt,height:It,totalWidth:Pt[0],totalHeight:Pt[1],margin:Lt,dimension:null!==(d=null==ot?void 0:ot.dimension)&&void 0!==d?d:"xy",scales:Kt,onBrush:null!=st?st:()=>{},binSize:_,snap:null==ot?void 0:ot.snap,binBoundaries:null!==(g=null==ot?void 0:ot.binBoundaries)&&void 0!==g?g:"bar"===p?null===(f=gn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==ot?void 0:ot.snapDuring,streaming:"streaming"===v}),(null==ut?void 0:ut.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ut.badgePosition?{top:4,left:4}:"bottom-left"===ut.badgePosition?{bottom:4,left:4}:"bottom-right"===ut.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:on?"#dc3545":"#28a745",color:"white"})},on?"STALE":"LIVE"),Nn,Bn))});Dt.displayName="StreamXYFrame";const Wt=e.createContext(null);function Gt(){return e.useContext(Wt)}function Yt(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function qt(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Xt,Vt]=st(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=qt(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=qt(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Ut,Qt]=st(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 Kt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Vt(e=>e.selections.get(r)),s=Vt(e=>e.setClause),a=Vt(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Yt(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:e.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}function Jt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=Kt({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:r,isActive:i}}function Zt(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=Kt({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[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&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,o,r,a,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:s,clear:l}}const en=e.createContext(!1);function tn({selections:t}){const n=Vt(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function nn({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const s=i.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=Jt({name:o,fields:[r]}),c=Kt({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[g,f]=e.useState(null),p=e.useRef(c.selectPoints);p.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?p.current({[r]:Array.from(u)}):y.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(f(e.label),l.onHover({[r]:e.label})):(f(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return h.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},h.createElement(he,{legendGroups:a,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:g,isolatedCategories:u}))}function on({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=Gt(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return h.createElement(Xt,null,h.createElement(Ut,null,t&&h.createElement(tn,{selections:t}),h.createElement(en.Provider,{value:l},l&&"top"===o&&a&&h.createElement(nn,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&h.createElement(nn,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function rn({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):M[i%M.length];return{label:r+"",color:a}}),label:""}]}}function sn(e){return e?"string"==typeof e?{name:e}:e:null}function an(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}h.createContext(void 0);const ln="#007bff";function cn(){var e;const t=ht(e=>e.theme),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function un(e){return"function"==typeof e?e:t=>t[e]}function dn(t,n,o){const r=Gt(),i=cn();return e.useMemo(()=>{var e;if(!n)return;const s=null!==(e=null!=o?o:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));if(r&&Object.keys(r).length>0){const t=_(e.map(e=>({_cat:e})),"_cat",s);return e=>r[e]||t(e)}return _(e.map(e=>({_cat:e})),"_cat",s)}if(r&&Object.keys(r).length>0){const e=_(t,n,s);return t=>r[t]||e(t)}return _(t,n,s)}if(r&&Object.keys(r).length>0){const e=_([{_:"a"}],"_",s);return t=>r[t]||e(t)}},[t,n,o,r,i])}function hn({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(n,o),g=Kt({name:(null==t?void 0:t.name)||"__unused__"}),f=Jt({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),p=Qt(e=>e.pushObservation),y=t?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=e.useState(null),b=u||o[0],x=e.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),k=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=Oe.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Oe={positions:new Map(Oe.positions).set(e,{xValue:t,sourceId:n})},je())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Me(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(i||p){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),p&&p(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,f,h,d,i,s,a,p,c,b]),w=e.useCallback(e=>{var t,n,o,r;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=Oe.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Oe.positions);return t.delete(e),Oe={positions:t},je(),!1}Oe={positions:new Map(Oe.positions).set(e,{xValue:t,sourceId:n,locked:!0})},je()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,s,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ce(e,d),Me(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function gn(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function fn({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(en),u=void 0!==r?r:!c&&!!n,d=e.useMemo(()=>{if(u&&n)return rn({data:t,colorBy:n,colorScale:o,getColor:E,categories:l})},[u,n,t,o,l]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);return d&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[a,s,d,i]);return{legend:d,margin:h,legendPosition:i}}function pn(t,n,o){const[r,i]=e.useState(null),[s,a]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,r,s]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const yn={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}}};function mn(e,t,n){var o,r,i,s,a,l,c;const u=yn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:vn(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function vn(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}const bn={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function xn(e,t){return"function"==typeof t?t(e):e[t]}function kn(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function wn(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=xn(e,n);s=kn(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=xn(e,r);a.push({label:n,value:kn(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=kn(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=kn(e[t[0]],o))}}const l=Object.assign(Object.assign({},bn),r);return h.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&h.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>h.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&h.createElement("span",null,e.label,": "),e.value)))}}function An(e){if(!0===e)return wn();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:h.createElement("div",{className:"semiotic-tooltip",style:bn},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?wn(e):wn())}function On(e){return"string"==typeof e?e:"value"}function Sn(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function jn(e,t){return"function"==typeof t?t(e):e[t]}function Mn(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?Sn(jn(o,t.accessor)):null;return h.createElement("div",{className:"semiotic-tooltip",style:bn},r&&h.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=Sn(jn(o,e.accessor));return h.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},h.createElement("span",{style:{opacity:.7}},e.label,": "),h.createElement("span",null,n))}))}}function Cn({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return h.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400}},h.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),h.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&h.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},n)))}class En extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:h.createElement(Cn,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function _n(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function Pn(e,t,n=3){let o,r=n+1;for(const n of t){const t=_n(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Bn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ln(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=Pn(e,t,3))&&void 0!==n?n:null)}function Nn({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Bn(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Ln(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const In={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},Tn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Hn={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Fn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],zn=["vertical","horizontal"],Rn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Fn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Tn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:zn},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:zn},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},In),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},In),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},In),Hn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},In),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},In),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:zn},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},In),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},In),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},In),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},In),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function $n(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Wn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Gn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Yn=new Set(["LineChart","AreaChart","StackedAreaChart"]),qn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Xn(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function Vn(e,t){const n=Xn(e),o=Xn(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const Un=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Qn(e,t){const n=[],o=function(e,t){const n=[],o=Rn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Rn).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!$n(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=Pn(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const s=Nn({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Bn(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Ln(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Rn[e]?(function(e,t,n){const o=Rn[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=Rn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Dn.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){Wn.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=Rn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Gn.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Yn.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(r=t.height)&&void 0!==r?r:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=Rn[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(i.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!qn.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Vn(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Vn(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of Un)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Kn;const Jn="undefined"!=typeof process&&"production"!==(null===(Kn=process.env)||void 0===Kn?void 0:Kn.NODE_ENV);function Zn({componentName:e,width:t,height:n,chartProps:o,children:r}){return h.createElement(En,{fallback:r=>{let i="";if(Jn&&o)try{const t=Qn(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return h.createElement(Cn,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const eo={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},to={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function no(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?h.createElement("div",{style:Object.assign(Object.assign({},eo),{width:t,height:n})},o||"No data available"):null}function oo(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(r+i)-i))/2);return h.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>h.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},to),{position:"absolute",top:s+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function ro(e,t,n,o){if(!Jn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function io(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const so="__forecastSegment";let ao=null;function lo(){return io(this,void 0,void 0,function*(){return ao||(ao=yield Promise.resolve().then(function(){return Ro})),ao})}const co=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:g="x",yAccessor:f="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:O=2,lineGradient:S,tooltip:j,pointIdAccessor:M,annotations:C,directLabel:_,gapStrategy:P="break",anomaly:B,forecast:L,frameProps:N={},selection:I,linkedHover:T,onObservation:H,onClick:F,hoverHighlight:z,hoverRadius:R,chartId:$,loading:D,emptyContent:W,legendInteraction:G,legendPosition:Y,xScaleType:q,yScaleType:X,color:V}=t,U=s.width,Q=s.height,K=s.enableHover,J=s.showGrid,Z=s.showLegend,ee=s.title,te=s.description,ne=s.summary,oe=s.accessibleTable,re=s.xLabel,ie=s.yLabel,se=oo(D,U,Q),ae=se?null:no(a,U,Q,W),le=a||[];ro("LineChart",le,"xAccessor",g),ro("LineChart",le,"yAccessor",f);const ce="string"==typeof g?g:"__semiotic_resolvedX",ue="string"==typeof f?f:"__semiotic_resolvedY",[de,he]=e.useState(null),[ge,fe]=e.useState([]),pe=e.useMemo(()=>{if(!L&&!B)return le;const e="function"==typeof g,t="function"==typeof f;return e||t?le.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=g(n)),t&&(o.__semiotic_resolvedY=f(n)),o}):le},[le,L,B,g,f]),ye=e.useRef(L),me=e.useRef(B);e.useEffect(()=>{if(!L&&!B)return void((ye.current||me.current)&&(he(null),fe([]),ye.current=L,me.current=B));let e=!1;const t=L!==ye.current||B!==me.current;if(ye.current=L,me.current=B,t&&(he(null),fe([])),L){const t=p&&"string"==typeof p&&"object"==typeof L?Object.assign(Object.assign({},L),{_groupBy:p}):L;(function(...e){return io(this,void 0,void 0,function*(){return(yield lo()).buildForecast(...e)})})(pe,ce,ue,t,B).then(t=>{e||(he(t),fe(t.annotations))}).catch(()=>{e||(he(null),fe([]))})}else B&&function(...e){return io(this,void 0,void 0,function*(){return(yield lo()).buildAnomalyAnnotations(...e)})}(B).then(t=>{e||(he(null),fe(t))}).catch(()=>{e||fe([])});return()=>{e=!0}},[pe,L,B,ce,ue]);const ve=de?de.processedData:le,be="__compoundGroup",xe=!(!L||!p),ke=xe?be:L?so:p,we=e.useMemo(()=>{if(!xe)return ve;const e="function"==typeof p?p:e=>e[p];return ve.map(t=>{const n=Object.assign({},t);return n[be]=`${e(t)}__${t[so]||"observed"}`,n})},[ve,xe,p]),Ae=xe?we:ve,Oe=e.useMemo(()=>{if(!L)return;const e=L.upperBounds,t=L.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let r=1/0,i=-1/0;const s=de?de.processedData:le;for(const e of s){const t="function"==typeof f?f(e):+e[f];if(isFinite(t)&&(r>t&&(r=t),t>i&&(i=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>i&&(i=t),r>t&&(r=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>i&&(i=t))}}return isFinite(r)&&isFinite(i)?[r,i]:void 0},[L,de,le,f]),{activeSelectionHook:Se,hoverSelectionHook:je,customHoverBehavior:Me,customClickBehavior:Ce,crosshairSourceId:Ee}=hn({selection:I,linkedHover:T,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:H,onClick:F,chartType:"LineChart",chartId:$,hoverHighlight:z,colorByField:"string"==typeof m?m:void 0}),_e=gn(T,Ee),Pe=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof f?f(e):e[f];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,f]),Be=void 0!==(null===(o=Ae[0])||void 0===o?void 0:o[y]),Le=e.useMemo(()=>{if(Be)return Ae;if(ke){const e=Ae.reduce((e,t)=>{const n="function"==typeof ke?ke(t):t[ke];if(!e[n]){const o={[y]:[]};"string"==typeof ke&&(o[ke]=n),xe&&(o[so]=t[so],"string"==typeof p&&(o[p]=t[p])),e[n]=o}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Ae}]},[Ae,ke,y,Be]),{gapProcessedLineData:Ne,hasGaps:Ie}=e.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const n of Le){const o=(n[y]||[]).filter(t=>!Pe(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const n of Le){const o=n[y]||[];let r=[],i=0;const s=ke&&"string"==typeof ke?n[ke]:void 0;for(const a of o)if(Pe(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]:r})),r=[],i++);else{const e=null!=s?`${s}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof f?f:"y",n=[];for(const o of Le){const r=o[y]||[],i=[];for(const n of r)Pe(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Le,hasGaps:!1}},[Le,P,y,Pe,ke,f]),Te=dn(ve,m,v),He=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ve){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ve,m]),Fe=pn(G,m,He),ze=e.useMemo(()=>je||(Fe.legendSelectionHook?Fe.legendSelectionHook:Se),[je,Fe.legendSelectionHook,Se]),Re=e.useMemo(()=>(e,t)=>{const n={strokeWidth:O},o=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return m?Te&&(n.stroke=E(e,m,Te),o&&(n.fill=n.stroke,n.fillOpacity=A)):(n.stroke=V||ln,o&&(n.fill=V||ln,n.fillOpacity=A)),n},[m,Te,O,w,A,V]),[$e,De]=e.useState(null);e.useEffect(()=>{if(!L)return void De(null);let e=!1;return function(...e){return io(this,void 0,void 0,function*(){return(yield lo()).createSegmentLineStyle(...e)})}(Re,L).then(t=>{e||De(()=>t)}).catch(()=>{e||De(null)}),()=>{e=!0}},[Re,L]);const We=$e||Re,Ge=e.useMemo(()=>an(We,ze,I),[We,ze,I]),Ye=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?Te&&(t.fill=E(e.parentLine||e,m,Te)):t.fill=V||ln,t}},[x,k,m,Te,V]),qe=Array.isArray(w)?"mixed":w?"area":"line",Xe="object"==typeof _?_:{},Ve=Xe.position||"end",Ue=Xe.fontSize||11,Qe=e.useMemo(()=>{var e,t;if(!_||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof f?f:e=>e[f],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of Ne){const o=n[y]||[];if(0===o.length)continue;const s="end"===Ve?o[o.length-1]:o[0],a=null!==(t=null!==(e=r(s))&&void 0!==e?e:r(n))&&void 0!==t?t:"";a&&!i.has(a+"")&&i.set(a+"",s)}const s=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:n(t),["string"==typeof f?f:"y"]:o(t),dx:"end"===Ve?6:-6,dy:0,color:Te?Te(e):ln,fontSize:Ue}));s.sort((e,t)=>{const n="string"==typeof f?f:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof f?f:"y",n=s[e-1],o=s[e];Ue+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ue+2)}return s},[_,m,Te,Ne,y,g,f,Ve,Ue]),Ke=(!_||void 0!==Z)&&Z,Je=e.useMemo(()=>{if(!_)return s.marginDefaults;const e=Qe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ue);return Math.max(e,o)},0),t=e+10,n="end"===Ve?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[_,Qe,Ue,Ve,s.marginDefaults]),{legend:Ze,margin:et,legendPosition:tt}=fn({data:Ne,colorBy:m,colorScale:Te,showLegend:Ke,legendPosition:Y,userMargin:l,defaults:Je}),nt=p||m,ot=e.useMemo(()=>Mn([{label:re||On(g),accessor:g,role:"x"},{label:ie||On(f),accessor:f,role:"y"},...nt?[{label:On(nt),accessor:nt,role:"group"}]:[]]),[g,f,re,ie,nt]),rt=Nn({componentName:"LineChart",data:Be?(null===(r=ve[0])||void 0===r?void 0:r[y])||[]:a,accessors:{xAccessor:g,yAccessor:f}}),it=e.useMemo(()=>Be||ke||Ie?Ne.flatMap(e=>{const t=e[y]||[];return ke&&"string"==typeof ke?t.map(t=>Object.assign(Object.assign({},t),{[ke]:e[ke]})):t}):Ae,[Ne,y,Be,ke,Ae,Ie]),st=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:qe},Array.isArray(w)&&{areaGroups:w}),S&&{lineGradient:S}),null!=R&&{hoverRadius:R}),null!=a&&{data:it}),{xAccessor:g,yAccessor:f,xScaleType:q,yScaleType:X}),Oe&&{yExtent:Oe}),{groupAccessor:"break"===P&&Ie?"_gapSegment":ke||void 0,curve:b,lineStyle:Ge}),x&&{pointStyle:Ye}),{size:[U,Q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:et,showAxes:s.showAxes,xLabel:re,yLabel:ie,xFormat:u,yFormat:d,enableHover:K,showGrid:J}),Ze&&{legend:Ze,legendPosition:tt}),G&&"none"!==G&&{legendHoverBehavior:Fe.onLegendHover,legendClickBehavior:Fe.onLegendClick,legendHighlightedCategory:Fe.highlightedCategory,legendIsolatedCategories:Fe.isolatedCategories}),ee&&{title:ee}),te&&{description:te}),ne&&{summary:ne}),void 0!==oe&&{accessibleTable:oe}),c&&{className:c}),{tooltipContent:!1===j?()=>null:"multi"===j?e=>{var t,n,o,r,i,s,a,l,c,u;const d=e.allSeries;if(!d||0===d.length){const s=null!==(i=null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t.value)&&void 0!==n?n:null===(o=e.data)||void 0===o?void 0:o.y)&&void 0!==r?r:e.value)&&void 0!==i?i:e.y;return h.createElement("div",{className:"semiotic-tooltip",style:bn},h.createElement("div",null,kn(s)))}const g=null!==(u=null!==(l=null!==(s=e.xValue)&&void 0!==s?s:null===(a=e.data)||void 0===a?void 0:a.time)&&void 0!==l?l:null===(c=e.data)||void 0===c?void 0:c.x)&&void 0!==u?u:e.time;return h.createElement("div",{className:"semiotic-tooltip",style:bn},null!=g&&h.createElement("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4}},kn(g)),d.map((e,t)=>h.createElement("div",{key:t,style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"}},h.createElement("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),h.createElement("span",{style:{flex:1,fontSize:"0.85em"}},e.group),h.createElement("span",{style:{fontWeight:500,fontSize:"0.85em"}},kn(e.value)))))}:An(j)||ot}),"multi"===j&&{tooltipMode:"multi"}),(T||H||F||z)&&{customHoverBehavior:Me}),(H||F||T)&&{customClickBehavior:Ce}),M&&{pointIdAccessor:M}),((null==C?void 0:C.length)||ge.length||Qe.length)&&{annotations:[...C||[],...ge,...Qe]}),_e),N);return se||ae||(rt?h.createElement(Cn,{componentName:"LineChart",message:rt,width:U,height:Q}):h.createElement(Zn,{componentName:"LineChart",width:U,height:Q},h.createElement(Dt,Object.assign({ref:i},st))))});co.displayName="LineChart";const uo=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:g="y",areaBy:f,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:A=!0,lineWidth:O=2,showPoints:S=!1,pointRadius:j=3,tooltip:M,annotations:C,frameProps:_={},selection:P,linkedHover:B,onObservation:L,onClick:N,hoverHighlight:I,chartId:T,loading:H,emptyContent:F,legendInteraction:z,legendPosition:R,color:$}=t,D=i.width,W=i.height,G=i.enableHover,Y=i.showGrid,q=i.showLegend,X=i.title,V=i.description,U=i.summary,Q=i.accessibleTable,K=i.xLabel,J=i.yLabel,Z=oo(H,D,W),ee=Z?null:no(s,D,W,F),te=s||[];ro("AreaChart",te,"xAccessor",d),ro("AreaChart",te,"yAccessor",g);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:se}=hn({selection:P,linkedHover:B,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:L,onClick:N,chartType:"AreaChart",chartId:T,hoverHighlight:I,colorByField:"string"==typeof v?v:void 0}),ae=gn(B,se),le=void 0!==(null===(o=te[0])||void 0===o?void 0:o[m]),ce=e.useMemo(()=>{if(le)return te;if(f){const e=te.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[m]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:te}]},[te,f,m,le]),ue=dn(te,v,b),de=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of te){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[te,v]),he=pn(z,v,de),ge=e.useMemo(()=>oe||(he.legendSelectionHook?he.legendSelectionHook:ne),[oe,he.legendSelectionHook,ne]),fe=e.useMemo(()=>e=>{const t={};if(v){if(ue){const n=E(e,v,ue);t.fill=n,A?(t.stroke=n,t.strokeWidth=O):t.stroke="none"}}else{const e=$||ln;t.fill=e,A?(t.stroke=e,t.strokeWidth=O):t.stroke="none"}return t.fillOpacity=k,t},[v,ue,$,k,A,O]),pe=e.useMemo(()=>an(fe,ge,P),[fe,ge,P]),ye=e.useMemo(()=>{if(S)return e=>{const t={r:j,fillOpacity:1};return v?ue&&(t.fill=E(e.parentLine||e,v,ue)):t.fill=ln,t}},[S,j,v,ue]),{legend:me,margin:ve,legendPosition:be}=fn({data:ce,colorBy:v,colorScale:ue,showLegend:q,legendPosition:R,userMargin:a,defaults:i.marginDefaults}),xe=f||v,ke=e.useMemo(()=>Mn([{label:K||On(d),accessor:d,role:"x"},{label:J||On(g),accessor:g,role:"y"},...xe?[{label:On(xe),accessor:xe,role:"group"}]:[]]),[d,g,K,J,xe]),we=Nn({componentName:"AreaChart",data:s,accessors:{xAccessor:d,yAccessor:g}}),Ae=e.useMemo(()=>le||f?ce.flatMap(e=>{const t=e[m]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):te,[ce,m,le,f,te]),Oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=s&&{data:Ae}),{xAccessor:d,yAccessor:g,groupAccessor:f||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:pe}),S&&ye&&{pointStyle:ye}),{size:[D,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ve,showAxes:i.showAxes,xLabel:K,yLabel:J,xFormat:c,yFormat:u,enableHover:G}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:Y}),me&&{legend:me,legendPosition:be}),z&&"none"!==z&&{legendHoverBehavior:he.onLegendHover,legendClickBehavior:he.onLegendClick,legendHighlightedCategory:he.highlightedCategory,legendIsolatedCategories:he.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),l&&{className:l}),{tooltipContent:!1===M?()=>null:An(M)||ke}),(B||L||N||I)&&{customHoverBehavior:re}),(L||N||B)&&{customClickBehavior:ie}),C&&C.length>0&&{annotations:C}),ae),_);return Z||ee||(we?h.createElement(Cn,{componentName:"AreaChart",message:we,width:D,height:W}):h.createElement(Zn,{componentName:"AreaChart",width:D,height:W},h.createElement(Dt,Object.assign({ref:r},Oe))))});function ho({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const s=e.useRef(new Set),a=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),d=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),h=e.useCallback(e=>t=>{d([t]),e(t)},[d]),g=e.useCallback(e=>t=>{d(t),e(t)},[d]),f=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:M,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return rn({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:E})},[t,n,r,o,l]),y=e.useMemo(()=>{if(p)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[p,i]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}uo.displayName="AreaChart";const go=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:g="y",areaBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m,curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:O=!1,tooltip:S,annotations:j,frameProps:M={},selection:C,linkedHover:_,onObservation:P,onClick:B,hoverHighlight:L,chartId:N,loading:I,emptyContent:T,legendInteraction:H,legendPosition:F,color:z}=t,R=i.width,$=i.height,D=i.enableHover,W=i.showGrid,G=i.showLegend,Y=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.xLabel,Q=i.yLabel,K=oo(I,R,$),J=K?null:no(s,R,$,T),Z=s||[],ee=ho({isPushMode:void 0===s,colorBy:y||f,colorScheme:m,showLegend:G,legendPosition:F}),te=e.useCallback(ee.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ee.wrapPush]),ne=e.useCallback(ee.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ee.wrapPushMany]);e.useImperativeHandle(n,()=>({push:te,pushMany:ne,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;ee.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[te,ne,ee.resetCategories]);const{activeSelectionHook:oe,hoverSelectionHook:re,customHoverBehavior:ie,customClickBehavior:se,crosshairSourceId:ae}=hn({selection:C,linkedHover:_,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:B,chartType:"StackedAreaChart",chartId:N,hoverHighlight:L,colorByField:"string"==typeof y?y:void 0}),le=gn(_,ae),ce=void 0!==(null===(o=Z[0])||void 0===o?void 0:o[p]),ue=e.useMemo(()=>{if(ce)return Z;if(f){const e=Z.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[p]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:Z}]},[Z,f,p,ce]),de=dn(Z,y,m),he=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Z){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Z,y]),ge=pn(H,y,he),fe=e.useMemo(()=>re||(ge.legendSelectionHook?ge.legendSelectionHook:oe),[re,ge.legendSelectionHook,oe]),pe=e.useMemo(()=>e=>{const t={};if(y&&de){const n=E(e,y,de);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=z||ln;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,de,b,x,k,z]),ye=e.useMemo(()=>an(pe,fe,C),[pe,fe,C]),me=e.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return y?de&&(t.fill=E(e.parentLine||e,y,de)):t.fill=z||ln,t}},[w,A,y,de,z]),{legend:ve,margin:be,legendPosition:xe}=fn({data:ue,colorBy:y,colorScale:de,showLegend:G,legendPosition:F,userMargin:a,defaults:i.marginDefaults}),ke=ee.streamingLegend||ve,we=F||xe,Ae=e.useMemo(()=>{if(ee.streamingMarginAdjust){const e=Object.assign({},be);for(const[t,n]of Object.entries(ee.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return be},[be,ee.streamingMarginAdjust]),Oe=f||y,Se=e.useMemo(()=>Mn([{label:U||On(d),accessor:d,role:"x"},{label:Q||On(g),accessor:g,role:"y"},...Oe?[{label:On(Oe),accessor:Oe,role:"group"}]:[]]),[d,g,U,Q,Oe]),je=Nn({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:d,yAccessor:g}}),Me=e.useMemo(()=>ce||f?ue.flatMap(e=>{const t=e[p]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):Z,[ue,p,ce,f,Z]),Ce=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=s&&{data:Me}),{xAccessor:d,yAccessor:g,groupAccessor:f||void 0,curve:v,normalize:O,lineStyle:ye}),w&&me&&{pointStyle:me}),{size:[R,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ae,showAxes:i.showAxes,xLabel:U,yLabel:Q,xFormat:c,yFormat:u,enableHover:D}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:W}),ke&&{legend:ke,legendPosition:we}),H&&"none"!==H&&{legendHoverBehavior:ge.onLegendHover,legendClickBehavior:ge.onLegendClick,legendHighlightedCategory:ge.highlightedCategory,legendIsolatedCategories:ge.isolatedCategories}),Y&&{title:Y}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),{tooltipContent:!1===S?()=>null:An(S)||Se}),(_||P||B||L)&&{customHoverBehavior:ie}),(P||B||_)&&{customClickBehavior:se}),j&&j.length>0&&{annotations:j}),le),M);return K||J||(je?h.createElement(Cn,{componentName:"StackedAreaChart",message:je,width:R,height:$}):h.createElement(Zn,{componentName:"StackedAreaChart",width:R,height:$},h.createElement(Dt,Object.assign({ref:r},Ce))))});function fo(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:A}=t,O="string"==typeof t.colorBy?t.colorBy:void 0,{activeSelectionHook:S,hoverSelectionHook:j,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:E}=hn({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:v,hoverHighlight:b,colorByField:O}),_=gn(c,E),P=dn(n,r,i),B=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),L=pn(s,r,B),N=e.useMemo(()=>j||(L.legendSelectionHook?L.legendSelectionHook:S),[j,L.legendSelectionHook,S]),{legend:I,margin:T,legendPosition:H}=fn({data:n,colorBy:r,colorScale:P,showLegend:p,legendPosition:a,userMargin:y,defaults:m}),F=e.useMemo(()=>{const e={};return I&&(e.legend=I,e.legendPosition=H),s&&"none"!==s&&(e.legendHoverBehavior=L.onLegendHover,e.legendClickBehavior=L.onLegendClick,e.legendHighlightedCategory=L.highlightedCategory,e.legendIsolatedCategories=L.isolatedCategories),e},[I,H,s,L.onLegendHover,L.onLegendClick,L.highlightedCategory,L.isolatedCategories]),z=oo(x,w,A),R=z?null:no(o,w,A,k);return{colorScale:P,allCategories:B,legendState:L,effectiveSelectionHook:N,activeSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,legend:I,margin:T,legendPosition:H,earlyReturn:z||R||null,legendBehaviorProps:F,crosshairProps:_}}go.displayName="StackedAreaChart";const po=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:O,linkedHover:S,linkedBrush:j,onObservation:M,onClick:C,hoverHighlight:_,chartId:B,loading:L,emptyContent:N,legendInteraction:I,legendPosition:T,color:H}=t,F=r.width,z=r.height,R=r.enableHover,$=r.showGrid,D=r.title,W=r.description,G=r.summary,Y=r.accessibleTable,q=r.xLabel,X=r.yLabel,V=i||[],U=fo({data:V,rawData:i,colorBy:g,colorScheme:f,legendInteraction:I,legendPosition:T,selection:O,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:M,onClick:C,hoverHighlight:_,chartType:"Scatterplot",chartId:B,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:L,emptyContent:N,width:F,height:z}),Q=sn(j),K=Zt({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof u?u:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof d?d:void 0)}),J=Q?"xyBrush"===K.brushInteraction.brush?"xy":"xBrush"===K.brushInteraction.brush?"x":"y":void 0,Z=h.useRef(K.brushInteraction);Z.current=K.brushInteraction;const ee=e.useCallback(e=>{const t=Z.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(U.earlyReturn)return U.earlyReturn;ro("Scatterplot",V,"xAccessor",u),ro("Scatterplot",V,"yAccessor",d);const te=e.useMemo(()=>{if(!p||0===V.length)return;const e=V.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[V,p]),ne=e.useMemo(()=>e=>{const t={fillOpacity:v};return g?U.colorScale&&(t.fill=E(e,g,U.colorScale)):t.fill=H||ln,t.r=p?P(e,p,y,te):m,t},[g,U.colorScale,p,y,te,m,v,H]),oe=e.useMemo(()=>an(ne,U.effectiveSelectionHook,O),[ne,U.effectiveSelectionHook,O]),re=e.useMemo(()=>Mn([{label:q||On(u),accessor:u,role:"x"},{label:X||On(d),accessor:d,role:"y"},...g?[{label:On(g),accessor:g,role:"color"}]:[],...p?[{label:On(p),accessor:p,role:"size"}]:[]]),[u,d,q,X,g,p]),ie=Nn({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:d}});if(ie)return h.createElement(Cn,{componentName:"Scatterplot",message:ie,width:F,height:z});const se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:V}),{xAccessor:u,yAccessor:d,colorAccessor:g||void 0,sizeAccessor:p||void 0,sizeRange:y,pointStyle:oe,colorScheme:f,size:[F,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,showAxes:r.showAxes,xLabel:q,yLabel:X,xFormat:l,yFormat:c,enableHover:R,showGrid:$}),U.legendBehaviorProps),D&&{title:D}),W&&{description:W}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),a&&{className:a}),{tooltipContent:!1===b?()=>null:An(b)||re}),(S||M||C||_)&&{customHoverBehavior:U.customHoverBehavior}),(M||C||S)&&{customClickBehavior:U.customClickBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),Q&&{brush:{dimension:J},onBrush:ee}),U.crosshairProps),A);return h.createElement(Zn,{componentName:"Scatterplot",width:F,height:z},h.createElement(Dt,Object.assign({ref:o},se)))});function yo(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}po.displayName="Scatterplot";const mo=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:d,orderLabel:g,pointRadius:f=4,tooltip:p,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,hoverHighlight:A,chartId:O,loading:S,emptyContent:j,legendInteraction:M}=t,C=r.width,E=r.height,_=r.enableHover,P=r.showGrid,B=r.title,L=r.description,N=r.summary,I=r.accessibleTable,T=r.xLabel,H=r.yLabel,F=i||[],{safeData:z,orderMap:R}=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let n=F;if(d&&F.length>0){const e="function"==typeof d?d:e=>e[d];n=[...F].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})}const o=new WeakMap;let r=0;for(const o of n){const n=e(o),i=t(o);null!=n&&null!=i&&isFinite(n)&&isFinite(i)&&r++}let i=0;for(const s of n){const n=e(s),a=t(s);null!=n&&null!=a&&isFinite(n)&&isFinite(a)&&o.set(s,{idx:i++,total:r})}return{safeData:n,orderMap:o}},[F,d,c,u]);ro("ConnectedScatterplot",z,"xAccessor",c),ro("ConnectedScatterplot",z,"yAccessor",u);const{activeSelectionHook:$,hoverSelectionHook:D,customHoverBehavior:W,customClickBehavior:G,crosshairSourceId:Y}=hn({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,onClick:w,chartType:"ConnectedScatterplot",chartId:O,hoverHighlight:A,colorByField:void 0}),q=gn(x,Y),X=pn(M,void 0,[]),V=e.useMemo(()=>D||(X.legendSelectionHook?X.legendSelectionHook:$),[D,X.legendSelectionHook,$]),U=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==V?void 0:V.isActive,s=null==V?void 0:V.predicate,a=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],d=yo(t,l),h=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?h?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=f+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=f,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[f,V]),Q=e.useMemo(()=>[U],[U]),K=e.useMemo(()=>(e,t,n)=>{var o,r;const i=e.filter(e=>"point"===e.type);if(2>i.length)return null;const s=i.length,a=100>s,l=[];for(let e=0;s-1>e;e++){const t=i[e],n=i[e+1],c=yo(e,s),u="number"==typeof(null===(o=t.style)||void 0===o?void 0:o.opacity)?t.style.opacity:1,d="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(u,d);a&&l.push(h.createElement("line",{key:"halo-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:f+2,strokeLinecap:"round",opacity:.5*g})),l.push(h.createElement("line",{key:"seg-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:c,strokeWidth:f,strokeLinecap:"round",opacity:g}))}return h.createElement(h.Fragment,null,l)},[f]),J=e.useMemo(()=>[K],[K]),Z=e.useMemo(()=>e=>{var t,n;const o=R.get(e),r=null!==(t=null==o?void 0:o.idx)&&void 0!==t?t:0,i=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:i>0?yo(r,i):"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[f,R]),ee=e.useMemo(()=>an(Z,V,b),[Z,V,b]),te=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),ne=g||("string"==typeof d?d:"Order"),oe=e.useMemo(()=>Mn([{label:T||On(c),accessor:c,role:"x"},{label:H||On(u),accessor:u,role:"y"},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[c,u,T,H,d,ne]),re=Nn({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),ie=oo(S,C,E),se=ie?null:no(i,C,E,j),ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:z}),{xAccessor:c,yAccessor:u,pointStyle:ee,size:[C,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,showAxes:r.showAxes,xLabel:T,yLabel:H,xFormat:a,yFormat:l,enableHover:_,showGrid:P}),B&&{title:B}),L&&{description:L}),N&&{summary:N}),void 0!==I&&{accessibleTable:I}),s&&{className:s}),{tooltipContent:!1===p?()=>null:An(p)||oe}),(x||k||w||A)&&{customHoverBehavior:W}),(k||w||x)&&{customClickBehavior:G}),y&&{pointIdAccessor:y}),{canvasPreRenderers:Q,svgPreRenderers:J}),m&&m.length>0&&{annotations:m}),q),v);return ie||se||(re?h.createElement(Cn,{componentName:"ConnectedScatterplot",message:re,width:C,height:E}):h.createElement(Zn,{componentName:"ConnectedScatterplot",width:C,height:E},h.createElement(Dt,Object.assign({ref:o},ae))))});mo.displayName="ConnectedScatterplot";const vo=e.forwardRef(function(t,n){const o=e.useRef(null),r=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:O={},selection:S,linkedHover:j,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:B,chartId:L,loading:N,emptyContent:I,legendInteraction:T,legendPosition:H,color:F}=t,z=r.width,R=r.height,$=r.enableHover,D=r.showGrid,W=r.showLegend,G=r.title,Y=r.description,q=r.summary,X=r.accessibleTable,V=r.xLabel,U=r.yLabel,Q=oo(N,z,R),K=Q?null:no(i,z,R,I),J=i||[],Z=void 0===i,ee=e.useRef(null),[te,ne]=e.useState(0),oe=e.useCallback(e=>{if(!Z)return;let t=!1;for(const n of e){const e="function"==typeof g?g(n):n[g];null!=e&&isFinite(e)&&(ee.current?(ee.current[0]>e&&(ee.current[0]=e,t=!0),e>ee.current[1]&&(ee.current[1]=e,t=!0)):(ee.current=[e,e],t=!0))}t&&ne(e=>e+1)},[Z,g]),re=ho({isPushMode:Z,colorBy:p,colorScheme:y,showLegend:W,legendPosition:H}),ie=e.useCallback(re.wrapPush(e=>{var t;oe([e]),null===(t=o.current)||void 0===t||t.push(e)}),[re.wrapPush,oe]),se=e.useCallback(re.wrapPushMany(e=>{var t;oe(e),null===(t=o.current)||void 0===t||t.pushMany(e)}),[re.wrapPushMany,oe]);e.useImperativeHandle(n,()=>({push:ie,pushMany:se,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;re.resetCategories(),ee.current=null,ne(e=>e+1),null===(e=o.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[ie,se,re.resetCategories]);const{activeSelectionHook:ae,hoverSelectionHook:le,customHoverBehavior:ce,customClickBehavior:ue,crosshairSourceId:de}=hn({selection:S,linkedHover:j,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,onClick:_,chartType:"BubbleChart",chartId:L,hoverHighlight:B,colorByField:"string"==typeof p?p:void 0}),he=gn(j,de),ge=sn(M);Zt({name:(null==ge?void 0:ge.name)||"__unused_brush__",xField:(null==ge?void 0:ge.xField)||("string"==typeof u?u:void 0),yField:(null==ge?void 0:ge.yField)||("string"==typeof d?d:void 0)});const fe=dn(J,p,y),pe=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of J){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[J,p]),ye=pn(T,p,pe),me=e.useMemo(()=>le||(ye.legendSelectionHook?ye.legendSelectionHook:ae),[le,ye.legendSelectionHook,ae]),ve=e.useMemo(()=>{if(Z)return ee.current||[0,1];const e=J.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[J,g,Z,te]),be=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return p?fe&&(t.fill=E(e,p,fe)):t.fill=F||ln,t.r=P(e,g,f,ve),t},[p,fe,g,f,ve,m,v,b,F]),xe=e.useMemo(()=>an(be,me,S),[be,me,S]),{legend:ke,margin:we,legendPosition:Ae}=fn({data:J,colorBy:p,colorScale:fe,showLegend:W,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),Oe=re.streamingLegend||ke,Se=H||Ae,je=e.useMemo(()=>{if(re.streamingMarginAdjust){const e=Object.assign({},we);for(const[t,n]of Object.entries(re.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return we},[we,re.streamingMarginAdjust]),Me=e.useMemo(()=>Mn([{label:V||On(u),accessor:u,role:"x"},{label:U||On(d),accessor:d,role:"y"},{label:On(g),accessor:g,role:"size"},...p?[{label:On(p),accessor:p,role:"color"}]:[]]),[u,d,V,U,g,p]),Ce=Nn({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:d},requiredProps:{sizeBy:g}});if(Ce)return h.createElement(Cn,{componentName:"BubbleChart",message:Ce,width:z,height:R});const Ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:J}),{xAccessor:u,yAccessor:d,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:xe,colorScheme:y,size:[z,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:je,showAxes:r.showAxes,xLabel:V,yLabel:U,xFormat:l,yFormat:c,enableHover:$,showGrid:D}),Oe&&{legend:Oe,legendPosition:Se}),T&&"none"!==T&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),G&&{title:G}),Y&&{description:Y}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),a&&{className:a}),{tooltipContent:!1===x?()=>null:An(x)||Me}),(j||C||_||B)&&{customHoverBehavior:ce}),(C||_||j)&&{customClickBehavior:ue}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),he),O);return Q||K||h.createElement(Zn,{componentName:"BubbleChart",width:z,height:R},h.createElement(Dt,Object.assign({ref:o},Ee)))});vo.displayName="BubbleChart";const bo=e.forwardRef(function(t,n){const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=mn(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xAccessor:u="x",yAccessor:d="y",valueAccessor:g="value",xFormat:f,yFormat:p,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:O={},selection:S,linkedHover:j,onObservation:M,onClick:C,hoverHighlight:E,chartId:_,loading:P,emptyContent:B,showLegend:L,legendPosition:N,legendInteraction:I}=t,T=s.width,H=s.height,F=s.enableHover,z=s.title,R=s.description,$=s.summary,D=s.accessibleTable,W=s.xLabel,G=s.yLabel,Y=oo(P,T,H),q=Y?null:no(a,T,H,B),X=a||[],V=null!=L&&L,U=null!=N?N:"right",{margin:Q}=fn({data:X,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:U,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:K,hoverSelectionHook:J,customHoverBehavior:Z,customClickBehavior:ee,crosshairSourceId:te}=hn({selection:S,linkedHover:j,fallbackFields:[],onObservation:M,onClick:C,chartType:"Heatmap",chartId:_,hoverHighlight:E,colorByField:void 0}),ne=gn(j,te),oe=pn(I,void 0,[]),re=e.useMemo(()=>J||(oe.legendSelectionHook?oe.legendSelectionHook:K),[J,oe.legendSelectionHook,K]),ie=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),se=e.useMemo(()=>{const e=X.map(ie);return[Math.min(...e),Math.max(...e)]},[X,ie]),ae=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(se),[y,m,se]);e.useMemo(()=>{const e=un(u),t=un(d);return{xBinCount:new Set(X.map(e)).size,yBinCount:new Set(X.map(t)).size}},[X,u,d]),e.useMemo(()=>({coordinates:X}),[X]);const le=e.useMemo(()=>e=>{const t=ie(e);return{fill:ae(t),stroke:x,strokeWidth:k}},[ie,ae,x,k]);e.useMemo(()=>an(le,re,S),[le,re,S]);const ce=e.useMemo(()=>Mn([{label:W||On(u),accessor:u,role:"x"},{label:G||On(d),accessor:d,role:"y"},{label:On(g),accessor:g,role:"value"}]),[u,d,W,G,g]),ue=Nn({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:d,valueAccessor:g}}),de=e.useMemo(()=>{if(V)return{gradient:{colorFn:e=>ae(e),domain:se,label:"string"==typeof g?g:"value",format:b}}},[V,ae,se,g,b]),he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=a&&{data:X}),{xAccessor:u,yAccessor:d,valueAccessor:g,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[T,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:s.showAxes,xLabel:W,yLabel:G,xFormat:f,yFormat:p,enableHover:F}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),de&&{legend:de,legendPosition:U}),z&&{title:z}),R&&{description:R}),$&&{summary:$}),void 0!==D&&{accessibleTable:D}),c&&{className:c}),{tooltipContent:!1===w?()=>null:An(w)||ce}),(j||M||C||E)&&{customHoverBehavior:Z}),(M||C||j)&&{customClickBehavior:ee}),A&&A.length>0&&{annotations:A}),ne),O);return Y||q||(ue?h.createElement(Cn,{componentName:"Heatmap",message:ue,width:T,height:H}):h.createElement(Zn,{componentName:"Heatmap",width:T,height:H},h.createElement(Dt,Object.assign({ref:r},he))))});bo.displayName="Heatmap";const xo="__splomIdx",ko={top:4,bottom:4,left:4,right:4};function wo({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-ko.left-ko.right,l=r-ko.top-ko.bottom;return e.useEffect(()=>{if(!s.current)return;const e=t.select(s.current).select(".brush-g"),r=n.brush().extent([[0,0],[a,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,s],[a,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(s)],[n.x.invert(a),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[a,l,o,i]),h.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},h.createElement("g",{className:"brush-g",transform:`translate(${ko.left},${ko.top})`}))}function Ao({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:g,onPointHover:f}){const p=e.useRef(null),y=Kt({name:c,clientId:`splom-${n}-${o}`}),m=Zt({name:c,xField:n,yField:o}),v=Kt({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==f||f(null));const t=e.data,n=null==t?void 0:t[xo];void 0!==n&&(b({[xo]:[n]}),null==f||f(t,e.x+ko.left,e.y+ko.top))},[b,f]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?E(e,a,l):ln,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*s):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[a,l,s,i,g,y.isActive,y.predicate,v.isActive,v.predicate,d]);return h.createElement("div",{style:{position:"relative",width:r,height:r}},h.createElement(Dt,{ref:p,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:ko,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&h.createElement(wo,{frameRef:p,cellSize:r,xField:n,yField:o,onBrush:x}))}function Oo({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const d=Kt({name:l,clientId:"splom-diag-"+n}),g=Kt({name:c,clientId:`splom-diag-${n}-hover`}),f="hover"===u?g:d,p=f.isActive,y=f.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),a=(Math.max(...e)-o)/i||1,l="string"==typeof s?s:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(i).fill(0),h=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),f=Array.from({length:i},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/a),i-1);if(d[r]++,p&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,p&&!y(e)||f[r][t]++)}}const m=Math.max(...d,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})}),b=f.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})});return{bars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,p,y,s]);return h.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},h.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>h.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):ln,opacity:p?.3:.6}))):m.bars.map((e,t)=>h.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ln,opacity:p?.3:.6})),p&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>h.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):ln,opacity:.7}))):m.selectedBars.map((e,t)=>h.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ln,opacity:.7}))))}function So({label:e,cellSize:t}){return h.createElement("svg",{width:t,height:t},h.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function jo(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:s,cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,O="splom",S="splom-hover",j=p?"hover":f?"brush":"hover",M=Vt(e=>e.clearSelection),[C,E]=e.useState(null),_=e.useCallback(()=>{M(S),E(null)},[M,S]),P=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[xo]?e:Object.assign(Object.assign({},e),{[xo]:t})),[n]),B=dn(P,i,s),L=void 0!==b?b:!!i,N=e.useMemo(()=>{if(!L||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(P.map(t=>t[e]))].map(e=>({label:e+"",color:B?B(e+""):ln})):null},[L,i,P,B]),I=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>a+"px").join(" "),gridTemplateRows:o.map(()=>a+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,a,l,40]);return h.createElement("div",{className:k,style:{position:"relative"}},N&&h.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>h.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},h.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),h.createElement("span",{style:{fontSize:11}},e.label)))),h.createElement("div",{style:I,onMouseLeave:"hover"===j?_:void 0},o.map((e,t)=>h.createElement(h.Fragment,{key:"row-"+e},h.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?h.createElement(So,{key:"diag-"+e,label:r[e]||e,cellSize:a}):h.createElement(Oo,{key:"diag-"+e,data:P,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:B,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:y,mode:j}):h.createElement(Ao,{key:`cell-${e}-${n}`,data:P,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:B,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:v,mode:j,onPointHover:"hover"===j?(r,i,s)=>{r?(E({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=s?s:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(E(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),h.createElement("div",null)," ",o.map(e=>h.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),C&&"hover"===j&&(()=>{const e=C.datum,t=r[C.xField]||C.xField,n=r[C.yField]||C.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[xo];return h.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(a+l)+C.px,top:C.rowIndex*(a+l)+C.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},h.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),h.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),h.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&h.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Mo(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),h.createElement(on,{selections:o},h.createElement(jo,Object.assign({},e)))}function Co({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),g=e.useRef(!1),f=o+i.left+i.right,p=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=t.select(u.current).select(".brush-group"),i="x"===a?n.brushX().extent([[0,0],[o,r]]):n.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===a?s.x:s.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!d.current||!s||!u.current)return;const e=t.select(u.current).select(".brush-group"),n="x"===a?s.x:s.y;if(g.current=!0,l){const t=[n(l[0]),n(l[1])];e.call(d.current.move,t)}else e.call(d.current.move,null);g.current=!1},[l,s,a]),h.createElement("svg",{ref:u,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Eo(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,description:u,summary:d,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:v="y",lineBy:b,lineDataAccessor:x="coordinates",colorBy:k,colorScheme:w,curve:A="linear",lineWidth:O=2,fillArea:S=!1,areaOpacity:j=.3,showPoints:M=!1,pointRadius:C=3,enableHover:_=!0,showGrid:P=!1,showLegend:B,legendPosition:L,tooltip:N,minimap:I={},renderBefore:T=!1,onBrush:H,brushExtent:F,frameProps:z={},loading:R,emptyContent:$}=t,D=oo(R,i,s),W=D?null:no(r,i,s,$),G=r||[],[Y,q]=e.useState(null),X=null!=F?F:Y,V=e.useCallback(e=>{F||q(e),null==H||H(e)},[F,H]),U=e.useRef(null),[Q,K]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=U.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?K(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const J=void 0!==(null===(n=G[0])||void 0===n?void 0:n[x]),Z=e.useMemo(()=>{if(J)return G;if(b){const e=G.reduce((e,t)=>{const n="function"==typeof b?b(t):t[b];if(!e[n]){const t={[x]:[]};"string"==typeof b&&(t[b]=n),e[n]=t}return e[n][x].push(t),e},{});return Object.values(e)}return[{[x]:G}]},[G,b,x,J]),ee=e.useMemo(()=>J||b?Z.flatMap(e=>{const t=e[x]||[];return b&&"string"==typeof b?t.map(t=>Object.assign(Object.assign({},t),{[b]:e[b]})):t}):G,[Z,x,J,b,G]),te=dn(G,k,w),ne=e.useMemo(()=>e=>{const t={strokeWidth:O};return t.stroke=k?E(e,k,te):ln,S&&(t.fill=t.stroke,t.fillOpacity=j),t},[k,te,O,S,j]),oe=e.useMemo(()=>I.lineStyle?I.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=k?E(e,k,te):ln,t},[k,te,I.lineStyle]),re=e.useMemo(()=>{if(M)return e=>{const t={r:C,fillOpacity:1};return t.fill=k?E(e.parentLine||e,k,te):ln,t}},[M,C,k,te]),{legend:ie,margin:se,legendPosition:ae}=fn({data:Z,colorBy:k,colorScale:te,showLegend:B,legendPosition:L,userMargin:a}),le=I.height||60,ce=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=I.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=I.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=I.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:se.left,right:null!==(a=null===(s=I.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:se.right}},[I.margin,se]),ue=I.brushDirection||"x",de=Nn({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:v}});if(de)return h.createElement(Cn,{componentName:"MinimapChart",message:de,width:i,height:s});const he=S?"area":"line",ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:A,lineStyle:ne},M&&{pointStyle:re}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:_,showGrid:P}),ie&&{legend:ie,legendPosition:ae}),c&&{title:c}),u&&{description:u}),d&&{summary:d}),N&&{tooltipContent:An(N)||void 0}),X&&{xExtent:X}),z),fe={chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:A,lineStyle:oe,size:[i,le+ce.top+ce.bottom],margin:ce,showAxes:null!==(o=I.showAxes)&&void 0!==o&&o,background:I.background,enableHover:!1},pe=h.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},h.createElement(Dt,Object.assign({ref:U},fe)),h.createElement(Co,{width:i-ce.left-ce.right,height:le,margin:ce,scales:Q,brushDirection:ue,extent:X,onBrush:V})),ye=h.createElement("div",{key:"main",style:{overflow:"hidden"}},h.createElement(Dt,Object.assign({},ge)));return D||W||h.createElement(Zn,{componentName:"MinimapChart",width:i,height:s},h.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},T?pe:ye,T?ye:pe))}Mo.displayName="ScatterplotMatrix",Eo.displayName="MinimapChart";const _o=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:O=.8,tooltip:S,pointIdAccessor:j,annotations:M,frameProps:C={},selection:_,linkedHover:B,onObservation:L,onClick:N,hoverHighlight:I,chartId:T,loading:H,emptyContent:F,legendInteraction:z,legendPosition:R,color:$}=t,D=r.width,W=r.height,G=r.enableHover,Y=r.showGrid,q=r.showLegend,X=r.title,V=r.description,U=r.summary,Q=r.accessibleTable,K=r.xLabel,J=r.yLabel,Z=oo(H,D,W),ee=Z?null:no(i,D,W,F),te=i||[];ro("QuadrantChart",te,"xAccessor",u),ro("QuadrantChart",te,"yAccessor",d);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:se}=hn({selection:_,linkedHover:B,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:N,chartType:"QuadrantChart",chartId:T,hoverHighlight:I,colorByField:"string"==typeof b?b:void 0}),ae=gn(B,se),le=dn(te,b,x),ce=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of te){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[te,b]),ue=pn(z,b,ce),de=e.useMemo(()=>oe||(ue.legendSelectionHook?ue.legendSelectionHook:ne),[oe,ue.legendSelectionHook,ne]),he=e.useMemo(()=>{if(!te.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof d?d:e=>+e[d];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of te){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=g&&isFinite(g)&&(n>g&&(n=g),g>o&&(o=g)),null!=f&&isFinite(f)&&(r>f&&(r=f),f>i&&(i=f)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(i-r)||1;return{xExtent:[n-s,o+s],yExtent:[r-a,i+a]}},[te,u,d,g,f]),ge=e.useMemo(()=>{if(!k||0===te.length)return;const e=te.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[te,k]),fe=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),pe=e.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),ye=e.useMemo(()=>e=>{const t={fillOpacity:O};if(b)le&&(t.fill=E(e,b,le));else{const n=fe(e),o=pe(e),r=null!=g?n>=g:void 0,i=null!=f?o>=f:void 0;t.fill=void 0===i||void 0===r?$||ln:i&&r?p.topRight.color:i&&!r?p.topLeft.color:!i&&r?p.bottomRight.color:p.bottomLeft.color}return t.r=k?P(e,k,w,ge):A,t},[b,le,k,w,ge,A,O,fe,pe,g,f,p,$]),me=e.useMemo(()=>an(ye,de,_),[ye,de,_]),{legend:ve,margin:be,legendPosition:xe}=fn({data:te,colorBy:b,colorScale:le,showLegend:q,legendPosition:R,userMargin:s,defaults:r.marginDefaults}),ke=e.useMemo(()=>{if(!te.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof d&&e.add(d),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=te[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[te,u,d,b,k]),we=e.useMemo(()=>Mn([...ke?[{label:ke,accessor:ke,role:"title"}]:[],{label:K||On(u),accessor:u,role:"x"},{label:J||On(d),accessor:d,role:"y"},...b?[{label:On(b),accessor:b,role:"color"}]:[],...k?[{label:On(k),accessor:k,role:"size"}]:[]]),[ke,u,d,K,J,b,k]),Ae=Nn({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:d}}),Oe=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=r.width,a=r.height,l=null!=g?o.x(g):s/2,c=null!=f?o.y(f):a/2;if(null!=g&&!isFinite(l))return;if(null!=f&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:p.topLeft,x:0,y:0,w:u,h:d},{config:p.topRight,x:u,y:0,w:s-u,h:d},{config:p.bottomLeft,x:0,y:d,w:u,h:a-d},{config:p.bottomRight,x:u,y:d,w:s-u,h:a-d}];for(const t of h)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,d),e.lineTo(s,d),e.stroke(),e.setLineDash([])}]},[g,f,p,y]),Se=e.useMemo(()=>m?[...Oe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,s=null!=g?n.x(g):r/2,a=null!=f?n.y(f):i/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,r-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,i-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:Oe,[Oe,m,v,p,g,f]),je=e.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...Se,...e]},[Se,C.canvasPreRenderers]),Me=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(e,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=o.width,i=o.height,s=null!=g?n.x(g):r/2,a=null!=f?n.y(f):i/2;if(null!=g&&!isFinite(s))return null;if(null!=f&&!isFinite(a))return null;const l=Math.max(0,Math.min(r,s)),c=Math.max(0,Math.min(i,a));return h.createElement(h.Fragment,null,[{config:p.topLeft,x:0,y:0,w:l,h:c},{config:p.topRight,x:l,y:0,w:r-l,h:c},{config:p.bottomLeft,x:0,y:c,w:l,h:i-c},{config:p.bottomRight,x:l,y:c,w:r-l,h:i-c}].map((e,t)=>{var n;return e.w>0&&e.h>0?h.createElement("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.config.color,opacity:null!==(n=e.config.opacity)&&void 0!==n?n:.08}):null}),h.createElement("line",{x1:l,y1:0,x2:l,y2:i,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),h.createElement("line",{x1:0,y1:c,x2:r,y2:c,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),m&&h.createElement(h.Fragment,null,h.createElement("text",{x:8,y:8+v,fill:p.topLeft.color,fontWeight:600,fontSize:v,opacity:.5},p.topLeft.label),h.createElement("text",{x:r-8,y:8+v,fill:p.topRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},p.topRight.label),h.createElement("text",{x:8,y:i-8,fill:p.bottomLeft.color,fontWeight:600,fontSize:v,opacity:.5},p.bottomLeft.label),h.createElement("text",{x:r-8,y:i-8,fill:p.bottomRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},p.bottomRight.label)))}]},[g,f,p,y,m,v]),Ce=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:te}),{xAccessor:u,yAccessor:d,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:me,colorScheme:x,size:[D,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:be,showAxes:r.showAxes,xLabel:K,yLabel:J,xFormat:l,yFormat:c,enableHover:G,showGrid:Y}),he&&{xExtent:he.xExtent,yExtent:he.yExtent}),ve&&{legend:ve,legendPosition:xe}),z&&"none"!==z&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),a&&{className:a}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?we:An(S)||we}),(B||L||N||I)&&{customHoverBehavior:re}),(L||N||B)&&{customClickBehavior:ie}),j&&{pointIdAccessor:j}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:je}),ae),C),je.length>0&&{canvasPreRenderers:je}),{svgPreRenderers:Me});return Z||ee||(Ae?h.createElement(Cn,{componentName:"QuadrantChart",message:Ae,width:D,height:W}):h.createElement(Zn,{componentName:"QuadrantChart",width:D,height:W},h.createElement(Dt,Object.assign({ref:o},Ce))))});_o.displayName="QuadrantChart";const Po="__ma_unitized",Bo="__ma_series";function Lo(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function No(e,t){return t[0]+e*(t[1]-t[0])}const Io=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null),s=e.useRef([]);e.useImperativeHandle(n,()=>({push:e=>{if(!i.current)return;const n=e;for(let e=0;t.series.length>e&&2>e;e++){const o=t.series[e],r=o.extent||s.current[e];if(!r)continue;const a=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(n);null!=a&&isFinite(a)&&i.current.push(Object.assign(Object.assign({},n),{[Po]:Lo(a,r),[Bo]:o.label||"Series "+(e+1)}))}},pushMany:e=>{if(!i.current)return;const n=[];for(const o of e)for(let e=0;t.series.length>e&&2>e;e++){const r=t.series[e],i=r.extent||s.current[e];if(!i)continue;const a=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(o);null!=a&&isFinite(a)&&n.push(Object.assign(Object.assign({},o),{[Po]:Lo(a,i),[Bo]:r.label||"Series "+(e+1)}))}i.current.pushMany(n)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=mn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,accessibleTable:t.accessibleTable},{width:800,height:400}),{data:l,margin:c,className:u,xFormat:d,xAccessor:g="x",series:f,colorScheme:p,curve:y="monotoneX",lineWidth:m=2,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:O,hoverHighlight:M,chartId:C,loading:E,emptyContent:_,legendInteraction:P,legendPosition:B}=t,L=a.width,N=a.height,I=a.enableHover,T=a.showGrid,H=null===(o=a.showLegend)||void 0===o||o,F=a.title,z=a.description,R=a.summary,$=a.accessibleTable,D=a.xLabel,W=2===f.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||W||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${f.length}. Rendering as a standard multi-line chart.`);const G=oo(E,L,N),Y=G?null:no(l,L,N,_),q=l||[],X=cn(),V=e.useMemo(()=>{let e;if(Array.isArray(p))e=p;else if(X&&X.length>0)e=X;else{const t=S[p];e=Array.isArray(t)?t:j}return f.map((t,n)=>t.color||e[n%e.length])},[f,p,X]),U=e.useMemo(()=>f.map((e,t)=>e.label||"Series "+(t+1)),[f]),{unitizedData:Q,extents:K}=e.useMemo(()=>{if(0===q.length){const e=f.map(e=>e.extent||null).filter(Boolean);return e.length===f.length&&(s.current=e),{unitizedData:[],extents:e.length===f.length?e:[]}}const e=f.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const r="function"==typeof t?t:e=>e[t];for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(q,e.yAccessor));if(s.current=e,!W){const t=[];for(const e of q)for(let n=0;f.length>n;n++){const o=f[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push(Object.assign(Object.assign({},e),{[Po]:r,[Bo]:U[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of q)for(let o=0;2>o;o++){const r=f[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push(Object.assign(Object.assign({},n),{[Po]:Lo(i,e[o]),[Bo]:U[o]}))}return{unitizedData:t,extents:e}},[q,f,W,U]),J=e.useMemo(()=>{if(W&&K.length>=2)return[{orient:"left",label:U[0],tickFormat:f[0].format||(e=>{const t=No(e,K[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:U[1],tickFormat:f[1].format||(e=>{const t=No(e,K[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[W,K,f,U]),Z=fo({data:e.useMemo(()=>Q.length>0?Q:U.map(e=>({[Bo]:e})),[Q,U]),rawData:l,colorBy:Bo,colorScheme:V,legendInteraction:P,legendPosition:B,selection:k,linkedHover:w,fallbackFields:[Bo],unwrapData:!1,onObservation:A,onClick:O,hoverHighlight:M,chartType:"MultiAxisLineChart",chartId:C,showLegend:H,userMargin:c,marginDefaults:W?Object.assign(Object.assign({},a.marginDefaults),{left:70,right:70}):a.marginDefaults,loading:E,emptyContent:_,width:L,height:N});if(Z.earlyReturn)return Z.earlyReturn;const ee=e.useMemo(()=>{const e=new Map;return U.forEach((t,n)=>e.set(t,V[n])),t=>({stroke:e.get(t[Bo])||V[0],strokeWidth:m,fill:"none"})},[U,V,m]),te=e.useMemo(()=>an(ee,Z.effectiveSelectionHook,k),[ee,Z.effectiveSelectionHook,k]),ne=e.useMemo(()=>{if(!1===v)return()=>null;return An(v)||(e=>{var t;const n=e.data||e,o=n[Bo],r=U.indexOf(o),i=n[Po],s=W&&r>=0&&K[r]?No(i,K[r]):i,a=r>=0&&(null===(t=f[r])||void 0===t?void 0:t.format)?f[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(n):n[g];return h.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},h.createElement("div",{style:{fontWeight:600,marginBottom:4,color:V[r]||"inherit"}},o),h.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),h.createElement("div",null,`${o}: ${a(s)}`))})},[v,U,V,K,W,f,g]),oe=Nn({componentName:"MultiAxisLineChart",data:l,accessors:{xAccessor:g}}),re=W?[0,1]:void 0,ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=l&&{data:Q}),{xAccessor:g,yAccessor:Po,groupAccessor:Bo,lineStyle:te,colorScheme:V,size:[L,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z.margin,showAxes:a.showAxes}),J&&{axes:J}),{xLabel:D}),W?{}:{yLabel:U[0]}),{xFormat:d}),W&&re&&{yExtent:re}),{enableHover:I}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:T,curve:y}),Z.legendBehaviorProps),F&&{title:F}),z&&{description:z}),R&&{summary:R}),void 0!==$&&{accessibleTable:$}),u&&{className:u}),{tooltipContent:ne}),b&&{annotations:b}),(w||A||O||M)&&{customHoverBehavior:Z.customHoverBehavior}),(A||O||w)&&{customClickBehavior:Z.customClickBehavior}),Z.crosshairProps),x);return G||Y||(oe?h.createElement(Cn,{componentName:"MultiAxisLineChart",message:oe,width:L,height:N}):h.createElement(Zn,{componentName:"MultiAxisLineChart",width:L,height:N},h.createElement(Dt,Object.assign({ref:i},ie))))});function To(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function Ho(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}Io.displayName="MultiAxisLineChart";const Fo="__forecastSegment";function zo(e,t){return"function"==typeof t?t(e):!!e[t]}const Ro=Object.freeze({__proto__:null,SEGMENT_FIELD:Fo,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,s,a,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&zo(e,u)?t="forecast":c&&zo(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Fo]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of b){const n=null!==(i=t[x])&&void 0!==i?i:"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][Fo]!==n[e+1][Fo]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[Fo]:n[e][Fo]})),t.push(Object.assign(Object.assign({},n[e]),{[Fo]:n[e+1][Fo]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Fo]!==b[e+1][Fo]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Fo]:b[e][Fo]})),k.push(Object.assign(Object.assign({},b[e]),{[Fo]:b[e+1][Fo]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[Fo]&&e.push(Object.assign(Object.assign({},t),{[Fo]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const n of k)"function"==typeof h&&(n[e]=h(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>zo(e,d)};e?(t.style=e,t.r=m):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=y,t.r=m,t.style={stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}),w.push(t)}return r&&w.push({type:"anomaly-band",threshold:null!==(s=r.threshold)&&void 0!==s?s:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(l=r.anomalyRadius)&&void 0!==l?l:6,label:r.label}),{processedData:k,annotations:w}}(e,0,0,o,r):function(e,t,n,o,r){var i,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[Fo]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Fo]:"training"}));const y=f.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let r=0,i=0,s=0,a=0;for(const[e,t]of y)r+=e,i+=t,s+=e*e,a+=e*t;const l=o*s-r*r;if(Math.abs(l)>1e-12){const s=(o*a-r*i)/l,f=(i-s*r)/o,p=e=>f+s*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,O=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...O),j=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*j,i=p(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[Fo]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label});const b=[];if(b.push(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Fo]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Fo]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle:function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[Fo];if("training"===o){let e=n.stroke;return"darken"===c?e=To(n.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:r}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===o){let e=n.stroke||"#666";return"lighten"===d&&(e=Ho(e,.4)),Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:void 0})}return"forecast"===o?Object.assign(Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:i}),null!=l&&{strokeOpacity:l}):n}},darkenColor:To,lightenColor:Ho});exports.AreaChart=uo,exports.BubbleChart=vo,exports.ConnectedScatterplot=mo,exports.Heatmap=bo,exports.LineChart=co,exports.MinimapChart=Eo,exports.MultiAxisLineChart=Io,exports.QuadrantChart=_o,exports.Scatterplot=po,exports.ScatterplotMatrix=Mo,exports.StackedAreaChart=go,exports.StreamXYFrame=Dt;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react"),n=require("d3-selection"),o=require("d3-brush"),i=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-scale-chromatic"),a=require("d3-array"),l=require("d3-hierarchy"),c=require("d3-shape"),u=require("regression");function d(e){return e&&e.__esModule?e:{default:e}}function h(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const g=h(t),p=d(u);function f(e,t){let n=0,o=t.length-1;for(;o>n;){const i=n+o+1>>1;t[i]>e?o=i-1:n=i}return t[n]}function y(e,t){let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i]?n=i+1:o=i}return t[n]}function m({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,dimension:c,scales:u,onBrush:d,binSize:h,snap:g,binBoundaries:p,snapDuring:m,streaming:v}){const b=t.useRef(null),x=t.useRef(null),k=t.useRef(d);k.current=d;const w=t.useRef(u);w.current=u;const j=t.useMemo(()=>p?[...p].sort((e,t)=>e-t):void 0,[p]),A=t.useRef(j);A.current=j;const O=t.useRef(!1),S=t.useRef(null);return t.useEffect(()=>{if(!b.current)return;const e=n.select(b.current).select(".brush-g"),t="x"===c?o.brushX():"y"===c?o.brushY():o.brush();return t.extent([[0,0],[i,r]]),t.on("brush end",n=>{if(O.current)return;const o=w.current;if(!o)return;if(!n.selection)return S.current=null,void k.current(null);let s,a;if("x"===c){const[e,t]=n.selection;s=[o.x.invert(e),o.x.invert(t)],a=[o.y.invert(r),o.y.invert(0)]}else if("y"===c){const[e,t]=n.selection;s=[o.x.invert(0),o.x.invert(i)],a=[o.y.invert(t),o.y.invert(e)]}else{const[[e,t],[i,r]]=n.selection;s=[o.x.invert(e),o.x.invert(i)],a=[o.y.invert(r),o.y.invert(t)]}if("bin"===g&&"y"!==c&&("end"===n.type||"brush"===n.type&&m)){const i=A.current;i&&i.length>0?s=function(e,t){return 0===t.length?e:[f(e[0],t),y(e[1],t)]}(s,i):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=o.x(s[0]),a=o.x(s[1]);if(O.current=!0,"x"===c)e.call(t.move,[r,a]);else if("xy"===c){const o=n.selection;e.call(t.move,[[r,o[0][1]],[a,o[1][1]]])}O.current=!1}const l={x:s,y:a};S.current=l,k.current(l)}),e.call(t),x.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),x.current=null}},[i,r,c,g,h,m]),t.useEffect(()=>{if(!(v&&u&&x.current&&S.current))return;if(!b.current)return;if("y"===c)return;const e=S.current,t=u.x.domain()[0],o=n.select(b.current).select(".brush-g");if(t>=e.x[1])return O.current=!0,o.call(x.current.move,null),O.current=!1,S.current=null,void k.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===g){const e=A.current;e&&e.length>0?i=y(t,e):h&&h>0&&(i=Math.ceil(t/h)*h)}if(i>=e.x[1])return O.current=!0,o.call(x.current.move,null),O.current=!1,S.current=null,void k.current(null);r=!0}const s=u.x(i),a=u.x(e.x[1]);if(O.current=!0,"x"===c)o.call(x.current.move,[s,a]);else{const t=u.y(e.y[1]),n=u.y(e.y[0]);o.call(x.current.move,[[s,t],[a,n]])}if(O.current=!1,r){const t={x:[i,e.x[1]],y:e.y};S.current=t,k.current(t)}},[u,v,c,g,h]),e.jsx("svg",{ref:b,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`})})}class v{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o: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(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function b(n){const o=t.createContext(null),i=x(n);return[function({children:i}){const r=t.useMemo(()=>x(n),[]);return e.jsx(o.Provider,{value:r,children:i})},e=>{var n;const r=null!==(n=t.useContext(o))&&void 0!==n?n:i,s=t.useRef(e);s.current=e;const a=t.useCallback(()=>s.current(r.getState()),[r]),l=t.useCallback(()=>s.current(r.getState()),[r]);return t.useSyncExternalStore(r.subscribe,a,l)}]}function x(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function k(e){if(!(null==e?void 0: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 w(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:j})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const j=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],A={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:10}},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:10}},S={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:j,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"},[C,M]=b(e=>({theme:A,setTheme(t){e(e=>{if("light"===t)return{theme:A};if("dark"===t)return{theme:O};if("high-contrast"===t)return{theme:S};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?O:A;return{theme:w(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}}return{theme:w(Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})}))}})}}));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(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,s=this.buffer[r];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(e),this.buffer[r]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),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}}class P{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(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.isNaN(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 L(e,t,n,o,i){const r=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 l=Math.floor(e/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const e=i(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return r}function B(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function N(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function T(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function I(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const H={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},F=s.schemeCategory10,R=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],z=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function W(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||z.has(t)}(o)?n(o):o}const o=null==e?void 0:e[t];return n?n(o):F[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%F.length]}function $(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return i.scaleOrdinal().domain(o).range(n).unknown("#999");const s=H[n]||H.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:F;return i.scaleOrdinal().domain(o).range(e).unknown("#999")}}function D(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!o)return i;const[r,s]=o,[a,l]=n;return s===r?(a+l)/2:a+(i-r)/(s-r)*(l-a)}function E(e,t,n){var o,i,r;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function Y(e,t,n){var o;const i=null!==(o=e.duration)&&void 0!==o?o:500,r=n-t;return i>r?1-r/i:0}function G(e,t,n){return e+(t-e)*n}function q(e,t,n){var o,i,r,s;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),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(s=null!==(i=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s: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 X(e,t,n,o,i,r){const s=[];for(const i of e){const e=n(i),r=o(i);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||s.push({px:t.x(e),py:t.y(r),rawY:r,d:i})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function V(e,t,n,o,i,r,s,a){const l=[];for(const r of e){const e=n(r),s=o(r);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(r):i;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:e,group:s}}function U(e,t,n,o,i,r,s){const a=n(e),l=o(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:i,style:r,datum:e};return void 0!==s&&(c.pointId=s),c}function Q(e,t,n,o,i,r,s){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:r,group:s}}function K(e,t,n,o,i,r,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function J(e,t,n){if(!e.getBounds||!e.scales)return null;const o=[],i=[];for(const n of t){const t=e.getX(n),r=e.getY(n);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const s=e.getBounds(n),a=e.scales.x(t);if(s&&0!==s)o.push([a,e.scales.y(r+s)]),i.push([a,e.scales.y(r-s)]);else{const t=e.scales.y(r);o.push([a,t]),i.push([a,t])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function Z(e,t,n,o){var i;if(!e.config.pointStyle)return;const r=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const s of o.data){let o=e.config.pointStyle(s);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const a=null!==(i=o.r)&&void 0!==i?i:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=U(s,e.scales,e.getX,r,a,o,l);c&&n.push(c)}}}const ee={blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo},te=new Map;class ne{constructor(e){if(this.xExtent=new P,this.yExtent=new P,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._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=e,this.buffer=new _(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=N(e.timeAccessor||e.xAccessor,"time"),this.getY=N(e.valueAccessor||e.yAccessor,"value")):(this.getX=N(e.xAccessor,"x"),this.getY=N(e.yAccessor,"y")),this.getGroup=I(e.groupAccessor),this.getCategory=I(e.categoryAccessor),this.getSize=e.sizeAccessor?N(e.sizeAccessor,"size"):void 0,this.getColor=I(e.colorAccessor),this.getBounds=e.boundsAccessor?N(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?N(e.y0Accessor,"y0"):void 0,this.getPointId=I(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?N(e.openAccessor,"open"):void 0,this.getHigh=N(e.highAccessor,"high"),this.getLow=N(e.lowAccessor,"low"),this.getClose=n?N(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new _(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?N(this.config.timeAccessor||this.config.xAccessor,"time"):N(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],i=o instanceof Date,r="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=i||r,r){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,r,s,a,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let p=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(o=c.xExtent[1])&&void 0!==o?o:h[1]]:h,f=c.yExtent?[null!==(r=c.yExtent[0])&&void 0!==r?r:g[0],null!==(s=c.yExtent[1])&&void 0!==s?s:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)f=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)f=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;let o=0;for(const e of t)for(const t of e.data){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const r=(n.get(e)||0)+i;n.set(e,r),r>o&&(o=r)}f=[0,o+(o>0?o*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:f}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,n,o,i){const r=L(e,t,n,o,i);if(0===r.size)return[0,0];let s=0;for(const e of r.values())e.total>s&&(s=e.total);return[0,s]}(u,this.getX,this.getY,c.binSize,this.getCategory);f=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(u,this.getY),n=t-e,o=n>0?n*c.extentPadding:1;f=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&f[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>f[1]&&(f[1]=t+n),f[0]>t-n&&(f[0]=t-n))}const e=f[1]-f[0],t=e>0?e*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],o=null===(l=c.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-t,null!=o?f[1]:f[1]+t],"log"===c.yScaleType&&0>=f[0]&&g[0]>0&&(f[0]=null!=n?f[0]:g[0]/(1+c.extentPadding))}if(p[0]===1/0||p[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();p=[e-864e5,e]}else p=[0,1];f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:i.scaleLinear().domain(p).range(t),y:i.scaleLinear().domain(f).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:i.scaleLinear().domain(f).range([v,e.width-v]),y:i.scaleLinear().domain(p).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):i.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,p,[v,e.width-v]),y:t(c.yScaleType,f,[e.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),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.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return this._quadtree=null,void(this._maxPointRadius=0);let t=0,n=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxPointRadius=n,ne.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const o=Array(t);let i=0;for(const e of this.scene)"point"===e.type&&(o[i++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._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 o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":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 o=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):i.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,o,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,r,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:o,scales:i}=this;if(!i||0===t.length)return[];const r={scales:i,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,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(o.chartType){case"line":return function(e,t){var n;const o=e.groupData(t),i=[],r=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of o){const n=J(e,t.data,t.key);n&&i.push(n)}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=X(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(o.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),i.push(o)}return Z(e,o,i),i}(r,t);case"area":return function(e,t){const n=e.groupData(t),o=[],i=e.scales.y.domain()[0],r=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=V(t.data,e.scales,e.getX,e.getY,i,n,t.key,r);e.config.gradientFill&&(s.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),o.push(s)}return Z(e,n,o),o}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],i=e.config.areaGroups||new Set,r=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n)if(i.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),i=V(t.data,e.scales,e.getX,e.getY,r,n,t.key,s);e.config.gradientFill&&(i.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),o.push(i)}else{const n=e.resolveLineStyle(t.key,t.data[0]),i=X(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),o.push(i)}return Z(e,n,o),o}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:i,stackedTops:r}=function(e,t,n,o,i,r,s){var a;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),r=o(i);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||e.set(t,(e.get(t)||0)+r)}u.set(t.key,e)}let d;if(r){d=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(t))||0;d.set(t,n||1)}}const h=[],g=new Map,p=new Map;for(const e of c)p.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[],l=new Map;for(const n of c){let i=e.get(n)||0;const s=p.get(n);r&&(i/=d.get(n));const c=s+i,u=t.x(n);a.push([u,t.y(s)]),o.push([u,t.y(c)]),p.set(n,c),l.set(n,c)}g.set(n.key,l);const f={type:"area",topPath:o,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(f.curve=s),h.push(f)}return{nodes:h,stackedTops:g}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o),s=i;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=r.get(o.key);if(n)for(const i of o.data){const o=e.getX(i),r=e.getY(i);null==o||Number.isNaN(o)||null==r||Number.isNaN(r)||!n.has(o)||t.set(i,n.get(o))}}const o=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};Z(e,n,s,o)}return s}(r,t);case"scatter":case"bubble":return function(e,t){var n;const o=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let s=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 o of n)e>o&&(e=o),o>t&&(t=o);s=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,l=(null===(n=e.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of t){let t=e.config.pointStyle?e.config.pointStyle(n):{fill:l,opacity:.8},r=t.r||i;if(s&&e.getSize){const t=e.getSize(n);null==t||Number.isNaN(t)||(r=s(t))}if(a&&e.getColor&&!t.fill){const o=e.getColor(n);o&&a.has(o)&&(t=Object.assign(Object.assign({},t),{fill:a.get(o)}))}const c=e.getPointId?e.getPointId(n)+"":void 0,u=U(n,e.scales,e.getX,e.getY,r,t,c);u&&o.push(u)}return o}(r,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,i,r;const s=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(i=e.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=e.config.heatmapAggregation)&&void 0!==r?r:"count",c=N(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),p=(d-u||1)/s,f=(g-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],i=e.getX(o),r=e.getY(o);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/p),s-1),d=Math.min(Math.floor((r-h)/f),a-1);if(0>l||0>d)continue;const g=d*s+l;m[g]++;const y=c(o);v[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===m[e])continue;let t;switch(l){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/s,j=n.height/a,A=e.config.showValues,O=e.config.heatmapValueFormat,S=[];for(let e=0;a>e;e++){const t=e*s;for(let n=0;s>n;n++){const o=t+n;if(0===m[o])continue;let i;switch(l){case"sum":i=v[o];break;case"mean":i=v[o]/m[o];break;default:i=m[o]}const r=(i-b)/k;S.push(K(n*w,(a-1-e)*j,w,j,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:e,value:i,count:m[o],sum:v[o]},A?{value:i,showValues:!0,valueFormat:O}:void 0))}}return S}(e,t,n);if(0===t.length)return[];const o=N(e.config.valueAccessor,"value"),i=T(e.config.xAccessor,"x"),r=T(e.config.yAccessor,"y"),a=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=i(n),s=r(n);c[e]=o,u[e]=s,a.has(o)||a.set(o,a.size),l.has(s)||l.set(s,l.size)}const d=a.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(a.keys()),p=Array.from(l.keys()),f=g.every(e=>"number"==typeof e&&!isNaN(e)),y=p.every(e=>"number"==typeof e&&!isNaN(e));if(f){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}if(y){p.sort((e,t)=>e-t),l.clear();for(let e=0;p.length>e;e++)l.set(p[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],i=a.get(c[e]),r=l.get(u[e]);if(void 0===i||void 0===r)continue;const s=o(n),h=r*d+i,g=x.get(h);let p;void 0!==g?p=g:(p=k++,x.set(h,p)),m[p]=h,v[p]=s,b[p]=n}let w=1/0,j=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(w>t&&(w=t),t>j&&(j=t))}if(!isFinite(w)||!isFinite(j))return[];const A=function(e){const t=e in ee?e:"blues";let n=te.get(t);if(n)return n;n=Array(256);const o=ee[t]||s.interpolateBlues;for(let e=0;256>e;e++)n[e]=o(e/255);return te.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),O=255/(j-w||1),S=n.width/d,C=n.height/h,M=e.config.showValues,_=e.config.heatmapValueFormat,P=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],o=n%d;P.push(K(o*S,(h-1-(n-o)/d)*C,S,C,A[Math.min((t-w)*O+.5|0,255)],b[e],M?{value:t,showValues:!0,valueFormat:_}:void 0))}return P}(r,t,e);case"bar":{const e=function(e,t){var n,o;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=L(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of i.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(n),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=n.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const s=[],a=e.scales,[l,c]=a.x.domain(),u=e.config.barStyle,d=null===(n=e.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,g="number"!=typeof h||0>h?1:h,p={};(null==u?void 0:u.stroke)&&(p.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(p.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(p.opacity=u.opacity);for(const t of i.values()){const n=Math.max(t.start,l),i=Math.min(t.end,c);if(n>=i)continue;const h=a.x(n),f=a.x(i),y=Math.abs(f-h),m=y>g+1?g:0,v=Math.min(h,f)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&t.categories.size>0){let n=0;for(const i of r){const r=t.categories.get(i)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(o=e.config.barColors)||void 0===o?void 0:o[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(Q(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},p),{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:r},i)),n+=r}}else{const e=a.y(0),n=a.y(t.total);s.push(Q(v,Math.min(e,n),b,Math.abs(e-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},p),{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of i.values())f.add(e.start),f.add(e.end);return{nodes:s,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=null!==(n=r.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,o,i,r,s,a;const l=[],c=e.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(o=c.fill)&&void 0!==o?o:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,g=c.stroke,p=c.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const i=e.scales.x(t),r=e.scales.y(o);let s=d;if(e.getCategory){const t=e.getCategory(n);s=(null===(a=e.config.barColors)||void 0===a?void 0:a[t])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:g,strokeWidth:p},datum:n};e.getPointId&&(c.pointId=e.getPointId(n)+""),l.push(c)}return l}(r,t);case"waterfall":return function(e,t,n){var o,i,r,s,a,l,c;const u=[],d=e.scales,h=e.config.waterfallStyle,g=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===g.length)return u;const p=null!==(r=null!==(o=null==h?void 0:h.positiveColor)&&void 0!==o?o:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",f=null!==(l=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(a=e.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==l?l:"#dc3545",y=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,m=null==h?void 0:h.stroke,v=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let t=0;g.length>t;t++){const o=g[t],i=e.getX(o),r=e.getY(o),s=x+r;let a;a=g.length-1>t?e.getX(g[t+1])-i:t>0?i-e.getX(g[t-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+n.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const j=d.y(x),A=d.y(s),O=Math.min(j,A),S=Math.abs(j-A),C={fill:0>r?f:p,stroke:m,strokeWidth:v};null!=b&&(C.opacity=b),u.push(Q(k,O,w,S,C,Object.assign(Object.assign({},o),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(r,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||e.getOpen&&e.getClose))return[];const r=[],s=e.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=i?a:s.upColor||"#28a745",c=i?a:s.downColor||"#dc3545",u=i?a:s.wickColor||"#333",d=s.wickWidth||(i?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else g=6;for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),s=e.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=i?o:e.getOpen(n),h=i?s:e.getClose(n);if(!i&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const p=h>=a,f={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:p,datum:n};i&&(f.isRange=!0),r.push(f)}return r}(r,t);default:return[]}}resolveBoundsStyle(e,t){var n;const o=this.config.boundsStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(e,t).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?E(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,i;const r=n.length;if(1>=r)return;const s=new Map;for(let e=0;n.length>e;e++)s.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let i=!1;for(let n=0;t.length>n;n++){const a=s.get(t[n]);null!=a?(o[n]=E(e,a,r),1>o[n]&&(i=!0)):o[n]=1}i&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const i=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=s.get(t[n]);null!=o?(i[n]=E(e,o,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of t){const t=s.get(n);if(null!=t){const n=E(e,t,r);i>n&&(i=n)}}if(1>i){const e=Array(o);e.fill(i),n._decayOpacities=e}}continue}const t=s.get(n.datum);if(null==t)continue;const a=E(e,t,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(i=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=e.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=e.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],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 i=0;for(const n of t){const t=c.get(n);if(null==t)continue;const r=o.get(t);if(null==r)continue;const a=Y(e,r,s);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const i=o.get(t);if(null==i)continue;const r=Y(e,i,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=e.duration)&&void 0!==n?n:500,r=t.peek();return null!=r&&i>o-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var i,r,s,a;n.clear(),o.clear();for(let l=0;t.length>l;l++){const c=t[l],u=q(e,c,l);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(i=c.style)||void 0===i?void 0:i.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?o.set(u,{path:c.path.map(e=>[e[0],e[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&o.set(u,{topPath:c.topPath.map(e=>[e[0],e[1]]),bottomPath:c.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.y(0))&&void 0!==t?t:0;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],i=q(this.transitionContext,t,e);i&&("point"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,r:0,opacity:0}):"rect"===t.type?this.prevPositionMap.set(i,{x:t.x,y:o,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}):"heatcell"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,w:t.w,h:t.h,opacity:0}):"line"===t.type?(t._introClipFraction=0,this.prevPathMap.set(i,{path:t.path.map(e=>[e[0],e[1]]),opacity:t.style.opacity})):"area"===t.type&&(t._introClipFraction=0,this.prevPathMap.set(i,{topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),opacity:t.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,i){var r,s,a,l,c,u,d,h,g,p,f,y,m,v,b,x,k,w,j,A,O,S,C,M,_,P,L,B,N,T,I,H,F,R,z,W,$,D,E,Y,G;if(0===o.size&&0===i.size)return n;const X=null!==(r=t.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let V=!1;const U=new Set,Q=new Set;for(let t=0;n.scene.length>t;t++){const r=n.scene[t],P=q(e,r,t);if(!P)continue;if(r._transitionKey=P,"line"===r.type||"area"===r.type){const e=i.get(P);if(e){if(Q.add(P),"line"===r.type&&e.path&&e.path.length===r.path.length){r._targetPath=r.path.map(e=>[e[0],e[1]]),r._prevPath=e.path;for(let t=0;r.path.length>t;t++)r.path[t]=[e.path[t][0],e.path[t][1]];V=!0}else if("area"===r.type&&e.topPath&&e.bottomPath&&e.topPath.length===r.topPath.length&&e.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(e=>[e[0],e[1]]),r._targetBottomPath=r.bottomPath.map(e=>[e[0],e[1]]),r._prevTopPath=e.topPath,r._prevBottomPath=e.bottomPath;for(let t=0;r.topPath.length>t;t++)r.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;r.bottomPath.length>t;t++)r.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];V=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=e.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;continue}const L=o.get(P);if("point"===r.type)if(L){U.add(P);const e={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,L.x===e.x&&L.y===e.y&&L.r===e.r||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=L.x,r.y=L.y,r.r=null!==(d=L.r)&&void 0!==d?d:r.r,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(L){U.add(P);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(g=r.style.opacity)&&void 0!==g?g:1,L.x===e.x&&L.y===e.y&&L.w===e.w&&L.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=L.x,r.y=L.y,r.w=null!==(p=L.w)&&void 0!==p?p:r.w,r.h=null!==(f=L.h)&&void 0!==f?f:r.h,V=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(L){U.add(P);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(v=null===(m=r.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,L.x===e.x&&L.y===e.y&&L.w===e.w&&L.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=L.x,r.y=L.y,r.w=null!==(b=L.w)&&void 0!==b?b:r.w,r.h=null!==(x=L.h)&&void 0!==x?x:r.h,V=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0;else if("candlestick"===r.type)if(L&&null!=L.openY){U.add(P);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(A=null===(j=r.style)||void 0===j?void 0:j.opacity)&&void 0!==A?A:1,(L.x!==e.x||L.openY!==e.openY||L.closeY!==e.closeY||L.highY!==e.highY||L.lowY!==e.lowY)&&(r._targetX=e.x,r._targetOpenY=e.openY,r._targetCloseY=e.closeY,r._targetHighY=e.highY,r._targetLowY=e.lowY,r.x=L.x,r.openY=L.openY,r.closeY=null!==(O=L.closeY)&&void 0!==O?O:r.closeY,r.highY=null!==(S=L.highY)&&void 0!==S?S:r.highY,r.lowY=null!==(C=L.lowY)&&void 0!==C?C:r.lowY,V=!0)}else r._targetOpacity=null!==(_=null===(M=r.style)||void 0===M?void 0:M.opacity)&&void 0!==_?_:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0}for(const[e,t]of i)if(!Q.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(P=t.opacity)&&void 0!==P?P:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),V=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={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:null!==(L=t.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),V=!0}for(const[e,t]of o)if(!U.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(B=t.r)&&void 0!==B?B:3,style:{opacity:null!==(N=t.opacity)&&void 0!==N?N:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(T=t.w)&&void 0!==T?T:0,h:null!==(I=t.h)&&void 0!==I?I:0,style:{opacity:null!==(H=t.opacity)&&void 0!==H?H:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(F=t.w)&&void 0!==F?F:0,h:null!==(R=t.h)&&void 0!==R?R:0,fill:"#999",datum:null,style:{opacity:null!==(z=t.opacity)&&void 0!==z?z:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("c:")){const o=null!==(W=t.openY)&&void 0!==W?W:t.y,i={type:"candlestick",x:t.x,openY:o,closeY:null!==($=t.closeY)&&void 0!==$?$:o,highY:null!==(D=t.highY)&&void 0!==D?D:o,lowY:null!==(E=t.lowY)&&void 0!==E?E:o,bodyWidth:null!==(Y=t.w)&&void 0!==Y?Y:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(G=t.opacity)&&void 0!==G?G:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(i)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:X}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var i,r,s,a,l,c;if(!n.activeTransition)return!1;const u=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,n.activeTransition),d=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(u,"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?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=G(r,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=G(n.x,e._targetX,d),e.y=G(n.y,e._targetY,d),void 0!==e._targetR&&void 0!==n.r&&(e.r=G(n.r,e._targetR,d))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=G(i,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=G(n.x,e._targetX,d),e.y=G(n.y,e._targetY,d),void 0!==n.w&&(e.w=G(n.w,e._targetW,d)),void 0!==n.h&&(e.h=G(n.h,e._targetH,d))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:G(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=G(n.x,e._targetX,d),e.y=G(n.y,e._targetY,d),void 0!==n.w&&(e.w=G(n.w,e._targetW,d)),void 0!==n.h&&(e.h=G(n.h,e._targetH,d))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:G(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=G(n.x,e._targetX,d),void 0!==n.openY&&(e.openY=G(n.openY,e._targetOpenY,d)),void 0!==n.closeY&&(e.closeY=G(n.closeY,e._targetCloseY,d)),void 0!==n.highY&&(e.highY=G(n.highY,e._targetHighY,d)),void 0!==n.lowY&&(e.lowY=G(n.lowY,e._targetLowY,d))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:G(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=G(t[o][0],n[o][0],d),e.path[o][1]=G(t[o][1],n[o][1],d)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(c=e._startOpacity)&&void 0!==c?c:0;e.style=Object.assign(Object.assign({},e.style),{opacity:G(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,i=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=G(t[n][0],o[n][0],d),e.topPath[n][1]=G(t[n][1],o[n][1],d);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=G(n[t][0],i[t][0],d),e.bottomPath[t][1]=G(n[t][1],i[t][1],d)}}if(u>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style: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("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}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||R,r=new Map;for(let e=0;n.length>e;e++)r.set(n[e],i[e%i.length]);return this._colorMapCache={key:o,map:r,version:this._ingestVersion},r}resolveLineStyle(e,t){var n;const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{stroke:t})}return n}const i=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.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:this.resolveGroupColor(e)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n,o;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const i=this.config.lineStyle;if("function"==typeof i){const n=i(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||R;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(e,o),this._groupColorMap.size>ne.GROUP_COLOR_MAP_CAP){const e=this._groupColorMap.keys().next().value;void 0!==e&&this._groupColorMap.delete(e)}return o}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=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&i.add(t)});const r=this.buffer.update(e=>n.has(o(e)),t);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,o,i;const r=Object.assign({},this.config);("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||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let s=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==r.chartType||"runtimeMode"in e&&e.runtimeMode!==r.runtimeMode;if(a||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const l=a||!B(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),c=a||!B(null!==(o=e.yAccessor)&&void 0!==o?o:e.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=N(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=N(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=N(this.config.xAccessor,"x"),this.getY=N(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!B(e.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?I(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!B(e.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?I(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!B(e.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?N(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!B(e.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?I(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!B(e.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?N(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!B(e.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?I(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!B(e.openAccessor,r.openAccessor)||"closeAccessor"in e&&!B(e.closeAccessor,r.closeAccessor)||"highAccessor"in e&&!B(e.highAccessor,r.highAccessor)||"lowAccessor"in e&&!B(e.lowAccessor,r.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?N(this.config.openAccessor,"open"):void 0,this.getHigh=N(this.config.highAccessor,"high"),this.getLow=N(this.config.lowAccessor,"low"),this.getClose=t?N(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0}if(!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==r[n]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function oe(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 ie(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function re(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function se(e,t){const n=re(e);if(!n)return!1;const o=re(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function ae(e,t,n,o=30,i,r=0){let s=null;if(i){const e=function(e,t,n,o,i){const r=Math.max(o,i+5,12),s=t-r,a=t+r,l=n-r,c=n+r;let u=null,d=1/0;return e.visit((e,i,r,h,g)=>{if(i>a||s>h||r>c||l>g)return!0;if(!e.length){let i=e;do{const e=i.data,r=e.x-t,s=e.y-n,a=Math.sqrt(r*r+s*s);ie(e.r,o)>=a&&d>a&&(u=e,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}(i,t,n,o,r);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const r of e){let e=null;switch(r.type){case"point":if(i)break;e=ce(r,t,n,o);break;case"line":e=ue(r,t,n,o);break;case"rect":e=he(r,t,n);break;case"heatcell":e=ge(r,t,n);break;case"area":if(!1===r.interactive)break;e=fe(r,t,n);break;case"candlestick":e=pe(r,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function le(e,t,n){if(0===e.length)return null;const o=ye(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let i=o,r=o;o>0&&e[o][0]>=t?(i=o-1,r=o):e.length-1>o&&(i=o,r=o+1);const[s,a]=e[i],[l,c]=e[r];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function ce(e,t,n,o=30){const i=t-e.x,r=n-e.y,s=Math.sqrt(i*i+r*r);return s>ie(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function ue(e,t,n,o=30){var i,r,s,a;if(0===e.path.length)return null;const l=ye(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let o=1/0;const i=Math.max(0,l-1),r=Math.min(e.path.length-2,l);for(let s=i;r>=s;s++){const[i,r]=e.path[s],[a,l]=e.path[s+1],c=de(t,n,i,r,a,l);o>c&&(o=c)}d=o}else{const e=t-c,o=n-u;d=Math.sqrt(e*e+o*o)}const h=null!==(a=null!==(r=null===(i=e.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(s=e.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function de(e,t,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function he(e,t,n){const o=oe(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ge(e,t,n){const o=oe(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function pe(e,t,n){const o=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function fe(e,t,n){if(0===e.topPath.length)return null;const o=ye(e.topPath,t);if(0>o)return null;const[i,r]=e.topPath[o],s=t-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:r,distance:l}}function ye(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function me(e,t,n){const o=e.byGroup.get(t);let i=0,r=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);r>t&&(r=t,i=e)}return o[i]._flatIndex}function ve(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}ne.GROUP_COLOR_MAP_CAP=1e3,ne.QUADTREE_THRESHOLD=500;const be={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function xe(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,be[n])(o(e,t)),i}function ke(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function we(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const je=(t,n,o,i,r,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:g}=t,p=[];let f=0;const y=!(!n&&!o),m="isolate"===u||void 0===u&&null!=r;return g.forEach((t,u)=>{const v=xe(t,u,d,h),b=we(t,i,r),x=r&&r.size>0&&r.has(t.label);p.push(e.jsxs("g",{transform:`translate(0,${f})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:y?l===s&&u===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:y?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:y?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.jsx(ke,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),f+=22}),p};function Ae({config:t,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+g.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&e.jsx("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),e.jsx("text",{x:a+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function Oe(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,p]=g.useState(0),[f,y]=g.useState(0),m=g.useCallback((e,t)=>{p(e),y(t)},[]),v="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,g)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+g)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:je(t,o,i,r,s,a,l,g,c,u)},"legend-group-"+g)),d+=22*t.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:m,legendInteraction:a}):(({legendGroups:t,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const g=[];t.forEach((t,n)=>{let p=0;t.label&&(p+=16);const f=((t,n,o,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:g,items:p}=t,f=[];let y=0,m=0;const v=!(!n&&!o),b="isolate"===u||void 0===u&&null!=r;p.forEach((t,u)=>{const x=xe(t,u,h,g),k=we(t,i,r),w=r&&r.size>0&&r.has(t.label),j=26+7*t.label.length;d&&d>0&&y>0&&y+j>d&&(m++,y=0),f.push(e.jsxs("g",{transform:`translate(${y},${22*m})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?l===s&&u===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?w||!1:void 0,"aria-current":v&&!b&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:v?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+p.length)%p.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:v?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.jsx(ke,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=j});let x=0,k=0;for(const e of p){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:f,offset:x,totalRows:w,totalHeight:22*w}})(t,i,r,s,a,l,c,n,u,d,o);p+=f.offset+5,g.push(Object.assign(Object.assign({label:t.label},f),{offset:p,totalRows:f.totalRows,totalHeight:f.totalHeight})),h+=p+12});let p=h>o?0:Math.max(0,(o-h)/2);const f=[];return g.forEach((o,i)=>{const r=t[i];r.label&&(f.push(e.jsx("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:r.label},"legend-text-"+i)),p+=16),f.push(e.jsx("g",{className:"legend-item",transform:`translate(${p},0)`,children:o.items},"legend-group-"+i)),p+=o.offset+5,t[i+1]&&f.push(e.jsx("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+i)),p+=12}),e.jsx("g",{children:f})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:m,legendInteraction:a}),b=!(!o&&!i);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==a&&(void 0!==a||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===d&&e.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),v]})}function Se(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function Ce(t){const{legend:n,totalWidth:o,totalHeight:i,margin:r,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!n)return null;const g="top"===s||"bottom"===s;let p,f;return"left"===s?(p=4,f=r.top):"top"===s?(p=0,f=a?32:8):"bottom"===s?(p=0,f=i-r.bottom+50):(p=o-r.right+10,f=r.top),e.jsx("g",{transform:`translate(${p}, ${f})`,children:(y=n,"object"==typeof y&&null!==y&&"gradient"in y?e.jsx(Ae,{config:n.gradient,orientation:g?"horizontal":"vertical",width:g?o:100}):Se(n)?e.jsx(Oe,{legendGroups:n.legendGroups,title:"",width:g?o:100,orientation:g?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n)});var y}function Me(e){return"string"==typeof e?{type:e}:e}function _e({orient:n,config:o,values:i,scale:r,size:s,length:l}){const c=function(e){var t,n,o,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(o),u="top"===n||"bottom"===n,d=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),o=s-8;if("boxplot"===c.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],r=t[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],r+1.5*s)}}(i);if(!t)return null;const{q1:s,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=t,g=Math.min(.5*o,20),p=(o-g)/2+4;if(u){const t=r(s),o=r(l),i=r(a),u=r(d),f=r(h),y="top"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:u,y1:m+y*(p+g/2),x2:f,y2:m+y*(p+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:m+y*p,x2:u,y2:m+y*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:f,y1:m+y*p,x2:f,y2:m+y*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,o),y:"top"===n?m-p-g:m+p,width:Math.abs(o-t),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:i,y1:"top"===n?m-p-g:m+p,x2:i,y2:"top"===n?m-p:m+p+g,stroke:c.fill,strokeWidth:2})]})}{const t=r(s),o=r(l),i=r(a),u=r(d),f=r(h),y="left"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:m+y*(p+g/2),y1:u,x2:m+y*(p+g/2),y2:f,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*p,y1:u,x2:m+y*(p+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*p,y1:f,x2:m+y*(p+g),y2:f,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===n?m-p-g:m+p,y:Math.min(t,o),width:g,height:Math.abs(o-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===n?m-p-g:m+p,y1:i,x2:"left"===n?m-p:m+p+g,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=a.bin().domain(t).thresholds(c.bins)(i);if(0===d.length)return null;const h=Math.max(...d.map(e=>e.length));if(0===h)return null;if("histogram"===c.type)return e.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const s=t.length/h*o;if(u){const o=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:o,y:"top"===n?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const o=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(o,o+a),width:s,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const t=o/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(o/2),a=r((e.x0+e.x1)/2);i.push(u?`${a},${"top"===n?-(t-s):t-s}`:`${"left"===n?-(t-s):t-s},${a}`)}for(let e=d.length-1;e>=0;e--){const s=d[e];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(o/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===n?-(t+a):t+a}`:`${"left"===n?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+n,children:e.jsx("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const t=[];if(u){const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${i},${e}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*o,s=r((e.x0+e.x1)/2);t.push(`L${s},${"top"===n?-i-4:i+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${s},${e}`),t.push("Z")}else{const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${e},${i}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*o,s=r((e.x0+e.x1)/2);t.push(`L${"left"===n?-i-4:i+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${e},${s}`),t.push("Z")}return e.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:e.jsx("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,r,c,s,l,n,u,4]);return d?e.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function Pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>o?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function Le(e,t,n,o){return"curly"===e?o?`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`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Be(t,n,o,i){if(!t)return e.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=t;if(!r&&!s)return e.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>n?"end":"start";const p=16,f=s?u?[s]:Pe(s,c):[],y=r?u?[r]:Pe(r,c):[],m="leftRight"===d?"end"===g?-4:4:0;let v=0;const b=[],x=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";f.length>0&&(b.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold",children:f.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:p,children:t},n))},"annotation-note-title")),v=f.length*p),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:g,y:v,children:y.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:p,children:t},n))},"annotation-note-label"));let k=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),k=e.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(f.length+y.length)*p+(y.length>0?p:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),k=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,f.length+y.length-1)*p;let j=0;return"topBottom"===d?j=0>o?-(w+2):18:"leftRight"===d&&(j="middle"===h?-(w+p+(y.length>0&&f.length>0?2:0))/2+8:"bottom"===h||0>o?-(w+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==j?`translate(0,${j})`:void 0,children:b}),k]})}function Ne(t,n,o,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&a.push(e.jsx("circle",{r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&a.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;a.push(e.jsx("line",{x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(e.jsx("line",{x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(e.jsx("line",{x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(e.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==t&&a.push(e.jsx("path",{d:Le((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function Te(t,n,o,i,r,s){const a=[];let l=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const e=s.width||0,o=s.height||0;if(e>0||o>0){const i=e/2,r=o/2,s=t-i,a=n-r;if(0!==s||0!==a){const t=Math.abs(s),n=Math.abs(a),u=e/2,d=o/2,h=t*d>n*u?u/t:d/n;l=i+s*h,c=r+a*h}}}else if("bracket"===r&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(a.push(e.jsx("line",{x1:l,y1:c,x2:t,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,s=Math.atan2(n-c,t-l);a.push(e.jsx("path",{d:`M${l},${c}L${l+o*Math.cos(s+r)},${c+o*Math.sin(s+r)}L${l+o*Math.cos(s-r)},${c+o*Math.sin(s-r)}Z`,fill:i||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return e.jsx("g",{className:"annotation-connector",children:a})}function Ie(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:p,events:f={},"data-testid":y}=t,m=new Set(Array.isArray(p)?p:[]);let v=i||0,b=r||0;null!=s&&(v=s-n),null!=a&&(b=a-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return e.jsxs("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":y},f,{children:[!m.has("connector")&&Te(v,b,c,h,x,u),!m.has("subject")&&Ne(x,u,h,n,o),!m.has("note")&&Be(l,v,b,h)]}))}function He(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.jsx(Ie,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return e.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return e.jsx(Ie,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Fe(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function Re(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function ze(e,t,n){var o,i,r,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const r=function(e){var t,n,o,i,r,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(i=n.stickyPositionCache)||void 0===i||i.set(t,r)),r}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Fe(e,n),c=Re(e,n)),null!=l&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function We(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const $e={linear:c.curveLinear,monotoneX:c.curveMonotoneX,monotoneY:c.curveMonotoneY,step:c.curveStep,stepAfter:c.curveStepAfter,stepBefore:c.curveStepBefore,basis:c.curveBasis,cardinal:c.curveCardinal,catmullRom:c.curveCatmullRom};let De={positions:new Map};const Ee=new Set;function Ye(){for(const e of Ee)e()}function Ge(e,t){const n=De.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(De.positions);o.delete(e),De={positions:o},Ye()}function qe(e,t){const n=De.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(De.positions);o.delete(e),De={positions:o},Ye()}function Xe(){return De}function Ve(e){return Ee.add(e),()=>Ee.delete(e)}const Ue={positions:new Map};function Qe(){return()=>{}}function Ke(){return Ue}function Je(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ze(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+o;for(let e=0;r>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*i}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${o+4*i},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function et(n){const{width:o,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:g}=n,p=t.useMemo(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||h||tt,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,r=l.x.ticks(Math.min(i,Math.max(2,Math.floor(o/70)))),s=r.map(e=>e.valueOf()),a=r.map((e,t)=>({value:e,pixel:l.x(e),label:n(e,t,s)})),c=a.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 nt(a,Math.max(55,c+8))},[l,u,h,o]),f=t.useMemo(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||tt,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return nt(l.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:l.y(e),label:n(e)})),22)},[l,u,g,i]),y=d&&l,m=c&&l;if(!y&&!m)return null;const v=null==u?void 0:u.find(e=>"bottom"===e.orient),b=null==u?void 0:u.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,j=(null==b?void 0:b.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return e.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[y&&(()=>{var t,n;const r=Je(null===(t=null==u?void 0:u.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),s=Je(null===(n=null==u?void 0:u.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[p.map((t,n)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),f.map((t,n)=>e.jsx("line",{x1:0,y1:t.pixel,x2:o,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),x&&!w&&e.jsx("line",{x1:0,y1:i,x2:o,y2:i,stroke:A,strokeWidth:1}),w&&e.jsx("path",{d:Ze("bottom",o,i),fill:"none",stroke:A,strokeWidth:1}),k&&!j&&e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),j&&e.jsx("path",{d:Ze("left",o,i),fill:"none",stroke:A,strokeWidth:1})]})})}function tt(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function nt(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function ot(n){var o,i;const{width:r,height:s,totalWidth:a,totalHeight:u,margin:d,scales:h,showAxes:g,axes:f,xLabel:y,yLabel:m,yLabelRight:v,xFormat:b,yFormat:x,showGrid:k,title:w,legend:j,legendHoverBehavior:A,legendClickBehavior:O,legendHighlightedCategory:S,legendIsolatedCategories:C,legendPosition:M="right",foregroundGraphics:_,marginalGraphics:P,xValues:L,yValues:B,annotations:N,svgAnnotationRules:T,xAccessor:I,yAccessor:H,annotationData:F,pointNodes:R,curve:z,underlayRendered:W,linkedCrosshairName:$,linkedCrosshairSourceId:D,children:E}=n,Y=t.useMemo(()=>{var e;if(!g||!h)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||b||tt,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=h.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),s=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:h.x(e),label:n(e,t,s)})),l=a.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),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let u=nt(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=h.x.domain()[1],t=h.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e,u.length,s);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:i})}}return u},[g,h,f,b,r]),G=t.useMemo(()=>{var e;if(!g||!h)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||tt,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let i=nt(h.y.ticks(Math.min(o,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),(null==t?void 0:t.includeMax)&&i.length>0){const e=h.y.domain()[1],t=h.y(e),o=i[i.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e);22>Math.abs(t-o)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:t,label:r})}}return i},[g,h,f,x,s]),q=t.useMemo(()=>{var e;if(!g||!h)return[];const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||tt,o=null!==(e=t.ticks)&&void 0!==e?e:5;return nt(h.y.ticks(Math.min(o,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[g,h,f,x,s]),X=t.useRef(new Map),V=t.useRef(null!==(o=null==N?void 0:N.length)&&void 0!==o?o:0),U=null!==(i=null==N?void 0:N.length)&&void 0!==i?i:0;V.current!==U&&(V.current=U,X.current=new Map);const Q=t.useMemo(()=>{if(!N||0===N.length)return null;const t=function(t,n,o){var i,r,s,a,u,d,h,g,f,y,m,v,b,x,k,w,j,A,O,S,C,M,_,P,L,B,N,T,I,H,F,R,z,W,$,D,E,Y,G,q,X,V,U,Q,K,J,Z,ee;switch(t.type){case"label":{const i=ze(t,n,o);if(!i)return null;const{x:r,y:s}=i;return We(r,s,o)?e.jsx(He,{noteData:{x:r,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}},"ann-"+n):null}case"callout":{const i=ze(t,n,o);if(!i)return null;const{x:r,y:s}=i;return We(r,s,o)?e.jsx(He,{noteData:{x:r,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}},"ann-"+n):null}case"x-threshold":{const i=Fe(t,o);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:i+4,y:a,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"y-threshold":{const i=Re(t,o);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(o.width||0)/2,l="middle"):(a=(o.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Fe(Object.assign(Object.assign({},e),{type:"point"}),o),y:Re(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=l.packEnclose(i),s=t.padding||10;return e.jsxs("g",{children:[e.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Fe(Object.assign(Object.assign({},e),{type:"point"}),o),y:Re(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,s=i.map(e=>e.x),a=i.map(e=>e.y),l=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...a)-r,d=Math.max(...a)+r;return e.jsxs("g",{children:[e.jsx("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"highlight":{const i=o.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],s={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.jsx("g",{children:r.map((n,i)=>{const r=Fe(n,o),a=Re(n,o);if(null==r||null==a)return null;const l="function"==typeof t.r?t.r(n):t.r||6,c="function"==typeof t.style?t.style(n):t.style||s;return e.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+n)}case"bracket":{const i=Fe(t,o),r=Re(t,o);return e.jsx(He,{noteData:{x:null!=i?i:0,y:null!=r?r: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-"+n)}case"trend":{const l=o.data||[];if(2>l.length)return null;const c=o.xAccessor||"x",g=o.yAccessor||"y",f=l.map(e=>[e[c],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(s=o.scales)||void 0===s?void 0:s.time,m=null!==(u=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==u?u:null===(d=o.scales)||void 0===d?void 0:d.value;if(!y||!m)return null;const v=t.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),i=o.map(e=>e[0]),r=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],g+=t*i[e]*i[e],p+=t*i[e]*r[e])}if(0===u){a.push([t,r[e]]);continue}const f=u*g-d*d;if(1e-12>Math.abs(f))a.push([t,h/u]);else{const e=(u*p-d*h)/f;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?p.default.polynomial(f,{order:t.order||2}):p.default.linear(f)).points;const x=b.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=t.color||"#6366f1";return e.jsxs("g",{children:[e.jsx("polyline",{points:x,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:y(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11,children:t.label})]},"ann-"+n)}case"band":{const i=null!==(f=null===(g=o.scales)||void 0===g?void 0:g.y)&&void 0!==f?f:null===(y=o.scales)||void 0===y?void 0:y.value,r=null!==(m=null==i?void 0:i(t.y0))&&void 0!==m?m:0,s=null!==(v=null==i?void 0:i(t.y1))&&void 0!==v?v:o.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+n)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=o.scales)||void 0===k?void 0:k.time,a=null!==(j=null===(w=o.scales)||void 0===w?void 0:w.y)&&void 0!==j?j:null===(A=o.scales)||void 0===A?void 0:A.value;if(!s||!a)return null;const l=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=i.filter(e=>null!=e[l]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=$e[o.curve||"linear"]||c.curveLinear,p=c.area().x(e=>s(e[r])).y0(e=>a(e[u])).y1(e=>a(e[l])).curve(g)(h);if(!p)return null;const f=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:p,fill:f,fillOpacity:null!==(O=t.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:s(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+n)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==(C=null===(S=o.scales)||void 0===S?void 0:S.x)&&void 0!==C?C:null===(M=o.scales)||void 0===M?void 0:M.time,a=null!==(P=null===(_=o.scales)||void 0===_?void 0:_.y)&&void 0!==P?P:null===(L=o.scales)||void 0===L?void 0:L.value;if(!s||!a)return null;const l=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(B=t.threshold)&&void 0!==B?B:2,g=c-h*d,p=!1!==t.showBand,f=t.fill||"#6366f1",y=null!==(N=t.fillOpacity)&&void 0!==N?N:.1,m=t.anomalyColor||"#ef4444",v=null!==(T=t.anomalyRadius)&&void 0!==T?T:6,b=a(c+h*d),x=a(g),k=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>h*d});return e.jsxs("g",{children:[p&&e.jsx("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:f,fillOpacity:y}),k.map((t,n)=>{const i=Fe(t,o),r=Re(t,o);return null==i||null==r?null:e.jsx("circle",{cx:i,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11,children:t.label})]},"ann-"+n)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(H=null===(I=o.scales)||void 0===I?void 0:I.x)&&void 0!==H?H:null===(F=o.scales)||void 0===F?void 0:F.time,l=null!==(z=null===(R=o.scales)||void 0===R?void 0:R.y)&&void 0!==z?z:null===(W=o.scales)||void 0===W?void 0:W.value;if(!a||!l)return null;const c=i.map(e=>[e[r],e[s]]).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 u;if("polynomial"===(t.method||"linear")){const e=p.default.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,r]of c)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*n)/r,a=(n-s*t)/e;u=e=>a+s*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(d-2,1)),f=c.reduce((e,t)=>e+t[0],0)/d,y=c.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),m=null!==($=t.confidence)&&void 0!==$?$:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=t.steps)&&void 0!==D?D:5,x=c[d-1][0],k=(x-c[0][0])/Math.max(d-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const j=[];for(const e of w){const t=u(e),n=g*Math.sqrt(1+1/d+(y>0?Math.pow(e-f,2)/y:0))*v;j.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${j.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${j.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,O=j.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),S=`${a(x)},${l(u(x))}`,C=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(E=t.fillOpacity)&&void 0!==E?E:.15,stroke:"none"}),e.jsx("polyline",{points:`${S} ${O}`,fill:"none",stroke:C,strokeWidth:null!==(Y=t.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&j.length>0&&e.jsx("text",{x:a(j[j.length-1].x)+4,y:l(j[j.length-1].yCenter)-4,fill:C,fontSize:11,children:t.label})]},"ann-"+n)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=ze(t,n,o);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!We(i,r,o))return null;const s=null!==(q=t.dx)&&void 0!==q?q:0,a=null!==(X=t.dy)&&void 0!==X?X:0,l=null!==(V=t.width)&&void 0!==V?V:32,c=null!==(U=t.height)&&void 0!==U?U:32,u=null!==(Q=t.content)&&void 0!==Q?Q:e.jsx("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return e.jsx("foreignObject",{x:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:e.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const i=ze(t,n,o);if(!i)return null;const{x:r,y:s}=i;return e.jsx("text",{x:r+(t.dx||0),y:s+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label},"ann-text-"+n)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=null===(K=o.scales)||void 0===K?void 0:K.o,s=null===(J=o.scales)||void 0===J?void 0:J.x,a=null===(Z=o.scales)||void 0===Z?void 0:Z.y,l=(null==r?void 0:r.bandwidth)?r:(null==s?void 0:s.bandwidth)?s:(null==a?void 0:a.bandwidth)?a:null;if(!l)return null;const c=l(i);if(null==c)return null;const u=l.bandwidth(),d=t.color||"var(--semiotic-primary, #4589ff)",h=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,g=t.label;return e.jsxs("g",(o.projection?"vertical"===o.projection:l===s)?{children:[e.jsx("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),g&&e.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:g})]}:{children:[e.jsx("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:h}),g&&e.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:I,yAccessor:H,width:r,height:s,data:F,frameType:"xy",pointNodes:R,curve:z,stickyPositionCache:X.current};return N.map((e,o)=>{if(T){const i=T(e,o,n);return null!=i?i:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[N,T,r,s,I,H,F,h,R,z]),K=function(e){var n;const o=t.useSyncExternalStore(e?Ve:Qe,e?Xe:Ke,e?Xe:Ke);return e&&null!==(n=o.positions.get(e))&&void 0!==n?n:null}($);return t.useEffect(()=>{if(!(null==K?void 0:K.locked)||!$)return;const e=e=>{"Escape"===e.key&&qe($)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==K?void 0:K.locked,$]),g||w||j||_||P||Q&&Q.length>0||k||E||K?e.jsxs("svg",{role:"img",width:a,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof w?w:"XY Chart"}),e.jsx("desc",{children:"string"==typeof w?w+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[k&&h&&!W&&(()=>{var t,n;const o=Je(null===(t=null==f?void 0:f.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=Je(null===(n=null==f?void 0:f.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[Y.map((t,n)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),G.map((t,n)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),g&&h&&(()=>{const t=null==f?void 0:f.find(e=>"left"===e.orient),n=null==f?void 0:f.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,i=!n||!1!==n.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==t?void 0:t.landmarkTicks,h="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",b=!!(null==n?void 0:n.autoRotate)&&Y.length>1&&(()=>{const e=r/Math.max(Y.length-1,1);return Y.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!W&&i&&!l&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:h,strokeWidth:1}),!W&&l&&e.jsx("path",{d:Ze("bottom",r,s),fill:"none",stroke:h,strokeWidth:1}),Y.map((t,n)=>{const o=!!c&&("function"==typeof c?c(t.value,n):se(t.value,n>0?Y[n-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:g,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0,children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"xtick-"+n)}),y&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"},children:y}),!W&&o&&!a&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:h,strokeWidth:1}),!W&&a&&e.jsx("path",{d:Ze("left",r,s),fill:"none",stroke:h,strokeWidth:1}),G.map((t,n)=>{const o=!!u&&("function"==typeof u?u(t.value,n):se(t.value,n>0?G[n-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:g,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-"+n)}),(()=>{const n=(null==t?void 0:t.label)||m;return n?e.jsx("text",{x:15-d.left,y:s/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-d.left}, ${s/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t||0===q.length)return null;const n=t.landmarkTicks,o=t.label||v;return e.jsxs(e.Fragment,{children:[!1!==t.baseline&&e.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:h,strokeWidth:1}),q.map((t,o)=>{const i=!!n&&("function"==typeof n?n(t.value,o):se(t.value,o>0?q[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${r},${t.pixel})`,children:[e.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:g,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-r-"+o)}),o&&e.jsx("text",{x:r+d.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${r+d.right-15}, ${s/2})`,style:{userSelect:"none"},children:o})]})})()]})})(),Q,P&&h&&L&&B&&e.jsxs(e.Fragment,{children:[P.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(_e,{orient:"top",config:Me(P.top),values:L,scale:h.x,size:d.top,length:r})}),P.bottom&&e.jsx("g",{transform:`translate(0, ${s})`,children:e.jsx(_e,{orient:"bottom",config:Me(P.bottom),values:L,scale:h.x,size:d.bottom,length:r})}),P.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(_e,{orient:"left",config:Me(P.left),values:B,scale:h.y,size:d.left,length:s})}),P.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx(_e,{orient:"right",config:Me(P.right),values:B,scale:h.y,size:d.right,length:s})})]}),_,K&&K.sourceId!==D&&(null==h?void 0:h.x)&&(()=>{const t=h.x(K.xValue);if(null==t||0>t||t>r)return null;const n=K.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),E]}),w&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof w?w:null}),Ce({legend:j,totalWidth:a,totalHeight:u,margin:d,legendPosition:M,title:w,legendHoverBehavior:A,legendClickBehavior:O,legendHighlightedCategory:S,legendIsolatedCategories:C})]}):null}function it(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const rt="undefined"==typeof window||"undefined"==typeof document,st=g.createContext(null),at={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function lt(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=r.indexOf(e),o=r.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${i[e]||e}`);return`${t}, ${o.join(", ")}`}const ct=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},ut={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid 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-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},dt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},ht={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},gt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},pt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},ft={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},yt={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function mt({scene:t,chartType:n,tableId:o,chartTitle:i}){var r;const[s,a]=g.useState(!1),l=g.useContext(st),c=null!==(r=null==l?void 0:l.visible)&&void 0!==r&&r,u=s||c,d=g.useRef(null),h=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n,p=g.useCallback(()=>{s||c||a(!0)},[s,c]),f=g.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[c]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:at}):null;if(!u)return e.jsx("div",{id:o,tabIndex:-1,onFocus:p,style:at,role:"region","aria-label":h,children:e.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",t.length," elements)"]})});const y=function(e){var t,n,o,i,r,s,a,l,c,u,d,h,g,p,f,y,m,v,b,x,k,w,j,A,O;const S=[];if(!Array.isArray(e))return S;for(const C of e)if(C&&"object"==typeof C)try{switch(C.type){case"point":S.push({label:"Point",values:{x:C.x,y:C.y}});break;case"line":{const e=C.path,t=Array.isArray(C.datum)?C.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=C.topPath,t=Array.isArray(C.datum)?C.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=C.datum&&"object"==typeof C.datum?C.datum:{},r=null!==(n=null!==(t=e.category)&&void 0!==t?t:C.group)&&void 0!==n?n:"",s=null!==(i=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==i?i:e.total;S.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":S.push({label:"Cell",values:{x:C.x,y:C.y,value:C.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=C.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=C.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=C.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=C.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=C.cx)&&void 0!==g?g:C.x,y:null!==(p=C.cy)&&void 0!==p?p:C.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(y=null===(f=C.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:"",x:null!==(m=C.cx)&&void 0!==m?m:C.x,y:null!==(v=C.cy)&&void 0!==v?v:C.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:C.x,open:C.open,high:C.high,low:C.low,close:C.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(j=null!==(k=null===(x=null===(b=C.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=C.datum)||void 0===w?void 0:w.name)&&void 0!==j?j:"",value:null!==(O=null===(A=C.datum)||void 0===A?void 0:A.value)&&void 0!==O?O:""}})}}catch(e){}return S}(t),m=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 o of t){const t=[],i=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],r=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),r+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),v=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${ct(e.min)} to ${ct(e.max)}, mean ${ct(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(y.length,m),b=y.slice(0,5),x=new Set;for(const e of b)for(const t of Object.keys(e.values))x.add(t);const k=Array.from(x);return e.jsxs("div",{ref:d,id:o,tabIndex:-1,onBlur:f,style:ut,role:"region","aria-label":h,children:[e.jsx("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:ht,children:"×"}),e.jsx("div",{role:"note",style:dt,children:v}),e.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:gt,children:[e.jsxs("caption",{style:yt,children:["First ",b.length," of ",y.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:pt,children:"type"}),k.map(t=>e.jsx("th",{style:pt,children:t},t))]})}),e.jsx("tbody",{children:b.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:ft,children:t.label}),k.map(n=>{return e.jsx("td",{style:ft,children:(o=t.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":ct(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]})]})}function vt({summary:t}){return t?e.jsx("div",{role:"note",style:at,children:t}):null}function bt({tableId:t}){return e.jsx("a",{href:"#"+t,style:at,onClick:e=>{e.preventDefault();const n=document.getElementById(t);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,at)},children:"Skip to data table"})}function xt({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:at,children:n})}const kt="var(--semiotic-focus, #005fcc)";function wt({active:t,hoverPoint:n,margin:o,size:i,shape:r="circle",width:s,height:a}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=s&&null!=a){const t=Math.max(s,4),n=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:kt,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:kt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:kt,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function jt({x:t,y:n,containerWidth:o,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=g.useRef(null),[u,d]=g.useState(null);g.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,o,i]);let h;return h=u?`translate(${u.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:c,className:a,style:{position:"absolute",left:r.left+t,top:r.top+n,transform:h,pointerEvents:"none",zIndex:l,width:"max-content"},children:s})}function At(e,n,o){const i=t.useRef(null),[r,s]=t.useState(null);return t.useEffect(()=>{if(!n&&!o)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[i,[n&&r?r.w:e[0],o&&r?r.h:e[1]]]}const Ot=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,St=new WeakMap;let Ct=0,Mt=!1,_t=null,Pt=null,Lt=null;function Bt(e,t){var n,o;if(!t)return t;const i=Ot.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||t;!function(){if(Mt)return;if("undefined"==typeof window||"undefined"==typeof document)return;Mt=!0;const e=()=>{Ct++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(_t=new MutationObserver(e),_t.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Pt=window.matchMedia("(prefers-color-scheme: dark)"),Lt=e,"function"==typeof Pt.addEventListener?Pt.addEventListener("change",Lt):"function"==typeof Pt.addListener&&Pt.addListener(Lt)}catch(e){}}();let s=St.get(r);s&&s.version===Ct||(s={version:Ct,map:new Map},St.set(r,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(o=i[2])||void 0===o?void 0:o.trim())||t;return s.map.set(t,l),l}function Nt(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Tt(e){const n=function(){const[e,n]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),e}(),o=t.useRef(n);o.current=n;const[i,r]=At(e.sizeProp,e.responsiveWidth,e.responsiveHeight),s=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),a=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,c=Nt(e.foregroundGraphics,r,s),u=Nt(e.backgroundGraphics,r,s),d=M(e=>e.theme),{transition:h,introEnabled:p}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+g.useId(),y=t.useRef(0),m=t.useRef(()=>{}),v=t.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>m.current()))},[]);t.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),k=t.useRef(null),w=t.useRef(0),j=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),A=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(j))},[j]),O=t.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),x.current()},[]);t.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const S=e.themeDirtyRef;return t.useEffect(()=>{S&&(Ct++,S.current=!0,v())},[d,v,S]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:p,tableId:f,rafRef:y,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:A,onPointerLeave:O}}function It(e,t,n,o){const i=e.getContext("2d");if(!i)return null;const r=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===r&&e.height===s||(e.width=r,e.height=s),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function Ht(e){switch(e){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function Ft(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Rt(e,t,n,o,i,r){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],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=r;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const zt=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(e.save(),e.beginPath(),e.rect(0,0,o.width*l,o.height),e.clip());const u=a.style.stroke||"#007bff",d=Bt(e,u)||u,h=a.style.strokeWidth||2,g=a.colorThresholds,p=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=h,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const v=null!==(i=a.style.opacity)&&void 0!==i?i:1;Rt(e,a.path,d,h,v,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const f=Ht(a.curve),y=g&&g.length>0&&p&&p.length===a.path.length,m=a._decayOpacities;if(m&&m.length===a.path.length&&!y){e.strokeStyle=d;const b=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let x=0;a.path.length-1>x;x++)e.globalAlpha=.5*(m[x]+m[x+1])*b,e.beginPath(),e.moveTo(a.path[x][0],a.path[x][1]),e.lineTo(a.path[x+1][0],a.path[x+1][1]),e.stroke()}else if(y){let k=null,w=null,j=null,A=null,O=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),O=!0}function C(){O&&(e.stroke(),O=!1)}for(let M=0;a.path.length>M;M++){const[_,P]=a.path[M],L=p[M],B=Ft(L,g,d);if(null!==k&&null!==A&&null!==j){if(B===A)e.lineTo(_,P);else{const N=[];for(const T of g){const I=T.value;(j>I||I>L)&&(I>j||L>I)||j===I||L===I||N.push({t:(I-j)/(L-j)})}N.sort((e,t)=>e.t-t.t);for(const H of N){const F=k+(_-k)*H.t,R=w+(P-w)*H.t,z=Ft(j+(L-j)*Math.min(H.t+1e-4,1),g,d);e.lineTo(F,R),C(),S(z,F,R)}e.lineTo(_,P)}k=_,w=P,j=L,A=B}else S(B,_,P),k=_,w=P,j=L,A=B}C()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=d;else{const W=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const $ of a.strokeGradient.colorStops)W.addColorStop(Math.max(0,Math.min(1,$.offset)),$.color);e.strokeStyle=W}if(f)c.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(a.path);else{const[D,E]=a.path[0];e.moveTo(D,E);for(let Y=1;a.path.length>Y;Y++)e.lineTo(a.path[Y][0],a.path[Y][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?Bt(e,a.style.fill):a.style.fill)||a.style.fill,f&&!y)c.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(a.path);else{const[q,X]=a.path[0];e.moveTo(q,X);for(let V=1;a.path.length>V;V++)e.lineTo(a.path[V][0],a.path[V][1])}const G=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(G,o.height),e.closePath(),e.fill()}void 0!==l&&1>l&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Wt(e,t){const n=e.fillStyle,o="#010203";try{e.fillStyle=o,e.fillStyle=t}catch(t){return e.fillStyle=n,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&t.trim().toLowerCase()!==o)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const r=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}function $t(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Dt(e,t,n=.3){$t(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 Et(e,t,n=.6){var o,i,r,s,a;if(!$t(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,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 Yt(e,t,n,o=.35){$t(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function Gt(e){switch(e){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function qt(e,t){const n=Gt(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=c.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Xt=(e,t,n,o)=>{var i,r,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const a=t.style.fill||"#4e79a7",l=t._decayOpacities;if(l&&l.length===t.topPath.length){const n=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=a;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(l[o]+l[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Bt(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*(l[n]+l[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 u=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(qt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const i=e.createLinearGradient(0,n,0,o);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const[n,o,r]=Wt(e,"string"==typeof a?a:"#4e79a7");i.addColorStop(0,`rgba(${n},${o},${r},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${n},${o},${r},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=u}else{const n=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=n*u,e.fillStyle=a}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(qt(e,t),Yt(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=u,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Bt(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=Gt(t.curve);if(e.beginPath(),n)c.line().x(e=>e[0]).y(e=>e[1]).curve(n).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!==n&&1>n&&e.restore(),e.globalAlpha=1}},Vt=(e,t,n,o)=>{var i;const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=("string"==typeof t.style.fill?Bt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Bt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Et(e,t),e.globalAlpha=1}}finally{e.restore()}}};function Ut(e,t,n){const o=t.fillGradient;if(!o)return null;const i=t.roundedEdge;let r=t.x,s=t.y,a=t.x,l=t.y+t.h;if("bottom"===i?(s=t.y+t.h,l=t.y):"right"===i?(r=t.x+t.w,s=t.y,a=t.x,l=t.y):"left"===i&&(r=t.x,s=t.y,a=t.x+t.w,l=t.y),"colorStops"in o){const t=o.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>t.length)return null;const n=e.createLinearGradient(r,s,a,l);for(const e of t)n.addColorStop(e.offset,e.color);return n}const c=e.createLinearGradient(r,s,a,l),[u,d,h]=Wt(e,n);return c.addColorStop(0,`rgba(${u},${d},${h},${o.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${o.bottomOpacity})`),c}const Qt=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Kt(e,t);else if(t.roundedTop&&t.roundedTop>0){const n=("string"==typeof t.style.fill?Bt(e,t.style.fill):t.style.fill)||Bt(e,"var(--semiotic-primary, #007bff)"),o="string"==typeof n?Ut(e,t,n):null;e.fillStyle=o||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:r,y:s,w:a,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(r,s),e.lineTo(r+a-i,s),e.arcTo(r+a,s,r+a,s+i,i),e.lineTo(r+a,s+l-i),e.arcTo(r+a,s+l,r+a-i,s+l,i),e.lineTo(r,s+l);break;case"left":e.moveTo(r+a,s),e.lineTo(r+i,s),e.arcTo(r,s,r,s+i,i),e.lineTo(r,s+l-i),e.arcTo(r,s+l,r+i,s+l,i),e.lineTo(r+a,s+l);break;case"bottom":e.moveTo(r,s),e.lineTo(r+a,s),e.lineTo(r+a,s+l-i),e.arcTo(r+a,s+l,r+a-i,s+l,i),e.lineTo(r+i,s+l),e.arcTo(r,s+l,r,s+l-i,i);break;default:e.moveTo(r,s+l),e.lineTo(r,s+i),e.arcTo(r,s,r+i,s,i),e.lineTo(r+a-i,s),e.arcTo(r+a,s,r+a,s+i,i),e.lineTo(r+a,s+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Bt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=("string"==typeof t.style.fill?Bt(e,t.style.fill):t.style.fill)||Bt(e,"var(--semiotic-primary, #007bff)"),o="string"==typeof n?Ut(e,t,n):null;e.fillStyle=o||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Bt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Dt(e,t),e.globalAlpha=1}};function Kt(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.h)-o;if(0>=i)return;const r=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),r){const r=i+o,s=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=r)e.drawImage(n,s,o,i,i)}else{const r=i+o,s=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=r)e.drawImage(n,o,s,i,i)}e.restore()}function Jt(e,t,n,o){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:n,time:t,value:n}),o)}function Zt(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function en(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const tn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function nn(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${tn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${tn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const on={line:[Xt,zt,Vt],area:[Xt,Vt],stackedarea:[Xt,Vt],scatter:[Vt],bubble:[Vt],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Bt(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Dt(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):en(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,r=t.y+t.h/2;e.fillStyle=Zt(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,r)}}}finally{e.restore()}}],bar:[Qt],swarm:[Vt],waterfall:[(e,t,n,o)=>{var i,r,s;Qt(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=Bt(e,c)||c,e.lineWidth=null!==(i=null==l?void 0:l._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const o=a[t],i=a[t+1];if(!(null===(r=o.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=i.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{var i,r,s;for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const a=(null!==(i=t._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(e.globalAlpha=a);const l=Bt(e,t.wickColor)||t.wickColor,c=60>o.height,u=c?Math.max(t.wickWidth,2):t.wickWidth,d=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=l,e.lineWidth=u,e.stroke()};if(c||d(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=l,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,r=Bt(e,i)||i;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}c&&d(),e.restore()}}],mixed:[Xt,zt,Vt]},rn={top:20,right:20,bottom:30,left:40},sn={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"};function an(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],i=n[3];return`#${e}${e}${o}${o}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}const ln={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function cn({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:n(t.value)}),e.jsx("div",{style:{opacity:.7,fontSize:11},children:n(t.time)})]})}const un=t.forwardRef(function(n,o){var i,r,s,a,l,c,u,d,h,p,f;const{chartType:y,runtimeMode:b,data:x,chunkThreshold:w,chunkSize:j,xAccessor:A,yAccessor:O,colorAccessor:S,sizeAccessor:C,groupAccessor:M,lineDataAccessor:_,curve:P,normalize:L,binSize:B,valueAccessor:N,arrowOfTime:T="right",windowMode:I="sliding",windowSize:H=200,timeAccessor:F,xExtent:R,yExtent:z,extentPadding:W=.1,scalePadding:$,sizeRange:D,size:E=[500,300],responsiveWidth:Y,responsiveHeight:G,margin:q,className:X,background:V,lineStyle:U,pointStyle:Q,areaStyle:K,barStyle:J,waterfallStyle:Z,swarmStyle:ee,barColors:te,colorScheme:oe,boundsAccessor:ie,boundsStyle:re,y0Accessor:se,gradientFill:ce,lineGradient:ue,areaGroups:de,openAccessor:he,highAccessor:ge,lowAccessor:pe,closeAccessor:fe,candlestickStyle:be,showAxes:xe=!0,axes:ke,xLabel:we,yLabel:je,yLabelRight:Ae,xFormat:Oe,yFormat:Se,tickFormatTime:Ce,tickFormatValue:Me,hoverAnnotation:_e,tooltipContent:Pe,customHoverBehavior:Le,customClickBehavior:Be,enableHover:Ne,hoverRadius:Te=30,tooltipMode:Ie,annotations:He,svgAnnotationRules:Fe,showGrid:Re,legend:ze,legendHoverBehavior:We,legendClickBehavior:$e,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Ye,backgroundGraphics:Ge,foregroundGraphics:qe,canvasPreRenderers:Xe,svgPreRenderers:Ve,title:Ue,categoryAccessor:Qe,brush:Ke,onBrush:Je,decay:Ze,pulse:tt,transition:nt,animate:st,staleness:at,heatmapAggregation:ct,heatmapXBins:ut,heatmapYBins:dt,showValues:ht,heatmapValueFormat:gt,marginalGraphics:pt,pointIdAccessor:ft,xScaleType:yt,yScaleType:kt,accessibleTable:At=!0,description:Ot,summary:St,linkedCrosshairName:Ct,linkedCrosshairSourceId:Mt}=n,_t=t.useRef(!1),Pt=Tt({sizeProp:E,responsiveWidth:Y,responsiveHeight:G,userMargin:q,marginDefault:rn,animate:st,transitionProp:nt,themeDirtyRef:_t}),{reducedMotionRef:Lt,responsiveRef:Bt,size:Nt,currentTheme:Ht,transition:Ft,introEnabled:Rt,tableId:zt,rafRef:Wt,renderFnRef:$t,scheduleRender:Dt}=Pt;let Et=Pt.margin;if(pt){const e=60,t=Object.assign({},Pt.margin);pt.top&&e>t.top&&(t.top=e),pt.bottom&&e>t.bottom&&(t.bottom=e),pt.left&&e>t.left&&(t.left=e),pt.right&&e>t.right&&(t.right=e),Et=t}const Yt="function"==typeof qe?qe({size:Nt,margin:Et}):qe,Gt="function"==typeof Ge?Ge({size:Nt,margin:Et}):Ge,qt=Nt[0]-Et.left-Et.right,Xt=Nt[1]-Et.top-Et.bottom,Vt=null!=_e?_e:Ne,Ut=t.useRef(null),Qt=t.useRef(null),[Kt,Zt]=t.useState(0),[en,tn]=t.useState(null),ln=t.useRef(null),un=t.useRef(null),[dn,hn]=t.useState(null),gn=t.useRef(sn.primary),[pn,fn]=t.useState(!1),[yn,mn]=t.useState([]),[vn,bn]=t.useState([]),xn="streaming"===b||["bar","swarm","waterfall"].includes(y),kn=t.useMemo(()=>{var e,t,n;return{chartType:y,runtimeMode:xn?"streaming":"bounded",windowSize:H,windowMode:I,arrowOfTime:xn?T:"right",extentPadding:W,scalePadding:$,xAccessor:xn?void 0:A,yAccessor:xn?void 0:O,timeAccessor:xn?F:void 0,valueAccessor:N,colorAccessor:S,sizeAccessor:C,groupAccessor:M||(_?"_lineGroup":void 0),categoryAccessor:Qe,lineDataAccessor:_,xScaleType:yt,yScaleType:kt,xExtent:R,yExtent:z,sizeRange:D,binSize:B,normalize:L,boundsAccessor:ie,boundsStyle:re,y0Accessor:se,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:de?new Set(de):void 0,lineGradient:ue,openAccessor:he,highAccessor:ge,lowAccessor:pe,closeAccessor:fe,candlestickStyle:be,lineStyle:U,pointStyle:Q,areaStyle:K,swarmStyle:ee,waterfallStyle:Z,colorScheme:oe,barColors:te,barStyle:J,annotations:He,decay:Ze,pulse:tt,transition:Ft,introAnimation:Rt,staleness:at,heatmapAggregation:ct,heatmapXBins:ut,heatmapYBins:dt,showValues:ht,heatmapValueFormat:gt,pointIdAccessor:ft,curve:P,themeCategorical:null===(e=null==Ht?void 0:Ht.colors)||void 0===e?void 0:e.categorical,themeSemantic:k(Ht),themeSequential:null===(t=null==Ht?void 0:Ht.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(n=null==Ht?void 0:Ht.colors)||void 0===n?void 0:n.diverging}},[y,H,I,T,W,$,A,O,F,N,yt,kt,S,C,M,Qe,_,R,z,D,B,L,ie,re,se,ce,ue,de,he,ge,pe,fe,be,U,Q,K,ee,Z,J,oe,te,He,Ze,tt,null==Ft?void 0:Ft.duration,null==Ft?void 0:Ft.easing,Rt,at,ct,ut,dt,ht,gt,xn,ft,P,Ht]),wn=t.useRef(null);wn.current||(wn.current=new ne(kn)),t.useEffect(()=>{var e;null===(e=wn.current)||void 0===e||e.updateConfig(kn),_t.current=!0,Dt()},[kn,Dt]);const jn=t.useRef(null);jn.current||(jn.current=new v(e=>{const t=wn.current;t&&t.ingest(e)&&(_t.current=!0,Dt())},{chunkThreshold:w,chunkSize:j})),t.useEffect(()=>{var e;null===(e=jn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:w,chunkSize:j})},[w,j]);const An=t.useCallback(e=>{var t;null===(t=jn.current)||void 0===t||t.push(e)},[]),On=t.useCallback(e=>{var t;null===(t=jn.current)||void 0===t||t.pushMany(e)},[]),Sn=t.useCallback(()=>{var e,t;null===(e=jn.current)||void 0===e||e.clear(),null===(t=wn.current)||void 0===t||t.clear(),_t.current=!0,Dt()},[Dt]);t.useImperativeHandle(o,()=>({push:An,pushMany:On,remove:e=>{var t,n,o;null===(t=jn.current)||void 0===t||t.flush();const i=null!==(o=null===(n=wn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return i.length>0&&(ln.current&&i.some(e=>{var t;return e===(null===(t=ln.current)||void 0===t?void 0:t.data)})&&(ln.current=null,hn(null)),_t.current=!0,Dt()),i},update:(e,t)=>{var n,o,i;null===(n=jn.current)||void 0===n||n.flush();const r=null!==(i=null===(o=wn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==i?i:[];return r.length>0&&(_t.current=!0,Dt()),r},clear:Sn,getData:()=>{var e,t,n;return null===(e=jn.current)||void 0===e||e.flush(),null!==(n=null===(t=wn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=wn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=wn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[An,On,Sn,Dt]),t.useEffect(()=>{var e,t;if(x){if(_&&x.length>0&&"object"==typeof x[0]&&null!==x[0]){const t="string"==typeof _?_:"coordinates";if(Array.isArray(x[0][t])){const n=[];for(const e of x){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=jn.current)||void 0===e||e.setBoundedData(n))}}null===(t=jn.current)||void 0===t||t.setBoundedData(x)}},[x,_]);const{hoverHandlerRef:Cn,hoverLeaveRef:Mn,onPointerMove:_n,onPointerLeave:Pn}=Pt;Cn.current=e=>{if(!Vt)return;const t=Ut.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Et.left,i=e.clientY-n.top-Et.top;if(0>o||o>qt||0>i||i>Xt)return void(ln.current&&(ln.current=null,un.current=null,hn(null),Le&&(Le(null),_t.current=!0),Dt()));const r=wn.current;if(!r||0===r.scene.length)return;const s=ae(r.scene,o,i,Te,r.quadtree,r.maxPointRadius);if(!s)return void(ln.current&&(ln.current=null,un.current=null,hn(null),Le&&Le(null),Dt()));const a=Jt(s.datum||{},s.x,s.y);if("multi"===Ie&&r.scene.length>0&&r.scales){const e=function(e,t,n=30){const o=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const r=le(e.path,t,n);if(null===r)continue;const s=ye(e.path,t);o.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:r,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const r=le(e.topPath,t,n);if(null===r)continue;const s=ye(e.topPath,t);o.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.topPath[s][0],y:r,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(r.scene,s.x,Te),t=r.scales.y.invert,n=r.scales.x.invert;if(e.length>0){const o=n?n(s.x):s.x;a.xValue=o,a.xPx=s.x;const i=gn.current;a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||i,datum:e.datum}))}}ln.current=a,un.current=s.node,hn(a),Le&&(Le(a),_t.current=!0),Dt()},Mn.current=()=>{ln.current&&(ln.current=null,un.current=null,hn(null),Le&&(Le(null),_t.current=!0),Dt())};const Ln=t.useRef(()=>{});Ln.current=e=>{if(!Be)return;const t=Ut.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Et.left,i=e.clientY-n.top-Et.top;if(0>o||o>qt||0>i||i>Xt)return void Be(null);const r=wn.current;if(!r||0===r.scene.length)return void Be(null);const s=ae(r.scene,o,i,Te,r.quadtree,r.maxPointRadius);Be(s?Jt(s.datum||{},s.x,s.y):null)};const Bn=t.useCallback(e=>Ln.current(e),[]),Nn=t.useRef(-1),Tn=t.useRef(null),In=t.useRef(null),Hn=t.useCallback(e=>{const t=wn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(In.current&&In.current.version===n)o=In.current.graph;else{const e=function(e){var t,n,o,i;const r=[];for(const s of e)switch(s.type){case"point":r.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(t=s.group)&&void 0!==t?t:"_default"});break;case"line":{const e=s,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)r.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:o});break}case"area":{const e=s,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)r.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});break}case"rect":r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(i=s.group)&&void 0!==i?i:"_default"});break;case"heatcell":r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:"_default"})}return r.sort((e,t)=>e.x-t.x||e.y-t.y),r}(t.scene);if(0===e.length)return;o=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let i=o.get(e);i||(i=[],o.set(e,i)),i.push(n)}for(const e of o.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 i=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),i=o.get(t);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(o.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=null===(n=r[e].datum)||void 0===n?void 0:n.id;null!=t&&s.set(t+"",e)}return{flat:r,groups:i,byGroup:o,idToIdx:s}}(e),In.current={version:n,graph:o}}const i=Nn.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Nn.current=0;const t=o.flat[0];Tn.current={shape:t.shape,w:t.w,h:t.h};const n=ve(t);return ln.current=n,hn(n),Le&&Le(n),void Dt()}const r=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[i];return{flatIndex:i,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=r._groupIndex)&&void 0!==o?o:0}}(o,i),s=function(e,t,n){const{group:o,indexInGroup:i}=t,r=n.byGroup.get(o);switch(e){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?me(n,n.groups[e+1],r[i]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?me(n,n.groups[e-1],r[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(e.key,r,o);if(null===s)return;if(e.preventDefault(),0>s)return Nn.current=-1,Tn.current=null,ln.current=null,un.current=null,hn(null),Le&&Le(null),void Dt();Nn.current=s;const a=o.flat[s];Tn.current={shape:a.shape,w:a.w,h:a.h};const l=ve(a);ln.current=l,hn(l),Le&&Le(l),Dt()},[Le,Dt]),Fn=t.useCallback(e=>{Nn.current=-1,Tn.current=null,_n(e)},[_n]);$t.current=()=>{var e,t;Wt.current=0;const n=Ut.current,o=Qt.current;if(!n||!o)return;const i=wn.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(Lt.current?r+1e6:r),a=!Lt.current&&s,l=_t.current||s;l&&!a&&i.computeScene({width:qt,height:Xt});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return sn;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=t.getPropertyValue("--semiotic-primary").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||sn.axisStroke,tickText:s||sn.tickText,crosshair:s?an(s,"66"):sn.crosshair,hoverFill:c?an(c,"4D"):sn.hoverFill,hoverStroke:s?an(s,"99"):sn.hoverStroke,pointRing:c||sn.pointRing,primary:r||sn.primary}:sn}(n);gn.current=u.primary;const d=null!==(e=null==at?void 0:at.threshold)&&void 0!==e?e:5e3,h=at&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const e=It(n,Nt,Et,c);if(e){if(e.clearRect(-Et.left,-Et.top,Nt[0],Nt[1]),h&&(e.globalAlpha=null!==(t=null==at?void 0:at.dimOpacity)&&void 0!==t?t:.5),"transparent"!==V&&!Ge){const t=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=V||(t&&"transparent"!==t?t:null);o&&(e.fillStyle=o,e.fillRect(-Et.left,-Et.top,Nt[0],Nt[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,qt,Xt),e.clip()),Xe&&i.scales)for(const t of Xe)e.save(),t(e,i.scene,i.scales,{width:qt,height:Xt}),e.restore();const o=on[y];if(o&&i.scales)for(const t of o)t(e,i.scene,i.scales,{width:qt,height:Xt});e.restore(),h&&(e.globalAlpha=1)}}{const e=It(o,Nt,Et,c);if(e&&(e.clearRect(-Et.left,-Et.top,Nt[0],Nt[1]),Vt&&ln.current&&i.scales&&function(e,t,n,o,i,r,s){var a;if(!1===i.crosshair)return;const l=t.allSeries,c=l&&l.length>0,u=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(e.strokeStyle=d.stroke||s.crosshair,e.lineWidth=d.strokeWidth||1,e.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?u:t.x,0),e.lineTo(c?u:t.x,o),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 l)null!=t.valuePx&&(e.beginPath(),e.arc(u,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=i.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}(r)||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,ln.current,qt,Xt,"object"==typeof Vt?Vt:{},un.current,u),un.current&&Array.isArray(_e))){const t=_e.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,i){var r;if(!n)return;const s=n.group;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||i.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,i.scene,un.current,t,u)}}l&&n&&n.setAttribute("aria-label",lt(i.scene,y+" chart"));const g=_t.current;if(_t.current=!1,g&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!en||e(en.x.domain()[0])!==e(i.scales.x.domain()[0])||e(en.x.domain()[1])!==e(i.scales.x.domain()[1])||e(en.y.domain()[0])!==e(i.scales.y.domain()[0])||e(en.y.domain()[1])!==e(i.scales.y.domain()[1])||en.x.range()[0]!==i.scales.x.range()[0]||en.x.range()[1]!==i.scales.x.range()[1]||en.y.range()[0]!==i.scales.y.range()[0]||en.y.range()[1]!==i.scales.y.range()[1])&&tn(i.scales),pt){const e=i.getData(),t="function"==typeof A?A:e=>e[A||"x"],n="function"==typeof O?O:e=>e[O||"y"];mn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),bn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&He&&He.length>0&&Zt(e=>e+1),(null==at?void 0:at.showBadge)&&fn(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Wt.current=requestAnimationFrame(()=>$t.current()))},t.useEffect(()=>(Dt(),()=>{var e;null===(e=jn.current)||void 0===e||e.clear()}),[Dt]),t.useEffect(()=>{_t.current=!0,Dt()},[y,qt,Xt,xe,V,U,Xe,Dt]),function(e,n,o,i,r,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-a.lastIngestTime>c;u!==r&&(s(u),o.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}(at,wn,_t,Dt,pn,fn);const Rn=t.useMemo(()=>{if(Oe||Ce)return;const e=wn.current;return(null==e?void 0:e.xIsDate)&&en?nn(en.x.domain()):void 0},[Oe,Ce,en]),zn=Oe||Ce||Rn,Wn=Vt&&dn?Pe?Pe(dn):e.jsx(cn,{hover:dn}):null,$n=Wn?e.jsx(jt,{x:dn.x,y:dn.y,containerWidth:qt,containerHeight:Xt,margin:Et,className:"stream-frame-tooltip",children:Wn}):null,Dn=Tn.current,En=e.jsx(wt,{active:Nn.current>=0,hoverPoint:dn,margin:Et,size:Nt,shape:null==Dn?void 0:Dn.shape,width:null==Dn?void 0:Dn.w,height:null==Dn?void 0:Dn.h}),Yn=(e,t,n,o)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null},Gn=Yn(A,F,"__semiotic_resolvedX","__semiotic_resolvedTime"),qn=Yn(O,N,"__semiotic_resolvedY","__semiotic_resolvedValue"),Xn=Gn.key,Vn=qn.key,Un=He&&He.length>0,Qn=e=>{if(!e||!Un||!Gn.fn&&!qn.fn)return e;let t=!1;const n=e.map(e=>{const n=Gn.fn&&Gn.key&&!(Gn.key in e),o=qn.fn&&qn.key&&!(qn.key in e);if(!n&&!o)return e;t=!0;const i=Object.assign({},e);return n&&(i[Gn.key]=Gn.fn(e)),o&&(i[qn.key]=qn.fn(e)),i});return t?n:e};if(rt){const t=wn.current;t&&x&&(t.ingest({inserts:x,bounded:!0}),t.computeScene({width:qt,height:Xt}));const n=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],o=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,s=zn||(()=>{if((null==t?void 0:t.xIsDate)&&o)return nn(o.x.domain())})();return e.jsxs("div",{className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":Ot||("string"==typeof Ue?Ue:"XY chart"),style:{position:"relative",width:Nt[0],height:Nt[1]},children:[e.jsx(vt,{summary:St}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Nt[0],height:Nt[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Et.left},${Et.top})`,children:Gt}),e.jsxs("g",{transform:`translate(${Et.left},${Et.top})`,children:[V&&e.jsx("rect",{x:0,y:0,width:qt,height:Xt,fill:V}),Ve&&o&&Ve.map((t,i)=>e.jsx(g.Fragment,{children:t(n,o,{width:qt,height:Xt})},"svgpre-"+i)),n.map((t,n)=>function(t,n){var o,i,r;switch(t.type){case"line":{const o=t;if(0===o.path.length)return null;const i="M"+o.path.map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+n)}case"area":{const r=t;if(0===r.topPath.length)return null;const s=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:`M${s}L${a}Z`,fill:it(r.style.fill),fillOpacity:null!==(i=null!==(o=r.style.fillOpacity)&&void 0!==o?o:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+n)}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:it(o.style.fill),opacity:null!==(r=o.style.opacity)&&void 0!==r?r:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+n)}case"rect":{const o=t;return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:it(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+n)}case"heatcell":{const o=t;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const t=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[i,r,s]=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]}(o.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e.jsxs("g",{children:[e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),e.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:t})]},"heatcell-"+n)}return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+n)}case"candlestick":{const o=t,i=Math.min(o.openY,o.closeY),r=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return e.jsxs("g",{children:[e.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),e.jsx("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}(t,n)).filter(Boolean)]})]}),e.jsx(ot,{width:qt,height:Xt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Et,scales:o,showAxes:xe,axes:ke,xLabel:we,yLabel:je,yLabelRight:Ae,xFormat:s,yFormat:Se||Me,showGrid:Re,title:Ue,legend:ze,legendHoverBehavior:We,legendClickBehavior:$e,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Ye,foregroundGraphics:Yt,marginalGraphics:pt,xValues:[],yValues:[],annotations:He,svgAnnotationRules:Fe,annotationFrame:0,xAccessor:Xn,yAccessor:Vn,annotationData:Qn(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,linkedCrosshairName:Ct,linkedCrosshairSourceId:Mt})]})}return e.jsxs("div",{ref:Bt,className:"stream-xy-frame"+(X?" "+X:""),role:"group","aria-label":Ot||("string"==typeof Ue?Ue:"XY chart"),tabIndex:0,style:{position:"relative",width:Y?"100%":Nt[0],height:G?"100%":Nt[1],overflow:"visible"},onKeyDown:Hn,children:[At&&e.jsx(bt,{tableId:zt}),At&&e.jsx(mt,{scene:null!==(a=null===(s=wn.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:y+" chart",tableId:zt,chartTitle:"string"==typeof Ue?Ue:void 0}),e.jsx(vt,{summary:St}),e.jsxs("div",{role:"img","aria-label":Ot||("string"==typeof Ue?Ue:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Vt?Fn:void 0,onMouseLeave:Vt?Pn:void 0,onClick:Be?Bn:void 0,children:[Gt&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Nt[0],height:Nt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Et.left},${Et.top})`,children:Gt})}),e.jsx(et,{width:qt,height:Xt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Et,scales:en,showAxes:xe,axes:ke,showGrid:Re,xFormat:zn,yFormat:Se||Me}),e.jsx("canvas",{ref:Ut,"aria-label":lt(null!==(c=null===(l=wn.current)||void 0===l?void 0:l.scene)&&void 0!==c?c:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:Qt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(xt,{hoverPoint:dn}),e.jsx(ot,{width:qt,height:Xt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Et,scales:en,showAxes:xe,axes:ke,xLabel:we,yLabel:je,yLabelRight:Ae,xFormat:zn,yFormat:Se||Me,showGrid:Re,title:Ue,legend:ze,legendHoverBehavior:We,legendClickBehavior:$e,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Ye,foregroundGraphics:Yt,marginalGraphics:pt,xValues:yn,yValues:vn,annotations:He,svgAnnotationRules:Fe,annotationFrame:Kt,xAccessor:Xn,yAccessor:Vn,annotationData:Qn(null===(u=wn.current)||void 0===u?void 0:u.getData()),pointNodes:null===(d=wn.current)||void 0===d?void 0:d.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,underlayRendered:!0,linkedCrosshairName:Ct,linkedCrosshairSourceId:Mt}),(Ke||Je)&&e.jsx(m,{width:qt,height:Xt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Et,dimension:null!==(h=null==Ke?void 0:Ke.dimension)&&void 0!==h?h:"xy",scales:en,onBrush:null!=Je?Je:()=>{},binSize:B,snap:null==Ke?void 0:Ke.snap,binBoundaries:null!==(p=null==Ke?void 0:Ke.binBoundaries)&&void 0!==p?p:"bar"===y?null===(f=wn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==Ke?void 0:Ke.snapDuring,streaming:"streaming"===b}),(null==at?void 0:at.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===at.badgePosition?{top:4,left:4}:"bottom-left"===at.badgePosition?{bottom:4,left:4}:"bottom-right"===at.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:pn?"#dc3545":"#28a745",color:"white"}),children:pn?"STALE":"LIVE"}),En,$n]})]})});un.displayName="StreamXYFrame";const dn=t.createContext(null);function hn(){return t.useContext(dn)}function gn(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function pn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[fn,yn]=b(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=pn(o,t),r=new Map(i.clauses);return r.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),r=new Map(o.clauses);return r.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=pn(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[mn,vn]=b(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 bn(e){const n=t.useId(),o=e.clientId||n,{name:i}=e,r=yn(e=>e.selections.get(i)),s=yn(e=>e.setClause),a=yn(e=>e.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(gn(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,o):()=>!0,[r,o]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(i,{clientId:o,type:"point",fields:t})},[o,i,s]),selectInterval:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(i,{clientId:o,type:"interval",fields:t})},[o,i,s]),clear:t.useCallback(()=>{a(i,o)},[a,i,o]),clientId:o}}function xn(e){const n=e.name||"hover",{fields:o}=e,{predicate:i,isActive:r,selectPoints:s,clear:a}=bn({name:n});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:i,isActive:r}}function kn(e){const{name:n,xField:o,yField:i}=e,{predicate:r,isActive:s,selectInterval:a,clear:l}=bn({name:n}),c=o&&i?"xyBrush":o?"xBrush":"yBrush",u=t.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,o,i,a,l]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:l}}const wn=t.createContext(!1);function jn({selections:e}){const n=yn(e=>e.setResolution);return t.useEffect(()=>{for(const[t,o]of Object.entries(e))o.resolution&&n(t,o.resolution)},[e,n]),null}function An({categoryColors:n,interaction:o,selectionName:i,field:r}){const s=Object.entries(n);if(0===s.length)return null;const a=s.map(([e])=>e),l=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:s.map(([e,t])=>({label:e,color:t})),label:""}],c=xn({name:i,fields:[r]}),u=bn({name:i,clientId:"__linked-legend-isolate__"}),[d,h]=t.useState(new Set),[g,p]=t.useState(null),f=t.useRef(u.selectPoints);f.current=u.selectPoints;const y=t.useRef(u.clear);y.current=u.clear,t.useEffect(()=>{"isolate"===o&&(d.size>0?f.current({[r]:Array.from(d)}):y.current())},[o,d,r]);const m=t.useCallback(e=>{"highlight"===o&&(e?(p(e.label),c.onHover({[r]:e.label})):(p(null),c.onHover(null)))},[o,r,c]),v=t.useCallback(e=>{"isolate"===o&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===a.length?new Set:n})},[o,a.length]),[b,[x]]=At([0,0],!0,!1),k=t.useMemo(()=>function(e,t){if(!t||0===e.length)return 1;let n=0,o=1;for(const i of e){const e=26+7*i.length;n>0&&n+e>t&&(o++,n=0),n+=e}return o}(s.map(([e])=>e),x),[s,x]);return e.jsx("div",{ref:b,style:{width:"100%",display:"block"},children:e.jsx("svg",{width:"100%",height:Math.max(30,22*k+8),style:{display:"block",overflow:"visible"},children:e.jsx(Oe,{legendGroups:l,title:!1,orientation:"horizontal",width:x,height:20,customHoverBehavior:"highlight"===o?m:void 0,customClickBehavior:"isolate"===o?v:void 0,highlightedCategory:g,isolatedCategories:d})})})}function On({children:t,selections:n,showLegend:o,legendPosition:i="top",legendInteraction:r="none",legendSelectionName:s="legend",legendField:a="category"}){const l=hn(),c=void 0!==o?o:!(!l||0>=Object.keys(l).length);return e.jsx(fn,{children:e.jsxs(mn,{children:[n&&e.jsx(jn,{selections:n}),e.jsxs(wn.Provider,{value:c,children:[c&&"top"===i&&l&&e.jsx(An,{categoryColors:l,interaction:r,selectionName:s,field:a}),t,c&&"bottom"===i&&l&&e.jsx(An,{categoryColors:l,interaction:r,selectionName:s,field:a})]})]})})}function Sn({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((i,r)=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),a=s?o(s,t,n):n?n(i):R[r%R.length];return{label:i+"",color:a}}),label:""}]}}function Cn(e){return e?"string"==typeof e?{name:e}:e:null}function Mn(e,t,n){return t?o=>{var i;const r=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(r,n.selectedStyle);else{const e=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.5;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle)}return r}:e}function _n(){return M(e=>e.theme)}g.createContext(void 0);const Pn="#007bff";function Ln(){var e;const t=_n(),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function Bn(e,n,o){const i=hn(),r=Ln();return t.useMemo(()=>{var t;if(!n)return;const s=null!==(t=null!=o?o:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof n){const t=Array.from(new Set(e.map(e=>n(e)+"")));if(i&&Object.keys(i).length>0){const e=$(t.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return $(t.map(e=>({_cat:e})),"_cat",s)}if(i&&Object.keys(i).length>0){const t=$(e,n,s);return e=>i[e]||t(e)}return $(e,n,s)}if(i&&Object.keys(i).length>0){const e=$([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,n,o,i,r])}function Nn({selection:e,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(n,o),g=bn({name:(null==e?void 0:e.name)||"__unused__"}),p=xn({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),f=vn(e=>e.pushObservation),y=e?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=t.useState(null),b=u||o[0],x=t.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),k=t.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=De.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(De={positions:new Map(De.positions).set(e,{xValue:t,sourceId:n})},Ye())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&p.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Ge(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&p.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(r||f){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(s),f&&f(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(e),f&&f(e)}}},[n,p,h,d,r,s,a,f,c,b]),w=t.useCallback(e=>{var t,n,o,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=De.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(De.positions);return t.delete(e),De={positions:t},Ye(),!1}De={positions:new Map(De.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ye()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(r||f){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(s),f&&f(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),f&&f(e)}}},[l,r,f,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{qe(e,d),Ge(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function Tn(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function In({data:e,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(wn),u=void 0!==i?i:!c&&!!n,d=t.useMemo(()=>{if(!u||!n)return;const t=Sn({data:e,colorBy:n,colorScale:o,getColor:W,categories:l});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[u,n,e,o,l]),h=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=Object.assign(Object.assign({},a),e);return d&&("right"===r&&110>t.right?t.right=110:"left"===r&&110>t.left?t.left=110:"top"===r&&50>t.top?t.top=50:"bottom"===r&&80>t.bottom&&(t.bottom=80)),t},[a,s,d,r]);return{legend:d,margin:h,legendPosition:r}}function Hn(e,n,o){const[i,r]=t.useState(null),[s,a]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&r(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&a(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),u=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=t?e[t]:"function"==typeof n?n(e):null;return s.has(o)}}:null},[e,n,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const Fn={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}}};function Rn(e,t,n){var o,i,r,s,a,l,c;const u=Fn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(i=t.height)&&void 0!==i?i:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(r=t.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:zn(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function zn(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Wn(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}const $n={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Dn(e,t){return"function"==typeof t?t(e):e[t]}function En(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Yn(t={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=Dn(t,o);a=En(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const s=Dn(t,o);l.push({label:n,value:En(s,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=En(t[n],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=En(t[e[0]],i))}}const c=Object.assign(Object.assign({},$n),r);return e.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((t,n)=>e.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},n))]})}}function Gn(t){if(!0===t)return Yn();if("function"==typeof t){const n=t;return t=>{const o=n(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==o?null:e.jsx("div",{className:"semiotic-tooltip",style:$n,children:o})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Yn(t):Yn())}function qn(e){return"string"==typeof e?e:"value"}function Xn(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Vn(e,t){if(!t)return Xn(e);try{const n=t(e);return null==n?Xn(e):n}catch(t){return Xn(e)}}function Un(e,t){return"function"==typeof t?t(e):e[t]}function Qn(t){const n=t.find(e=>"title"===e.role),o=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=n?Vn(Un(i,n.accessor),n.format):null;return e.jsxs("div",{className:"semiotic-tooltip",style:$n,children:[null!=r&&e.jsx("div",{style:{fontWeight:"bold",marginBottom:o.length>0?4:0},children:r}),o.map((t,n)=>{const o=Vn(Un(i,t.accessor),t.format);return e.jsxs("div",{style:n>0?{marginTop:2}:void 0,children:[e.jsxs("span",{style:{opacity:.7},children:[t.label,": "]}),e.jsx("span",{children:o})]},n)})]})}}function Kn({componentName:t,message:n,diagnosticHint:o,width:i,height:r}){return e.jsx("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&e.jsx("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class Jn extends g.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.jsx(Kn,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Zn(e,t){const n=e.length,o=t.length,i=Array(o+1);for(let e=0;o>=e;e++)i[e]=e;for(let r=1;n>=r;r++){let n=i[0];i[0]=r;for(let s=1;o>=s;s++){const o=i[s];i[s]=e[r-1]===t[s-1]?n:1+Math.min(n,i[s],i[s-1]),n=o}}return i[o]}function eo(e,t,n=3){let o,i=n+1;for(const n of t){const t=Zn(e.toLowerCase(),n.toLowerCase());i>t&&(i=t,o=n)}return i>n?void 0:o}function to(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function no(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=eo(e,t,3))&&void 0!==n?n:null)}function oo({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=to(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[i,r]of Object.entries(n))if(r&&"string"==typeof r&&!(r in o)){const n=no(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const io={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},ro={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},so={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},ao=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],lo=["vertical","horizontal"],co={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ao},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ao},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ao},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},CandlestickChart:{required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},highAccessor:{type:["string","function"]},lowAccessor:{type:["string","function"]},openAccessor:{type:["string","function"]},closeAccessor:{type:["string","function"]},candlestickStyle:{type:"object"},mode:{type:"string",enum:["primary","context","sparkline"]},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},io),ro),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:lo},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:lo},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},io),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},io),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},io),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},io),so),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},io),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},io),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:lo},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},io),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},io),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},io),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},io),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},io),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},io),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},io),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},io),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},io),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},io),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},io),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function uo(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const ho=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),go=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),po=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),fo=new Set(["LineChart","AreaChart","StackedAreaChart"]),yo=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function mo(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,i]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],r=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*r(n)+.7152*r(o)+.0722*r(i)}function vo(e,t){const n=mo(e),o=mo(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const bo=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function xo(e,t){const n=[],o=function(e,t){const n=[],o=co[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(co).join(", ")}`]};for(const i of o.required)null==t[i]&&n.push(`"${i}" is required for ${e}.`);for(const[e,i]of Object.entries(t)){if(null==i)continue;const t=o.props[e];if(t){if(!uo(i,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&n.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const i=Object.keys(o.props),r=new Set(i);for(const o of Object.keys(t))if(void 0!==t[o]&&!r.has(o)){const t=eo(o,i),r=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${i.join(", ")}.`;n.push(r)}if("array"===o.dataShape){const i=t.data,r={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(r[e]=n)}const s=oo({componentName:e,data:i,accessors:Object.keys(r).length>0?r:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const i=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:i=!0,accessors:r}){if(null==t&&null==n)return null;if(i&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(r&&t&&t.length>0){const n=to(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in n)){const n=no(i,t),r=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${i}" not found in node data. Available fields: ${t.join(", ")}.${r}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});i&&n.push(i)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return co[e]?(function(e,t,n){const o=co[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,i=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===i||"number"==typeof i&&i>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(i)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=co[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=Object.keys(r);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in r||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){ho.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){go.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=co[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=t.xAccessor;"string"==typeof s&&r[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!po.has(e))return;const i=t.rExtent||t.yExtent;i&&Array.isArray(i)&&i.length>=1&&null!=i[0]&&0!==i[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${i[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=i[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!fo.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=t.yAccessor||"y";"string"==typeof i&&o.some(e=>{const t=e[i];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${i}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,i;const r=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(i=t.height)&&void 0!==i?i:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);r>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const i=co[e];if(!i||"array"!==i.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(r.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const i=null===(o=r[n])||void 0===o?void 0:o[e.name];if("number"==typeof i&&Number.isFinite(i)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!yo.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const i=o.bottom;"number"==typeof i&&70>i&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${i}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const i=t.margin;if(!i||"object"!=typeof i)return;const r=i.right;"number"==typeof r&&100>r&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${r}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(i&&"object"==typeof i)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const r=i[o];"string"==typeof r&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${r}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;const r=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=vo(e,i);null!==t&&3>t&&r.push(`${e} (${t.toFixed(1)}:1)`)}r.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${r.length} color(s) in colorScheme have < 3:1 contrast against background "${i}": ${r.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const i=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>i.length)return;const r=[];for(let e=0;i.length-1>e;e++){const t=vo(i[e],i[e+1]);null!==t&&1.5>t&&r.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}r.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${r.length} adjacent color pair(s) in colorScheme have very similar luminance: ${r.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,i="string"==typeof t.description&&t.description.trim().length>0,r="string"==typeof t.summary&&t.summary.trim().length>0;o||i||r||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of bo)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var ko;const wo="undefined"!=typeof process&&"production"!==(null===(ko=process.env)||void 0===ko?void 0:ko.NODE_ENV);function jo({componentName:t,width:n,height:o,chartProps:i,children:r}){return e.jsx(Jn,{fallback:r=>{let s="";if(wo&&i)try{const e=xo(t,i);e.ok||(s=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.jsx(Kn,{componentName:t,message:r.message,diagnosticHint:s,width:n,height:o})},children:r})}const Ao={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Oo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function So(t,n,o,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},Ao),{width:n,height:o}),children:i||"No data available"}):null}function Co(t,n,o){if(!t)return null;const i=Math.min(5,Math.floor(o/40)),r=Math.max(8,Math.floor(o/(3*i))),s=Math.max(6,Math.floor(o/(2.5*i))),a=Math.floor((o-(i*(r+s)-s))/2);return e.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,o)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Oo),{position:"absolute",top:a+o*(r+s),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:r,opacity:.5+o%2*.2})},o))})}function Mo(e,t,n,o){if(!wo)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const i=t[0];if(!i||"object"!=typeof i)return;if(o in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${r}`)}function _o(e){const n=M(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,o;if(void 0!==e||void 0!==n)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:n})},[e,n])}function Po(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Lo="__forecastSegment";let Bo=null;function No(){return Po(this,void 0,void 0,function*(){return Bo||(Bo=yield Promise.resolve().then(function(){return di})),Bo})}const To=t.forwardRef(function(n,o){var i,r;const s=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=s.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const a=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable,xLabel:n.xLabel,yLabel:n.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,xAccessor:g="x",yAccessor:p="y",lineBy:f,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:j=.3,lineWidth:A=2,lineGradient:O,tooltip:S,pointIdAccessor:C,annotations:M,directLabel:_,gapStrategy:P="break",anomaly:L,forecast:B,frameProps:N={},selection:T,linkedHover:I,onObservation:H,onClick:F,hoverHighlight:R,hoverRadius:z,chartId:$,loading:D,emptyContent:E,legendInteraction:Y,legendPosition:G,xScaleType:q,yScaleType:X,color:V,stroke:U,strokeWidth:Q,opacity:K}=n,J=a.width,Z=a.height,ee=a.enableHover,te=a.showGrid,ne=a.showLegend,oe=a.title,ie=a.description,re=a.summary,se=a.accessibleTable,ae=a.xLabel,le=a.yLabel,ce=Co(D,J,Z),ue=ce?null:So(l,J,Z,E),de=l||[];Mo("LineChart",de,"xAccessor",g),Mo("LineChart",de,"yAccessor",p);const he="string"==typeof g?g:"__semiotic_resolvedX",ge="string"==typeof p?p:"__semiotic_resolvedY",[pe,fe]=t.useState(null),[ye,me]=t.useState([]),ve=t.useMemo(()=>{if(!B&&!L)return de;const e="function"==typeof g,t="function"==typeof p;return e||t?de.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=g(n)),t&&(o.__semiotic_resolvedY=p(n)),o}):de},[de,B,L,g,p]),be=t.useRef(B),xe=t.useRef(L);t.useEffect(()=>{if(!B&&!L)return void((be.current||xe.current)&&(fe(null),me([]),be.current=B,xe.current=L));let e=!1;const t=B!==be.current||L!==xe.current;if(be.current=B,xe.current=L,t&&(fe(null),me([])),B){const t=f&&"string"==typeof f&&"object"==typeof B?Object.assign(Object.assign({},B),{_groupBy:f}):B;(function(...e){return Po(this,void 0,void 0,function*(){return(yield No()).buildForecast(...e)})})(ve,he,ge,t,L).then(t=>{e||(fe(t),me(t.annotations))}).catch(()=>{e||(fe(null),me([]))})}else L&&function(...e){return Po(this,void 0,void 0,function*(){return(yield No()).buildAnomalyAnnotations(...e)})}(L).then(t=>{e||(fe(null),me(t))}).catch(()=>{e||me([])});return()=>{e=!0}},[ve,B,L,he,ge]);const ke=pe?pe.processedData:de,we="__compoundGroup",je=!(!B||!f),Ae=je?we:B?Lo:f,Oe=t.useMemo(()=>{if(!je)return ke;const e="function"==typeof f?f:e=>e[f];return ke.map(t=>{const n=Object.assign({},t);return n[we]=`${e(t)}__${t[Lo]||"observed"}`,n})},[ke,je,f]),Se=je?Oe:ke,Ce=t.useMemo(()=>{if(!B)return;const e=B.upperBounds,t=B.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let i=1/0,r=-1/0;const s=pe?pe.processedData:de;for(const e of s){const t="function"==typeof p?p(e):+e[p];if(isFinite(t)&&(i>t&&(i=t),t>r&&(r=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>r&&(r=t),i>t&&(i=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(i>t&&(i=t),t>r&&(r=t))}}return isFinite(i)&&isFinite(r)?[i,r]:void 0},[B,pe,de,p]),{activeSelectionHook:Me,hoverSelectionHook:_e,customHoverBehavior:Pe,customClickBehavior:Le,crosshairSourceId:Be}=Nn({selection:T,linkedHover:I,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:H,onClick:F,chartType:"LineChart",chartId:$,hoverHighlight:R,colorByField:"string"==typeof m?m:void 0}),Ne=_o(T),Te=Tn(I,Be),Ie=t.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof p?p(e):e[p];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,p]),He=void 0!==(null===(i=Se[0])||void 0===i?void 0:i[y]),Fe=t.useMemo(()=>{if(He)return Se;if(Ae){const e=Se.reduce((e,t)=>{const n="function"==typeof Ae?Ae(t):t[Ae];if(!e[n]){const o={[y]:[]};"string"==typeof Ae&&(o[Ae]=n),je&&(o[Lo]=t[Lo],"string"==typeof f&&(o[f]=t[f])),e[n]=o}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Se}]},[Se,Ae,y,He]),{gapProcessedLineData:Re,hasGaps:ze}=t.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const n of Fe){const o=(n[y]||[]).filter(t=>!Ie(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const n of Fe){const o=n[y]||[];let i=[],r=0;const s=Ae&&"string"==typeof Ae?n[Ae]:void 0;for(const a of o)if(Ie(a))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]:i})),i=[],r++);else{const e=null!=s?`${s}__seg${r}`:"__seg"+r;i.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}i.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof p?p:"y",n=[];for(const o of Fe){const i=o[y]||[],r=[];for(const n of i)Ie(n)?(e=!0,r.push(Object.assign(Object.assign({},n),{[t]:0}))):r.push(n);n.push(Object.assign(Object.assign({},o),{[y]:r}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Fe,hasGaps:!1}},[Fe,P,y,Ie,Ae,p]),We=Bn(ke,m,v),$e=t.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ke){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ke,m]),De=Hn(Y,m,$e),Ee=t.useMemo(()=>_e||(De.legendSelectionHook?De.legendSelectionHook:Me),[_e,De.legendSelectionHook,Me]),Ye=t.useMemo(()=>(e,t)=>{const n={strokeWidth:A},o=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return m?We&&(n.stroke=W(e,m,We),o&&(n.fill=n.stroke,n.fillOpacity=j)):(n.stroke=V||Pn,o&&(n.fill=V||Pn,n.fillOpacity=j)),n},[m,We,A,w,j,V]),[Ge,qe]=t.useState(null);t.useEffect(()=>{if(!B)return void qe(null);let e=!1;return function(...e){return Po(this,void 0,void 0,function*(){return(yield No()).createSegmentLineStyle(...e)})}(Ye,B).then(t=>{e||qe(()=>t)}).catch(()=>{e||qe(null)}),()=>{e=!0}},[Ye,B]);const Xe=Ge||Ye,Ve=t.useMemo(()=>Wn(Xe,{stroke:U,strokeWidth:Q,opacity:K}),[Xe,U,Q,K]),Ue=t.useMemo(()=>Mn(Ve,Ee,Ne),[Ve,Ee,Ne]),Qe=t.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?We&&(t.fill=W(e.parentLine||e,m,We)):t.fill=V||Pn,t}},[x,k,m,We,V]),Ke=Array.isArray(w)?"mixed":w?"area":"line",Je="object"==typeof _?_:{},Ze=Je.position||"end",et=Je.fontSize||11,tt=t.useMemo(()=>{var e,t;if(!_||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof p?p:e=>e[p],i="function"==typeof m?m:e=>e[m],r=new Map;for(const n of Re){const o=n[y]||[];if(0===o.length)continue;const s="end"===Ze?o[o.length-1]:o[0],a=null!==(t=null!==(e=i(s))&&void 0!==e?e:i(n))&&void 0!==t?t:"";a&&!r.has(a+"")&&r.set(a+"",s)}const s=Array.from(r.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:n(t),["string"==typeof p?p:"y"]:o(t),dx:"end"===Ze?6:-6,dy:0,color:We?We(e):Pn,fontSize:et}));s.sort((e,t)=>{const n="string"==typeof p?p:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof p?p:"y",n=s[e-1],o=s[e];et+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=et+2)}return s},[_,m,We,Re,y,g,p,Ze,et]),nt=(!_||void 0!==ne)&&ne,ot=t.useMemo(()=>{if(!_)return a.marginDefaults;const e=tt.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*et);return Math.max(e,o)},0),t=e+10,n="end"===Ze?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[n]:Math.max(a.marginDefaults[n]||0,t)})},[_,tt,et,Ze,a.marginDefaults]),{legend:it,margin:rt,legendPosition:st}=In({data:Re,colorBy:m,colorScale:We,showLegend:nt,legendPosition:G,userMargin:c,defaults:ot}),at=f||m,lt=t.useMemo(()=>Qn([{label:ae||qn(g),accessor:g,role:"x",format:d},{label:le||qn(p),accessor:p,role:"y",format:h},...at?[{label:qn(at),accessor:at,role:"group"}]:[]]),[g,p,ae,le,at,d,h]),ct=oo({componentName:"LineChart",data:He?(null===(r=ke[0])||void 0===r?void 0:r[y])||[]:l,accessors:{xAccessor:g,yAccessor:p}}),ut=t.useMemo(()=>He||Ae||ze?Re.flatMap(e=>{const t=e[y]||[];return Ae&&"string"==typeof Ae?t.map(t=>Object.assign(Object.assign({},t),{[Ae]:e[Ae]})):t}):Se,[Re,y,He,Ae,Se,ze]),dt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Ke},Array.isArray(w)&&{areaGroups:w}),O&&{lineGradient:O}),null!=z&&{hoverRadius:z}),null!=l&&{data:ut}),{xAccessor:g,yAccessor:p,xScaleType:q,yScaleType:X}),Ce&&{yExtent:Ce}),{groupAccessor:"break"===P&&ze?"_gapSegment":Ae||void 0,curve:b,lineStyle:Ue}),x&&{pointStyle:Qe}),{size:[J,Z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:rt,showAxes:a.showAxes,xLabel:ae,yLabel:le,xFormat:d,yFormat:h,enableHover:ee,showGrid:te}),it&&{legend:it,legendPosition:st}),Y&&"none"!==Y&&{legendHoverBehavior:De.onLegendHover,legendClickBehavior:De.onLegendClick,legendHighlightedCategory:De.highlightedCategory,legendIsolatedCategories:De.isolatedCategories}),oe&&{title:oe}),ie&&{description:ie}),re&&{summary:re}),void 0!==se&&{accessibleTable:se}),u&&{className:u}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===S?()=>null:"multi"===S?t=>{var n,o,i,r,s,a,l,c,u,d;const h=t.allSeries;if(!h||0===h.length){const a=null!==(s=null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n.value)&&void 0!==o?o:null===(i=t.data)||void 0===i?void 0:i.y)&&void 0!==r?r:t.value)&&void 0!==s?s:t.y;return e.jsx("div",{className:"semiotic-tooltip",style:$n,children:e.jsx("div",{children:En(a)})})}const g=null!==(d=null!==(c=null!==(a=t.xValue)&&void 0!==a?a:null===(l=t.data)||void 0===l?void 0:l.time)&&void 0!==c?c:null===(u=t.data)||void 0===u?void 0:u.x)&&void 0!==d?d:t.time;return e.jsxs("div",{className:"semiotic-tooltip",style:$n,children:[null!=g&&e.jsx("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:En(g)}),h.map((t,n)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:t.color,flexShrink:0}}),e.jsx("span",{style:{flex:1,fontSize:"0.85em"},children:t.group}),e.jsx("span",{style:{fontWeight:500,fontSize:"0.85em"},children:En(t.value)})]},n))]})}:Gn(S)||lt}),"multi"===S&&{tooltipMode:"multi"}),(I||H||F||R)&&{customHoverBehavior:Pe}),(H||F||I)&&{customClickBehavior:Le}),C&&{pointIdAccessor:C}),((null==M?void 0:M.length)||ye.length||tt.length)&&{annotations:[...M||[],...ye,...tt]}),Te),N);return ce||ue||(ct?e.jsx(Kn,{componentName:"LineChart",message:ct,width:J,height:Z}):e.jsx(jo,{componentName:"LineChart",width:J,height:Z,children:e.jsx(un,Object.assign({ref:s},dt))}))});To.displayName="LineChart";const Io=t.forwardRef(function(n,o){var i;const r=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const s=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",areaBy:p,y0Accessor:f,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:j=!0,lineWidth:A=2,showPoints:O=!1,pointRadius:S=3,tooltip:C,annotations:M,frameProps:_={},selection:P,linkedHover:L,onObservation:B,onClick:N,hoverHighlight:T,chartId:I,loading:H,emptyContent:F,legendInteraction:R,legendPosition:z,color:$,stroke:D,strokeWidth:E,opacity:Y}=n,G=s.width,q=s.height,X=s.enableHover,V=s.showGrid,U=s.showLegend,Q=s.title,K=s.description,J=s.summary,Z=s.accessibleTable,ee=s.xLabel,te=s.yLabel,ne=Co(H,G,q),oe=ne?null:So(a,G,q,F),ie=a||[];Mo("AreaChart",ie,"xAccessor",h),Mo("AreaChart",ie,"yAccessor",g);const{activeSelectionHook:re,hoverSelectionHook:se,customHoverBehavior:ae,customClickBehavior:le,crosshairSourceId:ce}=Nn({selection:P,linkedHover:L,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:B,onClick:N,chartType:"AreaChart",chartId:I,hoverHighlight:T,colorByField:"string"==typeof v?v:void 0}),ue=_o(P),de=Tn(L,ce),he=void 0!==(null===(i=ie[0])||void 0===i?void 0:i[m]),ge=t.useMemo(()=>{if(he)return ie;if(p){const e=ie.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[m]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:ie}]},[ie,p,m,he]),pe=Bn(ie,v,b),fe=t.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of ie){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[ie,v]),ye=Hn(R,v,fe),me=t.useMemo(()=>se||(ye.legendSelectionHook?ye.legendSelectionHook:re),[se,ye.legendSelectionHook,re]),ve=t.useMemo(()=>e=>{const t={};if(v){if(pe){const n=W(e,v,pe);t.fill=n,j?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else{const e=$||Pn;t.fill=e,j?(t.stroke=e,t.strokeWidth=A):t.stroke="none"}return t.fillOpacity=k,t},[v,pe,$,k,j,A]),be=t.useMemo(()=>Wn(ve,{stroke:D,strokeWidth:E,opacity:Y}),[ve,D,E,Y]),xe=t.useMemo(()=>Mn(be,me,ue),[be,me,ue]),ke=t.useMemo(()=>{if(O)return e=>{const t={r:S,fillOpacity:1};return v?pe&&(t.fill=W(e.parentLine||e,v,pe)):t.fill=Pn,t}},[O,S,v,pe]),{legend:we,margin:je,legendPosition:Ae}=In({data:ge,colorBy:v,colorScale:pe,showLegend:U,legendPosition:z,userMargin:l,defaults:s.marginDefaults}),Oe=p||v,Se=t.useMemo(()=>Qn([{label:ee||qn(h),accessor:h,role:"x",format:u},{label:te||qn(g),accessor:g,role:"y",format:d},...Oe?[{label:qn(Oe),accessor:Oe,role:"group"}]:[]]),[h,g,ee,te,Oe,u,d]),Ce=oo({componentName:"AreaChart",data:a,accessors:{xAccessor:h,yAccessor:g}}),Me=t.useMemo(()=>he||p?ge.flatMap(e=>{const t=e[m]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):ie,[ge,m,he,p,ie]),_e=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:Me}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0}),f&&{y0Accessor:f}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:xe}),O&&ke&&{pointStyle:ke}),{size:[G,q],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:je,showAxes:s.showAxes,xLabel:ee,yLabel:te,xFormat:u,yFormat:d,enableHover:X}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),{showGrid:V}),we&&{legend:we,legendPosition:Ae}),R&&"none"!==R&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),Q&&{title:Q}),K&&{description:K}),J&&{summary:J}),void 0!==Z&&{accessibleTable:Z}),c&&{className:c}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===C?()=>null:Gn(C)||Se}),(L||B||N||T)&&{customHoverBehavior:ae}),(B||N||L)&&{customClickBehavior:le}),M&&M.length>0&&{annotations:M}),de),_);return ne||oe||(Ce?e.jsx(Kn,{componentName:"AreaChart",message:Ce,width:G,height:q}):e.jsx(jo,{componentName:"AreaChart",width:G,height:q,children:e.jsx(un,Object.assign({ref:r},_e))}))});function Ho({isPushMode:e,colorBy:n,colorScheme:o,showLegend:i,legendPosition:r="right"}){const s=t.useRef(new Set),a=t.useRef([]),[l,c]=t.useState(0),u=t.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),d=t.useCallback(t=>{if(!e||!n)return;let o=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=u(e);null==t||s.current.has(t)||(s.current.add(t),a.current.push(t),o=!0)}o&&c(e=>e+1)},[e,n,u]),h=t.useCallback(e=>t=>{d([t]),e(t)},[d]),g=t.useCallback(e=>t=>{d(t),e(t)},[d]),p=t.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),f=t.useMemo(()=>{if(!e||!n||!1===i)return;const t=a.current;if(0===t.length)return;const r=Array.isArray(o)?o:R,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],r[e%r.length]);const l="string"==typeof n?n:"__streamCat";return Sn({data:t.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:W})},[e,n,i,o,l]),y=t.useMemo(()=>{if(f)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[f,r]);return{wrapPush:h,wrapPushMany:g,resetCategories:p,streamingLegend:f,streamingMarginAdjust:y}}Io.displayName="AreaChart";const Fo=t.forwardRef(function(n,o){var i;const r=t.useRef(null),s=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",areaBy:p,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:m,curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:j=3,normalize:A=!1,tooltip:O,annotations:S,frameProps:C={},selection:M,linkedHover:_,onObservation:P,onClick:L,hoverHighlight:B,chartId:N,loading:T,emptyContent:I,legendInteraction:H,legendPosition:F,color:R,stroke:z,strokeWidth:$,opacity:D}=n,E=s.width,Y=s.height,G=s.enableHover,q=s.showGrid,X=s.showLegend,V=s.title,U=s.description,Q=s.summary,K=s.accessibleTable,J=s.xLabel,Z=s.yLabel,ee=Co(T,E,Y),te=ee?null:So(a,E,Y,I),ne=a||[],oe=Ho({isPushMode:void 0===a,colorBy:y||p,colorScheme:m,showLegend:X,legendPosition:F}),ie=t.useCallback(oe.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[oe.wrapPush]),re=t.useCallback(oe.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[oe.wrapPushMany]);t.useImperativeHandle(o,()=>({push:ie,pushMany:re,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;oe.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[ie,re,oe.resetCategories]);const{activeSelectionHook:se,hoverSelectionHook:ae,customHoverBehavior:le,customClickBehavior:ce,crosshairSourceId:ue}=Nn({selection:M,linkedHover:_,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:L,chartType:"StackedAreaChart",chartId:N,hoverHighlight:B,colorByField:"string"==typeof y?y:void 0}),de=_o(M),he=Tn(_,ue),ge=void 0!==(null===(i=ne[0])||void 0===i?void 0:i[f]),pe=t.useMemo(()=>{if(ge)return ne;if(p){const e=ne.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[f]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:ne}]},[ne,p,f,ge]),fe=Bn(ne,y,m),ye=t.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of ne){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[ne,y]),me=Hn(H,y,ye),ve=t.useMemo(()=>ae||(me.legendSelectionHook?me.legendSelectionHook:se),[ae,me.legendSelectionHook,se]),be=t.useMemo(()=>e=>{const t={};if(y&&fe){const n=W(e,y,fe);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=R||Pn;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,fe,b,x,k,R]),xe=t.useMemo(()=>Wn(be,{stroke:z,strokeWidth:$,opacity:D}),[be,z,$,D]),ke=t.useMemo(()=>Mn(xe,ve,de),[xe,ve,de]),we=t.useMemo(()=>{if(w)return e=>{const t={r:j,fillOpacity:1};return y?fe&&(t.fill=W(e.parentLine||e,y,fe)):t.fill=R||Pn,t}},[w,j,y,fe,R]),{legend:je,margin:Ae,legendPosition:Oe}=In({data:pe,colorBy:y,colorScale:fe,showLegend:X,legendPosition:F,userMargin:l,defaults:s.marginDefaults}),Se=oe.streamingLegend||je,Ce=F||Oe,Me=t.useMemo(()=>{if(oe.streamingMarginAdjust){const e=Object.assign({},Ae);for(const[t,n]of Object.entries(oe.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return Ae},[Ae,oe.streamingMarginAdjust]),_e=p||y,Pe=t.useMemo(()=>Qn([{label:J||qn(h),accessor:h,role:"x",format:u},{label:Z||qn(g),accessor:g,role:"y",format:d},..._e?[{label:qn(_e),accessor:_e,role:"group"}]:[]]),[h,g,J,Z,_e,u,d]),Le=oo({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:h,yAccessor:g}}),Be=t.useMemo(()=>ge||p?pe.flatMap(e=>{const t=e[f]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):ne,[pe,f,ge,p,ne]),Ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=a&&{data:Be}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0,curve:v,normalize:A,lineStyle:ke}),w&&we&&{pointStyle:we}),{size:[E,Y],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Me,showAxes:s.showAxes,xLabel:J,yLabel:Z,xFormat:u,yFormat:d,enableHover:G}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),{showGrid:q}),Se&&{legend:Se,legendPosition:Ce}),H&&"none"!==H&&{legendHoverBehavior:me.onLegendHover,legendClickBehavior:me.onLegendClick,legendHighlightedCategory:me.highlightedCategory,legendIsolatedCategories:me.isolatedCategories}),V&&{title:V}),U&&{description:U}),Q&&{summary:Q}),void 0!==K&&{accessibleTable:K}),c&&{className:c}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===O?()=>null:Gn(O)||Pe}),(_||P||L||B)&&{customHoverBehavior:le}),(P||L||_)&&{customClickBehavior:ce}),S&&S.length>0&&{annotations:S}),he),C);return ee||te||(Le?e.jsx(Kn,{componentName:"StackedAreaChart",message:Le,width:E,height:Y}):e.jsx(jo,{componentName:"StackedAreaChart",width:E,height:Y,children:e.jsx(un,Object.assign({ref:r},Ne))}))});function Ro(e){const{data:n,rawData:o,colorBy:i,colorScheme:r,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:p,showLegend:f,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:j}=e,A="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:O,hoverSelectionHook:S,customHoverBehavior:C,customClickBehavior:M,crosshairSourceId:_}=Nn({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:p,onClick:v,hoverHighlight:b,colorByField:A}),P=Tn(c,_),L=Bn(n,i,r),B=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of n){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[n,i]),N=Hn(s,i,B),T=t.useMemo(()=>S||(N.legendSelectionHook?N.legendSelectionHook:O),[S,N.legendSelectionHook,O]),I=_o(l),{legend:H,margin:F,legendPosition:R}=In({data:n,colorBy:i,colorScale:L,showLegend:f,legendPosition:a,userMargin:y,defaults:m}),z=t.useMemo(()=>{const e={};return H&&(e.legend=H,e.legendPosition=R),s&&"none"!==s&&(e.legendHoverBehavior=N.onLegendHover,e.legendClickBehavior=N.onLegendClick,e.legendHighlightedCategory=N.highlightedCategory,e.legendIsolatedCategories=N.isolatedCategories),e},[H,R,s,N.onLegendHover,N.onLegendClick,N.highlightedCategory,N.isolatedCategories]),W=Co(x,w,j),$=W?null:So(o,w,j,k);return{colorScale:L,allCategories:B,legendState:N,effectiveSelectionHook:T,activeSelectionHook:O,customHoverBehavior:C,customClickBehavior:M,legend:H,margin:F,legendPosition:R,earlyReturn:W||$||null,legendBehaviorProps:z,crosshairProps:P,resolvedSelection:I}}Fo.displayName="StackedAreaChart";const zo=t.forwardRef(function(n,o){const i=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",colorBy:p,colorScheme:f,sizeBy:y,sizeRange:m=[3,15],pointRadius:v=5,pointOpacity:b=.8,tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:j,frameProps:A={},selection:O,linkedHover:S,linkedBrush:C,onObservation:M,onClick:_,hoverHighlight:P,chartId:L,loading:B,emptyContent:N,legendInteraction:T,legendPosition:I,color:H,stroke:F,strokeWidth:R,opacity:z}=n,$=r.width,E=r.height,Y=r.enableHover,G=r.showGrid,q=r.title,X=r.description,V=r.summary,U=r.accessibleTable,Q=r.xLabel,K=r.yLabel,J=s||[],Z=Ro({data:J,rawData:s,colorBy:p,colorScheme:f,legendInteraction:T,legendPosition:I,selection:O,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:M,onClick:_,hoverHighlight:P,chartType:"Scatterplot",chartId:L,showLegend:r.showLegend,userMargin:a,marginDefaults:r.marginDefaults,loading:B,emptyContent:N,width:$,height:E}),ee=Cn(C),te=kn({name:(null==ee?void 0:ee.name)||"__unused_brush__",xField:(null==ee?void 0:ee.xField)||("string"==typeof d?d:void 0),yField:(null==ee?void 0:ee.yField)||("string"==typeof h?h:void 0)}),ne=ee?"xyBrush"===te.brushInteraction.brush?"xy":"xBrush"===te.brushInteraction.brush?"x":"y":void 0,oe=g.useRef(te.brushInteraction);oe.current=te.brushInteraction;const ie=t.useCallback(e=>{const t=oe.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(Z.earlyReturn)return Z.earlyReturn;Mo("Scatterplot",J,"xAccessor",d),Mo("Scatterplot",J,"yAccessor",h);const re=t.useMemo(()=>{if(!y||0===J.length)return;const e=J.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[J,y]),se=t.useMemo(()=>e=>{const t={fillOpacity:b};return p?Z.colorScale&&(t.fill=W(e,p,Z.colorScale)):t.fill=H||Pn,t.r=y?D(e,y,m,re):v,t},[p,Z.colorScale,y,m,re,v,b,H]),ae=t.useMemo(()=>Wn(se,{stroke:F,strokeWidth:R,opacity:z}),[se,F,R,z]),le=t.useMemo(()=>Mn(ae,Z.effectiveSelectionHook,Z.resolvedSelection),[ae,Z.effectiveSelectionHook,Z.resolvedSelection]),ce=t.useMemo(()=>Qn([{label:Q||qn(d),accessor:d,role:"x",format:c},{label:K||qn(h),accessor:h,role:"y",format:u},...p?[{label:qn(p),accessor:p,role:"color"}]:[],...y?[{label:qn(y),accessor:y,role:"size"}]:[]]),[d,h,Q,K,p,y,c,u]),ue=oo({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(ue)return e.jsx(Kn,{componentName:"Scatterplot",message:ue,width:$,height:E});const de=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:J}),{xAccessor:d,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:y||void 0,sizeRange:m,pointStyle:le,colorScheme:f,size:[$,E],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Z.margin,showAxes:r.showAxes,xLabel:Q,yLabel:K,xFormat:c,yFormat:u,enableHover:Y,showGrid:G}),Z.legendBehaviorProps),q&&{title:q}),X&&{description:X}),V&&{summary:V}),void 0!==U&&{accessibleTable:U}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===x?()=>null:Gn(x)||ce}),(S||M||_||P)&&{customHoverBehavior:Z.customHoverBehavior}),(M||_||S)&&{customClickBehavior:Z.customClickBehavior}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),j&&j.length>0&&{annotations:j}),ee&&{brush:{dimension:ne},onBrush:ie}),Z.crosshairProps),A);return e.jsx(jo,{componentName:"Scatterplot",width:$,height:E,children:e.jsx(un,Object.assign({ref:i},de))})});function Wo(e,t){return s.interpolateViridis(1===t?.5:e/(t-1))}zo.displayName="Scatterplot";const $o=t.forwardRef(function(n,o){var i;const r=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const s=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",orderAccessor:g,orderLabel:p,pointRadius:f=4,tooltip:y,pointIdAccessor:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:O,loading:S,emptyContent:C,legendInteraction:M,stroke:_,strokeWidth:P,opacity:L}=n,B=s.width,N=s.height,T=s.enableHover,I=s.showGrid,H=s.title,F=s.description,R=s.summary,z=s.accessibleTable,W=s.xLabel,$=s.yLabel,D=a||[],{safeData:E,orderMap:Y}=t.useMemo(()=>{const e="function"==typeof d?d:e=>e[d],t="function"==typeof h?h:e=>e[h];let n=D;if(g&&D.length>0){const e="function"==typeof g?g:e=>e[g];n=[...D].sort((t,n)=>{const o=e(t),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})}const o=new WeakMap;let i=0;for(const o of n){const n=e(o),r=t(o);null!=n&&null!=r&&isFinite(n)&&isFinite(r)&&i++}let r=0;for(const s of n){const n=e(s),a=t(s);null!=n&&null!=a&&isFinite(n)&&isFinite(a)&&o.set(s,{idx:r++,total:i})}return{safeData:n,orderMap:o}},[D,g,d,h]);Mo("ConnectedScatterplot",E,"xAccessor",d),Mo("ConnectedScatterplot",E,"yAccessor",h);const{activeSelectionHook:G,hoverSelectionHook:q,customHoverBehavior:X,customClickBehavior:V,crosshairSourceId:U}=Nn({selection:x,linkedHover:k,fallbackFields:[],onObservation:w,onClick:j,chartType:"ConnectedScatterplot",chartId:O,hoverHighlight:A,colorByField:void 0}),Q=_o(x),K=Tn(k,U),J=Hn(M,void 0,[]),Z=t.useMemo(()=>q||(J.legendSelectionHook?J.legendSelectionHook:G),[q,J.legendSelectionHook,G]),ee=null!==(i=null==Q?void 0:Q.unselectedOpacity)&&void 0!==i?i:.5,te=t.useMemo(()=>(e,t)=>{var n,o;const i=t.filter(e=>"point"===e.type);if(2>i.length)return;const r=null==Z?void 0:Z.isActive,s=null==Z?void 0:Z.predicate,a=100>i.length,l=i.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=i[t],u=i[t+1],d=Wo(t,l),h=!r||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=r?h?1:ee:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=f+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=f,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[f,Z,ee]),ne=t.useMemo(()=>[te],[te]),oe=t.useMemo(()=>(t,n,o)=>{var i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return null;const a=s.length,l=100>a,c=[];for(let t=0;a-1>t;t++){const n=s[t],o=s[t+1],u=Wo(t,a),d="number"==typeof(null===(i=n.style)||void 0===i?void 0:i.opacity)?n.style.opacity:1,h="number"==typeof(null===(r=o.style)||void 0===r?void 0:r.opacity)?o.style.opacity:1,g=Math.min(d,h);l&&c.push(e.jsx("line",{x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:f+2,strokeLinecap:"round",opacity:.5*g},"halo-"+t)),c.push(e.jsx("line",{x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:u,strokeWidth:f,strokeLinecap:"round",opacity:g},"seg-"+t))}return e.jsx(e.Fragment,{children:c})},[f]),ie=t.useMemo(()=>[oe],[oe]),re=t.useMemo(()=>e=>{var t,n;const o=Y.get(e),i=null!==(t=null==o?void 0:o.idx)&&void 0!==t?t:0,r=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:r>0?Wo(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[f,Y]),se=t.useMemo(()=>Wn(re,{stroke:_,strokeWidth:P,opacity:L}),[re,_,P,L]),ae=t.useMemo(()=>Mn(se,Z,Q),[se,Z,Q]),le=Object.assign({top:50,right:40,bottom:60,left:70},"number"==typeof n.margin?{top:n.margin,bottom:n.margin,left:n.margin,right:n.margin}:n.margin),ce=p||("string"==typeof g?g:"Order"),ue=t.useMemo(()=>Qn([{label:W||qn(d),accessor:d,role:"x",format:c},{label:$||qn(h),accessor:h,role:"y",format:u},...g?[{label:ce,accessor:g,role:"group"}]:[]]),[d,h,W,$,g,ce,c,u]),de=oo({componentName:"ConnectedScatterplot",data:a,accessors:{xAccessor:d,yAccessor:h}}),he=Co(S,B,N),ge=he?null:So(a,B,N,C),pe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=a&&{data:E}),{xAccessor:d,yAccessor:h,pointStyle:ae,size:[B,N],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:le,showAxes:s.showAxes,xLabel:W,yLabel:$,xFormat:c,yFormat:u,enableHover:T,showGrid:I}),H&&{title:H}),F&&{description:F}),R&&{summary:R}),void 0!==z&&{accessibleTable:z}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===y?()=>null:Gn(y)||ue}),(k||w||j||A)&&{customHoverBehavior:X}),(w||j||k)&&{customClickBehavior:V}),m&&{pointIdAccessor:m}),{canvasPreRenderers:ne,svgPreRenderers:ie}),v&&v.length>0&&{annotations:v}),K),b);return he||ge||(de?e.jsx(Kn,{componentName:"ConnectedScatterplot",message:de,width:B,height:N}):e.jsx(jo,{componentName:"ConnectedScatterplot",width:B,height:N,children:e.jsx(un,Object.assign({ref:r},pe))}))});$o.displayName="ConnectedScatterplot";const Do=t.forwardRef(function(n,o){const i=t.useRef(null),r=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",sizeBy:g,sizeRange:p=[5,40],colorBy:f,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:j,frameProps:A={},selection:O,linkedHover:S,linkedBrush:C,onObservation:M,onClick:_,hoverHighlight:P,chartId:L,loading:B,emptyContent:N,legendInteraction:T,legendPosition:I,color:H,stroke:F,strokeWidth:R,opacity:z}=n,$=r.width,E=r.height,Y=r.enableHover,G=r.showGrid,q=r.showLegend,X=r.title,V=r.description,U=r.summary,Q=r.accessibleTable,K=r.xLabel,J=r.yLabel,Z=Co(B,$,E),ee=Z?null:So(s,$,E,N),te=s||[],ne=void 0===s,oe=t.useRef(null),[ie,re]=t.useState(0),se=t.useCallback(e=>{if(!ne)return;let t=!1;for(const n of e){const e="function"==typeof g?g(n):n[g];null!=e&&isFinite(e)&&(oe.current?(oe.current[0]>e&&(oe.current[0]=e,t=!0),e>oe.current[1]&&(oe.current[1]=e,t=!0)):(oe.current=[e,e],t=!0))}t&&re(e=>e+1)},[ne,g]),ae=Ho({isPushMode:ne,colorBy:f,colorScheme:y,showLegend:q,legendPosition:I}),le=t.useCallback(ae.wrapPush(e=>{var t;se([e]),null===(t=i.current)||void 0===t||t.push(e)}),[ae.wrapPush,se]),ce=t.useCallback(ae.wrapPushMany(e=>{var t;se(e),null===(t=i.current)||void 0===t||t.pushMany(e)}),[ae.wrapPushMany,se]);t.useImperativeHandle(o,()=>({push:le,pushMany:ce,remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;ae.resetCategories(),oe.current=null,re(e=>e+1),null===(e=i.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[le,ce,ae.resetCategories]);const{activeSelectionHook:ue,hoverSelectionHook:de,customHoverBehavior:he,customClickBehavior:ge,crosshairSourceId:pe}=Nn({selection:O,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:M,onClick:_,chartType:"BubbleChart",chartId:L,hoverHighlight:P,colorByField:"string"==typeof f?f:void 0}),fe=_o(O),ye=Tn(S,pe),me=Cn(C);kn({name:(null==me?void 0:me.name)||"__unused_brush__",xField:(null==me?void 0:me.xField)||("string"==typeof d?d:void 0),yField:(null==me?void 0:me.yField)||("string"==typeof h?h:void 0)});const ve=Bn(te,f,y),be=t.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of te){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[te,f]),xe=Hn(T,f,be),ke=t.useMemo(()=>de||(xe.legendSelectionHook?xe.legendSelectionHook:ue),[de,xe.legendSelectionHook,ue]),we=t.useMemo(()=>{if(ne)return oe.current||[0,1];const e=te.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[te,g,ne,ie]),je=t.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return f?ve&&(t.fill=W(e,f,ve)):t.fill=H||Pn,t.r=D(e,g,p,we),t},[f,ve,g,p,we,m,v,b,H]),Ae=t.useMemo(()=>Wn(je,{stroke:F,strokeWidth:R,opacity:z}),[je,F,R,z]),Oe=t.useMemo(()=>Mn(Ae,ke,fe),[Ae,ke,fe]),{legend:Se,margin:Ce,legendPosition:Me}=In({data:te,colorBy:f,colorScale:ve,showLegend:q,legendPosition:I,userMargin:a,defaults:r.marginDefaults}),_e=ae.streamingLegend||Se,Pe=I||Me,Le=t.useMemo(()=>{if(ae.streamingMarginAdjust){const e=Object.assign({},Ce);for(const[t,n]of Object.entries(ae.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return Ce},[Ce,ae.streamingMarginAdjust]),Be=t.useMemo(()=>Qn([{label:K||qn(d),accessor:d,role:"x",format:c},{label:J||qn(h),accessor:h,role:"y",format:u},{label:qn(g),accessor:g,role:"size"},...f?[{label:qn(f),accessor:f,role:"color"}]:[]]),[d,h,K,J,g,f,c,u]),Ne=oo({componentName:"BubbleChart",data:s,accessors:{xAccessor:d,yAccessor:h},requiredProps:{sizeBy:g}});if(Ne)return e.jsx(Kn,{componentName:"BubbleChart",message:Ne,width:$,height:E});const Te=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=s&&{data:te}),{xAccessor:d,yAccessor:h,colorAccessor:f||void 0,sizeAccessor:g,sizeRange:p,pointStyle:Oe,colorScheme:y,size:[$,E],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Le,showAxes:r.showAxes,xLabel:K,yLabel:J,xFormat:c,yFormat:u,enableHover:Y,showGrid:G}),_e&&{legend:_e,legendPosition:Pe}),T&&"none"!==T&&{legendHoverBehavior:xe.onLegendHover,legendClickBehavior:xe.onLegendClick,legendHighlightedCategory:xe.highlightedCategory,legendIsolatedCategories:xe.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==Q&&{accessibleTable:Q}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===x?()=>null:Gn(x)||Be}),(S||M||_||P)&&{customHoverBehavior:he}),(M||_||S)&&{customClickBehavior:ge}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),j&&j.length>0&&{annotations:j}),ye),A);return Z||ee||e.jsx(jo,{componentName:"BubbleChart",width:$,height:E,children:e.jsx(un,Object.assign({ref:i},Te))})});Do.displayName="BubbleChart";const Eo=t.forwardRef(function(n,o){var r;const a=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=a.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=a.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const l=Rn(n.mode,{width:n.width,height:n.height,showGrid:void 0,enableHover:n.enableHover,showLegend:void 0,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:c,margin:u,className:d,xAccessor:h="x",yAccessor:g="y",valueAccessor:p="value",xFormat:f,yFormat:y,colorScheme:m,customColorScale:v,showValues:b=!1,valueFormat:x,tooltip:k,annotations:w,frameProps:j={},selection:A,linkedHover:O,onObservation:S,onClick:C,hoverHighlight:M,chartId:_,loading:P,emptyContent:L,showLegend:B,legendPosition:N,legendInteraction:T}=n,I=l.width,H=l.height,F=l.enableHover,R=l.title,z=l.description,W=l.summary,$=l.accessibleTable,D=l.xLabel,E=l.yLabel,Y=Co(P,I,H),G=Y?null:So(c,I,H,L),q=c||[],X=function(){var e;const t=_n();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),V=null!==(r=null!=m?m:X)&&void 0!==r?r:"blues",U=null!=B&&B,Q=null!=N?N:"right",{margin:K}=In({data:q,colorBy:U?"value":void 0,colorScale:void 0,showLegend:U,legendPosition:Q,userMargin:u,defaults:l.marginDefaults}),{customHoverBehavior:J,customClickBehavior:Z,crosshairSourceId:ee}=Nn({selection:A,linkedHover:O,fallbackFields:[],onObservation:S,onClick:C,chartType:"Heatmap",chartId:_,hoverHighlight:M,colorByField:void 0});_o(A);const te=Tn(O,ee);Hn(T,void 0,[]);const ne=t.useMemo(()=>"function"==typeof p?e=>p(e):e=>e[p],[p]),oe=t.useMemo(()=>{const e=q.map(ne);return[Math.min(...e),Math.max(...e)]},[q,ne]),ie=t.useMemo(()=>"custom"===V&&v?v:i.scaleSequential({blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo}[V]||s.interpolateBlues).domain(oe),[V,v,oe]),re=t.useMemo(()=>Qn([{label:D||qn(h),accessor:h,role:"x",format:f},{label:E||qn(g),accessor:g,role:"y",format:y},{label:qn(p),accessor:p,role:"value",format:x}]),[h,g,D,E,p,f,y,x]),se=oo({componentName:"Heatmap",data:c,accessors:{xAccessor:h,yAccessor:g,valueAccessor:p}}),ae=t.useMemo(()=>{if(U)return{gradient:{colorFn:e=>ie(e),domain:oe,label:"string"==typeof p?p:"value",format:x}}},[U,ie,oe,p,x]),le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=c&&{data:q}),{xAccessor:h,yAccessor:g,valueAccessor:p,colorScheme:"custom"!==V?V:void 0,showValues:b,heatmapValueFormat:x,size:[I,H],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K,showAxes:l.showAxes,xLabel:D,yLabel:E,xFormat:f,yFormat:y,enableHover:F}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),ae&&{legend:ae,legendPosition:Q}),R&&{title:R}),z&&{description:z}),W&&{summary:W}),void 0!==$&&{accessibleTable:$}),d&&{className:d}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===k?()=>null:Gn(k)||re}),(O||S||C||M)&&{customHoverBehavior:J}),(S||C||O)&&{customClickBehavior:Z}),w&&w.length>0&&{annotations:w}),te),j);return Y||G||(se?e.jsx(Kn,{componentName:"Heatmap",message:se,width:I,height:H}):e.jsx(jo,{componentName:"Heatmap",width:I,height:H,children:e.jsx(un,Object.assign({ref:a},le))}))});Eo.displayName="Heatmap";const Yo="__splomIdx",Go={top:4,bottom:4,left:4,right:4};function qo({frameRef:i,cellSize:r,onBrush:s}){const a=t.useRef(null),l=r-Go.left-Go.right,c=r-Go.top-Go.bottom;return t.useEffect(()=>{if(!a.current)return;const e=n.select(a.current).select(".brush-g"),t=o.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const n=null===(t=i.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void s(null);const[[o,r],[a,l]]=e.selection,c=[[n.x.invert(o),n.y.invert(r)],[n.x.invert(a),n.y.invert(l)]];s(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[l,c,i,s]),e.jsx("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0},children:e.jsx("g",{className:"brush-g",transform:`translate(${Go.left},${Go.top})`})})}function Xo({data:n,xField:o,yField:i,cellSize:r,pointRadius:s,pointOpacity:a,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:h,mode:g,onPointHover:p}){const f=t.useRef(null),y=bn({name:u,clientId:`splom-${o}-${i}`}),m=kn({name:u,xField:o,yField:i}),v=bn({name:d,clientId:"splom-hover-source"}),b=v.selectPoints,x=t.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=t.useCallback(e=>{if(!e)return void(null==p||p(null));const t=e.data,n=null==t?void 0:t[Yo];void 0!==n&&(b({[Yo]:[n]}),null==p||p(t,e.x+Go.left,e.y+Go.top))},[b,p]),w=t.useCallback(e=>{const t={opacity:a,r:s};return t.fill=l?W(e,l,c):Pn,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*a):y.isActive&&!y.predicate(e)&&(t.opacity=h),t},[l,c,a,s,g,y.isActive,y.predicate,v.isActive,v.predicate,h]);return e.jsxs("div",{style:{position:"relative",width:r,height:r},children:[e.jsx(un,{ref:f,chartType:"scatter",data:n,size:[r,r],xAccessor:o,yAccessor:i,pointStyle:w,margin:Go,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&e.jsx(qo,{frameRef:f,cellSize:r,xField:o,yField:i,onBrush:x})]})}function Vo({data:n,field:o,label:i,cellSize:r,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=bn({name:c,clientId:"splom-diag-"+o}),g=bn({name:u,clientId:`splom-diag-${o}-hover`}),p="hover"===d?g:h,f=p.isActive,y=p.predicate,m=t.useMemo(()=>{const e=n.map(e=>e[o]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const t=Math.min(...e),i=(Math.max(...e)-t)/s||1,l="string"==typeof a?a:null,c=l?[...new Set(n.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(s).fill(0),h=Array(s).fill(0),g=Array.from({length:s},()=>Array(c.length).fill(0)),p=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of n){const n=e[o];if(null==n||isNaN(n))continue;const r=Math.min(Math.floor((n-t)/i),s-1);if(d[r]++,f&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,f&&!y(e)||p[r][t]++)}}const m=Math.max(...d,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:n,category:c[o]};return n+=i,a})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:n,category:c[o]};return n+=i,a})});return{bars:d.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[n,o,s,r,f,y,a]);return e.jsxs("svg",{width:r,height:r,style:{overflow:"hidden"},children:[e.jsx("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:i}),m.categories.length>0?m.categoryBars.map((t,n)=>t.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Pn,opacity:f?.3:.6},`bg-${n}-${o}`))):m.bars.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Pn,opacity:f?.3:.6},"bg-"+n)),f&&(m.categories.length>0?m.selectedCategoryBars.map((t,n)=>t.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Pn,opacity:.7},`sel-${n}-${o}`))):m.selectedBars.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Pn,opacity:.7},"sel-"+n)))]})}function Uo({label:t,cellSize:n}){return e.jsx("svg",{width:n,height:n,children:e.jsx("text",{x:n/2,y:n/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:t})})}function Qo(n){const{data:o,fields:i,fieldLabels:r={},colorBy:s,colorScheme:a,cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:d=.5,diagonal:h="histogram",histogramBins:p=20,brushMode:f="crossfilter",hoverMode:y=!0,unselectedOpacity:m=.1,showGrid:v=!1,tooltip:b,showLegend:x,idAccessor:k,className:w,onObservation:j,chartId:A}=n,O="splom",S="splom-hover",C=y?"hover":f?"brush":"hover",M=yn(e=>e.clearSelection),[_,P]=t.useState(null),L=t.useCallback(()=>{M(S),P(null)},[M,S]),B=t.useMemo(()=>(o||[]).map((e,t)=>void 0!==e[Yo]?e:Object.assign(Object.assign({},e),{[Yo]:t})),[o]),N=Bn(B,s,a),T=void 0!==x?x:!!s,I=t.useMemo(()=>{if(!T||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(B.map(t=>t[e]))].map(e=>({label:e+"",color:N?N(e+""):Pn})):null},[T,s,B,N]),H=t.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+i.map(()=>l+"px").join(" "),gridTemplateRows:i.map(()=>l+"px").join(" ")+" 40px",gap:c+"px",width:"fit-content"}),[i,l,c,40]);return e.jsxs("div",{className:w,style:{position:"relative"},children:[I&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:I.map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.jsx("span",{style:{fontSize:11},children:t.label})]},t.label))}),e.jsxs("div",{style:H,onMouseLeave:"hover"===C?L:void 0,children:[i.map((t,n)=>e.jsxs(g.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t}),i.map((o,i)=>n===i?"label"===h?e.jsx(Uo,{label:r[t]||t,cellSize:l},"diag-"+t):e.jsx(Vo,{data:B,field:t,label:r[t]||t,cellSize:l,bins:p,colorBy:s,colorScale:N,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:m,mode:C},"diag-"+t):e.jsx(Xo,{data:B,xField:o,yField:t,fieldLabels:r,cellSize:l,pointRadius:u,pointOpacity:d,colorBy:s,colorScale:N,brushSelectionName:O,hoverSelectionName:S,unselectedOpacity:m,showGrid:v,tooltip:b,mode:C,onPointHover:"hover"===C?(e,r,s)=>{e?(P({datum:e,xField:o,yField:t,colIndex:i,rowIndex:n,px:null!=r?r:0,py:null!=s?s:0}),j&&j({type:"hover",datum:e,x:null!=r?r:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(P(null),j&&j({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0},`cell-${t}-${o}`))]},"row-"+t)),e.jsx("div",{})," ",i.map(t=>e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t},"col-label-"+t))]}),_&&"hover"===C&&(()=>{const t=_.datum,n=r[_.xField]||_.xField,o=r[_.yField]||_.yField,i=s?"function"==typeof s?s(t):t[s]:null,a=k?"function"==typeof k?k(t):t[k]:"Row "+t[Yo];return e.jsxs("div",{style:{position:"absolute",left:40+_.colIndex*(l+c)+_.px,top:_.rowIndex*(l+c)+_.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10},children:[e.jsx("div",{style:{fontWeight:"bold",marginBottom:2},children:a+""}),e.jsxs("div",{children:[n,": ",null!=t[_.xField]?Number(t[_.xField]).toFixed(1):"–"]}),e.jsxs("div",{children:[o,": ",null!=t[_.yField]?Number(t[_.yField]).toFixed(1):"–"]}),null!=i&&e.jsxs("div",{style:{opacity:.8},children:["string"==typeof s?s:"group",": ",i+""]})]})})()]})}function Ko(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,i={};return!o&&n&&(i.splom={resolution:n}),o&&(i["splom-hover"]={resolution:"union"}),e.jsx(On,{selections:i,children:e.jsx(Qo,Object.assign({},t))})}function Jo({width:i,height:r,margin:s,scales:a,brushDirection:l,extent:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(!1),p=i+s.left+s.right,f=r+s.top+s.bottom;return t.useEffect(()=>{if(!d.current||!a)return;const e=n.select(d.current).select(".brush-group"),t="x"===l?o.brushX().extent([[0,0],[i,r]]):o.brushY().extent([[0,0],[i,r]]);return t.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void u(null);const n=("x"===l?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];u(o)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,i,r,l,u]),t.useEffect(()=>{if(!h.current||!a||!d.current)return;const e=n.select(d.current).select(".brush-group"),t="x"===l?a.x:a.y;if(g.current=!0,c){const n=[t(c[0]),t(c[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);g.current=!1},[c,a,l]),e.jsx("svg",{ref:d,width:p,height:f,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`})})}function Zo(n){var o,i;const{data:r,width:s=600,height:a=400,margin:l,className:c,title:u,description:d,summary:h,xLabel:g,yLabel:p,xFormat:f,yFormat:y,xAccessor:m="x",yAccessor:v="y",lineBy:b,lineDataAccessor:x="coordinates",colorBy:k,colorScheme:w,curve:j="linear",lineWidth:A=2,fillArea:O=!1,areaOpacity:S=.3,showPoints:C=!1,pointRadius:M=3,enableHover:_=!0,showGrid:P=!1,showLegend:L,legendPosition:B,tooltip:N,minimap:T={},renderBefore:I=!1,onBrush:H,brushExtent:F,frameProps:R={},loading:z,emptyContent:$}=n,D=Co(z,s,a),E=D?null:So(r,s,a,$),Y=r||[],[G,q]=t.useState(null),X=null!=F?F:G,V=t.useCallback(e=>{F||q(e),null==H||H(e)},[F,H]),U=t.useRef(null),[Q,K]=t.useState(null);t.useEffect(()=>{let e=0,t=!1;const n=()=>{var o,i;if(t)return;const r=null===(i=null===(o=U.current)||void 0===o?void 0:o.getScales)||void 0===i?void 0:i.call(o);r?K(r):e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{t=!0,e&&cancelAnimationFrame(e)}},[r]);const J=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[x]),Z=t.useMemo(()=>{if(J)return Y;if(b){const e=Y.reduce((e,t)=>{const n="function"==typeof b?b(t):t[b];if(!e[n]){const t={[x]:[]};"string"==typeof b&&(t[b]=n),e[n]=t}return e[n][x].push(t),e},{});return Object.values(e)}return[{[x]:Y}]},[Y,b,x,J]),ee=t.useMemo(()=>J||b?Z.flatMap(e=>{const t=e[x]||[];return b&&"string"==typeof b?t.map(t=>Object.assign(Object.assign({},t),{[b]:e[b]})):t}):Y,[Z,x,J,b,Y]),te=Bn(Y,k,w),ne=t.useMemo(()=>e=>{const t={strokeWidth:A};return t.stroke=k?W(e,k,te):Pn,O&&(t.fill=t.stroke,t.fillOpacity=S),t},[k,te,A,O,S]),oe=t.useMemo(()=>T.lineStyle?T.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=k?W(e,k,te):Pn,t},[k,te,T.lineStyle]),ie=t.useMemo(()=>{if(C)return e=>{const t={r:M,fillOpacity:1};return t.fill=k?W(e.parentLine||e,k,te):Pn,t}},[C,M,k,te]),{legend:re,margin:se,legendPosition:ae}=In({data:Z,colorBy:k,colorScale:te,showLegend:L,legendPosition:B,userMargin:l}),le=T.height||60,ce=t.useMemo(()=>{var e,t,n,o,i,r,s,a;return{top:null!==(t=null===(e=T.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=T.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(r=null===(i=T.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:se.left,right:null!==(a=null===(s=T.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:se.right}},[T.margin,se]),ue=T.brushDirection||"x",de=oo({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:v}});if(de)return e.jsx(Kn,{componentName:"MinimapChart",message:de,width:s,height:a});const he=O?"area":"line",ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:j,lineStyle:ne},C&&{pointStyle:ie}),{size:[s,a],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:se,showAxes:!0,xLabel:g,yLabel:p,xFormat:f,yFormat:y,enableHover:_,showGrid:P}),re&&{legend:re,legendPosition:ae}),u&&{title:u}),d&&{description:d}),h&&{summary:h}),N&&{tooltipContent:Gn(N)||void 0}),X&&{xExtent:X}),R),pe={chartType:he,data:ee,xAccessor:m,yAccessor:v,groupAccessor:b||void 0,curve:j,lineStyle:oe,size:[s,le+ce.top+ce.bottom],margin:ce,showAxes:null!==(i=T.showAxes)&&void 0!==i&&i,background:T.background,enableHover:!1},fe=e.jsxs("div",{style:{position:"relative",width:s,overflow:"hidden"},children:[e.jsx(un,Object.assign({ref:U},pe)),e.jsx(Jo,{width:s-ce.left-ce.right,height:le,margin:ce,scales:Q,brushDirection:ue,extent:X,onBrush:V})]},"minimap"),ye=e.jsx("div",{style:{overflow:"hidden"},children:e.jsx(un,Object.assign({},ge))},"main");return D||E||e.jsx(jo,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[I?fe:ye,I?ye:fe]})})}Ko.displayName="ScatterplotMatrix",Zo.displayName="MinimapChart";const ei=t.forwardRef(function(n,o){const i=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xCenter:g,yCenter:p,quadrants:f,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:j=5,pointOpacity:A=.8,tooltip:O,pointIdAccessor:S,annotations:C,frameProps:M={},selection:_,linkedHover:P,onObservation:L,onClick:B,hoverHighlight:N,chartId:T,loading:I,emptyContent:H,legendInteraction:F,legendPosition:R,color:z,stroke:$,strokeWidth:E,opacity:Y}=n,G=r.width,q=r.height,X=r.enableHover,V=r.showGrid,U=r.showLegend,Q=r.title,K=r.description,J=r.summary,Z=r.accessibleTable,ee=r.xLabel,te=r.yLabel,ne=Co(I,G,q),oe=ne?null:So(s,G,q,H),ie=s||[];Mo("QuadrantChart",ie,"xAccessor",d),Mo("QuadrantChart",ie,"yAccessor",h);const{activeSelectionHook:re,hoverSelectionHook:se,customHoverBehavior:ae,customClickBehavior:le,crosshairSourceId:ce}=Nn({selection:_,linkedHover:P,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:B,chartType:"QuadrantChart",chartId:T,hoverHighlight:N,colorByField:"string"==typeof b?b:void 0}),ue=_o(_),de=Tn(P,ce),he=Bn(ie,b,x),ge=t.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of ie){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[ie,b]),pe=Hn(F,b,ge),fe=t.useMemo(()=>se||(pe.legendSelectionHook?pe.legendSelectionHook:re),[se,pe.legendSelectionHook,re]),ye=t.useMemo(()=>{if(!ie.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let n=1/0,o=-1/0,i=1/0,r=-1/0;for(const s of ie){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(i>l&&(i=l),l>r&&(r=l))}if(null!=g&&isFinite(g)&&(n>g&&(n=g),g>o&&(o=g)),null!=p&&isFinite(p)&&(i>p&&(i=p),p>r&&(r=p)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(r-i)||1;return{xExtent:[n-s,o+s],yExtent:[i-a,r+a]}},[ie,d,h,g,p]),me=t.useMemo(()=>{if(!k||0===ie.length)return;const e=ie.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[ie,k]),ve=t.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),be=t.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),xe=t.useMemo(()=>e=>{const t={fillOpacity:A};if(b)he&&(t.fill=W(e,b,he));else{const n=ve(e),o=be(e),i=null!=g?n>=g:void 0,r=null!=p?o>=p:void 0;t.fill=void 0===r||void 0===i?z||Pn:r&&i?f.topRight.color:r&&!i?f.topLeft.color:!r&&i?f.bottomRight.color:f.bottomLeft.color}return t.r=k?D(e,k,w,me):j,t},[b,he,k,w,me,j,A,ve,be,g,p,f,z]),ke=t.useMemo(()=>Wn(xe,{stroke:$,strokeWidth:E,opacity:Y}),[xe,$,E,Y]),we=t.useMemo(()=>Mn(ke,fe,ue),[ke,fe,ue]),{legend:je,margin:Ae,legendPosition:Oe}=In({data:ie,colorBy:b,colorScale:he,showLegend:U,legendPosition:R,userMargin:a,defaults:r.marginDefaults}),Se=t.useMemo(()=>{if(!ie.length)return;const e=new Set;"string"==typeof d&&e.add(d),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=ie[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[ie,d,h,b,k]),Ce=t.useMemo(()=>Qn([...Se?[{label:Se,accessor:Se,role:"title"}]:[],{label:ee||qn(d),accessor:d,role:"x",format:c},{label:te||qn(h),accessor:h,role:"y",format:u},...b?[{label:qn(b),accessor:b,role:"color"}]:[],...k?[{label:qn(k),accessor:k,role:"size"}]:[]]),[Se,d,h,ee,te,b,k,c,u]),Me=oo({componentName:"QuadrantChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),_e=t.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,i)=>{var r;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=i.width,a=i.height,l=null!=g?o.x(g):s/2,c=null!=p?o.y(p):a/2;if(null!=g&&!isFinite(l))return;if(null!=p&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:f.topLeft,x:0,y:0,w:u,h:d},{config:f.topRight,x:u,y:0,w:s-u,h:d},{config:f.bottomLeft,x:0,y:d,w:u,h:a-d},{config:f.bottomRight,x:u,y:d,w:s-u,h:a-d}];for(const t of h)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(r=t.config.opacity)&&void 0!==r?r:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,d),e.lineTo(s,d),e.stroke(),e.setLineDash([])}]},[g,p,f,y]),Pe=t.useMemo(()=>m?[..._e,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const i=o.width,r=o.height,s=null!=g?n.x(g):i/2,a=null!=p?n.y(p):r/2;(null==g||isFinite(s))&&(null==p||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=f.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(f.topLeft.label,8,8),e.fillStyle=f.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(f.topRight.label,i-8,8),e.fillStyle=f.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(f.bottomLeft.label,8,r-8),e.fillStyle=f.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(f.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:_e,[_e,m,v,f,g,p]),Le=t.useMemo(()=>{const e=M.canvasPreRenderers||[];return[...Pe,...e]},[Pe,M.canvasPreRenderers]),Be=t.useMemo(()=>{var t;const n={stroke:y.stroke||"#999",strokeWidth:null!==(t=y.strokeWidth)&&void 0!==t?t:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(t,o,i)=>{if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return null;const r=i.width,s=i.height,a=null!=g?o.x(g):r/2,l=null!=p?o.y(p):s/2;if(null!=g&&!isFinite(a))return null;if(null!=p&&!isFinite(l))return null;const c=Math.max(0,Math.min(r,a)),u=Math.max(0,Math.min(s,l));return e.jsxs(e.Fragment,{children:[[{config:f.topLeft,x:0,y:0,w:c,h:u},{config:f.topRight,x:c,y:0,w:r-c,h:u},{config:f.bottomLeft,x:0,y:u,w:c,h:s-u},{config:f.bottomRight,x:c,y:u,w:r-c,h:s-u}].map((t,n)=>{var o;return t.w>0&&t.h>0?e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.config.color,opacity:null!==(o=t.config.opacity)&&void 0!==o?o:.08},"qf-"+n):null}),e.jsx("line",{x1:c,y1:0,x2:c,y2:s,stroke:n.stroke,strokeWidth:n.strokeWidth,strokeDasharray:n.dashArray}),e.jsx("line",{x1:0,y1:u,x2:r,y2:u,stroke:n.stroke,strokeWidth:n.strokeWidth,strokeDasharray:n.dashArray}),m&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:8,y:8+v,fill:f.topLeft.color,fontWeight:600,fontSize:v,opacity:.5,children:f.topLeft.label}),e.jsx("text",{x:r-8,y:8+v,fill:f.topRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end",children:f.topRight.label}),e.jsx("text",{x:8,y:s-8,fill:f.bottomLeft.color,fontWeight:600,fontSize:v,opacity:.5,children:f.bottomLeft.label}),e.jsx("text",{x:r-8,y:s-8,fill:f.bottomRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end",children:f.bottomRight.label})]})]})}]},[g,p,f,y,m,v]),Ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:ie}),{xAccessor:d,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:we,colorScheme:x,size:[G,q],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Ae,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),ye&&{xExtent:ye.xExtent,yExtent:ye.yExtent}),je&&{legend:je,legendPosition:Oe}),F&&"none"!==F&&{legendHoverBehavior:pe.onLegendHover,legendClickBehavior:pe.onLegendClick,legendHighlightedCategory:pe.highlightedCategory,legendIsolatedCategories:pe.isolatedCategories}),Q&&{title:Q}),K&&{description:K}),J&&{summary:J}),void 0!==Z&&{accessibleTable:Z}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?Ce:Gn(O)||Ce}),(P||L||B||N)&&{customHoverBehavior:ae}),(L||B||P)&&{customClickBehavior:le}),S&&{pointIdAccessor:S}),C&&C.length>0&&{annotations:C}),{canvasPreRenderers:Le}),de),M),Le.length>0&&{canvasPreRenderers:Le}),{svgPreRenderers:Be});return ne||oe||(Me?e.jsx(Kn,{componentName:"QuadrantChart",message:Me,width:G,height:q}):e.jsx(jo,{componentName:"QuadrantChart",width:G,height:q,children:e.jsx(un,Object.assign({ref:i},Ne))}))});ei.displayName="QuadrantChart";const ti="__ma_unitized",ni="__ma_series";function oi(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function ii(e,t){return t[0]+e*(t[1]-t[0])}const ri=t.forwardRef(function(n,o){var i,r;const s=t.useRef(null),a=t.useRef([]);t.useImperativeHandle(o,()=>({push:e=>{if(!s.current)return;const t=e;for(let e=0;n.series.length>e&&2>e;e++){const o=n.series[e],i=o.extent||a.current[e];if(!i)continue;const r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(t);null!=r&&isFinite(r)&&s.current.push(Object.assign(Object.assign({},t),{[ti]:oi(r,i),[ni]:o.label||"Series "+(e+1)}))}},pushMany:e=>{if(!s.current)return;const t=[];for(const o of e)for(let e=0;n.series.length>e&&2>e;e++){const i=n.series[e],r=i.extent||a.current[e];if(!r)continue;const s=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(o);null!=s&&isFinite(s)&&t.push(Object.assign(Object.assign({},o),{[ti]:oi(s,r),[ni]:i.label||"Series "+(e+1)}))}s.current.pushMany(t)},remove:e=>{var t,n;return null!==(n=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=s.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const l=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,accessibleTable:n.accessibleTable},{width:800,height:400}),{data:c,margin:u,className:d,xFormat:h,xAccessor:p="x",series:f,colorScheme:y,curve:m="monotoneX",lineWidth:v=2,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:j,onObservation:A,onClick:O,hoverHighlight:S,chartId:C,loading:M,emptyContent:_,legendInteraction:P,legendPosition:L,stroke:B,strokeWidth:N,opacity:T}=n,I=l.width,R=l.height,z=l.enableHover,W=l.showGrid,$=null===(i=l.showLegend)||void 0===i||i,D=l.title,E=l.description,Y=l.summary,G=l.accessibleTable,q=l.xLabel,X=2===f.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||X||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${f.length}. Rendering as a standard multi-line chart.`);const V=Co(M,I,R),U=V?null:So(c,I,R,_),Q=c||[],K=Ln(),J=t.useMemo(()=>{let e;if(Array.isArray(y))e=y;else if(K&&K.length>0)e=K;else{const t=H[y];e=Array.isArray(t)?t:F}return f.map((t,n)=>t.color||e[n%e.length])},[f,y,K]),Z=t.useMemo(()=>f.map((e,t)=>e.label||"Series "+(t+1)),[f]),{unitizedData:ee,extents:te}=t.useMemo(()=>{if(0===Q.length){const e=f.map(e=>e.extent||null).filter(Boolean);return e.length===f.length&&(a.current=e),{unitizedData:[],extents:e.length===f.length?e:[]}}const e=f.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const i="function"==typeof t?t:e=>e[t];for(const t of e){const e=i(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(Q,e.yAccessor));if(a.current=e,!X){const t=[];for(const e of Q)for(let n=0;f.length>n;n++){const o=f[n],i=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=i&&t.push(Object.assign(Object.assign({},e),{[ti]:i,[ni]:Z[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of Q)for(let o=0;2>o;o++){const i=f[o],r=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(n);null!=r&&t.push(Object.assign(Object.assign({},n),{[ti]:oi(r,e[o]),[ni]:Z[o]}))}return{unitizedData:t,extents:e}},[Q,f,X,Z]),ne=t.useMemo(()=>{if(X&&te.length>=2)return[{orient:"left",label:Z[0],tickFormat:f[0].format||(e=>{const t=ii(e,te[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:Z[1],tickFormat:f[1].format||(e=>{const t=ii(e,te[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[X,te,f,Z]),oe=Ro({data:t.useMemo(()=>ee.length>0?ee:Z.map(e=>({[ni]:e})),[ee,Z]),rawData:c,colorBy:ni,colorScheme:J,legendInteraction:P,legendPosition:L,selection:w,linkedHover:j,fallbackFields:[ni],unwrapData:!1,onObservation:A,onClick:O,hoverHighlight:S,chartType:"MultiAxisLineChart",chartId:C,showLegend:$,userMargin:u,marginDefaults:X?Object.assign(Object.assign({},l.marginDefaults),{left:70,right:70}):l.marginDefaults,loading:M,emptyContent:_,width:I,height:R});if(oe.earlyReturn)return oe.earlyReturn;const ie=t.useMemo(()=>{const e=new Map;return Z.forEach((t,n)=>e.set(t,J[n])),t=>({stroke:e.get(t[ni])||J[0],strokeWidth:v,fill:"none"})},[Z,J,v]),re=t.useMemo(()=>Wn(ie,{stroke:B,strokeWidth:N,opacity:T}),[ie,B,N,T]),se=t.useMemo(()=>Mn(re,oe.effectiveSelectionHook,oe.resolvedSelection),[re,oe.effectiveSelectionHook,oe.resolvedSelection]),ae=t.useMemo(()=>{if(!1===b)return()=>null;return Gn(b)||(e=>{var t;const n=e.data||e,o=n[ni],i=Z.indexOf(o),r=n[ti],s=X&&i>=0&&te[i]?ii(r,te[i]):r,a=i>=0&&(null===(t=f[i])||void 0===t?void 0:t.format)?f[i].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof p?p(n):n[p];return g.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},g.createElement("div",{style:{fontWeight:600,marginBottom:4,color:J[i]||"inherit"}},o),g.createElement("div",null,`${"string"==typeof p?p:"x"}: ${l}`),g.createElement("div",null,`${o}: ${a(s)}`))})},[b,Z,J,te,X,f,p]),le=oo({componentName:"MultiAxisLineChart",data:c,accessors:{xAccessor:p}}),ce=X?[0,1]:void 0,ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=c&&{data:ee}),{xAccessor:p,yAccessor:ti,groupAccessor:ni,lineStyle:se,colorScheme:J,size:[I,R],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:oe.margin,showAxes:l.showAxes}),ne&&{axes:ne}),{xLabel:q}),X?{}:{yLabel:Z[0]}),{xFormat:h}),X&&ce&&{yExtent:ce}),{enableHover:z}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),{showGrid:W,curve:m}),oe.legendBehaviorProps),D&&{title:D}),E&&{description:E}),Y&&{summary:Y}),void 0!==G&&{accessibleTable:G}),d&&{className:d}),null!=n.animate&&{animate:n.animate}),{tooltipContent:ae}),x&&{annotations:x}),(j||A||O||S)&&{customHoverBehavior:oe.customHoverBehavior}),(A||O||j)&&{customClickBehavior:oe.customClickBehavior}),oe.crosshairProps),k);return V||U||(le?e.jsx(Kn,{componentName:"MultiAxisLineChart",message:le,width:I,height:R}):e.jsx(jo,{componentName:"MultiAxisLineChart",width:I,height:R,children:e.jsx(un,Object.assign({ref:s},ue))}))});ri.displayName="MultiAxisLineChart";const si=t.forwardRef(function(n,o){const i=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Rn(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",highAccessor:h="high",lowAccessor:g="low",openAccessor:p,closeAccessor:f,candlestickStyle:y,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,chartId:A,loading:O,emptyContent:S}=n,C=r.width,M=r.height,_=r.enableHover,P=r.showGrid,L=r.title,B=r.description,N=r.summary,T=r.accessibleTable,I=r.xLabel,H=r.yLabel,F=Co(O,C,M),R=F?null:So(s,C,M,S),z=s||[],W=null==p||null==f;Mo("CandlestickChart",z,"xAccessor",d),Mo("CandlestickChart",z,"highAccessor",h),Mo("CandlestickChart",z,"lowAccessor",g),W||(Mo("CandlestickChart",z,"openAccessor",p),Mo("CandlestickChart",z,"closeAccessor",f));const{customHoverBehavior:$,customClickBehavior:D,crosshairSourceId:E}=Nn({selection:x,linkedHover:k,onObservation:w,onClick:j,chartType:"CandlestickChart",chartId:A}),Y=Tn(k,E),G=t.useMemo(()=>{const e=r.marginDefaults,t="sparkline"===n.mode?Object.assign(Object.assign({},e),{top:0,bottom:0}):e;return null==a?t:"number"==typeof a?{top:a,bottom:a,left:a,right:a}:Object.assign(Object.assign({},t),a)},[a,r.marginDefaults,n.mode]),q=t.useMemo(()=>{const e=[{label:I||qn(d),accessor:d,role:"x",format:c}];return W?(e.push({label:"High",accessor:h,role:"y",format:u}),e.push({label:"Low",accessor:g,format:u})):(e.push({label:"Open",accessor:p,format:u}),e.push({label:"High",accessor:h,format:u}),e.push({label:"Low",accessor:g,format:u}),e.push({label:"Close",accessor:f,format:u})),Qn(e)},[d,I,c,u,h,g,p,f,W]),X=oo({componentName:"CandlestickChart",data:s,accessors:Object.assign({xAccessor:d,highAccessor:h,lowAccessor:g},!W&&{openAccessor:p,closeAccessor:f})}),V=Math.max(2,Math.min(12,Math.round(C/40))),U=C>200?.1:.02,Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"candlestick"},null!=s&&{data:z}),{xAccessor:d,yAccessor:h,highAccessor:h,lowAccessor:g}),!W&&{openAccessor:p,closeAccessor:f}),y&&{candlestickStyle:y}),{scalePadding:V,extentPadding:U,size:[C,M],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:I,yLabel:H,xFormat:c,yFormat:u,enableHover:_,showGrid:P}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),L&&{title:L}),B&&{description:B}),N&&{summary:N}),void 0!==T&&{accessibleTable:T}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===m?()=>null:Gn(m)||q}),(k||w||j)&&{customHoverBehavior:$}),(w||j||k)&&{customClickBehavior:D}),v&&v.length>0&&{annotations:v}),Y),b);return F||R||(X?e.jsx(Kn,{componentName:"CandlestickChart",message:X,width:C,height:M}):e.jsx(jo,{componentName:"CandlestickChart",width:C,height:M,children:e.jsx(un,Object.assign({ref:i},Q))}))});function ai(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),i=Math.round(parseInt(n[2],16)*(1-t)),r=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function li(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),i=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),r=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}si.displayName="CandlestickChart";const ci="__forecastSegment";function ui(e,t){return"function"==typeof t?t(e):!!e[t]}const di=Object.freeze({__proto__:null,SEGMENT_FIELD:ci,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,i){return(r=o).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,n,o,i){var r,s,a,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:g,color:p="#6366f1",bandOpacity:f=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&ui(e,u)?t="forecast":c&&ui(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[ci]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of b){const n=null!==(r=t[x])&&void 0!==r?r:"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][ci]!==n[e+1][ci]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[ci]:n[e][ci]})),t.push(Object.assign(Object.assign({},n[e]),{[ci]:n[e+1][ci]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][ci]!==b[e+1][ci]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[ci]:b[e][ci]})),k.push(Object.assign(Object.assign({},b[e]),{[ci]:b[e+1][ci]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[ci]&&e.push(Object.assign(Object.assign({},t),{[ci]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const n of k)"function"==typeof h&&(n[e]=h(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:p,fillOpacity:f,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>ui(e,d)};e?(t.style=e,t.r=m):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=y,t.r=m,t.style={stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}),w.push(t)}return i&&w.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(a=i.bandOpacity)&&void 0!==a?a:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:k,annotations:w}}(e,0,0,o,i):function(e,t,n,o,i){var r,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],f=[];for(const n of e)n[t]>l?f.push(Object.assign(Object.assign({},n),{[ci]:"observed"})):p.push(Object.assign(Object.assign({},n),{[ci]:"training"}));const y=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let i=0,r=0,s=0,a=0;for(const[e,t]of y)i+=e,r+=t,s+=e*e,a+=e*t;const l=o*s-i*i;if(Math.abs(l)>1e-12){const s=(o*a-i*r)/l,p=(r-s*i)/o,f=e=>p+s*e,b=y.map(([e,t])=>t-f(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),j=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,A=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),O=Math.max(...A),S=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const i=O+e*S,r=f(i),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(i-k,2)/w:0))*j;v.push({[t]:i,[n]:r,[ci]:"forecast",__forecastUpper:r+s,__forecastLower:r-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&m.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(s=i.bandOpacity)&&void 0!==s?s:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(a=i.anomalyRadius)&&void 0!==a?a:6,label:i.label});const b=[];if(b.push(...p),p.length>0&&f.length>0&&b.push(Object.assign(Object.assign({},p[p.length-1]),{[ci]:"observed"})),b.push(...f),v.length>0){const e=f.length>0?f[f.length-1]:p[p.length-1];e&&b.push(Object.assign(Object.assign({},e),{[ci]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,i);var r},createSegmentLineStyle:function(e,t){var n,o;const i=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",r=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[ci];if("training"===o){let e=n.stroke;return"darken"===c?e=ai(n.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:i}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===o){let e=n.stroke||"#666";return"lighten"===d&&(e=li(e,.4)),Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:void 0})}return"forecast"===o?Object.assign(Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:r}),null!=l&&{strokeOpacity:l}):n}},darkenColor:ai,lightenColor:li});exports.AreaChart=Io,exports.BubbleChart=Do,exports.CandlestickChart=si,exports.ConnectedScatterplot=$o,exports.Heatmap=Eo,exports.LineChart=To,exports.MinimapChart=Zo,exports.MultiAxisLineChart=ri,exports.QuadrantChart=ei,exports.Scatterplot=zo,exports.ScatterplotMatrix=Ko,exports.StackedAreaChart=Fo,exports.StreamXYFrame=un;
|